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 Note that the default for this variable varies according to what system
289 type you're using. On `usg-unix-v' and `xenix' this variable defaults
290 to nil while on all other systems it defaults to t.")
292 (defvar gnus-article-save-directory gnus-directory
293 "*Name of the directory articles will be saved in (default \"~/News\").")
295 (defvar gnus-kill-files-directory gnus-directory
296 "*Name of the directory where kill files will be stored (default \"~/News\").")
298 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
299 "*A function to save articles in your favorite format.
300 The function must be interactively callable (in other words, it must
301 be an Emacs command).
303 Gnus provides the following functions:
305 * gnus-summary-save-in-rmail (Rmail format)
306 * gnus-summary-save-in-mail (Unix mail format)
307 * gnus-summary-save-in-folder (MH folder)
308 * gnus-summary-save-in-file (article format).
309 * gnus-summary-save-in-vm (use VM's folder format).")
311 (defvar gnus-prompt-before-saving 'always
312 "*This variable says how much prompting is to be done when saving articles.
313 If it is nil, no prompting will be done, and the articles will be
314 saved to the default files. If this variable is `always', each and
315 every article that is saved will be preceded by a prompt, even when
316 saving large batches of articles. If this variable is neither nil not
317 `always', there the user will be prompted once for a file name for
318 each invocation of the saving commands.")
320 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
321 "*A function generating a file name to save articles in Rmail format.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
324 (defvar gnus-mail-save-name (function gnus-plain-save-name)
325 "*A function generating a file name to save articles in Unix mail format.
326 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
328 (defvar gnus-folder-save-name (function gnus-folder-save-name)
329 "*A function generating a file name to save articles in MH folder.
330 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
332 (defvar gnus-file-save-name (function gnus-numeric-save-name)
333 "*A function generating a file name to save articles in article format.
334 The function is called with NEWSGROUP, HEADERS, and optional
337 (defvar gnus-split-methods
338 '((gnus-article-archive-name))
339 "*Variable used to suggest where articles are to be saved.
340 For instance, if you would like to save articles related to Gnus in
341 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
342 you could set this variable to something like:
344 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
345 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
347 This variable is an alist where the where the key is the match and the
348 value is a list of possible files to save in if the match is non-nil.
350 If the match is a string, it is used as a regexp match on the
351 article. If the match is a symbol, that symbol will be funcalled
352 from the buffer of the article to be saved with the newsgroup as the
353 parameter. If it is a list, it will be evaled in the same buffer.
355 If this form or function returns a string, this string will be used as
356 a possible file name; and if it returns a non-nil list, that list will
357 be used as possible file names.")
359 (defvar gnus-move-split-methods nil
360 "*Variable used to suggest where articles are to be moved to.
361 It uses the same syntax as the `gnus-split-methods' variable.")
363 (defvar gnus-save-score nil
364 "*If non-nil, save group scoring info.")
366 (defvar gnus-use-adaptive-scoring nil
367 "*If non-nil, use some adaptive scoring scheme.")
369 (defvar gnus-use-cache 'passive
370 "*If nil, Gnus will ignore the article cache.
371 If `passive', it will allow entering (and reading) articles
372 explicitly entered into the cache. If anything else, use the
373 cache to the full extent of the law.")
375 (defvar gnus-use-trees nil
376 "*If non-nil, display a thread tree buffer.")
378 (defvar gnus-use-grouplens nil
379 "*If non-nil, use GroupLens ratings.")
381 (defvar gnus-keep-backlog nil
382 "*If non-nil, Gnus will keep read articles for later re-retrieval.
383 If it is a number N, then Gnus will only keep the last N articles
384 read. If it is neither nil nor a number, Gnus will keep all read
385 articles. This is not a good idea.")
387 (defvar gnus-use-nocem nil
388 "*If non-nil, Gnus will read NoCeM cancel messages.")
390 (defvar gnus-use-demon nil
391 "If non-nil, Gnus might use some demons.")
393 (defvar gnus-use-scoring t
394 "*If non-nil, enable scoring.")
396 (defvar gnus-use-picons nil
397 "*If non-nil, display picons.")
399 (defvar gnus-fetch-old-headers nil
400 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
401 If an unread article in the group refers to an older, already read (or
402 just marked as read) article, the old article will not normally be
403 displayed in the Summary buffer. If this variable is non-nil, Gnus
404 will attempt to grab the headers to the old articles, and thereby
405 build complete threads. If it has the value `some', only enough
406 headers to connect otherwise loose threads will be displayed.
407 This variable can also be a number. In that case, no more than that
408 number of old headers will be fetched.
410 The server has to support NOV for any of this to work.")
413 ;(defvar gnus-visual t
414 ; "*If non-nil, will do various highlighting.
415 ;If nil, no mouse highlights (or any other highlights) will be
416 ;performed. This might speed up Gnus some when generating large group
417 ;and summary buffers.")
419 (defvar gnus-novice-user t
420 "*Non-nil means that you are a usenet novice.
421 If non-nil, verbose messages may be displayed and confirmations may be
424 (defvar gnus-expert-user nil
425 "*Non-nil means that you will never be asked for confirmation about anything.
426 And that means *anything*.")
428 (defvar gnus-verbose 7
429 "*Integer that says how verbose Gnus should be.
430 The higher the number, the more messages Gnus will flash to say what
431 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
432 display most important messages; and at ten, Gnus will keep on
433 jabbering all the time.")
435 (defvar gnus-keep-same-level nil
436 "*Non-nil means that the next newsgroup after the current will be on the same level.
437 When you type, for instance, `n' after reading the last article in the
438 current newsgroup, you will go to the next newsgroup. If this variable
439 is nil, the next newsgroup will be the next from the group
441 If this variable is non-nil, Gnus will either put you in the
442 next newsgroup with the same level, or, if no such newsgroup is
443 available, the next newsgroup with the lowest possible level higher
444 than the current level.
445 If this variable is `best', Gnus will make the next newsgroup the one
446 with the best level.")
448 (defvar gnus-summary-make-false-root 'adopt
449 "*nil means that Gnus won't gather loose threads.
450 If the root of a thread has expired or been read in a previous
451 session, the information necessary to build a complete thread has been
452 lost. Instead of having many small sub-threads from this original thread
453 scattered all over the summary buffer, Gnus can gather them.
455 If non-nil, Gnus will try to gather all loose sub-threads from an
456 original thread into one large thread.
458 If this variable is non-nil, it should be one of `none', `adopt',
461 If this variable is `none', Gnus will not make a false root, but just
462 present the sub-threads after another.
463 If this variable is `dummy', Gnus will create a dummy root that will
464 have all the sub-threads as children.
465 If this variable is `adopt', Gnus will make one of the \"children\"
466 the parent and mark all the step-children as such.
467 If this variable is `empty', the \"children\" are printed with empty
468 subject fields. (Or rather, they will be printed with a string
469 given by the `gnus-summary-same-subject' variable.)")
471 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
472 "*A regexp to match subjects to be excluded from loose thread gathering.
473 As loose thread gathering is done on subjects only, that means that
474 there can be many false gatherings performed. By rooting out certain
475 common subjects, gathering might become saner.")
477 (defvar gnus-summary-gather-subject-limit nil
478 "*Maximum length of subject comparisons when gathering loose threads.
479 Use nil to compare full subjects. Setting this variable to a low
480 number will help gather threads that have been corrupted by
481 newsreaders chopping off subject lines, but it might also mean that
482 unrelated articles that have subject that happen to begin with the
483 same few characters will be incorrectly gathered.
485 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
486 comparing subjects.")
488 (defvar gnus-simplify-ignored-prefixes nil
489 "*Regexp, matches for which are removed from subject lines when simplifying.")
491 (defvar gnus-build-sparse-threads nil
492 "*If non-nil, fill in the gaps in threads.
493 If `some', only fill in the gaps that are needed to tie loose threads
494 together. If `more', fill in all leaf nodes that Gnus can find. If
495 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
497 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
498 "Function used for gathering loose threads.
499 There are two pre-defined functions: `gnus-gather-threads-by-subject',
500 which only takes Subjects into consideration; and
501 `gnus-gather-threads-by-references', which compared the References
502 headers of the articles to find matches.")
504 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
505 (defvar gnus-summary-same-subject ""
506 "*String indicating that the current article has the same subject as the previous.
507 This variable will only be used if the value of
508 `gnus-summary-make-false-root' is `empty'.")
510 (defvar gnus-summary-goto-unread t
511 "*If non-nil, marking commands will go to the next unread article.
512 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
513 whether it is read or not.")
515 (defvar gnus-group-goto-unread t
516 "*If non-nil, movement commands will go to the next unread and subscribed group.")
518 (defvar gnus-goto-next-group-when-activating t
519 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
521 (defvar gnus-check-new-newsgroups t
522 "*Non-nil means that Gnus will add new newsgroups at startup.
523 If this variable is `ask-server', Gnus will ask the server for new
524 groups since the last time it checked. This means that the killed list
525 is no longer necessary, so you could set `gnus-save-killed-list' to
528 A variant is to have this variable be a list of select methods. Gnus
529 will then use the `ask-server' method on all these select methods to
530 query for new groups from all those servers.
533 (setq gnus-check-new-newsgroups
534 '((nntp \"some.server\") (nntp \"other.server\")))
536 If this variable is nil, then you have to tell Gnus explicitly to
537 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
539 (defvar gnus-check-bogus-newsgroups nil
540 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
541 If this variable is nil, then you have to tell Gnus explicitly to
542 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
544 (defvar gnus-read-active-file t
545 "*Non-nil means that Gnus will read the entire active file at startup.
546 If this variable is nil, Gnus will only know about the groups in your
549 If this variable is `some', Gnus will try to only read the relevant
550 parts of the active file from the server. Not all servers support
551 this, and it might be quite slow with other servers, but this should
552 generally be faster than both the t and nil value.
554 If you set this variable to nil or `some', you probably still want to
555 be told about new newsgroups that arrive. To do that, set
556 `gnus-check-new-newsgroups' to `ask-server'. This may not work
557 properly with all servers.")
559 (defvar gnus-level-subscribed 5
560 "*Groups with levels less than or equal to this variable are subscribed.")
562 (defvar gnus-level-unsubscribed 7
563 "*Groups with levels less than or equal to this variable are unsubscribed.
564 Groups with levels less than `gnus-level-subscribed', which should be
565 less than this variable, are subscribed.")
567 (defvar gnus-level-zombie 8
568 "*Groups with this level are zombie groups.")
570 (defvar gnus-level-killed 9
571 "*Groups with this level are killed.")
573 (defvar gnus-level-default-subscribed 3
574 "*New subscribed groups will be subscribed at this level.")
576 (defvar gnus-level-default-unsubscribed 6
577 "*New unsubscribed groups will be unsubscribed at this level.")
579 (defvar gnus-activate-level (1+ gnus-level-subscribed)
580 "*Groups higher than this level won't be activated on startup.
581 Setting this variable to something log might save lots of time when
582 you have many groups that you aren't interested in.")
584 (defvar gnus-activate-foreign-newsgroups 4
585 "*If nil, Gnus will not check foreign newsgroups at startup.
586 If it is non-nil, it should be a number between one and nine. Foreign
587 newsgroups that have a level lower or equal to this number will be
588 activated on startup. For instance, if you want to active all
589 subscribed newsgroups, but not the rest, you'd set this variable to
590 `gnus-level-subscribed'.
592 If you subscribe to lots of newsgroups from different servers, startup
593 might take a while. By setting this variable to nil, you'll save time,
594 but you won't be told how many unread articles there are in the
597 (defvar gnus-save-newsrc-file t
598 "*Non-nil means that Gnus will save the `.newsrc' file.
599 Gnus always saves its own startup file, which is called
600 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
601 be readily understood by other newsreaders. If you don't plan on
602 using other newsreaders, set this variable to nil to save some time on
605 (defvar gnus-save-killed-list t
606 "*If non-nil, save the list of killed groups to the startup file.
607 If you set this variable to nil, you'll save both time (when starting
608 and quitting) and space (both memory and disk), but it will also mean
609 that Gnus has no record of which groups are new and which are old, so
610 the automatic new newsgroups subscription methods become meaningless.
612 You should always set `gnus-check-new-newsgroups' to `ask-server' or
613 nil if you set this variable to nil.")
615 (defvar gnus-interactive-catchup t
616 "*If non-nil, require your confirmation when catching up a group.")
618 (defvar gnus-interactive-exit t
619 "*If non-nil, require your confirmation when exiting Gnus.")
621 (defvar gnus-kill-killed t
622 "*If non-nil, Gnus will apply kill files to already killed articles.
623 If it is nil, Gnus will never apply kill files to articles that have
624 already been through the scoring process, which might very well save lots
627 (defvar gnus-extract-address-components 'gnus-extract-address-components
628 "*Function for extracting address components from a From header.
629 Two pre-defined function exist: `gnus-extract-address-components',
630 which is the default, quite fast, and too simplistic solution, and
631 `mail-extract-address-components', which works much better, but is
634 (defvar gnus-summary-default-score 0
635 "*Default article score level.
636 If this variable is nil, scoring will be disabled.")
638 (defvar gnus-summary-zcore-fuzz 0
639 "*Fuzziness factor for the zcore in the summary buffer.
640 Articles with scores closer than this to `gnus-summary-default-score'
641 will not be marked.")
643 (defvar gnus-simplify-subject-fuzzy-regexp nil
644 "*Strings to be removed when doing fuzzy matches.
645 This can either be a regular expression or list of regular expressions
646 that will be removed from subject strings if fuzzy subject
647 simplification is selected.")
649 (defvar gnus-permanently-visible-groups nil
650 "*Regexp to match groups that should always be listed in the group buffer.
651 This means that they will still be listed when there are no unread
652 articles in the groups.")
654 (defvar gnus-list-groups-with-ticked-articles t
655 "*If non-nil, list groups that have only ticked articles.
656 If nil, only list groups that have unread articles.")
658 (defvar gnus-group-default-list-level gnus-level-subscribed
659 "*Default listing level.
660 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
662 (defvar gnus-group-use-permanent-levels nil
663 "*If non-nil, once you set a level, Gnus will use this level.")
665 (defvar gnus-group-list-inactive-groups t
666 "*If non-nil, inactive groups will be listed.")
668 (defvar gnus-show-mime nil
669 "*If non-nil, do mime processing of articles.
670 The articles will simply be fed to the function given by
671 `gnus-show-mime-method'.")
673 (defvar gnus-strict-mime t
674 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
676 (defvar gnus-show-mime-method 'metamail-buffer
677 "*Function to process a MIME message.
678 The function is called from the article buffer.")
680 (defvar gnus-decode-encoded-word-method (lambda ())
681 "*Function to decode a MIME encoded-words.
682 The function is called from the article buffer.")
684 (defvar gnus-show-threads t
685 "*If non-nil, display threads in summary mode.")
687 (defvar gnus-thread-hide-subtree nil
688 "*If non-nil, hide all threads initially.
689 If threads are hidden, you have to run the command
690 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
691 to expose hidden threads.")
693 (defvar gnus-thread-hide-killed t
694 "*If non-nil, hide killed threads automatically.")
696 (defvar gnus-thread-ignore-subject nil
697 "*If non-nil, ignore subjects and do all threading based on the Reference header.
698 If nil, which is the default, articles that have different subjects
699 from their parents will start separate threads.")
701 (defvar gnus-thread-operation-ignore-subject t
702 "*If non-nil, subjects will be ignored when doing thread commands.
703 This affects commands like `gnus-summary-kill-thread' and
704 `gnus-summary-lower-thread'.
706 If this variable is nil, articles in the same thread with different
707 subjects will not be included in the operation in question. If this
708 variable is `fuzzy', only articles that have subjects that are fuzzily
709 equal will be included.")
711 (defvar gnus-thread-indent-level 4
712 "*Number that says how much each sub-thread should be indented.")
714 (defvar gnus-ignored-newsgroups
715 (purecopy (mapconcat 'identity
716 '("^to\\." ; not "real" groups
717 "^[0-9. \t]+ " ; all digits in name
718 "[][\"#'()]" ; bogus characters
721 "*A regexp to match uninteresting newsgroups in the active file.
722 Any lines in the active file matching this regular expression are
723 removed from the newsgroup list before anything else is done to it,
724 thus making them effectively non-existent.")
726 (defvar gnus-ignored-headers
727 "^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:"
728 "*All headers that match this regexp will be hidden.
729 This variable can also be a list of regexps of headers to be ignored.
730 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
732 (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-"
733 "*All headers that do not match this regexp will be hidden.
734 This variable can also be a list of regexp of headers to remain visible.
735 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
737 (defvar gnus-sorted-header-list
738 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
739 "^Cc:" "^Date:" "^Organization:")
740 "*This variable is a list of regular expressions.
741 If it is non-nil, headers that match the regular expressions will
742 be placed first in the article buffer in the sequence specified by
745 (defvar gnus-boring-article-headers
746 '(empty followup-to reply-to)
747 "*Headers that are only to be displayed if they have interesting data.
748 Possible values in this list are `empty', `newsgroups', `followup-to',
749 `reply-to', and `date'.")
751 (defvar gnus-show-all-headers nil
752 "*If non-nil, don't hide any headers.")
754 (defvar gnus-save-all-headers t
755 "*If non-nil, don't remove any headers before saving.")
757 (defvar gnus-saved-headers gnus-visible-headers
758 "*Headers to keep if `gnus-save-all-headers' is nil.
759 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
760 If that variable is nil, however, all headers that match this regexp
761 will be kept while the rest will be deleted before saving.")
763 (defvar gnus-inhibit-startup-message nil
764 "*If non-nil, the startup message will not be displayed.")
766 (defvar gnus-signature-separator "^-- *$"
767 "Regexp matching signature separator.")
769 (defvar gnus-signature-limit nil
770 "Provide a limit to what is considered a signature.
771 If it is a number, no signature may not be longer (in characters) than
772 that number. If it is a function, the function will be called without
773 any parameters, and if it returns nil, there is no signature in the
774 buffer. If it is a string, it will be used as a regexp. If it
775 matches, the text in question is not a signature.")
777 (defvar gnus-auto-extend-newsgroup t
778 "*If non-nil, extend newsgroup forward and backward when requested.")
780 (defvar gnus-auto-select-first t
781 "*If nil, don't select the first unread article when entering a group.
782 If this variable is `best', select the highest-scored unread article
783 in the group. If neither nil nor `best', select the first unread
786 If you want to prevent automatic selection of the first unread article
787 in some newsgroups, set the variable to nil in
788 `gnus-select-group-hook'.")
790 (defvar gnus-auto-select-next t
791 "*If non-nil, offer to go to the next group from the end of the previous.
792 If the value is t and the next newsgroup is empty, Gnus will exit
793 summary mode and go back to group mode. If the value is neither nil
794 nor t, Gnus will select the following unread newsgroup. In
795 particular, if the value is the symbol `quietly', the next unread
796 newsgroup will be selected without any confirmation, and if it is
797 `almost-quietly', the next group will be selected without any
798 confirmation if you are located on the last article in the group.
799 Finally, if this variable is `slightly-quietly', the `Z n' command
800 will go to the next group without confirmation.")
802 (defvar gnus-auto-select-same nil
803 "*If non-nil, select the next article with the same subject.")
805 (defvar gnus-summary-check-current nil
806 "*If non-nil, consider the current article when moving.
807 The \"unread\" movement commands will stay on the same line if the
808 current article is unread.")
810 (defvar gnus-auto-center-summary t
811 "*If non-nil, always center the current summary buffer.
812 In particular, if `vertical' do only vertical recentering. If non-nil
813 and non-`vertical', do both horizontal and vertical recentering.")
815 (defvar gnus-break-pages t
816 "*If non-nil, do page breaking on articles.
817 The page delimiter is specified by the `gnus-page-delimiter'
820 (defvar gnus-page-delimiter "^\^L"
821 "*Regexp describing what to use as article page delimiters.
822 The default value is \"^\^L\", which is a form linefeed at the
823 beginning of a line.")
825 (defvar gnus-use-full-window t
826 "*If non-nil, use the entire Emacs screen.")
828 (defvar gnus-window-configuration nil
829 "Obsolete variable. See `gnus-buffer-configuration'.")
831 (defvar gnus-window-min-width 2
832 "*Minimum width of Gnus buffers.")
834 (defvar gnus-window-min-height 1
835 "*Minimum height of Gnus buffers.")
837 (defvar gnus-buffer-configuration
841 (if gnus-carpal '(group-carpal 4))))
845 (if gnus-carpal '(summary-carpal 4))))
852 (if gnus-carpal '(summary-carpal 4))
854 (vertical ((height . 5) (width . 15)
856 (left . -1) (top . 1))
866 (if gnus-carpal '(summary-carpal 4))
867 (if gnus-use-trees '(tree 0.25))
872 (if gnus-carpal '(server-carpal 2))))
876 (if gnus-carpal '(browse-carpal 2))))
879 (message 1.0 point)))
882 (article 1.0 point)))
893 (edit-group 1.0 point)))
897 (edit-server 1.0 point)))
901 (edit-score 1.0 point)))
908 (message 1.0 point)))
911 (message 1.0 point)))
914 (message 1.0 point)))
918 (message 1.0 point)))
925 (if gnus-carpal '(summary-carpal 4))
926 ("*Shell Command Output*" 1.0)))
929 ("*Gnus Help Bug*" 0.5)
930 ("*Gnus Bug*" 1.0 point)))
934 (message 1.0 point))))
935 "Window configuration for all possible Gnus buffers.
936 This variable is a list of lists. Each of these lists has a NAME and
937 a RULE. The NAMEs are commonsense names like `group', which names a
938 rule used when displaying the group buffer; `summary', which names a
939 rule for what happens when you enter a group and do not display an
940 article buffer; and so on. See the value of this variable for a
941 complete list of NAMEs.
943 Each RULE is a list of vectors. The first element in this vector is
944 the name of the buffer to be displayed; the second element is the
945 percentage of the screen this buffer is to occupy (a number in the
946 0.0-0.99 range); the optional third element is `point', which should
947 be present to denote which buffer point is to go to after making this
948 buffer configuration.")
950 (defvar gnus-window-to-buffer
951 '((group . gnus-group-buffer)
952 (summary . gnus-summary-buffer)
953 (article . gnus-article-buffer)
954 (server . gnus-server-buffer)
955 (browse . "*Gnus Browse Server*")
956 (edit-group . gnus-group-edit-buffer)
957 (edit-server . gnus-server-edit-buffer)
958 (group-carpal . gnus-carpal-group-buffer)
959 (summary-carpal . gnus-carpal-summary-buffer)
960 (server-carpal . gnus-carpal-server-buffer)
961 (browse-carpal . gnus-carpal-browse-buffer)
962 (edit-score . gnus-score-edit-buffer)
963 (message . gnus-message-buffer)
964 (mail . gnus-message-buffer)
965 (post-news . gnus-message-buffer)
966 (faq . gnus-faq-buffer)
967 (picons . "*Picons*")
968 (tree . gnus-tree-buffer)
969 (info . gnus-info-buffer)
970 (article-copy . gnus-article-copy)
971 (draft . gnus-draft-buffer))
972 "Mapping from short symbols to buffer names or buffer variables.")
974 (defvar gnus-carpal nil
975 "*If non-nil, display clickable icons.")
977 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
978 "*Function called with a group name when new group is detected.
979 A few pre-made functions are supplied: `gnus-subscribe-randomly'
980 inserts new groups at the beginning of the list of groups;
981 `gnus-subscribe-alphabetically' inserts new groups in strict
982 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
983 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
984 for your decision; `gnus-subscribe-killed' kills all new groups;
985 `gnus-subscribe-zombies' will make all new groups into zombies.")
987 ;; Suggested by a bug report by Hallvard B Furuseth.
988 ;; <h.b.furuseth@usit.uio.no>.
989 (defvar gnus-subscribe-options-newsgroup-method
990 (function gnus-subscribe-alphabetically)
991 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
992 If, for instance, you want to subscribe to all newsgroups in the
993 \"no\" and \"alt\" hierarchies, you'd put the following in your
996 options -n no.all alt.all
998 Gnus will the subscribe all new newsgroups in these hierarchies with
999 the subscription method in this variable.")
1001 (defvar gnus-subscribe-hierarchical-interactive nil
1002 "*If non-nil, Gnus will offer to subscribe hierarchically.
1003 When a new hierarchy appears, Gnus will ask the user:
1005 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1007 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1008 subscribe to all newsgroups in the hierarchy and `s' will skip this
1009 hierarchy in its entirety.")
1011 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1012 "*Function used for sorting the group buffer.
1013 This function will be called with group info entries as the arguments
1014 for the groups to be sorted. Pre-made functions include
1015 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1016 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1017 `gnus-group-sort-by-rank'.
1019 This variable can also be a list of sorting functions. In that case,
1020 the most significant sort function should be the last function in the
1023 ;; Mark variables suggested by Thomas Michanek
1024 ;; <Thomas.Michanek@telelogic.se>.
1025 (defvar gnus-unread-mark ?
1026 "*Mark used for unread articles.")
1027 (defvar gnus-ticked-mark ?!
1028 "*Mark used for ticked articles.")
1029 (defvar gnus-dormant-mark ??
1030 "*Mark used for dormant articles.")
1031 (defvar gnus-del-mark ?r
1032 "*Mark used for del'd articles.")
1033 (defvar gnus-read-mark ?R
1034 "*Mark used for read articles.")
1035 (defvar gnus-expirable-mark ?E
1036 "*Mark used for expirable articles.")
1037 (defvar gnus-killed-mark ?K
1038 "*Mark used for killed articles.")
1039 (defvar gnus-souped-mark ?F
1040 "*Mark used for killed articles.")
1041 (defvar gnus-kill-file-mark ?X
1042 "*Mark used for articles killed by kill files.")
1043 (defvar gnus-low-score-mark ?Y
1044 "*Mark used for articles with a low score.")
1045 (defvar gnus-catchup-mark ?C
1046 "*Mark used for articles that are caught up.")
1047 (defvar gnus-replied-mark ?A
1048 "*Mark used for articles that have been replied to.")
1049 (defvar gnus-cached-mark ?*
1050 "*Mark used for articles that are in the cache.")
1051 (defvar gnus-saved-mark ?S
1052 "*Mark used for articles that have been saved to.")
1053 (defvar gnus-process-mark ?#
1055 (defvar gnus-ancient-mark ?O
1056 "*Mark used for ancient articles.")
1057 (defvar gnus-sparse-mark ?Q
1058 "*Mark used for sparsely reffed articles.")
1059 (defvar gnus-canceled-mark ?G
1060 "*Mark used for canceled articles.")
1061 (defvar gnus-score-over-mark ?+
1062 "*Score mark used for articles with high scores.")
1063 (defvar gnus-score-below-mark ?-
1064 "*Score mark used for articles with low scores.")
1065 (defvar gnus-empty-thread-mark ?
1066 "*There is no thread under the article.")
1067 (defvar gnus-not-empty-thread-mark ?=
1068 "*There is a thread under the article.")
1070 (defvar gnus-view-pseudo-asynchronously nil
1071 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1073 (defvar gnus-view-pseudos nil
1074 "*If `automatic', pseudo-articles will be viewed automatically.
1075 If `not-confirm', pseudos will be viewed automatically, and the user
1076 will not be asked to confirm the command.")
1078 (defvar gnus-view-pseudos-separately t
1079 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1080 If nil, all files that use the same viewing command will be given as a
1081 list of parameters to that command.")
1083 (defvar gnus-insert-pseudo-articles t
1084 "*If non-nil, insert pseudo-articles when decoding articles.")
1086 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1087 "*Format of group lines.
1088 It works along the same lines as a normal formatting string,
1089 with some simple extensions.
1091 %M Only marked articles (character, \"*\" or \" \")
1092 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1093 %L Level of subscribedness (integer)
1094 %N Number of unread articles (integer)
1095 %I Number of dormant articles (integer)
1096 %i Number of ticked and dormant (integer)
1097 %T Number of ticked articles (integer)
1098 %R Number of read articles (integer)
1099 %t Total number of articles (integer)
1100 %y Number of unread, unticked articles (integer)
1101 %G Group name (string)
1102 %g Qualified group name (string)
1103 %D Group description (string)
1104 %s Select method (string)
1105 %o Moderated group (char, \"m\")
1106 %p Process mark (char)
1107 %O Moderated group (string, \"(m)\" or \"\")
1108 %P Topic indentation (string)
1109 %l Whether there are GroupLens predictions for this group (string)
1110 %n Select from where (string)
1111 %z A string that look like `<%s:%n>' if a foreign select method is used
1112 %u User defined specifier. The next character in the format string should
1113 be a letter. Gnus will call the function gnus-user-format-function-X,
1114 where X is the letter following %u. The function will be passed the
1115 current header as argument. The function should return a string, which
1116 will be inserted into the buffer just like information from any other
1119 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1120 the mouse point move inside the area. There can only be one such area.
1122 Note that this format specification is not always respected. For
1123 reasons of efficiency, when listing killed groups, this specification
1124 is ignored altogether. If the spec is changed considerably, your
1125 output may end up looking strange when listing both alive and killed
1128 If you use %o or %O, reading the active file will be slower and quite
1129 a bit of extra memory will be used. %D will also worsen performance.
1130 Also note that if you change the format specification to include any
1131 of these specs, you must probably re-start Gnus to see them go into
1134 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1135 "*The format specification of the lines in the summary buffer.
1137 It works along the same lines as a normal formatting string,
1138 with some simple extensions.
1140 %N Article number, left padded with spaces (string)
1142 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1143 %n Name of the poster (string)
1144 %a Extracted name of the poster (string)
1145 %A Extracted address of the poster (string)
1146 %F Contents of the From: header (string)
1147 %x Contents of the Xref: header (string)
1148 %D Date of the article (string)
1149 %d Date of the article (string) in DD-MMM format
1150 %M Message-id of the article (string)
1151 %r References of the article (string)
1152 %c Number of characters in the article (integer)
1153 %L Number of lines in the article (integer)
1154 %I Indentation based on thread level (a string of spaces)
1155 %T A string with two possible values: 80 spaces if the article
1156 is on thread level two or larger and 0 spaces on level one
1157 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1158 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1159 %[ Opening bracket (character, \"[\" or \"<\")
1160 %] Closing bracket (character, \"]\" or \">\")
1161 %> Spaces of length thread-level (string)
1162 %< Spaces of length (- 20 thread-level) (string)
1163 %i Article score (number)
1164 %z Article zcore (character)
1165 %t Number of articles under the current thread (number).
1166 %e Whether the thread is empty or not (character).
1167 %l GroupLens score (string).
1168 %u User defined specifier. The next character in the format string should
1169 be a letter. Gnus will call the function gnus-user-format-function-X,
1170 where X is the letter following %u. The function will be passed the
1171 current header as argument. The function should return a string, which
1172 will be inserted into the summary just like information from any other
1175 Text between %( and %) will be highlighted with `gnus-mouse-face'
1176 when the mouse point is placed inside the area. There can only be one
1179 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1180 with care. For reasons of efficiency, Gnus will compute what column
1181 these characters will end up in, and \"hard-code\" that. This means that
1182 it is illegal to have these specs after a variable-length spec. Well,
1183 you might not be arrested, but your summary buffer will look strange,
1184 which is bad enough.
1186 The smart choice is to have these specs as for to the left as
1189 This restriction may disappear in later versions of Gnus.")
1191 (defvar gnus-summary-dummy-line-format
1193 "*The format specification for the dummy roots in the summary buffer.
1194 It works along the same lines as a normal formatting string,
1195 with some simple extensions.
1199 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1200 "*The format specification for the summary mode line.
1201 It works along the same lines as a normal formatting string,
1202 with some simple extensions:
1205 %p Unprefixed group name
1206 %A Current article number
1208 %U Number of unread articles in the group
1209 %e Number of unselected articles in the group
1210 %Z A string with unread/unselected article counts
1211 %g Shortish group name
1212 %S Subject of the current article
1213 %u User-defined spec
1214 %s Current score file name
1215 %d Number of dormant articles
1216 %r Number of articles that have been marked as read in this session
1217 %E Number of articles expunged by the score files")
1219 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1220 "*The format specification for the article mode line.
1221 See `gnus-summary-mode-line-format' for a closer description.")
1223 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1224 "*The format specification for the group mode line.
1225 It works along the same lines as a normal formatting string,
1226 with some simple extensions:
1228 %S The native news server.
1229 %M The native select method.
1230 %: \":\" if %S isn't \"\".")
1232 (defvar gnus-valid-select-methods
1233 '(("nntp" post address prompt-address)
1234 ("nnspool" post address)
1235 ("nnvirtual" post-mail virtual prompt-address)
1236 ("nnmbox" mail respool address)
1237 ("nnml" mail respool address)
1238 ("nnmh" mail respool address)
1239 ("nndir" post-mail prompt-address address)
1240 ("nneething" none address prompt-address)
1241 ("nndoc" none address prompt-address)
1242 ("nnbabyl" mail address respool)
1243 ("nnkiboze" post address virtual)
1244 ("nnsoup" post-mail address)
1245 ("nndraft" post-mail)
1246 ("nnfolder" mail respool address))
1247 "An alist of valid select methods.
1248 The first element of each list lists should be a string with the name
1249 of the select method. The other elements may be be the category of
1250 this method (ie. `post', `mail', `none' or whatever) or other
1251 properties that this method has (like being respoolable).
1252 If you implement a new select method, all you should have to change is
1253 this variable. I think.")
1255 (defvar gnus-updated-mode-lines '(group article summary tree)
1256 "*List of buffers that should update their mode lines.
1257 The list may contain the symbols `group', `article' and `summary'. If
1258 the corresponding symbol is present, Gnus will keep that mode line
1259 updated with information that may be pertinent.
1260 If this variable is nil, screen refresh may be quicker.")
1262 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1263 (defvar gnus-mode-non-string-length nil
1264 "*Max length of mode-line non-string contents.
1265 If this is nil, Gnus will take space as is needed, leaving the rest
1266 of the modeline intact.")
1269 ;(defvar gnus-mouse-face 'highlight
1270 ; "*Face used for mouse highlighting in Gnus.
1271 ;No mouse highlights will be done if `gnus-visual' is nil.")
1273 (defvar gnus-summary-mark-below 0
1274 "*Mark all articles with a score below this variable as read.
1275 This variable is local to each summary buffer and usually set by the
1278 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1279 "*List of functions used for sorting articles in the summary buffer.
1280 This variable is only used when not using a threaded display.")
1282 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1283 "*List of functions used for sorting threads in the summary buffer.
1284 By default, threads are sorted by article number.
1286 Each function takes two threads and return non-nil if the first thread
1287 should be sorted before the other. If you use more than one function,
1288 the primary sort function should be the last. You should probably
1289 always include `gnus-thread-sort-by-number' in the list of sorting
1290 functions -- preferably first.
1292 Ready-mady functions include `gnus-thread-sort-by-number',
1293 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1294 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1295 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1297 (defvar gnus-thread-score-function '+
1298 "*Function used for calculating the total score of a thread.
1300 The function is called with the scores of the article and each
1301 subthread and should then return the score of the thread.
1303 Some functions you can use are `+', `max', or `min'.")
1305 (defvar gnus-summary-expunge-below nil
1306 "All articles that have a score less than this variable will be expunged.")
1308 (defvar gnus-thread-expunge-below nil
1309 "All threads that have a total score less than this variable will be expunged.
1310 See `gnus-thread-score-function' for en explanation of what a
1311 \"thread score\" is.")
1313 (defvar gnus-auto-subscribed-groups
1314 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1315 "*All new groups that match this regexp will be subscribed automatically.
1316 Note that this variable only deals with new groups. It has no effect
1317 whatsoever on old groups.")
1319 (defvar gnus-options-subscribe nil
1320 "*All new groups matching this regexp will be subscribed unconditionally.
1321 Note that this variable deals only with new newsgroups. This variable
1322 does not affect old newsgroups.")
1324 (defvar gnus-options-not-subscribe nil
1325 "*All new groups matching this regexp will be ignored.
1326 Note that this variable deals only with new newsgroups. This variable
1327 does not affect old (already subscribed) newsgroups.")
1329 (defvar gnus-auto-expirable-newsgroups nil
1330 "*Groups in which to automatically mark read articles as expirable.
1331 If non-nil, this should be a regexp that should match all groups in
1332 which to perform auto-expiry. This only makes sense for mail groups.")
1334 (defvar gnus-total-expirable-newsgroups nil
1335 "*Groups in which to perform expiry of all read articles.
1336 Use with extreme caution. All groups that match this regexp will be
1337 expiring - which means that all read articles will be deleted after
1338 (say) one week. (This only goes for mail groups and the like, of
1341 (defvar gnus-group-uncollapsed-levels 1
1342 "Number of group name elements to leave alone when making a short group name.")
1344 (defvar gnus-hidden-properties '(invisible t intangible t)
1345 "Property list to use for hiding text.")
1347 (defvar gnus-modtime-botch nil
1348 "*Non-nil means .newsrc should be deleted prior to save.
1349 Its use is due to the bogus appearance that .newsrc was modified on
1354 (defvar gnus-group-mode-hook nil
1355 "*A hook for Gnus group mode.")
1357 (defvar gnus-summary-mode-hook nil
1358 "*A hook for Gnus summary mode.
1359 This hook is run before any variables are set in the summary buffer.")
1361 (defvar gnus-article-mode-hook nil
1362 "*A hook for Gnus article mode.")
1364 (defvar gnus-summary-prepare-exit-hook nil
1365 "*A hook called when preparing to exit from the summary buffer.
1366 It calls `gnus-summary-expire-articles' by default.")
1367 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1369 (defvar gnus-summary-exit-hook nil
1370 "*A hook called on exit from the summary buffer.")
1372 (defvar gnus-group-catchup-group-hook nil
1373 "*A hook run when catching up a group from the group buffer.")
1375 (defvar gnus-group-update-group-hook nil
1376 "*A hook called when updating group lines.")
1378 (defvar gnus-open-server-hook nil
1379 "*A hook called just before opening connection to the news server.")
1381 (defvar gnus-load-hook nil
1382 "*A hook run while Gnus is loaded.")
1384 (defvar gnus-startup-hook nil
1385 "*A hook called at startup.
1386 This hook is called after Gnus is connected to the NNTP server.")
1388 (defvar gnus-get-new-news-hook nil
1389 "*A hook run just before Gnus checks for new news.")
1391 (defvar gnus-after-getting-new-news-hook nil
1392 "*A hook run after Gnus checks for new news.")
1394 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1395 "*A function that is called to generate the group buffer.
1396 The function is called with three arguments: The first is a number;
1397 all group with a level less or equal to that number should be listed,
1398 if the second is non-nil, empty groups should also be displayed. If
1399 the third is non-nil, it is a number. No groups with a level lower
1400 than this number should be displayed.
1402 The only current function implemented is `gnus-group-prepare-flat'.")
1404 (defvar gnus-group-prepare-hook nil
1405 "*A hook called after the group buffer has been generated.
1406 If you want to modify the group buffer, you can use this hook.")
1408 (defvar gnus-summary-prepare-hook nil
1409 "*A hook called after the summary buffer has been generated.
1410 If you want to modify the summary buffer, you can use this hook.")
1412 (defvar gnus-summary-generate-hook nil
1413 "*A hook run just before generating the summary buffer.
1414 This hook is commonly used to customize threading variables and the
1417 (defvar gnus-article-prepare-hook nil
1418 "*A hook called after an article has been prepared in the article buffer.
1419 If you want to run a special decoding program like nkf, use this hook.")
1421 ;(defvar gnus-article-display-hook nil
1422 ; "*A hook called after the article is displayed in the article buffer.
1423 ;The hook is designed to change the contents of the article
1424 ;buffer. Typical functions that this hook may contain are
1425 ;`gnus-article-hide-headers' (hide selected headers),
1426 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1427 ;`gnus-article-hide-signature' (hide signature) and
1428 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1429 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1430 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1431 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1433 (defvar gnus-article-x-face-too-ugly nil
1434 "Regexp matching posters whose face shouldn't be shown automatically.")
1436 (defvar gnus-select-group-hook nil
1437 "*A hook called when a newsgroup is selected.
1439 If you'd like to simplify subjects like the
1440 `gnus-summary-next-same-subject' command does, you can use the
1443 (setq gnus-select-group-hook
1446 (mapcar (lambda (header)
1447 (mail-header-set-subject
1449 (gnus-simplify-subject
1450 (mail-header-subject header) 're-only)))
1451 gnus-newsgroup-headers))))")
1453 (defvar gnus-select-article-hook nil
1454 "*A hook called when an article is selected.")
1456 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1457 "*A hook called to apply kill files to a group.
1458 This hook is intended to apply a kill file to the selected newsgroup.
1459 The function `gnus-apply-kill-file' is called by default.
1461 Since a general kill file is too heavy to use only for a few
1462 newsgroups, I recommend you to use a lighter hook function. For
1463 example, if you'd like to apply a kill file to articles which contains
1464 a string `rmgroup' in subject in newsgroup `control', you can use the
1467 (setq gnus-apply-kill-hook
1470 (cond ((string-match \"control\" gnus-newsgroup-name)
1471 (gnus-kill \"Subject\" \"rmgroup\")
1472 (gnus-expunge \"X\"))))))")
1474 (defvar gnus-visual-mark-article-hook
1475 (list 'gnus-highlight-selected-summary)
1476 "*Hook run after selecting an article in the summary buffer.
1477 It is meant to be used for highlighting the article in some way. It
1478 is not run if `gnus-visual' is nil.")
1480 (defvar gnus-parse-headers-hook nil
1481 "*A hook called before parsing the headers.")
1482 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1484 (defvar gnus-exit-group-hook nil
1485 "*A hook called when exiting (not quitting) summary mode.")
1487 (defvar gnus-suspend-gnus-hook nil
1488 "*A hook called when suspending (not exiting) Gnus.")
1490 (defvar gnus-exit-gnus-hook nil
1491 "*A hook called when exiting Gnus.")
1493 (defvar gnus-after-exiting-gnus-hook nil
1494 "*A hook called after exiting Gnus.")
1496 (defvar gnus-save-newsrc-hook nil
1497 "*A hook called before saving any of the newsrc files.")
1499 (defvar gnus-save-quick-newsrc-hook nil
1500 "*A hook called just before saving the quick newsrc file.
1501 Can be used to turn version control on or off.")
1503 (defvar gnus-save-standard-newsrc-hook nil
1504 "*A hook called just before saving the standard newsrc file.
1505 Can be used to turn version control on or off.")
1507 (defvar gnus-summary-update-hook
1508 (list 'gnus-summary-highlight-line)
1509 "*A hook called when a summary line is changed.
1510 The hook will not be called if `gnus-visual' is nil.
1512 The default function `gnus-summary-highlight-line' will
1513 highlight the line according to the `gnus-summary-highlight'
1516 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1517 "*A hook called when a group line is changed.
1518 The hook will not be called if `gnus-visual' is nil.
1520 The default function `gnus-group-highlight-line' will
1521 highlight the line according to the `gnus-group-highlight'
1524 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1525 "*A hook called when an article is selected for the first time.
1526 The hook is intended to mark an article as read (or unread)
1527 automatically when it is selected.")
1529 (defvar gnus-group-change-level-function nil
1530 "Function run when a group level is changed.
1531 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1533 ;; Remove any hilit infestation.
1534 (add-hook 'gnus-startup-hook
1536 (remove-hook 'gnus-summary-prepare-hook
1537 'hilit-rehighlight-buffer-quietly)
1538 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1539 (setq gnus-mark-article-hook
1540 '(gnus-summary-mark-read-and-unread-as-read))
1541 (remove-hook 'gnus-article-prepare-hook
1542 'hilit-rehighlight-buffer-quietly)))
1545 ;; Internal variables
1547 (defvar gnus-tree-buffer "*Tree*"
1548 "Buffer where Gnus thread trees are displayed.")
1551 (defvar gnus-use-generic-from nil)
1553 (defvar gnus-thread-indent-array nil)
1554 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1556 (defvar gnus-newsrc-file-version nil)
1558 (defvar gnus-method-history nil)
1559 ;; Variable holding the user answers to all method prompts.
1561 (defvar gnus-group-history nil)
1562 ;; Variable holding the user answers to all group prompts.
1564 (defvar gnus-server-alist nil
1565 "List of available servers.")
1567 (defvar gnus-group-indentation-function nil)
1569 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1571 (defvar gnus-goto-missing-group-function nil)
1573 (defvar gnus-override-subscribe-method nil)
1575 (defvar gnus-group-goto-next-group-function nil
1576 "Function to override finding the next group after listing groups.")
1578 (defconst gnus-article-mark-lists
1579 '((marked . tick) (replied . reply)
1580 (expirable . expire) (killed . killed)
1581 (bookmarks . bookmark) (dormant . dormant)
1582 (scored . score) (saved . save)
1586 ;; Avoid highlighting in kill files.
1587 (defvar gnus-summary-inhibit-highlight nil)
1588 (defvar gnus-newsgroup-selected-overlay nil)
1590 (defvar gnus-inhibit-hiding nil)
1591 (defvar gnus-group-indentation "")
1592 (defvar gnus-inhibit-limiting nil)
1593 (defvar gnus-created-frames nil)
1595 (defvar gnus-article-mode-map nil)
1596 (defvar gnus-dribble-buffer nil)
1597 (defvar gnus-headers-retrieved-by nil)
1598 (defvar gnus-article-reply nil)
1599 (defvar gnus-override-method nil)
1600 (defvar gnus-article-check-size nil)
1602 (defvar gnus-current-score-file nil)
1603 (defvar gnus-newsgroup-adaptive-score-file nil)
1604 (defvar gnus-scores-exclude-files nil)
1606 (defvar gnus-opened-servers nil)
1608 (defvar gnus-current-move-group nil)
1609 (defvar gnus-current-copy-group nil)
1610 (defvar gnus-current-crosspost-group nil)
1612 (defvar gnus-newsgroup-dependencies nil)
1613 (defvar gnus-newsgroup-async nil)
1614 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1616 (defvar gnus-newsgroup-adaptive nil)
1618 (defvar gnus-summary-display-table nil)
1619 (defvar gnus-summary-display-article-function nil)
1621 (defvar gnus-summary-highlight-line-function nil
1622 "Function called after highlighting a summary line.")
1624 (defvar gnus-group-line-format-alist
1625 `((?M gnus-tmp-marked-mark ?c)
1626 (?S gnus-tmp-subscribed ?c)
1627 (?L gnus-tmp-level ?d)
1628 (?N (cond ((eq number t) "*" )
1632 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1633 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1635 (?R gnus-tmp-number-of-read ?s)
1636 (?t gnus-tmp-number-total ?d)
1637 (?y gnus-tmp-number-of-unread ?s)
1638 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1639 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1640 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1641 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1642 (?g gnus-tmp-group ?s)
1643 (?G gnus-tmp-qualified-group ?s)
1644 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1645 (?D gnus-tmp-newsgroup-description ?s)
1646 (?o gnus-tmp-moderated ?c)
1647 (?O gnus-tmp-moderated-string ?s)
1648 (?p gnus-tmp-process-marked ?c)
1649 (?s gnus-tmp-news-server ?s)
1650 (?n gnus-tmp-news-method ?s)
1651 (?P gnus-group-indentation ?s)
1652 (?l gnus-tmp-grouplens ?s)
1653 (?z gnus-tmp-news-method-string ?s)
1654 (?u gnus-tmp-user-defined ?s)))
1656 (defvar gnus-summary-line-format-alist
1657 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1658 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1659 (?s gnus-tmp-subject-or-nil ?s)
1660 (?n gnus-tmp-name ?s)
1661 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1663 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1665 (?F gnus-tmp-from ?s)
1666 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1667 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1668 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1669 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1670 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1671 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1672 (?L gnus-tmp-lines ?d)
1673 (?I gnus-tmp-indentation ?s)
1674 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1675 (?R gnus-tmp-replied ?c)
1676 (?\[ gnus-tmp-opening-bracket ?c)
1677 (?\] gnus-tmp-closing-bracket ?c)
1678 (?\> (make-string gnus-tmp-level ? ) ?s)
1679 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1680 (?i gnus-tmp-score ?d)
1681 (?z gnus-tmp-score-char ?c)
1682 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1683 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1684 (?U gnus-tmp-unread ?c)
1685 (?t (gnus-summary-number-of-articles-in-thread
1686 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1688 (?e (gnus-summary-number-of-articles-in-thread
1689 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1691 (?u gnus-tmp-user-defined ?s))
1692 "An alist of format specifications that can appear in summary lines,
1693 and what variables they correspond with, along with the type of the
1694 variable (string, integer, character, etc).")
1696 (defvar gnus-summary-dummy-line-format-alist
1697 `((?S gnus-tmp-subject ?s)
1698 (?N gnus-tmp-number ?d)
1699 (?u gnus-tmp-user-defined ?s)))
1701 (defvar gnus-summary-mode-line-format-alist
1702 `((?G gnus-tmp-group-name ?s)
1703 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1704 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1705 (?A gnus-tmp-article-number ?d)
1706 (?Z gnus-tmp-unread-and-unselected ?s)
1707 (?V gnus-version ?s)
1708 (?U gnus-tmp-unread ?d)
1709 (?S gnus-tmp-subject ?s)
1710 (?e gnus-tmp-unselected ?d)
1711 (?u gnus-tmp-user-defined ?s)
1712 (?d (length gnus-newsgroup-dormant) ?d)
1713 (?t (length gnus-newsgroup-marked) ?d)
1714 (?r (length gnus-newsgroup-reads) ?d)
1715 (?E gnus-newsgroup-expunged-tally ?d)
1716 (?s (gnus-current-score-file-nondirectory) ?s)))
1718 (defvar gnus-article-mode-line-format-alist
1719 gnus-summary-mode-line-format-alist)
1721 (defvar gnus-group-mode-line-format-alist
1722 `((?S gnus-tmp-news-server ?s)
1723 (?M gnus-tmp-news-method ?s)
1724 (?u gnus-tmp-user-defined ?s)
1725 (?: gnus-tmp-colon ?s)))
1727 (defvar gnus-have-read-active-file nil)
1729 (defconst gnus-maintainer
1730 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1731 "The mail address of the Gnus maintainers.")
1733 (defconst gnus-version-number "5.2.16"
1734 "Version number for this version of Gnus.")
1736 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1737 "Version string for this version of Gnus.")
1739 (defvar gnus-info-nodes
1740 '((gnus-group-mode "(gnus)The Group Buffer")
1741 (gnus-summary-mode "(gnus)The Summary Buffer")
1742 (gnus-article-mode "(gnus)The Article Buffer"))
1743 "Alist of major modes and related Info nodes.")
1745 (defvar gnus-group-buffer "*Group*")
1746 (defvar gnus-summary-buffer "*Summary*")
1747 (defvar gnus-article-buffer "*Article*")
1748 (defvar gnus-server-buffer "*Server*")
1750 (defvar gnus-work-buffer " *gnus work*")
1752 (defvar gnus-original-article-buffer " *Original Article*")
1753 (defvar gnus-original-article nil)
1755 (defvar gnus-buffer-list nil
1756 "Gnus buffers that should be killed on exit.")
1758 (defvar gnus-slave nil
1759 "Whether this Gnus is a slave or not.")
1761 (defvar gnus-variable-list
1762 '(gnus-newsrc-options gnus-newsrc-options-n
1763 gnus-newsrc-last-checked-date
1764 gnus-newsrc-alist gnus-server-alist
1765 gnus-killed-list gnus-zombie-list
1766 gnus-topic-topology gnus-topic-alist
1768 "Gnus variables saved in the quick startup file.")
1770 (defvar gnus-newsrc-options nil
1771 "Options line in the .newsrc file.")
1773 (defvar gnus-newsrc-options-n nil
1774 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1776 (defvar gnus-newsrc-last-checked-date nil
1777 "Date Gnus last asked server for new newsgroups.")
1779 (defvar gnus-topic-topology nil
1780 "The complete topic hierarchy.")
1782 (defvar gnus-topic-alist nil
1783 "The complete topic-group alist.")
1785 (defvar gnus-newsrc-alist nil
1786 "Assoc list of read articles.
1787 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1789 (defvar gnus-newsrc-hashtb nil
1790 "Hashtable of gnus-newsrc-alist.")
1792 (defvar gnus-killed-list nil
1793 "List of killed newsgroups.")
1795 (defvar gnus-killed-hashtb nil
1796 "Hash table equivalent of gnus-killed-list.")
1798 (defvar gnus-zombie-list nil
1799 "List of almost dead newsgroups.")
1801 (defvar gnus-description-hashtb nil
1802 "Descriptions of newsgroups.")
1804 (defvar gnus-list-of-killed-groups nil
1805 "List of newsgroups that have recently been killed by the user.")
1807 (defvar gnus-active-hashtb nil
1808 "Hashtable of active articles.")
1810 (defvar gnus-moderated-list nil
1811 "List of moderated newsgroups.")
1813 (defvar gnus-group-marked nil)
1815 (defvar gnus-current-startup-file nil
1816 "Startup file for the current host.")
1818 (defvar gnus-last-search-regexp nil
1819 "Default regexp for article search command.")
1821 (defvar gnus-last-shell-command nil
1822 "Default shell command on article.")
1824 (defvar gnus-current-select-method nil
1825 "The current method for selecting a newsgroup.")
1827 (defvar gnus-group-list-mode nil)
1829 (defvar gnus-article-internal-prepare-hook nil)
1831 (defvar gnus-newsgroup-name nil)
1832 (defvar gnus-newsgroup-begin nil)
1833 (defvar gnus-newsgroup-end nil)
1834 (defvar gnus-newsgroup-last-rmail nil)
1835 (defvar gnus-newsgroup-last-mail nil)
1836 (defvar gnus-newsgroup-last-folder nil)
1837 (defvar gnus-newsgroup-last-file nil)
1838 (defvar gnus-newsgroup-auto-expire nil)
1839 (defvar gnus-newsgroup-active nil)
1841 (defvar gnus-newsgroup-data nil)
1842 (defvar gnus-newsgroup-data-reverse nil)
1843 (defvar gnus-newsgroup-limit nil)
1844 (defvar gnus-newsgroup-limits nil)
1846 (defvar gnus-newsgroup-unreads nil
1847 "List of unread articles in the current newsgroup.")
1849 (defvar gnus-newsgroup-unselected nil
1850 "List of unselected unread articles in the current newsgroup.")
1852 (defvar gnus-newsgroup-reads nil
1853 "Alist of read articles and article marks in the current newsgroup.")
1855 (defvar gnus-newsgroup-expunged-tally nil)
1857 (defvar gnus-newsgroup-marked nil
1858 "List of ticked articles in the current newsgroup (a subset of unread art).")
1860 (defvar gnus-newsgroup-killed nil
1861 "List of ranges of articles that have been through the scoring process.")
1863 (defvar gnus-newsgroup-cached nil
1864 "List of articles that come from the article cache.")
1866 (defvar gnus-newsgroup-saved nil
1867 "List of articles that have been saved.")
1869 (defvar gnus-newsgroup-kill-headers nil)
1871 (defvar gnus-newsgroup-replied nil
1872 "List of articles that have been replied to in the current newsgroup.")
1874 (defvar gnus-newsgroup-expirable nil
1875 "List of articles in the current newsgroup that can be expired.")
1877 (defvar gnus-newsgroup-processable nil
1878 "List of articles in the current newsgroup that can be processed.")
1880 (defvar gnus-newsgroup-bookmarks nil
1881 "List of articles in the current newsgroup that have bookmarks.")
1883 (defvar gnus-newsgroup-dormant nil
1884 "List of dormant articles in the current newsgroup.")
1886 (defvar gnus-newsgroup-scored nil
1887 "List of scored articles in the current newsgroup.")
1889 (defvar gnus-newsgroup-headers nil
1890 "List of article headers in the current newsgroup.")
1892 (defvar gnus-newsgroup-threads nil)
1894 (defvar gnus-newsgroup-prepared nil
1895 "Whether the current group has been prepared properly.")
1897 (defvar gnus-newsgroup-ancient nil
1898 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1900 (defvar gnus-newsgroup-sparse nil)
1902 (defvar gnus-current-article nil)
1903 (defvar gnus-article-current nil)
1904 (defvar gnus-current-headers nil)
1905 (defvar gnus-have-all-headers nil)
1906 (defvar gnus-last-article nil)
1907 (defvar gnus-newsgroup-history nil)
1908 (defvar gnus-current-kill-article nil)
1910 ;; Save window configuration.
1911 (defvar gnus-prev-winconf nil)
1913 (defvar gnus-summary-mark-positions nil)
1914 (defvar gnus-group-mark-positions nil)
1916 (defvar gnus-reffed-article-number nil)
1918 ;;; Let the byte-compiler know that we know about this variable.
1919 (defvar rmail-default-rmail-file)
1921 (defvar gnus-cache-removable-articles nil)
1923 (defvar gnus-dead-summary nil)
1925 (defconst gnus-summary-local-variables
1926 '(gnus-newsgroup-name
1927 gnus-newsgroup-begin gnus-newsgroup-end
1928 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1929 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1930 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1931 gnus-newsgroup-unselected gnus-newsgroup-marked
1932 gnus-newsgroup-reads gnus-newsgroup-saved
1933 gnus-newsgroup-replied gnus-newsgroup-expirable
1934 gnus-newsgroup-processable gnus-newsgroup-killed
1935 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1936 gnus-newsgroup-headers gnus-newsgroup-threads
1937 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1938 gnus-current-article gnus-current-headers gnus-have-all-headers
1939 gnus-last-article gnus-article-internal-prepare-hook
1940 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1941 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1942 gnus-newsgroup-async gnus-thread-expunge-below
1943 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1944 (gnus-summary-mark-below . global)
1945 gnus-newsgroup-active gnus-scores-exclude-files
1946 gnus-newsgroup-history gnus-newsgroup-ancient
1947 gnus-newsgroup-sparse
1948 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1949 gnus-newsgroup-adaptive-score-file
1950 (gnus-newsgroup-expunged-tally . 0)
1951 gnus-cache-removable-articles gnus-newsgroup-cached
1952 gnus-newsgroup-data gnus-newsgroup-data-reverse
1953 gnus-newsgroup-limit gnus-newsgroup-limits)
1954 "Variables that are buffer-local to the summary buffers.")
1956 (defconst gnus-bug-message
1957 "Sending a bug report to the Gnus Towers.
1958 ========================================
1960 The buffer below is a mail buffer. When you press `C-c C-c', it will
1961 be sent to the Gnus Bug Exterminators.
1963 At the bottom of the buffer you'll see lots of variable settings.
1964 Please do not delete those. They will tell the Bug People what your
1965 environment is, so that it will be easier to locate the bugs.
1967 If you have found a bug that makes Emacs go \"beep\", set
1968 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1969 and include the backtrace in your bug report.
1971 Please describe the bug in annoying, painstaking detail.
1973 Thank you for your help in stamping out bugs.
1976 ;;; End of variables.
1978 ;; Define some autoload functions Gnus might use.
1981 ;; This little mapcar goes through the list below and marks the
1982 ;; symbols in question as autoloaded functions.
1985 (let ((interactive (nth 1 (memq ':interactive package))))
1989 (when (consp function)
1990 (setq keymap (car (memq 'keymap function)))
1991 (setq function (car function)))
1992 (autoload function (car package) nil interactive keymap)))
1993 (if (eq (nth 1 package) ':interactive)
1996 '(("metamail" metamail-buffer)
1997 ("info" Info-goto-node)
1998 ("hexl" hexl-hex-string-to-integer)
1999 ("pp" pp pp-to-string pp-eval-expression)
2000 ("mail-extr" mail-extract-address-components)
2001 ("nnmail" nnmail-split-fancy nnmail-article-group)
2002 ("nnvirtual" nnvirtual-catchup-group)
2003 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2004 timezone-make-sortable-date timezone-make-time-string)
2005 ("rmailout" rmail-output)
2006 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2008 ("gnus-soup" :interactive t
2009 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2010 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2011 ("nnsoup" nnsoup-pack-replies)
2012 ("gnus-scomo" :interactive t gnus-score-mode)
2013 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2014 gnus-Folder-save-name gnus-folder-save-name)
2015 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2016 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2017 gnus-server-make-menu-bar gnus-article-make-menu-bar
2018 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2019 gnus-summary-highlight-line gnus-carpal-setup-buffer
2020 gnus-group-highlight-line
2021 gnus-article-add-button gnus-insert-next-page-button
2022 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2023 ("gnus-vis" :interactive t
2024 gnus-article-push-button gnus-article-press-button
2025 gnus-article-highlight gnus-article-highlight-some
2026 gnus-article-highlight-headers gnus-article-highlight-signature
2027 gnus-article-add-buttons gnus-article-add-buttons-to-head
2028 gnus-article-next-button gnus-article-prev-button)
2029 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2030 gnus-demon-add-disconnection gnus-demon-add-handler
2031 gnus-demon-remove-handler)
2032 ("gnus-demon" :interactive t
2033 gnus-demon-init gnus-demon-cancel)
2034 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2035 gnus-tree-open gnus-tree-close)
2036 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2037 gnus-nocem-unwanted-article-p)
2038 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2039 ("gnus-srvr" gnus-browse-foreign-server)
2040 ("gnus-cite" :interactive t
2041 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2042 gnus-article-hide-citation gnus-article-fill-cited-article
2043 gnus-article-hide-citation-in-followups)
2044 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2045 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2046 gnus-execute gnus-expunge)
2047 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2048 gnus-cache-possibly-remove-articles gnus-cache-request-article
2049 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2050 gnus-cache-enter-remove-article gnus-cached-article-p
2051 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2052 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2053 gnus-cache-remove-article)
2054 ("gnus-score" :interactive t
2055 gnus-summary-increase-score gnus-summary-lower-score
2056 gnus-score-flush-cache gnus-score-close
2057 gnus-score-raise-same-subject-and-select
2058 gnus-score-raise-same-subject gnus-score-default
2059 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2060 gnus-score-lower-same-subject gnus-score-lower-thread
2061 gnus-possibly-score-headers gnus-summary-raise-score
2062 gnus-summary-set-score gnus-summary-current-score)
2064 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2065 gnus-current-score-file-nondirectory gnus-score-adaptive
2066 gnus-score-find-trace gnus-score-file-name)
2067 ("gnus-edit" :interactive t gnus-score-customize)
2068 ("gnus-topic" :interactive t gnus-topic-mode)
2069 ("gnus-topic" gnus-topic-remove-group)
2070 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2071 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2072 ("gnus-uu" :interactive t
2073 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2074 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2075 gnus-uu-mark-by-regexp gnus-uu-mark-all
2076 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2077 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2078 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2079 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2080 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2081 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2082 gnus-uu-decode-binhex-view)
2083 ("gnus-msg" (gnus-summary-send-map keymap)
2084 gnus-mail-yank-original gnus-mail-send-and-exit
2085 gnus-article-mail gnus-new-mail gnus-mail-reply)
2086 ("gnus-msg" :interactive t
2087 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2088 gnus-summary-followup gnus-summary-followup-with-original
2089 gnus-summary-cancel-article gnus-summary-supersede-article
2090 gnus-post-news gnus-inews-news
2091 gnus-summary-reply gnus-summary-reply-with-original
2092 gnus-summary-mail-forward gnus-summary-mail-other-window
2094 ("gnus-picon" :interactive t gnus-article-display-picons
2095 gnus-group-display-picons gnus-picons-article-display-x-face)
2096 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2097 gnus-grouplens-mode)
2098 ("gnus-vm" gnus-vm-mail-setup)
2099 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2100 gnus-summary-save-article-vm))))
2104 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2105 ;; If you want the cursor to go somewhere else, set these two
2106 ;; functions in some startup hook to whatever you want.
2107 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2108 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2110 ;;; Various macros and substs.
2112 (defun gnus-header-from (header)
2113 (mail-header-from header))
2115 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2116 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2117 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2118 (w (make-symbol "w"))
2119 (buf (make-symbol "buf")))
2120 `(let* ((,tempvar (selected-window))
2122 (,w (get-buffer-window ,buf 'visible)))
2127 (pop-to-buffer ,buf))
2129 (select-window ,tempvar)))))
2131 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2132 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2133 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2135 (defmacro gnus-gethash (string hashtable)
2136 "Get hash value of STRING in HASHTABLE."
2137 `(symbol-value (intern-soft ,string ,hashtable)))
2139 (defmacro gnus-sethash (string value hashtable)
2140 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2141 `(set (intern ,string ,hashtable) ,value))
2143 (defmacro gnus-intern-safe (string hashtable)
2144 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2145 `(let ((symbol (intern ,string ,hashtable)))
2150 (defmacro gnus-group-unread (group)
2151 "Get the currently computed number of unread articles in GROUP."
2152 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2154 (defmacro gnus-group-entry (group)
2155 "Get the newsrc entry for GROUP."
2156 `(gnus-gethash ,group gnus-newsrc-hashtb))
2158 (defmacro gnus-active (group)
2159 "Get active info on GROUP."
2160 `(gnus-gethash ,group gnus-active-hashtb))
2162 (defmacro gnus-set-active (group active)
2163 "Set GROUP's active info."
2164 `(gnus-sethash ,group ,active gnus-active-hashtb))
2166 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2167 ;; function `substring' might cut on a middle of multi-octet
2169 (defun gnus-truncate-string (str width)
2170 (substring str 0 width))
2172 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2173 ;; to limit the length of a string. This function is necessary since
2174 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2175 (defsubst gnus-limit-string (str width)
2176 (if (> (length str) width)
2177 (substring str 0 width)
2180 (defsubst gnus-simplify-subject-re (subject)
2181 "Remove \"Re:\" from subject lines."
2182 (if (string-match "^[Rr][Ee]: *" subject)
2183 (substring subject (match-end 0))
2186 (defsubst gnus-functionp (form)
2187 "Return non-nil if FORM is funcallable."
2188 (or (and (symbolp form) (fboundp form))
2189 (and (listp form) (eq (car form) 'lambda))))
2191 (defsubst gnus-goto-char (point)
2192 (and point (goto-char point)))
2194 (defmacro gnus-buffer-exists-p (buffer)
2195 `(let ((buffer ,buffer))
2197 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2200 (defmacro gnus-kill-buffer (buffer)
2201 `(let ((buf ,buffer))
2202 (if (gnus-buffer-exists-p buf)
2203 (kill-buffer buf))))
2205 (defsubst gnus-point-at-bol ()
2206 "Return point at the beginning of the line."
2213 (defsubst gnus-point-at-eol ()
2214 "Return point at the end of the line."
2221 (defun gnus-alive-p ()
2222 "Say whether Gnus is running or not."
2223 (and gnus-group-buffer
2224 (get-buffer gnus-group-buffer)))
2226 (defun gnus-delete-first (elt list)
2227 "Delete by side effect the first occurrence of ELT as a member of LIST."
2228 (if (equal (car list) elt)
2231 (while (and (cdr list)
2232 (not (equal (cadr list) elt)))
2233 (setq list (cdr list)))
2235 (setcdr list (cddr list)))
2238 ;; Delete the current line (and the next N lines.);
2239 (defmacro gnus-delete-line (&optional n)
2240 `(delete-region (progn (beginning-of-line) (point))
2241 (progn (forward-line ,(or n 1)) (point))))
2243 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2244 (defvar gnus-init-inhibit nil)
2245 (defun gnus-read-init-file (&optional inhibit-next)
2246 (if gnus-init-inhibit
2247 (setq gnus-init-inhibit nil)
2248 (setq gnus-init-inhibit inhibit-next)
2250 (or (and (file-exists-p gnus-init-file)
2251 ;; Don't try to load a directory.
2252 (not (file-directory-p gnus-init-file)))
2253 (file-exists-p (concat gnus-init-file ".el"))
2254 (file-exists-p (concat gnus-init-file ".elc")))
2256 (load gnus-init-file nil t)
2258 (error "Error in %s: %s" gnus-init-file var))))))
2260 ;; Info access macros.
2262 (defmacro gnus-info-group (info)
2264 (defmacro gnus-info-rank (info)
2266 (defmacro gnus-info-read (info)
2268 (defmacro gnus-info-marks (info)
2270 (defmacro gnus-info-method (info)
2272 (defmacro gnus-info-params (info)
2275 (defmacro gnus-info-level (info)
2276 `(let ((rank (gnus-info-rank ,info)))
2280 (defmacro gnus-info-score (info)
2281 `(let ((rank (gnus-info-rank ,info)))
2282 (or (and (consp rank) (cdr rank)) 0)))
2284 (defmacro gnus-info-set-group (info group)
2285 `(setcar ,info ,group))
2286 (defmacro gnus-info-set-rank (info rank)
2287 `(setcar (nthcdr 1 ,info) ,rank))
2288 (defmacro gnus-info-set-read (info read)
2289 `(setcar (nthcdr 2 ,info) ,read))
2290 (defmacro gnus-info-set-marks (info marks)
2291 `(setcar (nthcdr 3 ,info) ,marks))
2292 (defmacro gnus-info-set-method (info method)
2293 `(setcar (nthcdr 4 ,info) ,method))
2294 (defmacro gnus-info-set-params (info params)
2295 `(setcar (nthcdr 5 ,info) ,params))
2297 (defmacro gnus-info-set-level (info level)
2298 `(let ((rank (cdr ,info)))
2299 (if (consp (car rank))
2300 (setcar (car rank) ,level)
2301 (setcar rank ,level))))
2302 (defmacro gnus-info-set-score (info score)
2303 `(let ((rank (cdr ,info)))
2304 (if (consp (car rank))
2305 (setcdr (car rank) ,score)
2306 (setcar rank (cons (car rank) ,score)))))
2308 (defmacro gnus-get-info (group)
2309 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2311 (defun gnus-byte-code (func)
2312 "Return a form that can be `eval'ed based on FUNC."
2313 (let ((fval (symbol-function func)))
2314 (if (byte-code-function-p fval)
2315 (let ((flist (append fval nil)))
2316 (setcar flist 'byte-code)
2318 (cons 'progn (cddr fval)))))
2320 ;; Find out whether the gnus-visual TYPE is wanted.
2321 (defun gnus-visual-p (&optional type class)
2322 (and gnus-visual ; Has to be non-nil, at least.
2323 (if (not type) ; We don't care about type.
2325 (if (listp gnus-visual) ; It's a list, so we check it.
2326 (or (memq type gnus-visual)
2327 (memq class gnus-visual))
2330 ;;; Load the compatability functions.
2340 (defvar gnus-shutdown-alist nil)
2342 (defun gnus-add-shutdown (function &rest symbols)
2343 "Run FUNCTION whenever one of SYMBOLS is shut down."
2344 (push (cons function symbols) gnus-shutdown-alist))
2346 (defun gnus-shutdown (symbol)
2347 "Shut down everything that waits for SYMBOL."
2348 (let ((alist gnus-shutdown-alist)
2350 (while (setq entry (pop alist))
2351 (when (memq symbol (cdr entry))
2352 (funcall (car entry))))))
2356 ;; Format specs. The chunks below are the machine-generated forms
2357 ;; that are to be evaled as the result of the default format strings.
2358 ;; We write them in here to get them byte-compiled. That way the
2359 ;; default actions will be quite fast, while still retaining the full
2360 ;; flexibility of the user-defined format specs.
2362 ;; First we have lots of dummy defvars to let the compiler know these
2363 ;; are really dynamic variables.
2365 (defvar gnus-tmp-unread)
2366 (defvar gnus-tmp-replied)
2367 (defvar gnus-tmp-score-char)
2368 (defvar gnus-tmp-indentation)
2369 (defvar gnus-tmp-opening-bracket)
2370 (defvar gnus-tmp-lines)
2371 (defvar gnus-tmp-name)
2372 (defvar gnus-tmp-closing-bracket)
2373 (defvar gnus-tmp-subject-or-nil)
2374 (defvar gnus-tmp-subject)
2375 (defvar gnus-tmp-marked)
2376 (defvar gnus-tmp-marked-mark)
2377 (defvar gnus-tmp-subscribed)
2378 (defvar gnus-tmp-process-marked)
2379 (defvar gnus-tmp-number-of-unread)
2380 (defvar gnus-tmp-group-name)
2381 (defvar gnus-tmp-group)
2382 (defvar gnus-tmp-article-number)
2383 (defvar gnus-tmp-unread-and-unselected)
2384 (defvar gnus-tmp-news-method)
2385 (defvar gnus-tmp-news-server)
2386 (defvar gnus-tmp-article-number)
2387 (defvar gnus-mouse-face)
2388 (defvar gnus-mouse-face-prop)
2390 (defun gnus-summary-line-format-spec ()
2391 (insert gnus-tmp-unread gnus-tmp-replied
2392 gnus-tmp-score-char gnus-tmp-indentation)
2393 (gnus-put-text-property
2397 gnus-tmp-opening-bracket
2398 (format "%4d: %-20s"
2400 (if (> (length gnus-tmp-name) 20)
2401 (substring gnus-tmp-name 0 20)
2403 gnus-tmp-closing-bracket)
2405 gnus-mouse-face-prop gnus-mouse-face)
2406 (insert " " gnus-tmp-subject-or-nil "\n"))
2408 (defvar gnus-summary-line-format-spec
2409 (gnus-byte-code 'gnus-summary-line-format-spec))
2411 (defun gnus-summary-dummy-line-format-spec ()
2413 (gnus-put-text-property
2418 gnus-mouse-face-prop gnus-mouse-face)
2419 (insert " " gnus-tmp-subject "\n"))
2421 (defvar gnus-summary-dummy-line-format-spec
2422 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2424 (defun gnus-group-line-format-spec ()
2425 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2426 gnus-tmp-process-marked
2427 gnus-group-indentation
2428 (format "%5s: " gnus-tmp-number-of-unread))
2429 (gnus-put-text-property
2432 (insert gnus-tmp-group "\n")
2434 gnus-mouse-face-prop gnus-mouse-face))
2435 (defvar gnus-group-line-format-spec
2436 (gnus-byte-code 'gnus-group-line-format-spec))
2438 (defvar gnus-format-specs
2439 `((version . ,emacs-version)
2440 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2441 (summary-dummy ,gnus-summary-dummy-line-format
2442 ,gnus-summary-dummy-line-format-spec)
2443 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2445 (defvar gnus-article-mode-line-format-spec nil)
2446 (defvar gnus-summary-mode-line-format-spec nil)
2447 (defvar gnus-group-mode-line-format-spec nil)
2449 ;;; Phew. All that gruft is over, fortunately.
2453 ;;; Gnus Utility Functions
2456 (defun gnus-extract-address-components (from)
2458 ;; First find the address - the thing with the @ in it. This may
2459 ;; not be accurate in mail addresses, but does the trick most of
2460 ;; the time in news messages.
2461 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2462 (setq address (substring from (match-beginning 0) (match-end 0))))
2463 ;; Then we check whether the "name <address>" format is used.
2465 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2466 ;; Linear white space is not required.
2467 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2468 (and (setq name (substring from 0 (match-beginning 0)))
2469 ;; Strip any quotes from the name.
2470 (string-match "\".*\"" name)
2471 (setq name (substring name 1 (1- (match-end 0))))))
2472 ;; If not, then "address (name)" is used.
2474 (and (string-match "(.+)" from)
2475 (setq name (substring from (1+ (match-beginning 0))
2476 (1- (match-end 0)))))
2477 (and (string-match "()" from)
2478 (setq name address))
2479 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2480 ;; XOVER might not support folded From headers.
2481 (and (string-match "(.*" from)
2482 (setq name (substring from (1+ (match-beginning 0))
2484 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2485 (list (or name from) (or address from))))
2487 (defun gnus-fetch-field (field)
2488 "Return the value of the header FIELD of current article."
2491 (let ((case-fold-search t)
2492 (inhibit-point-motion-hooks t))
2493 (nnheader-narrow-to-headers)
2494 (message-fetch-field field)))))
2496 (defun gnus-goto-colon ()
2498 (search-forward ":" (gnus-point-at-eol) t))
2501 (defun gnus-update-format (var)
2502 "Update the format specification near point."
2507 ;; Find the end of the current word.
2508 (re-search-forward "[ \t\n]" nil t)
2510 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2511 (match-string 1)))))
2512 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2513 (match-string 1 var))))
2514 (entry (assq type gnus-format-specs))
2517 (setq gnus-format-specs (delq entry gnus-format-specs)))
2519 (intern (format "%s-spec" var))
2520 (gnus-parse-format (setq value (symbol-value (intern var)))
2521 (symbol-value (intern (format "%s-alist" var)))
2522 (not (string-match "mode" var))))
2523 (setq spec (symbol-value (intern (format "%s-spec" var))))
2524 (push (list type value spec) gnus-format-specs)
2526 (pop-to-buffer "*Gnus Format*")
2528 (lisp-interaction-mode)
2529 (insert (pp-to-string spec))))
2531 (defun gnus-update-format-specifications (&optional force)
2532 "Update all (necessary) format specifications."
2533 ;; Make the indentation array.
2534 (gnus-make-thread-indent-array)
2536 ;; See whether all the stored info needs to be flushed.
2538 (not (equal emacs-version
2539 (cdr (assq 'version gnus-format-specs)))))
2540 (setq gnus-format-specs nil))
2542 ;; Go through all the formats and see whether they need updating.
2543 (let ((types '(summary summary-dummy group
2544 summary-mode group-mode article-mode))
2545 new-format entry type val)
2546 (while (setq type (pop types))
2547 ;; Jump to the proper buffer to find out the value of
2548 ;; the variable, if possible. (It may be buffer-local.)
2550 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2552 (when (and (boundp buffer)
2553 (setq val (symbol-value buffer))
2555 (buffer-name (get-buffer val)))
2556 (set-buffer (get-buffer val)))
2557 (setq new-format (symbol-value
2558 (intern (format "gnus-%s-line-format" type))))))
2559 (setq entry (cdr (assq type gnus-format-specs)))
2561 (equal (car entry) new-format))
2562 ;; Use the old format.
2563 (set (intern (format "gnus-%s-line-format-spec" type))
2565 ;; This is a new format.
2567 (if (not (stringp new-format))
2568 ;; This is a function call or something.
2570 ;; This is a "real" format.
2574 (intern (format "gnus-%s-line-format-alist"
2575 (if (eq type 'article-mode)
2576 'summary-mode type))))
2577 (not (string-match "mode$" (symbol-name type))))))
2578 ;; Enter the new format spec into the list.
2581 (setcar (cdr entry) val)
2582 (setcar entry new-format))
2583 (push (list type new-format val) gnus-format-specs))
2584 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2586 (unless (assq 'version gnus-format-specs)
2587 (push (cons 'version emacs-version) gnus-format-specs))
2589 (gnus-update-group-mark-positions)
2590 (gnus-update-summary-mark-positions))
2592 (defun gnus-update-summary-mark-positions ()
2593 "Compute where the summary marks are to go."
2595 (when (and gnus-summary-buffer
2596 (get-buffer gnus-summary-buffer)
2597 (buffer-name (get-buffer gnus-summary-buffer)))
2598 (set-buffer gnus-summary-buffer))
2599 (let ((gnus-replied-mark 129)
2600 (gnus-score-below-mark 130)
2601 (gnus-score-over-mark 130)
2604 (spec gnus-summary-line-format-spec)
2607 (gnus-set-work-buffer)
2608 (let ((gnus-summary-line-format-spec spec))
2609 (gnus-summary-insert-line
2610 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2611 (goto-char (point-min))
2612 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2614 (goto-char (point-min))
2615 (push (cons 'replied (and (search-forward "\201" nil t)
2618 (goto-char (point-min))
2619 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2621 (setq gnus-summary-mark-positions pos))))
2623 (defun gnus-update-group-mark-positions ()
2625 (let ((gnus-process-mark 128)
2626 (gnus-group-marked '("dummy.group"))
2627 (gnus-active-hashtb (make-vector 10 0)))
2628 (gnus-set-active "dummy.group" '(0 . 0))
2629 (gnus-set-work-buffer)
2630 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2631 (goto-char (point-min))
2632 (setq gnus-group-mark-positions
2633 (list (cons 'process (and (search-forward "\200" nil t)
2634 (- (point) 2))))))))
2636 (defvar gnus-mouse-face-0 'highlight)
2637 (defvar gnus-mouse-face-1 'highlight)
2638 (defvar gnus-mouse-face-2 'highlight)
2639 (defvar gnus-mouse-face-3 'highlight)
2640 (defvar gnus-mouse-face-4 'highlight)
2642 (defun gnus-mouse-face-function (form type)
2643 `(gnus-put-text-property
2644 (point) (progn ,@form (point))
2645 gnus-mouse-face-prop
2648 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2650 (defvar gnus-face-0 'bold)
2651 (defvar gnus-face-1 'italic)
2652 (defvar gnus-face-2 'bold-italic)
2653 (defvar gnus-face-3 'bold)
2654 (defvar gnus-face-4 'bold)
2656 (defun gnus-face-face-function (form type)
2657 `(gnus-put-text-property
2658 (point) (progn ,@form (point))
2659 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2661 (defun gnus-max-width-function (el max-width)
2662 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2664 `(if (> (length ,el) ,max-width)
2665 (substring ,el 0 ,max-width)
2667 `(let ((val (eval ,el)))
2669 (setq val (int-to-string val)))
2670 (if (> (length val) ,max-width)
2671 (substring val 0 ,max-width)
2674 (defun gnus-parse-format (format spec-alist &optional insert)
2675 ;; This function parses the FORMAT string with the help of the
2676 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2677 ;; string. If the FORMAT string contains the specifiers %( and %)
2678 ;; the text between them will have the mouse-face text property.
2680 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2682 (gnus-parse-complex-format format spec-alist)
2683 ;; This is a simple format.
2684 (gnus-parse-simple-format format spec-alist insert)))
2686 (defun gnus-parse-complex-format (format spec-alist)
2688 (gnus-set-work-buffer)
2690 (goto-char (point-min))
2691 (while (re-search-forward "\"" nil t)
2692 (replace-match "\\\"" nil t))
2693 (goto-char (point-min))
2695 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2696 (let ((number (if (match-beginning 1)
2697 (match-string 1) "0"))
2698 (delim (aref (match-string 2) 0)))
2699 (if (or (= delim ?\() (= delim ?\{))
2700 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2702 (replace-match "\")\""))))
2703 (goto-char (point-max))
2705 (goto-char (point-min))
2706 (let ((form (read (current-buffer))))
2707 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2709 (defun gnus-complex-form-to-spec (form spec-alist)
2714 (gnus-parse-simple-format sform spec-alist t)
2715 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2716 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2720 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2721 ;; This function parses the FORMAT string with the help of the
2722 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2725 spec flist fstring newspec elem beg result dontinsert)
2727 (gnus-set-work-buffer)
2729 (goto-char (point-min))
2730 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2732 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2734 beg (1+ (match-beginning 0)))
2735 ;; First check if there are any specs that look anything like
2736 ;; "%12,12A", ie. with a "max width specification". These have
2737 ;; to be treated specially.
2738 (if (setq beg (match-beginning 1))
2742 (1+ (match-beginning 1)) (match-end 1))))
2744 (setq beg (match-beginning 2)))
2745 ;; Find the specification from `spec-alist'.
2746 (unless (setq elem (cdr (assq spec spec-alist)))
2747 (setq elem '("*" ?s)))
2748 ;; Treat user defined format specifiers specially.
2749 (when (eq (car elem) 'gnus-tmp-user-defined)
2752 (list (intern (concat "gnus-user-format-function-"
2754 'gnus-tmp-header) ?s))
2755 (delete-region (match-beginning 3) (match-end 3)))
2756 (if (not (zerop max-width))
2757 (let ((el (car elem)))
2758 (cond ((= (cadr elem) ?c)
2759 (setq el (list 'char-to-string el)))
2761 (setq el (list 'int-to-string el))))
2762 (setq flist (cons (gnus-max-width-function el max-width)
2766 (setq flist (cons (car elem) flist))
2767 (setq newspec (cadr elem)))))
2768 ;; Remove the old specification (and possibly a ",12" string).
2769 (delete-region beg (match-end 2))
2770 ;; Insert the new specification.
2773 (setq fstring (buffer-substring 1 (point-max))))
2774 ;; Do some postprocessing to increase efficiency.
2779 ((string= fstring "")
2781 ;; Not a format string.
2782 ((not (string-match "%" fstring))
2784 ;; A format string with just a single string spec.
2785 ((string= fstring "%s")
2787 ;; A single character.
2788 ((string= fstring "%c")
2791 ((string= fstring "%d")
2794 (list `(princ ,(car flist)))
2795 (list `(int-to-string ,(car flist)))))
2796 ;; Just lots of chars and strings.
2797 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2799 ;; A single string spec at the beginning of the spec.
2800 ((string-match "\\`%[sc][^%]+\\'" fstring)
2801 (list (car flist) (substring fstring 2)))
2802 ;; A single string spec in the middle of the spec.
2803 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2804 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2805 ;; A single string spec in the end of the spec.
2806 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2807 (list (match-string 1 fstring) (car flist)))
2808 ;; A more complex spec.
2810 (list (cons 'format (cons fstring (nreverse flist)))))))
2816 (cons 'insert result)))
2817 (cond ((stringp result)
2820 (cons 'concat result))
2823 (defun gnus-eval-format (format &optional alist props)
2824 "Eval the format variable FORMAT, using ALIST.
2825 If PROPS, insert the result."
2826 (let ((form (gnus-parse-format format alist props)))
2828 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2831 (defun gnus-remove-text-with-property (prop)
2832 "Delete all text in the current buffer with text property PROP."
2834 (goto-char (point-min))
2836 (while (get-text-property (point) prop)
2838 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2840 (defun gnus-set-work-buffer ()
2841 (if (get-buffer gnus-work-buffer)
2843 (set-buffer gnus-work-buffer)
2845 (set-buffer (get-buffer-create gnus-work-buffer))
2846 (kill-all-local-variables)
2847 (buffer-disable-undo (current-buffer))
2848 (gnus-add-current-to-buffer-list)))
2850 ;; Article file names when saving.
2852 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2853 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2854 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2855 Otherwise, it is like ~/News/news/group/num."
2858 (concat (if (gnus-use-long-file-name 'not-save)
2859 (gnus-capitalize-newsgroup newsgroup)
2860 (gnus-newsgroup-directory-form newsgroup))
2861 "/" (int-to-string (mail-header-number headers)))
2862 gnus-article-save-directory)))
2864 (string-equal (file-name-directory default)
2865 (file-name-directory last-file))
2866 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2868 (or last-file default))))
2870 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2871 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2872 If variable `gnus-use-long-file-name' is non-nil, it is
2873 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2876 (concat (if (gnus-use-long-file-name 'not-save)
2878 (gnus-newsgroup-directory-form newsgroup))
2879 "/" (int-to-string (mail-header-number headers)))
2880 gnus-article-save-directory)))
2882 (string-equal (file-name-directory default)
2883 (file-name-directory last-file))
2884 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2886 (or last-file default))))
2888 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2889 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2890 If variable `gnus-use-long-file-name' is non-nil, it is
2891 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2894 (if (gnus-use-long-file-name 'not-save)
2895 (gnus-capitalize-newsgroup newsgroup)
2896 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2897 gnus-article-save-directory)))
2899 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2900 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2901 If variable `gnus-use-long-file-name' is non-nil, it is
2902 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2905 (if (gnus-use-long-file-name 'not-save)
2907 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2908 gnus-article-save-directory)))
2910 ;; For subscribing new newsgroup
2912 (defun gnus-subscribe-hierarchical-interactive (groups)
2913 (let ((groups (sort groups 'string<))
2914 prefixes prefix start ans group starts)
2916 (setq prefixes (list "^"))
2917 (while (and groups prefixes)
2918 (while (not (string-match (car prefixes) (car groups)))
2919 (setq prefixes (cdr prefixes)))
2920 (setq prefix (car prefixes))
2921 (setq start (1- (length prefix)))
2922 (if (and (string-match "[^\\.]\\." (car groups) start)
2925 (concat "^" (substring (car groups) 0 (match-end 0))))
2926 (string-match prefix (cadr groups)))
2928 (setq prefixes (cons prefix prefixes))
2929 (message "Descend hierarchy %s? ([y]nsq): "
2930 (substring prefix 1 (1- (length prefix))))
2931 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2933 (message "Descend hierarchy %s? ([y]nsq): "
2934 (substring prefix 1 (1- (length prefix)))))
2937 (string-match prefix
2938 (setq group (car groups))))
2939 (setq gnus-killed-list
2940 (cons group gnus-killed-list))
2941 (gnus-sethash group group gnus-killed-hashtb)
2942 (setq groups (cdr groups)))
2943 (setq starts (cdr starts)))
2946 (string-match prefix
2947 (setq group (car groups))))
2948 (gnus-sethash group group gnus-killed-hashtb)
2949 (gnus-subscribe-alphabetically (car groups))
2950 (setq groups (cdr groups)))
2951 (setq starts (cdr starts)))
2954 (setq group (car groups))
2955 (setq gnus-killed-list (cons group gnus-killed-list))
2956 (gnus-sethash group group gnus-killed-hashtb)
2957 (setq groups (cdr groups))))
2959 (message "Subscribe %s? ([n]yq)" (car groups))
2960 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2962 (message "Subscribe %s? ([n]yq)" (car groups)))
2963 (setq group (car groups))
2965 (gnus-subscribe-alphabetically (car groups))
2966 (gnus-sethash group group gnus-killed-hashtb))
2969 (setq group (car groups))
2970 (setq gnus-killed-list (cons group gnus-killed-list))
2971 (gnus-sethash group group gnus-killed-hashtb)
2972 (setq groups (cdr groups))))
2974 (setq gnus-killed-list (cons group gnus-killed-list))
2975 (gnus-sethash group group gnus-killed-hashtb)))
2976 (setq groups (cdr groups)))))))
2978 (defun gnus-subscribe-randomly (newsgroup)
2979 "Subscribe new NEWSGROUP by making it the first newsgroup."
2980 (gnus-subscribe-newsgroup newsgroup))
2982 (defun gnus-subscribe-alphabetically (newgroup)
2983 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2984 (let ((groups (cdr gnus-newsrc-alist))
2986 (while (and (not before) groups)
2987 (if (string< newgroup (caar groups))
2988 (setq before (caar groups))
2989 (setq groups (cdr groups))))
2990 (gnus-subscribe-newsgroup newgroup before)))
2992 (defun gnus-subscribe-hierarchically (newgroup)
2993 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2994 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2996 (set-buffer (find-file-noselect gnus-current-startup-file))
2997 (let ((groupkey newgroup)
2999 (while (and (not before) groupkey)
3000 (goto-char (point-min))
3002 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3003 (while (and (re-search-forward groupkey-re nil t)
3005 (setq before (match-string 1))
3006 (string< before newgroup)))))
3007 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3009 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3010 (substring groupkey (match-beginning 1) (match-end 1)))))
3011 (gnus-subscribe-newsgroup newgroup before))))
3013 (defun gnus-subscribe-interactively (group)
3014 "Subscribe the new GROUP interactively.
3015 It is inserted in hierarchical newsgroup order if subscribed. If not,
3017 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3018 (gnus-subscribe-hierarchically group)
3019 (push group gnus-killed-list)))
3021 (defun gnus-subscribe-zombies (group)
3022 "Make the new GROUP into a zombie group."
3023 (push group gnus-zombie-list))
3025 (defun gnus-subscribe-killed (group)
3026 "Make the new GROUP a killed group."
3027 (push group gnus-killed-list))
3029 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3030 "Subscribe new NEWSGROUP.
3031 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3032 the first newsgroup."
3033 ;; We subscribe the group by changing its level to `subscribed'.
3034 (gnus-group-change-level
3035 newsgroup gnus-level-default-subscribed
3036 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3037 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3041 (defun gnus-newsgroup-directory-form (newsgroup)
3042 "Make hierarchical directory name from NEWSGROUP name."
3043 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3044 (len (length newsgroup))
3046 ;; If this is a foreign group, we don't want to translate the
3048 (if (setq idx (string-match ":" newsgroup))
3049 (aset newsgroup idx ?/)
3051 ;; Replace all occurrences of `.' with `/'.
3053 (if (= (aref newsgroup idx) ?.)
3054 (aset newsgroup idx ?/))
3055 (setq idx (1+ idx)))
3058 (defun gnus-newsgroup-savable-name (group)
3059 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3061 (nnheader-replace-chars-in-string group ?/ ?.))
3063 (defun gnus-make-directory (dir)
3064 "Make DIRECTORY recursively."
3065 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3066 ;; of the many mysteries of the universe.
3067 (let* ((dir (expand-file-name dir default-directory))
3069 (if (string-match "/$" dir)
3070 (setq dir (substring dir 0 (match-beginning 0))))
3071 ;; First go down the path until we find a directory that exists.
3072 (while (not (file-exists-p dir))
3073 (setq dirs (cons dir dirs))
3074 (string-match "/[^/]+$" dir)
3075 (setq dir (substring dir 0 (match-beginning 0))))
3076 ;; Then create all the subdirs.
3077 (while (and dirs (not err))
3079 (make-directory (car dirs))
3080 (error (setq err t)))
3081 (setq dirs (cdr dirs)))
3082 ;; We return whether we were successful or not.
3085 (defun gnus-capitalize-newsgroup (newsgroup)
3086 "Capitalize NEWSGROUP name."
3087 (and (not (zerop (length newsgroup)))
3088 (concat (char-to-string (upcase (aref newsgroup 0)))
3089 (substring newsgroup 1))))
3091 ;; Various... things.
3093 (defun gnus-simplify-subject (subject &optional re-only)
3094 "Remove `Re:' and words in parentheses.
3095 If RE-ONLY is non-nil, strip leading `Re:'s only."
3096 (let ((case-fold-search t)) ;Ignore case.
3097 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3098 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3099 (setq subject (substring subject (match-end 0))))
3100 ;; Remove uninteresting prefixes.
3101 (if (and (not re-only)
3102 gnus-simplify-ignored-prefixes
3103 (string-match gnus-simplify-ignored-prefixes subject))
3104 (setq subject (substring subject (match-end 0))))
3105 ;; Remove words in parentheses from end.
3107 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3108 (setq subject (substring subject 0 (match-beginning 0)))))
3109 ;; Return subject string.
3112 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3114 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3115 (defun gnus-simplify-buffer-fuzzy ()
3116 (goto-char (point-min))
3117 (while (search-forward "\t" nil t)
3118 (replace-match " " t t))
3119 (goto-char (point-min))
3120 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3121 (goto-char (match-beginning 0))
3123 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3124 (looking-at "^[[].*: .*[]]$"))
3125 (goto-char (point-min))
3126 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3128 (replace-match "" t t))
3129 (goto-char (point-min))
3130 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3131 (goto-char (match-end 0))
3134 (progn (goto-char (match-beginning 0)))
3135 (re-search-forward ":"))))
3136 (goto-char (point-min))
3137 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" 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 (while (re-search-forward "^ +" nil t)
3147 (replace-match "" t t))
3148 (goto-char (point-min))
3149 (when gnus-simplify-subject-fuzzy-regexp
3150 (if (listp gnus-simplify-subject-fuzzy-regexp)
3151 (let ((list gnus-simplify-subject-fuzzy-regexp))
3153 (goto-char (point-min))
3154 (while (re-search-forward (car list) nil t)
3155 (replace-match "" t t))
3156 (setq list (cdr list))))
3157 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3158 (replace-match "" t t)))))
3160 (defun gnus-simplify-subject-fuzzy (subject)
3161 "Siplify a subject string fuzzily."
3163 (gnus-set-work-buffer)
3164 (let ((case-fold-search t))
3166 (inline (gnus-simplify-buffer-fuzzy))
3169 ;; Add the current buffer to the list of buffers to be killed on exit.
3170 (defun gnus-add-current-to-buffer-list ()
3171 (or (memq (current-buffer) gnus-buffer-list)
3172 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3174 (defun gnus-string> (s1 s2)
3175 (not (or (string< s1 s2)
3178 (defun gnus-read-active-file-p ()
3179 "Say whether the active file has been read from `gnus-select-method'."
3180 (memq gnus-select-method gnus-have-read-active-file))
3182 ;;; General various misc type functions.
3184 (defun gnus-clear-system ()
3185 "Clear all variables and buffers."
3186 ;; Clear Gnus variables.
3187 (let ((variables gnus-variable-list))
3189 (set (car variables) nil)
3190 (setq variables (cdr variables))))
3191 ;; Clear other internal variables.
3192 (setq gnus-list-of-killed-groups nil
3193 gnus-have-read-active-file nil
3194 gnus-newsrc-alist nil
3195 gnus-newsrc-hashtb nil
3196 gnus-killed-list nil
3197 gnus-zombie-list nil
3198 gnus-killed-hashtb nil
3199 gnus-active-hashtb nil
3200 gnus-moderated-list nil
3201 gnus-description-hashtb nil
3202 gnus-current-headers nil
3203 gnus-thread-indent-array nil
3204 gnus-newsgroup-headers nil
3205 gnus-newsgroup-name nil
3206 gnus-server-alist nil
3207 gnus-group-list-mode nil
3208 gnus-opened-servers nil
3209 gnus-current-select-method nil)
3210 (gnus-shutdown 'gnus)
3211 ;; Kill the startup file.
3212 (and gnus-current-startup-file
3213 (get-file-buffer gnus-current-startup-file)
3214 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3215 ;; Clear the dribble buffer.
3216 (gnus-dribble-clear)
3217 ;; Kill global KILL file buffer.
3218 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3219 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3220 (gnus-kill-buffer nntp-server-buffer)
3221 ;; Kill Gnus buffers.
3222 (while gnus-buffer-list
3223 (gnus-kill-buffer (pop gnus-buffer-list)))
3224 ;; Remove Gnus frames.
3225 (while gnus-created-frames
3226 (when (frame-live-p (car gnus-created-frames))
3227 ;; We slap a condition-case around this `delete-frame' to ensure
3228 ;; agains errors if we try do delete the single frame that's left.
3230 (delete-frame (car gnus-created-frames))
3232 (pop gnus-created-frames)))
3234 (defun gnus-windows-old-to-new (setting)
3235 ;; First we take care of the really, really old Gnus 3 actions.
3236 (when (symbolp setting)
3238 ;; Take care of ooold GNUS 3.x values.
3239 (cond ((eq setting 'SelectArticle) 'article)
3240 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3241 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3243 (if (or (listp setting)
3244 (not (and gnus-window-configuration
3245 (memq setting '(group summary article)))))
3247 (let* ((setting (if (eq setting 'group)
3248 (if (assq 'newsgroup gnus-window-configuration)
3250 'newsgroups) setting))
3251 (elem (cadr (assq setting gnus-window-configuration)))
3252 (total (apply '+ elem))
3253 (types '(group summary article))
3254 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3259 (or (not (numberp (nth i elem)))
3260 (zerop (nth i elem))
3262 (setq perc (/ (float (nth 0 elem)) total))
3263 (setq out (cons (if (eq pbuf (nth i types))
3264 (vector (nth i types) perc 'point)
3265 (vector (nth i types) perc))
3268 (list (nreverse out)))))
3271 (defun gnus-add-configuration (conf)
3272 "Add the window configuration CONF to `gnus-buffer-configuration'."
3273 (setq gnus-buffer-configuration
3274 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3275 gnus-buffer-configuration))))
3277 (defvar gnus-frame-list nil)
3279 (defun gnus-configure-frame (split &optional window)
3280 "Split WINDOW according to SPLIT."
3282 (setq window (get-buffer-window (current-buffer))))
3283 (select-window window)
3284 ;; This might be an old-stylee buffer config.
3285 (when (vectorp split)
3286 (setq split (append split nil)))
3287 (when (or (consp (car split))
3288 (vectorp (car split)))
3290 (push 'vertical split))
3291 ;; The SPLIT might be something that is to be evaled to
3292 ;; return a new SPLIT.
3293 (while (and (not (assq (car split) gnus-window-to-buffer))
3294 (gnus-functionp (car split)))
3295 (setq split (eval split)))
3296 (let* ((type (car split))
3298 (len (if (eq type 'horizontal) (window-width) (window-height)))
3300 (window-min-width (or gnus-window-min-width window-min-width))
3301 (window-min-height (or gnus-window-min-height window-min-height))
3302 s result new-win rest comp-subs size sub)
3304 ;; Nothing to do here.
3306 ;; Don't switch buffers.
3308 (and (memq 'point split) window))
3309 ;; This is a buffer to be selected.
3310 ((not (memq type '(frame horizontal vertical)))
3311 (let ((buffer (cond ((stringp type) type)
3312 (t (cdr (assq type gnus-window-to-buffer)))))
3315 (error "Illegal buffer type: %s" type))
3316 (unless (setq buf (get-buffer (if (symbolp buffer)
3317 (symbol-value buffer) buffer)))
3318 (setq buf (get-buffer-create (if (symbolp buffer)
3319 (symbol-value buffer) buffer))))
3320 (switch-to-buffer buf)
3321 ;; We return the window if it has the `point' spec.
3322 (and (memq 'point split) window)))
3323 ;; This is a frame split.
3325 (unless gnus-frame-list
3326 (setq gnus-frame-list (list (window-frame
3327 (get-buffer-window (current-buffer))))))
3329 params frame fresult)
3330 (while (< i (length subs))
3331 ;; Frame parameter is gotten from the sub-split.
3332 (setq params (cadr (elt subs i)))
3333 ;; It should be a list.
3334 (unless (listp params)
3336 ;; Create a new frame?
3337 (unless (setq frame (elt gnus-frame-list i))
3338 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3339 (push frame gnus-created-frames))
3340 ;; Is the old frame still alive?
3341 (unless (frame-live-p frame)
3342 (setcar (nthcdr i gnus-frame-list)
3343 (setq frame (make-frame params))))
3344 ;; Select the frame in question and do more splits there.
3345 (select-frame frame)
3346 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3348 ;; Select the frame that has the selected buffer.
3350 (select-frame (window-frame fresult)))))
3351 ;; This is a normal split.
3353 (when (> (length subs) 0)
3354 ;; First we have to compute the sizes of all new windows.
3356 (setq sub (append (pop subs) nil))
3357 (while (and (not (assq (car sub) gnus-window-to-buffer))
3358 (gnus-functionp (car sub)))
3359 (setq sub (eval sub)))
3361 (push sub comp-subs)
3362 (setq size (cadar comp-subs))
3363 (cond ((equal size 1.0)
3364 (setq rest (car comp-subs))
3367 (setq s (floor (* size len))))
3371 (error "Illegal size: %s" size)))
3372 ;; Try to make sure that we are inside the safe limits.
3374 ((eq type 'horizontal)
3375 (setq s (max s window-min-width)))
3376 ((eq type 'vertical)
3377 (setq s (max s window-min-height))))
3378 (setcar (cdar comp-subs) s)
3380 ;; Take care of the "1.0" spec.
3382 (setcar (cdr rest) (- len total))
3383 (error "No 1.0 specs in %s" split))
3384 ;; The we do the actual splitting in a nice recursive
3386 (setq comp-subs (nreverse comp-subs))
3388 (if (null (cdr comp-subs))
3389 (setq new-win window)
3391 (split-window window (cadar comp-subs)
3392 (eq type 'horizontal))))
3393 (setq result (or (gnus-configure-frame
3394 (car comp-subs) window) result))
3395 (select-window new-win)
3396 (setq window new-win)
3397 (setq comp-subs (cdr comp-subs))))
3398 ;; Return the proper window, if any.
3400 (select-window result))))))
3402 (defvar gnus-frame-split-p nil)
3404 (defun gnus-configure-windows (setting &optional force)
3405 (setq setting (gnus-windows-old-to-new setting))
3406 (let ((split (if (symbolp setting)
3407 (cadr (assq setting gnus-buffer-configuration))
3411 (setq gnus-frame-split-p nil)
3414 (error "No such setting: %s" setting))
3416 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3418 ;; All the windows mentioned are already visible, so we just
3419 ;; put point in the assigned buffer, and do not touch the
3421 (select-window all-visible)
3423 ;; Either remove all windows or just remove all Gnus windows.
3424 (let ((frame (selected-frame)))
3426 (if gnus-use-full-window
3427 ;; We want to remove all other windows.
3428 (if (not gnus-frame-split-p)
3429 ;; This is not a `frame' split, so we ignore the
3431 (delete-other-windows)
3432 ;; This is a `frame' split, so we delete all windows
3436 (unless (eq (cdr (assq 'minibuffer
3437 (frame-parameters frame)))
3439 (select-frame frame)
3440 (delete-other-windows)))
3442 ;; Just remove some windows.
3443 (gnus-remove-some-windows)
3444 (switch-to-buffer nntp-server-buffer))
3445 (select-frame frame)))
3447 (switch-to-buffer nntp-server-buffer)
3448 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3450 (defun gnus-all-windows-visible-p (split)
3451 "Say whether all buffers in SPLIT are currently visible.
3452 In particular, the value returned will be the window that
3454 (let ((stack (list split))
3456 type buffer win buf)
3457 (while (and (setq split (pop stack))
3459 ;; Be backwards compatible.
3460 (when (vectorp split)
3461 (setq split (append split nil)))
3462 (when (or (consp (car split))
3463 (vectorp (car split)))
3465 (push 'vertical split))
3466 ;; The SPLIT might be something that is to be evaled to
3467 ;; return a new SPLIT.
3468 (while (and (not (assq (car split) gnus-window-to-buffer))
3469 (gnus-functionp (car split)))
3470 (setq split (eval split)))
3472 (setq type (elt split 0))
3477 ((not (memq type '(horizontal vertical frame)))
3478 (setq buffer (cond ((stringp type) type)
3479 (t (cdr (assq type gnus-window-to-buffer)))))
3481 (error "Illegal buffer type: %s" type))
3482 (when (setq buf (get-buffer (if (symbolp buffer)
3483 (symbol-value buffer)
3485 (setq win (get-buffer-window buf t)))
3487 (when (memq 'point split)
3488 (setq all-visible win))
3489 (setq all-visible nil)))
3491 (when (eq type 'frame)
3492 (setq gnus-frame-split-p t))
3493 (setq stack (append (cddr split) stack)))))
3494 (unless (eq all-visible t)
3497 (defun gnus-window-top-edge (&optional window)
3498 (nth 1 (window-edges window)))
3500 (defun gnus-remove-some-windows ()
3501 (let ((buffers gnus-window-to-buffer)
3502 buf bufs lowest-buf lowest)
3504 ;; Remove windows on all known Gnus buffers.
3506 (setq buf (cdar buffers))
3508 (setq buf (and (boundp buf) (symbol-value buf))))
3510 (get-buffer-window buf)
3512 (setq bufs (cons buf bufs))
3514 (if (or (not lowest)
3515 (< (gnus-window-top-edge) lowest))
3517 (setq lowest (gnus-window-top-edge))
3518 (setq lowest-buf buf)))))
3519 (setq buffers (cdr buffers)))
3520 ;; Remove windows on *all* summary buffers.
3523 (let ((buf (window-buffer win)))
3524 (if (string-match "^\\*Summary" (buffer-name buf))
3526 (setq bufs (cons buf bufs))
3528 (if (or (not lowest)
3529 (< (gnus-window-top-edge) lowest))
3531 (setq lowest-buf buf)
3532 (setq lowest (gnus-window-top-edge)))))))))
3535 (pop-to-buffer lowest-buf)
3536 (switch-to-buffer nntp-server-buffer)))
3538 (and (not (eq (car bufs) lowest-buf))
3539 (delete-windows-on (car bufs)))
3540 (setq bufs (cdr bufs))))))
3542 (defun gnus-version (&optional arg)
3543 "Version number of this version of Gnus.
3544 If ARG, insert string at point."
3546 (let ((methods gnus-valid-select-methods)
3549 ;; Go through all the legal select methods and add their version
3550 ;; numbers to the total version string. Only the backends that are
3551 ;; currently in use will have their message numbers taken into
3554 (setq meth (intern (concat (caar methods) "-version")))
3556 (stringp (symbol-value meth))
3557 (setq mess (concat mess "; " (symbol-value meth))))
3558 (setq methods (cdr methods)))
3560 (insert (message mess))
3563 (defun gnus-info-find-node ()
3564 "Find Info documentation of Gnus."
3566 ;; Enlarge info window if needed.
3567 (let ((mode major-mode)
3569 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3570 (setq gnus-info-buffer (current-buffer))
3571 (gnus-configure-windows 'info)))
3573 (defun gnus-days-between (date1 date2)
3574 ;; Return the number of days between date1 and date2.
3575 (- (gnus-day-number date1) (gnus-day-number date2)))
3577 (defun gnus-day-number (date)
3578 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3579 (timezone-parse-date date))))
3580 (timezone-absolute-from-gregorian
3581 (nth 1 dat) (nth 2 dat) (car dat))))
3583 (defun gnus-encode-date (date)
3584 "Convert DATE to internal time."
3585 (let* ((parse (timezone-parse-date date))
3586 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3587 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3588 (encode-time (caddr time) (cadr time) (car time)
3589 (caddr date) (cadr date) (car date) (nth 4 date))))
3591 (defun gnus-time-minus (t1 t2)
3592 "Subtract two internal times."
3593 (let ((borrow (< (cadr t1) (cadr t2))))
3594 (list (- (car t1) (car t2) (if borrow 1 0))
3595 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3597 (defun gnus-file-newer-than (file date)
3598 (let ((fdate (nth 5 (file-attributes file))))
3599 (or (> (car fdate) (car date))
3600 (and (= (car fdate) (car date))
3601 (> (nth 1 fdate) (nth 1 date))))))
3603 (defmacro gnus-local-set-keys (&rest plist)
3604 "Set the keys in PLIST in the current keymap."
3605 `(gnus-define-keys-1 (current-local-map) ',plist))
3607 (defmacro gnus-define-keys (keymap &rest plist)
3608 "Define all keys in PLIST in KEYMAP."
3609 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3611 (put 'gnus-define-keys 'lisp-indent-function 1)
3612 (put 'gnus-define-keys 'lisp-indent-hook 1)
3613 (put 'gnus-define-keymap 'lisp-indent-function 1)
3614 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3616 (defmacro gnus-define-keymap (keymap &rest plist)
3617 "Define all keys in PLIST in KEYMAP."
3618 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3620 (defun gnus-define-keys-1 (keymap plist)
3622 (error "Can't set keys in a null keymap"))
3623 (cond ((symbolp keymap)
3624 (setq keymap (symbol-value keymap)))
3627 (set (car keymap) nil)
3628 (define-prefix-command (car keymap))
3629 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3630 (setq keymap (symbol-value (car keymap)))))
3633 (when (symbolp (setq key (pop plist)))
3634 (setq key (symbol-value key)))
3635 (define-key keymap key (pop plist)))))
3637 (defun gnus-group-read-only-p (&optional group)
3638 "Check whether GROUP supports editing or not.
3639 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3640 that that variable is buffer-local to the summary buffers."
3641 (let ((group (or group gnus-newsgroup-name)))
3642 (not (gnus-check-backend-function 'request-replace-article group))))
3644 (defun gnus-group-total-expirable-p (group)
3645 "Check whether GROUP is total-expirable or not."
3646 (let ((params (gnus-info-params (gnus-get-info group))))
3647 (or (memq 'total-expire params)
3648 (cdr (assq 'total-expire params)) ; (total-expire . t)
3649 (and gnus-total-expirable-newsgroups ; Check var.
3650 (string-match gnus-total-expirable-newsgroups group)))))
3652 (defun gnus-group-auto-expirable-p (group)
3653 "Check whether GROUP is total-expirable or not."
3654 (let ((params (gnus-info-params (gnus-get-info group))))
3655 (or (memq 'auto-expire params)
3656 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3657 (and gnus-auto-expirable-newsgroups ; Check var.
3658 (string-match gnus-auto-expirable-newsgroups group)))))
3660 (defun gnus-virtual-group-p (group)
3661 "Say whether GROUP is virtual or not."
3662 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3663 gnus-valid-select-methods)))
3665 (defun gnus-news-group-p (group &optional article)
3666 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3667 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3668 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3669 (eq (gnus-request-type group article) 'news))))
3671 (defsubst gnus-simplify-subject-fully (subject)
3672 "Simplify a subject string according to the user's wishes."
3674 ((null gnus-summary-gather-subject-limit)
3675 (gnus-simplify-subject-re subject))
3676 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3677 (gnus-simplify-subject-fuzzy subject))
3678 ((numberp gnus-summary-gather-subject-limit)
3679 (gnus-limit-string (gnus-simplify-subject-re subject)
3680 gnus-summary-gather-subject-limit))
3684 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3685 "Check whether two subjects are equal. If optional argument
3686 simple-first is t, first argument is already simplified."
3688 ((null simple-first)
3689 (equal (gnus-simplify-subject-fully s1)
3690 (gnus-simplify-subject-fully s2)))
3693 (gnus-simplify-subject-fully s2)))))
3695 ;; Returns a list of writable groups.
3696 (defun gnus-writable-groups ()
3697 (let ((alist gnus-newsrc-alist)
3699 (while (setq group (car (pop alist)))
3700 (unless (gnus-group-read-only-p group)
3701 (push group groups)))
3704 (defun gnus-completing-read (default prompt &rest args)
3705 ;; Like `completing-read', except that DEFAULT is the default argument.
3706 (let* ((prompt (if default
3707 (concat prompt " (default " default ") ")
3708 (concat prompt " ")))
3709 (answer (apply 'completing-read prompt args)))
3710 (if (or (null answer) (zerop (length answer)))
3714 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3716 (defun gnus-y-or-n-p (prompt)
3721 (defun gnus-yes-or-no-p (prompt)
3723 (yes-or-no-p prompt)
3726 ;; Check whether to use long file names.
3727 (defun gnus-use-long-file-name (symbol)
3728 ;; The variable has to be set...
3729 (and gnus-use-long-file-name
3730 ;; If it isn't a list, then we return t.
3731 (or (not (listp gnus-use-long-file-name))
3732 ;; If it is a list, and the list contains `symbol', we
3734 (not (memq symbol gnus-use-long-file-name)))))
3736 ;; I suspect there's a better way, but I haven't taken the time to do
3737 ;; it yet. -erik selberg@cs.washington.edu
3738 (defun gnus-dd-mmm (messy-date)
3739 "Return a string like DD-MMM from a big messy string"
3740 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3746 ;; Make sure leading zeroes are stripped.
3747 (number-to-string (string-to-number (aref datevec 2)))
3751 (nth (1- (string-to-number (aref datevec 1)))
3752 timezone-months-assoc))
3755 (defun gnus-mode-string-quote (string)
3756 "Quote all \"%\" in STRING."
3758 (gnus-set-work-buffer)
3760 (goto-char (point-min))
3761 (while (search-forward "%" nil t)
3765 ;; Make a hash table (default and minimum size is 255).
3766 ;; Optional argument HASHSIZE specifies the table size.
3767 (defun gnus-make-hashtable (&optional hashsize)
3768 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3770 ;; Make a number that is suitable for hashing; bigger than MIN and one
3772 (defun gnus-create-hash-size (min)
3778 ;; Show message if message has a lower level than `gnus-verbose'.
3779 ;; Guideline for numbers:
3780 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3781 ;; for things that take a long time, 7 - not very important messages
3782 ;; on stuff, 9 - messages inside loops.
3783 (defun gnus-message (level &rest args)
3784 (if (<= level gnus-verbose)
3785 (apply 'message args)
3786 ;; We have to do this format thingy here even if the result isn't
3787 ;; shown - the return value has to be the same as the return value
3789 (apply 'format args)))
3791 (defun gnus-error (level &rest args)
3792 "Beep an error if `gnus-verbose' is on LEVEL or less."
3793 (when (<= (floor level) gnus-verbose)
3794 (apply 'message args)
3797 (when (and (floatp level)
3798 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3799 (sit-for duration))))
3802 ;; Generate a unique new group name.
3803 (defun gnus-generate-new-group-name (leaf)
3806 (while (gnus-gethash name gnus-newsrc-hashtb)
3807 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3810 (defsubst gnus-hide-text (b e props)
3811 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3812 (gnus-add-text-properties b e props)
3813 (when (memq 'intangible props)
3814 (gnus-put-text-property (max (1- b) (point-min))
3815 b 'intangible (cddr (memq 'intangible props)))))
3817 (defsubst gnus-unhide-text (b e)
3818 "Remove hidden text properties from region between B and E."
3819 (remove-text-properties b e gnus-hidden-properties)
3820 (when (memq 'intangible gnus-hidden-properties)
3821 (gnus-put-text-property (max (1- b) (point-min))
3822 b 'intangible nil)))
3824 (defun gnus-hide-text-type (b e type)
3825 "Hide text of TYPE between B and E."
3826 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3828 (defun gnus-parent-headers (headers &optional generation)
3829 "Return the headers of the GENERATIONeth parent of HEADERS."
3831 (setq generation 1))
3832 (let (references parent)
3833 (while (and headers (not (zerop generation)))
3834 (setq references (mail-header-references headers))
3835 (when (and references
3836 (setq parent (gnus-parent-id references))
3837 (setq headers (car (gnus-id-to-thread parent))))
3841 (defun gnus-parent-id (references)
3842 "Return the last Message-ID in REFERENCES."
3843 (when (and references
3844 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3845 (substring references (match-beginning 1) (match-end 1))))
3847 (defun gnus-split-references (references)
3848 "Return a list of Message-IDs in REFERENCES."
3851 (while (string-match "<[^>]+>" references beg)
3852 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3856 (defun gnus-buffer-live-p (buffer)
3857 "Say whether BUFFER is alive or not."
3860 (buffer-name (get-buffer buffer))))
3862 (defun gnus-ephemeral-group-p (group)
3863 "Say whether GROUP is ephemeral or not."
3864 (gnus-group-get-parameter group 'quit-config))
3866 (defun gnus-group-quit-config (group)
3867 "Return the quit-config of GROUP."
3868 (gnus-group-get-parameter group 'quit-config))
3870 (defun gnus-simplify-mode-line ()
3871 "Make mode lines a bit simpler."
3872 (setq mode-line-modified "-- ")
3873 (when (listp mode-line-format)
3874 (make-local-variable 'mode-line-format)
3875 (setq mode-line-format (copy-sequence mode-line-format))
3876 (when (equal (nth 3 mode-line-format) " ")
3877 (setcar (nthcdr 3 mode-line-format) " "))))
3879 ;;; List and range functions
3881 (defun gnus-last-element (list)
3882 "Return last element of LIST."
3884 (setq list (cdr list)))
3887 (defun gnus-copy-sequence (list)
3888 "Do a complete, total copy of a list."
3889 (if (and (consp list) (not (consp (cdr list))))
3890 (cons (car list) (cdr list))
3891 (mapcar (lambda (elem) (if (consp elem)
3892 (if (consp (cdr elem))
3893 (gnus-copy-sequence elem)
3894 (cons (car elem) (cdr elem)))
3898 (defun gnus-set-difference (list1 list2)
3899 "Return a list of elements of LIST1 that do not appear in LIST2."
3900 (let ((list1 (copy-sequence list1)))
3902 (setq list1 (delq (car list2) list1))
3903 (setq list2 (cdr list2)))
3906 (defun gnus-sorted-complement (list1 list2)
3907 "Return a list of elements of LIST1 that do not appear in LIST2.
3908 Both lists have to be sorted over <."
3910 (if (or (null list1) (null list2))
3912 (while (and list1 list2)
3913 (cond ((= (car list1) (car list2))
3914 (setq list1 (cdr list1)
3916 ((< (car list1) (car list2))
3917 (setq out (cons (car list1) out))
3918 (setq list1 (cdr list1)))
3920 (setq out (cons (car list2) out))
3921 (setq list2 (cdr list2)))))
3922 (nconc (nreverse out) (or list1 list2)))))
3924 (defun gnus-intersection (list1 list2)
3927 (if (memq (car list2) list1)
3928 (setq result (cons (car list2) result)))
3929 (setq list2 (cdr list2)))
3932 (defun gnus-sorted-intersection (list1 list2)
3933 ;; LIST1 and LIST2 have to be sorted over <.
3935 (while (and list1 list2)
3936 (cond ((= (car list1) (car list2))
3937 (setq out (cons (car list1) out)
3940 ((< (car list1) (car list2))
3941 (setq list1 (cdr list1)))
3943 (setq list2 (cdr list2)))))
3946 (defun gnus-set-sorted-intersection (list1 list2)
3947 ;; LIST1 and LIST2 have to be sorted over <.
3948 ;; This function modifies LIST1.
3949 (let* ((top (cons nil list1))
3951 (while (and list1 list2)
3952 (cond ((= (car list1) (car list2))
3956 ((< (car list1) (car list2))
3957 (setcdr prev (cdr list1))
3958 (setq list1 (cdr list1)))
3960 (setq list2 (cdr list2)))))
3964 (defun gnus-compress-sequence (numbers &optional always-list)
3965 "Convert list of numbers to a list of ranges or a single range.
3966 If ALWAYS-LIST is non-nil, this function will always release a list of
3968 (let* ((first (car numbers))
3969 (last (car numbers))
3973 (if (not (listp (cdr numbers)))
3976 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3977 ((= (1+ last) (car numbers)) ;Still in sequence
3978 (setq last (car numbers)))
3979 (t ;End of one sequence
3981 (cons (if (= first last) first
3982 (cons first last)) result))
3983 (setq first (car numbers))
3984 (setq last (car numbers))))
3985 (setq numbers (cdr numbers)))
3986 (if (and (not always-list) (null result))
3987 (if (= first last) (list first) (cons first last))
3988 (nreverse (cons (if (= first last) first (cons first last))
3991 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3992 (defun gnus-uncompress-range (ranges)
3993 "Expand a list of ranges into a list of numbers.
3994 RANGES is either a single range on the form `(num . num)' or a list of
3996 (let (first last result)
4000 ((not (listp (cdr ranges)))
4001 (setq first (car ranges))
4002 (setq last (cdr ranges))
4003 (while (<= first last)
4004 (setq result (cons first result))
4005 (setq first (1+ first)))
4009 (if (atom (car ranges))
4010 (if (numberp (car ranges))
4011 (setq result (cons (car ranges) result)))
4012 (setq first (caar ranges))
4013 (setq last (cdar ranges))
4014 (while (<= first last)
4015 (setq result (cons first result))
4016 (setq first (1+ first))))
4017 (setq ranges (cdr ranges)))
4018 (nreverse result)))))
4020 (defun gnus-add-to-range (ranges list)
4021 "Return a list of ranges that has all articles from both RANGES and LIST.
4022 Note: LIST has to be sorted over `<'."
4024 (gnus-compress-sequence list t)
4025 (setq list (copy-sequence list))
4026 (or (listp (cdr ranges))
4027 (setq ranges (list ranges)))
4029 ilist lowest highest temp)
4030 (while (and ranges list)
4032 (setq lowest (or (and (atom (car ranges)) (car ranges))
4034 (while (and list (cdr list) (< (cadr list) lowest))
4035 (setq list (cdr list)))
4036 (if (< (car ilist) lowest)
4039 (setq list (cdr list))
4041 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4042 (setq highest (or (and (atom (car ranges)) (car ranges))
4044 (while (and list (<= (car list) highest))
4045 (setq list (cdr list)))
4046 (setq ranges (cdr ranges)))
4048 (setq out (nconc (gnus-compress-sequence list t) out)))
4049 (setq out (sort out (lambda (r1 r2)
4050 (< (or (and (atom r1) r1) (car r1))
4051 (or (and (atom r2) r2) (car r2))))))
4054 (if (atom (car ranges))
4056 (if (atom (cadr ranges))
4057 (if (= (1+ (car ranges)) (cadr ranges))
4059 (setcar ranges (cons (car ranges)
4061 (setcdr ranges (cddr ranges))))
4062 (if (= (1+ (car ranges)) (caadr ranges))
4064 (setcar (cadr ranges) (car ranges))
4065 (setcar ranges (cadr ranges))
4066 (setcdr ranges (cddr ranges))))))
4068 (if (atom (cadr ranges))
4069 (if (= (1+ (cdar ranges)) (cadr ranges))
4071 (setcdr (car ranges) (cadr ranges))
4072 (setcdr ranges (cddr ranges))))
4073 (if (= (1+ (cdar ranges)) (caadr ranges))
4075 (setcdr (car ranges) (cdadr ranges))
4076 (setcdr ranges (cddr ranges)))))))
4077 (setq ranges (cdr ranges)))
4080 (defun gnus-remove-from-range (ranges list)
4081 "Return a list of ranges that has all articles from LIST removed from RANGES.
4082 Note: LIST has to be sorted over `<'."
4083 ;; !!! This function shouldn't look like this, but I've got a headache.
4084 (gnus-compress-sequence
4085 (gnus-sorted-complement
4086 (gnus-uncompress-range ranges) list)))
4088 (defun gnus-member-of-range (number ranges)
4089 (if (not (listp (cdr ranges)))
4090 (and (>= number (car ranges))
4091 (<= number (cdr ranges)))
4094 (if (numberp (car ranges))
4095 (>= number (car ranges))
4096 (>= number (caar ranges)))
4098 (if (if (numberp (car ranges))
4099 (= number (car ranges))
4100 (and (>= number (caar ranges))
4101 (<= number (cdar ranges))))
4102 (setq not-stop nil))
4103 (setq ranges (cdr ranges)))
4106 (defun gnus-range-length (range)
4107 "Return the length RANGE would have if uncompressed."
4108 (length (gnus-uncompress-range range)))
4110 (defun gnus-sublist-p (list sublist)
4111 "Test whether all elements in SUBLIST are members of LIST."
4114 (unless (memq (pop sublist) list)
4124 (defvar gnus-group-mode-map nil)
4125 (put 'gnus-group-mode 'mode-class 'special)
4127 (unless gnus-group-mode-map
4128 (setq gnus-group-mode-map (make-keymap))
4129 (suppress-keymap gnus-group-mode-map)
4131 (gnus-define-keys gnus-group-mode-map
4132 " " gnus-group-read-group
4133 "=" gnus-group-select-group
4134 "\r" gnus-group-select-group
4135 "\M-\r" gnus-group-quick-select-group
4136 "j" gnus-group-jump-to-group
4137 "n" gnus-group-next-unread-group
4138 "p" gnus-group-prev-unread-group
4139 "\177" gnus-group-prev-unread-group
4140 [delete] gnus-group-prev-unread-group
4141 "N" gnus-group-next-group
4142 "P" gnus-group-prev-group
4143 "\M-n" gnus-group-next-unread-group-same-level
4144 "\M-p" gnus-group-prev-unread-group-same-level
4145 "," gnus-group-best-unread-group
4146 "." gnus-group-first-unread-group
4147 "u" gnus-group-unsubscribe-current-group
4148 "U" gnus-group-unsubscribe-group
4149 "c" gnus-group-catchup-current
4150 "C" gnus-group-catchup-current-all
4151 "l" gnus-group-list-groups
4152 "L" gnus-group-list-all-groups
4154 "g" gnus-group-get-new-news
4155 "\M-g" gnus-group-get-new-news-this-group
4156 "R" gnus-group-restart
4157 "r" gnus-group-read-init-file
4158 "B" gnus-group-browse-foreign-server
4159 "b" gnus-group-check-bogus-groups
4160 "F" gnus-find-new-newsgroups
4161 "\C-c\C-d" gnus-group-describe-group
4162 "\M-d" gnus-group-describe-all-groups
4163 "\C-c\C-a" gnus-group-apropos
4164 "\C-c\M-\C-a" gnus-group-description-apropos
4165 "a" gnus-group-post-news
4166 "\ek" gnus-group-edit-local-kill
4167 "\eK" gnus-group-edit-global-kill
4168 "\C-k" gnus-group-kill-group
4169 "\C-y" gnus-group-yank-group
4170 "\C-w" gnus-group-kill-region
4171 "\C-x\C-t" gnus-group-transpose-groups
4172 "\C-c\C-l" gnus-group-list-killed
4173 "\C-c\C-x" gnus-group-expire-articles
4174 "\C-c\M-\C-x" gnus-group-expire-all-groups
4176 "s" gnus-group-save-newsrc
4177 "z" gnus-group-suspend
4178 "Z" gnus-group-clear-dribble
4181 "?" gnus-group-describe-briefly
4182 "\C-c\C-i" gnus-info-find-node
4183 "\M-e" gnus-group-edit-group-method
4184 "^" gnus-group-enter-server-mode
4185 gnus-mouse-2 gnus-mouse-pick-group
4186 "<" beginning-of-buffer
4189 "\C-c\C-s" gnus-group-sort-groups
4191 "\C-c\M-g" gnus-activate-all-groups
4192 "\M-&" gnus-group-universal-argument
4193 "#" gnus-group-mark-group
4194 "\M-#" gnus-group-unmark-group)
4196 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4197 "m" gnus-group-mark-group
4198 "u" gnus-group-unmark-group
4199 "w" gnus-group-mark-region
4200 "m" gnus-group-mark-buffer
4201 "r" gnus-group-mark-regexp
4202 "U" gnus-group-unmark-all-groups)
4204 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4205 "d" gnus-group-make-directory-group
4206 "h" gnus-group-make-help-group
4207 "a" gnus-group-make-archive-group
4208 "k" gnus-group-make-kiboze-group
4209 "m" gnus-group-make-group
4210 "E" gnus-group-edit-group
4211 "e" gnus-group-edit-group-method
4212 "p" gnus-group-edit-group-parameters
4213 "v" gnus-group-add-to-virtual
4214 "V" gnus-group-make-empty-virtual
4215 "D" gnus-group-enter-directory
4216 "f" gnus-group-make-doc-group
4217 "r" gnus-group-rename-group
4218 "\177" gnus-group-delete-group
4219 [delete] gnus-group-delete-group)
4221 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4222 "b" gnus-group-brew-soup
4223 "w" gnus-soup-save-areas
4224 "s" gnus-soup-send-replies
4225 "p" gnus-soup-pack-packet
4226 "r" nnsoup-pack-replies)
4228 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4229 "s" gnus-group-sort-groups
4230 "a" gnus-group-sort-groups-by-alphabet
4231 "u" gnus-group-sort-groups-by-unread
4232 "l" gnus-group-sort-groups-by-level
4233 "v" gnus-group-sort-groups-by-score
4234 "r" gnus-group-sort-groups-by-rank
4235 "m" gnus-group-sort-groups-by-method)
4237 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4238 "k" gnus-group-list-killed
4239 "z" gnus-group-list-zombies
4240 "s" gnus-group-list-groups
4241 "u" gnus-group-list-all-groups
4242 "A" gnus-group-list-active
4243 "a" gnus-group-apropos
4244 "d" gnus-group-description-apropos
4245 "m" gnus-group-list-matching
4246 "M" gnus-group-list-all-matching
4247 "l" gnus-group-list-level)
4249 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4250 "f" gnus-score-flush-cache)
4252 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4253 "f" gnus-group-fetch-faq)
4255 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4256 "l" gnus-group-set-current-level
4257 "t" gnus-group-unsubscribe-current-group
4258 "s" gnus-group-unsubscribe-group
4259 "k" gnus-group-kill-group
4260 "y" gnus-group-yank-group
4261 "w" gnus-group-kill-region
4262 "\C-k" gnus-group-kill-level
4263 "z" gnus-group-kill-all-zombies))
4265 (defun gnus-group-mode ()
4266 "Major mode for reading news.
4268 All normal editing commands are switched off.
4269 \\<gnus-group-mode-map>
4270 The group buffer lists (some of) the groups available. For instance,
4271 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4272 lists all zombie groups.
4274 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4275 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4277 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4279 The following commands are available:
4281 \\{gnus-group-mode-map}"
4283 (when (and menu-bar-mode
4284 (gnus-visual-p 'group-menu 'menu))
4285 (gnus-group-make-menu-bar))
4286 (kill-all-local-variables)
4287 (gnus-simplify-mode-line)
4288 (setq major-mode 'gnus-group-mode)
4289 (setq mode-name "Group")
4290 (gnus-group-set-mode-line)
4291 (setq mode-line-process nil)
4292 (use-local-map gnus-group-mode-map)
4293 (buffer-disable-undo (current-buffer))
4294 (setq truncate-lines t)
4295 (setq buffer-read-only t)
4296 (gnus-make-local-hook 'post-command-hook)
4297 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4298 (run-hooks 'gnus-group-mode-hook))
4300 (defun gnus-clear-inboxes-moved ()
4301 (setq nnmail-moved-inboxes nil))
4303 (defun gnus-mouse-pick-group (e)
4304 "Enter the group under the mouse pointer."
4307 (gnus-group-read-group nil))
4309 ;; Look at LEVEL and find out what the level is really supposed to be.
4310 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4311 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4312 (defun gnus-group-default-level (&optional level number-or-nil)
4314 (gnus-group-use-permanent-levels
4315 (or (setq gnus-group-use-permanent-levels
4316 (or level (if (numberp gnus-group-use-permanent-levels)
4317 gnus-group-use-permanent-levels
4318 (or gnus-group-default-list-level
4319 gnus-level-subscribed))))
4320 gnus-group-default-list-level gnus-level-subscribed))
4324 (or level gnus-group-default-list-level gnus-level-subscribed))))
4327 (defun gnus-slave-no-server (&optional arg)
4328 "Read network news as a slave, without connecting to local server"
4330 (gnus-no-server arg t))
4333 (defun gnus-no-server (&optional arg slave)
4335 If ARG is a positive number, Gnus will use that as the
4336 startup level. If ARG is nil, Gnus will be started at level 2.
4337 If ARG is non-nil and not a positive number, Gnus will
4338 prompt the user for the name of an NNTP server to use.
4339 As opposed to `gnus', this command will not connect to the local server."
4341 (let ((val (or arg (1- gnus-level-default-subscribed))))
4343 (make-local-variable 'gnus-group-use-permanent-levels)
4344 (setq gnus-group-use-permanent-levels val)))
4347 (defun gnus-slave (&optional arg)
4348 "Read news as a slave."
4350 (gnus arg nil 'slave))
4353 (defun gnus-other-frame (&optional arg)
4354 "Pop up a frame to read news."
4356 (if (get-buffer gnus-group-buffer)
4357 (let ((pop-up-frames t))
4359 (select-frame (make-frame))
4363 (defun gnus (&optional arg dont-connect slave)
4365 If ARG is non-nil and a positive number, Gnus will use that as the
4366 startup level. If ARG is non-nil and not a positive number, Gnus will
4367 prompt the user for the name of an NNTP server to use."
4370 (if (get-buffer gnus-group-buffer)
4372 (switch-to-buffer gnus-group-buffer)
4373 (gnus-group-get-new-news))
4376 (nnheader-init-server-buffer)
4377 (gnus-read-init-file)
4378 (setq gnus-slave slave)
4380 (gnus-group-setup-buffer)
4381 (let ((buffer-read-only nil))
4383 (if (not gnus-inhibit-startup-message)
4385 (gnus-group-startup-message)
4388 (let ((level (and (numberp arg) (> arg 0) arg))
4394 (gnus-start-news-server (and arg (not level))))))
4395 (if (and (not dont-connect)
4398 (run-hooks 'gnus-startup-hook)
4399 ;; NNTP server is successfully open.
4401 ;; Find the current startup file name.
4402 (setq gnus-current-startup-file
4403 (gnus-make-newsrc-file gnus-startup-file))
4405 ;; Read the dribble file.
4406 (when (or gnus-slave gnus-use-dribble-file)
4407 (gnus-dribble-read-file))
4409 ;; Allow using GroupLens predictions.
4410 (when gnus-use-grouplens
4412 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4414 (gnus-summary-make-display-table)
4415 ;; Do the actual startup.
4416 (gnus-setup-news nil level dont-connect)
4417 ;; Generate the group buffer.
4418 (gnus-group-list-groups level)
4419 (gnus-group-first-unread-group)
4420 (gnus-configure-windows 'group)
4421 (gnus-group-set-mode-line))))))
4423 (defun gnus-unload ()
4424 "Unload all Gnus features."
4426 (or (boundp 'load-history)
4427 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4428 (let ((history load-history)
4431 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4432 (setq feature (cdr (assq 'provide (car history))))
4433 (unload-feature feature 'force))
4434 (setq history (cdr history)))))
4436 (defun gnus-compile ()
4437 "Byte-compile the user-defined format specs."
4439 (let ((entries gnus-format-specs)
4440 entry gnus-tmp-func)
4442 (gnus-message 7 "Compiling format specs...")
4445 (setq entry (pop entries))
4446 (if (eq (car entry) 'version)
4447 (setq gnus-format-specs (delq entry gnus-format-specs))
4448 (when (and (listp (caddr entry))
4449 (not (eq 'byte-code (caaddr entry))))
4450 (fset 'gnus-tmp-func
4451 `(lambda () ,(caddr entry)))
4452 (byte-compile 'gnus-tmp-func)
4453 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4455 (push (cons 'version emacs-version) gnus-format-specs)
4457 (gnus-message 7 "Compiling user specs...done"))))
4459 (defun gnus-indent-rigidly (start end arg)
4460 "Indent rigidly using only spaces and no tabs."
4463 (narrow-to-region start end)
4464 (indent-rigidly start end arg)
4465 (goto-char (point-min))
4466 (while (search-forward "\t" nil t)
4467 (replace-match " " t t)))))
4469 (defun gnus-group-startup-message (&optional x y)
4470 "Insert startup message in current buffer."
4471 ;; Insert the message.
4476 _ ___ __ ___ __ _ ___
4495 ;; And then hack it.
4496 (gnus-indent-rigidly (point-min) (point-max)
4497 (/ (max (- (window-width) (or x 46)) 0) 2))
4498 (goto-char (point-min))
4500 (let* ((pheight (count-lines (point-min) (point-max)))
4501 (wheight (window-height))
4502 (rest (- wheight pheight)))
4503 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4505 (goto-char (point-min))
4506 (and (search-forward "Praxis" nil t)
4507 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4508 (goto-char (point-min))
4509 (let* ((mode-string (gnus-group-set-mode-line)))
4510 (setq mode-line-buffer-identification
4511 (list (concat gnus-version (substring (car mode-string) 4))))
4512 (set-buffer-modified-p t)))
4514 (defun gnus-group-setup-buffer ()
4515 (or (get-buffer gnus-group-buffer)
4517 (switch-to-buffer gnus-group-buffer)
4518 (gnus-add-current-to-buffer-list)
4520 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4522 (defun gnus-group-list-groups (&optional level unread lowest)
4523 "List newsgroups with level LEVEL or lower that have unread articles.
4524 Default is all subscribed groups.
4525 If argument UNREAD is non-nil, groups with no unread articles are also
4527 (interactive (list (if current-prefix-arg
4528 (prefix-numeric-value current-prefix-arg)
4530 (gnus-group-default-level nil t)
4531 gnus-group-default-list-level
4532 gnus-level-subscribed))))
4534 (setq level (car gnus-group-list-mode)
4535 unread (cdr gnus-group-list-mode)))
4536 (setq level (gnus-group-default-level level))
4537 (gnus-group-setup-buffer) ;May call from out of group buffer
4538 (gnus-update-format-specifications)
4539 (let ((case-fold-search nil)
4540 (props (text-properties-at (gnus-point-at-bol)))
4541 (group (gnus-group-group-name)))
4542 (set-buffer gnus-group-buffer)
4543 (funcall gnus-group-prepare-function level unread lowest)
4544 (if (zerop (buffer-size))
4545 (gnus-message 5 gnus-no-groups-message)
4546 (goto-char (point-max))
4547 (when (or (not gnus-group-goto-next-group-function)
4548 (not (funcall gnus-group-goto-next-group-function
4551 ;; Go to the first group with unread articles.
4552 (gnus-group-search-forward t)
4553 ;; Find the right group to put point on. If the current group
4554 ;; has disappeared in the new listing, try to find the next
4555 ;; one. If no next one can be found, just leave point at the
4556 ;; first newsgroup in the buffer.
4557 (if (not (gnus-goto-char
4559 (point-min) (point-max)
4560 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4561 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4563 (not (gnus-goto-char
4565 (point-min) (point-max) 'gnus-group
4567 (caar newsrc) gnus-active-hashtb)))))
4568 (setq newsrc (cdr newsrc)))
4569 (or newsrc (progn (goto-char (point-max))
4570 (forward-line -1)))))))
4571 ;; Adjust cursor point.
4572 (gnus-group-position-point))))
4574 (defun gnus-group-list-level (level &optional all)
4575 "List groups on LEVEL.
4576 If ALL (the prefix), also list groups that have no unread articles."
4577 (interactive "nList groups on level: \nP")
4578 (gnus-group-list-groups level all level))
4580 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4581 "List all newsgroups with unread articles of level LEVEL or lower.
4582 If ALL is non-nil, list groups that have no unread articles.
4583 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4584 If REGEXP, only list groups matching REGEXP."
4585 (set-buffer gnus-group-buffer)
4586 (let ((buffer-read-only nil)
4587 (newsrc (cdr gnus-newsrc-alist))
4588 (lowest (or lowest 1))
4589 info clevel unread group params)
4591 (if (< lowest gnus-level-zombie)
4592 ;; List living groups.
4594 (setq info (car newsrc)
4595 group (gnus-info-group info)
4596 params (gnus-info-params info)
4598 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4599 (and unread ; This group might be bogus
4601 (string-match regexp group))
4602 (<= (setq clevel (gnus-info-level info)) level)
4604 (or all ; We list all groups?
4605 (if (eq unread t) ; Unactivated?
4606 gnus-group-list-inactive-groups ; We list unactivated
4607 (> unread 0)) ; We list groups with unread articles
4608 (and gnus-list-groups-with-ticked-articles
4609 (cdr (assq 'tick (gnus-info-marks info))))
4610 ; And groups with tickeds
4611 ;; Check for permanent visibility.
4612 (and gnus-permanently-visible-groups
4613 (string-match gnus-permanently-visible-groups
4615 (memq 'visible params)
4616 (cdr (assq 'visible params)))
4617 (gnus-group-insert-group-line
4618 group (gnus-info-level info)
4619 (gnus-info-marks info) unread (gnus-info-method info)))))
4621 ;; List dead groups.
4622 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4623 (gnus-group-prepare-flat-list-dead
4624 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4625 gnus-level-zombie ?Z
4627 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4628 (gnus-group-prepare-flat-list-dead
4629 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4630 gnus-level-killed ?K regexp))
4632 (gnus-group-set-mode-line)
4633 (setq gnus-group-list-mode (cons level all))
4634 (run-hooks 'gnus-group-prepare-hook)))
4636 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4637 ;; List zombies and killed lists somewhat faster, which was
4638 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4639 ;; this by ignoring the group format specification altogether.
4642 ;; This loop is used when listing groups that match some
4645 (setq group (pop groups))
4646 (when (string-match regexp group)
4647 (gnus-add-text-properties
4648 (point) (prog1 (1+ (point))
4649 (insert " " mark " *: " group "\n"))
4650 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4652 'gnus-level level))))
4653 ;; This loop is used when listing all groups.
4655 (gnus-add-text-properties
4656 (point) (prog1 (1+ (point))
4657 (insert " " mark " *: "
4658 (setq group (pop groups)) "\n"))
4659 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4661 'gnus-level level))))))
4663 (defmacro gnus-group-real-name (group)
4664 "Find the real name of a foreign newsgroup."
4665 `(let ((gname ,group))
4666 (if (string-match ":[^:]+$" gname)
4667 (substring gname (1+ (match-beginning 0)))
4670 (defsubst gnus-server-add-address (method)
4671 (let ((method-name (symbol-name (car method))))
4672 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4673 (not (assq (intern (concat method-name "-address")) method)))
4674 (append method (list (list (intern (concat method-name "-address"))
4678 (defsubst gnus-server-get-method (group method)
4679 ;; Input either a server name, and extended server name, or a
4680 ;; select method, and return a select method.
4681 (cond ((stringp method)
4682 (gnus-server-to-method method))
4683 ((equal method gnus-select-method)
4685 ((and (stringp (car method)) group)
4686 (gnus-server-extend-method group method))
4687 ((and method (not group)
4688 (equal (cadr method) ""))
4691 (gnus-server-add-address method))))
4693 (defun gnus-server-to-method (server)
4694 "Map virtual server names to select methods."
4696 ;; Is this a method, perhaps?
4697 (and server (listp server) server)
4698 ;; Perhaps this is the native server?
4699 (and (equal server "native") gnus-select-method)
4700 ;; It should be in the server alist.
4701 (cdr (assoc server gnus-server-alist))
4702 ;; If not, we look through all the opened server
4703 ;; to see whether we can find it there.
4704 (let ((opened gnus-opened-servers))
4706 (not (equal server (format "%s:%s" (caaar opened)
4711 (defmacro gnus-method-equal (ss1 ss2)
4712 "Say whether two servers are equal."
4716 (and (= (length s1) (length s2))
4718 (while (and s1 (member (car s1) s2))
4722 (defun gnus-server-equal (m1 m2)
4723 "Say whether two methods are equal."
4724 (let ((m1 (cond ((null m1) gnus-select-method)
4725 ((stringp m1) (gnus-server-to-method m1))
4727 (m2 (cond ((null m2) gnus-select-method)
4728 ((stringp m2) (gnus-server-to-method m2))
4730 (gnus-method-equal m1 m2)))
4732 (defun gnus-servers-using-backend (backend)
4733 "Return a list of known servers using BACKEND."
4734 (let ((opened gnus-opened-servers)
4737 (when (eq backend (caaar opened))
4738 (push (caar opened) out))
4742 (defun gnus-group-prefixed-name (group method)
4743 "Return the whole name from GROUP and METHOD."
4744 (and (stringp method) (setq method (gnus-server-to-method method)))
4745 (concat (format "%s" (car method))
4747 (or (assoc (format "%s" (car method))
4748 (gnus-methods-using 'address))
4749 (gnus-server-equal method gnus-message-archive-method))
4751 (not (string= (nth 1 method) "")))
4752 (concat "+" (nth 1 method)))
4755 (defun gnus-group-real-prefix (group)
4756 "Return the prefix of the current group name."
4757 (if (string-match "^[^:]+:" group)
4758 (substring group 0 (match-end 0))
4761 (defun gnus-group-method (group)
4762 "Return the server or method used for selecting GROUP."
4763 (let ((prefix (gnus-group-real-prefix group)))
4764 (if (equal prefix "")
4766 (let ((servers gnus-opened-servers)
4768 backend possible found)
4769 (if (string-match "^[^\\+]+\\+" prefix)
4770 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4771 server (substring prefix (match-end 0) (1- (length prefix))))
4772 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4774 (when (eq (caaar servers) backend)
4775 (setq possible (caar servers))
4776 (when (equal (cadaar servers) server)
4777 (setq found (caar servers))))
4779 (or (car (rassoc found gnus-server-alist))
4781 (car (rassoc possible gnus-server-alist))
4783 (list backend server))))))
4785 (defsubst gnus-secondary-method-p (method)
4786 "Return whether METHOD is a secondary select method."
4787 (let ((methods gnus-secondary-select-methods)
4788 (gmethod (gnus-server-get-method nil method)))
4790 (not (equal (gnus-server-get-method nil (car methods))
4792 (setq methods (cdr methods)))
4795 (defun gnus-group-foreign-p (group)
4796 "Say whether a group is foreign or not."
4797 (and (not (gnus-group-native-p group))
4798 (not (gnus-group-secondary-p group))))
4800 (defun gnus-group-native-p (group)
4801 "Say whether the group is native or not."
4802 (not (string-match ":" group)))
4804 (defun gnus-group-secondary-p (group)
4805 "Say whether the group is secondary or not."
4806 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4808 (defun gnus-group-get-parameter (group &optional symbol)
4809 "Returns the group parameters for GROUP.
4810 If SYMBOL, return the value of that symbol in the group parameters."
4811 (let ((params (gnus-info-params (gnus-get-info group))))
4813 (gnus-group-parameter-value params symbol)
4816 (defun gnus-group-parameter-value (params symbol)
4817 "Return the value of SYMBOL in group PARAMS."
4818 (or (car (memq symbol params)) ; It's either a simple symbol
4819 (cdr (assq symbol params)))) ; or a cons.
4821 (defun gnus-group-add-parameter (group param)
4822 "Add parameter PARAM to GROUP."
4823 (let ((info (gnus-get-info group)))
4825 () ; This is a dead group. We just ignore it.
4826 ;; Cons the new param to the old one and update.
4827 (gnus-group-set-info (cons param (gnus-info-params info))
4830 (defun gnus-group-set-parameter (group name value)
4831 "Set parameter NAME to VALUE in GROUP."
4832 (let ((info (gnus-get-info group)))
4834 () ; This is a dead group. We just ignore it.
4835 (let ((old-params (gnus-info-params info))
4836 (new-params (list (cons name value))))
4838 (if (or (not (listp (car old-params)))
4839 (not (eq (caar old-params) name)))
4840 (setq new-params (append new-params (list (car old-params)))))
4841 (setq old-params (cdr old-params)))
4842 (gnus-group-set-info new-params group 'params)))))
4844 (defun gnus-group-add-score (group &optional score)
4845 "Add SCORE to the GROUP score.
4846 If SCORE is nil, add 1 to the score of GROUP."
4847 (let ((info (gnus-get-info group)))
4849 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4851 (defun gnus-summary-bubble-group ()
4852 "Increase the score of the current group.
4853 This is a handy function to add to `gnus-summary-exit-hook' to
4854 increase the score of each group you read."
4855 (gnus-group-add-score gnus-newsgroup-name))
4857 (defun gnus-group-set-info (info &optional method-only-group part)
4858 (let* ((entry (gnus-gethash
4859 (or method-only-group (gnus-info-group info))
4860 gnus-newsrc-hashtb))
4862 (info (if method-only-group (nth 2 entry) info))
4864 (when method-only-group
4866 (error "Trying to change non-existent group %s" method-only-group))
4867 ;; We have received parts of the actual group info - either the
4868 ;; select method or the group parameters. We first check
4869 ;; whether we have to extend the info, and if so, do that.
4870 (let ((len (length info))
4871 (total (if (eq part 'method) 5 6)))
4873 (setcdr (nthcdr (1- len) info)
4874 (make-list (- total len) nil)))
4875 ;; Then we enter the new info.
4876 (setcar (nthcdr (1- total) info) part-info)))
4878 ;; This is a new group, so we just create it.
4880 (set-buffer gnus-group-buffer)
4881 (setq method (gnus-info-method info))
4882 (when (gnus-server-equal method "native")
4885 (set-buffer gnus-group-buffer)
4887 ;; It's a foreign group...
4888 (gnus-group-make-group
4889 (gnus-group-real-name (gnus-info-group info))
4890 (if (stringp method) method
4891 (prin1-to-string (car method)))
4893 (nth 1 (gnus-info-method info))))
4894 ;; It's a native group.
4895 (gnus-group-make-group (gnus-info-group info))))
4896 (gnus-message 6 "Note: New group created")
4898 (gnus-gethash (gnus-group-prefixed-name
4899 (gnus-group-real-name (gnus-info-group info))
4900 (or (gnus-info-method info) gnus-select-method))
4901 gnus-newsrc-hashtb))))
4902 ;; Whether it was a new group or not, we now have the entry, so we
4903 ;; can do the update.
4906 (setcar (nthcdr 2 entry) info)
4907 (when (and (not (eq (car entry) t))
4908 (gnus-active (gnus-info-group info)))
4909 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4910 (error "No such group: %s" (gnus-info-group info)))))
4912 (defun gnus-group-set-method-info (group select-method)
4913 (gnus-group-set-info select-method group 'method))
4915 (defun gnus-group-set-params-info (group params)
4916 (gnus-group-set-info params group 'params))
4918 (defun gnus-group-update-group-line ()
4919 "Update the current line in the group buffer."
4920 (let* ((buffer-read-only nil)
4921 (group (gnus-group-group-name))
4922 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4923 gnus-group-indentation)
4925 (not (gnus-ephemeral-group-p group))
4927 (concat "(gnus-group-set-info '"
4928 (prin1-to-string (nth 2 entry)) ")")))
4929 (setq gnus-group-indentation (gnus-group-group-indentation))
4931 (gnus-group-insert-group-line-info group)
4933 (gnus-group-position-point)))
4935 (defun gnus-group-insert-group-line-info (group)
4936 "Insert GROUP on the current line."
4937 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4941 ;; (Un)subscribed group.
4942 (setq info (nth 2 entry))
4943 (gnus-group-insert-group-line
4944 group (gnus-info-level info) (gnus-info-marks info)
4945 (or (car entry) t) (gnus-info-method info)))
4946 ;; This group is dead.
4947 (gnus-group-insert-group-line
4949 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4951 (if (setq active (gnus-active group))
4952 (- (1+ (cdr active)) (car active)) 0)
4955 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4956 gnus-tmp-marked number
4958 "Insert a group line in the group buffer."
4959 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4960 (gnus-tmp-number-total
4962 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4964 (gnus-tmp-number-of-unread
4965 (if (numberp number) (int-to-string (max 0 number))
4967 (gnus-tmp-number-of-read
4968 (if (numberp number)
4969 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4971 (gnus-tmp-subscribed
4972 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4973 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4974 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4976 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4977 (gnus-tmp-newsgroup-description
4978 (if gnus-description-hashtb
4979 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4982 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4983 (gnus-tmp-moderated-string
4984 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4986 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4987 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4988 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4989 (gnus-tmp-news-method-string
4991 (format "(%s:%s)" (car gnus-tmp-method)
4992 (cadr gnus-tmp-method)) ""))
4993 (gnus-tmp-marked-mark
4994 (if (and (numberp number)
4996 (cdr (assq 'tick gnus-tmp-marked)))
4998 (gnus-tmp-process-marked
4999 (if (member gnus-tmp-group gnus-group-marked)
5000 gnus-process-mark ? ))
5002 (or (and gnus-use-grouplens
5003 (bbb-grouplens-group-p gnus-tmp-group))
5005 (buffer-read-only nil)
5006 header gnus-tmp-header) ; passed as parameter to user-funcs.
5008 (gnus-add-text-properties
5012 (eval gnus-group-line-format-spec))
5013 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5014 gnus-unread ,(if (numberp number)
5015 (string-to-int gnus-tmp-number-of-unread)
5017 gnus-marked ,gnus-tmp-marked-mark
5018 gnus-indentation ,gnus-group-indentation
5019 gnus-level ,gnus-tmp-level))
5020 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5022 (run-hooks 'gnus-group-update-hook)
5024 ;; Allow XEmacs to remove front-sticky text properties.
5025 (gnus-group-remove-excess-properties)))
5027 (defun gnus-group-update-group (group &optional visible-only)
5028 "Update all lines where GROUP appear.
5029 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5032 (set-buffer gnus-group-buffer)
5033 ;; The buffer may be narrowed.
5036 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5038 found buffer-read-only)
5039 ;; Enter the current status into the dribble buffer.
5040 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5041 (if (and entry (not (gnus-ephemeral-group-p group)))
5043 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5045 ;; Find all group instances. If topics are in use, each group
5046 ;; may be listed in more than once.
5047 (while (setq loc (text-property-any
5048 loc (point-max) 'gnus-group ident))
5051 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5053 (gnus-group-insert-group-line-info group)
5056 (run-hooks 'gnus-group-update-group-hook)))
5057 (setq loc (1+ loc)))
5058 (unless (or found visible-only)
5059 ;; No such line in the buffer, find out where it's supposed to
5060 ;; go, and insert it there (or at the end of the buffer).
5061 (if gnus-goto-missing-group-function
5062 (funcall gnus-goto-missing-group-function group)
5063 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5064 (while (and entry (car entry)
5068 (point-min) (point-max)
5069 'gnus-group (gnus-intern-safe
5070 (caar entry) gnus-active-hashtb)))))
5071 (setq entry (cdr entry)))
5072 (or entry (goto-char (point-max)))))
5073 ;; Finally insert the line.
5074 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5075 (gnus-group-insert-group-line-info group)
5078 (run-hooks 'gnus-group-update-group-hook))))
5079 (gnus-group-set-mode-line)))))
5081 (defun gnus-group-set-mode-line ()
5082 "Update the mode line in the group buffer."
5083 (when (memq 'group gnus-updated-mode-lines)
5084 ;; Yes, we want to keep this mode line updated.
5086 (set-buffer gnus-group-buffer)
5087 (let* ((gformat (or gnus-group-mode-line-format-spec
5088 (setq gnus-group-mode-line-format-spec
5090 gnus-group-mode-line-format
5091 gnus-group-mode-line-format-alist))))
5092 (gnus-tmp-news-server (cadr gnus-select-method))
5093 (gnus-tmp-news-method (car gnus-select-method))
5094 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5096 gnus-tmp-header ;Dummy binding for user-defined formats
5097 ;; Get the resulting string.
5098 (mode-string (eval gformat)))
5099 ;; Say whether the dribble buffer has been modified.
5100 (setq mode-line-modified
5101 (if (and gnus-dribble-buffer
5102 (buffer-name gnus-dribble-buffer)
5103 (buffer-modified-p gnus-dribble-buffer)
5105 (set-buffer gnus-dribble-buffer)
5106 (not (zerop (buffer-size)))))
5108 ;; If the line is too long, we chop it off.
5109 (when (> (length mode-string) max-len)
5110 (setq mode-string (substring mode-string 0 (- max-len 4))))
5112 (setq mode-line-buffer-identification
5114 (set-buffer-modified-p t))))))
5116 (defun gnus-group-group-name ()
5117 "Get the name of the newsgroup on the current line."
5118 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5119 (and group (symbol-name group))))
5121 (defun gnus-group-group-level ()
5122 "Get the level of the newsgroup on the current line."
5123 (get-text-property (gnus-point-at-bol) 'gnus-level))
5125 (defun gnus-group-group-indentation ()
5126 "Get the indentation of the newsgroup on the current line."
5127 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5128 (and gnus-group-indentation-function
5129 (funcall gnus-group-indentation-function))
5132 (defun gnus-group-group-unread ()
5133 "Get the number of unread articles of the newsgroup on the current line."
5134 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5136 (defun gnus-group-search-forward (&optional backward all level first-too)
5137 "Find the next newsgroup with unread articles.
5138 If BACKWARD is non-nil, find the previous newsgroup instead.
5139 If ALL is non-nil, just find any newsgroup.
5140 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5142 If FIRST-TOO, the current line is also eligible as a target."
5143 (let ((way (if backward -1 1))
5144 (low gnus-level-killed)
5147 (if (and backward (progn (beginning-of-line)) (bobp))
5149 (or first-too (forward-line way))
5157 (get-text-property (point) 'gnus-unread)))
5158 (and (numberp unread) (> unread 0)))
5159 (setq lev (get-text-property (point)
5161 (<= lev gnus-level-subscribed)))
5163 (and (setq lev (get-text-property (point)
5172 (zerop (forward-line way)))))
5174 (progn (gnus-group-position-point) t)
5175 (goto-char (or pos beg))
5178 ;;; Gnus group mode commands
5182 (defun gnus-group-mark-group (n &optional unmark no-advance)
5183 "Mark the current group."
5185 (let ((buffer-read-only nil)
5189 (when (setq group (gnus-group-group-name))
5193 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5198 (setq gnus-group-marked (delete group gnus-group-marked)))
5200 (setq gnus-group-marked
5201 (cons group (delete group gnus-group-marked)))))
5202 (or no-advance (gnus-group-next-group 1))
5204 (gnus-summary-position-point)
5207 (defun gnus-group-unmark-group (n)
5208 "Remove the mark from the current group."
5210 (gnus-group-mark-group n 'unmark)
5211 (gnus-group-position-point))
5213 (defun gnus-group-unmark-all-groups ()
5214 "Unmark all groups."
5216 (let ((groups gnus-group-marked))
5219 (gnus-group-remove-mark (pop groups)))))
5220 (gnus-group-position-point))
5222 (defun gnus-group-mark-region (unmark beg end)
5223 "Mark all groups between point and mark.
5224 If UNMARK, remove the mark instead."
5225 (interactive "P\nr")
5226 (let ((num (count-lines beg end)))
5229 (- num (gnus-group-mark-group num unmark)))))
5231 (defun gnus-group-mark-buffer (&optional unmark)
5232 "Mark all groups in the buffer.
5233 If UNMARK, remove the mark instead."
5235 (gnus-group-mark-region unmark (point-min) (point-max)))
5237 (defun gnus-group-mark-regexp (regexp)
5238 "Mark all groups that match some regexp."
5239 (interactive "sMark (regexp): ")
5240 (let ((alist (cdr gnus-newsrc-alist))
5243 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5244 (gnus-group-set-mark group))))
5245 (gnus-group-position-point))
5247 (defun gnus-group-remove-mark (group)
5248 "Remove the process mark from GROUP and move point there.
5249 Return nil if the group isn't displayed."
5250 (if (gnus-group-goto-group group)
5252 (gnus-group-mark-group 1 'unmark t)
5254 (setq gnus-group-marked
5255 (delete group gnus-group-marked))
5258 (defun gnus-group-set-mark (group)
5259 "Set the process mark on GROUP."
5260 (if (gnus-group-goto-group group)
5262 (gnus-group-mark-group 1 nil t))
5263 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5265 (defun gnus-group-universal-argument (arg &optional groups func)
5266 "Perform any command on all groups accoring to the process/prefix convention."
5268 (let ((groups (or groups (gnus-group-process-prefix arg)))
5270 (if (eq (setq func (or func
5273 (substitute-command-keys
5274 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5276 (gnus-error 1 "Undefined key")
5278 (gnus-group-remove-mark (setq group (pop groups)))
5279 (command-execute func))))
5280 (gnus-group-position-point))
5282 (defun gnus-group-process-prefix (n)
5283 "Return a list of groups to work on.
5284 Take into consideration N (the prefix) and the list of marked groups."
5287 (setq n (prefix-numeric-value n))
5288 ;; There is a prefix, so we return a list of the N next
5290 (let ((way (if (< n 0) -1 1))
5295 (setq group (gnus-group-group-name)))
5296 (setq groups (cons group groups))
5298 (gnus-group-next-group way)))
5300 ((and (boundp 'transient-mark-mode)
5302 (boundp 'mark-active)
5304 ;; Work on the region between point and mark.
5305 (let ((max (max (point) (mark)))
5308 (goto-char (min (point) (mark)))
5311 (push (gnus-group-group-name) groups)
5312 (zerop (gnus-group-next-group 1))
5314 (nreverse groups))))
5316 ;; No prefix, but a list of marked articles.
5317 (reverse gnus-group-marked))
5319 ;; Neither marked articles or a prefix, so we return the
5321 (let ((group (gnus-group-group-name)))
5322 (and group (list group))))))
5324 ;; Selecting groups.
5326 (defun gnus-group-read-group (&optional all no-article group)
5327 "Read news in this newsgroup.
5328 If the prefix argument ALL is non-nil, already read articles become
5329 readable. IF ALL is a number, fetch this number of articles. If the
5330 optional argument NO-ARTICLE is non-nil, no article will be
5331 auto-selected upon group entry. If GROUP is non-nil, fetch that
5334 (let ((group (or group (gnus-group-group-name)))
5335 number active marked entry)
5336 (or group (error "No group on current line"))
5337 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5338 group gnus-newsrc-hashtb)))))
5339 ;; This group might be a dead group. In that case we have to get
5340 ;; the number of unread articles from `gnus-active-hashtb'.
5342 (cond ((numberp all) all)
5344 ((setq active (gnus-active group))
5345 (- (1+ (cdr active)) (car active)))))
5346 (gnus-summary-read-group
5347 group (or all (and (numberp number)
5348 (zerop (+ number (length (cdr (assq 'tick marked)))
5349 (length (cdr (assq 'dormant marked)))))))
5352 (defun gnus-group-select-group (&optional all)
5353 "Select this newsgroup.
5354 No article is selected automatically.
5355 If ALL is non-nil, already read articles become readable.
5356 If ALL is a number, fetch this number of articles."
5358 (gnus-group-read-group all t))
5360 (defun gnus-group-quick-select-group (&optional all)
5361 "Select the current group \"quickly\".
5362 This means that no highlighting or scoring will be performed."
5365 gnus-score-find-score-files-function
5366 gnus-apply-kill-hook
5367 gnus-summary-expunge-below)
5368 (gnus-group-read-group all t)))
5370 (defun gnus-group-visible-select-group (&optional all)
5371 "Select the current group without hiding any articles."
5373 (let ((gnus-inhibit-limiting t))
5374 (gnus-group-read-group all t)))
5377 (defun gnus-fetch-group (group)
5378 "Start Gnus if necessary and enter GROUP.
5379 Returns whether the fetching was successful or not."
5380 (interactive "sGroup name: ")
5381 (or (get-buffer gnus-group-buffer)
5383 (gnus-group-read-group nil nil group))
5385 ;; Enter a group that is not in the group buffer. Non-nil is returned
5386 ;; if selection was successful.
5387 (defun gnus-group-read-ephemeral-group
5388 (group method &optional activate quit-config)
5389 (let ((group (if (gnus-group-foreign-p group) group
5390 (gnus-group-prefixed-name group method))))
5393 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5394 ((quit-config . ,(if quit-config quit-config
5395 (cons (current-buffer) 'summary))))))
5397 (set-buffer gnus-group-buffer)
5398 (or (gnus-check-server method)
5399 (error "Unable to contact server: %s" (gnus-status-message method)))
5400 (if activate (or (gnus-request-group group)
5401 (error "Couldn't request group")))
5403 (gnus-group-read-group t t group)
5407 (defun gnus-group-jump-to-group (group)
5408 "Jump to newsgroup GROUP."
5410 (list (completing-read
5411 "Group: " gnus-active-hashtb nil
5412 (gnus-read-active-file-p)
5414 'gnus-group-history)))
5416 (when (equal group "")
5417 (error "Empty group name"))
5419 (when (string-match "[\000-\032]" group)
5420 (error "Control characters in group: %s" group))
5422 (let ((b (text-property-any
5423 (point-min) (point-max)
5424 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5425 (unless (gnus-ephemeral-group-p group)
5427 ;; Either go to the line in the group buffer...
5429 ;; ... or insert the line.
5432 (gnus-activate-group group)
5433 (error "%s error: %s" group (gnus-status-message group)))
5435 (gnus-group-update-group group)
5436 (goto-char (text-property-any
5437 (point-min) (point-max)
5438 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5439 ;; Adjust cursor point.
5440 (gnus-group-position-point)))
5442 (defun gnus-group-goto-group (group)
5443 "Goto to newsgroup GROUP."
5445 (let ((b (text-property-any (point-min) (point-max)
5446 'gnus-group (gnus-intern-safe
5447 group gnus-active-hashtb))))
5448 (and b (goto-char b)))))
5450 (defun gnus-group-next-group (n)
5451 "Go to next N'th newsgroup.
5452 If N is negative, search backward instead.
5453 Returns the difference between N and the number of skips actually
5456 (gnus-group-next-unread-group n t))
5458 (defun gnus-group-next-unread-group (n &optional all level)
5459 "Go to next N'th unread newsgroup.
5460 If N is negative, search backward instead.
5461 If ALL is non-nil, choose any newsgroup, unread or not.
5462 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5463 such group can be found, the next group with a level higher than
5465 Returns the difference between N and the number of skips actually
5468 (let ((backward (< n 0))
5471 (gnus-group-search-forward
5472 backward (or (not gnus-group-goto-unread) all) level))
5474 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5475 (if level " on this level or higher" "")))
5478 (defun gnus-group-prev-group (n)
5479 "Go to previous N'th newsgroup.
5480 Returns the difference between N and the number of skips actually
5483 (gnus-group-next-unread-group (- n) t))
5485 (defun gnus-group-prev-unread-group (n)
5486 "Go to previous N'th unread newsgroup.
5487 Returns the difference between N and the number of skips actually
5490 (gnus-group-next-unread-group (- n)))
5492 (defun gnus-group-next-unread-group-same-level (n)
5493 "Go to next N'th unread newsgroup on the same level.
5494 If N is negative, search backward instead.
5495 Returns the difference between N and the number of skips actually
5498 (gnus-group-next-unread-group n t (gnus-group-group-level))
5499 (gnus-group-position-point))
5501 (defun gnus-group-prev-unread-group-same-level (n)
5502 "Go to next N'th unread newsgroup on the same level.
5503 Returns the difference between N and the number of skips actually
5506 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5507 (gnus-group-position-point))
5509 (defun gnus-group-best-unread-group (&optional exclude-group)
5510 "Go to the group with the highest level.
5511 If EXCLUDE-GROUP, do not go to that group."
5513 (goto-char (point-min))
5517 (setq unread (get-text-property (point) 'gnus-unread))
5518 (if (and (numberp unread) (> unread 0))
5520 (if (and (get-text-property (point) 'gnus-level)
5521 (< (get-text-property (point) 'gnus-level) best)
5522 (or (not exclude-group)
5523 (not (equal exclude-group (gnus-group-group-name)))))
5525 (setq best (get-text-property (point) 'gnus-level))
5526 (setq best-point (point))))))
5528 (if best-point (goto-char best-point))
5529 (gnus-summary-position-point)
5530 (and best-point (gnus-group-group-name))))
5532 (defun gnus-group-first-unread-group ()
5533 "Go to the first group with unread articles."
5536 (let ((opoint (point))
5538 (goto-char (point-min))
5539 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5540 (and (numberp unread) ; Not a topic.
5541 (not (zerop unread))) ; Has unread articles.
5542 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5545 nil)) ; Not success.
5546 (gnus-group-position-point)))
5548 (defun gnus-group-enter-server-mode ()
5549 "Jump to the server buffer."
5551 (gnus-enter-server-buffer))
5553 (defun gnus-group-make-group (name &optional method address)
5554 "Add a new newsgroup.
5555 The user will be prompted for a NAME, for a select METHOD, and an
5559 (read-string "Group name: ")
5562 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5563 nil t nil 'gnus-method-history)))
5564 (cond ((assoc method gnus-valid-select-methods)
5566 (if (memq 'prompt-address
5567 (assoc method gnus-valid-select-methods))
5568 (read-string "Address: ")
5570 ((assoc method gnus-server-alist)
5573 (list method ""))))))
5575 (let* ((meth (and method (if address (list (intern method) address)
5577 (nname (if method (gnus-group-prefixed-name name meth) name))
5579 (when (gnus-gethash nname gnus-newsrc-hashtb)
5580 (error "Group %s already exists" nname))
5581 ;; Subscribe to the new group.
5582 (gnus-group-change-level
5583 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5584 gnus-level-default-subscribed gnus-level-killed
5585 (and (gnus-group-group-name)
5586 (gnus-gethash (gnus-group-group-name)
5587 gnus-newsrc-hashtb))
5590 (gnus-set-active nname (cons 1 0))
5591 (or (gnus-ephemeral-group-p name)
5593 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5595 (gnus-group-insert-group-line-info nname)
5597 (gnus-group-position-point)
5599 ;; Load the backend and try to make the backend create
5600 ;; the group as well.
5601 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5603 gnus-valid-select-methods)
5605 (gnus-check-server meth)
5606 (and (gnus-check-backend-function 'request-create-group nname)
5607 (gnus-request-create-group nname))
5610 (defun gnus-group-delete-group (group &optional force)
5611 "Delete the current group.
5612 If FORCE (the prefix) is non-nil, all the articles in the group will
5613 be deleted. This is \"deleted\" as in \"removed forever from the face
5614 of the Earth\". There is no undo."
5616 (list (gnus-group-group-name)
5617 current-prefix-arg))
5618 (or group (error "No group to rename"))
5619 (or (gnus-check-backend-function 'request-delete-group group)
5620 (error "This backend does not support group deletion"))
5622 (if (not (gnus-yes-or-no-p
5624 "Do you really want to delete %s%s? "
5625 group (if force " and all its contents" ""))))
5627 (gnus-message 6 "Deleting group %s..." group)
5628 (if (not (gnus-request-delete-group group force))
5629 (gnus-error 3 "Couldn't delete group %s" group)
5630 (gnus-message 6 "Deleting group %s...done" group)
5631 (gnus-group-goto-group group)
5632 (gnus-group-kill-group 1 t)
5633 (gnus-sethash group nil gnus-active-hashtb)
5635 (gnus-group-position-point)))
5637 (defun gnus-group-rename-group (group new-name)
5640 (gnus-group-group-name)
5642 (or (gnus-check-backend-function
5643 'request-rename-group (gnus-group-group-name))
5644 (error "This backend does not support renaming groups"))
5645 (read-string "New group name: "))))
5647 (or (gnus-check-backend-function 'request-rename-group group)
5648 (error "This backend does not support renaming groups"))
5650 (or group (error "No group to rename"))
5651 (and (string-match "^[ \t]*$" new-name)
5652 (error "Not a valid group name"))
5654 ;; We find the proper prefixed name.
5656 (gnus-group-prefixed-name
5657 (gnus-group-real-name new-name)
5658 (gnus-info-method (gnus-get-info group))))
5660 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5662 (if (not (gnus-request-rename-group group new-name))
5663 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5664 ;; We rename the group internally by killing it...
5665 (gnus-group-goto-group group)
5666 (gnus-group-kill-group)
5667 ;; ... changing its name ...
5668 (setcar (cdar gnus-list-of-killed-groups) new-name)
5669 ;; ... and then yanking it. Magic!
5670 (gnus-group-yank-group)
5671 (gnus-set-active new-name (gnus-active group))
5672 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5674 (gnus-group-position-point)))
5676 (defun gnus-group-edit-group (group &optional part)
5677 "Edit the group on the current line."
5678 (interactive (list (gnus-group-group-name)))
5679 (let* ((part (or part 'info))
5680 (done-func `(lambda ()
5681 "Exit editing mode and update the information."
5683 (gnus-group-edit-group-done ',part ,group)))
5684 (winconf (current-window-configuration))
5686 (or group (error "No group on current line"))
5687 (or (setq info (gnus-get-info group))
5688 (error "Killed group; can't be edited"))
5689 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5690 (gnus-configure-windows 'edit-group)
5691 (gnus-add-current-to-buffer-list)
5693 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5694 (use-local-map (copy-keymap emacs-lisp-mode-map))
5695 (local-set-key "\C-c\C-c" done-func)
5696 (make-local-variable 'gnus-prev-winconf)
5697 (setq gnus-prev-winconf winconf)
5702 ";; Type `C-c C-c' after editing the select method.\n\n")
5704 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5706 ";; Type `C-c C-c' after editing the group info.\n\n")))
5709 (cond ((eq part 'method)
5710 (or (gnus-info-method info) "native"))
5712 (gnus-info-params info))
5716 (defun gnus-group-edit-group-method (group)
5717 "Edit the select method of GROUP."
5718 (interactive (list (gnus-group-group-name)))
5719 (gnus-group-edit-group group 'method))
5721 (defun gnus-group-edit-group-parameters (group)
5722 "Edit the group parameters of GROUP."
5723 (interactive (list (gnus-group-group-name)))
5724 (gnus-group-edit-group group 'params))
5726 (defun gnus-group-edit-group-done (part group)
5727 "Get info from buffer, update variables and jump to the group buffer."
5728 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5729 (goto-char (point-min))
5730 (let* ((form (read (current-buffer)))
5731 (winconf gnus-prev-winconf)
5732 (method (cond ((eq part 'info) (nth 4 form))
5733 ((eq part 'method) form)
5735 (info (cond ((eq part 'info) form)
5736 ((eq part 'method) (gnus-get-info group))
5739 (if (or (not method)
5741 gnus-select-method method))
5742 (gnus-group-real-name (car info))
5743 (gnus-group-prefixed-name
5744 (gnus-group-real-name (car info)) method))
5746 (when (and new-group
5747 (not (equal new-group group)))
5748 (when (gnus-group-goto-group group)
5749 (gnus-group-kill-group 1))
5750 (gnus-activate-group new-group))
5752 (if (and info new-group)
5754 (setq info (gnus-copy-sequence info))
5755 (setcar info new-group)
5756 (unless (gnus-server-equal method "native")
5757 (unless (nthcdr 3 info)
5758 (nconc info (list nil nil)))
5759 (unless (nthcdr 4 info)
5760 (nconc info (list nil)))
5761 (gnus-info-set-method info method))
5762 (gnus-group-set-info info))
5763 (gnus-group-set-info form (or new-group group) part))
5764 (kill-buffer (current-buffer))
5765 (and winconf (set-window-configuration winconf))
5766 (set-buffer gnus-group-buffer)
5767 (gnus-group-update-group (or new-group group))
5768 (gnus-group-position-point)))
5770 (defun gnus-group-make-help-group ()
5771 "Create the Gnus documentation group."
5773 (let ((path load-path)
5774 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5776 (and (gnus-gethash name gnus-newsrc-hashtb)
5777 (error "Documentation group already exists"))
5779 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5781 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5783 (setq file (concat (file-name-directory
5784 (directory-file-name dir))
5785 "etc/gnus-tut.txt"))))
5788 (gnus-message 1 "Couldn't find doc group")
5789 (gnus-group-make-group
5790 (gnus-group-real-name name)
5791 (list 'nndoc "gnus-help"
5792 (list 'nndoc-address file)
5793 (list 'nndoc-article-type 'mbox)))))
5794 (gnus-group-position-point))
5796 (defun gnus-group-make-doc-group (file type)
5797 "Create a group that uses a single file as the source."
5799 (list (read-file-name "File name: ")
5800 (and current-prefix-arg 'ask)))
5801 (when (eq type 'ask)
5806 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5808 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5809 ((= char ?b) 'babyl)
5810 ((= char ?d) 'digest)
5811 ((= char ?f) 'forward)
5813 (t (setq err (format "%c unknown. " char))
5816 (let* ((file (expand-file-name file))
5817 (name (gnus-generate-new-group-name
5818 (gnus-group-prefixed-name
5819 (file-name-nondirectory file) '(nndoc "")))))
5820 (gnus-group-make-group
5821 (gnus-group-real-name name)
5822 (list 'nndoc (file-name-nondirectory file)
5823 (list 'nndoc-address file)
5824 (list 'nndoc-article-type (or type 'guess))))))
5826 (defun gnus-group-make-archive-group (&optional all)
5827 "Create the (ding) Gnus archive group of the most recent articles.
5828 Given a prefix, create a full group."
5830 (let ((group (gnus-group-prefixed-name
5831 (if all "ding.archives" "ding.recent") '(nndir ""))))
5832 (and (gnus-gethash group gnus-newsrc-hashtb)
5833 (error "Archive group already exists"))
5834 (gnus-group-make-group
5835 (gnus-group-real-name group)
5836 (list 'nndir (if all "hpc" "edu")
5837 (list 'nndir-directory
5838 (if all gnus-group-archive-directory
5839 gnus-group-recent-archive-directory))))))
5841 (defun gnus-group-make-directory-group (dir)
5842 "Create an nndir group.
5843 The user will be prompted for a directory. The contents of this
5844 directory will be used as a newsgroup. The directory should contain
5845 mail messages or news articles in files that have numeric names."
5847 (list (read-file-name "Create group from directory: ")))
5848 (or (file-exists-p dir) (error "No such directory"))
5849 (or (file-directory-p dir) (error "Not a directory"))
5853 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5855 (gnus-group-prefixed-name
5856 (concat (file-name-as-directory (directory-file-name dir))
5859 (setq ext (format "<%d>" (setq i (1+ i)))))
5860 (gnus-group-make-group
5861 (gnus-group-real-name group)
5862 (list 'nndir group (list 'nndir-directory dir)))))
5864 (defun gnus-group-make-kiboze-group (group address scores)
5865 "Create an nnkiboze group.
5866 The user will be prompted for a name, a regexp to match groups, and
5867 score file entries for articles to include in the group."
5870 (read-string "nnkiboze group name: ")
5871 (read-string "Source groups (regexp): ")
5872 (let ((headers (mapcar (lambda (group) (list group))
5873 '("subject" "from" "number" "date" "message-id"
5874 "references" "chars" "lines" "xref"
5875 "followup" "all" "body" "head")))
5876 scores header regexp regexps)
5877 (while (not (equal "" (setq header (completing-read
5878 "Match on header: " headers nil t))))
5880 (while (not (equal "" (setq regexp (read-string
5881 (format "Match on %s (string): "
5883 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5884 (setq scores (cons (cons header regexps) scores)))
5886 (gnus-group-make-group group "nnkiboze" address)
5887 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5888 (let (emacs-lisp-mode-hook)
5889 (pp scores (current-buffer)))))
5891 (defun gnus-group-add-to-virtual (n vgroup)
5892 "Add the current group to a virtual group."
5894 (list current-prefix-arg
5895 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5897 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5898 (error "%s is not an nnvirtual group" vgroup))
5899 (let* ((groups (gnus-group-process-prefix n))
5900 (method (gnus-info-method (gnus-get-info vgroup))))
5901 (setcar (cdr method)
5903 (nth 1 method) "\\|"
5906 (gnus-group-remove-mark s)
5907 (concat "\\(^" (regexp-quote s) "$\\)"))
5909 (gnus-group-position-point))
5911 (defun gnus-group-make-empty-virtual (group)
5912 "Create a new, fresh, empty virtual group."
5913 (interactive "sCreate new, empty virtual group: ")
5914 (let* ((method (list 'nnvirtual "^$"))
5915 (pgroup (gnus-group-prefixed-name group method)))
5916 ;; Check whether it exists already.
5917 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5918 (error "Group %s already exists." pgroup))
5919 ;; Subscribe the new group after the group on the current line.
5920 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5921 (gnus-group-update-group pgroup)
5923 (gnus-group-position-point)))
5925 (defun gnus-group-enter-directory (dir)
5926 "Enter an ephemeral nneething group."
5927 (interactive "DDirectory to read: ")
5928 (let* ((method (list 'nneething dir))
5929 (leaf (gnus-group-prefixed-name
5930 (file-name-nondirectory (directory-file-name dir))
5932 (name (gnus-generate-new-group-name leaf)))
5933 (let ((nneething-read-only t))
5934 (or (gnus-group-read-ephemeral-group
5936 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5938 (error "Couldn't enter %s" dir)))))
5940 ;; Group sorting commands
5941 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5943 (defun gnus-group-sort-groups (func &optional reverse)
5944 "Sort the group buffer according to FUNC.
5945 If REVERSE, reverse the sorting order."
5946 (interactive (list gnus-group-sort-function
5947 current-prefix-arg))
5949 ((not (listp func)) func)
5951 ((= 1 (length func)) (car func))
5953 ,(gnus-make-sort-function
5954 (reverse func)))))))
5955 ;; We peel off the dummy group from the alist.
5957 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5958 (pop gnus-newsrc-alist))
5960 (setq gnus-newsrc-alist
5961 (sort gnus-newsrc-alist func))
5963 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5964 ;; Regenerate the hash table.
5965 (gnus-make-hashtable-from-newsrc-alist)
5966 (gnus-group-list-groups))))
5968 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5969 "Sort the group buffer alphabetically by group name.
5970 If REVERSE, sort in reverse order."
5972 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5974 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5975 "Sort the group buffer by number of unread articles.
5976 If REVERSE, sort in reverse order."
5978 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5980 (defun gnus-group-sort-groups-by-level (&optional reverse)
5981 "Sort the group buffer by group level.
5982 If REVERSE, sort in reverse order."
5984 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5986 (defun gnus-group-sort-groups-by-score (&optional reverse)
5987 "Sort the group buffer by group score.
5988 If REVERSE, sort in reverse order."
5990 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5992 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5993 "Sort the group buffer by group rank.
5994 If REVERSE, sort in reverse order."
5996 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5998 (defun gnus-group-sort-groups-by-method (&optional reverse)
5999 "Sort the group buffer alphabetically by backend name.
6000 If REVERSE, sort in reverse order."
6002 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6004 (defun gnus-group-sort-by-alphabet (info1 info2)
6005 "Sort alphabetically."
6006 (string< (gnus-info-group info1) (gnus-info-group info2)))
6008 (defun gnus-group-sort-by-unread (info1 info2)
6009 "Sort by number of unread articles."
6010 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6011 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6012 (< (or (and (numberp n1) n1) 0)
6013 (or (and (numberp n2) n2) 0))))
6015 (defun gnus-group-sort-by-level (info1 info2)
6017 (< (gnus-info-level info1) (gnus-info-level info2)))
6019 (defun gnus-group-sort-by-method (info1 info2)
6020 "Sort alphabetically by backend name."
6021 (string< (symbol-name (car (gnus-find-method-for-group
6022 (gnus-info-group info1) info1)))
6023 (symbol-name (car (gnus-find-method-for-group
6024 (gnus-info-group info2) info2)))))
6026 (defun gnus-group-sort-by-score (info1 info2)
6027 "Sort by group score."
6028 (< (gnus-info-score info1) (gnus-info-score info2)))
6030 (defun gnus-group-sort-by-rank (info1 info2)
6031 "Sort by level and score."
6032 (let ((level1 (gnus-info-level info1))
6033 (level2 (gnus-info-level info2)))
6034 (or (< level1 level2)
6035 (and (= level1 level2)
6036 (> (gnus-info-score info1) (gnus-info-score info2))))))
6038 ;; Group catching up.
6040 (defun gnus-group-clear-data (n)
6041 "Clear all marks and read ranges from the current group."
6043 (let ((groups (gnus-group-process-prefix n))
6045 (while (setq group (pop groups))
6046 (setq info (gnus-get-info group))
6047 (gnus-info-set-read info nil)
6048 (when (gnus-info-marks info)
6049 (gnus-info-set-marks info nil))
6050 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6051 (when (gnus-group-goto-group group)
6052 (gnus-group-remove-mark group)
6053 (gnus-group-update-group-line)))))
6055 (defun gnus-group-catchup-current (&optional n all)
6056 "Mark all articles not marked as unread in current newsgroup as read.
6057 If prefix argument N is numeric, the ARG next newsgroups will be
6058 caught up. If ALL is non-nil, marked articles will also be marked as
6059 read. Cross references (Xref: header) of articles are ignored.
6060 The difference between N and actual number of newsgroups that were
6061 caught up is returned."
6063 (unless (gnus-group-group-name)
6064 (error "No group on the current line"))
6065 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6069 "Do you really want to mark all articles as read? "
6070 "Mark all unread articles as read? "))))
6072 (let ((groups (gnus-group-process-prefix n))
6075 ;; Virtual groups have to be given special treatment.
6076 (let ((method (gnus-find-method-for-group (car groups))))
6077 (if (eq 'nnvirtual (car method))
6078 (nnvirtual-catchup-group
6079 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6080 (gnus-group-remove-mark (car groups))
6081 (if (>= (gnus-group-group-level) gnus-level-zombie)
6082 (gnus-message 2 "Dead groups can't be caught up")
6084 (gnus-group-goto-group (car groups))
6085 (gnus-group-catchup (car groups) all))
6086 (gnus-group-update-group-line)
6087 (setq ret (1+ ret))))
6088 (setq groups (cdr groups)))
6089 (gnus-group-next-unread-group 1)
6092 (defun gnus-group-catchup-current-all (&optional n)
6093 "Mark all articles in current newsgroup as read.
6094 Cross references (Xref: header) of articles are ignored."
6096 (gnus-group-catchup-current n 'all))
6098 (defun gnus-group-catchup (group &optional all)
6099 "Mark all articles in GROUP as read.
6100 If ALL is non-nil, all articles are marked as read.
6101 The return value is the number of articles that were marked as read,
6102 or nil if no action could be taken."
6103 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6105 ;; Do the updating only if the newsgroup isn't killed.
6106 (if (not (numberp (car entry)))
6107 (gnus-message 1 "Can't catch up; non-active group")
6108 ;; Do auto-expirable marks if that's required.
6109 (when (gnus-group-auto-expirable-p group)
6110 (gnus-add-marked-articles
6111 group 'expire (gnus-list-of-unread-articles group))
6113 (let ((marks (nth 3 (nth 2 entry))))
6114 (gnus-add-marked-articles
6115 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6116 (gnus-add-marked-articles
6117 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6119 (gnus-update-read-articles group nil)
6120 ;; Also nix out the lists of marks and dormants.
6122 (gnus-add-marked-articles group 'tick nil nil 'force)
6123 (gnus-add-marked-articles group 'dormant nil nil 'force))
6124 (run-hooks 'gnus-group-catchup-group-hook)
6127 (defun gnus-group-expire-articles (&optional n)
6128 "Expire all expirable articles in the current newsgroup."
6130 (let ((groups (gnus-group-process-prefix n))
6133 (error "No groups to expire"))
6134 (while (setq group (pop groups))
6135 (gnus-group-remove-mark group)
6136 (when (gnus-check-backend-function 'request-expire-articles group)
6137 (gnus-message 6 "Expiring articles in %s..." group)
6138 (let* ((info (gnus-get-info group))
6139 (expirable (if (gnus-group-total-expirable-p group)
6140 (cons nil (gnus-list-of-read-articles group))
6141 (assq 'expire (gnus-info-marks info))))
6142 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6146 (gnus-compress-sequence
6148 ;; We set the expiry variables to the groupp
6150 (let ((nnmail-expiry-wait-function nil)
6151 (nnmail-expiry-wait expiry-wait))
6152 (gnus-request-expire-articles
6153 (gnus-uncompress-sequence (cdr expirable)) group))
6154 ;; Just expire using the normal expiry values.
6155 (gnus-request-expire-articles
6156 (gnus-uncompress-sequence (cdr expirable)) group)))))
6157 (gnus-message 6 "Expiring articles in %s...done" group)))
6158 (gnus-group-position-point))))
6160 (defun gnus-group-expire-all-groups ()
6161 "Expire all expirable articles in all newsgroups."
6164 (gnus-message 5 "Expiring...")
6165 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6166 (cdr gnus-newsrc-alist))))
6167 (gnus-group-expire-articles nil)))
6168 (gnus-group-position-point)
6169 (gnus-message 5 "Expiring...done"))
6171 (defun gnus-group-set-current-level (n level)
6172 "Set the level of the next N groups to LEVEL."
6177 (let ((s (read-string
6178 (format "Level (default %s): "
6179 (or (gnus-group-group-level)
6180 gnus-level-default-subscribed)))))
6181 (if (string-match "^\\s-*$" s)
6182 (int-to-string (or (gnus-group-group-level)
6183 gnus-level-default-subscribed))
6185 (or (and (>= level 1) (<= level gnus-level-killed))
6186 (error "Illegal level: %d" level))
6187 (let ((groups (gnus-group-process-prefix n))
6189 (while (setq group (pop groups))
6190 (gnus-group-remove-mark group)
6191 (gnus-message 6 "Changed level of %s from %d to %d"
6192 group (or (gnus-group-group-level) gnus-level-killed)
6194 (gnus-group-change-level
6195 group level (or (gnus-group-group-level) gnus-level-killed))
6196 (gnus-group-update-group-line)))
6197 (gnus-group-position-point))
6199 (defun gnus-group-unsubscribe-current-group (&optional n)
6200 "Toggle subscription of the current group.
6201 If given numerical prefix, toggle the N next groups."
6203 (let ((groups (gnus-group-process-prefix n))
6206 (setq group (car groups)
6207 groups (cdr groups))
6208 (gnus-group-remove-mark group)
6209 (gnus-group-unsubscribe-group
6210 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6211 gnus-level-default-unsubscribed
6212 gnus-level-default-subscribed) t)
6213 (gnus-group-update-group-line))
6214 (gnus-group-next-group 1)))
6216 (defun gnus-group-unsubscribe-group (group &optional level silent)
6217 "Toggle subscription to GROUP.
6218 Killed newsgroups are subscribed. If SILENT, don't try to update the
6221 (list (completing-read
6222 "Group: " gnus-active-hashtb nil
6223 (gnus-read-active-file-p)
6225 'gnus-group-history)))
6226 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6228 ((string-match "^[ \t]$" group)
6229 (error "Empty group name"))
6231 ;; Toggle subscription flag.
6232 (gnus-group-change-level
6233 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6234 gnus-level-subscribed)
6235 (1+ gnus-level-subscribed)
6236 gnus-level-default-subscribed)))
6238 (gnus-group-update-group group)))
6239 ((and (stringp group)
6240 (or (not (gnus-read-active-file-p))
6241 (gnus-active group)))
6242 ;; Add new newsgroup.
6243 (gnus-group-change-level
6245 (if level level gnus-level-default-subscribed)
6246 (or (and (member group gnus-zombie-list)
6249 (and (gnus-group-group-name)
6250 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6252 (gnus-group-update-group group)))
6253 (t (error "No such newsgroup: %s" group)))
6254 (gnus-group-position-point)))
6256 (defun gnus-group-transpose-groups (n)
6257 "Move the current newsgroup up N places.
6258 If given a negative prefix, move down instead. The difference between
6259 N and the number of steps taken is returned."
6261 (or (gnus-group-group-name)
6262 (error "No group on current line"))
6263 (gnus-group-kill-group 1)
6265 (forward-line (- n))
6266 (gnus-group-yank-group)
6267 (gnus-group-position-point)))
6269 (defun gnus-group-kill-all-zombies ()
6270 "Kill all zombie newsgroups."
6272 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6273 (setq gnus-zombie-list nil)
6274 (gnus-group-list-groups))
6276 (defun gnus-group-kill-region (begin end)
6277 "Kill newsgroups in current region (excluding current point).
6278 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6293 (beginning-of-line) ;Important when LINES < 1
6294 (gnus-group-kill-group lines)))
6296 (defun gnus-group-kill-group (&optional n discard)
6297 "Kill the next N groups.
6298 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6299 However, only groups that were alive can be yanked; already killed
6300 groups or zombie groups can't be yanked.
6301 The return value is the name of the group that was killed, or a list
6304 (let ((buffer-read-only nil)
6305 (groups (gnus-group-process-prefix n))
6306 group entry level out)
6307 (if (< (length groups) 10)
6308 ;; This is faster when there are few groups.
6310 (push (setq group (pop groups)) out)
6311 (gnus-group-remove-mark group)
6312 (setq level (gnus-group-group-level))
6314 (when (and (not discard)
6315 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6316 (push (cons (car entry) (nth 2 entry))
6317 gnus-list-of-killed-groups))
6318 (gnus-group-change-level
6319 (if entry entry group) gnus-level-killed (if entry nil level)))
6320 ;; If there are lots and lots of groups to be killed, we use
6321 ;; this thing instead.
6323 (setq groups (nreverse groups))
6325 (gnus-group-remove-mark (setq group (pop groups)))
6328 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6329 (push (cons (car entry) (nth 2 entry))
6330 gnus-list-of-killed-groups)
6331 (setcdr (cdr entry) (cdddr entry)))
6332 ((member group gnus-zombie-list)
6333 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6334 (gnus-make-hashtable-from-newsrc-alist)))
6336 (gnus-group-position-point)
6337 (if (< (length out) 2) (car out) (nreverse out))))
6339 (defun gnus-group-yank-group (&optional arg)
6340 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6341 inserting it before the current newsgroup. The numeric ARG specifies
6342 how many newsgroups are to be yanked. The name of the newsgroup yanked
6343 is returned, or (if several groups are yanked) a list of yanked groups
6346 (setq arg (or arg 1))
6347 (let (info group prev out)
6348 (while (>= (decf arg) 0)
6349 (if (not (setq info (pop gnus-list-of-killed-groups)))
6350 (error "No more newsgroups to yank"))
6351 (push (setq group (nth 1 info)) out)
6352 ;; Find which newsgroup to insert this one before - search
6353 ;; backward until something suitable is found. If there are no
6354 ;; other newsgroups in this buffer, just make this newsgroup the
6356 (setq prev (gnus-group-group-name))
6357 (gnus-group-change-level
6358 info (gnus-info-level (cdr info)) gnus-level-killed
6359 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6361 (gnus-group-insert-group-line-info group))
6363 (gnus-group-position-point)
6364 (if (< (length out) 2) (car out) (nreverse out))))
6366 (defun gnus-group-kill-level (level)
6367 "Kill all groups that is on a certain LEVEL."
6368 (interactive "nKill all groups on level: ")
6370 ((= level gnus-level-zombie)
6371 (setq gnus-killed-list
6372 (nconc gnus-zombie-list gnus-killed-list))
6373 (setq gnus-zombie-list nil))
6374 ((and (< level gnus-level-zombie)
6376 (or gnus-expert-user
6379 "Do you really want to kill all groups on level %d? "
6381 (let* ((prev gnus-newsrc-alist)
6384 (if (= (gnus-info-level level) level)
6385 (setcdr prev (cdr alist))
6387 (setq alist (cdr alist)))
6388 (gnus-make-hashtable-from-newsrc-alist)
6389 (gnus-group-list-groups)))
6391 (error "Can't kill; illegal level: %d" level))))
6393 (defun gnus-group-list-all-groups (&optional arg)
6394 "List all newsgroups with level ARG or lower.
6395 Default is gnus-level-unsubscribed, which lists all subscribed and most
6396 unsubscribed groups."
6398 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6400 ;; Redefine this to list ALL killed groups if prefix arg used.
6401 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6402 (defun gnus-group-list-killed (&optional arg)
6403 "List all killed newsgroups in the group buffer.
6404 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6405 entail asking the server for the groups."
6407 ;; Find all possible killed newsgroups if arg.
6409 (gnus-get-killed-groups))
6410 (if (not gnus-killed-list)
6411 (gnus-message 6 "No killed groups")
6412 (let (gnus-group-list-mode)
6413 (funcall gnus-group-prepare-function
6414 gnus-level-killed t gnus-level-killed))
6415 (goto-char (point-min)))
6416 (gnus-group-position-point))
6418 (defun gnus-group-list-zombies ()
6419 "List all zombie newsgroups in the group buffer."
6421 (if (not gnus-zombie-list)
6422 (gnus-message 6 "No zombie groups")
6423 (let (gnus-group-list-mode)
6424 (funcall gnus-group-prepare-function
6425 gnus-level-zombie t gnus-level-zombie))
6426 (goto-char (point-min)))
6427 (gnus-group-position-point))
6429 (defun gnus-group-list-active ()
6430 "List all groups that are available from the server(s)."
6432 ;; First we make sure that we have really read the active file.
6433 (unless (gnus-read-active-file-p)
6434 (let ((gnus-read-active-file t))
6435 (gnus-read-active-file)))
6436 ;; Find all groups and sort them.
6444 (setq list (cons (symbol-name sym) list))))
6448 (buffer-read-only nil))
6451 (gnus-group-insert-group-line-info (pop groups)))
6452 (goto-char (point-min))))
6454 (defun gnus-activate-all-groups (level)
6455 "Activate absolutely all groups."
6456 (interactive (list 7))
6457 (let ((gnus-activate-level level)
6458 (gnus-activate-foreign-newsgroups level))
6459 (gnus-group-get-new-news)))
6461 (defun gnus-group-get-new-news (&optional arg)
6462 "Get newly arrived articles.
6463 If ARG is a number, it specifies which levels you are interested in
6464 re-scanning. If ARG is non-nil and not a number, this will force
6465 \"hard\" re-reading of the active files from all servers."
6467 (run-hooks 'gnus-get-new-news-hook)
6468 ;; We might read in new NoCeM messages here.
6469 (when (and gnus-use-nocem
6471 (gnus-nocem-scan-groups))
6472 ;; If ARG is not a number, then we read the active file.
6473 (when (and arg (not (numberp arg)))
6474 (let ((gnus-read-active-file t))
6475 (gnus-read-active-file))
6478 (setq arg (gnus-group-default-level arg t))
6479 (if (and gnus-read-active-file (not arg))
6481 (gnus-read-active-file)
6482 (gnus-get-unread-articles arg))
6483 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6484 (gnus-get-unread-articles arg)))
6485 (run-hooks 'gnus-after-getting-new-news-hook)
6486 (gnus-group-list-groups))
6488 (defun gnus-group-get-new-news-this-group (&optional n)
6489 "Check for newly arrived news in the current group (and the N-1 next groups).
6490 The difference between N and the number of newsgroup checked is returned.
6491 If N is negative, this group and the N-1 previous groups will be checked."
6493 (let* ((groups (gnus-group-process-prefix n))
6494 (ret (if (numberp n) (- n (length groups)) 0))
6495 (beg (unless n (point)))
6497 (while (setq group (pop groups))
6498 (gnus-group-remove-mark group)
6499 (if (gnus-activate-group group 'scan)
6501 (gnus-get-unread-articles-in-group
6502 (gnus-get-info group) (gnus-active group) t)
6503 (unless (gnus-virtual-group-p group)
6504 (gnus-close-group group))
6505 (gnus-group-update-group group))
6506 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6507 (when beg (goto-char beg))
6508 (when gnus-goto-next-group-when-activating
6509 (gnus-group-next-unread-group 1 t))
6510 (gnus-summary-position-point)
6513 (defun gnus-group-fetch-faq (group &optional faq-dir)
6514 "Fetch the FAQ for the current group."
6517 (and (gnus-group-group-name)
6518 (gnus-group-real-name (gnus-group-group-name)))
6519 (cond (current-prefix-arg
6521 "Faq dir: " (and (listp gnus-group-faq-directory)
6522 (mapcar (lambda (file) (list file))
6523 gnus-group-faq-directory)))))))
6525 (setq faq-dir (if (listp gnus-group-faq-directory)
6526 (car gnus-group-faq-directory)
6527 gnus-group-faq-directory)))
6528 (or group (error "No group name given"))
6529 (let ((file (concat (file-name-as-directory faq-dir)
6530 (gnus-group-real-name group))))
6531 (if (not (file-exists-p file))
6532 (error "No such file: %s" file)
6535 (defun gnus-group-describe-group (force &optional group)
6536 "Display a description of the current newsgroup."
6537 (interactive (list current-prefix-arg (gnus-group-group-name)))
6538 (and force (setq gnus-description-hashtb nil))
6539 (let ((method (gnus-find-method-for-group group))
6541 (or group (error "No group name given"))
6542 (and (or (and gnus-description-hashtb
6543 ;; We check whether this group's method has been
6544 ;; queried for a description file.
6546 (gnus-group-prefixed-name "" method)
6547 gnus-description-hashtb))
6548 (setq desc (gnus-group-get-description group))
6549 (gnus-read-descriptions-file method))
6551 (or desc (gnus-gethash group gnus-description-hashtb)
6552 "No description available")))))
6554 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6555 (defun gnus-group-describe-all-groups (&optional force)
6556 "Pop up a buffer with descriptions of all newsgroups."
6558 (and force (setq gnus-description-hashtb nil))
6559 (if (not (or gnus-description-hashtb
6560 (gnus-read-all-descriptions-files)))
6561 (error "Couldn't request descriptions file"))
6562 (let ((buffer-read-only nil)
6568 (insert (format " *: %-20s %s\n" (symbol-name group)
6569 (symbol-value group)))
6570 (gnus-add-text-properties
6571 b (1+ b) (list 'gnus-group group
6572 'gnus-unread t 'gnus-marked nil
6573 'gnus-level (1+ gnus-level-subscribed))))
6574 gnus-description-hashtb)
6575 (goto-char (point-min))
6576 (gnus-group-position-point)))
6578 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6579 (defun gnus-group-apropos (regexp &optional search-description)
6580 "List all newsgroups that have names that match a regexp."
6581 (interactive "sGnus apropos (regexp): ")
6583 (obuf (current-buffer))
6585 ;; Go through all newsgroups that are known to Gnus.
6588 (and (symbol-name group)
6589 (string-match regexp (symbol-name group))
6590 (setq groups (cons (symbol-name group) groups))))
6592 ;; Also go through all descriptions that are known to Gnus.
6593 (when search-description
6596 (and (string-match regexp (symbol-value group))
6597 (gnus-active (symbol-name group))
6598 (setq groups (cons (symbol-name group) groups))))
6599 gnus-description-hashtb))
6601 (gnus-message 3 "No groups matched \"%s\"." regexp)
6602 ;; Print out all the groups.
6604 (pop-to-buffer "*Gnus Help*")
6605 (buffer-disable-undo (current-buffer))
6607 (setq groups (sort groups 'string<))
6609 ;; Groups may be entered twice into the list of groups.
6610 (if (not (string= (car groups) prev))
6612 (insert (setq prev (car groups)) "\n")
6613 (if (and gnus-description-hashtb
6614 (setq des (gnus-gethash (car groups)
6615 gnus-description-hashtb)))
6616 (insert " " des "\n"))))
6617 (setq groups (cdr groups)))
6618 (goto-char (point-min))))
6619 (pop-to-buffer obuf)))
6621 (defun gnus-group-description-apropos (regexp)
6622 "List all newsgroups that have names or descriptions that match a regexp."
6623 (interactive "sGnus description apropos (regexp): ")
6624 (if (not (or gnus-description-hashtb
6625 (gnus-read-all-descriptions-files)))
6626 (error "Couldn't request descriptions file"))
6627 (gnus-group-apropos regexp t))
6629 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6630 (defun gnus-group-list-matching (level regexp &optional all lowest)
6631 "List all groups with unread articles that match REGEXP.
6632 If the prefix LEVEL is non-nil, it should be a number that says which
6633 level to cut off listing groups.
6634 If ALL, also list groups with no unread articles.
6635 If LOWEST, don't list groups with level lower than LOWEST.
6637 This command may read the active file."
6638 (interactive "P\nsList newsgroups matching: ")
6639 ;; First make sure active file has been read.
6641 (> (prefix-numeric-value level) gnus-level-killed))
6642 (gnus-get-killed-groups))
6643 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6644 all (or lowest 1) regexp)
6645 (goto-char (point-min))
6646 (gnus-group-position-point))
6648 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6649 "List all groups that match REGEXP.
6650 If the prefix LEVEL is non-nil, it should be a number that says which
6651 level to cut off listing groups.
6652 If LOWEST, don't list groups with level lower than LOWEST."
6653 (interactive "P\nsList newsgroups matching: ")
6654 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6656 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6657 (defun gnus-group-save-newsrc (&optional force)
6658 "Save the Gnus startup files.
6659 If FORCE, force saving whether it is necessary or not."
6661 (gnus-save-newsrc-file force))
6663 (defun gnus-group-restart (&optional arg)
6664 "Force Gnus to read the .newsrc file."
6666 (when (gnus-yes-or-no-p
6667 (format "Are you sure you want to read %s? "
6668 gnus-current-startup-file))
6669 (gnus-save-newsrc-file)
6670 (gnus-setup-news 'force)
6671 (gnus-group-list-groups arg)))
6673 (defun gnus-group-read-init-file ()
6674 "Read the Gnus elisp init file."
6676 (gnus-read-init-file))
6678 (defun gnus-group-check-bogus-groups (&optional silent)
6679 "Check bogus newsgroups.
6680 If given a prefix, don't ask for confirmation before removing a bogus
6683 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6684 (gnus-group-list-groups))
6686 (defun gnus-group-edit-global-kill (&optional article group)
6687 "Edit the global kill file.
6688 If GROUP, edit that local kill file instead."
6690 (setq gnus-current-kill-article article)
6691 (gnus-kill-file-edit-file group)
6694 (substitute-command-keys
6695 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6696 (if group "local" "global")))))
6698 (defun gnus-group-edit-local-kill (article group)
6699 "Edit a local kill file."
6700 (interactive (list nil (gnus-group-group-name)))
6701 (gnus-group-edit-global-kill article group))
6703 (defun gnus-group-force-update ()
6704 "Update `.newsrc' file."
6706 (gnus-save-newsrc-file))
6708 (defun gnus-group-suspend ()
6709 "Suspend the current Gnus session.
6710 In fact, cleanup buffers except for group mode buffer.
6711 The hook gnus-suspend-gnus-hook is called before actually suspending."
6713 (run-hooks 'gnus-suspend-gnus-hook)
6714 ;; Kill Gnus buffers except for group mode buffer.
6715 (let ((group-buf (get-buffer gnus-group-buffer)))
6716 ;; Do this on a separate list in case the user does a ^G before we finish
6717 (let ((gnus-buffer-list
6718 (delq group-buf (delq gnus-dribble-buffer
6719 (append gnus-buffer-list nil)))))
6720 (while gnus-buffer-list
6721 (gnus-kill-buffer (car gnus-buffer-list))
6722 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6725 (setq gnus-buffer-list (list group-buf))
6726 (bury-buffer group-buf)
6727 (delete-windows-on group-buf t)))))
6729 (defun gnus-group-clear-dribble ()
6730 "Clear all information from the dribble buffer."
6732 (gnus-dribble-clear)
6733 (gnus-message 7 "Cleared dribble buffer"))
6735 (defun gnus-group-exit ()
6736 "Quit reading news after updating .newsrc.eld and .newsrc.
6737 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6740 (or noninteractive ;For gnus-batch-kill
6741 (not gnus-interactive-exit) ;Without confirmation
6743 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6744 (run-hooks 'gnus-exit-gnus-hook)
6745 ;; Offer to save data from non-quitted summary buffers.
6746 (gnus-offer-save-summaries)
6747 ;; Save the newsrc file(s).
6748 (gnus-save-newsrc-file)
6750 (gnus-close-backends)
6751 ;; Reset everything.
6753 ;; Allow the user to do things after cleaning up.
6754 (run-hooks 'gnus-after-exiting-gnus-hook)))
6756 (defun gnus-close-backends ()
6757 ;; Send a close request to all backends that support such a request.
6758 (let ((methods gnus-valid-select-methods)
6761 (if (fboundp (setq func (intern (concat (caar methods)
6762 "-request-close"))))
6764 (setq methods (cdr methods)))))
6766 (defun gnus-group-quit ()
6767 "Quit reading news without updating .newsrc.eld or .newsrc.
6768 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6770 (when (or noninteractive ;For gnus-batch-kill
6771 (zerop (buffer-size))
6772 (not (gnus-server-opened gnus-select-method))
6774 (not gnus-current-startup-file)
6776 (format "Quit reading news without saving %s? "
6777 (file-name-nondirectory gnus-current-startup-file))))
6778 (run-hooks 'gnus-exit-gnus-hook)
6779 (if gnus-use-full-window
6780 (delete-other-windows)
6781 (gnus-remove-some-windows))
6783 (gnus-close-backends)
6785 ;; Allow the user to do things after cleaning up.
6786 (run-hooks 'gnus-after-exiting-gnus-hook)))
6788 (defun gnus-offer-save-summaries ()
6789 "Offer to save all active summary buffers."
6791 (let ((buflist (buffer-list))
6793 ;; Go through all buffers and find all summaries.
6795 (and (setq bufname (buffer-name (car buflist)))
6796 (string-match "Summary" bufname)
6798 (set-buffer bufname)
6799 ;; We check that this is, indeed, a summary buffer.
6800 (and (eq major-mode 'gnus-summary-mode)
6801 ;; Also make sure this isn't bogus.
6802 gnus-newsgroup-prepared))
6803 (push bufname buffers))
6804 (setq buflist (cdr buflist)))
6805 ;; Go through all these summary buffers and offer to save them.
6808 "Update summary buffer %s? "
6809 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6812 (defun gnus-group-describe-briefly ()
6813 "Give a one line description of the group mode commands."
6815 (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")))
6817 (defun gnus-group-browse-foreign-server (method)
6818 "Browse a foreign news server.
6819 If called interactively, this function will ask for a select method
6820 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6821 If not, METHOD should be a list where the first element is the method
6822 and the second element is the address."
6824 (list (let ((how (completing-read
6826 (append gnus-valid-select-methods gnus-server-alist)
6827 nil t (cons "nntp" 0) 'gnus-method-history)))
6828 ;; We either got a backend name or a virtual server name.
6829 ;; If the first, we also need an address.
6830 (if (assoc how gnus-valid-select-methods)
6832 ;; Suggested by mapjph@bath.ac.uk.
6835 (mapcar (lambda (server) (list server))
6836 gnus-secondary-servers)))
6837 ;; We got a server name, so we find the method.
6838 (gnus-server-to-method how)))))
6839 (gnus-browse-foreign-server method))
6843 ;;; Gnus summary mode
6846 (defvar gnus-summary-mode-map nil)
6848 (put 'gnus-summary-mode 'mode-class 'special)
6850 (unless gnus-summary-mode-map
6851 (setq gnus-summary-mode-map (make-keymap))
6852 (suppress-keymap gnus-summary-mode-map)
6854 ;; Non-orthogonal keys
6856 (gnus-define-keys gnus-summary-mode-map
6857 " " gnus-summary-next-page
6858 "\177" gnus-summary-prev-page
6859 [delete] gnus-summary-prev-page
6860 "\r" gnus-summary-scroll-up
6861 "n" gnus-summary-next-unread-article
6862 "p" gnus-summary-prev-unread-article
6863 "N" gnus-summary-next-article
6864 "P" gnus-summary-prev-article
6865 "\M-\C-n" gnus-summary-next-same-subject
6866 "\M-\C-p" gnus-summary-prev-same-subject
6867 "\M-n" gnus-summary-next-unread-subject
6868 "\M-p" gnus-summary-prev-unread-subject
6869 "." gnus-summary-first-unread-article
6870 "," gnus-summary-best-unread-article
6871 "\M-s" gnus-summary-search-article-forward
6872 "\M-r" gnus-summary-search-article-backward
6873 "<" gnus-summary-beginning-of-article
6874 ">" gnus-summary-end-of-article
6875 "j" gnus-summary-goto-article
6876 "^" gnus-summary-refer-parent-article
6877 "\M-^" gnus-summary-refer-article
6878 "u" gnus-summary-tick-article-forward
6879 "!" gnus-summary-tick-article-forward
6880 "U" gnus-summary-tick-article-backward
6881 "d" gnus-summary-mark-as-read-forward
6882 "D" gnus-summary-mark-as-read-backward
6883 "E" gnus-summary-mark-as-expirable
6884 "\M-u" gnus-summary-clear-mark-forward
6885 "\M-U" gnus-summary-clear-mark-backward
6886 "k" gnus-summary-kill-same-subject-and-select
6887 "\C-k" gnus-summary-kill-same-subject
6888 "\M-\C-k" gnus-summary-kill-thread
6889 "\M-\C-l" gnus-summary-lower-thread
6890 "e" gnus-summary-edit-article
6891 "#" gnus-summary-mark-as-processable
6892 "\M-#" gnus-summary-unmark-as-processable
6893 "\M-\C-t" gnus-summary-toggle-threads
6894 "\M-\C-s" gnus-summary-show-thread
6895 "\M-\C-h" gnus-summary-hide-thread
6896 "\M-\C-f" gnus-summary-next-thread
6897 "\M-\C-b" gnus-summary-prev-thread
6898 "\M-\C-u" gnus-summary-up-thread
6899 "\M-\C-d" gnus-summary-down-thread
6900 "&" gnus-summary-execute-command
6901 "c" gnus-summary-catchup-and-exit
6902 "\C-w" gnus-summary-mark-region-as-read
6903 "\C-t" gnus-summary-toggle-truncation
6904 "?" gnus-summary-mark-as-dormant
6905 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6906 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6907 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6908 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6909 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6910 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6911 "=" gnus-summary-expand-window
6912 "\C-x\C-s" gnus-summary-reselect-current-group
6913 "\M-g" gnus-summary-rescan-group
6914 "w" gnus-summary-stop-page-breaking
6915 "\C-c\C-r" gnus-summary-caesar-message
6916 "\M-t" gnus-summary-toggle-mime
6917 "f" gnus-summary-followup
6918 "F" gnus-summary-followup-with-original
6919 "C" gnus-summary-cancel-article
6920 "r" gnus-summary-reply
6921 "R" gnus-summary-reply-with-original
6922 "\C-c\C-f" gnus-summary-mail-forward
6923 "o" gnus-summary-save-article
6924 "\C-o" gnus-summary-save-article-mail
6925 "|" gnus-summary-pipe-output
6926 "\M-k" gnus-summary-edit-local-kill
6927 "\M-K" gnus-summary-edit-global-kill
6929 "\C-c\C-d" gnus-summary-describe-group
6930 "q" gnus-summary-exit
6931 "Q" gnus-summary-exit-no-update
6932 "\C-c\C-i" gnus-info-find-node
6933 gnus-mouse-2 gnus-mouse-pick-article
6934 "m" gnus-summary-mail-other-window
6935 "a" gnus-summary-post-news
6936 "x" gnus-summary-limit-to-unread
6937 "s" gnus-summary-isearch-article
6938 "t" gnus-article-hide-headers
6939 "g" gnus-summary-show-article
6940 "l" gnus-summary-goto-last-article
6941 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6942 "\C-d" gnus-summary-enter-digest-group
6944 "*" gnus-cache-enter-article
6945 "\M-*" gnus-cache-remove-article
6946 "\M-&" gnus-summary-universal-argument
6947 "\C-l" gnus-recenter
6948 "I" gnus-summary-increase-score
6949 "L" gnus-summary-lower-score
6951 "V" gnus-summary-score-map
6952 "X" gnus-uu-extract-map
6953 "S" gnus-summary-send-map)
6955 ;; Sort of orthogonal keymap
6956 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6957 "t" gnus-summary-tick-article-forward
6958 "!" gnus-summary-tick-article-forward
6959 "d" gnus-summary-mark-as-read-forward
6960 "r" gnus-summary-mark-as-read-forward
6961 "c" gnus-summary-clear-mark-forward
6962 " " gnus-summary-clear-mark-forward
6963 "e" gnus-summary-mark-as-expirable
6964 "x" gnus-summary-mark-as-expirable
6965 "?" gnus-summary-mark-as-dormant
6966 "b" gnus-summary-set-bookmark
6967 "B" gnus-summary-remove-bookmark
6968 "#" gnus-summary-mark-as-processable
6969 "\M-#" gnus-summary-unmark-as-processable
6970 "S" gnus-summary-limit-include-expunged
6971 "C" gnus-summary-catchup
6972 "H" gnus-summary-catchup-to-here
6973 "\C-c" gnus-summary-catchup-all
6974 "k" gnus-summary-kill-same-subject-and-select
6975 "K" gnus-summary-kill-same-subject
6976 "P" gnus-uu-mark-map)
6978 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6979 "c" gnus-summary-clear-above
6980 "u" gnus-summary-tick-above
6981 "m" gnus-summary-mark-above
6982 "k" gnus-summary-kill-below)
6984 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6985 "/" gnus-summary-limit-to-subject
6986 "n" gnus-summary-limit-to-articles
6987 "w" gnus-summary-pop-limit
6988 "s" gnus-summary-limit-to-subject
6989 "a" gnus-summary-limit-to-author
6990 "u" gnus-summary-limit-to-unread
6991 "m" gnus-summary-limit-to-marks
6992 "v" gnus-summary-limit-to-score
6993 "D" gnus-summary-limit-include-dormant
6994 "d" gnus-summary-limit-exclude-dormant
6995 ;; "t" gnus-summary-limit-exclude-thread
6996 "E" gnus-summary-limit-include-expunged
6997 "c" gnus-summary-limit-exclude-childless-dormant
6998 "C" gnus-summary-limit-mark-excluded-as-read)
7000 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7001 "n" gnus-summary-next-unread-article
7002 "p" gnus-summary-prev-unread-article
7003 "N" gnus-summary-next-article
7004 "P" gnus-summary-prev-article
7005 "\C-n" gnus-summary-next-same-subject
7006 "\C-p" gnus-summary-prev-same-subject
7007 "\M-n" gnus-summary-next-unread-subject
7008 "\M-p" gnus-summary-prev-unread-subject
7009 "f" gnus-summary-first-unread-article
7010 "b" gnus-summary-best-unread-article
7011 "j" gnus-summary-goto-article
7012 "g" gnus-summary-goto-subject
7013 "l" gnus-summary-goto-last-article
7014 "p" gnus-summary-pop-article)
7016 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7017 "k" gnus-summary-kill-thread
7018 "l" gnus-summary-lower-thread
7019 "i" gnus-summary-raise-thread
7020 "T" gnus-summary-toggle-threads
7021 "t" gnus-summary-rethread-current
7022 "^" gnus-summary-reparent-thread
7023 "s" gnus-summary-show-thread
7024 "S" gnus-summary-show-all-threads
7025 "h" gnus-summary-hide-thread
7026 "H" gnus-summary-hide-all-threads
7027 "n" gnus-summary-next-thread
7028 "p" gnus-summary-prev-thread
7029 "u" gnus-summary-up-thread
7030 "o" gnus-summary-top-thread
7031 "d" gnus-summary-down-thread
7032 "#" gnus-uu-mark-thread
7033 "\M-#" gnus-uu-unmark-thread)
7035 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7036 "c" gnus-summary-catchup-and-exit
7037 "C" gnus-summary-catchup-all-and-exit
7038 "E" gnus-summary-exit-no-update
7039 "Q" gnus-summary-exit
7040 "Z" gnus-summary-exit
7041 "n" gnus-summary-catchup-and-goto-next-group
7042 "R" gnus-summary-reselect-current-group
7043 "G" gnus-summary-rescan-group
7044 "N" gnus-summary-next-group
7045 "P" gnus-summary-prev-group)
7047 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7048 " " gnus-summary-next-page
7049 "n" gnus-summary-next-page
7050 "\177" gnus-summary-prev-page
7051 [delete] gnus-summary-prev-page
7052 "p" gnus-summary-prev-page
7053 "\r" gnus-summary-scroll-up
7054 "<" gnus-summary-beginning-of-article
7055 ">" gnus-summary-end-of-article
7056 "b" gnus-summary-beginning-of-article
7057 "e" gnus-summary-end-of-article
7058 "^" gnus-summary-refer-parent-article
7059 "r" gnus-summary-refer-parent-article
7060 "R" gnus-summary-refer-references
7061 "g" gnus-summary-show-article
7062 "s" gnus-summary-isearch-article)
7064 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7065 "b" gnus-article-add-buttons
7066 "B" gnus-article-add-buttons-to-head
7067 "o" gnus-article-treat-overstrike
7068 ;; "w" gnus-article-word-wrap
7069 "w" gnus-article-fill-cited-article
7070 "c" gnus-article-remove-cr
7071 "L" gnus-article-remove-trailing-blank-lines
7072 "q" gnus-article-de-quoted-unreadable
7073 "f" gnus-article-display-x-face
7074 "l" gnus-summary-stop-page-breaking
7075 "r" gnus-summary-caesar-message
7076 "t" gnus-article-hide-headers
7077 "v" gnus-summary-verbose-headers
7078 "m" gnus-summary-toggle-mime)
7080 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7081 "a" gnus-article-hide
7082 "h" gnus-article-hide-headers
7083 "b" gnus-article-hide-boring-headers
7084 "s" gnus-article-hide-signature
7085 "c" gnus-article-hide-citation
7086 "p" gnus-article-hide-pgp
7087 "\C-c" gnus-article-hide-citation-maybe)
7089 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7090 "a" gnus-article-highlight
7091 "h" gnus-article-highlight-headers
7092 "c" gnus-article-highlight-citation
7093 "s" gnus-article-highlight-signature)
7095 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7096 "z" gnus-article-date-ut
7097 "u" gnus-article-date-ut
7098 "l" gnus-article-date-local
7099 "e" gnus-article-date-lapsed
7100 "o" gnus-article-date-original)
7102 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7104 "f" gnus-summary-fetch-faq
7105 "d" gnus-summary-describe-group
7106 "h" gnus-summary-describe-briefly
7107 "i" gnus-info-find-node)
7109 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7110 "e" gnus-summary-expire-articles
7111 "\M-\C-e" gnus-summary-expire-articles-now
7112 "\177" gnus-summary-delete-article
7113 [delete] gnus-summary-delete-article
7114 "m" gnus-summary-move-article
7115 "r" gnus-summary-respool-article
7116 "w" gnus-summary-edit-article
7117 "c" gnus-summary-copy-article
7118 "B" gnus-summary-crosspost-article
7119 "q" gnus-summary-respool-query
7120 "i" gnus-summary-import-article)
7122 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7123 "o" gnus-summary-save-article
7124 "m" gnus-summary-save-article-mail
7125 "r" gnus-summary-save-article-rmail
7126 "f" gnus-summary-save-article-file
7127 "b" gnus-summary-save-article-body-file
7128 "h" gnus-summary-save-article-folder
7129 "v" gnus-summary-save-article-vm
7130 "p" gnus-summary-pipe-output
7131 "s" gnus-soup-add-article)
7136 (defun gnus-summary-mode (&optional group)
7137 "Major mode for reading articles.
7139 All normal editing commands are switched off.
7140 \\<gnus-summary-mode-map>
7141 Each line in this buffer represents one article. To read an
7142 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7143 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7146 You can also post articles and send mail from this buffer. To
7147 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7148 of an article, type `\\[gnus-summary-reply]'.
7150 There are approx. one gazillion commands you can execute in this
7151 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7153 The following commands are available:
7155 \\{gnus-summary-mode-map}"
7157 (when (and menu-bar-mode
7158 (gnus-visual-p 'summary-menu 'menu))
7159 (gnus-summary-make-menu-bar))
7160 (kill-all-local-variables)
7161 (gnus-summary-make-local-variables)
7162 (gnus-make-thread-indent-array)
7163 (gnus-simplify-mode-line)
7164 (setq major-mode 'gnus-summary-mode)
7165 (setq mode-name "Summary")
7166 (make-local-variable 'minor-mode-alist)
7167 (use-local-map gnus-summary-mode-map)
7168 (buffer-disable-undo (current-buffer))
7169 (setq buffer-read-only t) ;Disable modification
7170 (setq truncate-lines t)
7171 (setq selective-display t)
7172 (setq selective-display-ellipses t) ;Display `...'
7173 (setq buffer-display-table gnus-summary-display-table)
7174 (setq gnus-newsgroup-name group)
7175 (make-local-variable 'gnus-summary-line-format)
7176 (make-local-variable 'gnus-summary-line-format-spec)
7177 (make-local-variable 'gnus-summary-mark-positions)
7178 (run-hooks 'gnus-summary-mode-hook))
7180 (defun gnus-summary-make-local-variables ()
7181 "Make all the local summary buffer variables."
7182 (let ((locals gnus-summary-local-variables)
7184 (while (setq local (pop locals))
7187 (if (eq (cdr local) 'global)
7188 ;; Copy the global value of the variable.
7189 (setq global (symbol-value (car local)))
7190 ;; Use the value from the list.
7191 (setq global (eval (cdr local))))
7192 (make-local-variable (car local))
7193 (set (car local) global))
7194 ;; Simple nil-valued local variable.
7195 (make-local-variable local)
7198 (defun gnus-summary-make-display-table ()
7199 ;; Change the display table. Odd characters have a tendency to mess
7200 ;; up nicely formatted displays - we make all possible glyphs
7201 ;; display only a single character.
7203 ;; We start from the standard display table, if any.
7204 (setq gnus-summary-display-table
7205 (or (copy-sequence standard-display-table)
7206 (make-display-table)))
7207 ;; Nix out all the control chars...
7209 (while (>= (setq i (1- i)) 0)
7210 (aset gnus-summary-display-table i [??])))
7211 ;; ... but not newline and cr, of course. (cr is necessary for the
7212 ;; selective display).
7213 (aset gnus-summary-display-table ?\n nil)
7214 (aset gnus-summary-display-table ?\r nil)
7215 ;; We nix out any glyphs over 126 that are not set already.
7217 (while (>= (setq i (1- i)) 127)
7218 ;; Only modify if the entry is nil.
7219 (or (aref gnus-summary-display-table i)
7220 (aset gnus-summary-display-table i [??])))))
7222 (defun gnus-summary-clear-local-variables ()
7223 (let ((locals gnus-summary-local-variables))
7225 (if (consp (car locals))
7226 (and (vectorp (caar locals))
7227 (set (caar locals) nil))
7228 (and (vectorp (car locals))
7229 (set (car locals) nil)))
7230 (setq locals (cdr locals)))))
7232 ;; Summary data functions.
7234 (defmacro gnus-data-number (data)
7237 (defmacro gnus-data-set-number (data number)
7238 `(setcar ,data ,number))
7240 (defmacro gnus-data-mark (data)
7243 (defmacro gnus-data-set-mark (data mark)
7244 `(setcar (nthcdr 1 ,data) ,mark))
7246 (defmacro gnus-data-pos (data)
7249 (defmacro gnus-data-set-pos (data pos)
7250 `(setcar (nthcdr 2 ,data) ,pos))
7252 (defmacro gnus-data-header (data)
7255 (defmacro gnus-data-level (data)
7258 (defmacro gnus-data-unread-p (data)
7259 `(= (nth 1 ,data) gnus-unread-mark))
7261 (defmacro gnus-data-pseudo-p (data)
7262 `(consp (nth 3 ,data)))
7264 (defmacro gnus-data-find (number)
7265 `(assq ,number gnus-newsgroup-data))
7267 (defmacro gnus-data-find-list (number &optional data)
7268 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7269 (memq (assq ,number bdata)
7272 (defmacro gnus-data-make (number mark pos header level)
7273 `(list ,number ,mark ,pos ,header ,level))
7275 (defun gnus-data-enter (after-article number mark pos header level offset)
7276 (let ((data (gnus-data-find-list after-article)))
7277 (or data (error "No such article: %d" after-article))
7278 (setcdr data (cons (gnus-data-make number mark pos header level)
7280 (setq gnus-newsgroup-data-reverse nil)
7281 (gnus-data-update-list (cddr data) offset)))
7283 (defun gnus-data-enter-list (after-article list &optional offset)
7285 (let ((data (and after-article (gnus-data-find-list after-article)))
7287 (or data (not after-article) (error "No such article: %d" after-article))
7288 ;; Find the last element in the list to be spliced into the main
7291 (setq list (cdr list)))
7294 (setcdr list gnus-newsgroup-data)
7295 (setq gnus-newsgroup-data ilist)
7296 (and offset (gnus-data-update-list (cdr list) offset)))
7297 (setcdr list (cdr data))
7299 (and offset (gnus-data-update-list (cdr data) offset)))
7300 (setq gnus-newsgroup-data-reverse nil))))
7302 (defun gnus-data-remove (article &optional offset)
7303 (let ((data gnus-newsgroup-data))
7304 (if (= (gnus-data-number (car data)) article)
7305 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7306 gnus-newsgroup-data-reverse nil)
7308 (and (= (gnus-data-number (cadr data)) article)
7310 (setcdr data (cddr data))
7311 (and offset (gnus-data-update-list (cdr data) offset))
7313 gnus-newsgroup-data-reverse nil)))
7314 (setq data (cdr data))))))
7316 (defmacro gnus-data-list (backward)
7318 (or gnus-newsgroup-data-reverse
7319 (setq gnus-newsgroup-data-reverse
7320 (reverse gnus-newsgroup-data)))
7321 gnus-newsgroup-data))
7323 (defun gnus-data-update-list (data offset)
7324 "Add OFFSET to the POS of all data entries in DATA."
7326 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7327 (setq data (cdr data))))
7329 (defun gnus-data-compute-positions ()
7330 "Compute the positions of all articles."
7331 (let ((data gnus-newsgroup-data)
7334 (when (setq pos (text-property-any
7335 (point-min) (point-max)
7336 'gnus-number (gnus-data-number (car data))))
7337 (gnus-data-set-pos (car data) (+ pos 3)))
7338 (setq data (cdr data)))))
7340 (defun gnus-summary-article-pseudo-p (article)
7341 "Say whether this article is a pseudo article or not."
7342 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7344 (defun gnus-article-parent-p (number)
7345 "Say whether this article is a parent or not."
7346 (let ((data (gnus-data-find-list number)))
7347 (and (cdr data) ; There has to be an article after...
7348 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7349 (gnus-data-level (nth 1 data))))))
7351 (defun gnus-article-children (number)
7352 "Return a list of all children to NUMBER."
7353 (let* ((data (gnus-data-find-list number))
7354 (level (gnus-data-level (car data)))
7356 (setq data (cdr data))
7358 (= (gnus-data-level (car data)) (1+ level)))
7359 (push (gnus-data-number (car data)) children)
7360 (setq data (cdr data)))
7363 (defmacro gnus-summary-skip-intangible ()
7364 "If the current article is intangible, then jump to a different article."
7365 '(let ((to (get-text-property (point) 'gnus-intangible)))
7366 (and to (gnus-summary-goto-subject to))))
7368 (defmacro gnus-summary-article-intangible-p ()
7369 "Say whether this article is intangible or not."
7370 '(get-text-property (point) 'gnus-intangible))
7372 ;; Some summary mode macros.
7374 (defmacro gnus-summary-article-number ()
7375 "The article number of the article on the current line.
7376 If there isn's an article number here, then we return the current
7379 (gnus-summary-skip-intangible)
7380 (or (get-text-property (point) 'gnus-number)
7381 (gnus-summary-last-subject))))
7383 (defmacro gnus-summary-article-header (&optional number)
7384 `(gnus-data-header (gnus-data-find
7385 ,(or number '(gnus-summary-article-number)))))
7387 (defmacro gnus-summary-thread-level (&optional number)
7388 `(if (and (eq gnus-summary-make-false-root 'dummy)
7389 (get-text-property (point) 'gnus-intangible))
7391 (gnus-data-level (gnus-data-find
7392 ,(or number '(gnus-summary-article-number))))))
7394 (defmacro gnus-summary-article-mark (&optional number)
7395 `(gnus-data-mark (gnus-data-find
7396 ,(or number '(gnus-summary-article-number)))))
7398 (defmacro gnus-summary-article-pos (&optional number)
7399 `(gnus-data-pos (gnus-data-find
7400 ,(or number '(gnus-summary-article-number)))))
7402 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7403 (defmacro gnus-summary-article-subject (&optional number)
7404 "Return current subject string or nil if nothing."
7407 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7408 '(gnus-data-header (assq (gnus-summary-article-number)
7409 gnus-newsgroup-data)))))
7412 (mail-header-subject headers))))
7414 (defmacro gnus-summary-article-score (&optional number)
7415 "Return current article score."
7416 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7417 gnus-newsgroup-scored))
7418 gnus-summary-default-score 0))
7420 (defun gnus-summary-article-children (&optional number)
7421 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7422 (level (gnus-data-level (car data)))
7424 (while (and (setq data (cdr data))
7425 (> (setq l (gnus-data-level (car data))) level))
7426 (and (= (1+ level) l)
7427 (setq children (cons (gnus-data-number (car data))
7429 (nreverse children)))
7431 (defun gnus-summary-article-parent (&optional number)
7432 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7433 (gnus-data-list t)))
7434 (level (gnus-data-level (car data))))
7436 () ; This is a root.
7437 ;; We search until we find an article with a level less than
7438 ;; this one. That function has to be the parent.
7439 (while (and (setq data (cdr data))
7440 (not (< (gnus-data-level (car data)) level))))
7441 (and data (gnus-data-number (car data))))))
7443 (defun gnus-unread-mark-p (mark)
7444 "Say whether MARK is the unread mark."
7445 (= mark gnus-unread-mark))
7447 (defun gnus-read-mark-p (mark)
7448 "Say whether MARK is one of the marks that mark as read.
7449 This is all marks except unread, ticked, dormant, and expirable."
7450 (not (or (= mark gnus-unread-mark)
7451 (= mark gnus-ticked-mark)
7452 (= mark gnus-dormant-mark)
7453 (= mark gnus-expirable-mark))))
7455 ;; Saving hidden threads.
7457 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7458 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7459 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7461 (defmacro gnus-save-hidden-threads (&rest forms)
7462 "Save hidden threads, eval FORMS, and restore the hidden threads."
7463 (let ((config (make-symbol "config")))
7464 `(let ((,config (gnus-hidden-threads-configuration)))
7468 (gnus-restore-hidden-threads-configuration ,config)))))
7470 (defun gnus-hidden-threads-configuration ()
7471 "Return the current hidden threads configuration."
7474 (goto-char (point-min))
7475 (while (search-forward "\r" nil t)
7476 (push (1- (point)) config))
7479 (defun gnus-restore-hidden-threads-configuration (config)
7480 "Restore hidden threads configuration from CONFIG."
7481 (let (point buffer-read-only)
7482 (while (setq point (pop config))
7483 (when (and (< point (point-max))
7485 (= (following-char) ?\n))
7486 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7488 ;; Various summary mode internalish functions.
7490 (defun gnus-mouse-pick-article (e)
7493 (gnus-summary-next-page nil t))
7495 (defun gnus-summary-setup-buffer (group)
7496 "Initialize summary buffer."
7497 (let ((buffer (concat "*Summary " group "*")))
7498 (if (get-buffer buffer)
7501 (setq gnus-summary-buffer (current-buffer))
7502 (not gnus-newsgroup-prepared))
7503 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7504 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7505 (gnus-add-current-to-buffer-list)
7506 (gnus-summary-mode group)
7508 (gnus-carpal-setup-buffer 'summary))
7509 (unless gnus-single-article-buffer
7510 (make-local-variable 'gnus-article-buffer)
7511 (make-local-variable 'gnus-article-current)
7512 (make-local-variable 'gnus-original-article-buffer))
7513 (setq gnus-newsgroup-name group)
7516 (defun gnus-set-global-variables ()
7517 ;; Set the global equivalents of the summary buffer-local variables
7518 ;; to the latest values they had. These reflect the summary buffer
7519 ;; that was in action when the last article was fetched.
7520 (when (eq major-mode 'gnus-summary-mode)
7521 (setq gnus-summary-buffer (current-buffer))
7522 (let ((name gnus-newsgroup-name)
7523 (marked gnus-newsgroup-marked)
7524 (unread gnus-newsgroup-unreads)
7525 (headers gnus-current-headers)
7526 (data gnus-newsgroup-data)
7527 (summary gnus-summary-buffer)
7528 (article-buffer gnus-article-buffer)
7529 (original gnus-original-article-buffer)
7530 (gac gnus-article-current)
7531 (score-file gnus-current-score-file))
7533 (set-buffer gnus-group-buffer)
7534 (setq gnus-newsgroup-name name)
7535 (setq gnus-newsgroup-marked marked)
7536 (setq gnus-newsgroup-unreads unread)
7537 (setq gnus-current-headers headers)
7538 (setq gnus-newsgroup-data data)
7539 (setq gnus-article-current gac)
7540 (setq gnus-summary-buffer summary)
7541 (setq gnus-article-buffer article-buffer)
7542 (setq gnus-original-article-buffer original)
7543 (setq gnus-current-score-file score-file)))))
7545 (defun gnus-summary-last-article-p (&optional article)
7546 "Return whether ARTICLE is the last article in the buffer."
7547 (if (not (setq article (or article (gnus-summary-article-number))))
7548 t ; All non-existant numbers are the last article. :-)
7549 (not (cdr (gnus-data-find-list article)))))
7551 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7552 "Insert a dummy root in the summary buffer."
7554 (gnus-add-text-properties
7555 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7556 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7558 (defun gnus-make-thread-indent-array ()
7560 (unless (and gnus-thread-indent-array
7561 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7562 (setq gnus-thread-indent-array (make-vector 201 "")
7563 gnus-thread-indent-array-level gnus-thread-indent-level)
7565 (aset gnus-thread-indent-array n
7566 (make-string (* n gnus-thread-indent-level) ? ))
7569 (defun gnus-summary-insert-line
7570 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7571 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7572 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7573 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7574 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7575 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7576 (gnus-tmp-score-char
7577 (if (or (null gnus-summary-default-score)
7578 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7579 gnus-summary-zcore-fuzz)) ?
7580 (if (< gnus-tmp-score gnus-summary-default-score)
7581 gnus-score-below-mark gnus-score-over-mark)))
7582 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7583 ((memq gnus-tmp-current gnus-newsgroup-cached)
7585 (gnus-tmp-replied gnus-replied-mark)
7586 ((memq gnus-tmp-current gnus-newsgroup-saved)
7588 (t gnus-unread-mark)))
7589 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7592 ((string-match "(.+)" gnus-tmp-from)
7593 (substring gnus-tmp-from
7594 (1+ (match-beginning 0)) (1- (match-end 0))))
7595 ((string-match "<[^>]+> *$" gnus-tmp-from)
7596 (let ((beg (match-beginning 0)))
7597 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7598 (substring gnus-tmp-from (1+ (match-beginning 0))
7599 (1- (match-end 0))))
7600 (substring gnus-tmp-from 0 beg))))
7602 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7603 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7604 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7605 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7606 (buffer-read-only nil))
7607 (when (string= gnus-tmp-name "")
7608 (setq gnus-tmp-name gnus-tmp-from))
7609 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7610 (gnus-put-text-property
7612 (progn (eval gnus-summary-line-format-spec) (point))
7613 'gnus-number gnus-tmp-number)
7614 (when (gnus-visual-p 'summary-highlight 'highlight)
7616 (run-hooks 'gnus-summary-update-hook)
7619 (defun gnus-summary-update-line (&optional dont-update)
7620 ;; Update summary line after change.
7621 (when (and gnus-summary-default-score
7622 (not gnus-summary-inhibit-highlight))
7623 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7624 (article (gnus-summary-article-number))
7625 (score (gnus-summary-article-score article)))
7627 (if (and gnus-summary-mark-below
7628 (< (gnus-summary-article-score)
7629 gnus-summary-mark-below))
7630 ;; This article has a low score, so we mark it as read.
7631 (when (memq article gnus-newsgroup-unreads)
7632 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7633 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7634 ;; This article was previously marked as read on account
7635 ;; of a low score, but now it has risen, so we mark it as
7637 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7638 (gnus-summary-update-mark
7639 (if (or (null gnus-summary-default-score)
7640 (<= (abs (- score gnus-summary-default-score))
7641 gnus-summary-zcore-fuzz)) ?
7642 (if (< score gnus-summary-default-score)
7643 gnus-score-below-mark gnus-score-over-mark)) 'score))
7644 ;; Do visual highlighting.
7645 (when (gnus-visual-p 'summary-highlight 'highlight)
7646 (run-hooks 'gnus-summary-update-hook)))))
7648 (defvar gnus-tmp-new-adopts nil)
7650 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7651 ;; Sum up all elements (and sub-elements) in a list.
7653 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7655 ((and (consp thread) (cdr thread))
7658 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7661 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7664 (when (and level (zerop level) gnus-tmp-new-adopts)
7667 'gnus-summary-number-of-articles-in-thread
7668 gnus-tmp-new-adopts))))
7670 (if (> number 1) gnus-not-empty-thread-mark
7671 gnus-empty-thread-mark)
7674 (defun gnus-summary-set-local-parameters (group)
7675 "Go through the local params of GROUP and set all variable specs in that list."
7676 (let ((params (gnus-info-params (gnus-get-info group)))
7679 (setq elem (car params)
7680 params (cdr params))
7681 (and (consp elem) ; Has to be a cons.
7682 (consp (cdr elem)) ; The cdr has to be a list.
7683 (symbolp (car elem)) ; Has to be a symbol in there.
7684 (not (memq (car elem)
7685 '(quit-config to-address to-list to-group)))
7686 (progn ; So we set it.
7687 (make-local-variable (car elem))
7688 (set (car elem) (eval (nth 1 elem))))))))
7690 (defun gnus-summary-read-group (group &optional show-all no-article
7691 kill-buffer no-display)
7692 "Start reading news in newsgroup GROUP.
7693 If SHOW-ALL is non-nil, already read articles are also listed.
7694 If NO-ARTICLE is non-nil, no article is selected initially.
7695 If NO-DISPLAY, don't generate a summary buffer."
7696 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7697 (let* ((new-group (gnus-summary-setup-buffer group))
7698 (quit-config (gnus-group-quit-config group))
7699 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7701 ;; This summary buffer exists already, so we just select it.
7703 (gnus-set-global-variables)
7705 (gnus-kill-or-deaden-summary kill-buffer))
7706 (gnus-configure-windows 'summary 'force)
7707 (gnus-set-mode-line 'summary)
7708 (gnus-summary-position-point)
7711 ;; We couldn't select this group.
7713 (when (and (eq major-mode 'gnus-summary-mode)
7714 (not (equal (current-buffer) kill-buffer)))
7715 (kill-buffer (current-buffer))
7716 (if (not quit-config)
7718 (set-buffer gnus-group-buffer)
7719 (gnus-group-jump-to-group group)
7720 (gnus-group-next-unread-group 1))
7721 (if (not (buffer-name (car quit-config)))
7722 (gnus-configure-windows 'group 'force)
7723 (set-buffer (car quit-config))
7724 (and (eq major-mode 'gnus-summary-mode)
7725 (gnus-set-global-variables))
7726 (gnus-configure-windows (cdr quit-config)))))
7727 (gnus-message 3 "Can't select group")
7729 ;; The user did a `C-g' while prompting for number of articles,
7730 ;; so we exit this group.
7731 ((eq did-select 'quit)
7732 (and (eq major-mode 'gnus-summary-mode)
7733 (not (equal (current-buffer) kill-buffer))
7734 (kill-buffer (current-buffer)))
7736 (gnus-kill-or-deaden-summary kill-buffer))
7737 (if (not quit-config)
7739 (set-buffer gnus-group-buffer)
7740 (gnus-group-jump-to-group group)
7741 (gnus-group-next-unread-group 1)
7742 (gnus-configure-windows 'group 'force))
7743 (if (not (buffer-name (car quit-config)))
7744 (gnus-configure-windows 'group 'force)
7745 (set-buffer (car quit-config))
7746 (and (eq major-mode 'gnus-summary-mode)
7747 (gnus-set-global-variables))
7748 (gnus-configure-windows (cdr quit-config))))
7749 ;; Finally signal the quit.
7751 ;; The group was successfully selected.
7753 (gnus-set-global-variables)
7754 ;; Save the active value in effect when the group was entered.
7755 (setq gnus-newsgroup-active
7757 (gnus-active gnus-newsgroup-name)))
7758 ;; You can change the summary buffer in some way with this hook.
7759 (run-hooks 'gnus-select-group-hook)
7760 ;; Set any local variables in the group parameters.
7761 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7762 (gnus-update-format-specifications)
7763 ;; Do score processing.
7764 (when gnus-use-scoring
7765 (gnus-possibly-score-headers))
7766 ;; Check whether to fill in the gaps in the threads.
7767 (when gnus-build-sparse-threads
7768 (gnus-build-sparse-threads))
7769 ;; Find the initial limit.
7770 (if gnus-show-threads
7772 (let ((gnus-newsgroup-dormant nil))
7773 (gnus-summary-initial-limit show-all))
7774 (gnus-summary-initial-limit show-all))
7775 (setq gnus-newsgroup-limit
7777 (lambda (header) (mail-header-number header))
7778 gnus-newsgroup-headers)))
7779 ;; Generate the summary buffer.
7781 (gnus-summary-prepare))
7782 (when gnus-use-trees
7783 (gnus-tree-open group)
7784 (setq gnus-summary-highlight-line-function
7785 'gnus-tree-highlight-article))
7786 ;; If the summary buffer is empty, but there are some low-scored
7787 ;; articles or some excluded dormants, we include these in the
7789 (when (and (zerop (buffer-size))
7791 (cond (gnus-newsgroup-dormant
7792 (gnus-summary-limit-include-dormant))
7793 ((and gnus-newsgroup-scored show-all)
7794 (gnus-summary-limit-include-expunged))))
7795 ;; Function `gnus-apply-kill-file' must be called in this hook.
7796 (run-hooks 'gnus-apply-kill-hook)
7797 (if (and (zerop (buffer-size))
7800 ;; This newsgroup is empty.
7801 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7802 (gnus-message 6 "No unread news")
7804 (gnus-kill-or-deaden-summary kill-buffer))
7805 ;; Return nil from this function.
7807 ;; Hide conversation thread subtrees. We cannot do this in
7808 ;; gnus-summary-prepare-hook since kill processing may not
7809 ;; work with hidden articles.
7810 (and gnus-show-threads
7811 gnus-thread-hide-subtree
7812 (gnus-summary-hide-all-threads))
7813 ;; Show first unread article if requested.
7814 (if (and (not no-article)
7816 gnus-newsgroup-unreads
7817 gnus-auto-select-first)
7818 (unless (if (eq gnus-auto-select-first 'best)
7819 (gnus-summary-best-unread-article)
7820 (gnus-summary-first-unread-article))
7821 (gnus-configure-windows 'summary))
7822 ;; Don't select any articles, just move point to the first
7823 ;; article in the group.
7824 (goto-char (point-min))
7825 (gnus-summary-position-point)
7826 (gnus-set-mode-line 'summary)
7827 (gnus-configure-windows 'summary 'force))
7828 ;; If we are in async mode, we send some info to the backend.
7829 (when gnus-newsgroup-async
7830 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7832 (gnus-kill-or-deaden-summary kill-buffer))
7833 (when (get-buffer-window gnus-group-buffer t)
7834 ;; Gotta use windows, because recenter does wierd stuff if
7835 ;; the current buffer ain't the displayed window.
7836 (let ((owin (selected-window)))
7837 (select-window (get-buffer-window gnus-group-buffer t))
7838 (when (gnus-group-goto-group group)
7840 (select-window owin))))
7841 ;; Mark this buffer as "prepared".
7842 (setq gnus-newsgroup-prepared t)
7845 (defun gnus-summary-prepare ()
7846 "Generate the summary buffer."
7847 (let ((buffer-read-only nil))
7849 (setq gnus-newsgroup-data nil
7850 gnus-newsgroup-data-reverse nil)
7851 (run-hooks 'gnus-summary-generate-hook)
7852 ;; Generate the buffer, either with threads or without.
7853 (when gnus-newsgroup-headers
7854 (gnus-summary-prepare-threads
7855 (if gnus-show-threads
7856 (gnus-sort-gathered-threads
7857 (funcall gnus-summary-thread-gathering-function
7859 (gnus-cut-threads (gnus-make-threads)))))
7860 ;; Unthreaded display.
7861 (gnus-sort-articles gnus-newsgroup-headers))))
7862 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7863 ;; Call hooks for modifying summary buffer.
7864 (goto-char (point-min))
7865 (run-hooks 'gnus-summary-prepare-hook)))
7867 (defun gnus-gather-threads-by-subject (threads)
7868 "Gather threads by looking at Subject headers."
7869 (if (not gnus-summary-make-false-root)
7871 (let ((hashtb (gnus-make-hashtable 1023))
7874 subject hthread whole-subject)
7876 (setq whole-subject (mail-header-subject (caar threads)))
7879 ;; Truncate the subject.
7880 ((numberp gnus-summary-gather-subject-limit)
7881 (setq subject (gnus-simplify-subject-re whole-subject))
7882 (if (> (length subject) gnus-summary-gather-subject-limit)
7883 (substring subject 0 gnus-summary-gather-subject-limit)
7885 ;; Fuzzily simplify it.
7886 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7887 (gnus-simplify-subject-fuzzy whole-subject))
7888 ;; Just remove the leading "Re:".
7890 (gnus-simplify-subject-re whole-subject))))
7892 (if (and gnus-summary-gather-exclude-subject
7893 (string-match gnus-summary-gather-exclude-subject
7895 () ; We don't want to do anything with this article.
7896 ;; We simplify the subject before looking it up in the
7899 (if (setq hthread (gnus-gethash subject hashtb))
7901 ;; We enter a dummy root into the thread, if we
7902 ;; haven't done that already.
7903 (unless (stringp (caar hthread))
7904 (setcar hthread (list whole-subject (car hthread))))
7905 ;; We add this new gathered thread to this gathered
7907 (setcdr (car hthread)
7908 (nconc (cdar hthread) (list (car threads))))
7909 ;; Remove it from the list of threads.
7910 (setcdr prev (cdr threads))
7911 (setq threads prev))
7912 ;; Enter this thread into the hash table.
7913 (gnus-sethash subject threads hashtb)))
7915 (setq threads (cdr threads)))
7918 (defun gnus-gather-threads-by-references (threads)
7919 "Gather threads by looking at References headers."
7920 (let ((idhashtb (gnus-make-hashtable 1023))
7921 (thhashtb (gnus-make-hashtable 1023))
7924 ids references id gthread gid entered)
7926 (when (setq references (mail-header-references (caar threads)))
7927 (setq id (mail-header-id (caar threads)))
7928 (setq ids (gnus-split-references references))
7931 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7933 (gnus-sethash (car ids) id idhashtb)
7934 (gnus-sethash id threads thhashtb))
7935 (setq gthread (gnus-gethash gid thhashtb))
7937 ;; We enter a dummy root into the thread, if we
7938 ;; haven't done that already.
7939 (unless (stringp (caar gthread))
7940 (setcar gthread (list (mail-header-subject (caar gthread))
7942 ;; We add this new gathered thread to this gathered
7944 (setcdr (car gthread)
7945 (nconc (cdar gthread) (list (car threads)))))
7946 ;; Add it into the thread hash table.
7947 (gnus-sethash id gthread thhashtb)
7949 ;; Remove it from the list of threads.
7950 (setcdr prev (cdr threads))
7951 (setq threads prev))
7952 (setq ids (cdr ids))))
7954 (setq threads (cdr threads)))
7957 (defun gnus-sort-gathered-threads (threads)
7958 "Sort subtreads inside each gathered thread by article number."
7959 (let ((result threads))
7961 (when (stringp (caar threads))
7962 (setcdr (car threads)
7963 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7964 (setq threads (cdr threads)))
7967 (defun gnus-make-threads ()
7968 "Go through the dependency hashtb and find the roots. Return all threads."
7972 (unless (car (symbol-value refs))
7973 ;; These threads do not refer back to any other articles,
7974 ;; so they're roots.
7975 (setq threads (append (cdr (symbol-value refs)) threads))))
7976 gnus-newsgroup-dependencies)
7979 (defun gnus-build-sparse-threads ()
7980 (let ((headers gnus-newsgroup-headers)
7981 (deps gnus-newsgroup-dependencies)
7982 header references generation relations
7983 cthread subject child end pthread relation)
7984 ;; First we create an alist of generations/relations, where
7985 ;; generations is how much we trust the ralation, and the relation
7987 (gnus-message 7 "Making sparse threads...")
7989 (nnheader-set-temp-buffer " *gnus sparse threads*")
7990 (while (setq header (pop headers))
7991 (when (and (setq references (mail-header-references header))
7992 (not (string= references "")))
7994 (setq child (mail-header-id header)
7995 subject (mail-header-subject header))
7997 (while (search-backward ">" nil t)
7998 (setq end (1+ (point)))
7999 (when (search-backward "<" nil t)
8000 (push (list (incf generation)
8001 child (setq child (buffer-substring (point) end))
8004 (push (list (1+ generation) child nil subject) relations)
8006 (kill-buffer (current-buffer)))
8007 ;; Sort over trustworthiness.
8008 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8009 (while (setq relation (pop relations))
8010 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8011 (unless (car (symbol-value cthread))
8012 ;; Make this article the parent of these threads.
8013 (setcar (symbol-value cthread)
8014 (vector gnus-reffed-article-number
8018 (or (caddr relation) "") 0 0 "")))
8019 (set cthread (list (vector gnus-reffed-article-number
8021 "" "" (cadr relation)
8022 (or (caddr relation) "") 0 0 ""))))
8023 (push gnus-reffed-article-number gnus-newsgroup-limit)
8024 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8025 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8026 gnus-newsgroup-reads)
8027 (decf gnus-reffed-article-number)
8028 ;; Make this new thread the child of its parent.
8029 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8030 (setcdr (symbol-value pthread)
8031 (nconc (cdr (symbol-value pthread))
8032 (list (symbol-value cthread))))
8033 (set pthread (list nil (symbol-value cthread))))))
8034 (gnus-message 7 "Making sparse threads...done")))
8036 (defun gnus-build-old-threads ()
8037 ;; Look at all the articles that refer back to old articles, and
8038 ;; fetch the headers for the articles that aren't there. This will
8039 ;; build complete threads - if the roots haven't been expired by the
8044 (when (not (car (symbol-value refs)))
8045 (setq heads (cdr (symbol-value refs)))
8047 (if (memq (mail-header-number (caar heads))
8048 gnus-newsgroup-dormant)
8049 (setq heads (cdr heads))
8050 (setq id (symbol-name refs))
8051 (while (and (setq id (gnus-build-get-header id))
8052 (not (car (gnus-gethash
8053 id gnus-newsgroup-dependencies)))))
8054 (setq heads nil)))))
8055 gnus-newsgroup-dependencies)))
8057 (defun gnus-build-get-header (id)
8058 ;; Look through the buffer of NOV lines and find the header to
8059 ;; ID. Enter this line into the dependencies hash table, and return
8060 ;; the id of the parent article (if any).
8061 (let ((deps gnus-newsgroup-dependencies)
8065 (set-buffer nntp-server-buffer)
8066 (goto-char (point-min))
8067 (while (and (not found) (search-forward id nil t))
8069 (setq found (looking-at
8070 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8071 (regexp-quote id))))
8072 (or found (beginning-of-line 2)))
8076 (setq header (gnus-nov-parse-line
8077 (read (current-buffer)) deps))
8078 (gnus-parent-id (mail-header-references header)))))
8080 (let ((number (mail-header-number header)))
8081 (push number gnus-newsgroup-limit)
8082 (push header gnus-newsgroup-headers)
8083 (if (memq number gnus-newsgroup-unselected)
8085 (push number gnus-newsgroup-unreads)
8086 (setq gnus-newsgroup-unselected
8087 (delq number gnus-newsgroup-unselected)))
8088 (push number gnus-newsgroup-ancient)))))))
8090 (defun gnus-summary-update-article (article &optional iheader)
8091 "Update ARTICLE in the summary buffer."
8092 (set-buffer gnus-summary-buffer)
8093 (let* ((header (or iheader (gnus-summary-article-header article)))
8094 (id (mail-header-id header))
8095 (data (gnus-data-find article))
8096 (thread (gnus-id-to-thread id))
8097 (references (mail-header-references header))
8102 (not (equal "" references)))
8105 (buffer-read-only nil)
8107 (number (mail-header-number header))
8110 ;; !!! Should this be in or not?
8112 (setcar thread nil))
8114 (delq thread parent))
8115 (if (gnus-summary-insert-subject id header iheader)
8116 ;; Set the (possibly) new article number in the data structure.
8117 (gnus-data-set-number data (gnus-id-to-article id))
8121 (defun gnus-rebuild-thread (id)
8122 "Rebuild the thread containing ID."
8123 (let ((buffer-read-only nil)
8124 current thread data)
8125 (if (not gnus-show-threads)
8126 (setq thread (list (car (gnus-id-to-thread id))))
8127 ;; Get the thread this article is part of.
8128 (setq thread (gnus-remove-thread id)))
8129 (setq current (save-excursion
8130 (and (zerop (forward-line -1))
8131 (gnus-summary-article-number))))
8132 ;; If this is a gathered thread, we have to go some re-gathering.
8133 (when (stringp (car thread))
8134 (let ((subject (car thread))
8136 (setq thread (cdr thread))
8138 (unless (memq (setq thr (gnus-id-to-thread
8140 (mail-header-id (caar thread)))))
8143 (setq thread (cdr thread)))
8144 ;; We now have all (unique) roots.
8145 (if (= (length roots) 1)
8146 ;; All the loose roots are now one solid root.
8147 (setq thread (car roots))
8148 (setq thread (cons subject (gnus-sort-threads roots))))))
8150 ;; We then insert this thread into the summary buffer.
8151 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8152 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8153 (setq data (nreverse gnus-newsgroup-data))
8154 (setq threads gnus-newsgroup-threads))
8155 ;; We splice the new data into the data structure.
8156 (gnus-data-enter-list current data)
8157 (gnus-data-compute-positions)
8158 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8160 (defun gnus-number-to-header (number)
8161 "Return the header for article NUMBER."
8162 (let ((headers gnus-newsgroup-headers))
8164 (not (= number (mail-header-number (car headers)))))
8169 (defun gnus-id-to-thread (id)
8170 "Return the (sub-)thread where ID appears."
8171 (gnus-gethash id gnus-newsgroup-dependencies))
8173 (defun gnus-id-to-article (id)
8174 "Return the article number of ID."
8175 (let ((thread (gnus-id-to-thread id)))
8178 (mail-header-number (car thread)))))
8180 (defun gnus-id-to-header (id)
8181 "Return the article headers of ID."
8182 (car (gnus-id-to-thread id)))
8184 (defun gnus-article-displayed-root-p (article)
8185 "Say whether ARTICLE is a root(ish) article."
8186 (let ((level (gnus-summary-thread-level article))
8187 (refs (mail-header-references (gnus-summary-article-header article)))
8193 ((null (gnus-parent-id refs)) t)
8195 (null (setq particle (gnus-id-to-article
8196 (gnus-parent-id refs))))
8197 (null (gnus-summary-thread-level particle)))))))
8199 (defun gnus-root-id (id)
8200 "Return the id of the root of the thread where ID appears."
8202 (while (and id (setq prev (car (gnus-gethash
8203 id gnus-newsgroup-dependencies))))
8205 id (gnus-parent-id (mail-header-references prev))))
8208 (defun gnus-remove-thread (id &optional dont-remove)
8209 "Remove the thread that has ID in it."
8210 (let ((dep gnus-newsgroup-dependencies)
8211 headers thread last-id)
8212 ;; First go up in this thread until we find the root.
8213 (setq last-id (gnus-root-id id))
8214 (setq headers (list (car (gnus-id-to-thread last-id))
8215 (caadr (gnus-id-to-thread last-id))))
8216 ;; We have now found the real root of this thread. It might have
8217 ;; been gathered into some loose thread, so we have to search
8218 ;; through the threads to find the thread we wanted.
8219 (let ((threads gnus-newsgroup-threads)
8222 (setq sub (car threads))
8223 (if (stringp (car sub))
8224 ;; This is a gathered threads, so we look at the roots
8225 ;; below it to find whether this article in in this
8228 (setq sub (cdr sub))
8230 (when (member (caar sub) headers)
8231 (setq thread (car threads)
8234 (setq sub (cdr sub))))
8235 ;; It's an ordinary thread, so we check it.
8236 (when (eq (car sub) (car headers))
8239 (setq threads (cdr threads)))
8240 ;; If this article is in no thread, then it's a root.
8243 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8244 (setq thread (gnus-gethash last-id dep)))
8247 thread ; We return this thread.
8249 (if (stringp (car thread))
8251 ;; If we use dummy roots, then we have to remove the
8252 ;; dummy root as well.
8253 (when (eq gnus-summary-make-false-root 'dummy)
8256 (setq thread (cdr thread))
8258 (gnus-remove-thread-1 (car thread))
8259 (setq thread (cdr thread))))
8260 (gnus-remove-thread-1 thread))))))))
8262 (defun gnus-remove-thread-1 (thread)
8263 "Remove the thread THREAD recursively."
8264 (let ((number (mail-header-number (car thread)))
8266 (when (setq pos (text-property-any
8267 (point-min) (point-max) 'gnus-number number))
8270 (gnus-data-remove number))
8271 (setq thread (cdr thread))
8273 (gnus-remove-thread-1 (pop thread)))))
8275 (defun gnus-sort-threads (threads)
8277 (if (not gnus-thread-sort-functions)
8279 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8280 (car gnus-thread-sort-functions)
8282 ,(gnus-make-sort-function
8283 (reverse gnus-thread-sort-functions))))))
8284 (gnus-message 7 "Sorting threads...")
8287 (gnus-message 7 "Sorting threads...done")))))
8289 (defun gnus-sort-articles (articles)
8291 (when gnus-article-sort-functions
8292 (let ((func (if (= 1 (length gnus-article-sort-functions))
8293 (car gnus-article-sort-functions)
8295 ,(gnus-make-sort-function
8296 (reverse gnus-article-sort-functions))))))
8297 (gnus-message 7 "Sorting articles...")
8299 (setq gnus-newsgroup-headers (sort articles func))
8300 (gnus-message 7 "Sorting articles...done")))))
8302 (defun gnus-make-sort-function (funs)
8303 "Return a composite sort condition based on the functions in FUNC."
8305 `(or (,(car funs) t1 t2)
8306 (and (not (,(car funs) t2 t1))
8307 ,(gnus-make-sort-function (cdr funs))))
8308 `(,(car funs) t1 t2)))
8310 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8311 (defmacro gnus-thread-header (thread)
8312 ;; Return header of first article in THREAD.
8313 ;; Note that THREAD must never, ever be anything else than a variable -
8314 ;; using some other form will lead to serious barfage.
8315 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8316 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8317 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8320 (defsubst gnus-article-sort-by-number (h1 h2)
8321 "Sort articles by article number."
8322 (< (mail-header-number h1)
8323 (mail-header-number h2)))
8325 (defun gnus-thread-sort-by-number (h1 h2)
8326 "Sort threads by root article number."
8327 (gnus-article-sort-by-number
8328 (gnus-thread-header h1) (gnus-thread-header h2)))
8330 (defsubst gnus-article-sort-by-author (h1 h2)
8331 "Sort articles by root author."
8333 (let ((extract (funcall
8334 gnus-extract-address-components
8335 (mail-header-from h1))))
8336 (or (car extract) (cdr extract)))
8337 (let ((extract (funcall
8338 gnus-extract-address-components
8339 (mail-header-from h2))))
8340 (or (car extract) (cdr extract)))))
8342 (defun gnus-thread-sort-by-author (h1 h2)
8343 "Sort threads by root author."
8344 (gnus-article-sort-by-author
8345 (gnus-thread-header h1) (gnus-thread-header h2)))
8347 (defsubst gnus-article-sort-by-subject (h1 h2)
8348 "Sort articles by root subject."
8350 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8351 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8353 (defun gnus-thread-sort-by-subject (h1 h2)
8354 "Sort threads by root subject."
8355 (gnus-article-sort-by-subject
8356 (gnus-thread-header h1) (gnus-thread-header h2)))
8358 (defsubst gnus-article-sort-by-date (h1 h2)
8359 "Sort articles by root article date."
8361 (inline (gnus-sortable-date (mail-header-date h1)))
8362 (inline (gnus-sortable-date (mail-header-date h2)))))
8364 (defun gnus-thread-sort-by-date (h1 h2)
8365 "Sort threads by root article date."
8366 (gnus-article-sort-by-date
8367 (gnus-thread-header h1) (gnus-thread-header h2)))
8369 (defsubst gnus-article-sort-by-score (h1 h2)
8370 "Sort articles by root article score.
8371 Unscored articles will be counted as having a score of zero."
8372 (> (or (cdr (assq (mail-header-number h1)
8373 gnus-newsgroup-scored))
8374 gnus-summary-default-score 0)
8375 (or (cdr (assq (mail-header-number h2)
8376 gnus-newsgroup-scored))
8377 gnus-summary-default-score 0)))
8379 (defun gnus-thread-sort-by-score (h1 h2)
8380 "Sort threads by root article score."
8381 (gnus-article-sort-by-score
8382 (gnus-thread-header h1) (gnus-thread-header h2)))
8384 (defun gnus-thread-sort-by-total-score (h1 h2)
8385 "Sort threads by the sum of all scores in the thread.
8386 Unscored articles will be counted as having a score of zero."
8387 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8389 (defun gnus-thread-total-score (thread)
8390 ;; This function find the total score of THREAD.
8391 (cond ((null thread)
8394 (if (stringp (car thread))
8395 (apply gnus-thread-score-function 0
8396 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8397 (gnus-thread-total-score-1 thread)))
8399 (gnus-thread-total-score-1 (list thread)))))
8401 (defun gnus-thread-total-score-1 (root)
8402 ;; This function find the total score of the thread below ROOT.
8403 (setq root (car root))
8404 (apply gnus-thread-score-function
8405 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8406 gnus-summary-default-score 0)
8407 (mapcar 'gnus-thread-total-score
8408 (cdr (gnus-gethash (mail-header-id root)
8409 gnus-newsgroup-dependencies)))))
8411 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8412 (defvar gnus-tmp-prev-subject nil)
8413 (defvar gnus-tmp-false-parent nil)
8414 (defvar gnus-tmp-root-expunged nil)
8415 (defvar gnus-tmp-dummy-line nil)
8417 (defun gnus-summary-prepare-threads (threads)
8418 "Prepare summary buffer from THREADS and indentation LEVEL.
8419 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8420 or a straight list of headers."
8421 (gnus-message 7 "Generating summary...")
8423 (setq gnus-newsgroup-threads threads)
8426 (let ((gnus-tmp-level 0)
8427 (default-score (or gnus-summary-default-score 0))
8428 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8429 thread number subject stack state gnus-tmp-gathered beg-match
8430 new-roots gnus-tmp-new-adopts thread-end
8431 gnus-tmp-header gnus-tmp-unread
8432 gnus-tmp-replied gnus-tmp-subject-or-nil
8433 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8434 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8435 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8437 (setq gnus-tmp-prev-subject nil)
8439 (if (vectorp (car threads))
8440 ;; If this is a straight (sic) list of headers, then a
8441 ;; threaded summary display isn't required, so we just create
8442 ;; an unthreaded one.
8443 (gnus-summary-prepare-unthreaded threads)
8445 ;; Do the threaded display.
8447 (while (or threads stack gnus-tmp-new-adopts new-roots)
8449 (if (and (= gnus-tmp-level 0)
8450 (not (setq gnus-tmp-dummy-line nil))
8453 (not gnus-tmp-false-parent)
8454 (or gnus-tmp-new-adopts new-roots))
8455 (if gnus-tmp-new-adopts
8456 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8457 thread (list (car gnus-tmp-new-adopts))
8458 gnus-tmp-header (caar thread)
8459 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8461 (setq thread (list (car new-roots))
8462 gnus-tmp-header (caar thread)
8463 new-roots (cdr new-roots))))
8466 ;; If there are some threads, we do them before the
8467 ;; threads on the stack.
8468 (setq thread threads
8469 gnus-tmp-header (caar thread))
8470 ;; There were no current threads, so we pop something off
8472 (setq state (car stack)
8473 gnus-tmp-level (car state)
8476 gnus-tmp-header (caar thread))))
8478 (setq gnus-tmp-false-parent nil)
8479 (setq gnus-tmp-root-expunged nil)
8480 (setq thread-end nil)
8482 (if (stringp gnus-tmp-header)
8483 ;; The header is a dummy root.
8485 ((eq gnus-summary-make-false-root 'adopt)
8486 ;; We let the first article adopt the rest.
8487 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8489 (setq gnus-tmp-gathered
8491 (lambda (h) (mail-header-number (car h)))
8494 (setq thread (cons (list (caar thread)
8497 (setq gnus-tmp-level -1
8498 gnus-tmp-false-parent t))
8499 ((eq gnus-summary-make-false-root 'empty)
8500 ;; We print adopted articles with empty subject fields.
8501 (setq gnus-tmp-gathered
8503 (lambda (h) (mail-header-number (car h)))
8506 (setq gnus-tmp-level -1))
8507 ((eq gnus-summary-make-false-root 'dummy)
8508 ;; We remember that we probably want to output a dummy
8510 (setq gnus-tmp-dummy-line gnus-tmp-header)
8511 (setq gnus-tmp-prev-subject gnus-tmp-header))
8513 ;; We do not make a root for the gathered
8514 ;; sub-threads at all.
8515 (setq gnus-tmp-level -1)))
8517 (setq number (mail-header-number gnus-tmp-header)
8518 subject (mail-header-subject gnus-tmp-header))
8521 ;; If the thread has changed subject, we might want to make
8522 ;; this subthread into a root.
8523 ((and (null gnus-thread-ignore-subject)
8524 (not (zerop gnus-tmp-level))
8525 gnus-tmp-prev-subject
8527 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8528 (setq new-roots (nconc new-roots (list (car thread)))
8530 gnus-tmp-header nil))
8531 ;; If the article lies outside the current limit,
8532 ;; then we do not display it.
8533 ((and (not (memq number gnus-newsgroup-limit))
8534 (not gnus-tmp-dummy-line))
8535 (setq gnus-tmp-gathered
8537 (lambda (h) (mail-header-number (car h)))
8540 (setq gnus-tmp-new-adopts (if (cdar thread)
8541 (append gnus-tmp-new-adopts
8543 gnus-tmp-new-adopts)
8545 gnus-tmp-header nil)
8546 (when (zerop gnus-tmp-level)
8547 (setq gnus-tmp-root-expunged t)))
8548 ;; Perhaps this article is to be marked as read?
8549 ((and gnus-summary-mark-below
8550 (< (or (cdr (assq number gnus-newsgroup-scored))
8552 gnus-summary-mark-below)
8553 ;; Don't touch sparse articles.
8554 (not (memq number gnus-newsgroup-sparse))
8555 (not (memq number gnus-newsgroup-ancient)))
8556 (setq gnus-newsgroup-unreads
8557 (delq number gnus-newsgroup-unreads))
8558 (if gnus-newsgroup-auto-expire
8559 (push number gnus-newsgroup-expirable)
8560 (push (cons number gnus-low-score-mark)
8561 gnus-newsgroup-reads))))
8563 (when gnus-tmp-header
8564 ;; We may have an old dummy line to output before this
8566 (when gnus-tmp-dummy-line
8567 (gnus-summary-insert-dummy-line
8568 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8569 (setq gnus-tmp-dummy-line nil))
8571 ;; Compute the mark.
8575 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8576 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8577 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8578 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8579 (t (or (cdr (assq number gnus-newsgroup-reads))
8580 gnus-ancient-mark))))
8582 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8583 gnus-tmp-header gnus-tmp-level)
8584 gnus-newsgroup-data)
8586 ;; Actually insert the line.
8588 gnus-tmp-subject-or-nil
8590 ((and gnus-thread-ignore-subject
8591 gnus-tmp-prev-subject
8592 (not (inline (gnus-subject-equal
8593 gnus-tmp-prev-subject subject))))
8595 ((zerop gnus-tmp-level)
8596 (if (and (eq gnus-summary-make-false-root 'empty)
8597 (memq number gnus-tmp-gathered)
8598 gnus-tmp-prev-subject
8599 (inline (gnus-subject-equal
8600 gnus-tmp-prev-subject subject)))
8601 gnus-summary-same-subject
8603 (t gnus-summary-same-subject)))
8604 (if (and (eq gnus-summary-make-false-root 'adopt)
8605 (= gnus-tmp-level 1)
8606 (memq number gnus-tmp-gathered))
8607 (setq gnus-tmp-opening-bracket ?\<
8608 gnus-tmp-closing-bracket ?\>)
8609 (setq gnus-tmp-opening-bracket ?\[
8610 gnus-tmp-closing-bracket ?\]))
8612 gnus-tmp-indentation
8613 (aref gnus-thread-indent-array gnus-tmp-level)
8614 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8615 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8616 gnus-summary-default-score 0)
8618 (if (or (null gnus-summary-default-score)
8619 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8620 gnus-summary-zcore-fuzz)) ?
8621 (if (< gnus-tmp-score gnus-summary-default-score)
8622 gnus-score-below-mark gnus-score-over-mark))
8624 (cond ((memq number gnus-newsgroup-processable)
8626 ((memq number gnus-newsgroup-cached)
8628 ((memq number gnus-newsgroup-replied)
8630 (t gnus-unread-mark))
8631 gnus-tmp-from (mail-header-from gnus-tmp-header)
8634 ((string-match "(.+)" gnus-tmp-from)
8635 (substring gnus-tmp-from
8636 (1+ (match-beginning 0)) (1- (match-end 0))))
8637 ((string-match "<[^>]+> *$" gnus-tmp-from)
8638 (setq beg-match (match-beginning 0))
8639 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8640 (substring gnus-tmp-from (1+ (match-beginning 0))
8641 (1- (match-end 0))))
8642 (substring gnus-tmp-from 0 beg-match)))
8644 (when (string= gnus-tmp-name "")
8645 (setq gnus-tmp-name gnus-tmp-from))
8646 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8647 (gnus-put-text-property
8649 (progn (eval gnus-summary-line-format-spec) (point))
8650 'gnus-number number)
8653 (run-hooks 'gnus-summary-update-hook)
8656 (setq gnus-tmp-prev-subject subject)))
8658 (when (nth 1 thread)
8659 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8660 (incf gnus-tmp-level)
8661 (setq threads (if thread-end nil (cdar thread)))
8663 (setq gnus-tmp-level 0)))))
8664 (gnus-message 7 "Generating summary...done"))
8666 (defun gnus-summary-prepare-unthreaded (headers)
8667 "Generate an unthreaded summary buffer based on HEADERS."
8668 (let (header number mark)
8671 ;; We may have to root out some bad articles...
8672 (when (memq (setq number (mail-header-number
8673 (setq header (pop headers))))
8674 gnus-newsgroup-limit)
8675 ;; Mark article as read when it has a low score.
8676 (when (and gnus-summary-mark-below
8677 (< (or (cdr (assq number gnus-newsgroup-scored))
8678 gnus-summary-default-score 0)
8679 gnus-summary-mark-below)
8680 (not (memq number gnus-newsgroup-ancient)))
8681 (setq gnus-newsgroup-unreads
8682 (delq number gnus-newsgroup-unreads))
8683 (if gnus-newsgroup-auto-expire
8684 (push number gnus-newsgroup-expirable)
8685 (push (cons number gnus-low-score-mark)
8686 gnus-newsgroup-reads)))
8690 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8691 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8692 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8693 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8694 (t (or (cdr (assq number gnus-newsgroup-reads))
8695 gnus-ancient-mark))))
8696 (setq gnus-newsgroup-data
8697 (cons (gnus-data-make number mark (1+ (point)) header 0)
8698 gnus-newsgroup-data))
8699 (gnus-summary-insert-line
8700 header 0 nil mark (memq number gnus-newsgroup-replied)
8701 (memq number gnus-newsgroup-expirable)
8702 (mail-header-subject header) nil
8703 (cdr (assq number gnus-newsgroup-scored))
8704 (memq number gnus-newsgroup-processable))))))
8706 (defun gnus-select-newsgroup (group &optional read-all)
8707 "Select newsgroup GROUP.
8708 If READ-ALL is non-nil, all articles in the group are selected."
8709 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8710 (info (nth 2 entry))
8711 articles fetched-articles cached)
8713 (or (gnus-check-server
8714 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8715 (error "Couldn't open server"))
8717 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8718 (gnus-activate-group group) ; Or we can activate it...
8719 (progn ; Or we bug out.
8720 (when (equal major-mode 'gnus-summary-mode)
8721 (kill-buffer (current-buffer)))
8722 (error "Couldn't request group %s: %s"
8723 group (gnus-status-message group))))
8725 (unless (gnus-request-group group t)
8726 (when (equal major-mode 'gnus-summary-mode)
8727 (kill-buffer (current-buffer)))
8728 (error "Couldn't request group %s: %s"
8729 group (gnus-status-message group)))
8731 (setq gnus-newsgroup-name group)
8732 (setq gnus-newsgroup-unselected nil)
8733 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8735 (and gnus-asynchronous
8736 (gnus-check-backend-function
8737 'request-asynchronous gnus-newsgroup-name)
8738 (setq gnus-newsgroup-async
8739 (gnus-request-asynchronous gnus-newsgroup-name)))
8741 ;; Adjust and set lists of article marks.
8743 (gnus-adjust-marked-articles info))
8745 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8746 (when (gnus-virtual-group-p group)
8747 (setq cached gnus-newsgroup-cached))
8749 (setq gnus-newsgroup-unreads
8750 (gnus-set-difference
8751 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8752 gnus-newsgroup-dormant))
8754 (setq gnus-newsgroup-processable nil)
8756 (setq articles (gnus-articles-to-read group read-all))
8760 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8762 ((eq articles 0) nil)
8764 ;; Init the dependencies hash table.
8765 (setq gnus-newsgroup-dependencies
8766 (gnus-make-hashtable (length articles)))
8767 ;; Retrieve the headers and read them in.
8768 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8769 (setq gnus-newsgroup-headers
8771 (setq gnus-headers-retrieved-by
8772 (gnus-retrieve-headers
8773 articles gnus-newsgroup-name
8774 ;; We might want to fetch old headers, but
8775 ;; not if there is only 1 article.
8776 (and gnus-fetch-old-headers
8778 (not (eq gnus-fetch-old-headers 'some))
8779 (not (numberp gnus-fetch-old-headers)))
8780 (> (length articles) 1))))))
8781 (gnus-get-newsgroup-headers-xover articles)
8782 (gnus-get-newsgroup-headers)))
8783 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8785 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8787 (setq gnus-newsgroup-cached cached))
8789 ;; Set the initial limit.
8790 (setq gnus-newsgroup-limit (copy-sequence articles))
8791 ;; Remove canceled articles from the list of unread articles.
8792 (setq gnus-newsgroup-unreads
8793 (gnus-set-sorted-intersection
8794 gnus-newsgroup-unreads
8795 (setq fetched-articles
8796 (mapcar (lambda (headers) (mail-header-number headers))
8797 gnus-newsgroup-headers))))
8798 ;; Removed marked articles that do not exist.
8799 (gnus-update-missing-marks
8800 (gnus-sorted-complement fetched-articles articles))
8801 ;; We might want to build some more threads first.
8802 (and gnus-fetch-old-headers
8803 (eq gnus-headers-retrieved-by 'nov)
8804 (gnus-build-old-threads))
8805 ;; Check whether auto-expire is to be done in this group.
8806 (setq gnus-newsgroup-auto-expire
8807 (gnus-group-auto-expirable-p group))
8808 ;; Set up the article buffer now, if necessary.
8809 (unless gnus-single-article-buffer
8810 (gnus-article-setup-buffer))
8811 ;; First and last article in this newsgroup.
8812 (when gnus-newsgroup-headers
8813 (setq gnus-newsgroup-begin
8814 (mail-header-number (car gnus-newsgroup-headers))
8817 (gnus-last-element gnus-newsgroup-headers))))
8818 (setq gnus-reffed-article-number -1)
8819 ;; GROUP is successfully selected.
8820 (or gnus-newsgroup-headers t)))))
8822 (defun gnus-articles-to-read (group read-all)
8823 ;; Find out what articles the user wants to read.
8825 ;; Select all articles if `read-all' is non-nil, or if there
8826 ;; are no unread articles.
8828 (and (zerop (length gnus-newsgroup-marked))
8829 (zerop (length gnus-newsgroup-unreads))))
8830 (gnus-uncompress-range (gnus-active group))
8831 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8832 (copy-sequence gnus-newsgroup-unreads))
8834 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8835 (scored (length scored-list))
8836 (number (length articles))
8837 (marked (+ (length gnus-newsgroup-marked)
8838 (length gnus-newsgroup-dormant)))
8846 ((and (or (<= scored marked) (= scored number))
8847 (numberp gnus-large-newsgroup)
8848 (> number gnus-large-newsgroup))
8852 "How many articles from %s (default %d): "
8853 gnus-newsgroup-name number))))
8854 (if (string-match "^[ \t]*$" input) number input)))
8855 ((and (> scored marked) (< scored number)
8856 (> (- scored number) 20))
8859 (format "%s %s (%d scored, %d total): "
8860 "How many articles from"
8861 group scored number))))
8862 (if (string-match "^[ \t]*$" input)
8866 (setq select (if (stringp select) (string-to-number select) select))
8867 (if (or (null select) (zerop select))
8869 (if (and (not (zerop scored)) (<= (abs select) scored))
8871 (setq articles (sort scored-list '<))
8872 (setq number (length articles)))
8873 (setq articles (copy-sequence articles)))
8875 (if (< (abs select) number)
8877 ;; Select the N oldest articles.
8878 (setcdr (nthcdr (1- (abs select)) articles) nil)
8879 ;; Select the N most recent articles.
8880 (setq articles (nthcdr (- number select) articles))))
8881 (setq gnus-newsgroup-unselected
8882 (gnus-sorted-intersection
8883 gnus-newsgroup-unreads
8884 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8887 (defun gnus-killed-articles (killed articles)
8890 (if (inline (gnus-member-of-range (car articles) killed))
8891 (setq out (cons (car articles) out)))
8892 (setq articles (cdr articles)))
8895 (defun gnus-uncompress-marks (marks)
8896 "Uncompress the mark ranges in MARKS."
8897 (let ((uncompressed '(score bookmark))
8900 (if (memq (caar marks) uncompressed)
8901 (push (car marks) out)
8902 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8903 (setq marks (cdr marks)))
8906 (defun gnus-adjust-marked-articles (info)
8907 "Set all article lists and remove all marks that are no longer legal."
8908 (let* ((marked-lists (gnus-info-marks info))
8909 (active (gnus-active (gnus-info-group info)))
8912 (types gnus-article-mark-lists)
8913 (uncompressed '(score bookmark))
8914 marks var articles article mark)
8917 (setq marks (pop marked-lists))
8918 (set (setq var (intern (format "gnus-newsgroup-%s"
8919 (car (rassq (setq mark (car marks))
8921 (if (memq (car marks) uncompressed) (cdr marks)
8922 (gnus-uncompress-range (cdr marks))))
8924 (setq articles (symbol-value var))
8926 ;; All articles have to be subsets of the active articles.
8928 ;; Adjust "simple" lists.
8929 ((memq mark '(tick dormant expirable reply killed save))
8931 (when (or (< (setq article (pop articles)) min) (> article max))
8932 (set var (delq article (symbol-value var))))))
8934 ((memq mark '(score bookmark))
8936 (when (or (< (car (setq article (pop articles))) min)
8937 (> (car article) max))
8938 (set var (delq article (symbol-value var))))))))))
8940 (defun gnus-update-missing-marks (missing)
8941 "Go through the list of MISSING articles and remove them mark lists."
8943 (let ((types gnus-article-mark-lists)
8945 ;; Go through all types.
8947 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8948 (when (symbol-value var)
8949 ;; This list has articles. So we delete all missing articles
8953 (set var (delq (pop m) (symbol-value var)))))))))
8955 (defun gnus-update-marks ()
8956 "Enter the various lists of marked articles into the newsgroup info list."
8957 (let ((types gnus-article-mark-lists)
8958 (info (gnus-get-info gnus-newsgroup-name))
8959 (uncompressed '(score bookmark killed))
8960 type list newmarked symbol)
8962 ;; Add all marks lists that are non-nil to the list of marks lists.
8964 (setq type (pop types))
8965 (when (setq list (symbol-value
8967 (intern (format "gnus-newsgroup-%s"
8969 (push (cons (cdr type)
8970 (if (memq (cdr type) uncompressed) list
8971 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8974 ;; Enter these new marks into the info of the group.
8976 (setcar (nthcdr 3 info) newmarked)
8977 ;; Add the marks lists to the end of the info.
8979 (setcdr (nthcdr 2 info) (list newmarked))))
8981 ;; Cut off the end of the info if there's nothing else there.
8985 (when (nthcdr (decf i) info)
8986 (setcdr (nthcdr i info) nil)))))))
8988 (defun gnus-add-marked-articles (group type articles &optional info force)
8989 ;; Add ARTICLES of TYPE to the info of GROUP.
8990 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8991 ;; add, but replace marked articles of TYPE with ARTICLES.
8992 (let ((info (or info (gnus-get-info group)))
8993 (uncompressed '(score bookmark killed))
8996 (and (not (setq marked (nthcdr 3 info)))
8998 (setcdr (nthcdr 2 info)
8999 (list (list (cons type (gnus-compress-sequence
9001 (and (not (setq m (assq type (car marked))))
9004 (cons (cons type (gnus-compress-sequence articles t) )
9008 (setcar (nthcdr 3 info)
9009 (delq (assq type (car marked)) (car marked)))
9010 (setcdr m (gnus-compress-sequence articles t)))
9011 (setcdr m (gnus-compress-sequence
9012 (sort (nconc (gnus-uncompress-range (cdr m))
9013 (copy-sequence articles)) '<) t))))))
9015 (defun gnus-set-mode-line (where)
9016 "This function sets the mode line of the article or summary buffers.
9017 If WHERE is `summary', the summary mode line format will be used."
9018 ;; Is this mode line one we keep updated?
9019 (when (memq where gnus-updated-mode-lines)
9022 ;; We evaluate this in the summary buffer since these
9023 ;; variables are buffer-local to that buffer.
9024 (set-buffer gnus-summary-buffer)
9025 ;; We bind all these variables that are used in the `eval' form
9027 (let* ((mformat (symbol-value
9029 (format "gnus-%s-mode-line-format-spec" where))))
9030 (gnus-tmp-group-name gnus-newsgroup-name)
9031 (gnus-tmp-article-number (or gnus-current-article 0))
9032 (gnus-tmp-unread gnus-newsgroup-unreads)
9033 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9034 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9035 (gnus-tmp-unread-and-unselected
9036 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9037 (zerop gnus-tmp-unselected)) "")
9038 ((zerop gnus-tmp-unselected)
9039 (format "{%d more}" gnus-tmp-unread-and-unticked))
9040 (t (format "{%d(+%d) more}"
9041 gnus-tmp-unread-and-unticked
9042 gnus-tmp-unselected))))
9044 (if (and gnus-current-headers
9045 (vectorp gnus-current-headers))
9046 (gnus-mode-string-quote
9047 (mail-header-subject gnus-current-headers)) ""))
9049 gnus-tmp-header);; passed as argument to any user-format-funcs
9050 (setq mode-string (eval mformat))
9051 (setq max-len (max 4 (if gnus-mode-non-string-length
9053 gnus-mode-non-string-length)
9054 (length mode-string))))
9055 ;; We might have to chop a bit of the string off...
9056 (when (> (length mode-string) max-len)
9058 (concat (gnus-truncate-string mode-string (- max-len 3))
9060 ;; Pad the mode string a bit.
9061 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9062 ;; Update the mode line.
9063 (setq mode-line-buffer-identification (list mode-string))
9064 (set-buffer-modified-p t))))
9066 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9067 "Go through the HEADERS list and add all Xrefs to a hash table.
9068 The resulting hash table is returned, or nil if no Xrefs were found."
9069 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9070 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9071 (xref-hashtb (make-vector 63 0))
9072 start group entry number xrefs header)
9074 (setq header (pop headers))
9075 (when (and (setq xrefs (mail-header-xref header))
9076 (not (memq (setq number (mail-header-number header))
9079 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9080 (setq start (match-end 0))
9081 (setq group (if prefix
9082 (concat prefix (substring xrefs (match-beginning 1)
9084 (substring xrefs (match-beginning 1) (match-end 1))))
9086 (string-to-int (substring xrefs (match-beginning 2)
9088 (if (setq entry (gnus-gethash group xref-hashtb))
9089 (setcdr entry (cons number (cdr entry)))
9090 (gnus-sethash group (cons number nil) xref-hashtb)))))
9091 (and start xref-hashtb)))
9093 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9094 "Look through all the headers and mark the Xrefs as read."
9095 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9096 name entry info xref-hashtb idlist method nth4)
9098 (set-buffer gnus-group-buffer)
9099 (when (setq xref-hashtb
9100 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9103 (unless (string= from-newsgroup (setq name (symbol-name group)))
9104 (setq idlist (symbol-value group))
9105 ;; Dead groups are not updated.
9107 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9109 (if (stringp (setq nth4 (gnus-info-method info)))
9110 (setq nth4 (gnus-server-to-method nth4))))
9111 ;; Only do the xrefs if the group has the same
9112 ;; select method as the group we have just read.
9113 (or (gnus-methods-equal-p
9114 nth4 (gnus-find-method-for-group from-newsgroup))
9116 (equal nth4 (setq method (gnus-find-method-for-group
9118 (and (equal (car nth4) (car method))
9119 (equal (nth 1 nth4) (nth 1 method))))
9120 gnus-use-cross-reference
9121 (or (not (eq gnus-use-cross-reference t))
9123 ;; Only do cross-references on subscribed
9124 ;; groups, if that is what is wanted.
9125 (<= (gnus-info-level info) gnus-level-subscribed))
9126 (gnus-group-make-articles-read name idlist))))
9129 (defun gnus-group-make-articles-read (group articles)
9131 (entry (gnus-gethash group gnus-newsrc-hashtb))
9132 (info (nth 2 entry))
9133 (active (gnus-active group))
9135 ;; First peel off all illegal article numbers.
9137 (let ((ids articles)
9141 (if (and first (> id (cdr active)))
9143 ;; We'll end up in this situation in one particular
9144 ;; obscure situation. If you re-scan a group and get
9145 ;; a new article that is cross-posted to a different
9146 ;; group that has not been re-scanned, you might get
9147 ;; crossposted article that has a higher number than
9148 ;; Gnus believes possible. So we re-activate this
9149 ;; group as well. This might mean doing the
9150 ;; crossposting thingy will *increase* the number
9151 ;; of articles in some groups. Tsk, tsk.
9152 (setq active (or (gnus-activate-group group) active))))
9153 (if (or (> id (cdr active))
9154 (< id (car active)))
9155 (setq articles (delq id articles)))
9156 (setq ids (cdr ids)))))
9157 ;; If the read list is nil, we init it.
9159 (null (gnus-info-read info))
9161 (gnus-info-set-read info (cons 1 (1- (car active)))))
9162 ;; Then we add the read articles to the range.
9167 (gnus-info-read info) (setq articles (sort articles '<)))))
9168 ;; Then we have to re-compute how many unread
9169 ;; articles there are in this group.
9174 (setq num (- (1+ (cdr active)) (car active))))
9175 ((not (listp (cdr range)))
9176 (setq num (- (cdr active) (- (1+ (cdr range))
9180 (if (numberp (car range))
9182 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9183 (setq range (cdr range)))
9184 (setq num (- (cdr active) num))))
9185 ;; Update the number of unread articles.
9187 ;; Update the group buffer.
9188 (gnus-group-update-group group t)))))
9190 (defun gnus-methods-equal-p (m1 m2)
9191 (let ((m1 (or m1 gnus-select-method))
9192 (m2 (or m2 gnus-select-method)))
9194 (and (eq (car m1) (car m2))
9195 (or (not (memq 'address (assoc (symbol-name (car m1))
9196 gnus-valid-select-methods)))
9197 (equal (nth 1 m1) (nth 1 m2)))))))
9199 (defsubst gnus-header-value ()
9202 (if (re-search-forward "^[^ \t]" nil t)
9206 (gnus-point-at-eol))))
9208 (defvar gnus-newsgroup-none-id 0)
9210 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9211 (let ((cur nntp-server-buffer)
9214 (save-excursion (set-buffer gnus-summary-buffer)
9215 gnus-newsgroup-dependencies)))
9216 headers id id-dep ref-dep end ref)
9218 (set-buffer nntp-server-buffer)
9219 (run-hooks 'gnus-parse-headers-hook)
9220 (let ((case-fold-search t)
9221 in-reply-to header p lines)
9222 (goto-char (point-min))
9223 ;; Search to the beginning of the next header. Error messages
9224 ;; do not begin with 2 or 3.
9225 (while (re-search-forward "^[23][0-9]+ " nil t)
9228 ;; This implementation of this function, with nine
9229 ;; search-forwards instead of the one re-search-forward and
9230 ;; a case (which basically was the old function) is actually
9231 ;; about twice as fast, even though it looks messier. You
9232 ;; can't have everything, I guess. Speed and elegance
9233 ;; doesn't always go hand in hand.
9242 (narrow-to-region (point)
9243 (or (and (search-forward "\n.\n" nil t)
9249 (if (search-forward "\nsubject: " nil t)
9250 (gnus-header-value) "(none)"))
9254 (if (search-forward "\nfrom: " nil t)
9255 (gnus-header-value) "(nobody)"))
9259 (if (search-forward "\ndate: " nil t)
9260 (gnus-header-value) ""))
9264 (if (search-forward "\nmessage-id: " nil t)
9265 (setq id (gnus-header-value))
9266 ;; If there was no message-id, we just fake one to make
9267 ;; subsequent routines simpler.
9268 (setq id (concat "none+"
9270 (setq gnus-newsgroup-none-id
9271 (1+ gnus-newsgroup-none-id)))))))
9275 (if (search-forward "\nreferences: " nil t)
9284 (search-backward ">" end t)
9287 (search-backward "<" end t)
9289 ;; Get the references from the in-reply-to header if there
9290 ;; were no references and the in-reply-to header looks
9292 (if (and (search-forward "\nin-reply-to: " nil t)
9293 (setq in-reply-to (gnus-header-value))
9294 (string-match "<[^>]+>" in-reply-to))
9295 (setq ref (substring in-reply-to (match-beginning 0)
9303 (if (search-forward "\nlines: " nil t)
9304 (if (numberp (setq lines (read cur)))
9310 (and (search-forward "\nxref: " nil t)
9311 (gnus-header-value)))))
9312 ;; We do the threading while we read the headers. The
9313 ;; message-id and the last reference are both entered into
9314 ;; the same hash table. Some tippy-toeing around has to be
9315 ;; done in case an article has arrived before the article
9316 ;; which it refers to.
9317 (if (boundp (setq id-dep (intern id dependencies)))
9318 (if (and (car (symbol-value id-dep))
9320 ;; An article with this Message-ID has already
9321 ;; been seen, so we ignore this one, except we add
9322 ;; any additional Xrefs (in case the two articles
9323 ;; came from different servers).
9325 (mail-header-set-xref
9326 (car (symbol-value id-dep))
9327 (concat (or (mail-header-xref
9328 (car (symbol-value id-dep))) "")
9329 (or (mail-header-xref header) "")))
9331 (setcar (symbol-value id-dep) header))
9332 (set id-dep (list header)))
9334 (if (boundp (setq ref-dep (intern ref dependencies)))
9335 (setcdr (symbol-value ref-dep)
9336 (nconc (cdr (symbol-value ref-dep))
9337 (list (symbol-value id-dep))))
9338 (set ref-dep (list nil (symbol-value id-dep))))
9339 (setq headers (cons header headers)))
9340 (goto-char (point-max))
9342 (nreverse headers)))))
9344 ;; The following macros and functions were written by Felix Lee
9345 ;; <flee@cse.psu.edu>.
9347 (defmacro gnus-nov-read-integer ()
9349 (if (= (following-char) ?\t)
9351 (let ((num (condition-case nil (read buffer) (error nil))))
9352 (if (numberp num) num 0)))
9353 (or (eobp) (forward-char 1))))
9355 (defmacro gnus-nov-skip-field ()
9356 '(search-forward "\t" eol 'move))
9358 (defmacro gnus-nov-field ()
9359 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9361 ;; Goes through the xover lines and returns a list of vectors
9362 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9363 force-new dependencies)
9364 "Parse the news overview data in the server buffer, and return a
9365 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9366 ;; Get the Xref when the users reads the articles since most/some
9367 ;; NNTP servers do not include Xrefs when using XOVER.
9368 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9369 (let ((cur nntp-server-buffer)
9370 (dependencies (or dependencies gnus-newsgroup-dependencies))
9371 number headers header)
9373 (set-buffer nntp-server-buffer)
9374 ;; Allow the user to mangle the headers before parsing them.
9375 (run-hooks 'gnus-parse-headers-hook)
9376 (goto-char (point-min))
9377 (while (and sequence (not (eobp)))
9378 (setq number (read cur))
9379 (while (and sequence (< (car sequence) number))
9380 (setq sequence (cdr sequence)))
9382 (eq number (car sequence))
9384 (setq sequence (cdr sequence))
9386 (inline (gnus-nov-parse-line
9387 number dependencies force-new)))
9388 (setq headers (cons header headers)))))
9390 (setq headers (nreverse headers)))
9393 ;; This function has to be called with point after the article number
9394 ;; on the beginning of the line.
9395 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9397 (eol (gnus-point-at-eol))
9398 (buffer (current-buffer))
9399 header ref id id-dep ref-dep)
9401 ;; overview: [num subject from date id refs chars lines misc]
9402 (narrow-to-region (point) eol)
9403 (or (eobp) (forward-char))
9409 (gnus-nov-field) ; subject
9410 (gnus-nov-field) ; from
9411 (gnus-nov-field) ; date
9412 (setq id (or (gnus-nov-field)
9415 (setq none (1+ none)))))) ; id
9418 (let ((beg (point)))
9419 (search-forward "\t" eol)
9420 (if (search-backward ">" beg t)
9424 (search-backward "<" beg t)))
9426 (gnus-nov-field)) ; refs
9427 (gnus-nov-read-integer) ; chars
9428 (gnus-nov-read-integer) ; lines
9429 (if (= (following-char) ?\n)
9431 (gnus-nov-field)) ; misc
9434 (gnus-error 4 "Strange nov line")
9440 ;; We build the thread tree.
9442 (if (boundp (setq id-dep (intern id dependencies)))
9443 (if (and (car (symbol-value id-dep))
9445 ;; An article with this Message-ID has already been seen,
9446 ;; so we ignore this one, except we add any additional
9447 ;; Xrefs (in case the two articles came from different
9450 (mail-header-set-xref
9451 (car (symbol-value id-dep))
9452 (concat (or (mail-header-xref
9453 (car (symbol-value id-dep))) "")
9454 (or (mail-header-xref header) "")))
9456 (setcar (symbol-value id-dep) header))
9457 (set id-dep (list header))))
9459 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9460 (setcdr (symbol-value ref-dep)
9461 (nconc (cdr (symbol-value ref-dep))
9462 (list (symbol-value id-dep))))
9463 (set ref-dep (list nil (symbol-value id-dep)))))
9466 (defun gnus-article-get-xrefs ()
9467 "Fill in the Xref value in `gnus-current-headers', if necessary.
9468 This is meant to be called in `gnus-article-internal-prepare-hook'."
9469 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9470 gnus-current-headers)))
9471 (or (not gnus-use-cross-reference)
9473 (and (mail-header-xref headers)
9474 (not (string= (mail-header-xref headers) "")))
9475 (let ((case-fold-search t)
9478 (nnheader-narrow-to-headers)
9479 (goto-char (point-min))
9480 (if (or (and (eq (downcase (following-char)) ?x)
9481 (looking-at "Xref:"))
9482 (search-forward "\nXref:" nil t))
9484 (goto-char (1+ (match-end 0)))
9485 (setq xref (buffer-substring (point)
9486 (progn (end-of-line) (point))))
9487 (mail-header-set-xref headers xref))))))))
9489 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9490 "Find article ID and insert the summary line for that article."
9491 (let ((header (if (and old-header use-old-header)
9492 old-header (gnus-read-header id)))
9493 (number (and (numberp id) id))
9496 ;; Rebuild the thread that this article is part of and go to the
9497 ;; article we have fetched.
9498 (when (and (not gnus-show-threads)
9500 (when (setq pos (text-property-any
9501 (point-min) (point-max) 'gnus-number
9502 (mail-header-number old-header)))
9505 (gnus-data-remove (mail-header-number old-header))))
9507 (mail-header-set-number header (mail-header-number old-header)))
9508 (setq gnus-newsgroup-sparse
9509 (delq (setq number (mail-header-number header))
9510 gnus-newsgroup-sparse))
9511 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9512 (gnus-rebuild-thread (mail-header-id header))
9513 (gnus-summary-goto-subject number nil t))
9514 (when (and (numberp number)
9516 ;; We have to update the boundaries even if we can't fetch the
9517 ;; article if ID is a number -- so that the next `P' or `N'
9518 ;; command will fetch the previous (or next) article even
9519 ;; if the one we tried to fetch this time has been canceled.
9520 (and (> number gnus-newsgroup-end)
9521 (setq gnus-newsgroup-end number))
9522 (and (< number gnus-newsgroup-begin)
9523 (setq gnus-newsgroup-begin number))
9524 (setq gnus-newsgroup-unselected
9525 (delq number gnus-newsgroup-unselected)))
9526 ;; Report back a success?
9527 (and header (mail-header-number header))))
9529 (defun gnus-summary-work-articles (n)
9530 "Return a list of articles to be worked upon. The prefix argument,
9531 the list of process marked articles, and the current article will be
9532 taken into consideration."
9534 ((and n (numberp n))
9535 ;; A numerical prefix has been given.
9536 (let ((backward (< n 0))
9542 (push (setq article (gnus-summary-article-number))
9545 (gnus-summary-find-prev nil article)
9546 (gnus-summary-find-next nil article)))
9548 (nreverse articles)))
9549 ((and (boundp 'transient-mark-mode)
9552 ;; Work on the region between point and mark.
9553 (let ((max (max (point) (mark)))
9556 (goto-char (min (point) (mark)))
9559 (push (setq article (gnus-summary-article-number)) articles)
9560 (gnus-summary-find-next nil article)
9562 (nreverse articles))))
9563 (gnus-newsgroup-processable
9564 ;; There are process-marked articles present.
9565 (reverse gnus-newsgroup-processable))
9567 ;; Just return the current article.
9568 (list (gnus-summary-article-number)))))
9570 (defun gnus-summary-search-group (&optional backward use-level)
9571 "Search for next unread newsgroup.
9572 If optional argument BACKWARD is non-nil, search backward instead."
9574 (set-buffer gnus-group-buffer)
9575 (if (gnus-group-search-forward
9576 backward nil (if use-level (gnus-group-group-level) nil))
9577 (gnus-group-group-name))))
9579 (defun gnus-summary-best-group (&optional exclude-group)
9580 "Find the name of the best unread group.
9581 If EXCLUDE-GROUP, do not go to this group."
9583 (set-buffer gnus-group-buffer)
9585 (gnus-group-best-unread-group exclude-group))))
9587 (defun gnus-summary-find-next (&optional unread article backward)
9588 (if backward (gnus-summary-find-prev)
9589 (let* ((dummy (gnus-summary-article-intangible-p))
9590 (article (or article (gnus-summary-article-number)))
9591 (arts (gnus-data-find-list article))
9593 (when (and (not dummy)
9594 (or (not gnus-summary-check-current)
9596 (not (gnus-data-unread-p (car arts)))))
9597 (setq arts (cdr arts)))
9602 (when (gnus-data-unread-p (car arts))
9603 (setq result (car arts)
9605 (setq arts (cdr arts)))
9608 (goto-char (gnus-data-pos result))
9609 (gnus-data-number result)))))
9611 (defun gnus-summary-find-prev (&optional unread article)
9612 (let* ((eobp (eobp))
9613 (article (or article (gnus-summary-article-number)))
9614 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9616 (when (and (not eobp)
9617 (or (not gnus-summary-check-current)
9619 (not (gnus-data-unread-p (car arts)))))
9620 (setq arts (cdr arts)))
9625 (and (gnus-data-unread-p (car arts))
9626 (setq result (car arts)
9628 (setq arts (cdr arts)))
9632 (goto-char (gnus-data-pos result))
9633 (gnus-data-number result)))))
9635 (defun gnus-summary-find-subject (subject &optional unread backward article)
9636 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9637 (article (or article (gnus-summary-article-number)))
9638 (articles (gnus-data-list backward))
9639 (arts (gnus-data-find-list article articles))
9641 (when (or (not gnus-summary-check-current)
9643 (not (gnus-data-unread-p (car arts))))
9644 (setq arts (cdr arts)))
9646 (and (or (not unread)
9647 (gnus-data-unread-p (car arts)))
9648 (vectorp (gnus-data-header (car arts)))
9650 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9651 (setq result (car arts)
9653 (setq arts (cdr arts)))
9655 (goto-char (gnus-data-pos result))
9656 (gnus-data-number result))))
9658 (defun gnus-summary-search-forward (&optional unread subject backward)
9659 "Search forward for an article.
9660 If UNREAD, look for unread articles. If SUBJECT, look for
9661 articles with that subject. If BACKWARD, search backward instead."
9662 (cond (subject (gnus-summary-find-subject subject unread backward))
9663 (backward (gnus-summary-find-prev unread))
9664 (t (gnus-summary-find-next unread))))
9666 (defun gnus-recenter (&optional n)
9667 "Center point in window and redisplay frame.
9668 Also do horizontal recentering."
9670 (when (and gnus-auto-center-summary
9671 (not (eq gnus-auto-center-summary 'vertical)))
9672 (gnus-horizontal-recenter))
9675 (defun gnus-summary-recenter ()
9676 "Center point in the summary window.
9677 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9678 displayed, no centering will be performed."
9679 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9680 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9681 (let* ((top (cond ((< (window-height) 4) 0)
9682 ((< (window-height) 7) 1)
9684 (height (1- (window-height)))
9685 (bottom (save-excursion (goto-char (point-max))
9686 (forward-line (- height))
9688 (window (get-buffer-window (current-buffer))))
9689 ;; The user has to want it.
9690 (when gnus-auto-center-summary
9691 (when (get-buffer-window gnus-article-buffer)
9692 ;; Only do recentering when the article buffer is displayed,
9693 ;; Set the window start to either `bottom', which is the biggest
9694 ;; possible valid number, or the second line from the top,
9695 ;; whichever is the least.
9697 window (min bottom (save-excursion
9698 (forward-line (- top)) (point)))))
9699 ;; Do horizontal recentering while we're at it.
9700 (when (and (get-buffer-window (current-buffer) t)
9701 (not (eq gnus-auto-center-summary 'vertical)))
9702 (let ((selected (selected-window)))
9703 (select-window (get-buffer-window (current-buffer) t))
9704 (gnus-summary-position-point)
9705 (gnus-horizontal-recenter)
9706 (select-window selected))))))
9708 (defun gnus-horizontal-recenter ()
9709 "Recenter the current buffer horizontally."
9710 (if (< (current-column) (/ (window-width) 2))
9711 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9712 (let* ((orig (point))
9713 (end (window-end (get-buffer-window (current-buffer) t)))
9715 ;; Find the longest line currently displayed in the window.
9716 (goto-char (window-start))
9717 (while (and (not (eobp))
9720 (setq max (max max (current-column)))
9723 ;; Scroll horizontally to center (sort of) the point.
9724 (if (> max (window-width))
9726 (get-buffer-window (current-buffer) t)
9727 (min (- (current-column) (/ (window-width) 3))
9728 (+ 2 (- max (window-width)))))
9729 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9732 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9733 (defun gnus-short-group-name (group &optional levels)
9734 "Collapse GROUP name LEVELS."
9741 (while (string-match "\\." group skip)
9742 (setq skip (match-end 0)
9745 (if (string-match ":" group)
9746 (setq foreign (substring group 0 (match-end 0))
9747 group (substring group (match-end 0))))
9749 (if (and (string-match "\\." group)
9750 (> levels (- gnus-group-uncollapsed-levels 1)))
9751 (setq name (concat name (substring group 0 1))
9752 group (substring group (match-end 0))
9754 name (concat name "."))
9755 (setq name (concat foreign name group)
9759 (defun gnus-summary-jump-to-group (newsgroup)
9760 "Move point to NEWSGROUP in group mode buffer."
9761 ;; Keep update point of group mode buffer if visible.
9762 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9763 (save-window-excursion
9764 ;; Take care of tree window mode.
9765 (if (get-buffer-window gnus-group-buffer)
9766 (pop-to-buffer gnus-group-buffer))
9767 (gnus-group-jump-to-group newsgroup))
9769 ;; Take care of tree window mode.
9770 (if (get-buffer-window gnus-group-buffer)
9771 (pop-to-buffer gnus-group-buffer)
9772 (set-buffer gnus-group-buffer))
9773 (gnus-group-jump-to-group newsgroup))))
9775 ;; This function returns a list of article numbers based on the
9776 ;; difference between the ranges of read articles in this group and
9777 ;; the range of active articles.
9778 (defun gnus-list-of-unread-articles (group)
9779 (let* ((read (gnus-info-read (gnus-get-info group)))
9780 (active (gnus-active group))
9783 ;; If none are read, then all are unread.
9785 (setq first (car active))
9786 ;; If the range of read articles is a single range, then the
9787 ;; first unread article is the article after the last read
9788 ;; article. Sounds logical, doesn't it?
9789 (if (not (listp (cdr read)))
9790 (setq first (1+ (cdr read)))
9791 ;; `read' is a list of ranges.
9792 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9797 (while (< first nlast)
9798 (setq unread (cons first unread))
9799 (setq first (1+ first))))
9800 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9801 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9802 (setq read (cdr read)))))
9803 ;; And add the last unread articles.
9804 (while (<= first last)
9805 (setq unread (cons first unread))
9806 (setq first (1+ first)))
9807 ;; Return the list of unread articles.
9810 (defun gnus-list-of-read-articles (group)
9811 "Return a list of unread, unticked and non-dormant articles."
9812 (let* ((info (gnus-get-info group))
9813 (marked (gnus-info-marks info))
9814 (active (gnus-active group)))
9816 (gnus-set-difference
9817 (gnus-sorted-complement
9818 (gnus-uncompress-range active)
9819 (gnus-list-of-unread-articles group))
9821 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9822 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9824 ;; Various summary commands
9826 (defun gnus-summary-universal-argument (arg)
9827 "Perform any operation on all articles that are process/prefixed."
9829 (gnus-set-global-variables)
9830 (let ((articles (gnus-summary-work-articles arg))
9837 (substitute-command-keys
9838 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9841 (gnus-error 1 "Undefined key")
9844 (gnus-summary-goto-subject (setq article (pop articles)))
9845 (command-execute func)
9846 (gnus-summary-remove-process-mark article)))))
9847 (gnus-summary-position-point))
9849 (defun gnus-summary-toggle-truncation (&optional arg)
9850 "Toggle truncation of summary lines.
9851 With arg, turn line truncation on iff arg is positive."
9853 (setq truncate-lines
9854 (if (null arg) (not truncate-lines)
9855 (> (prefix-numeric-value arg) 0)))
9858 (defun gnus-summary-reselect-current-group (&optional all rescan)
9859 "Exit and then reselect the current newsgroup.
9860 The prefix argument ALL means to select all articles."
9862 (gnus-set-global-variables)
9863 (let ((current-subject (gnus-summary-article-number))
9864 (group gnus-newsgroup-name))
9865 (setq gnus-newsgroup-begin nil)
9867 ;; We have to adjust the point of group mode buffer because the
9868 ;; current point was moved to the next unread newsgroup by
9870 (gnus-summary-jump-to-group group)
9873 (gnus-group-get-new-news-this-group 1)))
9874 (gnus-group-read-group all t)
9875 (gnus-summary-goto-subject current-subject)))
9877 (defun gnus-summary-rescan-group (&optional all)
9878 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9880 (gnus-summary-reselect-current-group all t))
9882 (defun gnus-summary-update-info ()
9883 (let* ((group gnus-newsgroup-name))
9884 (when gnus-newsgroup-kill-headers
9885 (setq gnus-newsgroup-killed
9886 (gnus-compress-sequence
9888 (gnus-set-sorted-intersection
9889 (gnus-uncompress-range gnus-newsgroup-killed)
9890 (setq gnus-newsgroup-unselected
9891 (sort gnus-newsgroup-unselected '<)))
9892 (setq gnus-newsgroup-unreads
9893 (sort gnus-newsgroup-unreads '<))) t)))
9894 (unless (listp (cdr gnus-newsgroup-killed))
9895 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9896 (let ((headers gnus-newsgroup-headers))
9897 (run-hooks 'gnus-exit-group-hook)
9898 (unless gnus-save-score
9899 (setq gnus-newsgroup-scored nil))
9900 ;; Set the new ranges of read articles.
9901 (gnus-update-read-articles
9902 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9903 ;; Set the current article marks.
9905 ;; Do the cross-ref thing.
9906 (when gnus-use-cross-reference
9907 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9908 ;; Do adaptive scoring, and possibly save score files.
9909 (when gnus-newsgroup-adaptive
9910 (gnus-score-adaptive))
9911 (when gnus-use-scoring
9913 ;; Do not switch windows but change the buffer to work.
9914 (set-buffer gnus-group-buffer)
9915 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9916 (gnus-group-update-group group)))))
9918 (defun gnus-summary-exit (&optional temporary)
9919 "Exit reading current newsgroup, and then return to group selection mode.
9920 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9922 (gnus-set-global-variables)
9923 (gnus-kill-save-kill-buffer)
9924 (let* ((group gnus-newsgroup-name)
9925 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9927 (buf (current-buffer)))
9928 (run-hooks 'gnus-summary-prepare-exit-hook)
9929 ;; If we have several article buffers, we kill them at exit.
9930 (unless gnus-single-article-buffer
9931 (gnus-kill-buffer gnus-original-article-buffer)
9932 (setq gnus-article-current nil))
9933 (when gnus-use-cache
9934 (gnus-cache-possibly-remove-articles)
9935 (gnus-cache-save-buffers))
9936 (when gnus-use-trees
9937 (gnus-tree-close group))
9938 ;; Make all changes in this group permanent.
9940 (gnus-summary-update-info))
9941 (gnus-close-group group)
9942 ;; Make sure where I was, and go to next newsgroup.
9943 (set-buffer gnus-group-buffer)
9945 (gnus-group-jump-to-group group))
9946 (run-hooks 'gnus-summary-exit-hook)
9948 (gnus-group-next-unread-group 1))
9951 ;; If we have several article buffers, we kill them at exit.
9952 (unless gnus-single-article-buffer
9953 (gnus-kill-buffer gnus-article-buffer)
9954 (gnus-kill-buffer gnus-original-article-buffer)
9955 (setq gnus-article-current nil))
9957 (if (not gnus-kill-summary-on-exit)
9958 (gnus-deaden-summary)
9959 ;; We set all buffer-local variables to nil. It is unclear why
9960 ;; this is needed, but if we don't, buffer-local variables are
9961 ;; not garbage-collected, it seems. This would the lead to en
9962 ;; ever-growing Emacs.
9963 (gnus-summary-clear-local-variables)
9964 (when (get-buffer gnus-article-buffer)
9965 (bury-buffer gnus-article-buffer))
9966 ;; We clear the global counterparts of the buffer-local
9967 ;; variables as well, just to be on the safe side.
9968 (gnus-configure-windows 'group 'force)
9969 (gnus-summary-clear-local-variables)
9970 ;; Return to group mode buffer.
9971 (if (eq mode 'gnus-summary-mode)
9972 (gnus-kill-buffer buf)))
9973 (setq gnus-current-select-method gnus-select-method)
9974 (pop-to-buffer gnus-group-buffer)
9975 ;; Clear the current group name.
9976 (if (not quit-config)
9978 (gnus-group-jump-to-group group)
9979 (gnus-group-next-unread-group 1)
9980 (gnus-configure-windows 'group 'force))
9981 (if (not (buffer-name (car quit-config)))
9982 (gnus-configure-windows 'group 'force)
9983 (set-buffer (car quit-config))
9984 (and (eq major-mode 'gnus-summary-mode)
9985 (gnus-set-global-variables))
9986 (gnus-configure-windows (cdr quit-config))))
9988 (setq gnus-newsgroup-name nil)))))
9990 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9991 (defun gnus-summary-exit-no-update (&optional no-questions)
9992 "Quit reading current newsgroup without updating read article info."
9994 (gnus-set-global-variables)
9995 (let* ((group gnus-newsgroup-name)
9996 (quit-config (gnus-group-quit-config group)))
9997 (when (or no-questions
9999 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10000 ;; If we have several article buffers, we kill them at exit.
10001 (unless gnus-single-article-buffer
10002 (gnus-kill-buffer gnus-article-buffer)
10003 (gnus-kill-buffer gnus-original-article-buffer)
10004 (setq gnus-article-current nil))
10005 (if (not gnus-kill-summary-on-exit)
10006 (gnus-deaden-summary)
10007 (gnus-close-group group)
10008 (gnus-summary-clear-local-variables)
10009 (set-buffer gnus-group-buffer)
10010 (gnus-summary-clear-local-variables)
10011 (when (get-buffer gnus-summary-buffer)
10012 (kill-buffer gnus-summary-buffer)))
10013 (unless gnus-single-article-buffer
10014 (setq gnus-article-current nil))
10015 (when gnus-use-trees
10016 (gnus-tree-close group))
10017 (when (get-buffer gnus-article-buffer)
10018 (bury-buffer gnus-article-buffer))
10019 ;; Return to the group buffer.
10020 (gnus-configure-windows 'group 'force)
10021 ;; Clear the current group name.
10022 (setq gnus-newsgroup-name nil)
10023 (when (equal (gnus-group-group-name) group)
10024 (gnus-group-next-unread-group 1))
10026 (if (not (buffer-name (car quit-config)))
10027 (gnus-configure-windows 'group 'force)
10028 (set-buffer (car quit-config))
10029 (when (eq major-mode 'gnus-summary-mode)
10030 (gnus-set-global-variables))
10031 (gnus-configure-windows (cdr quit-config)))))))
10033 ;;; Dead summaries.
10035 (defvar gnus-dead-summary-mode-map nil)
10037 (if gnus-dead-summary-mode-map
10039 (setq gnus-dead-summary-mode-map (make-keymap))
10040 (suppress-keymap gnus-dead-summary-mode-map)
10041 (substitute-key-definition
10042 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10043 (let ((keys '("\C-d" "\r" "\177")))
10045 (define-key gnus-dead-summary-mode-map
10046 (pop keys) 'gnus-summary-wake-up-the-dead))))
10048 (defvar gnus-dead-summary-mode nil
10049 "Minor mode for Gnus summary buffers.")
10051 (defun gnus-dead-summary-mode (&optional arg)
10052 "Minor mode for Gnus summary buffers."
10054 (when (eq major-mode 'gnus-summary-mode)
10055 (make-local-variable 'gnus-dead-summary-mode)
10056 (setq gnus-dead-summary-mode
10057 (if (null arg) (not gnus-dead-summary-mode)
10058 (> (prefix-numeric-value arg) 0)))
10059 (when gnus-dead-summary-mode
10060 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10061 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10062 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10063 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10064 minor-mode-map-alist)))))
10066 (defun gnus-deaden-summary ()
10067 "Make the current summary buffer into a dead summary buffer."
10068 ;; Kill any previous dead summary buffer.
10069 (when (and gnus-dead-summary
10070 (buffer-name gnus-dead-summary))
10072 (set-buffer gnus-dead-summary)
10073 (when gnus-dead-summary-mode
10074 (kill-buffer (current-buffer)))))
10075 ;; Make this the current dead summary.
10076 (setq gnus-dead-summary (current-buffer))
10077 (gnus-dead-summary-mode 1)
10078 (let ((name (buffer-name)))
10079 (when (string-match "Summary" name)
10081 (concat (substring name 0 (match-beginning 0)) "Dead "
10082 (substring name (match-beginning 0))) t))))
10084 (defun gnus-kill-or-deaden-summary (buffer)
10085 "Kill or deaden the summary BUFFER."
10086 (when (and (buffer-name buffer)
10087 (not gnus-single-article-buffer))
10089 (set-buffer buffer)
10090 (gnus-kill-buffer gnus-article-buffer)
10091 (gnus-kill-buffer gnus-original-article-buffer)))
10092 (cond (gnus-kill-summary-on-exit
10093 (when (and gnus-use-trees
10094 (and (get-buffer buffer)
10095 (buffer-name (get-buffer buffer))))
10097 (set-buffer (get-buffer buffer))
10098 (gnus-tree-close gnus-newsgroup-name)))
10099 (gnus-kill-buffer buffer))
10100 ((and (get-buffer buffer)
10101 (buffer-name (get-buffer buffer)))
10103 (set-buffer buffer)
10104 (gnus-deaden-summary)))))
10106 (defun gnus-summary-wake-up-the-dead (&rest args)
10107 "Wake up the dead summary buffer."
10109 (gnus-dead-summary-mode -1)
10110 (let ((name (buffer-name)))
10111 (when (string-match "Dead " name)
10113 (concat (substring name 0 (match-beginning 0))
10114 (substring name (match-end 0))) t)))
10115 (gnus-message 3 "This dead summary is now alive again"))
10117 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10118 (defun gnus-summary-fetch-faq (&optional faq-dir)
10119 "Fetch the FAQ for the current group.
10120 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10124 (if current-prefix-arg
10126 "Faq dir: " (and (listp gnus-group-faq-directory)
10127 gnus-group-faq-directory)))))
10128 (let (gnus-faq-buffer)
10129 (and (setq gnus-faq-buffer
10130 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10131 (gnus-configure-windows 'summary-faq))))
10133 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10134 (defun gnus-summary-describe-group (&optional force)
10135 "Describe the current newsgroup."
10137 (gnus-group-describe-group force gnus-newsgroup-name))
10139 (defun gnus-summary-describe-briefly ()
10140 "Describe summary mode commands briefly."
10143 (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")))
10145 ;; Walking around group mode buffer from summary mode.
10147 (defun gnus-summary-next-group (&optional no-article target-group backward)
10148 "Exit current newsgroup and then select next unread newsgroup.
10149 If prefix argument NO-ARTICLE is non-nil, no article is selected
10150 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10151 previous group instead."
10153 (gnus-set-global-variables)
10154 (let ((current-group gnus-newsgroup-name)
10155 (current-buffer (current-buffer))
10157 ;; First we semi-exit this group to update Xrefs and all variables.
10158 ;; We can't do a real exit, because the window conf must remain
10159 ;; the same in case the user is prompted for info, and we don't
10160 ;; want the window conf to change before that...
10161 (gnus-summary-exit t)
10162 (while (not entered)
10163 ;; Then we find what group we are supposed to enter.
10164 (set-buffer gnus-group-buffer)
10165 (gnus-group-jump-to-group current-group)
10168 (if (eq gnus-keep-same-level 'best)
10169 (gnus-summary-best-group gnus-newsgroup-name)
10170 (gnus-summary-search-group backward gnus-keep-same-level))))
10171 (if (not target-group)
10172 ;; There are no further groups, so we return to the group
10175 (gnus-message 5 "Returning to the group buffer")
10177 (set-buffer current-buffer)
10178 (gnus-summary-exit))
10179 ;; We try to enter the target group.
10180 (gnus-group-jump-to-group target-group)
10181 (let ((unreads (gnus-group-group-unread)))
10182 (if (and (or (eq t unreads)
10183 (and unreads (not (zerop unreads))))
10184 (gnus-summary-read-group
10185 target-group nil no-article current-buffer))
10187 (setq current-group target-group
10188 target-group nil)))))))
10190 (defun gnus-summary-prev-group (&optional no-article)
10191 "Exit current newsgroup and then select previous unread newsgroup.
10192 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10194 (gnus-summary-next-group no-article nil t))
10196 ;; Walking around summary lines.
10198 (defun gnus-summary-first-subject (&optional unread)
10199 "Go to the first unread subject.
10200 If UNREAD is non-nil, go to the first unread article.
10201 Returns the article selected or nil if there are no unread articles."
10206 ((null gnus-newsgroup-data)
10207 (gnus-message 3 "No articles in the group")
10209 ;; Pick the first article.
10211 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10212 (gnus-data-number (car gnus-newsgroup-data)))
10213 ;; No unread articles.
10214 ((null gnus-newsgroup-unreads)
10215 (gnus-message 3 "No more unread articles")
10217 ;; Find the first unread article.
10219 (let ((data gnus-newsgroup-data))
10221 (not (gnus-data-unread-p (car data))))
10222 (setq data (cdr data)))
10225 (goto-char (gnus-data-pos (car data)))
10226 (gnus-data-number (car data)))))))
10227 (gnus-summary-position-point)))
10229 (defun gnus-summary-next-subject (n &optional unread dont-display)
10230 "Go to next N'th summary line.
10231 If N is negative, go to the previous N'th subject line.
10232 If UNREAD is non-nil, only unread articles are selected.
10233 The difference between N and the actual number of steps taken is
10236 (let ((backward (< n 0))
10238 (while (and (> n 0)
10240 (gnus-summary-find-prev unread)
10241 (gnus-summary-find-next unread)))
10243 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10244 (if unread " unread" "")))
10245 (unless dont-display
10246 (gnus-summary-recenter)
10247 (gnus-summary-position-point))
10250 (defun gnus-summary-next-unread-subject (n)
10251 "Go to next N'th unread summary line."
10253 (gnus-summary-next-subject n t))
10255 (defun gnus-summary-prev-subject (n &optional unread)
10256 "Go to previous N'th summary line.
10257 If optional argument UNREAD is non-nil, only unread article is selected."
10259 (gnus-summary-next-subject (- n) unread))
10261 (defun gnus-summary-prev-unread-subject (n)
10262 "Go to previous N'th unread summary line."
10264 (gnus-summary-next-subject (- n) t))
10266 (defun gnus-summary-goto-subject (article &optional force silent)
10267 "Go the subject line of ARTICLE.
10268 If FORCE, also allow jumping to articles not currently shown."
10270 (data (gnus-data-find article)))
10271 ;; We read in the article if we have to.
10274 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10275 (setq data (gnus-data-find article)))
10280 (gnus-message 3 "Can't find article %d" article))
10282 (goto-char (gnus-data-pos data))
10285 ;; Walking around summary lines with displaying articles.
10287 (defun gnus-summary-expand-window (&optional arg)
10288 "Make the summary buffer take up the entire Emacs frame.
10289 Given a prefix, will force an `article' buffer configuration."
10291 (gnus-set-global-variables)
10293 (gnus-configure-windows 'article 'force)
10294 (gnus-configure-windows 'summary 'force)))
10296 (defun gnus-summary-display-article (article &optional all-header)
10297 "Display ARTICLE in article buffer."
10298 (gnus-set-global-variables)
10302 (if gnus-summary-display-article-function
10303 (funcall gnus-summary-display-article-function article all-header)
10304 (gnus-article-prepare article all-header))
10305 (run-hooks 'gnus-select-article-hook)
10306 (unless (zerop gnus-current-article)
10307 (gnus-summary-goto-subject gnus-current-article))
10308 (gnus-summary-recenter)
10309 (when gnus-use-trees
10310 (gnus-possibly-generate-tree article)
10311 (gnus-highlight-selected-tree article))
10312 ;; Successfully display article.
10313 (gnus-article-set-window-start
10314 (cdr (assq article gnus-newsgroup-bookmarks))))))
10316 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10317 "Select the current article.
10318 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10319 non-nil, the article will be re-fetched even if it already present in
10320 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10322 ;; Make sure we are in the summary buffer to work around bbdb bug.
10323 (unless (eq major-mode 'gnus-summary-mode)
10324 (set-buffer gnus-summary-buffer))
10325 (let ((article (or article (gnus-summary-article-number)))
10326 (all-headers (not (not all-headers))) ;Must be T or NIL.
10327 gnus-summary-display-article-function
10330 (gnus-summary-article-pseudo-p article)
10331 (error "This is a pseudo-article."))
10334 (set-buffer gnus-summary-buffer)
10335 (if (or (and gnus-single-article-buffer
10336 (or (null gnus-current-article)
10337 (null gnus-article-current)
10338 (null (get-buffer gnus-article-buffer))
10339 (not (eq article (cdr gnus-article-current)))
10340 (not (equal (car gnus-article-current)
10341 gnus-newsgroup-name))))
10342 (and (not gnus-single-article-buffer)
10343 (or (null gnus-current-article)
10344 (not (eq gnus-current-article article))))
10346 ;; The requested article is different from the current article.
10348 (gnus-summary-display-article article all-headers)
10349 (setq did article))
10350 (if (or all-headers gnus-show-all-headers)
10351 (gnus-article-show-all-headers))
10354 (gnus-article-set-window-start
10355 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10357 (defun gnus-summary-set-current-mark (&optional current-mark)
10358 "Obsolete function."
10361 (defun gnus-summary-next-article (&optional unread subject backward push)
10362 "Select the next article.
10363 If UNREAD, only unread articles are selected.
10364 If SUBJECT, only articles with SUBJECT are selected.
10365 If BACKWARD, the previous article is selected instead of the next."
10367 (gnus-set-global-variables)
10369 ;; Is there such an article?
10370 ((and (gnus-summary-search-forward unread subject backward)
10371 (or (gnus-summary-display-article (gnus-summary-article-number))
10372 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10373 (gnus-summary-position-point))
10374 ;; If not, we try the first unread, if that is wanted.
10376 gnus-auto-select-same
10377 (or (gnus-summary-first-unread-article)
10378 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10379 (gnus-summary-position-point)
10380 (gnus-message 6 "Wrapped"))
10381 ;; Try to get next/previous article not displayed in this group.
10382 ((and gnus-auto-extend-newsgroup
10383 (not unread) (not subject))
10384 (gnus-summary-goto-article
10385 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10387 ;; Go to next/previous group.
10389 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10390 (gnus-summary-jump-to-group gnus-newsgroup-name))
10391 (let ((cmd last-command-char)
10393 (if (eq gnus-keep-same-level 'best)
10394 (gnus-summary-best-group gnus-newsgroup-name)
10395 (gnus-summary-search-group backward gnus-keep-same-level))))
10396 ;; For some reason, the group window gets selected. We change
10398 (select-window (get-buffer-window (current-buffer)))
10399 ;; Select next unread newsgroup automagically.
10401 ((not gnus-auto-select-next)
10402 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10403 ((or (eq gnus-auto-select-next 'quietly)
10404 (and (eq gnus-auto-select-next 'slightly-quietly)
10406 (and (eq gnus-auto-select-next 'almost-quietly)
10407 (gnus-summary-last-article-p)))
10409 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10410 (gnus-summary-exit)
10411 (gnus-message 7 "No more%s articles (%s)..."
10412 (if unread " unread" "")
10413 (if group (concat "selecting " group)
10415 (gnus-summary-next-group nil group backward)))
10417 (gnus-summary-walk-group-buffer
10418 gnus-newsgroup-name cmd unread backward)))))))
10420 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10421 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10422 (?\C-p (gnus-group-prev-unread-group 1))))
10423 keve key group ended)
10425 (set-buffer gnus-group-buffer)
10426 (gnus-summary-jump-to-group from-group)
10428 (if (eq gnus-keep-same-level 'best)
10429 (gnus-summary-best-group gnus-newsgroup-name)
10430 (gnus-summary-search-group backward gnus-keep-same-level))))
10433 5 "No more%s articles%s" (if unread " unread" "")
10435 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10436 (format " (Type %s for %s [%s])"
10437 (single-key-description cmd) group
10438 (car (gnus-gethash group gnus-newsrc-hashtb)))
10439 (format " (Type %s to exit %s)"
10440 (single-key-description cmd)
10441 gnus-newsgroup-name)))
10442 ;; Confirm auto selection.
10443 (setq key (car (setq keve (gnus-read-event-char))))
10446 ((assq key keystrokes)
10447 (let ((obuf (current-buffer)))
10448 (switch-to-buffer gnus-group-buffer)
10450 (gnus-group-jump-to-group group))
10451 (eval (cadr (assq key keystrokes)))
10452 (setq group (gnus-group-group-name))
10453 (switch-to-buffer obuf))
10456 (if (or (not group)
10457 (gnus-ephemeral-group-p gnus-newsgroup-name))
10458 (gnus-summary-exit)
10459 (gnus-summary-next-group nil group backward)))
10461 (push (cdr keve) unread-command-events))))))
10463 (defun gnus-read-event-char ()
10464 "Get the next event."
10465 (let ((event (read-event)))
10466 (cons (and (numberp event) event) event)))
10468 (defun gnus-summary-next-unread-article ()
10469 "Select unread article after current one."
10471 (gnus-summary-next-article t (and gnus-auto-select-same
10472 (gnus-summary-article-subject))))
10474 (defun gnus-summary-prev-article (&optional unread subject)
10475 "Select the article after the current one.
10476 If UNREAD is non-nil, only unread articles are selected."
10478 (gnus-summary-next-article unread subject t))
10480 (defun gnus-summary-prev-unread-article ()
10481 "Select unred article before current one."
10483 (gnus-summary-prev-article t (and gnus-auto-select-same
10484 (gnus-summary-article-subject))))
10486 (defun gnus-summary-next-page (&optional lines circular)
10487 "Show next page of the selected article.
10488 If at the end of the current article, select the next article.
10489 LINES says how many lines should be scrolled up.
10491 If CIRCULAR is non-nil, go to the start of the article instead of
10492 selecting the next article when reaching the end of the current
10495 (setq gnus-summary-buffer (current-buffer))
10496 (gnus-set-global-variables)
10497 (let ((article (gnus-summary-article-number))
10499 (gnus-configure-windows 'article)
10500 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10501 (if (and (eq gnus-summary-goto-unread 'never)
10502 (not (gnus-summary-last-article-p article)))
10503 (gnus-summary-next-article)
10504 (gnus-summary-next-unread-article))
10505 (if (or (null gnus-current-article)
10506 (null gnus-article-current)
10507 (/= article (cdr gnus-article-current))
10508 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10509 ;; Selected subject is different from current article's.
10510 (gnus-summary-display-article article)
10511 (gnus-eval-in-buffer-window gnus-article-buffer
10512 (setq endp (gnus-article-next-page lines)))
10515 (gnus-summary-beginning-of-article))
10517 (gnus-message 3 "End of message"))
10519 (if (and (eq gnus-summary-goto-unread 'never)
10520 (not (gnus-summary-last-article-p article)))
10521 (gnus-summary-next-article)
10522 (gnus-summary-next-unread-article)))))))
10523 (gnus-summary-recenter)
10524 (gnus-summary-position-point)))
10526 (defun gnus-summary-prev-page (&optional lines)
10527 "Show previous page of selected article.
10528 Argument LINES specifies lines to be scrolled down."
10530 (gnus-set-global-variables)
10531 (let ((article (gnus-summary-article-number)))
10532 (gnus-configure-windows 'article)
10533 (if (or (null gnus-current-article)
10534 (null gnus-article-current)
10535 (/= article (cdr gnus-article-current))
10536 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10537 ;; Selected subject is different from current article's.
10538 (gnus-summary-display-article article)
10539 (gnus-summary-recenter)
10540 (gnus-eval-in-buffer-window gnus-article-buffer
10541 (gnus-article-prev-page lines))))
10542 (gnus-summary-position-point))
10544 (defun gnus-summary-scroll-up (lines)
10545 "Scroll up (or down) one line current article.
10546 Argument LINES specifies lines to be scrolled up (or down if negative)."
10548 (gnus-set-global-variables)
10549 (gnus-configure-windows 'article)
10550 (gnus-summary-show-thread)
10551 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10552 (gnus-eval-in-buffer-window gnus-article-buffer
10554 (if (gnus-article-next-page lines)
10555 (gnus-message 3 "End of message")))
10557 (gnus-article-prev-page (- lines))))))
10558 (gnus-summary-recenter)
10559 (gnus-summary-position-point))
10561 (defun gnus-summary-next-same-subject ()
10562 "Select next article which has the same subject as current one."
10564 (gnus-set-global-variables)
10565 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10567 (defun gnus-summary-prev-same-subject ()
10568 "Select previous article which has the same subject as current one."
10570 (gnus-set-global-variables)
10571 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10573 (defun gnus-summary-next-unread-same-subject ()
10574 "Select next unread article which has the same subject as current one."
10576 (gnus-set-global-variables)
10577 (gnus-summary-next-article t (gnus-summary-article-subject)))
10579 (defun gnus-summary-prev-unread-same-subject ()
10580 "Select previous unread article which has the same subject as current one."
10582 (gnus-set-global-variables)
10583 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10585 (defun gnus-summary-first-unread-article ()
10586 "Select the first unread article.
10587 Return nil if there are no unread articles."
10589 (gnus-set-global-variables)
10591 (if (gnus-summary-first-subject t)
10593 (gnus-summary-show-thread)
10594 (gnus-summary-first-subject t)
10595 (gnus-summary-display-article (gnus-summary-article-number))))
10596 (gnus-summary-position-point)))
10598 (defun gnus-summary-best-unread-article ()
10599 "Select the unread article with the highest score."
10601 (gnus-set-global-variables)
10602 (let ((best -1000000)
10603 (data gnus-newsgroup-data)
10606 (and (gnus-data-unread-p (car data))
10608 (gnus-summary-article-score (gnus-data-number (car data))))
10611 article (gnus-data-number (car data))))
10612 (setq data (cdr data)))
10615 (gnus-summary-goto-article article)
10616 (error "No unread articles"))
10617 (gnus-summary-position-point))))
10619 (defun gnus-summary-last-subject ()
10620 "Go to the last displayed subject line in the group."
10621 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10623 (gnus-summary-goto-subject article))))
10625 (defun gnus-summary-goto-article (article &optional all-headers force)
10626 "Fetch ARTICLE and display it if it exists.
10627 If ALL-HEADERS is non-nil, no header lines are hidden."
10633 (mapcar (lambda (number) (list (int-to-string number)))
10634 gnus-newsgroup-limit)))
10638 (if (gnus-summary-goto-subject article force)
10639 (gnus-summary-display-article article all-headers)
10640 (gnus-message 4 "Couldn't go to article %s" article) nil)
10641 (gnus-summary-position-point)))
10643 (defun gnus-summary-goto-last-article ()
10644 "Go to the previously read article."
10647 (and gnus-last-article
10648 (gnus-summary-goto-article gnus-last-article))
10649 (gnus-summary-position-point)))
10651 (defun gnus-summary-pop-article (number)
10652 "Pop one article off the history and go to the previous.
10653 NUMBER articles will be popped off."
10656 (setq gnus-newsgroup-history
10657 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10659 (gnus-summary-goto-article (car to))
10660 (error "Article history empty")))
10661 (gnus-summary-position-point))
10663 ;; Summary commands and functions for limiting the summary buffer.
10665 (defun gnus-summary-limit-to-articles (n)
10666 "Limit the summary buffer to the next N articles.
10667 If not given a prefix, use the process marked articles instead."
10669 (gnus-set-global-variables)
10671 (let ((articles (gnus-summary-work-articles n)))
10672 (setq gnus-newsgroup-processable nil)
10673 (gnus-summary-limit articles))
10674 (gnus-summary-position-point)))
10676 (defun gnus-summary-pop-limit (&optional total)
10677 "Restore the previous limit.
10678 If given a prefix, remove all limits."
10680 (gnus-set-global-variables)
10682 (setq gnus-newsgroup-limits
10683 (list (mapcar (lambda (h) (mail-header-number h))
10684 gnus-newsgroup-headers))))
10685 (unless gnus-newsgroup-limits
10686 (error "No limit to pop"))
10688 (gnus-summary-limit nil 'pop)
10689 (gnus-summary-position-point)))
10691 (defun gnus-summary-limit-to-subject (subject &optional header)
10692 "Limit the summary buffer to articles that have subjects that match a regexp."
10693 (interactive "sRegexp: ")
10695 (setq header "subject"))
10696 (when (not (equal "" subject))
10698 (let ((articles (gnus-summary-find-matching
10699 (or header "subject") subject 'all)))
10700 (or articles (error "Found no matches for \"%s\"" subject))
10701 (gnus-summary-limit articles))
10702 (gnus-summary-position-point))))
10704 (defun gnus-summary-limit-to-author (from)
10705 "Limit the summary buffer to articles that have authors that match a regexp."
10706 (interactive "sRegexp: ")
10707 (gnus-summary-limit-to-subject from "from"))
10709 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10711 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10713 (defun gnus-summary-limit-to-unread (&optional all)
10714 "Limit the summary buffer to articles that are not marked as read.
10715 If ALL is non-nil, limit strictly to unread articles."
10718 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10719 (gnus-summary-limit-to-marks
10720 ;; Concat all the marks that say that an article is read and have
10722 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10723 gnus-killed-mark gnus-kill-file-mark
10724 gnus-low-score-mark gnus-expirable-mark
10725 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10728 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10729 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10731 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10732 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10733 If REVERSE, limit the summary buffer to articles that are not marked
10734 with MARKS. MARKS can either be a string of marks or a list of marks.
10735 Returns how many articles were removed."
10736 (interactive "sMarks: ")
10737 (gnus-set-global-variables)
10739 (let ((data gnus-newsgroup-data)
10740 (marks (if (listp marks) marks
10741 (append marks nil))) ; Transform to list.
10744 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10745 (memq (gnus-data-mark (car data)) marks))
10746 (setq articles (cons (gnus-data-number (car data)) articles)))
10747 (setq data (cdr data)))
10748 (gnus-summary-limit articles))
10749 (gnus-summary-position-point)))
10751 (defun gnus-summary-limit-to-score (&optional score)
10752 "Limit to articles with score at or above SCORE."
10754 (gnus-set-global-variables)
10755 (setq score (if score
10756 (prefix-numeric-value score)
10757 (or gnus-summary-default-score 0)))
10758 (let ((data gnus-newsgroup-data)
10761 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10763 (push (gnus-data-number (car data)) articles))
10764 (setq data (cdr data)))
10766 (gnus-summary-limit articles)
10767 (gnus-summary-position-point))))
10769 (defun gnus-summary-limit-include-dormant ()
10770 "Display all the hidden articles that are marked as dormant."
10772 (gnus-set-global-variables)
10773 (or gnus-newsgroup-dormant
10774 (error "There are no dormant articles in this group"))
10776 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10777 (gnus-summary-position-point)))
10779 (defun gnus-summary-limit-exclude-dormant ()
10780 "Hide all dormant articles."
10782 (gnus-set-global-variables)
10784 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10785 (gnus-summary-position-point)))
10787 (defun gnus-summary-limit-exclude-childless-dormant ()
10788 "Hide all dormant articles that have no children."
10790 (gnus-set-global-variables)
10791 (let ((data (gnus-data-list t))
10792 articles d children)
10793 ;; Find all articles that are either not dormant or have
10795 (while (setq d (pop data))
10796 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10797 (and (setq children
10798 (gnus-article-children (gnus-data-number d)))
10801 (when (memq (car children) articles)
10806 (push (gnus-data-number d) articles)))
10807 ;; Do the limiting.
10809 (gnus-summary-limit articles)
10810 (gnus-summary-position-point))))
10812 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10813 "Mark all unread excluded articles as read.
10814 If ALL, mark even excluded ticked and dormants as read."
10816 (let ((articles (gnus-sorted-complement
10818 (mapcar (lambda (h) (mail-header-number h))
10819 gnus-newsgroup-headers)
10821 (sort gnus-newsgroup-limit '<)))
10823 (setq gnus-newsgroup-unreads nil)
10825 (setq gnus-newsgroup-dormant nil
10826 gnus-newsgroup-marked nil
10827 gnus-newsgroup-reads
10829 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10830 gnus-newsgroup-reads))
10831 (while (setq article (pop articles))
10832 (unless (or (memq article gnus-newsgroup-dormant)
10833 (memq article gnus-newsgroup-marked))
10834 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10836 (defun gnus-summary-limit (articles &optional pop)
10838 ;; We pop the previous limit off the stack and use that.
10839 (setq articles (car gnus-newsgroup-limits)
10840 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10841 ;; We use the new limit, so we push the old limit on the stack.
10842 (setq gnus-newsgroup-limits
10843 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10845 (setq gnus-newsgroup-limit articles)
10846 (let ((total (length gnus-newsgroup-data))
10847 (data (gnus-data-find-list (gnus-summary-article-number)))
10849 ;; This will do all the work of generating the new summary buffer
10850 ;; according to the new limit.
10851 (gnus-summary-prepare)
10852 ;; Hide any threads, possibly.
10853 (and gnus-show-threads
10854 gnus-thread-hide-subtree
10855 (gnus-summary-hide-all-threads))
10856 ;; Try to return to the article you were at, or one in the
10859 ;; We try to find some article after the current one.
10861 (and (gnus-summary-goto-subject
10862 (gnus-data-number (car data)) nil t)
10865 (setq data (cdr data))))
10867 ;; If there is no data, that means that we were after the last
10868 ;; article. The same goes when we can't find any articles
10869 ;; after the current one.
10871 (goto-char (point-max))
10872 (gnus-summary-find-prev)))
10873 ;; We return how many articles were removed from the summary
10874 ;; buffer as a result of the new limit.
10875 (- total (length gnus-newsgroup-data))))
10877 (defsubst gnus-invisible-cut-children (threads)
10880 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10885 (defsubst gnus-cut-thread (thread)
10886 "Go forwards in the thread until we find an article that we want to display."
10887 (when (or (eq gnus-fetch-old-headers 'some)
10888 (eq gnus-build-sparse-threads 'some)
10889 (eq gnus-build-sparse-threads 'more))
10890 ;; Deal with old-fetched headers and sparse threads.
10894 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10895 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10896 (or (<= (length (cdr thread)) 1)
10897 (gnus-invisible-cut-children (cdr thread))))
10898 (setq thread (cadr thread))))
10901 (defun gnus-cut-threads (threads)
10902 "Cut off all uninteresting articles from the beginning of threads."
10903 (when (or (eq gnus-fetch-old-headers 'some)
10904 (eq gnus-build-sparse-threads 'some)
10905 (eq gnus-build-sparse-threads 'more))
10906 (let ((th threads))
10908 (setcar th (gnus-cut-thread (car th)))
10909 (setq th (cdr th)))))
10910 ;; Remove nixed out threads.
10911 (delq nil threads))
10913 (defun gnus-summary-initial-limit (&optional show-if-empty)
10914 "Figure out what the initial limit is supposed to be on group entry.
10915 This entails weeding out unwanted dormants, low-scored articles,
10916 fetch-old-headers verbiage, and so on."
10917 ;; Most groups have nothing to remove.
10918 (if (or gnus-inhibit-limiting
10919 (and (null gnus-newsgroup-dormant)
10920 (not (eq gnus-fetch-old-headers 'some))
10921 (null gnus-summary-expunge-below)
10922 (not (eq gnus-build-sparse-threads 'some))
10923 (not (eq gnus-build-sparse-threads 'more))
10924 (null gnus-thread-expunge-below)
10925 (not gnus-use-nocem)))
10927 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10928 (setq gnus-newsgroup-limit nil)
10931 (unless (car (symbol-value node))
10932 ;; These threads have no parents -- they are roots.
10933 (let ((nodes (cdr (symbol-value node)))
10936 (if (and gnus-thread-expunge-below
10937 (< (gnus-thread-total-score (car nodes))
10938 gnus-thread-expunge-below))
10939 (gnus-expunge-thread (pop nodes))
10940 (setq thread (pop nodes))
10941 (gnus-summary-limit-children thread))))))
10942 gnus-newsgroup-dependencies)
10943 ;; If this limitation resulted in an empty group, we might
10944 ;; pop the previous limit and use it instead.
10945 (when (and (not gnus-newsgroup-limit)
10947 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10948 gnus-newsgroup-limit))
10950 (defun gnus-summary-limit-children (thread)
10951 "Return 1 if this subthread is visible and 0 if it is not."
10952 ;; First we get the number of visible children to this thread. This
10953 ;; is done by recursing down the thread using this function, so this
10954 ;; will really go down to a leaf article first, before slowly
10955 ;; working its way up towards the root.
10959 (apply '+ (mapcar 'gnus-summary-limit-children
10962 (number (mail-header-number (car thread)))
10965 ;; If this article is dormant and has absolutely no visible
10966 ;; children, then this article isn't visible.
10967 (and (memq number gnus-newsgroup-dormant)
10969 ;; If this is "fetch-old-headered" and there is only one
10970 ;; visible child (or less), then we don't want this article.
10971 (and (eq gnus-fetch-old-headers 'some)
10972 (memq number gnus-newsgroup-ancient)
10974 ;; If this is a sparsely inserted article with no children,
10975 ;; we don't want it.
10976 (and (eq gnus-build-sparse-threads 'some)
10977 (memq number gnus-newsgroup-sparse)
10979 ;; If we use expunging, and this article is really
10980 ;; low-scored, then we don't want this article.
10981 (when (and gnus-summary-expunge-below
10983 (or (cdr (assq number gnus-newsgroup-scored))
10984 gnus-summary-default-score))
10985 gnus-summary-expunge-below))
10986 ;; We increase the expunge-tally here, but that has
10987 ;; nothing to do with the limits, really.
10988 (incf gnus-newsgroup-expunged-tally)
10989 ;; We also mark as read here, if that's wanted.
10990 (when (and gnus-summary-mark-below
10991 (< score gnus-summary-mark-below))
10992 (setq gnus-newsgroup-unreads
10993 (delq number gnus-newsgroup-unreads))
10994 (if gnus-newsgroup-auto-expire
10995 (push number gnus-newsgroup-expirable)
10996 (push (cons number gnus-low-score-mark)
10997 gnus-newsgroup-reads)))
10999 (and gnus-use-nocem
11000 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11001 ;; Nope, invisible article.
11003 ;; Ok, this article is to be visible, so we add it to the limit
11005 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11008 (defun gnus-expunge-thread (thread)
11009 "Mark all articles in THREAD as read."
11010 (let* ((number (mail-header-number (car thread))))
11011 (incf gnus-newsgroup-expunged-tally)
11012 ;; We also mark as read here, if that's wanted.
11013 (setq gnus-newsgroup-unreads
11014 (delq number gnus-newsgroup-unreads))
11015 (if gnus-newsgroup-auto-expire
11016 (push number gnus-newsgroup-expirable)
11017 (push (cons number gnus-low-score-mark)
11018 gnus-newsgroup-reads)))
11019 ;; Go recursively through all subthreads.
11020 (mapcar 'gnus-expunge-thread (cdr thread)))
11022 ;; Summary article oriented commands
11024 (defun gnus-summary-refer-parent-article (n)
11025 "Refer parent article N times.
11026 The difference between N and the number of articles fetched is returned."
11028 (gnus-set-global-variables)
11032 (let* ((header (gnus-summary-article-header))
11034 ;; If we try to find the parent of the currently
11035 ;; displayed article, then we take a look at the actual
11036 ;; References header, since this is slightly more
11037 ;; reliable than the References field we got from the
11039 (if (and (eq (mail-header-number header)
11040 (cdr gnus-article-current))
11041 (equal gnus-newsgroup-name
11042 (car gnus-article-current)))
11044 (set-buffer gnus-original-article-buffer)
11045 (nnheader-narrow-to-headers)
11047 (message-fetch-field "references")
11049 ;; It's not the current article, so we take a bet on
11050 ;; the value we got from the server.
11051 (mail-header-references header))))
11052 (if (setq ref (or ref (mail-header-references header)))
11053 (or (gnus-summary-refer-article (gnus-parent-id ref))
11054 (gnus-message 1 "Couldn't find parent"))
11055 (gnus-message 1 "No references in article %d"
11056 (gnus-summary-article-number))
11059 (gnus-summary-position-point)
11062 (defun gnus-summary-refer-references ()
11063 "Fetch all articles mentioned in the References header.
11064 Return how many articles were fetched."
11066 (gnus-set-global-variables)
11067 (let ((ref (mail-header-references (gnus-summary-article-header)))
11068 (current (gnus-summary-article-number))
11070 ;; For each Message-ID in the References header...
11071 (while (string-match "<[^>]*>" ref)
11073 ;; ... fetch that article.
11074 (gnus-summary-refer-article
11075 (prog1 (match-string 0 ref)
11076 (setq ref (substring ref (match-end 0))))))
11077 (gnus-summary-goto-subject current)
11078 (gnus-summary-position-point)
11081 (defun gnus-summary-refer-article (message-id)
11082 "Fetch an article specified by MESSAGE-ID."
11083 (interactive "sMessage-ID: ")
11084 (when (and (stringp message-id)
11085 (not (zerop (length message-id))))
11086 ;; Construct the correct Message-ID if necessary.
11087 ;; Suggested by tale@pawl.rpi.edu.
11088 (unless (string-match "^<" message-id)
11089 (setq message-id (concat "<" message-id)))
11090 (unless (string-match ">$" message-id)
11091 (setq message-id (concat message-id ">")))
11092 (let* ((header (gnus-id-to-header message-id))
11093 (sparse (and header
11094 (memq (mail-header-number header)
11095 gnus-newsgroup-sparse))))
11098 ;; The article is present in the buffer, to we just go to it.
11099 (gnus-summary-goto-article
11100 (mail-header-number header) nil header)
11102 (gnus-summary-update-article (mail-header-number header))))
11103 ;; We fetch the article
11104 (let ((gnus-override-method
11105 (and (gnus-news-group-p gnus-newsgroup-name)
11106 gnus-refer-article-method))
11108 ;; Start the special refer-article method, if necessary.
11109 (when (and gnus-refer-article-method
11110 (gnus-news-group-p gnus-newsgroup-name))
11111 (gnus-check-server gnus-refer-article-method))
11112 ;; Fetch the header, and display the article.
11113 (if (setq number (gnus-summary-insert-subject message-id))
11114 (gnus-summary-select-article nil nil nil number)
11115 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11117 (defun gnus-summary-enter-digest-group (&optional force)
11118 "Enter a digest group based on the current article."
11120 (gnus-set-global-variables)
11121 (gnus-summary-select-article)
11122 (let ((name (format "%s-%d"
11123 (gnus-group-prefixed-name
11124 gnus-newsgroup-name (list 'nndoc ""))
11125 gnus-current-article))
11126 (ogroup gnus-newsgroup-name)
11127 (case-fold-search t)
11128 (buf (current-buffer))
11131 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11132 (insert-buffer-substring gnus-original-article-buffer)
11134 (goto-char (point-min))
11135 (or (search-forward "\n\n" nil t) (point)))
11136 (goto-char (point-min))
11137 (delete-matching-lines "^\\(Path\\):\\|^From ")
11140 (if (gnus-group-read-ephemeral-group
11141 name `(nndoc ,name (nndoc-address
11143 (nndoc-article-type ,(if force 'digest 'guess))) t)
11144 ;; Make all postings to this group go to the parent group.
11145 (nconc (gnus-info-params (gnus-get-info name))
11146 (list (cons 'to-group ogroup)))
11147 ;; Couldn't select this doc group.
11148 (switch-to-buffer buf)
11149 (gnus-set-global-variables)
11150 (gnus-configure-windows 'summary)
11151 (gnus-message 3 "Article couldn't be entered?"))
11152 (kill-buffer dig))))
11154 (defun gnus-summary-isearch-article (&optional regexp-p)
11155 "Do incremental search forward on the current article.
11156 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11158 (gnus-set-global-variables)
11159 (gnus-summary-select-article)
11160 (gnus-configure-windows 'article)
11161 (gnus-eval-in-buffer-window gnus-article-buffer
11162 (goto-char (point-min))
11163 (isearch-forward regexp-p)))
11165 (defun gnus-summary-search-article-forward (regexp &optional backward)
11166 "Search for an article containing REGEXP forward.
11167 If BACKWARD, search backward instead."
11170 (format "Search article %s (regexp%s): "
11171 (if current-prefix-arg "backward" "forward")
11172 (if gnus-last-search-regexp
11173 (concat ", default " gnus-last-search-regexp)
11175 current-prefix-arg))
11176 (gnus-set-global-variables)
11177 (if (string-equal regexp "")
11178 (setq regexp (or gnus-last-search-regexp ""))
11179 (setq gnus-last-search-regexp regexp))
11180 (unless (gnus-summary-search-article regexp backward)
11181 (error "Search failed: \"%s\"" regexp)))
11183 (defun gnus-summary-search-article-backward (regexp)
11184 "Search for an article containing REGEXP backward."
11187 (format "Search article backward (regexp%s): "
11188 (if gnus-last-search-regexp
11189 (concat ", default " gnus-last-search-regexp)
11191 (gnus-summary-search-article-forward regexp 'backward))
11193 (defun gnus-summary-search-article (regexp &optional backward)
11194 "Search for an article containing REGEXP.
11195 Optional argument BACKWARD means do search for backward.
11196 `gnus-select-article-hook' is not called during the search."
11197 (let ((gnus-select-article-hook nil) ;Disable hook.
11198 (gnus-article-display-hook nil)
11199 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11202 're-search-backward 're-search-forward))
11203 (sum (current-buffer))
11205 (gnus-save-hidden-threads
11206 (gnus-summary-select-article)
11207 (set-buffer gnus-article-buffer)
11211 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11213 (re-search-backward regexp nil t)
11214 (re-search-forward regexp nil t))
11215 ;; We found the regexp.
11217 (setq found 'found)
11218 (beginning-of-line)
11220 (get-buffer-window (current-buffer))
11224 ;; We didn't find it, so we go to the next article.
11226 (if (not (if backward (gnus-summary-find-prev)
11227 (gnus-summary-find-next)))
11228 ;; No more articles.
11230 ;; Select the next article and adjust point.
11231 (gnus-summary-select-article)
11232 (set-buffer gnus-article-buffer)
11234 (goto-char (if backward (point-max) (point-min))))))
11235 (gnus-message 7 ""))
11236 ;; Return whether we found the regexp.
11237 (when (eq found 'found)
11238 (gnus-summary-show-thread)
11239 (gnus-summary-goto-subject gnus-current-article)
11240 (gnus-summary-position-point)
11243 (defun gnus-summary-find-matching (header regexp &optional backward unread
11245 "Return a list of all articles that match REGEXP on HEADER.
11246 The search stars on the current article and goes forwards unless
11247 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11248 If UNREAD is non-nil, only unread articles will
11249 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11250 in the comparisons."
11251 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11252 (gnus-data-find-list
11253 (gnus-summary-article-number) (gnus-data-list backward))))
11254 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11255 (case-fold-search (not not-case-fold))
11257 (or (fboundp (intern (concat "mail-header-" header)))
11258 (error "%s is not a valid header" header))
11260 (setq d (car data))
11261 (and (or (not unread) ; We want all articles...
11262 (gnus-data-unread-p d)) ; Or just unreads.
11263 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11264 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11265 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11266 (setq data (cdr data)))
11267 (nreverse articles)))
11269 (defun gnus-summary-execute-command (header regexp command &optional backward)
11270 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11271 If HEADER is an empty string (or nil), the match is done on the entire
11272 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11274 (list (let ((completion-ignore-case t))
11277 (mapcar (lambda (string) (list string))
11278 '("Number" "Subject" "From" "Lines" "Date"
11279 "Message-ID" "Xref" "References" "Body"))
11280 nil 'require-match))
11281 (read-string "Regexp: ")
11282 (read-key-sequence "Command: ")
11283 current-prefix-arg))
11284 (when (equal header "Body")
11286 (gnus-set-global-variables)
11287 ;; Hidden thread subtrees must be searched as well.
11288 (gnus-summary-show-all-threads)
11289 ;; We don't want to change current point nor window configuration.
11291 (save-window-excursion
11292 (gnus-message 6 "Executing %s..." (key-description command))
11293 ;; We'd like to execute COMMAND interactively so as to give arguments.
11294 (gnus-execute header regexp
11295 `(lambda () (call-interactively ',(key-binding command)))
11297 (gnus-message 6 "Executing %s...done" (key-description command)))))
11299 (defun gnus-summary-beginning-of-article ()
11300 "Scroll the article back to the beginning."
11302 (gnus-set-global-variables)
11303 (gnus-summary-select-article)
11304 (gnus-configure-windows 'article)
11305 (gnus-eval-in-buffer-window gnus-article-buffer
11307 (goto-char (point-min))
11308 (and gnus-break-pages (gnus-narrow-to-page))))
11310 (defun gnus-summary-end-of-article ()
11311 "Scroll to the end of the article."
11313 (gnus-set-global-variables)
11314 (gnus-summary-select-article)
11315 (gnus-configure-windows 'article)
11316 (gnus-eval-in-buffer-window gnus-article-buffer
11318 (goto-char (point-max))
11320 (and gnus-break-pages (gnus-narrow-to-page))))
11322 (defun gnus-summary-show-article (&optional arg)
11323 "Force re-fetching of the current article.
11324 If ARG (the prefix) is non-nil, show the raw article without any
11325 article massaging functions being run."
11327 (gnus-set-global-variables)
11329 ;; Select the article the normal way.
11330 (gnus-summary-select-article nil 'force)
11331 ;; Bind the article treatment functions to nil.
11332 (let ((gnus-have-all-headers t)
11333 gnus-article-display-hook
11334 gnus-article-prepare-hook
11337 (gnus-summary-select-article nil 'force)))
11338 (gnus-summary-goto-subject gnus-current-article)
11339 ; (gnus-configure-windows 'article)
11340 (gnus-summary-position-point))
11342 (defun gnus-summary-verbose-headers (&optional arg)
11343 "Toggle permanent full header display.
11344 If ARG is a positive number, turn header display on.
11345 If ARG is a negative number, turn header display off."
11347 (gnus-set-global-variables)
11348 (gnus-summary-toggle-header arg)
11349 (setq gnus-show-all-headers
11350 (cond ((or (not (numberp arg))
11352 (not gnus-show-all-headers))
11356 (defun gnus-summary-toggle-header (&optional arg)
11357 "Show the headers if they are hidden, or hide them if they are shown.
11358 If ARG is a positive number, show the entire header.
11359 If ARG is a negative number, hide the unwanted header lines."
11361 (gnus-set-global-variables)
11363 (set-buffer gnus-article-buffer)
11364 (let* ((buffer-read-only nil)
11365 (inhibit-point-motion-hooks t)
11366 (hidden (text-property-any
11367 (goto-char (point-min)) (search-forward "\n\n")
11370 (goto-char (point-min))
11371 (when (search-forward "\n\n" nil t)
11372 (delete-region (point-min) (1- (point))))
11373 (goto-char (point-min))
11375 (set-buffer gnus-original-article-buffer)
11376 (goto-char (point-min))
11377 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11378 (insert-buffer-substring gnus-original-article-buffer 1 e)
11379 (let ((gnus-inhibit-hiding t))
11380 (run-hooks 'gnus-article-display-hook))
11381 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11382 (gnus-article-hide-headers)))))
11384 (defun gnus-summary-show-all-headers ()
11385 "Make all header lines visible."
11387 (gnus-set-global-variables)
11388 (gnus-article-show-all-headers))
11390 (defun gnus-summary-toggle-mime (&optional arg)
11391 "Toggle MIME processing.
11392 If ARG is a positive number, turn MIME processing on."
11394 (gnus-set-global-variables)
11395 (setq gnus-show-mime
11396 (if (null arg) (not gnus-show-mime)
11397 (> (prefix-numeric-value arg) 0)))
11398 (gnus-summary-select-article t 'force))
11400 (defun gnus-summary-caesar-message (&optional arg)
11401 "Caesar rotate the current article by 13.
11402 The numerical prefix specifies how manu places to rotate each letter
11405 (gnus-set-global-variables)
11406 (gnus-summary-select-article)
11407 (let ((mail-header-separator ""))
11408 (gnus-eval-in-buffer-window gnus-article-buffer
11411 (let ((start (window-start))
11413 (message-caesar-buffer-body arg)
11414 (set-window-start (get-buffer-window (current-buffer)) start))))))
11416 (defun gnus-summary-stop-page-breaking ()
11417 "Stop page breaking in the current article."
11419 (gnus-set-global-variables)
11420 (gnus-summary-select-article)
11421 (gnus-eval-in-buffer-window gnus-article-buffer
11424 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11425 "Move the current article to a different newsgroup.
11426 If N is a positive number, move the N next articles.
11427 If N is a negative number, move the N previous articles.
11428 If N is nil and any articles have been marked with the process mark,
11429 move those articles instead.
11430 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11431 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11432 re-spool using this method.
11434 For this function to work, both the current newsgroup and the
11435 newsgroup that you want to move to have to support the `request-move'
11436 and `request-accept' functions."
11438 (unless action (setq action 'move))
11439 (gnus-set-global-variables)
11440 ;; Check whether the source group supports the required functions.
11441 (cond ((and (eq action 'move)
11442 (not (gnus-check-backend-function
11443 'request-move-article gnus-newsgroup-name)))
11444 (error "The current group does not support article moving"))
11445 ((and (eq action 'crosspost)
11446 (not (gnus-check-backend-function
11447 'request-replace-article gnus-newsgroup-name)))
11448 (error "The current group does not support article editing")))
11449 (let ((articles (gnus-summary-work-articles n))
11450 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11451 (names '((move "Move" "Moving")
11452 (copy "Copy" "Copying")
11453 (crosspost "Crosspost" "Crossposting")))
11454 (copy-buf (save-excursion
11455 (nnheader-set-temp-buffer " *copy article*")))
11456 art-group to-method new-xref article to-groups)
11457 (unless (assq action names)
11458 (error "Unknown action %s" action))
11459 ;; Read the newsgroup name.
11460 (when (and (not to-newsgroup)
11461 (not select-method))
11463 (gnus-read-move-group-name
11464 (cadr (assq action names))
11465 (symbol-value (intern (format "gnus-current-%s-group" action)))
11467 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11468 (setq to-method (or select-method
11469 (gnus-find-method-for-group to-newsgroup)))
11470 ;; Check the method we are to move this article to...
11471 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11472 (error "%s does not support article copying" (car to-method)))
11473 (or (gnus-check-server to-method)
11474 (error "Can't open server %s" (car to-method)))
11475 (gnus-message 6 "%s to %s: %s..."
11476 (caddr (assq action names))
11477 (or (car select-method) to-newsgroup) articles)
11479 (setq article (pop articles))
11483 ;; Move the article.
11485 (gnus-request-move-article
11486 article ; Article to move
11487 gnus-newsgroup-name ; From newsgrouo
11488 (nth 1 (gnus-find-method-for-group
11489 gnus-newsgroup-name)) ; Server
11490 (list 'gnus-request-accept-article
11491 to-newsgroup (list 'quote select-method)
11492 (not articles)) ; Accept form
11493 (not articles))) ; Only save nov last time
11494 ;; Copy the article.
11497 (set-buffer copy-buf)
11498 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11499 (gnus-request-accept-article
11500 to-newsgroup select-method (not articles))))
11501 ;; Crosspost the article.
11502 ((eq action 'crosspost)
11503 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11504 (setq new-xref (concat gnus-newsgroup-name ":" article))
11505 (if (and xref (not (string= xref "")))
11507 (when (string-match "^Xref: " xref)
11508 (setq xref (substring xref (match-end 0))))
11509 (setq new-xref (concat xref " " new-xref)))
11510 (setq new-xref (concat (system-name) " " new-xref)))
11512 (set-buffer copy-buf)
11513 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11514 (nnheader-replace-header "xref" new-xref)
11515 (gnus-request-accept-article
11516 to-newsgroup select-method (not articles)))))))
11517 (if (not art-group)
11518 (gnus-message 1 "Couldn't %s article %s"
11519 (cadr (assq action names)) article)
11522 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11524 (gnus-group-prefixed-name
11527 (gnus-find-method-for-group to-newsgroup)))
11528 gnus-newsrc-hashtb)))
11529 (info (nth 2 entry))
11530 (to-group (gnus-info-group info)))
11531 ;; Update the group that has been moved to.
11533 (memq action '(move copy)))
11534 (unless (member to-group to-groups)
11535 (push to-group to-groups))
11537 (unless (memq article gnus-newsgroup-unreads)
11538 (gnus-info-set-read
11539 info (gnus-add-to-range (gnus-info-read info)
11540 (list (cdr art-group)))))
11542 ;; Copy any marks over to the new group.
11543 (let ((marks gnus-article-mark-lists)
11544 (to-article (cdr art-group)))
11546 ;; See whether the article is to be put in the cache.
11547 (when gnus-use-cache
11548 (gnus-cache-possibly-enter-article
11549 to-group to-article
11550 (let ((header (copy-sequence
11551 (gnus-summary-article-header article))))
11552 (mail-header-set-number header to-article)
11554 (memq article gnus-newsgroup-marked)
11555 (memq article gnus-newsgroup-dormant)
11556 (memq article gnus-newsgroup-unreads)))
11559 (when (memq article (symbol-value
11560 (intern (format "gnus-newsgroup-%s"
11562 ;; If the other group is the same as this group,
11563 ;; then we have to add the mark to the list.
11564 (when (equal to-group gnus-newsgroup-name)
11565 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11568 (intern (format "gnus-newsgroup-%s"
11570 ;; Copy mark to other group.
11571 (gnus-add-marked-articles
11572 to-group (cdar marks) (list to-article) info))
11573 (setq marks (cdr marks)))))
11575 ;; Update the Xref header in this article to point to
11576 ;; the new crossposted article we have just created.
11577 (when (eq action 'crosspost)
11579 (set-buffer copy-buf)
11580 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11581 (nnheader-replace-header
11582 "xref" (concat new-xref " " (gnus-group-prefixed-name
11583 (car art-group) to-method)
11584 ":" (cdr art-group)))
11585 (gnus-request-replace-article
11586 article gnus-newsgroup-name (current-buffer)))))
11588 (gnus-summary-goto-subject article)
11589 (when (eq action 'move)
11590 (gnus-summary-mark-article article gnus-canceled-mark)))
11591 (gnus-summary-remove-process-mark article))
11592 ;; Re-activate all groups that have been moved to.
11594 (gnus-activate-group (pop to-groups)))
11596 (gnus-kill-buffer copy-buf)
11597 (gnus-summary-position-point)
11598 (gnus-set-mode-line 'summary)))
11600 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11601 "Move the current article to a different newsgroup.
11602 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11603 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11604 re-spool using this method."
11606 (gnus-summary-move-article n nil select-method 'copy))
11608 (defun gnus-summary-crosspost-article (&optional n)
11609 "Crosspost the current article to some other group."
11611 (gnus-summary-move-article n nil nil 'crosspost))
11613 (defvar gnus-summary-respool-default-method nil
11614 "Default method for respooling an article.
11615 If nil, use to the current newsgroup method.")
11617 (defun gnus-summary-respool-article (&optional n method)
11618 "Respool the current article.
11619 The article will be squeezed through the mail spooling process again,
11620 which means that it will be put in some mail newsgroup or other
11621 depending on `nnmail-split-methods'.
11622 If N is a positive number, respool the N next articles.
11623 If N is a negative number, respool the N previous articles.
11624 If N is nil and any articles have been marked with the process mark,
11625 respool those articles instead.
11627 Respooling can be done both from mail groups and \"real\" newsgroups.
11628 In the former case, the articles in question will be moved from the
11629 current group into whatever groups they are destined to. In the
11630 latter case, they will be copied into the relevant groups."
11632 (list current-prefix-arg
11633 (let* ((methods (gnus-methods-using 'respool))
11635 (symbol-name (or gnus-summary-respool-default-method
11636 (car (gnus-find-method-for-group
11637 gnus-newsgroup-name)))))
11639 (gnus-completing-read
11640 methname "What backend do you want to use when? "
11641 methods nil t nil 'gnus-method-history))
11644 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11645 (list (intern method) ""))
11649 (cdr (completing-read
11651 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11652 (gnus-set-global-variables)
11654 (error "No method given for respooling"))
11655 (if (assoc (symbol-name
11656 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11657 (gnus-methods-using 'respool))
11658 (gnus-summary-move-article n nil method)
11659 (gnus-summary-copy-article n nil method)))
11661 (defun gnus-summary-import-article (file)
11662 "Import a random file into a mail newsgroup."
11663 (interactive "fImport file: ")
11664 (gnus-set-global-variables)
11665 (let ((group gnus-newsgroup-name)
11666 (now (current-time))
11668 (or (gnus-check-backend-function 'request-accept-article group)
11669 (error "%s does not support article importing" group))
11670 (or (file-readable-p file)
11671 (not (file-regular-p file))
11672 (error "Can't read %s" file))
11674 (set-buffer (get-buffer-create " *import file*"))
11675 (buffer-disable-undo (current-buffer))
11677 (insert-file-contents file)
11678 (goto-char (point-min))
11679 (unless (nnheader-article-p)
11680 ;; This doesn't look like an article, so we fudge some headers.
11681 (setq atts (file-attributes file)
11682 lines (count-lines (point-min) (point-max)))
11683 (insert "From: " (read-string "From: ") "\n"
11684 "Subject: " (read-string "Subject: ") "\n"
11685 "Date: " (timezone-make-date-arpa-standard
11686 (current-time-string (nth 5 atts))
11687 (current-time-zone now)
11688 (current-time-zone now)) "\n"
11689 "Message-ID: " (message-make-message-id) "\n"
11690 "Lines: " (int-to-string lines) "\n"
11691 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11692 (gnus-request-accept-article group nil t)
11693 (kill-buffer (current-buffer)))))
11695 (defun gnus-summary-expire-articles (&optional now)
11696 "Expire all articles that are marked as expirable in the current group."
11698 (gnus-set-global-variables)
11699 (when (gnus-check-backend-function
11700 'request-expire-articles gnus-newsgroup-name)
11701 ;; This backend supports expiry.
11702 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11703 (expirable (if total
11704 (gnus-list-of-read-articles gnus-newsgroup-name)
11705 (setq gnus-newsgroup-expirable
11706 (sort gnus-newsgroup-expirable '<))))
11707 (expiry-wait (if now 'immediate
11708 (gnus-group-get-parameter
11709 gnus-newsgroup-name 'expiry-wait)))
11712 ;; There are expirable articles in this group, so we run them
11713 ;; through the expiry process.
11714 (gnus-message 6 "Expiring articles...")
11715 ;; The list of articles that weren't expired is returned.
11717 (let ((nnmail-expiry-wait-function nil)
11718 (nnmail-expiry-wait expiry-wait))
11719 (setq es (gnus-request-expire-articles
11720 expirable gnus-newsgroup-name)))
11721 (setq es (gnus-request-expire-articles
11722 expirable gnus-newsgroup-name)))
11723 (or total (setq gnus-newsgroup-expirable es))
11724 ;; We go through the old list of expirable, and mark all
11725 ;; really expired articles as nonexistent.
11726 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11727 (let ((gnus-use-cache nil))
11729 (unless (memq (car expirable) es)
11730 (when (gnus-data-find (car expirable))
11731 (gnus-summary-mark-article
11732 (car expirable) gnus-canceled-mark)))
11733 (setq expirable (cdr expirable)))))
11734 (gnus-message 6 "Expiring articles...done")))))
11736 (defun gnus-summary-expire-articles-now ()
11737 "Expunge all expirable articles in the current group.
11738 This means that *all* articles that are marked as expirable will be
11739 deleted forever, right now."
11741 (gnus-set-global-variables)
11742 (or gnus-expert-user
11744 "Are you really, really, really sure you want to delete all these messages? ")
11746 (gnus-summary-expire-articles t))
11748 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11749 (defun gnus-summary-delete-article (&optional n)
11750 "Delete the N next (mail) articles.
11751 This command actually deletes articles. This is not a marking
11752 command. The article will disappear forever from your life, never to
11754 If N is negative, delete backwards.
11755 If N is nil and articles have been marked with the process mark,
11756 delete these instead."
11758 (gnus-set-global-variables)
11759 (or (gnus-check-backend-function 'request-expire-articles
11760 gnus-newsgroup-name)
11761 (error "The current newsgroup does not support article deletion."))
11762 ;; Compute the list of articles to delete.
11763 (let ((articles (gnus-summary-work-articles n))
11765 (if (and gnus-novice-user
11766 (not (gnus-y-or-n-p
11767 (format "Do you really want to delete %s forever? "
11768 (if (> (length articles) 1)
11769 (format "these %s articles" (length articles))
11770 "this article")))))
11772 ;; Delete the articles.
11773 (setq not-deleted (gnus-request-expire-articles
11774 articles gnus-newsgroup-name 'force))
11776 (gnus-summary-remove-process-mark (car articles))
11777 ;; The backend might not have been able to delete the article
11779 (or (memq (car articles) not-deleted)
11780 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11781 (setq articles (cdr articles))))
11782 (gnus-summary-position-point)
11783 (gnus-set-mode-line 'summary)
11786 (defun gnus-summary-edit-article (&optional force)
11787 "Enter into a buffer and edit the current article.
11788 This will have permanent effect only in mail groups.
11789 If FORCE is non-nil, allow editing of articles even in read-only
11793 (set-buffer gnus-summary-buffer)
11794 (gnus-set-global-variables)
11795 (when (and (not force)
11796 (gnus-group-read-only-p))
11797 (error "The current newsgroup does not support article editing."))
11798 (gnus-summary-select-article t nil t)
11799 (gnus-configure-windows 'article)
11800 (select-window (get-buffer-window gnus-article-buffer))
11801 (gnus-message 6 "C-c C-c to end edits")
11802 (setq buffer-read-only nil)
11804 (use-local-map (copy-keymap (current-local-map)))
11805 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11806 (buffer-enable-undo)
11808 (goto-char (point-min))
11809 (search-forward "\n\n" nil t)))
11811 (defun gnus-summary-edit-article-done ()
11812 "Make edits to the current article permanent."
11814 (if (gnus-group-read-only-p)
11816 (gnus-summary-edit-article-postpone)
11818 1 "The current newsgroup does not support article editing."))
11819 (let ((buf (format "%s" (buffer-string))))
11822 (if (not (gnus-request-replace-article
11823 (cdr gnus-article-current) (car gnus-article-current)
11825 (error "Couldn't replace article.")
11826 (gnus-article-mode)
11827 (use-local-map gnus-article-mode-map)
11828 (setq buffer-read-only t)
11829 (buffer-disable-undo (current-buffer))
11830 (gnus-configure-windows 'summary)
11831 (gnus-summary-update-article (cdr gnus-article-current))
11832 (when gnus-use-cache
11833 (gnus-cache-update-article
11834 (car gnus-article-current) (cdr gnus-article-current)))
11835 (when gnus-keep-backlog
11836 (gnus-backlog-remove-article
11837 (car gnus-article-current) (cdr gnus-article-current))))
11839 (when (get-buffer gnus-original-article-buffer)
11840 (set-buffer gnus-original-article-buffer)
11841 (setq gnus-original-article nil)))
11842 (setq gnus-article-current nil
11843 gnus-current-article nil)
11844 (run-hooks 'gnus-article-display-hook)
11845 (and (gnus-visual-p 'summary-highlight 'highlight)
11846 (run-hooks 'gnus-visual-mark-article-hook)))))
11848 (defun gnus-summary-edit-article-postpone ()
11849 "Postpone changes to the current article."
11851 (gnus-article-mode)
11852 (use-local-map gnus-article-mode-map)
11853 (setq buffer-read-only t)
11854 (buffer-disable-undo (current-buffer))
11855 (gnus-configure-windows 'summary)
11856 (and (gnus-visual-p 'summary-highlight 'highlight)
11857 (run-hooks 'gnus-visual-mark-article-hook)))
11859 (defun gnus-summary-respool-query ()
11860 "Query where the respool algorithm would put this article."
11862 (gnus-set-global-variables)
11863 (gnus-summary-select-article)
11865 (set-buffer gnus-article-buffer)
11867 (goto-char (point-min))
11868 (search-forward "\n\n")
11869 (narrow-to-region (point-min) (point))
11870 (pp-eval-expression
11871 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11873 ;; Summary marking commands.
11875 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11876 "Mark articles which has the same subject as read, and then select the next.
11877 If UNMARK is positive, remove any kind of mark.
11878 If UNMARK is negative, tick articles."
11880 (gnus-set-global-variables)
11882 (setq unmark (prefix-numeric-value unmark)))
11884 (gnus-summary-mark-same-subject
11885 (gnus-summary-article-subject) unmark)))
11886 ;; Select next unread article. If auto-select-same mode, should
11887 ;; select the first unread article.
11888 (gnus-summary-next-article t (and gnus-auto-select-same
11889 (gnus-summary-article-subject)))
11890 (gnus-message 7 "%d article%s marked as %s"
11891 count (if (= count 1) " is" "s are")
11892 (if unmark "unread" "read"))))
11894 (defun gnus-summary-kill-same-subject (&optional unmark)
11895 "Mark articles which has the same subject as read.
11896 If UNMARK is positive, remove any kind of mark.
11897 If UNMARK is negative, tick articles."
11899 (gnus-set-global-variables)
11901 (setq unmark (prefix-numeric-value unmark)))
11903 (gnus-summary-mark-same-subject
11904 (gnus-summary-article-subject) unmark)))
11905 ;; If marked as read, go to next unread subject.
11907 ;; Go to next unread subject.
11908 (gnus-summary-next-subject 1 t))
11909 (gnus-message 7 "%d articles are marked as %s"
11910 count (if unmark "unread" "read"))))
11912 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11913 "Mark articles with same SUBJECT as read, and return marked number.
11914 If optional argument UNMARK is positive, remove any kinds of marks.
11915 If optional argument UNMARK is negative, mark articles as unread instead."
11919 ((null unmark) ; Mark as read.
11922 (gnus-summary-mark-article-as-read gnus-killed-mark)
11923 (gnus-summary-show-thread) t)
11924 (gnus-summary-find-subject subject))
11925 (setq count (1+ count))))
11926 ((> unmark 0) ; Tick.
11929 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11930 (gnus-summary-show-thread) t)
11931 (gnus-summary-find-subject subject))
11932 (setq count (1+ count))))
11933 (t ; Mark as unread.
11936 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11937 (gnus-summary-show-thread) t)
11938 (gnus-summary-find-subject subject))
11939 (setq count (1+ count)))))
11940 (gnus-set-mode-line 'summary)
11941 ;; Return the number of marked articles.
11944 (defun gnus-summary-mark-as-processable (n &optional unmark)
11945 "Set the process mark on the next N articles.
11946 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11947 the process mark instead. The difference between N and the actual
11948 number of articles marked is returned."
11950 (gnus-set-global-variables)
11951 (let ((backward (< n 0))
11956 (gnus-summary-remove-process-mark
11957 (gnus-summary-article-number))
11958 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11959 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11961 (if (/= 0 n) (gnus-message 7 "No more articles"))
11962 (gnus-summary-recenter)
11963 (gnus-summary-position-point)
11966 (defun gnus-summary-unmark-as-processable (n)
11967 "Remove the process mark from the next N articles.
11968 If N is negative, mark backward instead. The difference between N and
11969 the actual number of articles marked is returned."
11971 (gnus-set-global-variables)
11972 (gnus-summary-mark-as-processable n t))
11974 (defun gnus-summary-unmark-all-processable ()
11975 "Remove the process mark from all articles."
11977 (gnus-set-global-variables)
11979 (while gnus-newsgroup-processable
11980 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11981 (gnus-summary-position-point))
11983 (defun gnus-summary-mark-as-expirable (n)
11984 "Mark N articles forward as expirable.
11985 If N is negative, mark backward instead. The difference between N and
11986 the actual number of articles marked is returned."
11988 (gnus-set-global-variables)
11989 (gnus-summary-mark-forward n gnus-expirable-mark))
11991 (defun gnus-summary-mark-article-as-replied (article)
11992 "Mark ARTICLE replied and update the summary line."
11993 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11994 (let ((buffer-read-only nil))
11995 (when (gnus-summary-goto-subject article)
11996 (gnus-summary-update-secondary-mark article))))
11998 (defun gnus-summary-set-bookmark (article)
11999 "Set a bookmark in current article."
12000 (interactive (list (gnus-summary-article-number)))
12001 (gnus-set-global-variables)
12002 (if (or (not (get-buffer gnus-article-buffer))
12003 (not gnus-current-article)
12004 (not gnus-article-current)
12005 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12006 (error "No current article selected"))
12007 ;; Remove old bookmark, if one exists.
12008 (let ((old (assq article gnus-newsgroup-bookmarks)))
12009 (if old (setq gnus-newsgroup-bookmarks
12010 (delq old gnus-newsgroup-bookmarks))))
12011 ;; Set the new bookmark, which is on the form
12012 ;; (article-number . line-number-in-body).
12013 (setq gnus-newsgroup-bookmarks
12017 (set-buffer gnus-article-buffer)
12021 (goto-char (point-min))
12022 (search-forward "\n\n" nil t)
12025 gnus-newsgroup-bookmarks))
12026 (gnus-message 6 "A bookmark has been added to the current article."))
12028 (defun gnus-summary-remove-bookmark (article)
12029 "Remove the bookmark from the current article."
12030 (interactive (list (gnus-summary-article-number)))
12031 (gnus-set-global-variables)
12032 ;; Remove old bookmark, if one exists.
12033 (let ((old (assq article gnus-newsgroup-bookmarks)))
12036 (setq gnus-newsgroup-bookmarks
12037 (delq old gnus-newsgroup-bookmarks))
12038 (gnus-message 6 "Removed bookmark."))
12039 (gnus-message 6 "No bookmark in current article."))))
12041 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12042 (defun gnus-summary-mark-as-dormant (n)
12043 "Mark N articles forward as dormant.
12044 If N is negative, mark backward instead. The difference between N and
12045 the actual number of articles marked is returned."
12047 (gnus-set-global-variables)
12048 (gnus-summary-mark-forward n gnus-dormant-mark))
12050 (defun gnus-summary-set-process-mark (article)
12051 "Set the process mark on ARTICLE and update the summary line."
12052 (setq gnus-newsgroup-processable
12054 (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-remove-process-mark (article)
12060 "Remove the process mark from ARTICLE and update the summary line."
12061 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12062 (when (gnus-summary-goto-subject article)
12063 (gnus-summary-show-thread)
12064 (gnus-summary-update-secondary-mark article)))
12066 (defun gnus-summary-set-saved-mark (article)
12067 "Set the process mark on ARTICLE and update the summary line."
12068 (push article gnus-newsgroup-saved)
12069 (when (gnus-summary-goto-subject article)
12070 (gnus-summary-update-secondary-mark article)))
12072 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12073 "Mark N articles as read forwards.
12074 If N is negative, mark backwards instead.
12075 Mark with MARK. If MARK is ? , ?! or ??, articles will be
12077 The difference between N and the actual number of articles marked is
12080 (gnus-set-global-variables)
12081 (let ((backward (< n 0))
12082 (gnus-summary-goto-unread
12083 (and gnus-summary-goto-unread
12084 (not (eq gnus-summary-goto-unread 'never))
12085 (not (memq mark (list gnus-unread-mark
12086 gnus-ticked-mark gnus-dormant-mark)))))
12088 (mark (or mark gnus-del-mark)))
12089 (while (and (> n 0)
12090 (gnus-summary-mark-article nil mark no-expire)
12091 (zerop (gnus-summary-next-subject
12093 (and gnus-summary-goto-unread
12094 (not (eq gnus-summary-goto-unread 'never)))
12097 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12098 (gnus-summary-recenter)
12099 (gnus-summary-position-point)
12100 (gnus-set-mode-line 'summary)
12103 (defun gnus-summary-mark-article-as-read (mark)
12104 "Mark the current article quickly as read with MARK."
12105 (let ((article (gnus-summary-article-number)))
12106 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12107 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12108 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12109 (setq gnus-newsgroup-reads
12110 (cons (cons article mark) gnus-newsgroup-reads))
12111 ;; Possibly remove from cache, if that is used.
12112 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12113 ;; Allow the backend to change the mark.
12114 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12115 ;; Check for auto-expiry.
12116 (when (and gnus-newsgroup-auto-expire
12117 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12118 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12119 (= mark gnus-ancient-mark)
12120 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12121 (setq mark gnus-expirable-mark)
12122 (push article gnus-newsgroup-expirable))
12123 ;; Set the mark in the buffer.
12124 (gnus-summary-update-mark mark 'unread)
12127 (defun gnus-summary-mark-article-as-unread (mark)
12128 "Mark the current article quickly as unread with MARK."
12129 (let ((article (gnus-summary-article-number)))
12130 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12131 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12132 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12133 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12134 (cond ((= mark gnus-ticked-mark)
12135 (push article gnus-newsgroup-marked))
12136 ((= mark gnus-dormant-mark)
12137 (push article gnus-newsgroup-dormant))
12139 (push article gnus-newsgroup-unreads)))
12140 (setq gnus-newsgroup-reads
12141 (delq (assq article gnus-newsgroup-reads)
12142 gnus-newsgroup-reads))
12144 ;; See whether the article is to be put in the cache.
12145 (and gnus-use-cache
12146 (vectorp (gnus-summary-article-header article))
12148 (gnus-cache-possibly-enter-article
12149 gnus-newsgroup-name article
12150 (gnus-summary-article-header article)
12151 (= mark gnus-ticked-mark)
12152 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12155 (gnus-summary-update-mark mark 'unread)
12158 (defun gnus-summary-mark-article (&optional article mark no-expire)
12159 "Mark ARTICLE with MARK. MARK can be any character.
12160 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12161 `??' (dormant) and `?E' (expirable).
12162 If MARK is nil, then the default character `?D' is used.
12163 If ARTICLE is nil, then the article on the current line will be
12165 ;; The mark might be a string.
12166 (and (stringp mark)
12167 (setq mark (aref mark 0)))
12168 ;; If no mark is given, then we check auto-expiring.
12169 (and (not no-expire)
12170 gnus-newsgroup-auto-expire
12172 (and (numberp mark)
12173 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12174 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12175 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12176 (setq mark gnus-expirable-mark))
12177 (let* ((mark (or mark gnus-del-mark))
12178 (article (or article (gnus-summary-article-number))))
12179 (or article (error "No article on current line"))
12180 (if (or (= mark gnus-unread-mark)
12181 (= mark gnus-ticked-mark)
12182 (= mark gnus-dormant-mark))
12183 (gnus-mark-article-as-unread article mark)
12184 (gnus-mark-article-as-read article mark))
12186 ;; See whether the article is to be put in the cache.
12187 (and gnus-use-cache
12188 (not (= mark gnus-canceled-mark))
12189 (vectorp (gnus-summary-article-header article))
12191 (gnus-cache-possibly-enter-article
12192 gnus-newsgroup-name article
12193 (gnus-summary-article-header article)
12194 (= mark gnus-ticked-mark)
12195 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12197 (if (gnus-summary-goto-subject article nil t)
12198 (let ((buffer-read-only nil))
12199 (gnus-summary-show-thread)
12201 (gnus-summary-update-mark mark 'unread)
12204 (defun gnus-summary-update-secondary-mark (article)
12205 "Update the secondary (read, process, cache) mark."
12206 (gnus-summary-update-mark
12207 (cond ((memq article gnus-newsgroup-processable)
12209 ((memq article gnus-newsgroup-cached)
12211 ((memq article gnus-newsgroup-replied)
12213 ((memq article gnus-newsgroup-saved)
12215 (t gnus-unread-mark))
12217 (when (gnus-visual-p 'summary-highlight 'highlight)
12218 (run-hooks 'gnus-summary-update-hook))
12221 (defun gnus-summary-update-mark (mark type)
12222 (beginning-of-line)
12223 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12224 (buffer-read-only nil))
12226 (<= (+ forward (point)) (point-max)))
12227 ;; Go to the right position on the line.
12228 (goto-char (+ forward (point)))
12229 ;; Replace the old mark with the new mark.
12230 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12231 ;; Optionally update the marks by some user rule.
12232 (when (eq type 'unread)
12233 (gnus-data-set-mark
12234 (gnus-data-find (gnus-summary-article-number)) mark)
12235 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12237 (defun gnus-mark-article-as-read (article &optional mark)
12238 "Enter ARTICLE in the pertinent lists and remove it from others."
12239 ;; Make the article expirable.
12240 (let ((mark (or mark gnus-del-mark)))
12241 (if (= mark gnus-expirable-mark)
12242 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12243 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12244 ;; Remove from unread and marked lists.
12245 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12246 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12247 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12248 (push (cons article mark) gnus-newsgroup-reads)
12249 ;; Possibly remove from cache, if that is used.
12250 (when gnus-use-cache
12251 (gnus-cache-enter-remove-article article))))
12253 (defun gnus-mark-article-as-unread (article &optional mark)
12254 "Enter ARTICLE in the pertinent lists and remove it from others."
12255 (let ((mark (or mark gnus-ticked-mark)))
12256 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12257 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12258 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12259 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12260 (cond ((= mark gnus-ticked-mark)
12261 (push article gnus-newsgroup-marked))
12262 ((= mark gnus-dormant-mark)
12263 (push article gnus-newsgroup-dormant))
12265 (push article gnus-newsgroup-unreads)))
12266 (setq gnus-newsgroup-reads
12267 (delq (assq article gnus-newsgroup-reads)
12268 gnus-newsgroup-reads))))
12270 (defalias 'gnus-summary-mark-as-unread-forward
12271 'gnus-summary-tick-article-forward)
12272 (make-obsolete 'gnus-summary-mark-as-unread-forward
12273 'gnus-summary-tick-article-forward)
12274 (defun gnus-summary-tick-article-forward (n)
12275 "Tick N articles forwards.
12276 If N is negative, tick backwards instead.
12277 The difference between N and the number of articles ticked is returned."
12279 (gnus-summary-mark-forward n gnus-ticked-mark))
12281 (defalias 'gnus-summary-mark-as-unread-backward
12282 'gnus-summary-tick-article-backward)
12283 (make-obsolete 'gnus-summary-mark-as-unread-backward
12284 'gnus-summary-tick-article-backward)
12285 (defun gnus-summary-tick-article-backward (n)
12286 "Tick N articles backwards.
12287 The difference between N and the number of articles ticked is returned."
12289 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12291 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12292 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12293 (defun gnus-summary-tick-article (&optional article clear-mark)
12294 "Mark current article as unread.
12295 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12296 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12298 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12299 gnus-ticked-mark)))
12301 (defun gnus-summary-mark-as-read-forward (n)
12302 "Mark N articles as read forwards.
12303 If N is negative, mark backwards instead.
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-backward (n)
12310 "Mark the N articles as read backwards.
12311 The difference between N and the actual number of articles marked is
12314 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12316 (defun gnus-summary-mark-as-read (&optional article mark)
12317 "Mark current article as read.
12318 ARTICLE specifies the article to be marked as read.
12319 MARK specifies a string to be inserted at the beginning of the line."
12320 (gnus-summary-mark-article article mark))
12322 (defun gnus-summary-clear-mark-forward (n)
12323 "Clear marks from N articles forward.
12324 If N is negative, clear backward instead.
12325 The difference between N and the number of marks cleared is returned."
12327 (gnus-summary-mark-forward n gnus-unread-mark))
12329 (defun gnus-summary-clear-mark-backward (n)
12330 "Clear marks from N articles backward.
12331 The difference between N and the number of marks cleared is returned."
12333 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12335 (defun gnus-summary-mark-unread-as-read ()
12336 "Intended to be used by `gnus-summary-mark-article-hook'."
12337 (when (memq gnus-current-article gnus-newsgroup-unreads)
12338 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12340 (defun gnus-summary-mark-read-and-unread-as-read ()
12341 "Intended to be used by `gnus-summary-mark-article-hook'."
12342 (let ((mark (gnus-summary-article-mark)))
12343 (when (or (gnus-unread-mark-p mark)
12344 (gnus-read-mark-p mark))
12345 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12347 (defun gnus-summary-mark-region-as-read (point mark all)
12348 "Mark all unread articles between point and mark as read.
12349 If given a prefix, mark all articles between point and mark as read,
12350 even ticked and dormant ones."
12351 (interactive "r\nP")
12355 (beginning-of-line)
12360 (memq (setq article (gnus-summary-article-number))
12361 gnus-newsgroup-unreads))
12362 (gnus-summary-mark-article article gnus-del-mark))
12364 (gnus-summary-find-next))))))
12366 (defun gnus-summary-mark-below (score mark)
12367 "Mark articles with score less than SCORE with MARK."
12368 (interactive "P\ncMark: ")
12369 (gnus-set-global-variables)
12370 (setq score (if score
12371 (prefix-numeric-value score)
12372 (or gnus-summary-default-score 0)))
12374 (set-buffer gnus-summary-buffer)
12375 (goto-char (point-min))
12378 (and (< (gnus-summary-article-score) score)
12379 (gnus-summary-mark-article nil mark))
12380 (gnus-summary-find-next)))))
12382 (defun gnus-summary-kill-below (&optional score)
12383 "Mark articles with score below SCORE as read."
12385 (gnus-set-global-variables)
12386 (gnus-summary-mark-below score gnus-killed-mark))
12388 (defun gnus-summary-clear-above (&optional score)
12389 "Clear all marks from articles with score above SCORE."
12391 (gnus-set-global-variables)
12392 (gnus-summary-mark-above score gnus-unread-mark))
12394 (defun gnus-summary-tick-above (&optional score)
12395 "Tick all articles with score above SCORE."
12397 (gnus-set-global-variables)
12398 (gnus-summary-mark-above score gnus-ticked-mark))
12400 (defun gnus-summary-mark-above (score mark)
12401 "Mark articles with score over SCORE with MARK."
12402 (interactive "P\ncMark: ")
12403 (gnus-set-global-variables)
12404 (setq score (if score
12405 (prefix-numeric-value score)
12406 (or gnus-summary-default-score 0)))
12408 (set-buffer gnus-summary-buffer)
12409 (goto-char (point-min))
12411 (if (> (gnus-summary-article-score) score)
12412 (gnus-summary-mark-article nil mark))
12414 (gnus-summary-find-next)))))
12416 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12417 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12418 (defun gnus-summary-limit-include-expunged ()
12419 "Display all the hidden articles that were expunged for low scores."
12421 (gnus-set-global-variables)
12422 (let ((buffer-read-only nil))
12423 (let ((scored gnus-newsgroup-scored)
12426 (or (gnus-summary-goto-subject (caar scored))
12427 (and (setq h (gnus-summary-article-header (caar scored)))
12428 (< (cdar scored) gnus-summary-expunge-below)
12429 (setq headers (cons h headers))))
12430 (setq scored (cdr scored)))
12431 (or headers (error "No expunged articles hidden."))
12432 (goto-char (point-min))
12433 (gnus-summary-prepare-unthreaded (nreverse headers)))
12434 (goto-char (point-min))
12435 (gnus-summary-position-point)))
12437 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12438 "Mark all articles not marked as unread in this newsgroup as read.
12439 If prefix argument ALL is non-nil, all articles are marked as read.
12440 If QUIETLY is non-nil, no questions will be asked.
12441 If TO-HERE is non-nil, it should be a point in the buffer. All
12442 articles before this point will be marked as read.
12443 The number of articles marked as read is returned."
12445 (gnus-set-global-variables)
12448 (not gnus-interactive-catchup) ;Without confirmation?
12452 "Mark absolutely all articles as read? "
12453 "Mark all unread articles as read? ")))
12455 (not gnus-newsgroup-adaptive)
12456 (not gnus-newsgroup-auto-expire))
12459 (setq gnus-newsgroup-marked nil
12460 gnus-newsgroup-dormant nil))
12461 (setq gnus-newsgroup-unreads nil))
12462 ;; We actually mark all articles as canceled, which we
12463 ;; have to do when using auto-expiry or adaptive scoring.
12464 (gnus-summary-show-all-threads)
12465 (if (gnus-summary-first-subject (not all))
12467 (if to-here (< (point) to-here) t)
12468 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12469 (gnus-summary-find-next (not all)))))
12471 (setq gnus-newsgroup-unreads nil))
12472 (gnus-set-mode-line 'summary)))
12473 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12474 (if (and (not to-here) (eq 'nnvirtual (car method)))
12475 (nnvirtual-catchup-group
12476 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12477 (gnus-summary-position-point)))
12479 (defun gnus-summary-catchup-to-here (&optional all)
12480 "Mark all unticked articles before the current one as read.
12481 If ALL is non-nil, also mark ticked and dormant articles as read."
12483 (gnus-set-global-variables)
12485 (gnus-save-hidden-threads
12486 (let ((beg (point)))
12487 ;; We check that there are unread articles.
12488 (when (or all (gnus-summary-find-prev))
12489 (gnus-summary-catchup all t beg)))))
12490 (gnus-summary-position-point))
12492 (defun gnus-summary-catchup-all (&optional quietly)
12493 "Mark all articles in this newsgroup as read."
12495 (gnus-set-global-variables)
12496 (gnus-summary-catchup t quietly))
12498 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12499 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12500 If prefix argument ALL is non-nil, all articles are marked as read."
12502 (gnus-set-global-variables)
12503 (gnus-summary-catchup all quietly nil 'fast)
12504 ;; Select next newsgroup or exit.
12505 (if (eq gnus-auto-select-next 'quietly)
12506 (gnus-summary-next-group nil)
12507 (gnus-summary-exit)))
12509 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12510 "Mark all articles in this newsgroup as read, and then exit."
12512 (gnus-set-global-variables)
12513 (gnus-summary-catchup-and-exit t quietly))
12515 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12516 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12517 "Mark all articles in this group as read and select the next group.
12518 If given a prefix, mark all articles, unread as well as ticked, as
12521 (gnus-set-global-variables)
12523 (gnus-summary-catchup all))
12524 (gnus-summary-next-article t nil nil t))
12526 ;; Thread-based commands.
12528 (defun gnus-summary-articles-in-thread (&optional article)
12529 "Return a list of all articles in the current thread.
12530 If ARTICLE is non-nil, return all articles in the thread that starts
12531 with that article."
12532 (let* ((article (or article (gnus-summary-article-number)))
12533 (data (gnus-data-find-list article))
12534 (top-level (gnus-data-level (car data)))
12536 (cond ((null gnus-thread-operation-ignore-subject)
12537 (gnus-simplify-subject-re
12538 (mail-header-subject (gnus-data-header (car data)))))
12539 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12540 (gnus-simplify-subject-fuzzy
12541 (mail-header-subject (gnus-data-header (car data)))))
12543 (end-point (save-excursion
12544 (if (gnus-summary-go-to-next-thread)
12545 (point) (point-max))))
12548 (< (gnus-data-pos (car data)) end-point))
12549 (when (or (not top-subject)
12550 (string= top-subject
12551 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12552 (gnus-simplify-subject-fuzzy
12553 (mail-header-subject
12554 (gnus-data-header (car data))))
12555 (gnus-simplify-subject-re
12556 (mail-header-subject
12557 (gnus-data-header (car data)))))))
12558 (push (gnus-data-number (car data)) articles))
12559 (unless (and (setq data (cdr data))
12560 (> (gnus-data-level (car data)) top-level))
12562 ;; Return the list of articles.
12563 (nreverse articles)))
12565 (defun gnus-summary-rethread-current ()
12566 "Rethread the thread the current article is part of."
12568 (gnus-set-global-variables)
12569 (let* ((gnus-show-threads t)
12570 (article (gnus-summary-article-number))
12571 (id (mail-header-id (gnus-summary-article-header)))
12572 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12574 (error "No article on the current line"))
12575 (gnus-rebuild-thread id)
12576 (gnus-summary-goto-subject article)))
12578 (defun gnus-summary-reparent-thread ()
12579 "Make current article child of the marked (or previous) article.
12581 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12582 is non-nil or the Subject: of both articles are the same."
12584 (or (not (gnus-group-read-only-p))
12585 (error "The current newsgroup does not support article editing."))
12586 (or (<= (length gnus-newsgroup-processable) 1)
12587 (error "No more than one article may be marked."))
12588 (save-window-excursion
12589 (let ((gnus-article-buffer " *reparent*")
12590 (current-article (gnus-summary-article-number))
12591 ; first grab the marked article, otherwise one line up.
12592 (parent-article (if (not (null gnus-newsgroup-processable))
12593 (car gnus-newsgroup-processable)
12595 (if (eq (forward-line -1) 0)
12596 (gnus-summary-article-number)
12597 (error "Beginning of summary buffer."))))))
12598 (or (not (eq current-article parent-article))
12599 (error "An article may not be self-referential."))
12600 (let ((message-id (mail-header-id
12601 (gnus-summary-article-header parent-article))))
12602 (or (and message-id (not (equal message-id "")))
12603 (error "No message-id in desired parent."))
12604 (gnus-summary-select-article t t nil current-article)
12605 (set-buffer gnus-article-buffer)
12606 (setq buffer-read-only nil)
12607 (let ((buf (format "%s" (buffer-string))))
12610 (goto-char (point-min))
12611 (if (search-forward-regexp "^References: " nil t)
12612 (insert message-id " " )
12613 (insert "References: " message-id "\n"))
12614 (or (gnus-request-replace-article current-article
12615 (car gnus-article-current)
12616 gnus-article-buffer)
12617 (error "Couldn't replace article."))
12618 (set-buffer gnus-summary-buffer)
12619 (gnus-summary-unmark-all-processable)
12620 (gnus-summary-rethread-current)
12621 (gnus-message 3 "Article %d is now the child of article %d."
12622 current-article parent-article)))))
12624 (defun gnus-summary-toggle-threads (&optional arg)
12625 "Toggle showing conversation threads.
12626 If ARG is positive number, turn showing conversation threads on."
12628 (gnus-set-global-variables)
12629 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12630 (setq gnus-show-threads
12631 (if (null arg) (not gnus-show-threads)
12632 (> (prefix-numeric-value arg) 0)))
12633 (gnus-summary-prepare)
12634 (gnus-summary-goto-subject current)
12635 (gnus-summary-position-point)))
12637 (defun gnus-summary-show-all-threads ()
12638 "Show all threads."
12640 (gnus-set-global-variables)
12642 (let ((buffer-read-only nil))
12643 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12644 (gnus-summary-position-point))
12646 (defun gnus-summary-show-thread ()
12647 "Show thread subtrees.
12648 Returns nil if no thread was there to be shown."
12650 (gnus-set-global-variables)
12651 (let ((buffer-read-only nil)
12653 ;; first goto end then to beg, to have point at beg after let
12654 (end (progn (end-of-line) (point)))
12655 (beg (progn (beginning-of-line) (point))))
12657 ;; Any hidden lines here?
12658 (search-forward "\r" end t)
12659 (subst-char-in-region beg end ?\^M ?\n t)
12661 (gnus-summary-position-point))))
12663 (defun gnus-summary-hide-all-threads ()
12664 "Hide all thread subtrees."
12666 (gnus-set-global-variables)
12668 (goto-char (point-min))
12669 (gnus-summary-hide-thread)
12670 (while (zerop (gnus-summary-next-thread 1 t))
12671 (gnus-summary-hide-thread)))
12672 (gnus-summary-position-point))
12674 (defun gnus-summary-hide-thread ()
12675 "Hide thread subtrees.
12676 Returns nil if no threads were there to be hidden."
12678 (gnus-set-global-variables)
12679 (let ((buffer-read-only nil)
12681 (article (gnus-summary-article-number)))
12683 ;; Go forward until either the buffer ends or the subthread
12685 (when (and (not (eobp))
12686 (or (zerop (gnus-summary-next-thread 1 t))
12687 (goto-char (point-max))))
12689 (if (and (> (point) start)
12690 (search-backward "\n" start t))
12692 (subst-char-in-region start (point) ?\n ?\^M)
12693 (gnus-summary-goto-subject article))
12696 ;;(gnus-summary-position-point)
12699 (defun gnus-summary-go-to-next-thread (&optional previous)
12700 "Go to the same level (or less) next thread.
12701 If PREVIOUS is non-nil, go to previous thread instead.
12702 Return the article number moved to, or nil if moving was impossible."
12703 (let ((level (gnus-summary-thread-level))
12704 (way (if previous -1 1))
12707 (while (and (not (eobp))
12708 (< level (gnus-summary-thread-level)))
12709 (forward-line way))
12716 (gnus-summary-article-number)
12717 (goto-char beg)))))
12719 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12720 "Go to the same level (or less) next thread.
12721 If PREVIOUS is non-nil, go to previous thread instead.
12722 Return the article number moved to, or nil if moving was impossible."
12723 (if (and (eq gnus-summary-make-false-root 'dummy)
12724 (gnus-summary-article-intangible-p))
12725 (let ((beg (point)))
12726 (while (and (zerop (forward-line 1))
12727 (not (gnus-summary-article-intangible-p))
12728 (not (zerop (save-excursion
12729 (gnus-summary-thread-level))))))
12735 (let* ((level (gnus-summary-thread-level))
12736 (article (gnus-summary-article-number))
12737 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12740 (if (<= (gnus-data-level (car data)) level)
12741 (setq oart (gnus-data-number (car data))
12743 (setq data (cdr data))))
12745 (gnus-summary-goto-subject oart)))))
12747 (defun gnus-summary-next-thread (n &optional silent)
12748 "Go to the same level next N'th thread.
12749 If N is negative, search backward instead.
12750 Returns the difference between N and the number of skips actually
12753 If SILENT, don't output messages."
12755 (gnus-set-global-variables)
12756 (let ((backward (< n 0))
12759 (while (and (> n 0)
12760 (gnus-summary-go-to-next-thread backward))
12763 (gnus-summary-position-point))
12764 (when (and (not silent) (/= 0 n))
12765 (gnus-message 7 "No more threads"))
12768 (defun gnus-summary-prev-thread (n)
12769 "Go to the same level previous N'th thread.
12770 Returns the difference between N and the number of skips actually
12773 (gnus-set-global-variables)
12774 (gnus-summary-next-thread (- n)))
12776 (defun gnus-summary-go-down-thread ()
12777 "Go down one level in the current thread."
12778 (let ((children (gnus-summary-article-children)))
12780 (gnus-summary-goto-subject (car children)))))
12782 (defun gnus-summary-go-up-thread ()
12783 "Go up one level in the current thread."
12784 (let ((parent (gnus-summary-article-parent)))
12786 (gnus-summary-goto-subject parent))))
12788 (defun gnus-summary-down-thread (n)
12789 "Go down thread N steps.
12790 If N is negative, go up instead.
12791 Returns the difference between N and how many steps down that were
12794 (gnus-set-global-variables)
12797 (while (and (> n 0)
12798 (if up (gnus-summary-go-up-thread)
12799 (gnus-summary-go-down-thread)))
12801 (gnus-summary-position-point)
12802 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12805 (defun gnus-summary-up-thread (n)
12806 "Go up thread N steps.
12807 If N is negative, go up instead.
12808 Returns the difference between N and how many steps down that were
12811 (gnus-set-global-variables)
12812 (gnus-summary-down-thread (- n)))
12814 (defun gnus-summary-top-thread ()
12815 "Go to the top of the thread."
12817 (gnus-set-global-variables)
12818 (while (gnus-summary-go-up-thread))
12819 (gnus-summary-article-number))
12821 (defun gnus-summary-kill-thread (&optional unmark)
12822 "Mark articles under current thread as read.
12823 If the prefix argument is positive, remove any kinds of marks.
12824 If the prefix argument is negative, tick articles instead."
12826 (gnus-set-global-variables)
12828 (setq unmark (prefix-numeric-value unmark)))
12829 (let ((articles (gnus-summary-articles-in-thread)))
12831 ;; Expand the thread.
12832 (gnus-summary-show-thread)
12833 ;; Mark all the articles.
12835 (gnus-summary-goto-subject (car articles))
12836 (cond ((null unmark)
12837 (gnus-summary-mark-article-as-read gnus-killed-mark))
12839 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12841 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12842 (setq articles (cdr articles))))
12843 ;; Hide killed subtrees.
12845 gnus-thread-hide-killed
12846 (gnus-summary-hide-thread))
12847 ;; If marked as read, go to next unread subject.
12849 ;; Go to next unread subject.
12850 (gnus-summary-next-subject 1 t)))
12851 (gnus-set-mode-line 'summary))
12853 ;; Summary sorting commands
12855 (defun gnus-summary-sort-by-number (&optional reverse)
12856 "Sort summary buffer by article number.
12857 Argument REVERSE means reverse order."
12859 (gnus-summary-sort 'number reverse))
12861 (defun gnus-summary-sort-by-author (&optional reverse)
12862 "Sort summary buffer by author name alphabetically.
12863 If case-fold-search is non-nil, case of letters is ignored.
12864 Argument REVERSE means reverse order."
12866 (gnus-summary-sort 'author reverse))
12868 (defun gnus-summary-sort-by-subject (&optional reverse)
12869 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12870 If case-fold-search is non-nil, case of letters is ignored.
12871 Argument REVERSE means reverse order."
12873 (gnus-summary-sort 'subject reverse))
12875 (defun gnus-summary-sort-by-date (&optional reverse)
12876 "Sort summary buffer by date.
12877 Argument REVERSE means reverse order."
12879 (gnus-summary-sort 'date reverse))
12881 (defun gnus-summary-sort-by-score (&optional reverse)
12882 "Sort summary buffer by score.
12883 Argument REVERSE means reverse order."
12885 (gnus-summary-sort 'score reverse))
12887 (defun gnus-summary-sort (predicate reverse)
12888 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12889 (gnus-set-global-variables)
12890 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12891 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12892 (gnus-thread-sort-functions
12897 (,thread t2 t1)))))
12898 (gnus-article-sort-functions
12903 (,article t2 t1)))))
12905 (gnus-summary-prepare-hook nil))
12906 ;; We do the sorting by regenerating the threads.
12907 (gnus-summary-prepare)
12908 ;; Hide subthreads if needed.
12909 (when (and gnus-show-threads gnus-thread-hide-subtree)
12910 (gnus-summary-hide-all-threads)))
12911 ;; If in async mode, we send some info to the backend.
12912 (when gnus-newsgroup-async
12913 (gnus-request-asynchronous
12914 gnus-newsgroup-name gnus-newsgroup-data)))
12916 (defun gnus-sortable-date (date)
12917 "Make sortable string by string-lessp from DATE.
12918 Timezone package is used."
12921 (setq date (inline (timezone-fix-time
12923 (aref (inline (timezone-parse-date date)) 4))))
12925 (timezone-make-sortable-date
12926 (aref date 0) (aref date 1) (aref date 2)
12928 (timezone-make-time-string
12929 (aref date 3) (aref date 4) (aref date 5))))))
12932 ;; Summary saving commands.
12934 (defun gnus-summary-save-article (&optional n not-saved)
12935 "Save the current article using the default saver function.
12936 If N is a positive number, save the N next articles.
12937 If N is a negative number, save the N previous articles.
12938 If N is nil and any articles have been marked with the process mark,
12939 save those articles instead.
12940 The variable `gnus-default-article-saver' specifies the saver function."
12942 (gnus-set-global-variables)
12943 (let ((articles (gnus-summary-work-articles n))
12944 (save-buffer (save-excursion
12945 (nnheader-set-temp-buffer " *Gnus Save*")))
12946 file header article)
12948 (setq header (gnus-summary-article-header
12949 (setq article (pop articles))))
12950 (if (not (vectorp header))
12951 ;; This is a pseudo-article.
12952 (if (assq 'name header)
12953 (gnus-copy-file (cdr (assq 'name header)))
12954 (gnus-message 1 "Article %d is unsaveable" article))
12955 ;; This is a real article.
12956 (save-window-excursion
12957 (gnus-summary-select-article t nil nil article))
12959 (set-buffer save-buffer)
12961 (insert-buffer-substring gnus-original-article-buffer))
12962 (unless gnus-save-all-headers
12963 ;; Remove headers accoring to `gnus-saved-headers'.
12964 (let ((gnus-visible-headers
12965 (or gnus-saved-headers gnus-visible-headers))
12966 (gnus-article-buffer save-buffer))
12967 (gnus-article-hide-headers 1 t)))
12968 (save-window-excursion
12969 (if (not gnus-default-article-saver)
12970 (error "No default saver is defined.")
12971 ;; !!! Magic! The saving functions all save
12972 ;; `gnus-original-article-buffer' (or so they think),
12973 ;; but we bind that variable to our save-buffer.
12974 (set-buffer gnus-article-buffer)
12975 (let ((gnus-original-article-buffer save-buffer))
12976 (set-buffer gnus-summary-buffer)
12977 (setq file (funcall
12978 gnus-default-article-saver
12980 ((not gnus-prompt-before-saving)
12982 ((eq gnus-prompt-before-saving 'always)
12985 (gnus-summary-remove-process-mark article)
12987 (gnus-summary-set-saved-mark article))))
12988 (gnus-kill-buffer save-buffer)
12989 (gnus-summary-position-point)
12992 (defun gnus-summary-pipe-output (&optional arg)
12993 "Pipe the current article to a subprocess.
12994 If N is a positive number, pipe the N next articles.
12995 If N is a negative number, pipe the N previous articles.
12996 If N is nil and any articles have been marked with the process mark,
12997 pipe those articles instead."
12999 (gnus-set-global-variables)
13000 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13001 (gnus-summary-save-article arg t))
13002 (gnus-configure-windows 'pipe))
13004 (defun gnus-summary-save-article-mail (&optional arg)
13005 "Append the current article to an mail file.
13006 If N is a positive number, save the N next articles.
13007 If N is a negative number, save the N previous articles.
13008 If N is nil and any articles have been marked with the process mark,
13009 save those articles instead."
13011 (gnus-set-global-variables)
13012 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13013 (gnus-summary-save-article arg)))
13015 (defun gnus-summary-save-article-rmail (&optional arg)
13016 "Append the current article to an rmail file.
13017 If N is a positive number, save the N next articles.
13018 If N is a negative number, save the N previous articles.
13019 If N is nil and any articles have been marked with the process mark,
13020 save those articles instead."
13022 (gnus-set-global-variables)
13023 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13024 (gnus-summary-save-article arg)))
13026 (defun gnus-summary-save-article-file (&optional arg)
13027 "Append the current article to a file.
13028 If N is a positive number, save the N next articles.
13029 If N is a negative number, save the N previous articles.
13030 If N is nil and any articles have been marked with the process mark,
13031 save those articles instead."
13033 (gnus-set-global-variables)
13034 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13035 (gnus-summary-save-article arg)))
13037 (defun gnus-summary-save-article-body-file (&optional arg)
13038 "Append the current article body to a file.
13039 If N is a positive number, save the N next articles.
13040 If N is a negative number, save the N previous articles.
13041 If N is nil and any articles have been marked with the process mark,
13042 save those articles instead."
13044 (gnus-set-global-variables)
13045 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13046 (gnus-summary-save-article arg)))
13048 (defun gnus-get-split-value (methods)
13049 "Return a value based on the split METHODS."
13050 (let (split-name method result match)
13053 (set-buffer gnus-original-article-buffer)
13055 (nnheader-narrow-to-headers)
13057 (goto-char (point-min))
13058 (setq method (pop methods))
13059 (setq match (car method))
13062 ;; Regular expression.
13064 (re-search-forward match nil t)
13066 ((gnus-functionp match)
13070 (setq result (funcall match gnus-newsgroup-name))))
13075 (setq result (eval match)))))
13076 (setq split-name (append (cdr method) split-name))
13077 (cond ((stringp result)
13078 (push result split-name))
13080 (setq split-name (append result split-name)))))))))
13083 (defun gnus-read-move-group-name (prompt default articles prefix)
13084 "Read a group name."
13085 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13086 (minibuffer-confirm-incomplete nil) ; XEmacs
13093 (assoc (symbol-name
13094 (car (gnus-find-method-for-group
13096 gnus-valid-select-methods))
13097 (push (list (symbol-name g)) group-map)))
13098 gnus-active-hashtb))
13100 (format "%s %s to:"
13102 (if (> (length articles) 1)
13103 (format "these %d articles" (length articles))
13108 (gnus-completing-read default prom
13109 group-map nil nil prefix
13110 'gnus-group-history))
13111 ((= 1 (length split-name))
13112 (gnus-completing-read (car split-name) prom group-map
13114 'gnus-group-history))
13116 (gnus-completing-read nil prom
13117 (mapcar (lambda (el) (list el))
13118 (nreverse split-name))
13120 'gnus-group-history)))))
13122 (if (or (string= to-newsgroup "")
13123 (string= to-newsgroup prefix))
13124 (setq to-newsgroup (or default "")))
13125 (or (gnus-active to-newsgroup)
13126 (gnus-activate-group to-newsgroup)
13127 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13129 (or (gnus-request-create-group to-newsgroup)
13130 (error "Couldn't create group %s" to-newsgroup)))
13131 (error "No such group: %s" to-newsgroup)))
13134 (defun gnus-read-save-file-name (prompt default-name)
13135 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13137 ;; Let the split methods have their say.
13139 ;; No split name was found.
13142 (concat prompt " (default "
13143 (file-name-nondirectory default-name) ") ")
13144 (file-name-directory default-name)
13146 ;; A single split name was found
13147 ((= 1 (length split-name))
13149 (concat prompt " (default " (car split-name) ") ")
13150 gnus-article-save-directory
13151 (concat gnus-article-save-directory (car split-name))))
13152 ;; A list of splits was found.
13154 (setq split-name (nreverse split-name))
13156 (let ((file-name-history (nconc split-name file-name-history)))
13159 (concat prompt " (`M-p' for defaults) ")
13160 gnus-article-save-directory
13161 (car split-name))))
13162 (car (push result file-name-history)))))))
13163 ;; If we have read a directory, we append the default file name.
13164 (when (file-directory-p file)
13165 (setq file (concat (file-name-as-directory file)
13166 (file-name-nondirectory default-name))))
13167 ;; Possibly translate some charaters.
13168 (nnheader-translate-file-chars file)))
13170 (defun gnus-article-archive-name (group)
13171 "Return the first instance of an \"Archive-name\" in the current buffer."
13172 (let ((case-fold-search t))
13173 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13174 (match-string 1))))
13176 (defun gnus-summary-save-in-rmail (&optional filename)
13177 "Append this article to Rmail file.
13178 Optional argument FILENAME specifies file name.
13179 Directory to save to is default to `gnus-article-save-directory'."
13181 (gnus-set-global-variables)
13182 (let ((default-name
13183 (funcall gnus-rmail-save-name gnus-newsgroup-name
13184 gnus-current-headers gnus-newsgroup-last-rmail)))
13186 (cond ((eq filename 'default)
13188 (filename filename)
13189 (t (gnus-read-save-file-name
13190 "Save in rmail file:" default-name))))
13191 (gnus-make-directory (file-name-directory filename))
13192 (gnus-eval-in-buffer-window gnus-original-article-buffer
13196 (gnus-output-to-rmail filename))))
13197 ;; Remember the directory name to save articles
13198 (setq gnus-newsgroup-last-rmail filename)))
13200 (defun gnus-summary-save-in-mail (&optional filename)
13201 "Append this article to Unix mail file.
13202 Optional argument FILENAME specifies file name.
13203 Directory to save to is default to `gnus-article-save-directory'."
13205 (gnus-set-global-variables)
13206 (let ((default-name
13207 (funcall gnus-mail-save-name gnus-newsgroup-name
13208 gnus-current-headers gnus-newsgroup-last-mail)))
13210 (cond ((eq filename 'default)
13212 (filename filename)
13213 (t (gnus-read-save-file-name
13214 "Save in Unix mail file:" default-name))))
13216 (expand-file-name filename
13218 (file-name-directory default-name))))
13219 (gnus-make-directory (file-name-directory filename))
13220 (gnus-eval-in-buffer-window gnus-original-article-buffer
13224 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13225 (gnus-output-to-rmail filename)
13226 (let ((mail-use-rfc822 t))
13227 (rmail-output filename 1 t t))))))
13228 ;; Remember the directory name to save articles.
13229 (setq gnus-newsgroup-last-mail filename)))
13231 (defun gnus-summary-save-in-file (&optional filename)
13232 "Append this article to file.
13233 Optional argument FILENAME specifies file name.
13234 Directory to save to is default to `gnus-article-save-directory'."
13236 (gnus-set-global-variables)
13237 (let ((default-name
13238 (funcall gnus-file-save-name gnus-newsgroup-name
13239 gnus-current-headers gnus-newsgroup-last-file)))
13241 (cond ((eq filename 'default)
13243 (filename filename)
13244 (t (gnus-read-save-file-name
13245 "Save in file:" default-name))))
13246 (gnus-make-directory (file-name-directory filename))
13247 (gnus-eval-in-buffer-window gnus-original-article-buffer
13251 (gnus-output-to-file filename))))
13252 ;; Remember the directory name to save articles.
13253 (setq gnus-newsgroup-last-file filename)))
13255 (defun gnus-summary-save-body-in-file (&optional filename)
13256 "Append this article body to a file.
13257 Optional argument FILENAME specifies file name.
13258 The directory to save in defaults to `gnus-article-save-directory'."
13260 (gnus-set-global-variables)
13261 (let ((default-name
13262 (funcall gnus-file-save-name gnus-newsgroup-name
13263 gnus-current-headers gnus-newsgroup-last-file)))
13265 (cond ((eq filename 'default)
13267 (filename filename)
13268 (t (gnus-read-save-file-name
13269 "Save body in file:" default-name))))
13270 (gnus-make-directory (file-name-directory filename))
13271 (gnus-eval-in-buffer-window gnus-article-buffer
13275 (goto-char (point-min))
13276 (and (search-forward "\n\n" nil t)
13277 (narrow-to-region (point) (point-max)))
13278 (gnus-output-to-file filename))))
13279 ;; Remember the directory name to save articles.
13280 (setq gnus-newsgroup-last-file filename)))
13282 (defun gnus-summary-save-in-pipe (&optional command)
13283 "Pipe this article to subprocess."
13285 (gnus-set-global-variables)
13287 (cond ((eq command 'default)
13288 gnus-last-shell-command)
13290 (t (read-string "Shell command on article: "
13291 gnus-last-shell-command))))
13292 (if (string-equal command "")
13293 (setq command gnus-last-shell-command))
13294 (gnus-eval-in-buffer-window gnus-article-buffer
13297 (shell-command-on-region (point-min) (point-max) command nil)))
13298 (setq gnus-last-shell-command command))
13300 ;; Summary extract commands
13302 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13303 (let ((buffer-read-only nil)
13304 (article (gnus-summary-article-number))
13306 (or (gnus-summary-goto-subject article)
13307 (error (format "No such article: %d" article)))
13308 (gnus-summary-position-point)
13309 ;; If all commands are to be bunched up on one line, we collect
13311 (if gnus-view-pseudos-separately
13313 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13316 (setq action (cdr (assq 'action (car ps))))
13317 (setq files (list (cdr (assq 'name (car ps)))))
13318 (while (and ps (cdr ps)
13319 (string= (or action "1")
13320 (or (cdr (assq 'action (cadr ps))) "2")))
13321 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13322 (setcdr ps (cddr ps)))
13325 (if (not (string-match "%s" action))
13326 (setq files (cons " " files)))
13327 (setq files (cons " " files))
13328 (and (assq 'execute (car ps))
13329 (setcdr (assq 'execute (car ps))
13330 (funcall (if (string-match "%s" action)
13333 (mapconcat (lambda (f) f) files " ")))))
13334 (setq ps (cdr ps)))))
13335 (if (and gnus-view-pseudos (not not-view))
13337 (and (assq 'execute (car pslist))
13338 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13339 (eq gnus-view-pseudos 'not-confirm)))
13340 (setq pslist (cdr pslist)))
13343 (setq after-article (or (cdr (assq 'article (car pslist)))
13344 (gnus-summary-article-number)))
13345 (gnus-summary-goto-subject after-article)
13348 (insert " " (file-name-nondirectory
13349 (cdr (assq 'name (car pslist))))
13350 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13352 (forward-line -1) ; back to `b'
13353 (gnus-add-text-properties
13354 b (1- e) (list 'gnus-number gnus-reffed-article-number
13355 gnus-mouse-face-prop gnus-mouse-face))
13357 after-article gnus-reffed-article-number
13358 gnus-unread-mark b (car pslist) 0 (- e b))
13359 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13360 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13361 (setq pslist (cdr pslist)))))))
13363 (defun gnus-pseudos< (p1 p2)
13364 (let ((c1 (cdr (assq 'action p1)))
13365 (c2 (cdr (assq 'action p2))))
13366 (and c1 c2 (string< c1 c2))))
13368 (defun gnus-request-pseudo-article (props)
13369 (cond ((assq 'execute props)
13370 (gnus-execute-command (cdr (assq 'execute props)))))
13371 (let ((gnus-current-article (gnus-summary-article-number)))
13372 (run-hooks 'gnus-mark-article-hook)))
13374 (defun gnus-execute-command (command &optional automatic)
13376 (gnus-article-setup-buffer)
13377 (set-buffer gnus-article-buffer)
13378 (setq buffer-read-only nil)
13379 (let ((command (if automatic command (read-string "Command: " command)))
13380 ;; Just binding this here doesn't help, because there might
13381 ;; be output from the process after exiting the scope of
13383 ;; (buffer-read-only nil)
13386 (insert "$ " command "\n\n")
13387 (if gnus-view-pseudo-asynchronously
13388 (start-process "gnus-execute" nil "sh" "-c" command)
13389 (call-process "sh" nil t nil "-c" command)))))
13391 (defun gnus-copy-file (file &optional to)
13394 (list (read-file-name "Copy file: " default-directory)
13395 (read-file-name "Copy file to: " default-directory)))
13396 (gnus-set-global-variables)
13397 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13398 (and (file-directory-p to)
13399 (setq to (concat (file-name-as-directory to)
13400 (file-name-nondirectory file))))
13401 (copy-file file to))
13403 ;; Summary kill commands.
13405 (defun gnus-summary-edit-global-kill (article)
13406 "Edit the \"global\" kill file."
13407 (interactive (list (gnus-summary-article-number)))
13408 (gnus-set-global-variables)
13409 (gnus-group-edit-global-kill article))
13411 (defun gnus-summary-edit-local-kill ()
13412 "Edit a local kill file applied to the current newsgroup."
13414 (gnus-set-global-variables)
13415 (setq gnus-current-headers (gnus-summary-article-header))
13416 (gnus-set-global-variables)
13417 (gnus-group-edit-local-kill
13418 (gnus-summary-article-number) gnus-newsgroup-name))
13422 ;;; Gnus article mode
13425 (put 'gnus-article-mode 'mode-class 'special)
13427 (if gnus-article-mode-map
13429 (setq gnus-article-mode-map (make-keymap))
13430 (suppress-keymap gnus-article-mode-map)
13432 (gnus-define-keys gnus-article-mode-map
13433 " " gnus-article-goto-next-page
13434 "\177" gnus-article-goto-prev-page
13435 [delete] gnus-article-goto-prev-page
13436 "\C-c^" gnus-article-refer-article
13437 "h" gnus-article-show-summary
13438 "s" gnus-article-show-summary
13439 "\C-c\C-m" gnus-article-mail
13440 "?" gnus-article-describe-briefly
13441 gnus-mouse-2 gnus-article-push-button
13442 "\r" gnus-article-press-button
13443 "\t" gnus-article-next-button
13444 "\M-\t" gnus-article-prev-button
13445 "\C-c\C-b" gnus-bug)
13447 (substitute-key-definition
13448 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13450 (defun gnus-article-mode ()
13451 "Major mode for displaying an article.
13453 All normal editing commands are switched off.
13455 The following commands are available:
13457 \\<gnus-article-mode-map>
13458 \\[gnus-article-next-page]\t Scroll the article one page forwards
13459 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13460 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13461 \\[gnus-article-show-summary]\t Display the summary buffer
13462 \\[gnus-article-mail]\t Send a reply to the address near point
13463 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13464 \\[gnus-info-find-node]\t Go to the Gnus info node"
13466 (when (and menu-bar-mode
13467 (gnus-visual-p 'article-menu 'menu))
13468 (gnus-article-make-menu-bar))
13469 (kill-all-local-variables)
13470 (gnus-simplify-mode-line)
13471 (setq mode-name "Article")
13472 (setq major-mode 'gnus-article-mode)
13473 (make-local-variable 'minor-mode-alist)
13474 (or (assq 'gnus-show-mime minor-mode-alist)
13475 (setq minor-mode-alist
13476 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13477 (use-local-map gnus-article-mode-map)
13478 (make-local-variable 'page-delimiter)
13479 (setq page-delimiter gnus-page-delimiter)
13480 (buffer-disable-undo (current-buffer))
13481 (setq buffer-read-only t) ;Disable modification
13482 (run-hooks 'gnus-article-mode-hook))
13484 (defun gnus-article-setup-buffer ()
13485 "Initialize the article buffer."
13486 (let* ((name (if gnus-single-article-buffer "*Article*"
13487 (concat "*Article " gnus-newsgroup-name "*")))
13489 (progn (string-match "\\*Article" name)
13490 (concat " *Original Article"
13491 (substring name (match-end 0))))))
13492 (setq gnus-article-buffer name)
13493 (setq gnus-original-article-buffer original)
13494 ;; This might be a variable local to the summary buffer.
13495 (unless gnus-single-article-buffer
13497 (set-buffer gnus-summary-buffer)
13498 (setq gnus-article-buffer name)
13499 (setq gnus-original-article-buffer original)
13500 (gnus-set-global-variables))
13501 (make-local-variable 'gnus-summary-buffer))
13502 ;; Init original article buffer.
13504 (set-buffer (get-buffer-create gnus-original-article-buffer))
13505 (buffer-disable-undo (current-buffer))
13506 (setq major-mode 'gnus-original-article-mode)
13507 (make-local-variable 'gnus-original-article))
13508 (if (get-buffer name)
13511 (buffer-disable-undo (current-buffer))
13512 (setq buffer-read-only t)
13513 (gnus-add-current-to-buffer-list)
13514 (or (eq major-mode 'gnus-article-mode)
13515 (gnus-article-mode))
13518 (set-buffer (get-buffer-create name))
13519 (gnus-add-current-to-buffer-list)
13520 (gnus-article-mode)
13521 (current-buffer)))))
13523 ;; Set article window start at LINE, where LINE is the number of lines
13524 ;; from the head of the article.
13525 (defun gnus-article-set-window-start (&optional line)
13527 (get-buffer-window gnus-article-buffer t)
13529 (set-buffer gnus-article-buffer)
13530 (goto-char (point-min))
13533 (gnus-message 6 "Moved to bookmark")
13534 (search-forward "\n\n" nil t)
13535 (forward-line line)
13538 (defun gnus-kill-all-overlays ()
13539 "Delete all overlays in the current buffer."
13540 (when (fboundp 'overlay-lists)
13541 (let* ((overlayss (overlay-lists))
13542 (buffer-read-only nil)
13543 (overlays (nconc (car overlayss) (cdr overlayss))))
13545 (delete-overlay (pop overlays))))))
13547 (defun gnus-request-article-this-buffer (article group)
13548 "Get an article and insert it into this buffer."
13549 (let (do-update-line)
13553 (gnus-kill-all-overlays)
13554 (setq group (or group gnus-newsgroup-name))
13556 ;; Open server if it has closed.
13557 (gnus-check-server (gnus-find-method-for-group group))
13559 ;; Using `gnus-request-article' directly will insert the article into
13560 ;; `nntp-server-buffer' - so we'll save some time by not having to
13561 ;; copy it from the server buffer into the article buffer.
13563 ;; We only request an article by message-id when we do not have the
13564 ;; headers for it, so we'll have to get those.
13565 (when (stringp article)
13566 (let ((gnus-override-method gnus-refer-article-method))
13567 (gnus-read-header article)))
13569 ;; If the article number is negative, that means that this article
13570 ;; doesn't belong in this newsgroup (possibly), so we find its
13571 ;; message-id and request it by id instead of number.
13572 (when (and (numberp article)
13573 gnus-summary-buffer
13574 (get-buffer gnus-summary-buffer)
13575 (buffer-name (get-buffer gnus-summary-buffer)))
13577 (set-buffer gnus-summary-buffer)
13578 (let ((header (gnus-summary-article-header article)))
13581 ((memq article gnus-newsgroup-sparse)
13582 ;; This is a sparse gap article.
13583 (setq do-update-line article)
13584 (setq article (mail-header-id header))
13585 (let ((gnus-override-method gnus-refer-article-method))
13586 (gnus-read-header article))
13587 (setq gnus-newsgroup-sparse
13588 (delq article gnus-newsgroup-sparse)))
13590 ;; It's a real article.
13591 (setq article (mail-header-id header)))
13593 ;; It is an extracted pseudo-article.
13594 (setq article 'pseudo)
13595 (gnus-request-pseudo-article header))))
13597 (let ((method (gnus-find-method-for-group
13598 gnus-newsgroup-name)))
13599 (if (not (eq (car method) 'nneething))
13601 (let ((dir (concat (file-name-as-directory (nth 1 method))
13602 (mail-header-subject header))))
13603 (if (file-directory-p dir)
13605 (setq article 'nneething)
13606 (gnus-group-enter-directory dir)))))))))
13609 ;; Refuse to select canceled articles.
13610 ((and (numberp article)
13611 gnus-summary-buffer
13612 (get-buffer gnus-summary-buffer)
13613 (buffer-name (get-buffer gnus-summary-buffer))
13614 (eq (cdr (save-excursion
13615 (set-buffer gnus-summary-buffer)
13616 (assq article gnus-newsgroup-reads)))
13617 gnus-canceled-mark))
13619 ;; We first check `gnus-original-article-buffer'.
13620 ((and (get-buffer gnus-original-article-buffer)
13623 (set-buffer gnus-original-article-buffer)
13624 (and (equal (car gnus-original-article) group)
13625 (eq (cdr gnus-original-article) article))))
13626 (insert-buffer-substring gnus-original-article-buffer)
13628 ;; Check the backlog.
13629 ((and gnus-keep-backlog
13630 (gnus-backlog-request-article group article (current-buffer)))
13632 ;; Check the cache.
13633 ((and gnus-use-cache
13635 (gnus-cache-request-article article group))
13637 ;; Get the article and put into the article buffer.
13638 ((or (stringp article) (numberp article))
13639 (let ((gnus-override-method
13640 (and (stringp article) gnus-refer-article-method))
13641 (buffer-read-only nil))
13643 (gnus-kill-all-overlays)
13644 (if (gnus-request-article article group (current-buffer))
13646 (and gnus-keep-backlog
13648 (gnus-backlog-enter-article
13649 group article (current-buffer)))
13651 ;; It was a pseudo.
13654 ;; Take the article from the original article buffer
13655 ;; and place it in the buffer it's supposed to be in.
13656 (when (and (get-buffer gnus-article-buffer)
13657 ;;(numberp article)
13658 (equal (buffer-name (current-buffer))
13659 (buffer-name (get-buffer gnus-article-buffer))))
13661 (if (get-buffer gnus-original-article-buffer)
13662 (set-buffer (get-buffer gnus-original-article-buffer))
13663 (set-buffer (get-buffer-create gnus-original-article-buffer))
13664 (buffer-disable-undo (current-buffer))
13665 (setq major-mode 'gnus-original-article-mode)
13666 (setq buffer-read-only t)
13667 (gnus-add-current-to-buffer-list))
13668 (let (buffer-read-only)
13670 (insert-buffer-substring gnus-article-buffer))
13671 (setq gnus-original-article (cons group article))))
13673 ;; Update sparse articles.
13674 (when (and do-update-line
13675 (or (numberp article)
13676 (stringp article)))
13677 (let ((buf (current-buffer)))
13678 (set-buffer gnus-summary-buffer)
13679 (gnus-summary-update-article do-update-line)
13680 (gnus-summary-goto-subject do-update-line nil t)
13681 (set-window-point (get-buffer-window (current-buffer) t)
13683 (set-buffer buf))))))
13685 (defun gnus-read-header (id &optional header)
13686 "Read the headers of article ID and enter them into the Gnus system."
13687 (let ((group gnus-newsgroup-name)
13688 (gnus-override-method
13689 (and (gnus-news-group-p gnus-newsgroup-name)
13690 gnus-refer-article-method))
13692 ;; First we check to see whether the header in question is already
13695 ;; This is a Message-ID.
13696 (setq header (or header (gnus-id-to-header id)))
13697 ;; This is an article number.
13698 (setq header (or header (gnus-summary-article-header id))))
13700 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13701 ;; We have found the header.
13703 ;; We have to really fetch the header to this article.
13705 (if (gnus-check-backend-function 'request-head group)
13706 (gnus-request-head id group)
13707 (gnus-request-article id group)))
13709 (set-buffer nntp-server-buffer)
13710 (and (search-forward "\n\n" nil t)
13711 (delete-region (1- (point)) (point-max)))
13712 (goto-char (point-max))
13714 (goto-char (point-min))
13718 ((cdr where) (cdr where))
13719 (header (mail-header-number header))
13720 (t gnus-reffed-article-number))
13722 (insert " Article retrieved.\n"))
13724 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13725 ; (setcar (gnus-id-to-thread id) nil))
13726 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13727 () ; Malformed head.
13728 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13729 (if (and (stringp id)
13730 (not (string= (gnus-group-real-name group)
13732 ;; If we fetched by Message-ID and the article came
13733 ;; from a different group, we fudge some bogus article
13734 ;; numbers for this article.
13735 (mail-header-set-number header gnus-reffed-article-number))
13736 (decf gnus-reffed-article-number)
13737 (gnus-remove-header (mail-header-number header))
13738 (push header gnus-newsgroup-headers)
13739 (setq gnus-current-headers header)
13740 (push (mail-header-number header) gnus-newsgroup-limit))
13743 (defun gnus-remove-header (number)
13744 "Remove header NUMBER from `gnus-newsgroup-headers'."
13745 (if (and gnus-newsgroup-headers
13746 (= number (mail-header-number (car gnus-newsgroup-headers))))
13747 (pop gnus-newsgroup-headers)
13748 (let ((headers gnus-newsgroup-headers))
13749 (while (and (cdr headers)
13750 (not (= number (mail-header-number (cadr headers)))))
13752 (when (cdr headers)
13753 (setcdr headers (cddr headers))))))
13755 (defun gnus-article-prepare (article &optional all-headers header)
13756 "Prepare ARTICLE in article mode buffer.
13757 ARTICLE should either be an article number or a Message-ID.
13758 If ARTICLE is an id, HEADER should be the article headers.
13759 If ALL-HEADERS is non-nil, no headers are hidden."
13761 ;; Make sure we start in a summary buffer.
13762 (unless (eq major-mode 'gnus-summary-mode)
13763 (set-buffer gnus-summary-buffer))
13764 (setq gnus-summary-buffer (current-buffer))
13765 ;; Make sure the connection to the server is alive.
13766 (unless (gnus-server-opened
13767 (gnus-find-method-for-group gnus-newsgroup-name))
13768 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13769 (gnus-request-group gnus-newsgroup-name t))
13770 (let* ((article (if header (mail-header-number header) article))
13771 (summary-buffer (current-buffer))
13772 (internal-hook gnus-article-internal-prepare-hook)
13773 (group gnus-newsgroup-name)
13776 (gnus-article-setup-buffer)
13777 (set-buffer gnus-article-buffer)
13778 ;; Deactivate active regions.
13779 (when (and (boundp 'transient-mark-mode)
13780 transient-mark-mode)
13781 (setq mark-active nil))
13782 (if (not (setq result (let ((buffer-read-only nil))
13783 (gnus-request-article-this-buffer
13785 ;; There is no such article.
13787 (when (and (numberp article)
13788 (not (memq article gnus-newsgroup-sparse)))
13789 (setq gnus-article-current
13790 (cons gnus-newsgroup-name article))
13791 (set-buffer gnus-summary-buffer)
13792 (setq gnus-current-article article)
13793 (gnus-summary-mark-article article gnus-canceled-mark))
13794 (unless (memq article gnus-newsgroup-sparse)
13796 1 "No such article (may have expired or been canceled)")))
13797 (if (or (eq result 'pseudo) (eq result 'nneething))
13800 (set-buffer summary-buffer)
13801 (setq gnus-last-article gnus-current-article
13802 gnus-newsgroup-history (cons gnus-current-article
13803 gnus-newsgroup-history)
13804 gnus-current-article 0
13805 gnus-current-headers nil
13806 gnus-article-current nil)
13807 (if (eq result 'nneething)
13808 (gnus-configure-windows 'summary)
13809 (gnus-configure-windows 'article))
13810 (gnus-set-global-variables))
13811 (gnus-set-mode-line 'article))
13812 ;; The result from the `request' was an actual article -
13813 ;; or at least some text that is now displayed in the
13815 (if (and (numberp article)
13816 (not (eq article gnus-current-article)))
13817 ;; Seems like a new article has been selected.
13818 ;; `gnus-current-article' must be an article number.
13820 (set-buffer summary-buffer)
13821 (setq gnus-last-article gnus-current-article
13822 gnus-newsgroup-history (cons gnus-current-article
13823 gnus-newsgroup-history)
13824 gnus-current-article article
13825 gnus-current-headers
13826 (gnus-summary-article-header gnus-current-article)
13827 gnus-article-current
13828 (cons gnus-newsgroup-name gnus-current-article))
13829 (unless (vectorp gnus-current-headers)
13830 (setq gnus-current-headers nil))
13831 (gnus-summary-show-thread)
13832 (run-hooks 'gnus-mark-article-hook)
13833 (gnus-set-mode-line 'summary)
13834 (and (gnus-visual-p 'article-highlight 'highlight)
13835 (run-hooks 'gnus-visual-mark-article-hook))
13836 ;; Set the global newsgroup variables here.
13837 ;; Suggested by Jim Sisolak
13838 ;; <sisolak@trans4.neep.wisc.edu>.
13839 (gnus-set-global-variables)
13840 (setq gnus-have-all-headers
13841 (or all-headers gnus-show-all-headers))
13842 (and gnus-use-cache
13843 (vectorp (gnus-summary-article-header article))
13844 (gnus-cache-possibly-enter-article
13846 (gnus-summary-article-header article)
13847 (memq article gnus-newsgroup-marked)
13848 (memq article gnus-newsgroup-dormant)
13849 (memq article gnus-newsgroup-unreads)))))
13850 (when (or (numberp article)
13852 ;; Hooks for getting information from the article.
13853 ;; This hook must be called before being narrowed.
13854 (let (buffer-read-only)
13855 (run-hooks 'internal-hook)
13856 (run-hooks 'gnus-article-prepare-hook)
13857 ;; Decode MIME message.
13859 (if (or (not gnus-strict-mime)
13860 (gnus-fetch-field "Mime-Version"))
13861 (funcall gnus-show-mime-method)
13862 (funcall gnus-decode-encoded-word-method)))
13863 ;; Perform the article display hooks.
13864 (run-hooks 'gnus-article-display-hook))
13866 (goto-char (point-min))
13867 (and gnus-break-pages (gnus-narrow-to-page)))
13868 (gnus-set-mode-line 'article)
13869 (gnus-configure-windows 'article)
13870 (goto-char (point-min))
13873 (defun gnus-article-show-all-headers ()
13874 "Show all article headers in article mode buffer."
13876 (gnus-article-setup-buffer)
13877 (set-buffer gnus-article-buffer)
13878 (let ((buffer-read-only nil))
13879 (gnus-unhide-text (point-min) (point-max)))))
13881 (defun gnus-article-hide-headers-if-wanted ()
13882 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13883 Provided for backwards compatibility."
13884 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13885 gnus-inhibit-hiding
13886 (gnus-article-hide-headers)))
13888 (defsubst gnus-article-header-rank ()
13889 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13890 (let ((list gnus-sorted-header-list)
13893 (when (looking-at (car list))
13895 (setq list (cdr list))
13899 (defun gnus-article-hide-headers (&optional arg delete)
13900 "Toggle whether to hide unwanted headers and possibly sort them as well.
13901 If given a negative prefix, always show; if given a positive prefix,
13903 (interactive (gnus-hidden-arg))
13904 (if (gnus-article-check-hidden-text 'headers arg)
13905 ;; Show boring headers as well.
13906 (gnus-article-show-hidden-text 'boring-headers)
13907 ;; This function might be inhibited.
13908 (unless gnus-inhibit-hiding
13910 (set-buffer gnus-article-buffer)
13912 (let ((buffer-read-only nil)
13913 (props (nconc (list 'gnus-type 'headers)
13914 gnus-hidden-properties))
13915 (max (1+ (length gnus-sorted-header-list)))
13916 (ignored (when (not (stringp gnus-visible-headers))
13917 (cond ((stringp gnus-ignored-headers)
13918 gnus-ignored-headers)
13919 ((listp gnus-ignored-headers)
13920 (mapconcat 'identity gnus-ignored-headers
13923 (cond ((stringp gnus-visible-headers)
13924 gnus-visible-headers)
13925 ((and gnus-visible-headers
13926 (listp gnus-visible-headers))
13927 (mapconcat 'identity gnus-visible-headers "\\|"))))
13928 (inhibit-point-motion-hooks t)
13930 ;; First we narrow to just the headers.
13932 (goto-char (point-min))
13933 ;; Hide any "From " lines at the beginning of (mail) articles.
13934 (while (looking-at "From ")
13938 (delete-region (point-min) (point))
13939 (gnus-hide-text (point-min) (point) props)))
13940 ;; Then treat the rest of the header lines.
13943 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13944 ;; Then we use the two regular expressions
13945 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13946 ;; select which header lines is to remain visible in the
13948 (goto-char (point-min))
13949 (while (re-search-forward "^[^ \t]*:" nil t)
13950 (beginning-of-line)
13951 ;; We add the headers we want to keep to a list and delete
13952 ;; them from the buffer.
13953 (gnus-put-text-property
13954 (point) (1+ (point)) 'message-rank
13955 (if (or (and visible (looking-at visible))
13957 (not (looking-at ignored))))
13958 (gnus-article-header-rank)
13961 (message-sort-headers-1)
13962 (when (setq beg (text-property-any
13963 (point-min) (point-max) 'message-rank (+ 2 max)))
13964 ;; We make the unwanted headers invisible.
13966 (delete-region beg (point-max))
13967 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13968 (gnus-hide-text-type beg (point-max) 'headers))
13969 ;; Work around XEmacs lossage.
13970 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13972 (defun gnus-article-hide-boring-headers (&optional arg)
13973 "Toggle hiding of headers that aren't very interesting.
13974 If given a negative prefix, always show; if given a positive prefix,
13976 (interactive (gnus-hidden-arg))
13977 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13979 (set-buffer gnus-article-buffer)
13981 (let ((buffer-read-only nil)
13982 (list gnus-boring-article-headers)
13983 (inhibit-point-motion-hooks t)
13985 (nnheader-narrow-to-headers)
13987 (setq elem (pop list))
13988 (goto-char (point-min))
13990 ;; Hide empty headers.
13992 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13994 (gnus-hide-text-type
13995 (progn (beginning-of-line) (point))
13998 (if (re-search-forward "^[^ \t]" nil t)
13999 (match-beginning 0)
14002 ;; Hide boring Newsgroups header.
14003 ((eq elem 'newsgroups)
14004 (when (equal (message-fetch-field "newsgroups")
14005 (gnus-group-real-name gnus-newsgroup-name))
14006 (gnus-article-hide-header "newsgroups")))
14007 ((eq elem 'followup-to)
14008 (when (equal (message-fetch-field "followup-to")
14009 (message-fetch-field "newsgroups"))
14010 (gnus-article-hide-header "followup-to")))
14011 ((eq elem 'reply-to)
14012 (let ((from (message-fetch-field "from"))
14013 (reply-to (message-fetch-field "reply-to")))
14017 (nth 1 (funcall gnus-extract-address-components from))
14018 (nth 1 (funcall gnus-extract-address-components
14020 (gnus-article-hide-header "reply-to"))))
14022 (let ((date (message-fetch-field "date")))
14024 (< (gnus-days-between date (current-time-string))
14026 (gnus-article-hide-header "date")))))))))))
14028 (defun gnus-article-hide-header (header)
14030 (goto-char (point-min))
14031 (when (re-search-forward (concat "^" header ":") nil t)
14032 (gnus-hide-text-type
14033 (progn (beginning-of-line) (point))
14036 (if (re-search-forward "^[^ \t]" nil t)
14037 (match-beginning 0)
14039 'boring-headers))))
14041 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14042 (defun gnus-article-treat-overstrike ()
14043 "Translate overstrikes into bold text."
14046 (set-buffer gnus-article-buffer)
14047 (let ((buffer-read-only nil))
14048 (while (search-forward "\b" nil t)
14049 (let ((next (following-char))
14050 (previous (char-after (- (point) 2))))
14052 ((eq next previous)
14053 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14054 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14056 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14057 (gnus-put-text-property
14058 (- (point) 2) (1- (point)) 'face 'underline))
14060 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14061 (gnus-put-text-property
14062 (point) (1+ (point)) 'face 'underline))))))))
14064 (defun gnus-article-word-wrap ()
14065 "Format too long lines."
14068 (set-buffer gnus-article-buffer)
14069 (let ((buffer-read-only nil))
14071 (goto-char (point-min))
14072 (search-forward "\n\n" nil t)
14074 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14075 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14076 (adaptive-fill-mode t))
14077 (while (not (eobp))
14078 (and (>= (current-column) (min fill-column (window-width)))
14079 (/= (preceding-char) ?:)
14080 (fill-paragraph nil))
14081 (end-of-line 2))))))
14083 (defun gnus-article-remove-cr ()
14084 "Remove carriage returns from an article."
14087 (set-buffer gnus-article-buffer)
14088 (let ((buffer-read-only nil))
14089 (goto-char (point-min))
14090 (while (search-forward "\r" nil t)
14091 (replace-match "" t t)))))
14093 (defun gnus-article-remove-trailing-blank-lines ()
14094 "Remove all trailing blank lines from the article."
14097 (set-buffer gnus-article-buffer)
14098 (let ((buffer-read-only nil))
14099 (goto-char (point-max))
14103 (while (looking-at "^[ \t]*$")
14108 (defun gnus-article-display-x-face (&optional force)
14109 "Look for an X-Face header and display it if present."
14110 (interactive (list 'force))
14112 (set-buffer gnus-article-buffer)
14113 ;; Delete the old process, if any.
14114 (when (process-status "gnus-x-face")
14115 (delete-process "gnus-x-face"))
14116 (let ((inhibit-point-motion-hooks t)
14117 (case-fold-search nil)
14120 (nnheader-narrow-to-headers)
14121 (setq from (message-fetch-field "from"))
14122 (goto-char (point-min))
14123 (when (and gnus-article-x-face-command
14125 ;; Check whether this face is censored.
14126 (not gnus-article-x-face-too-ugly)
14127 (and gnus-article-x-face-too-ugly from
14128 (not (string-match gnus-article-x-face-too-ugly
14130 ;; Has to be present.
14131 (re-search-forward "^X-Face: " nil t))
14132 ;; We now have the area of the buffer where the X-Face is stored.
14133 (let ((beg (point))
14134 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14135 ;; We display the face.
14136 (if (symbolp gnus-article-x-face-command)
14137 ;; The command is a lisp function, so we call it.
14138 (if (gnus-functionp gnus-article-x-face-command)
14139 (funcall gnus-article-x-face-command beg end)
14140 (error "%s is not a function" gnus-article-x-face-command))
14141 ;; The command is a string, so we interpret the command
14142 ;; as a, well, command, and fork it off.
14143 (let ((process-connection-type nil))
14144 (process-kill-without-query
14146 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14147 (process-send-region "gnus-x-face" beg end)
14148 (process-send-eof "gnus-x-face")))))))))
14150 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14151 (defun gnus-decode-rfc1522 ()
14152 "Hack to remove QP encoding from headers."
14153 (let ((case-fold-search t)
14154 (inhibit-point-motion-hooks t)
14155 (buffer-read-only nil)
14159 (goto-char (point-min))
14160 (or (search-forward "\n\n" nil t) (point-max)))
14162 (while (re-search-forward
14163 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14164 (setq string (match-string 1))
14165 (narrow-to-region (match-beginning 0) (match-end 0))
14166 (delete-region (point-min) (point-max))
14168 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14169 (subst-char-in-region (point-min) (point-max) ?_ ? )
14171 (goto-char (point-min))))))
14173 (defun gnus-article-de-quoted-unreadable (&optional force)
14174 "Do a naive translation of a quoted-printable-encoded article.
14175 This is in no way, shape or form meant as a replacement for real MIME
14176 processing, but is simply a stop-gap measure until MIME support is
14178 If FORCE, decode the article whether it is marked as quoted-printable
14180 (interactive (list 'force))
14182 (set-buffer gnus-article-buffer)
14183 (let ((case-fold-search t)
14184 (buffer-read-only nil)
14185 (type (gnus-fetch-field "content-transfer-encoding")))
14186 (gnus-decode-rfc1522)
14188 (and type (string-match "quoted-printable" (downcase type))))
14189 (goto-char (point-min))
14190 (search-forward "\n\n" nil 'move)
14191 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14193 (defun gnus-mime-decode-quoted-printable (from to)
14194 "Decode Quoted-Printable in the region between FROM and TO."
14197 (while (search-forward "=" to t)
14198 (cond ((eq (following-char) ?\n)
14201 ((looking-at "[0-9A-F][0-9A-F]")
14202 (subst-char-in-region
14203 (1- (point)) (point) ?=
14204 (hexl-hex-string-to-integer
14205 (buffer-substring (point) (+ 2 (point)))))
14209 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14211 (defun gnus-article-hide-pgp (&optional arg)
14212 "Toggle hiding of any PGP headers and signatures in the current article.
14213 If given a negative prefix, always show; if given a positive prefix,
14215 (interactive (gnus-hidden-arg))
14216 (unless (gnus-article-check-hidden-text 'pgp arg)
14218 (set-buffer gnus-article-buffer)
14219 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14220 buffer-read-only beg end)
14222 (goto-char (point-min))
14223 ;; Hide the "header".
14224 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14225 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14227 ;; Hide the actual signature.
14228 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14229 (setq end (1+ (match-beginning 0)))
14232 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14234 ;; Perhaps we shouldn't hide to the end of the buffer
14235 ;; if there is no end to the signature?
14238 ;; Hide "- " PGP quotation markers.
14239 (when (and beg end)
14240 (narrow-to-region beg end)
14241 (goto-char (point-min))
14242 (while (re-search-forward "^- " nil t)
14243 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14246 (defun gnus-article-hide-signature (&optional arg)
14247 "Hide the signature in the current article.
14248 If given a negative prefix, always show; if given a positive prefix,
14250 (interactive (gnus-hidden-arg))
14251 (unless (gnus-article-check-hidden-text 'signature arg)
14253 (set-buffer gnus-article-buffer)
14255 (let ((buffer-read-only nil))
14256 (when (gnus-narrow-to-signature)
14257 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14259 (defun gnus-article-strip-leading-blank-lines ()
14260 "Remove all blank lines from the beginning of the article."
14263 (set-buffer gnus-article-buffer)
14264 (let (buffer-read-only)
14265 (goto-char (point-min))
14266 (when (search-forward "\n\n" nil t)
14267 (while (looking-at "[ \t]$")
14268 (gnus-delete-line))))))
14270 (defvar mime::preview/content-list)
14271 (defvar mime::preview-content-info/point-min)
14272 (defun gnus-narrow-to-signature ()
14273 "Narrow to the signature."
14275 (if (and (boundp 'mime::preview/content-list)
14276 mime::preview/content-list)
14277 (let ((pcinfo (car (last mime::preview/content-list))))
14279 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14282 (goto-char (point-max))
14283 (when (re-search-backward gnus-signature-separator nil t)
14285 (when (or (null gnus-signature-limit)
14286 (and (numberp gnus-signature-limit)
14287 (< (- (point-max) (point)) gnus-signature-limit))
14288 (and (gnus-functionp gnus-signature-limit)
14289 (funcall gnus-signature-limit))
14290 (and (stringp gnus-signature-limit)
14291 (not (re-search-forward gnus-signature-limit nil t))))
14292 (narrow-to-region (point) (point-max))
14295 (defun gnus-hidden-arg ()
14296 "Return the current prefix arg as a number, or 0 if no prefix."
14297 (list (if current-prefix-arg
14298 (prefix-numeric-value current-prefix-arg)
14301 (defun gnus-article-check-hidden-text (type arg)
14302 "Return nil if hiding is necessary.
14303 Arg can be nil or a number. Nil and positive means hide, negative
14304 means show, 0 means toggle."
14306 (set-buffer gnus-article-buffer)
14307 (let ((hide (gnus-article-hidden-text-p type)))
14313 (gnus-article-show-hidden-text type))
14315 (if (eq hide 'hidden)
14316 (gnus-article-show-hidden-text type)
14319 (defun gnus-article-hidden-text-p (type)
14320 "Say whether the current buffer contains hidden text of type TYPE."
14321 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14323 (if (get-text-property pos 'invisible)
14327 (defun gnus-article-hide (&optional arg force)
14328 "Hide all the gruft in the current article.
14329 This means that PGP stuff, signatures, cited text and (some)
14330 headers will be hidden.
14331 If given a prefix, show the hidden text instead."
14332 (interactive (list current-prefix-arg 'force))
14333 (gnus-article-hide-headers arg)
14334 (gnus-article-hide-pgp arg)
14335 (gnus-article-hide-citation-maybe arg force)
14336 (gnus-article-hide-signature arg))
14338 (defun gnus-article-show-hidden-text (type &optional hide)
14339 "Show all hidden text of type TYPE.
14340 If HIDE, hide the text instead."
14342 (set-buffer gnus-article-buffer)
14343 (let ((buffer-read-only nil)
14344 (inhibit-point-motion-hooks t)
14346 (while (gnus-goto-char (text-property-any
14347 beg (point-max) 'gnus-type type))
14351 (gnus-hide-text beg (point) gnus-hidden-properties)
14352 (gnus-unhide-text beg (point)))
14353 (setq beg (point)))
14356 (defvar gnus-article-time-units
14357 `((year . ,(* 365.25 24 60 60))
14358 (week . ,(* 7 24 60 60))
14359 (day . ,(* 24 60 60))
14360 (hour . ,(* 60 60))
14363 "Mapping from time units to seconds.")
14365 (defun gnus-article-date-ut (&optional type highlight)
14366 "Convert DATE date to universal time in the current article.
14367 If TYPE is `local', convert to local time; if it is `lapsed', output
14368 how much time has lapsed since DATE."
14369 (interactive (list 'ut t))
14370 (let* ((header (or gnus-current-headers
14371 (gnus-summary-article-header) ""))
14372 (date (and (vectorp header) (mail-header-date header)))
14373 (date-regexp "^Date: \\|^X-Sent: ")
14374 (now (current-time))
14375 (inhibit-point-motion-hooks t)
14377 (when (and date (not (string= date "")))
14379 (set-buffer gnus-article-buffer)
14381 (nnheader-narrow-to-headers)
14382 (let ((buffer-read-only nil))
14383 ;; Delete any old Date headers.
14384 (if (re-search-forward date-regexp nil t)
14386 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14387 eface (get-text-property (1- (gnus-point-at-eol))
14389 (message-remove-header date-regexp t)
14390 (beginning-of-line))
14391 (goto-char (point-max)))
14392 (insert (gnus-make-date-line date type))
14393 ;; Do highlighting.
14395 (when (and (gnus-visual-p 'article-highlight 'highlight)
14396 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14397 (gnus-put-text-property (match-beginning 1) (match-end 1)
14399 (gnus-put-text-property (match-beginning 2) (match-end 2)
14400 'face eface))))))))
14402 (defun gnus-make-date-line (date type)
14403 "Return a DATE line of TYPE."
14405 ;; Convert to the local timezone. We have to slap a
14406 ;; `condition-case' round the calls to the timezone
14407 ;; functions since they aren't particularly resistant to
14410 (concat "Date: " (condition-case ()
14411 (timezone-make-date-arpa-standard date)
14414 ;; Convert to Universal Time.
14418 (timezone-make-date-arpa-standard date nil "UT")
14421 ;; Get the original date from the article.
14422 ((eq type 'original)
14423 (concat "Date: " date "\n"))
14424 ;; Do an X-Sent lapsed format.
14426 ;; If the date is seriously mangled, the timezone
14427 ;; functions are liable to bug out, so we condition-case
14428 ;; the entire thing.
14429 (let* ((now (current-time))
14434 (timezone-make-date-arpa-standard
14435 (current-time-string now)
14436 (current-time-zone now) "UT"))
14438 (timezone-make-date-arpa-standard
14441 (real-sec (+ (* (float (car real-time)) 65536)
14443 (sec (abs real-sec))
14446 ((equal real-time '(0 0))
14447 "X-Sent: Unknown\n")
14453 ;; This is a bit convoluted, but basically we go
14454 ;; through the time units for years, weeks, etc,
14455 ;; and divide things to see whether that results
14456 ;; in positive answers.
14459 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14460 ;; The (remaining) seconds are too few to
14461 ;; be divided into this time unit.
14463 ;; It's big enough, so we output it.
14464 (setq sec (- sec (* num (cdr unit))))
14466 (concat (if prev ", " "") (int-to-string
14468 " " (symbol-name (car unit))
14469 (if (> num 1) "s" ""))
14471 gnus-article-time-units "")
14472 ;; If dates are odd, then it might appear like the
14473 ;; article was sent in the future.
14476 " in the future\n"))))))
14478 (error "Unknown conversion type: %s" type))))
14480 (defun gnus-article-date-local (&optional highlight)
14481 "Convert the current article date to the local timezone."
14482 (interactive (list t))
14483 (gnus-article-date-ut 'local highlight))
14485 (defun gnus-article-date-original (&optional highlight)
14486 "Convert the current article date to what it was originally.
14487 This is only useful if you have used some other date conversion
14488 function and want to see what the date was before converting."
14489 (interactive (list t))
14490 (gnus-article-date-ut 'original highlight))
14492 (defun gnus-article-date-lapsed (&optional highlight)
14493 "Convert the current article date to time lapsed since it was sent."
14494 (interactive (list t))
14495 (gnus-article-date-ut 'lapsed highlight))
14497 (defun gnus-article-maybe-highlight ()
14498 "Do some article highlighting if `gnus-visual' is non-nil."
14499 (if (gnus-visual-p 'article-highlight 'highlight)
14500 (gnus-article-highlight-some)))
14502 ;;; Article savers.
14504 (defun gnus-output-to-rmail (file-name)
14505 "Append the current article to an Rmail file named FILE-NAME."
14507 ;; Most of these codes are borrowed from rmailout.el.
14508 (setq file-name (expand-file-name file-name))
14509 (setq rmail-default-rmail-file file-name)
14510 (let ((artbuf (current-buffer))
14511 (tmpbuf (get-buffer-create " *Gnus-output*")))
14513 (or (get-file-buffer file-name)
14514 (file-exists-p file-name)
14515 (if (gnus-yes-or-no-p
14516 (concat "\"" file-name "\" does not exist, create it? "))
14517 (let ((file-buffer (create-file-buffer file-name)))
14519 (set-buffer file-buffer)
14520 (rmail-insert-rmail-file-header)
14521 (let ((require-final-newline nil))
14522 (write-region (point-min) (point-max) file-name t 1)))
14523 (kill-buffer file-buffer))
14524 (error "Output file does not exist")))
14525 (set-buffer tmpbuf)
14526 (buffer-disable-undo (current-buffer))
14528 (insert-buffer-substring artbuf)
14529 (gnus-convert-article-to-rmail)
14530 ;; Decide whether to append to a file or to an Emacs buffer.
14531 (let ((outbuf (get-file-buffer file-name)))
14533 (append-to-file (point-min) (point-max) file-name)
14534 ;; File has been visited, in buffer OUTBUF.
14535 (set-buffer outbuf)
14536 (let ((buffer-read-only nil)
14537 (msg (and (boundp 'rmail-current-message)
14538 (symbol-value 'rmail-current-message))))
14539 ;; If MSG is non-nil, buffer is in RMAIL mode.
14542 (narrow-to-region (point-max) (point-max))))
14543 (insert-buffer-substring tmpbuf)
14546 (goto-char (point-min))
14548 (search-backward "\^_")
14549 (narrow-to-region (point) (point-max))
14550 (goto-char (1+ (point-min)))
14551 (rmail-count-new-messages t)
14552 (rmail-show-message msg)))))))
14553 (kill-buffer tmpbuf)))
14555 (defun gnus-output-to-file (file-name)
14556 "Append the current article to a file named FILE-NAME."
14557 (let ((artbuf (current-buffer)))
14558 (nnheader-temp-write nil
14559 (insert-buffer-substring artbuf)
14560 ;; Append newline at end of the buffer as separator, and then
14561 ;; save it to file.
14562 (goto-char (point-max))
14564 (append-to-file (point-min) (point-max) file-name))))
14566 (defun gnus-convert-article-to-rmail ()
14567 "Convert article in current buffer to Rmail message format."
14568 (let ((buffer-read-only nil))
14569 ;; Convert article directly into Babyl format.
14570 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14571 (goto-char (point-min))
14572 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14573 (while (search-forward "\n\^_" nil t) ;single char
14574 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14575 (goto-char (point-max))
14578 (defun gnus-narrow-to-page (&optional arg)
14579 "Narrow the article buffer to a page.
14580 If given a numerical ARG, move forward ARG pages."
14582 (setq arg (if arg (prefix-numeric-value arg) 0))
14584 (set-buffer gnus-article-buffer)
14585 (goto-char (point-min))
14587 (when (gnus-visual-p 'page-marker)
14588 (let ((buffer-read-only nil))
14589 (gnus-remove-text-with-property 'gnus-prev)
14590 (gnus-remove-text-with-property 'gnus-next)))
14593 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14595 (re-search-forward page-delimiter nil 'move arg)))
14596 (goto-char (match-end 0)))
14599 (if (re-search-forward page-delimiter nil 'move)
14600 (match-beginning 0)
14602 (when (and (gnus-visual-p 'page-marker)
14603 (not (= (point-min) 1)))
14605 (goto-char (point-min))
14606 (gnus-insert-prev-page-button)))
14607 (when (and (gnus-visual-p 'page-marker)
14608 (not (= (1- (point-max)) (buffer-size))))
14610 (goto-char (point-max))
14611 (gnus-insert-next-page-button)))))
14613 ;; Article mode commands
14615 (defun gnus-article-goto-next-page ()
14616 "Show the next page of the article."
14618 (when (gnus-article-next-page)
14619 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14621 (defun gnus-article-goto-prev-page ()
14622 "Show the next page of the article."
14624 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14625 (gnus-article-prev-page nil)))
14627 (defun gnus-article-next-page (&optional lines)
14628 "Show the next page of the current article.
14629 If end of article, return non-nil. Otherwise return nil.
14630 Argument LINES specifies lines to be scrolled up."
14632 (move-to-window-line -1)
14633 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14634 (if (save-excursion
14636 (and (pos-visible-in-window-p) ;Not continuation line.
14638 ;; Nothing in this page.
14639 (if (or (not gnus-break-pages)
14642 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14644 (gnus-narrow-to-page 1) ;Go to next page.
14646 ;; More in this page.
14650 ;; Long lines may cause an end-of-buffer error.
14651 (goto-char (point-max))))
14652 (move-to-window-line 0)
14655 (defun gnus-article-prev-page (&optional lines)
14656 "Show previous page of current article.
14657 Argument LINES specifies lines to be scrolled down."
14659 (move-to-window-line 0)
14660 (if (and gnus-break-pages
14662 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14664 (gnus-narrow-to-page -1) ;Go to previous page.
14665 (goto-char (point-max))
14669 (scroll-down lines)
14671 (move-to-window-line 0))))
14673 (defun gnus-article-refer-article ()
14674 "Read article specified by message-id around point."
14676 (let ((point (point)))
14677 (search-forward ">" nil t) ;Move point to end of "<....>".
14678 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14679 (let ((message-id (match-string 1)))
14681 (set-buffer gnus-summary-buffer)
14682 (gnus-summary-refer-article message-id))
14683 (goto-char (point))
14684 (error "No references around point"))))
14686 (defun gnus-article-show-summary ()
14687 "Reconfigure windows to show summary buffer."
14689 (gnus-configure-windows 'article)
14690 (gnus-summary-goto-subject gnus-current-article))
14692 (defun gnus-article-describe-briefly ()
14693 "Describe article mode commands briefly."
14696 (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")))
14698 (defun gnus-article-summary-command ()
14699 "Execute the last keystroke in the summary buffer."
14701 (let ((obuf (current-buffer))
14702 (owin (current-window-configuration))
14704 (switch-to-buffer gnus-summary-buffer 'norecord)
14705 (setq func (lookup-key (current-local-map) (this-command-keys)))
14706 (call-interactively func)
14708 (set-window-configuration owin)
14709 (set-window-point (get-buffer-window (current-buffer)) (point))))
14711 (defun gnus-article-summary-command-nosave ()
14712 "Execute the last keystroke in the summary buffer."
14715 (pop-to-buffer gnus-summary-buffer 'norecord)
14716 (setq func (lookup-key (current-local-map) (this-command-keys)))
14717 (call-interactively func)))
14719 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14720 "Read a summary buffer key sequence and execute it from the article buffer."
14723 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14724 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14725 "=" "^" "\M-^" "|"))
14728 (set-buffer gnus-summary-buffer)
14729 (push (or key last-command-event) unread-command-events)
14730 (setq keys (read-key-sequence nil)))
14733 (if (member keys nosaves)
14735 (pop-to-buffer gnus-summary-buffer 'norecord)
14736 (if (setq func (lookup-key (current-local-map) keys))
14737 (call-interactively func)
14739 (let ((obuf (current-buffer))
14740 (owin (current-window-configuration))
14743 (if not-restore-window
14744 (pop-to-buffer gnus-summary-buffer 'norecord)
14745 (switch-to-buffer gnus-summary-buffer 'norecord))
14746 (setq in-buffer (current-buffer))
14747 (if (setq func (lookup-key (current-local-map) keys))
14748 (call-interactively func)
14750 (when (eq in-buffer (current-buffer))
14752 (unless not-restore-window
14753 (set-window-configuration owin))
14754 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14758 ;;; Kill file handling.
14762 (defalias 'gnus-batch-kill 'gnus-batch-score)
14764 (defun gnus-batch-score ()
14765 "Run batched scoring.
14766 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14767 Newsgroups is a list of strings in Bnews format. If you want to score
14768 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14769 score the alt hierarchy, you'd say \"!alt.all\"."
14772 (gnus-newsrc-parse-options
14773 (apply (function concat)
14774 (mapcar (lambda (g) (concat g " "))
14775 command-line-args-left))))
14776 (gnus-expert-user t)
14777 (nnmail-spool-file nil)
14778 (gnus-use-dribble-file nil)
14779 (yes (car yes-and-no))
14780 (no (cdr yes-and-no))
14782 ;; Disable verbose message.
14783 gnus-novice-user gnus-large-newsgroup)
14784 ;; Eat all arguments.
14785 (setq command-line-args-left nil)
14788 ;; Apply kills to specified newsgroups in command line arguments.
14789 (setq newsrc (cdr gnus-newsrc-alist))
14791 (setq group (caar newsrc))
14792 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14793 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14795 (or (eq (car entry) t)
14796 (not (zerop (car entry)))))
14797 (if yes (string-match yes group) t)
14798 (or (null no) (not (string-match no group))))
14800 (gnus-summary-read-group group nil t nil t)
14801 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14802 (gnus-summary-exit))))
14803 (setq newsrc (cdr newsrc)))
14805 (switch-to-buffer gnus-group-buffer)
14806 (gnus-group-save-newsrc)))
14808 (defun gnus-apply-kill-file ()
14809 "Apply a kill file to the current newsgroup.
14810 Returns the number of articles marked as read."
14811 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14812 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14813 (gnus-apply-kill-file-internal)
14816 (defun gnus-kill-save-kill-buffer ()
14817 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14818 (when (get-file-buffer file)
14820 (set-buffer (get-file-buffer file))
14821 (and (buffer-modified-p) (save-buffer))
14822 (kill-buffer (current-buffer))))))
14824 (defvar gnus-kill-file-name "KILL"
14825 "Suffix of the kill files.")
14827 (defun gnus-newsgroup-kill-file (newsgroup)
14828 "Return the name of a kill file name for NEWSGROUP.
14829 If NEWSGROUP is nil, return the global kill file name instead."
14831 ;; The global KILL file is placed at top of the directory.
14832 ((or (null newsgroup)
14833 (string-equal newsgroup ""))
14834 (expand-file-name gnus-kill-file-name
14835 gnus-kill-files-directory))
14836 ;; Append ".KILL" to newsgroup name.
14837 ((gnus-use-long-file-name 'not-kill)
14838 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14839 "." gnus-kill-file-name)
14840 gnus-kill-files-directory))
14841 ;; Place "KILL" under the hierarchical directory.
14843 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14844 "/" gnus-kill-file-name)
14845 gnus-kill-files-directory))))
14852 (defvar gnus-dribble-ignore nil)
14853 (defvar gnus-dribble-eval-file nil)
14855 (defun gnus-dribble-file-name ()
14856 "Return the dribble file for the current .newsrc."
14858 (if gnus-dribble-directory
14859 (concat (file-name-as-directory gnus-dribble-directory)
14860 (file-name-nondirectory gnus-current-startup-file))
14861 gnus-current-startup-file)
14864 (defun gnus-dribble-enter (string)
14865 "Enter STRING into the dribble buffer."
14866 (if (and (not gnus-dribble-ignore)
14867 gnus-dribble-buffer
14868 (buffer-name gnus-dribble-buffer))
14869 (let ((obuf (current-buffer)))
14870 (set-buffer gnus-dribble-buffer)
14871 (insert string "\n")
14872 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14873 (set-buffer obuf))))
14875 (defun gnus-dribble-read-file ()
14876 "Read the dribble file from disk."
14877 (let ((dribble-file (gnus-dribble-file-name)))
14879 (set-buffer (setq gnus-dribble-buffer
14881 (file-name-nondirectory dribble-file))))
14882 (gnus-add-current-to-buffer-list)
14884 (setq buffer-file-name dribble-file)
14886 (buffer-disable-undo (current-buffer))
14887 (bury-buffer (current-buffer))
14888 (set-buffer-modified-p nil)
14889 (let ((auto (make-auto-save-file-name))
14890 (gnus-dribble-ignore t)
14892 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14893 ;; Load whichever file is newest -- the auto save file
14894 ;; or the "real" file.
14895 (if (file-newer-than-file-p auto dribble-file)
14896 (insert-file-contents auto)
14897 (insert-file-contents dribble-file))
14898 (unless (zerop (buffer-size))
14899 (set-buffer-modified-p t))
14900 ;; Set the file modes to reflect the .newsrc file modes.
14902 (when (and (file-exists-p gnus-current-startup-file)
14903 (setq modes (file-modes gnus-current-startup-file)))
14904 (set-file-modes dribble-file modes))
14905 ;; Possibly eval the file later.
14906 (when (gnus-y-or-n-p
14907 "Auto-save file exists. Do you want to read it? ")
14908 (setq gnus-dribble-eval-file t)))))))
14910 (defun gnus-dribble-eval-file ()
14911 (when gnus-dribble-eval-file
14912 (setq gnus-dribble-eval-file nil)
14914 (let ((gnus-dribble-ignore t))
14915 (set-buffer gnus-dribble-buffer)
14916 (eval-buffer (current-buffer))))))
14918 (defun gnus-dribble-delete-file ()
14919 (when (file-exists-p (gnus-dribble-file-name))
14920 (delete-file (gnus-dribble-file-name)))
14921 (when gnus-dribble-buffer
14923 (set-buffer gnus-dribble-buffer)
14924 (let ((auto (make-auto-save-file-name)))
14925 (if (file-exists-p auto)
14926 (delete-file auto))
14928 (set-buffer-modified-p nil)))))
14930 (defun gnus-dribble-save ()
14931 (when (and gnus-dribble-buffer
14932 (buffer-name gnus-dribble-buffer))
14934 (set-buffer gnus-dribble-buffer)
14937 (defun gnus-dribble-clear ()
14938 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14940 (set-buffer gnus-dribble-buffer)
14942 (set-buffer-modified-p nil)
14943 (setq buffer-saved-size (buffer-size)))))
14947 ;;; Server Communication
14950 (defun gnus-start-news-server (&optional confirm)
14951 "Open a method for getting news.
14952 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14954 (if gnus-current-select-method
14955 ;; Stream is already opened.
14957 ;; Open NNTP server.
14958 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14961 ;; Read server name with completion.
14962 (setq gnus-nntp-server
14963 (completing-read "NNTP server: "
14964 (mapcar (lambda (server) (list server))
14965 (cons (list gnus-nntp-server)
14966 gnus-secondary-servers))
14967 nil nil gnus-nntp-server))))
14969 (if (and gnus-nntp-server
14970 (stringp gnus-nntp-server)
14971 (not (string= gnus-nntp-server "")))
14972 (setq gnus-select-method
14973 (cond ((or (string= gnus-nntp-server "")
14974 (string= gnus-nntp-server "::"))
14975 (list 'nnspool (system-name)))
14976 ((string-match "^:" gnus-nntp-server)
14977 (list 'nnmh gnus-nntp-server
14978 (list 'nnmh-directory
14979 (file-name-as-directory
14981 (concat "~/" (substring
14982 gnus-nntp-server 1)))))
14983 (list 'nnmh-get-new-mail nil)))
14985 (list 'nntp gnus-nntp-server)))))
14987 (setq how (car gnus-select-method))
14988 (cond ((eq how 'nnspool)
14990 (gnus-message 5 "Looking up local news spool..."))
14993 (gnus-message 5 "Looking up mh spool..."))
14996 (setq gnus-current-select-method gnus-select-method)
14997 (run-hooks 'gnus-open-server-hook)
14999 ;; gnus-open-server-hook might have opened it
15000 (gnus-server-opened gnus-select-method)
15001 (gnus-open-server gnus-select-method)
15004 "%s (%s) open error: '%s'. Continue? "
15005 (car gnus-select-method) (cadr gnus-select-method)
15006 (gnus-status-message gnus-select-method)))
15007 (gnus-error 1 "Couldn't open server on %s"
15008 (nth 1 gnus-select-method))))))
15010 (defun gnus-check-group (group)
15011 "Try to make sure that the server where GROUP exists is alive."
15012 (let ((method (gnus-find-method-for-group group)))
15013 (or (gnus-server-opened method)
15014 (gnus-open-server method))))
15016 (defun gnus-check-server (&optional method silent)
15017 "Check whether the connection to METHOD is down.
15018 If METHOD is nil, use `gnus-select-method'.
15019 If it is down, start it up (again)."
15020 (let ((method (or method gnus-select-method)))
15021 ;; Transform virtual server names into select methods.
15022 (when (stringp method)
15023 (setq method (gnus-server-to-method method)))
15024 (if (gnus-server-opened method)
15025 ;; The stream is already opened.
15027 ;; Open the server.
15029 (gnus-message 5 "Opening %s server%s..." (car method)
15030 (if (equal (nth 1 method) "") ""
15031 (format " on %s" (nth 1 method)))))
15032 (run-hooks 'gnus-open-server-hook)
15034 (gnus-open-server method)
15038 (defun gnus-get-function (method function)
15039 "Return a function symbol based on METHOD and FUNCTION."
15040 ;; Translate server names into methods.
15042 (error "Attempted use of a nil select method"))
15043 (when (stringp method)
15044 (setq method (gnus-server-to-method method)))
15045 (let ((func (intern (format "%s-%s" (car method) function))))
15046 ;; If the functions isn't bound, we require the backend in
15048 (unless (fboundp func)
15049 (require (car method))
15050 (unless (fboundp func)
15051 ;; This backend doesn't implement this function.
15052 (error "No such function: %s" func)))
15057 ;;; Interface functions to the backends.
15060 (defun gnus-open-server (method)
15061 "Open a connection to METHOD."
15062 (when (stringp method)
15063 (setq method (gnus-server-to-method method)))
15064 (let ((elem (assoc method gnus-opened-servers)))
15065 ;; If this method was previously denied, we just return nil.
15066 (if (eq (nth 1 elem) 'denied)
15068 (gnus-message 1 "Denied server")
15070 ;; Open the server.
15072 (funcall (gnus-get-function method 'open-server)
15073 (nth 1 method) (nthcdr 2 method))))
15074 ;; If this hasn't been opened before, we add it to the list.
15076 (setq elem (list method nil)
15077 gnus-opened-servers (cons elem gnus-opened-servers)))
15078 ;; Set the status of this server.
15079 (setcar (cdr elem) (if result 'ok 'denied))
15080 ;; Return the result from the "open" call.
15083 (defun gnus-close-server (method)
15084 "Close the connection to METHOD."
15085 (when (stringp method)
15086 (setq method (gnus-server-to-method method)))
15087 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15089 (defun gnus-request-list (method)
15090 "Request the active file from METHOD."
15091 (when (stringp method)
15092 (setq method (gnus-server-to-method method)))
15093 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15095 (defun gnus-request-list-newsgroups (method)
15096 "Request the newsgroups file from METHOD."
15097 (when (stringp method)
15098 (setq method (gnus-server-to-method method)))
15099 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15101 (defun gnus-request-newgroups (date method)
15102 "Request all new groups since DATE from METHOD."
15103 (when (stringp method)
15104 (setq method (gnus-server-to-method method)))
15105 (funcall (gnus-get-function method 'request-newgroups)
15106 date (nth 1 method)))
15108 (defun gnus-server-opened (method)
15109 "Check whether a connection to METHOD has been opened."
15110 (when (stringp method)
15111 (setq method (gnus-server-to-method method)))
15112 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15114 (defun gnus-status-message (method)
15115 "Return the status message from METHOD.
15116 If METHOD is a string, it is interpreted as a group name. The method
15117 this group uses will be queried."
15118 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15120 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15122 (defun gnus-request-group (group &optional dont-check method)
15123 "Request GROUP. If DONT-CHECK, no information is required."
15124 (let ((method (or method (gnus-find-method-for-group group))))
15125 (when (stringp method)
15126 (setq method (gnus-server-to-method method)))
15127 (funcall (gnus-get-function method 'request-group)
15128 (gnus-group-real-name group) (nth 1 method) dont-check)))
15130 (defun gnus-request-asynchronous (group &optional articles)
15131 "Request that GROUP behave asynchronously.
15132 ARTICLES is the `data' of the group."
15133 (let ((method (gnus-find-method-for-group group)))
15134 (funcall (gnus-get-function method 'request-asynchronous)
15135 (gnus-group-real-name group) (nth 1 method) articles)))
15137 (defun gnus-list-active-group (group)
15138 "Request active information on GROUP."
15139 (let ((method (gnus-find-method-for-group group))
15140 (func 'list-active-group))
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-request-group-description (group)
15146 "Request a description of GROUP."
15147 (let ((method (gnus-find-method-for-group group))
15148 (func 'request-group-description))
15149 (when (gnus-check-backend-function func group)
15150 (funcall (gnus-get-function method func)
15151 (gnus-group-real-name group) (nth 1 method)))))
15153 (defun gnus-close-group (group)
15154 "Request the GROUP be closed."
15155 (let ((method (gnus-find-method-for-group group)))
15156 (funcall (gnus-get-function method 'close-group)
15157 (gnus-group-real-name group) (nth 1 method))))
15159 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15160 "Request headers for ARTICLES in GROUP.
15161 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15162 (let ((method (gnus-find-method-for-group group)))
15163 (if (and gnus-use-cache (numberp (car articles)))
15164 (gnus-cache-retrieve-headers articles group fetch-old)
15165 (funcall (gnus-get-function method 'retrieve-headers)
15166 articles (gnus-group-real-name group) (nth 1 method)
15169 (defun gnus-retrieve-groups (groups method)
15170 "Request active information on GROUPS from METHOD."
15171 (when (stringp method)
15172 (setq method (gnus-server-to-method method)))
15173 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15175 (defun gnus-request-type (group &optional article)
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-type (car method)))
15180 (funcall (gnus-get-function method 'request-type)
15181 (gnus-group-real-name group) article))))
15183 (defun gnus-request-update-mark (group article mark)
15184 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15185 (let ((method (gnus-find-method-for-group group)))
15186 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15188 (funcall (gnus-get-function method 'request-update-mark)
15189 (gnus-group-real-name group) article mark))))
15191 (defun gnus-request-article (article group &optional buffer)
15192 "Request the ARTICLE in GROUP.
15193 ARTICLE can either be an article number or an article Message-ID.
15194 If BUFFER, insert the article in that group."
15195 (let ((method (gnus-find-method-for-group group)))
15196 (funcall (gnus-get-function method 'request-article)
15197 article (gnus-group-real-name group) (nth 1 method) buffer)))
15199 (defun gnus-request-head (article group)
15200 "Request the head of ARTICLE in GROUP."
15201 (let ((method (gnus-find-method-for-group group)))
15202 (funcall (gnus-get-function method 'request-head)
15203 article (gnus-group-real-name group) (nth 1 method))))
15205 (defun gnus-request-body (article group)
15206 "Request the body of ARTICLE in GROUP."
15207 (let ((method (gnus-find-method-for-group group)))
15208 (funcall (gnus-get-function method 'request-body)
15209 article (gnus-group-real-name group) (nth 1 method))))
15211 (defun gnus-request-post (method)
15212 "Post the current buffer using METHOD."
15213 (when (stringp method)
15214 (setq method (gnus-server-to-method method)))
15215 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15217 (defun gnus-request-scan (group method)
15218 "Request a SCAN being performed in GROUP from METHOD.
15219 If GROUP is nil, all groups on METHOD are scanned."
15220 (let ((method (if group (gnus-find-method-for-group group) method)))
15221 (funcall (gnus-get-function method 'request-scan)
15222 (and group (gnus-group-real-name group)) (nth 1 method))))
15224 (defsubst gnus-request-update-info (info method)
15225 "Request that METHOD update INFO."
15226 (when (stringp method)
15227 (setq method (gnus-server-to-method method)))
15228 (when (gnus-check-backend-function 'request-update-info (car method))
15229 (funcall (gnus-get-function method 'request-update-info)
15230 (gnus-group-real-name (gnus-info-group info))
15231 info (nth 1 method))))
15233 (defun gnus-request-expire-articles (articles group &optional force)
15234 (let ((method (gnus-find-method-for-group group)))
15235 (funcall (gnus-get-function method 'request-expire-articles)
15236 articles (gnus-group-real-name group) (nth 1 method)
15239 (defun gnus-request-move-article
15240 (article group server accept-function &optional last)
15241 (let ((method (gnus-find-method-for-group group)))
15242 (funcall (gnus-get-function method 'request-move-article)
15243 article (gnus-group-real-name group)
15244 (nth 1 method) accept-function last)))
15246 (defun gnus-request-accept-article (group method &optional last)
15247 ;; Make sure there's a newline at the end of the article.
15248 (when (stringp method)
15249 (setq method (gnus-server-to-method method)))
15250 (when (and (not method)
15252 (setq method (gnus-find-method-for-group group)))
15253 (goto-char (point-max))
15256 (let ((func (car (or method (gnus-find-method-for-group group)))))
15257 (funcall (intern (format "%s-request-accept-article" func))
15258 (if (stringp group) (gnus-group-real-name group) group)
15262 (defun gnus-request-replace-article (article group buffer)
15263 (let ((func (car (gnus-find-method-for-group group))))
15264 (funcall (intern (format "%s-request-replace-article" func))
15265 article (gnus-group-real-name group) buffer)))
15267 (defun gnus-request-associate-buffer (group)
15268 (let ((method (gnus-find-method-for-group group)))
15269 (funcall (gnus-get-function method 'request-associate-buffer)
15270 (gnus-group-real-name group))))
15272 (defun gnus-request-restore-buffer (article group)
15273 "Request a new buffer restored to the state of ARTICLE."
15274 (let ((method (gnus-find-method-for-group group)))
15275 (funcall (gnus-get-function method 'request-restore-buffer)
15276 article (gnus-group-real-name group) (nth 1 method))))
15278 (defun gnus-request-create-group (group &optional method)
15279 (when (stringp method)
15280 (setq method (gnus-server-to-method method)))
15281 (let ((method (or method (gnus-find-method-for-group group))))
15282 (funcall (gnus-get-function method 'request-create-group)
15283 (gnus-group-real-name group) (nth 1 method))))
15285 (defun gnus-request-delete-group (group &optional force)
15286 (let ((method (gnus-find-method-for-group group)))
15287 (funcall (gnus-get-function method 'request-delete-group)
15288 (gnus-group-real-name group) force (nth 1 method))))
15290 (defun gnus-request-rename-group (group new-name)
15291 (let ((method (gnus-find-method-for-group group)))
15292 (funcall (gnus-get-function method 'request-rename-group)
15293 (gnus-group-real-name group)
15294 (gnus-group-real-name new-name) (nth 1 method))))
15296 (defun gnus-member-of-valid (symbol group)
15297 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15298 (memq symbol (assoc
15299 (symbol-name (car (gnus-find-method-for-group group)))
15300 gnus-valid-select-methods)))
15302 (defun gnus-method-option-p (method option)
15303 "Return non-nil if select METHOD has OPTION as a parameter."
15304 (when (stringp method)
15305 (setq method (gnus-server-to-method method)))
15306 (memq option (assoc (format "%s" (car method))
15307 gnus-valid-select-methods)))
15309 (defun gnus-server-extend-method (group method)
15310 ;; This function "extends" a virtual server. If the server is
15311 ;; "hello", and the select method is ("hello" (my-var "something"))
15312 ;; in the group "alt.alt", this will result in a new virtual server
15313 ;; called "hello+alt.alt".
15315 (gnus-copy-sequence
15316 (if (equal (car method) "native") gnus-select-method
15317 (cdr (assoc (car method) gnus-server-alist))))))
15318 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15319 (nconc entry (cdr method))))
15321 (defun gnus-find-method-for-group (group &optional info)
15322 "Find the select method that GROUP uses."
15323 (or gnus-override-method
15325 gnus-select-method)
15326 (let ((info (or info (gnus-get-info group)))
15329 (not (setq method (gnus-info-method info)))
15330 (equal method "native"))
15333 (cond ((stringp method)
15334 (gnus-server-to-method method))
15335 ((stringp (car method))
15336 (gnus-server-extend-method group method))
15339 (cond ((equal (cadr method) "")
15341 ((null (cadr method))
15342 (list (car method) ""))
15344 (gnus-server-add-address method)))))))
15346 (defun gnus-check-backend-function (func group)
15347 "Check whether GROUP supports function FUNC."
15348 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15350 (fboundp (intern (format "%s-%s" method func)))))
15352 (defun gnus-methods-using (feature)
15353 "Find all methods that have FEATURE."
15354 (let ((valids gnus-valid-select-methods)
15357 (if (memq feature (car valids))
15358 (setq outs (cons (car valids) outs)))
15359 (setq valids (cdr valids)))
15364 ;;; Active & Newsrc File Handling
15367 (defun gnus-setup-news (&optional rawfile level dont-connect)
15368 "Setup news information.
15369 If RAWFILE is non-nil, the .newsrc file will also be read.
15370 If LEVEL is non-nil, the news will be set up at level LEVEL."
15371 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15374 ;; Clear some variables to re-initialize news information.
15375 (setq gnus-newsrc-alist nil
15376 gnus-active-hashtb nil)
15377 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15378 (gnus-read-newsrc-file rawfile))
15380 (when (and (not (assoc "archive" gnus-server-alist))
15381 gnus-message-archive-method)
15382 (push (cons "archive" gnus-message-archive-method)
15383 gnus-server-alist))
15385 ;; If we don't read the complete active file, we fill in the
15387 (if (or (null gnus-read-active-file)
15388 (eq gnus-read-active-file 'some))
15389 (gnus-update-active-hashtb-from-killed))
15391 ;; Read the active file and create `gnus-active-hashtb'.
15392 ;; If `gnus-read-active-file' is nil, then we just create an empty
15393 ;; hash table. The partial filling out of the hash table will be
15394 ;; done in `gnus-get-unread-articles'.
15395 (and gnus-read-active-file
15397 (gnus-read-active-file))
15399 (or gnus-active-hashtb
15400 (setq gnus-active-hashtb (make-vector 4095 0)))
15402 ;; Initialize the cache.
15403 (when gnus-use-cache
15406 ;; Possibly eval the dribble file.
15407 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15409 ;; Slave Gnusii should then clear the dribble buffer.
15410 (when (and init gnus-slave)
15411 (gnus-dribble-clear))
15413 (gnus-update-format-specifications)
15415 ;; See whether we need to read the description file.
15416 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15417 (not gnus-description-hashtb)
15419 gnus-read-active-file)
15420 (gnus-read-all-descriptions-files))
15422 ;; Find new newsgroups and treat them.
15423 (if (and init gnus-check-new-newsgroups (not level)
15424 (gnus-check-server gnus-select-method))
15425 (gnus-find-new-newsgroups))
15427 ;; We might read in new NoCeM messages here.
15428 (when (and gnus-use-nocem
15430 (not dont-connect))
15431 (gnus-nocem-scan-groups))
15433 ;; Find the number of unread articles in each non-dead group.
15434 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15435 (gnus-get-unread-articles level))
15437 (if (and init gnus-check-bogus-newsgroups
15438 gnus-read-active-file (not level)
15439 (gnus-server-opened gnus-select-method))
15440 (gnus-check-bogus-newsgroups))))
15442 (defun gnus-find-new-newsgroups (&optional arg)
15443 "Search for new newsgroups and add them.
15444 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15445 The `-n' option line from .newsrc is respected.
15446 If ARG (the prefix), use the `ask-server' method to query
15447 the server for new groups."
15449 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15450 (null gnus-read-active-file)
15451 (eq gnus-read-active-file 'some))
15452 'ask-server gnus-check-new-newsgroups)))
15453 (unless (gnus-check-first-time-used)
15454 (if (or (consp check)
15455 (eq check 'ask-server))
15456 ;; Ask the server for new groups.
15457 (gnus-ask-server-for-new-groups)
15458 ;; Go through the active hashtb and look for new groups.
15460 group new-newsgroups)
15461 (gnus-message 5 "Looking for new newsgroups...")
15462 (unless gnus-have-read-active-file
15463 (gnus-read-active-file))
15464 (setq gnus-newsrc-last-checked-date (current-time-string))
15465 (unless gnus-killed-hashtb
15466 (gnus-make-hashtable-from-killed))
15467 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15468 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15471 (if (or (null (setq group (symbol-name sym)))
15473 (null (symbol-value sym))
15474 (gnus-gethash group gnus-killed-hashtb)
15475 (gnus-gethash group gnus-newsrc-hashtb))
15477 (let ((do-sub (gnus-matches-options-n group)))
15479 ((eq do-sub 'subscribe)
15480 (setq groups (1+ groups))
15481 (gnus-sethash group group gnus-killed-hashtb)
15482 (funcall gnus-subscribe-options-newsgroup-method group))
15483 ((eq do-sub 'ignore)
15486 (setq groups (1+ groups))
15487 (gnus-sethash group group gnus-killed-hashtb)
15488 (if gnus-subscribe-hierarchical-interactive
15489 (setq new-newsgroups (cons group new-newsgroups))
15490 (funcall gnus-subscribe-newsgroup-method group)))))))
15491 gnus-active-hashtb)
15492 (when new-newsgroups
15493 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15494 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15496 (gnus-message 6 "%d new newsgroup%s arrived."
15497 groups (if (> groups 1) "s have" " has"))
15498 (gnus-message 6 "No new newsgroups.")))))))
15500 (defun gnus-matches-options-n (group)
15501 ;; Returns `subscribe' if the group is to be unconditionally
15502 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15503 ;; no match for the group.
15505 ;; First we check the two user variables.
15507 ((and gnus-options-subscribe
15508 (string-match gnus-options-subscribe group))
15510 ((and gnus-auto-subscribed-groups
15511 (string-match gnus-auto-subscribed-groups group))
15513 ((and gnus-options-not-subscribe
15514 (string-match gnus-options-not-subscribe group))
15516 ;; Then we go through the list that was retrieved from the .newsrc
15517 ;; file. This list has elements on the form
15518 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15519 ;; is in the reverse order of the options line) is returned.
15521 (let ((regs gnus-newsrc-options-n))
15523 (not (string-match (caar regs) group)))
15524 (setq regs (cdr regs)))
15525 (and regs (cdar regs))))))
15527 (defun gnus-ask-server-for-new-groups ()
15528 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15529 (methods (cons gnus-select-method
15531 (when gnus-message-archive-method
15534 (and (consp gnus-check-new-newsgroups)
15535 gnus-check-new-newsgroups)
15536 gnus-secondary-select-methods))))
15538 (new-date (current-time-string))
15539 group new-newsgroups got-new method hashtb
15540 gnus-override-subscribe-method)
15541 ;; Go through both primary and secondary select methods and
15542 ;; request new newsgroups.
15543 (while (setq method (gnus-server-get-method nil (pop methods)))
15544 (setq new-newsgroups nil)
15545 (setq gnus-override-subscribe-method method)
15546 (when (and (gnus-check-server method)
15547 (gnus-request-newgroups date method))
15550 (setq hashtb (gnus-make-hashtable 100))
15551 (set-buffer nntp-server-buffer)
15552 ;; Enter all the new groups into a hashtable.
15553 (gnus-active-to-gnus-format method hashtb 'ignore))
15554 ;; Now all new groups from `method' are in `hashtb'.
15556 (lambda (group-sym)
15557 (if (or (null (setq group (symbol-name group-sym)))
15558 (not (boundp group-sym))
15559 (null (symbol-value group-sym))
15560 (gnus-gethash group gnus-newsrc-hashtb)
15561 (member group gnus-zombie-list)
15562 (member group gnus-killed-list))
15563 ;; The group is already known.
15565 ;; Make this group active.
15566 (when (symbol-value group-sym)
15567 (gnus-set-active group (symbol-value group-sym)))
15568 ;; Check whether we want it or not.
15569 (let ((do-sub (gnus-matches-options-n group)))
15571 ((eq do-sub 'subscribe)
15573 (gnus-sethash group group gnus-killed-hashtb)
15574 (funcall gnus-subscribe-options-newsgroup-method group))
15575 ((eq do-sub 'ignore)
15579 (gnus-sethash group group gnus-killed-hashtb)
15580 (if gnus-subscribe-hierarchical-interactive
15581 (push group new-newsgroups)
15582 (funcall gnus-subscribe-newsgroup-method group)))))))
15584 (when new-newsgroups
15585 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15586 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15588 (gnus-message 6 "%d new newsgroup%s arrived."
15589 groups (if (> groups 1) "s have" " has")))
15590 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15593 (defun gnus-check-first-time-used ()
15594 (if (or (> (length gnus-newsrc-alist) 1)
15595 (file-exists-p gnus-startup-file)
15596 (file-exists-p (concat gnus-startup-file ".el"))
15597 (file-exists-p (concat gnus-startup-file ".eld")))
15599 (gnus-message 6 "First time user; subscribing you to default groups")
15600 (unless (gnus-read-active-file-p)
15601 (gnus-read-active-file))
15602 (setq gnus-newsrc-last-checked-date (current-time-string))
15603 (let ((groups gnus-default-subscribed-newsgroups)
15607 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15610 (if (null (setq group (symbol-name sym)))
15612 (let ((do-sub (gnus-matches-options-n group)))
15614 ((eq do-sub 'subscribe)
15615 (gnus-sethash group group gnus-killed-hashtb)
15616 (funcall gnus-subscribe-options-newsgroup-method group))
15617 ((eq do-sub 'ignore)
15620 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15621 gnus-active-hashtb)
15623 (if (gnus-active (car groups))
15624 (gnus-group-change-level
15625 (car groups) gnus-level-default-subscribed gnus-level-killed))
15626 (setq groups (cdr groups)))
15627 (gnus-group-make-help-group)
15628 (and gnus-novice-user
15629 (gnus-message 7 "`A k' to list killed groups"))))))
15631 (defun gnus-subscribe-group (group previous &optional method)
15632 (gnus-group-change-level
15634 (list t group gnus-level-default-subscribed nil nil method)
15636 gnus-level-default-subscribed gnus-level-killed previous t))
15638 ;; `gnus-group-change-level' is the fundamental function for changing
15639 ;; subscription levels of newsgroups. This might mean just changing
15640 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15641 ;; again, which subscribes/unsubscribes a group, which is equally
15642 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15643 ;; from 8-9 to 1-7 means that you remove the group from the list of
15644 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15645 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15646 ;; which is trivial.
15647 ;; ENTRY can either be a string (newsgroup name) or a list (if
15648 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15649 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15651 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15652 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15654 (defun gnus-group-change-level (entry level &optional oldlevel
15655 previous fromkilled)
15656 (let (group info active num)
15657 ;; Glean what info we can from the arguments
15659 (if fromkilled (setq group (nth 1 entry))
15660 (setq group (car (nth 2 entry))))
15661 (setq group entry))
15662 (if (and (stringp entry)
15664 (< oldlevel gnus-level-zombie))
15665 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15666 (if (and (not oldlevel)
15668 (setq oldlevel (gnus-info-level (nth 2 entry)))
15669 (setq oldlevel (or oldlevel 9)))
15670 (if (stringp previous)
15671 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15673 (if (and (>= oldlevel gnus-level-zombie)
15674 (gnus-gethash group gnus-newsrc-hashtb))
15675 ;; We are trying to subscribe a group that is already
15679 (or (gnus-ephemeral-group-p group)
15680 (gnus-dribble-enter
15681 (format "(gnus-group-change-level %S %S %S %S %S)"
15682 group level oldlevel (car (nth 2 previous)) fromkilled)))
15684 ;; Then we remove the newgroup from any old structures, if needed.
15685 ;; If the group was killed, we remove it from the killed or zombie
15686 ;; list. If not, and it is in fact going to be killed, we remove
15687 ;; it from the newsrc hash table and assoc.
15689 ((>= oldlevel gnus-level-zombie)
15690 (if (= oldlevel gnus-level-zombie)
15691 (setq gnus-zombie-list (delete group gnus-zombie-list))
15692 (setq gnus-killed-list (delete group gnus-killed-list))))
15694 (if (and (>= level gnus-level-zombie)
15697 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15699 (setcdr (gnus-gethash (car (nth 3 entry))
15700 gnus-newsrc-hashtb)
15702 (setcdr (cdr entry) (cdddr entry))))))
15704 ;; Finally we enter (if needed) the list where it is supposed to
15705 ;; go, and change the subscription level. If it is to be killed,
15706 ;; we enter it into the killed or zombie list.
15708 ((>= level gnus-level-zombie)
15709 ;; Remove from the hash table.
15710 (gnus-sethash group nil gnus-newsrc-hashtb)
15711 ;; We do not enter foreign groups into the list of dead
15713 (unless (gnus-group-foreign-p group)
15714 (if (= level gnus-level-zombie)
15715 (setq gnus-zombie-list (cons group gnus-zombie-list))
15716 (setq gnus-killed-list (cons group gnus-killed-list)))))
15718 ;; If the list is to be entered into the newsrc assoc, and
15719 ;; it was killed, we have to create an entry in the newsrc
15720 ;; hashtb format and fix the pointers in the newsrc assoc.
15721 (if (< oldlevel gnus-level-zombie)
15722 ;; It was alive, and it is going to stay alive, so we
15723 ;; just change the level and don't change any pointers or
15724 ;; hash table entries.
15725 (setcar (cdaddr entry) level)
15727 (setq info (cdr entry)
15729 (setq active (gnus-active group))
15731 (if active (- (1+ (cdr active)) (car active)) t))
15732 ;; Check whether the group is foreign. If so, the
15733 ;; foreign select method has to be entered into the
15735 (let ((method (or gnus-override-subscribe-method
15736 (gnus-group-method group))))
15737 (if (eq method gnus-select-method)
15738 (setq info (list group level nil))
15739 (setq info (list group level nil nil method)))))
15742 (let ((p gnus-newsrc-alist))
15746 (setq entry (cons info (cddr previous)))
15749 (setcdr (cdr previous) entry)
15750 (gnus-sethash group (cons num (cdr previous))
15751 gnus-newsrc-hashtb))
15752 (setcdr previous entry)
15753 (gnus-sethash group (cons num previous)
15754 gnus-newsrc-hashtb))
15756 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15757 (when gnus-group-change-level-function
15758 (funcall gnus-group-change-level-function group level oldlevel)))))
15760 (defun gnus-kill-newsgroup (newsgroup)
15761 "Obsolete function. Kills a newsgroup."
15762 (gnus-group-change-level
15763 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15765 (defun gnus-check-bogus-newsgroups (&optional confirm)
15766 "Remove bogus newsgroups.
15767 If CONFIRM is non-nil, the user has to confirm the deletion of every
15769 (let ((newsrc (cdr gnus-newsrc-alist))
15770 bogus group entry info)
15771 (gnus-message 5 "Checking bogus newsgroups...")
15772 (unless (gnus-read-active-file-p)
15773 (gnus-read-active-file))
15774 (when (gnus-read-active-file-p)
15775 ;; Find all bogus newsgroup that are subscribed.
15777 (setq info (pop newsrc)
15778 group (gnus-info-group info))
15779 (unless (or (gnus-active group) ; Active
15780 (gnus-info-method info) ; Foreign
15782 (not (gnus-y-or-n-p
15783 (format "Remove bogus newsgroup: %s " group)))))
15784 ;; Found a bogus newsgroup.
15785 (push group bogus)))
15786 ;; Remove all bogus subscribed groups by first killing them, and
15787 ;; then removing them from the list of killed groups.
15789 (when (setq entry (gnus-gethash (setq group (pop bogus))
15790 gnus-newsrc-hashtb))
15791 (gnus-group-change-level entry gnus-level-killed)
15792 (setq gnus-killed-list (delete group gnus-killed-list))))
15793 ;; Then we remove all bogus groups from the list of killed and
15794 ;; zombie groups. They are are removed without confirmation.
15795 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15798 (setq killed (symbol-value (car dead-lists)))
15800 (unless (gnus-active (setq group (pop killed)))
15801 ;; The group is bogus.
15802 ;; !!!Slow as hell.
15803 (set (car dead-lists)
15804 (delete group (symbol-value (car dead-lists))))))
15805 (setq dead-lists (cdr dead-lists))))
15806 (gnus-message 5 "Checking bogus newsgroups...done"))))
15808 (defun gnus-check-duplicate-killed-groups ()
15809 "Remove duplicates from the list of killed groups."
15811 (let ((killed gnus-killed-list))
15813 (gnus-message 9 "%d" (length killed))
15814 (setcdr killed (delete (car killed) (cdr killed)))
15815 (setq killed (cdr killed)))))
15817 ;; We want to inline a function from gnus-cache, so we cheat here:
15820 (require 'gnus-cache))
15822 (defun gnus-get-unread-articles-in-group (info active &optional update)
15824 ;; Allow the backend to update the info in the group.
15826 (gnus-request-update-info
15827 info (gnus-find-method-for-group (gnus-info-group info))))
15828 (gnus-activate-group (gnus-info-group info) nil t))
15829 (let* ((range (gnus-info-read info))
15831 ;; If a cache is present, we may have to alter the active info.
15832 (when (and gnus-use-cache info)
15833 (inline (gnus-cache-possibly-alter-active
15834 (gnus-info-group info) active)))
15835 ;; Modify the list of read articles according to what articles
15836 ;; are available; then tally the unread articles and add the
15837 ;; number to the group hash table entry.
15839 ((zerop (cdr active))
15842 (setq num (- (1+ (cdr active)) (car active))))
15843 ((not (listp (cdr range)))
15844 ;; Fix a single (num . num) range according to the
15845 ;; active hash table.
15846 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15847 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15848 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15849 ;; Compute number of unread articles.
15850 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15852 ;; The read list is a list of ranges. Fix them according to
15853 ;; the active hash table.
15854 ;; First peel off any elements that are below the lower
15856 (while (and (cdr range)
15858 (or (and (atom (cadr range)) (cadr range))
15860 (if (numberp (car range))
15863 (or (and (numberp (cadr range))
15866 (setcdr (car range)
15867 (or (and (numberp (nth 1 range)) (nth 1 range))
15869 (setcdr range (cddr range)))
15870 ;; Adjust the first element to be the same as the lower limit.
15871 (if (and (not (atom (car range)))
15872 (< (cdar range) (car active)))
15873 (setcdr (car range) (1- (car active))))
15874 ;; Then we want to peel off any elements that are higher
15875 ;; than the upper active limit.
15876 (let ((srange range))
15877 ;; Go past all legal elements.
15878 (while (and (cdr srange)
15879 (<= (or (and (atom (cadr srange))
15881 (caadr srange)) (cdr active)))
15882 (setq srange (cdr srange)))
15884 ;; Nuke all remaining illegal elements.
15885 (setcdr srange nil))
15887 ;; Adjust the final element.
15888 (if (and (not (atom (car srange)))
15889 (> (cdar srange) (cdr active)))
15890 (setcdr (car srange) (cdr active))))
15891 ;; Compute the number of unread articles.
15893 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15895 (or (and (atom (car range)) (car range))
15897 (setq range (cdr range)))
15898 (setq num (max 0 (- (cdr active) num)))))
15899 ;; Set the number of unread articles.
15901 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15904 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15905 ;; and compute how many unread articles there are in each group.
15906 (defun gnus-get-unread-articles (&optional level)
15907 (let* ((newsrc (cdr gnus-newsrc-alist))
15908 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15911 (cond ((and gnus-activate-foreign-newsgroups
15912 (not (numberp gnus-activate-foreign-newsgroups)))
15913 (1+ gnus-level-subscribed))
15914 ((numberp gnus-activate-foreign-newsgroups)
15915 gnus-activate-foreign-newsgroups)
15918 info group active method)
15919 (gnus-message 5 "Checking new news...")
15922 (setq active (gnus-active (setq group (gnus-info-group
15923 (setq info (pop newsrc))))))
15925 ;; Check newsgroups. If the user doesn't want to check them, or
15926 ;; they can't be checked (for instance, if the news server can't
15927 ;; be reached) we just set the number of unread articles in this
15928 ;; newsgroup to t. This means that Gnus thinks that there are
15929 ;; unread articles, but it has no idea how many.
15930 (if (and (setq method (gnus-info-method info))
15931 (not (gnus-server-equal
15933 (setq method (gnus-server-get-method nil method))))
15934 (not (gnus-secondary-method-p method)))
15935 ;; These groups are foreign. Check the level.
15936 (when (<= (gnus-info-level info) foreign-level)
15937 (setq active (gnus-activate-group group 'scan))
15938 (unless (inline (gnus-virtual-group-p group))
15939 (inline (gnus-close-group group)))
15940 (when (fboundp (intern (concat (symbol-name (car method))
15941 "-request-update-info")))
15942 (inline (gnus-request-update-info info method))))
15943 ;; These groups are native or secondary.
15944 (when (and (<= (gnus-info-level info) level)
15945 (not gnus-read-active-file))
15946 (setq active (gnus-activate-group group 'scan))
15947 (inline (gnus-close-group group))))
15949 ;; Get the number of unread articles in the group.
15951 (inline (gnus-get-unread-articles-in-group info active))
15952 ;; The group couldn't be reached, so we nix out the number of
15953 ;; unread articles and stuff.
15954 (gnus-set-active group nil)
15955 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15957 (gnus-message 5 "Checking new news...done")))
15959 ;; Create a hash table out of the newsrc alist. The `car's of the
15960 ;; alist elements are used as keys.
15961 (defun gnus-make-hashtable-from-newsrc-alist ()
15962 (let ((alist gnus-newsrc-alist)
15963 (ohashtb gnus-newsrc-hashtb)
15965 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15967 (setq prev (setq gnus-newsrc-alist
15968 (if (equal (caar gnus-newsrc-alist)
15971 (cons (list "dummy.group" 0 nil) alist)))))
15975 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15977 gnus-newsrc-hashtb)
15979 alist (cdr alist)))))
15981 (defun gnus-make-hashtable-from-killed ()
15982 "Create a hash table from the killed and zombie lists."
15983 (let ((lists '(gnus-killed-list gnus-zombie-list))
15985 (setq gnus-killed-hashtb
15986 (gnus-make-hashtable
15987 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15988 (while (setq list (pop lists))
15989 (setq list (symbol-value list))
15991 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15993 (defun gnus-activate-group (group &optional scan dont-check)
15994 ;; Check whether a group has been activated or not.
15995 ;; If SCAN, request a scan of that group as well.
15996 (let ((method (gnus-find-method-for-group group))
15998 (and (gnus-check-server method)
15999 ;; We escape all bugs and quit here to make it possible to
16000 ;; continue if a group is so out-there that it reports bugs
16004 (gnus-check-backend-function 'request-scan (car method))
16005 (gnus-request-scan group method))
16008 (gnus-request-group group dont-check)
16012 (set-buffer nntp-server-buffer)
16013 (goto-char (point-min))
16014 ;; Parse the result we got from `gnus-request-group'.
16015 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16017 (goto-char (match-beginning 1))
16019 group (setq active (cons (read (current-buffer))
16020 (read (current-buffer)))))
16021 ;; Return the new active info.
16024 (defun gnus-update-read-articles (group unread)
16025 "Update the list of read and ticked articles in GROUP using the
16026 UNREAD and TICKED lists.
16027 Note: UNSELECTED has to be sorted over `<'.
16028 Returns whether the updating was successful."
16029 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16030 (entry (gnus-gethash group gnus-newsrc-hashtb))
16031 (info (nth 2 entry))
16033 (unread (sort (copy-sequence unread) '<))
16035 (if (or (not info) (not active))
16036 ;; There is no info on this group if it was, in fact,
16037 ;; killed. Gnus stores no information on killed groups, so
16038 ;; there's nothing to be done.
16039 ;; One could store the information somewhere temporarily,
16040 ;; perhaps... Hmmm...
16042 ;; Remove any negative articles numbers.
16043 (while (and unread (< (car unread) 0))
16044 (setq unread (cdr unread)))
16045 ;; Remove any expired article numbers
16046 (while (and unread (< (car unread) (car active)))
16047 (setq unread (cdr unread)))
16048 ;; Compute the ranges of read articles by looking at the list of
16049 ;; unread articles.
16051 (if (/= (car unread) prev)
16052 (setq read (cons (if (= prev (1- (car unread))) prev
16053 (cons prev (1- (car unread)))) read)))
16054 (setq prev (1+ (car unread)))
16055 (setq unread (cdr unread)))
16056 (when (<= prev (cdr active))
16057 (setq read (cons (cons prev (cdr active)) read)))
16058 ;; Enter this list into the group info.
16059 (gnus-info-set-read
16060 info (if (> (length read) 1) (nreverse read) read))
16061 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16062 (gnus-get-unread-articles-in-group info (gnus-active group))
16065 (defun gnus-make-articles-unread (group articles)
16066 "Mark ARTICLES in GROUP as unread."
16067 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16068 (gnus-gethash (gnus-group-real-name group)
16069 gnus-newsrc-hashtb))))
16070 (ranges (gnus-info-read info))
16073 (when (gnus-member-of-range
16074 (setq article (pop articles)) ranges)
16075 (setq news (cons article news))))
16077 (gnus-info-set-read
16078 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16079 (gnus-group-update-group group t))))
16081 ;; Enter all dead groups into the hashtb.
16082 (defun gnus-update-active-hashtb-from-killed ()
16083 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16084 (lists (list gnus-killed-list gnus-zombie-list))
16087 (setq killed (car lists))
16089 (gnus-sethash (car killed) nil hashtb)
16090 (setq killed (cdr killed)))
16091 (setq lists (cdr lists)))))
16093 (defun gnus-get-killed-groups ()
16094 "Go through the active hashtb and all all unknown groups as killed."
16095 ;; First make sure active file has been read.
16096 (unless (gnus-read-active-file-p)
16097 (let ((gnus-read-active-file t))
16098 (gnus-read-active-file)))
16099 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16100 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16104 (group (symbol-name sym)))
16105 (if (or (null group)
16106 (gnus-gethash group gnus-killed-hashtb)
16107 (gnus-gethash group gnus-newsrc-hashtb))
16109 (let ((do-sub (gnus-matches-options-n group)))
16110 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16112 (setq groups (1+ groups))
16113 (setq gnus-killed-list
16114 (cons group gnus-killed-list))
16115 (gnus-sethash group group gnus-killed-hashtb))))))
16116 gnus-active-hashtb))
16118 ;; Get the active file(s) from the backend(s).
16119 (defun gnus-read-active-file ()
16120 (gnus-group-set-mode-line)
16123 (if (gnus-check-server gnus-select-method)
16124 ;; The native server is available.
16125 (cons gnus-select-method gnus-secondary-select-methods)
16126 ;; The native server is down, so we just do the
16128 gnus-secondary-select-methods)
16129 ;; Also read from the archive server.
16130 (when gnus-message-archive-method
16131 (list "archive"))))
16133 (setq gnus-have-read-active-file nil)
16135 (set-buffer nntp-server-buffer)
16137 (let* ((method (if (stringp (car methods))
16138 (gnus-server-get-method nil (car methods))
16140 (where (nth 1 method))
16141 (mesg (format "Reading active file%s via %s..."
16142 (if (and where (not (zerop (length where))))
16143 (concat " from " where) "")
16145 (gnus-message 5 mesg)
16146 (when (gnus-check-server method)
16147 ;; Request that the backend scan its incoming messages.
16148 (and (gnus-check-backend-function 'request-scan (car method))
16149 (gnus-request-scan nil method))
16151 ((and (eq gnus-read-active-file 'some)
16152 (gnus-check-backend-function 'retrieve-groups (car method)))
16153 (let ((newsrc (cdr gnus-newsrc-alist))
16154 (gmethod (gnus-server-get-method nil method))
16156 (while (setq info (pop newsrc))
16157 (when (gnus-server-equal
16158 (gnus-find-method-for-group
16159 (gnus-info-group info) info)
16161 (push (gnus-group-real-name (gnus-info-group info))
16164 (gnus-check-server method)
16165 (setq list-type (gnus-retrieve-groups groups method))
16169 1.2 "Cannot read partial active file from %s server."
16171 ((eq list-type 'active)
16172 (gnus-active-to-gnus-format method gnus-active-hashtb))
16174 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16176 (if (not (gnus-request-list method))
16177 (unless (equal method gnus-message-archive-method)
16178 (gnus-error 1 "Cannot read active file from %s server."
16180 (gnus-message 5 mesg)
16181 (gnus-active-to-gnus-format method gnus-active-hashtb)
16182 ;; We mark this active file as read.
16183 (push method gnus-have-read-active-file)
16184 (gnus-message 5 "%sdone" mesg))))))
16185 (setq methods (cdr methods))))))
16187 ;; Read an active file and place the results in `gnus-active-hashtb'.
16188 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16190 (setq method gnus-select-method))
16191 (let ((cur (current-buffer))
16193 (if (and gnus-active-hashtb
16194 (not (equal method gnus-select-method)))
16196 (setq gnus-active-hashtb
16197 (if (equal method gnus-select-method)
16198 (gnus-make-hashtable
16199 (count-lines (point-min) (point-max)))
16200 (gnus-make-hashtable 4096)))))))
16201 ;; Delete unnecessary lines.
16202 (goto-char (point-min))
16203 (while (search-forward "\nto." nil t)
16204 (delete-region (1+ (match-beginning 0))
16205 (progn (forward-line 1) (point))))
16206 (or (string= gnus-ignored-newsgroups "")
16208 (goto-char (point-min))
16209 (delete-matching-lines gnus-ignored-newsgroups)))
16210 ;; Make the group names readable as a lisp expression even if they
16211 ;; contain special characters.
16212 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16213 (goto-char (point-max))
16214 (while (re-search-backward "[][';?()#]" nil t)
16216 ;; If these are groups from a foreign select method, we insert the
16217 ;; group prefix in front of the group names.
16218 (and method (not (gnus-server-equal
16219 (gnus-server-get-method nil method)
16220 (gnus-server-get-method nil gnus-select-method)))
16221 (let ((prefix (gnus-group-prefixed-name "" method)))
16222 (goto-char (point-min))
16223 (while (and (not (eobp))
16224 (progn (insert prefix)
16225 (zerop (forward-line 1)))))))
16226 ;; Store the active file in a hash table.
16227 (goto-char (point-min))
16228 (if (string-match "%[oO]" gnus-group-line-format)
16229 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16230 ;; If we want information on moderated groups, we use this
16232 (let* ((mod-hashtb (make-vector 7 0))
16233 (m (intern "m" mod-hashtb))
16235 (while (not (eobp))
16236 (condition-case nil
16238 (narrow-to-region (point) (gnus-point-at-eol))
16239 (setq group (let ((obarray hashtb)) (read cur)))
16240 (if (and (numberp (setq max (read cur)))
16241 (numberp (setq min (read cur)))
16243 (skip-chars-forward " \t")
16245 (or (= (following-char) ?=)
16246 (= (following-char) ?x)
16247 (= (following-char) ?j)))))
16248 (set group (cons min max))
16250 ;; Enter moderated groups into a list.
16251 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16252 (setq gnus-moderated-list
16253 (cons (symbol-name group) gnus-moderated-list))))
16260 ;; And if we do not care about moderation, we use this loop,
16261 ;; which is faster.
16262 (let (group max min)
16263 (while (not (eobp))
16266 (narrow-to-region (point) (gnus-point-at-eol))
16267 ;; group gets set to a symbol interned in the hash table
16268 ;; (what a hack!!) - jwz
16269 (setq group (let ((obarray hashtb)) (read cur)))
16270 (if (and (numberp (setq max (read cur)))
16271 (numberp (setq min (read cur)))
16273 (skip-chars-forward " \t")
16275 (or (= (following-char) ?=)
16276 (= (following-char) ?x)
16277 (= (following-char) ?j)))))
16278 (set group (cons min max))
16286 (gnus-message 3 "Warning - illegal active: %s"
16288 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16290 (forward-line 1))))))
16292 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16293 ;; Parse a "groups" active file.
16294 (let ((cur (current-buffer))
16296 (if (and method gnus-active-hashtb)
16298 (setq gnus-active-hashtb
16299 (gnus-make-hashtable
16300 (count-lines (point-min) (point-max)))))))
16301 (prefix (and method
16302 (not (gnus-server-equal
16303 (gnus-server-get-method nil method)
16304 (gnus-server-get-method nil gnus-select-method)))
16305 (gnus-group-prefixed-name "" method))))
16307 (goto-char (point-min))
16308 ;; We split this into to separate loops, one with the prefix
16309 ;; and one without to speed the reading up somewhat.
16311 (let (min max opoint group)
16312 (while (not (eobp))
16315 (read cur) (read cur)
16316 (setq min (read cur)
16319 (skip-chars-forward " \t")
16322 (set (let ((obarray hashtb)) (read cur))
16324 (error (and group (symbolp group) (set group nil))))
16326 (let (min max group)
16327 (while (not (eobp))
16329 (if (= (following-char) ?2)
16331 (read cur) (read cur)
16332 (setq min (read cur)
16334 (set (setq group (let ((obarray hashtb)) (read cur)))
16336 (error (and group (symbolp group) (set group nil))))
16337 (forward-line 1))))))
16339 (defun gnus-read-newsrc-file (&optional force)
16340 "Read startup file.
16341 If FORCE is non-nil, the .newsrc file is read."
16342 ;; Reset variables that might be defined in the .newsrc.eld file.
16343 (let ((variables gnus-variable-list))
16345 (set (car variables) nil)
16346 (setq variables (cdr variables))))
16347 (let* ((newsrc-file gnus-current-startup-file)
16348 (quick-file (concat newsrc-file ".el")))
16350 ;; We always load the .newsrc.eld file. If always contains
16351 ;; much information that can not be gotten from the .newsrc
16352 ;; file (ticked articles, killed groups, foreign methods, etc.)
16353 (gnus-read-newsrc-el-file quick-file)
16355 (if (and (file-exists-p gnus-current-startup-file)
16357 (and (file-newer-than-file-p newsrc-file quick-file)
16358 (file-newer-than-file-p newsrc-file
16359 (concat quick-file "d")))
16360 (not gnus-newsrc-alist)))
16361 ;; We read the .newsrc file. Note that if there if a
16362 ;; .newsrc.eld file exists, it has already been read, and
16363 ;; the `gnus-newsrc-hashtb' has been created. While reading
16364 ;; the .newsrc file, Gnus will only use the information it
16365 ;; can find there for changing the data already read -
16366 ;; ie. reading the .newsrc file will not trash the data
16367 ;; already read (except for read articles).
16369 (gnus-message 5 "Reading %s..." newsrc-file)
16370 (set-buffer (find-file-noselect newsrc-file))
16371 (buffer-disable-undo (current-buffer))
16372 (gnus-newsrc-to-gnus-format)
16373 (kill-buffer (current-buffer))
16374 (gnus-message 5 "Reading %s...done" newsrc-file)))
16376 ;; Read any slave files.
16378 (gnus-master-read-slave-newsrc))
16380 ;; Convert old to new.
16381 (gnus-convert-old-newsrc))))
16383 (defun gnus-continuum-version (version)
16384 "Return VERSION as a floating point number."
16385 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16386 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16387 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16388 (number (match-string 2 version))
16390 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16391 (setq major (string-to-number (match-string 1 number)))
16392 (setq minor (string-to-number (match-string 2 number)))
16393 (setq least (if (match-beginning 3)
16394 (string-to-number (match-string 3 number))
16398 (format "%s00%02d%02d"
16400 ((member alpha '("(ding)" "d")) "4.99")
16401 ((member alpha '("September" "s")) "5.01")
16402 ((member alpha '("Red" "r")) "5.03"))
16404 (format "%d.%02d%02d" major minor least))))))
16406 (defun gnus-convert-old-newsrc ()
16407 "Convert old newsrc into the new format, if needed."
16408 (let ((fcv (and gnus-newsrc-file-version
16409 (gnus-continuum-version gnus-newsrc-file-version))))
16411 ;; No .newsrc.eld file was loaded.
16413 ;; Gnus 5 .newsrc.eld was loaded.
16414 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16415 (gnus-convert-old-ticks)))))
16417 (defun gnus-convert-old-ticks ()
16418 (let ((newsrc (cdr gnus-newsrc-alist))
16419 marks info dormant ticked)
16420 (while (setq info (pop newsrc))
16421 (when (setq marks (gnus-info-marks info))
16422 (setq dormant (cdr (assq 'dormant marks))
16423 ticked (cdr (assq 'tick marks)))
16424 (when (or dormant ticked)
16425 (gnus-info-set-read
16428 (gnus-info-read info)
16429 (nconc (gnus-uncompress-range dormant)
16430 (gnus-uncompress-range ticked)))))))))
16432 (defun gnus-read-newsrc-el-file (file)
16433 (let ((ding-file (concat file "d")))
16434 ;; We always, always read the .eld file.
16435 (gnus-message 5 "Reading %s..." ding-file)
16436 (let (gnus-newsrc-assoc)
16437 (condition-case nil
16438 (load ding-file t t t)
16440 (gnus-error 1 "Error in %s" ding-file)))
16441 (when gnus-newsrc-assoc
16442 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16443 (gnus-make-hashtable-from-newsrc-alist)
16444 (when (file-newer-than-file-p file ding-file)
16445 ;; Old format quick file
16446 (gnus-message 5 "Reading %s..." file)
16447 ;; The .el file is newer than the .eld file, so we read that one
16449 (gnus-read-old-newsrc-el-file file))))
16451 ;; Parse the old-style quick startup file
16452 (defun gnus-read-old-newsrc-el-file (file)
16453 (let (newsrc killed marked group m info)
16455 (let ((gnus-killed-assoc nil)
16456 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16458 (condition-case nil
16461 (setq newsrc gnus-newsrc-assoc
16462 killed gnus-killed-assoc
16463 marked gnus-marked-assoc)))
16464 (setq gnus-newsrc-alist nil)
16465 (while (setq group (pop newsrc))
16466 (if (setq info (gnus-get-info (car group)))
16468 (gnus-info-set-read info (cddr group))
16469 (gnus-info-set-level
16470 info (if (nth 1 group) gnus-level-default-subscribed
16471 gnus-level-default-unsubscribed))
16472 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16475 (if (nth 1 group) gnus-level-default-subscribed
16476 gnus-level-default-unsubscribed)
16478 gnus-newsrc-alist))
16479 ;; Copy marks into info.
16480 (when (setq m (assoc (car group) marked))
16481 (unless (nthcdr 3 info)
16482 (nconc info (list nil)))
16483 (gnus-info-set-marks
16484 info (list (cons 'tick (gnus-compress-sequence
16485 (sort (cdr m) '<) t))))))
16486 (setq newsrc killed)
16488 (setcar newsrc (caar newsrc))
16489 (setq newsrc (cdr newsrc)))
16490 (setq gnus-killed-list killed))
16491 ;; The .el file version of this variable does not begin with
16492 ;; "options", while the .eld version does, so we just add it if it
16495 gnus-newsrc-options
16497 (and (not (string-match "^ *options" gnus-newsrc-options))
16498 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16499 (and (not (string-match "\n$" gnus-newsrc-options))
16500 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16501 ;; Finally, if we read some options lines, we parse them.
16502 (or (string= gnus-newsrc-options "")
16503 (gnus-newsrc-parse-options gnus-newsrc-options))))
16505 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16506 (gnus-make-hashtable-from-newsrc-alist)))
16508 (defun gnus-make-newsrc-file (file)
16509 "Make server dependent file name by catenating FILE and server host name."
16510 (let* ((file (expand-file-name file nil))
16511 (real-file (concat file "-" (nth 1 gnus-select-method))))
16512 (if (or (file-exists-p real-file)
16513 (file-exists-p (concat real-file ".el"))
16514 (file-exists-p (concat real-file ".eld")))
16517 (defun gnus-newsrc-to-gnus-format ()
16518 (setq gnus-newsrc-options "")
16519 (setq gnus-newsrc-options-n nil)
16521 (or gnus-active-hashtb
16522 (setq gnus-active-hashtb (make-vector 4095 0)))
16523 (let ((buf (current-buffer))
16524 (already-read (> (length gnus-newsrc-alist) 1))
16525 group subscribed options-symbol newsrc Options-symbol
16527 (goto-char (point-min))
16528 ;; We intern the symbol `options' in the active hashtb so that we
16529 ;; can `eq' against it later.
16530 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16531 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16533 (while (not (eobp))
16534 ;; We first read the first word on the line by narrowing and
16535 ;; then reading into `gnus-active-hashtb'. Most groups will
16536 ;; already exist in that hashtb, so this will save some string
16540 (progn (skip-chars-forward "^ \t!:\n") (point)))
16541 (goto-char (point-min))
16543 (and (/= (point-min) (point-max))
16544 (let ((obarray gnus-active-hashtb)) (read buf))))
16546 ;; Now, the symbol we have read is either `options' or a group
16547 ;; name. If it is an options line, we just add it to a string.
16549 ((or (eq symbol options-symbol)
16550 (eq symbol Options-symbol))
16551 (setq gnus-newsrc-options
16552 ;; This concating is quite inefficient, but since our
16553 ;; thorough studies show that approx 99.37% of all
16554 ;; .newsrc files only contain a single options line, we
16555 ;; don't give a damn, frankly, my dear.
16556 (concat gnus-newsrc-options
16558 (gnus-point-at-bol)
16559 ;; Options may continue on the next line.
16560 (or (and (re-search-forward "^[^ \t]" nil 'move)
16561 (progn (beginning-of-line) (point)))
16565 ;; Group names can be just numbers.
16566 (when (numberp symbol)
16567 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16568 (or (boundp symbol) (set symbol nil))
16569 ;; It was a group name.
16570 (setq subscribed (= (following-char) ?:)
16571 group (symbol-name symbol)
16574 ;; If the line ends here, this is clearly a buggy line, so
16575 ;; we put point a the beginning of line and let the cond
16576 ;; below do the error handling.
16577 (beginning-of-line)
16578 ;; We skip to the beginning of the ranges.
16579 (skip-chars-forward "!: \t"))
16580 ;; We are now at the beginning of the list of read articles.
16581 ;; We read them range by range.
16584 ((looking-at "[0-9]+")
16585 ;; We narrow and read a number instead of buffer-substring/
16586 ;; string-to-int because it's faster. narrow/widen is
16587 ;; faster than save-restriction/narrow, and save-restriction
16588 ;; produces a garbage object.
16590 (narrow-to-region (match-beginning 0) (match-end 0))
16593 ;; If the next character is a dash, then this is a range.
16594 (if (= (following-char) ?-)
16596 ;; We read the upper bound of the range.
16598 (if (not (looking-at "[0-9]+"))
16599 ;; This is a buggy line, by we pretend that
16600 ;; it's kinda OK. Perhaps the user should be
16602 (setq reads (cons num1 reads))
16607 (narrow-to-region (match-beginning 0)
16612 ;; It was just a simple number, so we add it to the
16614 (setq reads (cons num1 reads)))
16615 ;; If the next char in ?\n, then we have reached the end
16616 ;; of the line and return nil.
16617 (/= (following-char) ?\n))
16618 ((= (following-char) ?\n)
16619 ;; End of line, so we end.
16622 ;; Not numbers and not eol, so this might be a buggy
16625 ;; If it was eob instead of ?\n, we allow it.
16627 ;; The line was buggy.
16629 (gnus-error 3.1 "Mangled line: %s"
16630 (buffer-substring (gnus-point-at-bol)
16631 (gnus-point-at-eol)))))
16633 ;; Skip past ", ". Spaces are illegal in these ranges, but
16634 ;; we allow them, because it's a common mistake to put a
16635 ;; space after the comma.
16636 (skip-chars-forward ", "))
16638 ;; We have already read .newsrc.eld, so we gently update the
16639 ;; data in the hash table with the information we have just
16642 (let ((info (gnus-get-info group))
16645 ;; There is an entry for this file in the alist.
16647 (gnus-info-set-read info (nreverse reads))
16648 ;; We update the level very gently. In fact, we
16649 ;; only change it if there's been a status change
16650 ;; from subscribed to unsubscribed, or vice versa.
16651 (setq level (gnus-info-level info))
16652 (cond ((and (<= level gnus-level-subscribed)
16654 (setq level (if reads
16655 gnus-level-default-unsubscribed
16656 (1+ gnus-level-default-unsubscribed))))
16657 ((and (> level gnus-level-subscribed) subscribed)
16658 (setq level gnus-level-default-subscribed)))
16659 (gnus-info-set-level info level))
16660 ;; This is a new group.
16661 (setq info (list group
16663 gnus-level-default-subscribed
16665 (1+ gnus-level-subscribed)
16666 gnus-level-default-unsubscribed))
16667 (nreverse reads))))
16668 (setq newsrc (cons info newsrc))))))
16671 (setq newsrc (nreverse newsrc))
16673 (if (not already-read)
16675 ;; We now have two newsrc lists - `newsrc', which is what we
16676 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16677 ;; what we've read from .newsrc.eld. We have to merge these
16678 ;; lists. We do this by "attaching" any (foreign) groups in the
16679 ;; gnus-newsrc-alist to the (native) group that precedes them.
16680 (let ((rc (cdr gnus-newsrc-alist))
16681 (prev gnus-newsrc-alist)
16684 (or (null (nth 4 (car rc))) ; It's a native group.
16685 (assoc (caar rc) newsrc) ; It's already in the alist.
16686 (if (setq entry (assoc (caar prev) newsrc))
16687 (setcdr (setq mentry (memq entry newsrc))
16688 (cons (car rc) (cdr mentry)))
16689 (setq newsrc (cons (car rc) newsrc))))
16693 (setq gnus-newsrc-alist newsrc)
16694 ;; We make the newsrc hashtb.
16695 (gnus-make-hashtable-from-newsrc-alist)
16697 ;; Finally, if we read some options lines, we parse them.
16698 (or (string= gnus-newsrc-options "")
16699 (gnus-newsrc-parse-options gnus-newsrc-options))))
16701 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16702 ;; The return value will be a list on the form
16703 ;; ((regexp1 . ignore)
16704 ;; (regexp2 . subscribe)...)
16705 ;; When handling new newsgroups, groups that match a `ignore' regexp
16706 ;; will be ignored, and groups that match a `subscribe' regexp will be
16707 ;; subscribed. A line like
16708 ;; options -n !all rec.all
16709 ;; will lead to a list that looks like
16710 ;; (("^rec\\..+" . subscribe)
16711 ;; ("^.+" . ignore))
16712 ;; So all "rec.*" groups will be subscribed, while all the other
16713 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16714 ;; different from "options -n rec.all !all".
16715 (defun gnus-newsrc-parse-options (options)
16718 (gnus-set-work-buffer)
16719 (insert (regexp-quote options))
16720 ;; First we treat all continuation lines.
16721 (goto-char (point-min))
16722 (while (re-search-forward "\n[ \t]+" nil t)
16723 (replace-match " " t t))
16724 ;; Then we transform all "all"s into ".+"s.
16725 (goto-char (point-min))
16726 (while (re-search-forward "\\ball\\b" nil t)
16727 (replace-match ".+" t t))
16728 (goto-char (point-min))
16729 ;; We remove all other options than the "-n" ones.
16730 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16731 (replace-match " ")
16733 (goto-char (point-min))
16735 ;; We are only interested in "options -n" lines - we
16736 ;; ignore the other option lines.
16737 (while (re-search-forward "[ \t]-n" nil t)
16739 (or (save-excursion
16740 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16742 (gnus-point-at-eol)))
16743 ;; Search for all "words"...
16744 (while (re-search-forward "[^ \t,\n]+" eol t)
16745 (if (= (char-after (match-beginning 0)) ?!)
16746 ;; If the word begins with a bang (!), this is a "not"
16747 ;; spec. We put this spec (minus the bang) and the
16748 ;; symbol `ignore' into the list.
16749 (setq out (cons (cons (concat
16750 "^" (buffer-substring
16751 (1+ (match-beginning 0))
16754 ;; There was no bang, so this is a "yes" spec.
16755 (setq out (cons (cons (concat "^" (match-string 0))
16756 'subscribe) out)))))
16758 (setq gnus-newsrc-options-n out))))
16760 (defun gnus-save-newsrc-file (&optional force)
16761 "Save .newsrc file."
16762 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16763 ;; from the variable gnus-newsrc-alist.
16764 (when (and (or gnus-newsrc-alist gnus-killed-list)
16765 gnus-current-startup-file)
16767 (if (and (or gnus-use-dribble-file gnus-slave)
16769 (or (not gnus-dribble-buffer)
16770 (not (buffer-name gnus-dribble-buffer))
16771 (zerop (save-excursion
16772 (set-buffer gnus-dribble-buffer)
16774 (gnus-message 4 "(No changes need to be saved)")
16775 (run-hooks 'gnus-save-newsrc-hook)
16777 (gnus-slave-save-newsrc)
16779 (when gnus-save-newsrc-file
16780 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16781 (gnus-gnus-to-newsrc-format)
16782 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16783 ;; Save .newsrc.eld.
16784 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16785 (make-local-variable 'version-control)
16786 (setq version-control 'never)
16787 (setq buffer-file-name
16788 (concat gnus-current-startup-file ".eld"))
16789 (setq default-directory (file-name-directory buffer-file-name))
16790 (gnus-add-current-to-buffer-list)
16791 (buffer-disable-undo (current-buffer))
16793 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16794 (gnus-gnus-to-quick-newsrc-format)
16795 (run-hooks 'gnus-save-quick-newsrc-hook)
16797 (kill-buffer (current-buffer))
16799 5 "Saving %s.eld...done" gnus-current-startup-file))
16800 (gnus-dribble-delete-file)
16801 (gnus-group-set-mode-line)))))
16803 (defun gnus-gnus-to-quick-newsrc-format ()
16804 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16805 (insert ";; Gnus startup file.\n")
16806 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16807 (insert ";; to read .newsrc.\n")
16808 (insert "(setq gnus-newsrc-file-version "
16809 (prin1-to-string gnus-version) ")\n")
16811 (if gnus-save-killed-list gnus-variable-list
16812 ;; Remove the `gnus-killed-list' from the list of variables
16813 ;; to be saved, if required.
16814 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16815 ;; Peel off the "dummy" group.
16816 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16818 ;; Insert the variables into the file.
16820 (when (and (boundp (setq variable (pop variables)))
16821 (symbol-value variable))
16822 (insert "(setq " (symbol-name variable) " '")
16823 (prin1 (symbol-value variable) (current-buffer))
16826 (defun gnus-gnus-to-newsrc-format ()
16827 ;; Generate and save the .newsrc file.
16829 (set-buffer (create-file-buffer gnus-current-startup-file))
16830 (let ((newsrc (cdr gnus-newsrc-alist))
16831 (standard-output (current-buffer))
16832 info ranges range method)
16833 (setq buffer-file-name gnus-current-startup-file)
16834 (setq default-directory (file-name-directory buffer-file-name))
16835 (buffer-disable-undo (current-buffer))
16838 (if gnus-newsrc-options (insert gnus-newsrc-options))
16839 ;; Write subscribed and unsubscribed.
16840 (while (setq info (pop newsrc))
16841 ;; Don't write foreign groups to .newsrc.
16842 (when (or (null (setq method (gnus-info-method info)))
16843 (equal method "native")
16844 (gnus-server-equal method gnus-select-method))
16845 (insert (gnus-info-group info)
16846 (if (> (gnus-info-level info) gnus-level-subscribed)
16848 (when (setq ranges (gnus-info-read info))
16850 (if (not (listp (cdr ranges)))
16851 (if (= (car ranges) (cdr ranges))
16852 (princ (car ranges))
16853 (princ (car ranges))
16855 (princ (cdr ranges)))
16856 (while (setq range (pop ranges))
16857 (if (or (atom range) (= (car range) (cdr range)))
16858 (princ (or (and (atom range) range) (car range)))
16859 (princ (car range))
16861 (princ (cdr range)))
16862 (if ranges (insert ",")))))
16864 (make-local-variable 'version-control)
16865 (setq version-control 'never)
16866 ;; It has been reported that sometime the modtime on the .newsrc
16867 ;; file seems to be off. We really do want to overwrite it, so
16868 ;; we clear the modtime here before saving. It's a bit odd,
16870 ;; sometimes the modtime clear isn't sufficient. most brute force:
16871 ;; delete the silly thing entirely first. but this fails to provide
16872 ;; such niceties as .newsrc~ creation.
16873 (if gnus-modtime-botch
16874 (delete-file gnus-startup-file)
16875 (clear-visited-file-modtime))
16876 (run-hooks 'gnus-save-standard-newsrc-hook)
16878 (kill-buffer (current-buffer)))))
16882 ;;; Slave functions.
16885 (defun gnus-slave-save-newsrc ()
16887 (set-buffer gnus-dribble-buffer)
16889 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16890 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16892 (defun gnus-master-read-slave-newsrc ()
16895 (file-name-directory gnus-current-startup-file)
16899 (file-name-nondirectory gnus-current-startup-file)
16903 (if (not slave-files)
16904 () ; There are no slave files to read.
16905 (gnus-message 7 "Reading slave newsrcs...")
16907 (set-buffer (get-buffer-create " *gnus slave*"))
16908 (buffer-disable-undo (current-buffer))
16910 (sort (mapcar (lambda (file)
16911 (list (nth 5 (file-attributes file)) file))
16914 (or (< (caar f1) (caar f2))
16915 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16918 (setq file (nth 1 (car slave-files)))
16919 (insert-file-contents file)
16920 (if (condition-case ()
16922 (eval-buffer (current-buffer))
16925 (gnus-error 3.2 "Possible error in %s" file)
16927 (or gnus-slave ; Slaves shouldn't delete these files.
16931 (setq slave-files (cdr slave-files))))
16932 (gnus-message 7 "Reading slave newsrcs...done"))))
16936 ;;; Group description.
16939 (defun gnus-read-all-descriptions-files ()
16940 (let ((methods (cons gnus-select-method
16942 (when gnus-message-archive-method
16944 gnus-secondary-select-methods))))
16946 (gnus-read-descriptions-file (car methods))
16947 (setq methods (cdr methods)))
16950 (defun gnus-read-descriptions-file (&optional method)
16951 (let ((method (or method gnus-select-method)))
16952 (when (stringp method)
16953 (setq method (gnus-server-to-method method)))
16954 ;; We create the hashtable whether we manage to read the desc file
16955 ;; to avoid trying to re-read after a failed read.
16956 (or gnus-description-hashtb
16957 (setq gnus-description-hashtb
16958 (gnus-make-hashtable (length gnus-active-hashtb))))
16959 ;; Mark this method's desc file as read.
16960 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16961 gnus-description-hashtb)
16963 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16965 ((not (gnus-check-server method))
16966 (gnus-message 1 "Couldn't open server")
16968 ((not (gnus-request-list-newsgroups method))
16969 (gnus-message 1 "Couldn't read newsgroups descriptions")
16975 (set-buffer nntp-server-buffer)
16976 (goto-char (point-min))
16977 (if (or (search-forward "\n.\n" nil t)
16978 (goto-char (point-max)))
16980 (beginning-of-line)
16981 (narrow-to-region (point-min) (point))))
16982 (goto-char (point-min))
16983 (while (not (eobp))
16984 ;; If we get an error, we set group to 0, which is not a
16988 (let ((obarray gnus-description-hashtb))
16989 ;; Group is set to a symbol interned in this
16991 (read nntp-server-buffer))
16993 (skip-chars-forward " \t")
16994 ;; ... which leads to this line being effectively ignored.
16995 (and (symbolp group)
16996 (set group (buffer-substring
16997 (point) (progn (end-of-line) (point)))))
16998 (forward-line 1))))
16999 (gnus-message 5 "Reading descriptions file...done")
17002 (defun gnus-group-get-description (group)
17003 "Get the description of a group by sending XGTITLE to the server."
17004 (when (gnus-request-group-description group)
17006 (set-buffer nntp-server-buffer)
17007 (goto-char (point-min))
17008 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17009 (match-string 1)))))
17013 ;;; Buffering of read articles.
17016 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17017 (defvar gnus-backlog-articles nil)
17018 (defvar gnus-backlog-hashtb nil)
17020 (defun gnus-backlog-buffer ()
17021 "Return the backlog buffer."
17022 (or (get-buffer gnus-backlog-buffer)
17024 (set-buffer (get-buffer-create gnus-backlog-buffer))
17025 (buffer-disable-undo (current-buffer))
17026 (setq buffer-read-only t)
17027 (gnus-add-current-to-buffer-list)
17028 (get-buffer gnus-backlog-buffer))))
17030 (defun gnus-backlog-setup ()
17031 "Initialize backlog variables."
17032 (unless gnus-backlog-hashtb
17033 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17035 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17037 (defun gnus-backlog-shutdown ()
17038 "Clear all backlog variables and buffers."
17039 (when (get-buffer gnus-backlog-buffer)
17040 (kill-buffer gnus-backlog-buffer))
17041 (setq gnus-backlog-hashtb nil
17042 gnus-backlog-articles nil))
17044 (defun gnus-backlog-enter-article (group number buffer)
17045 (gnus-backlog-setup)
17046 (let ((ident (intern (concat group ":" (int-to-string number))
17047 gnus-backlog-hashtb))
17049 (if (memq ident gnus-backlog-articles)
17050 () ; It's already kept.
17051 ;; Remove the oldest article, if necessary.
17052 (and (numberp gnus-keep-backlog)
17053 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17054 (gnus-backlog-remove-oldest-article))
17055 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17056 ;; Insert the new article.
17058 (set-buffer (gnus-backlog-buffer))
17059 (let (buffer-read-only)
17060 (goto-char (point-max))
17061 (or (bolp) (insert "\n"))
17063 (insert-buffer-substring buffer)
17064 ;; Tag the beginning of the article with the ident.
17065 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17067 (defun gnus-backlog-remove-oldest-article ()
17069 (set-buffer (gnus-backlog-buffer))
17070 (goto-char (point-min))
17071 (if (zerop (buffer-size))
17072 () ; The buffer is empty.
17073 (let ((ident (get-text-property (point) 'gnus-backlog))
17075 ;; Remove the ident from the list of articles.
17077 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17078 ;; Delete the article itself.
17080 (point) (next-single-property-change
17081 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17083 (defun gnus-backlog-remove-article (group number)
17084 "Remove article NUMBER in GROUP from the backlog."
17085 (when (numberp number)
17086 (gnus-backlog-setup)
17087 (let ((ident (intern (concat group ":" (int-to-string number))
17088 gnus-backlog-hashtb))
17090 (when (memq ident gnus-backlog-articles)
17091 ;; It was in the backlog.
17093 (set-buffer (gnus-backlog-buffer))
17094 (let (buffer-read-only)
17095 (when (setq beg (text-property-any
17096 (point-min) (point-max) 'gnus-backlog
17098 ;; Find the end (i. e., the beginning of the next article).
17100 (next-single-property-change
17101 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17102 (delete-region beg end)
17106 (defun gnus-backlog-request-article (group number buffer)
17107 (when (numberp number)
17108 (gnus-backlog-setup)
17109 (let ((ident (intern (concat group ":" (int-to-string number))
17110 gnus-backlog-hashtb))
17112 (when (memq ident gnus-backlog-articles)
17113 ;; It was in the backlog.
17115 (set-buffer (gnus-backlog-buffer))
17116 (if (not (setq beg (text-property-any
17117 (point-min) (point-max) 'gnus-backlog
17119 ;; It wasn't in the backlog after all.
17121 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17122 ;; Find the end (i. e., the beginning of the next article).
17124 (next-single-property-change
17125 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17126 (let ((buffer-read-only nil))
17128 (insert-buffer-substring gnus-backlog-buffer beg end)
17131 ;; Allow redefinition of Gnus functions.
17133 (gnus-ems-redefine)
17137 ;;; gnus.el ends here