1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
37 (eval-when-compile (require 'cl))
39 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
40 "*Directory variable from which all other Gnus file variables are derived.")
42 ;; Site dependent variables. These variables should be defined in
45 (defvar gnus-default-nntp-server nil
46 "Specify a default NNTP server.
47 This variable should be defined in paths.el, and should never be set
49 If you want to change servers, you should use `gnus-select-method'.
50 See the documentation to that variable.")
52 (defvar gnus-backup-default-subscribed-newsgroups
53 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
54 "Default default new newsgroups the first time Gnus is run.
55 Should be set in paths.el, and shouldn't be touched by the user.")
57 (defvar gnus-local-domain nil
58 "Local domain name without a host name.
59 The DOMAINNAME environment variable is used instead if it is defined.
60 If the `system-name' function returns the full Internet name, there is
61 no need to set this variable.")
63 (defvar gnus-local-organization nil
64 "String with a description of what organization (if any) the user belongs to.
65 The ORGANIZATION environment variable is used instead if it is defined.
66 If this variable contains a function, this function will be called
67 with the current newsgroup name as the argument. The function should
70 In any case, if the string (either in the variable, in the environment
71 variable, or returned by the function) is a file name, the contents of
72 this file will be used as the organization.")
74 ;; Customization variables
76 ;; Don't touch this variable.
77 (defvar gnus-nntp-service "nntp"
78 "*NNTP service name (\"nntp\" or 119).
79 This is an obsolete variable, which is scarcely used. If you use an
80 nntp server for your newsgroup and want to change the port number
81 used to 899, you would say something along these lines:
83 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
85 (defvar gnus-nntpserver-file "/etc/nntpserver"
86 "*A file with only the name of the nntp server in it.")
88 ;; This function is used to check both the environment variable
89 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
90 ;; an nntp server name default.
91 (defun gnus-getenv-nntpserver ()
92 (or (getenv "NNTPSERVER")
93 (and (file-readable-p gnus-nntpserver-file)
95 (set-buffer (get-buffer-create " *gnus nntp*"))
96 (buffer-disable-undo (current-buffer))
97 (insert-file-contents gnus-nntpserver-file)
98 (let ((name (buffer-string)))
100 (if (string-match "^[ \t\n]*$" name)
103 (kill-buffer (current-buffer))))))))
105 (defvar gnus-select-method
107 (list 'nntp (or (condition-case ()
108 (gnus-getenv-nntpserver)
110 (if (and gnus-default-nntp-server
111 (not (string= gnus-default-nntp-server "")))
112 gnus-default-nntp-server)
114 (if (or (null gnus-nntp-service)
115 (equal gnus-nntp-service "nntp"))
117 (list gnus-nntp-service)))
118 "*Default method for selecting a newsgroup.
119 This variable should be a list, where the first element is how the
120 news is to be fetched, the second is the address.
122 For instance, if you want to get your news via NNTP from
123 \"flab.flab.edu\", you could say:
125 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
127 If you want to use your local spool, say:
129 (setq gnus-select-method (list 'nnspool (system-name)))
131 If you use this variable, you must set `gnus-nntp-server' to nil.
133 There is a lot more to know about select methods and virtual servers -
134 see the manual for details.")
136 (defvar gnus-message-archive-method
139 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
140 (nnfolder-active-file
141 ,(nnheader-concat message-directory "archive/active"))
142 (nnfolder-get-new-mail nil)
143 (nnfolder-inhibit-expiry t))
144 "*Method used for archiving messages you've sent.
145 This should be a mail method.
147 It's probably not a very effective to change this variable once you've
148 run Gnus once. After doing that, you must edit this server from the
151 (defvar gnus-message-archive-group nil
152 "*Name of the group in which to save the messages you've written.
153 This can either be a string, a list of strings; or an alist
154 of regexps/functions/forms to be evaluated to return a string (or a list
155 of strings). The functions are called with the name of the current
156 group (or nil) as a parameter.
158 If you want to save your mail in one group and the news articles you
159 write in another group, you could say something like:
161 \(setq gnus-message-archive-group
162 '((if (message-news-p)
166 Normally the group names returned by this variable should be
167 unprefixed -- which implictly means \"store on the archive server\".
168 However, you may wish to store the message on some other server. In
169 that case, just return a fully prefixed name of the group --
170 \"nnml+private:mail.misc\", for instance.")
172 (defvar gnus-refer-article-method nil
173 "*Preferred method for fetching an article by Message-ID.
174 If you are reading news from the local spool (with nnspool), fetching
175 articles by Message-ID is painfully slow. By setting this method to an
176 nntp method, you might get acceptable results.
178 The value of this variable must be a valid select method as discussed
179 in the documentation of `gnus-select-method'.")
181 (defvar gnus-secondary-select-methods nil
182 "*A list of secondary methods that will be used for reading news.
183 This is a list where each element is a complete select method (see
184 `gnus-select-method').
186 If, for instance, you want to read your mail with the nnml backend,
187 you could set this variable:
189 (setq gnus-secondary-select-methods '((nnml \"\")))")
191 (defvar gnus-secondary-servers nil
192 "*List of NNTP servers that the user can choose between interactively.
193 To make Gnus query you for a server, you have to give `gnus' a
194 non-numeric prefix - `C-u M-x gnus', in short.")
196 (defvar gnus-nntp-server nil
197 "*The name of the host running the NNTP server.
198 This variable is semi-obsolete. Use the `gnus-select-method'
201 (defvar gnus-startup-file "~/.newsrc"
202 "*Your `.newsrc' file.
203 `.newsrc-SERVER' will be used instead if that exists.")
205 (defvar gnus-init-file "~/.gnus"
206 "*Your Gnus elisp startup file.
207 If a file with the .el or .elc suffixes exist, it will be read
210 (defvar gnus-group-faq-directory
211 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
212 "/ftp@sunsite.auc.dk:/pub/usenet/"
213 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
214 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
215 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
216 "/ftp@rtfm.mit.edu:/pub/usenet/"
217 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
218 "/ftp@ftp.sunet.se:/pub/usenet/"
219 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
220 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
221 "/ftp@ftp.hk.super.net:/mirror/faqs/")
222 "*Directory where the group FAQs are stored.
223 This will most commonly be on a remote machine, and the file will be
226 This variable can also be a list of directories. In that case, the
227 first element in the list will be used by default. The others can
228 be used when being prompted for a site.
230 Note that Gnus uses an aol machine as the default directory. If this
231 feels fundamentally unclean, just think of it as a way to finally get
232 something of value back from them.
234 If the default site is too slow, try one of these:
236 North America: mirrors.aol.com /pub/rtfm/usenet
237 ftp.seas.gwu.edu /pub/rtfm
238 rtfm.mit.edu /pub/usenet
239 Europe: ftp.uni-paderborn.de /pub/FAQ
240 src.doc.ic.ac.uk /usenet/news-FAQS
241 ftp.sunet.se /pub/usenet
242 sunsite.auc.dk /pub/usenet
243 Asia: nctuccca.edu.tw /USENET/FAQ
244 hwarang.postech.ac.kr /pub/usenet
245 ftp.hk.super.net /mirror/faqs")
247 (defvar gnus-group-archive-directory
248 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
249 "*The address of the (ding) archives.")
251 (defvar gnus-group-recent-archive-directory
252 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
253 "*The address of the most recent (ding) articles.")
255 (defvar gnus-default-subscribed-newsgroups nil
256 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
257 It should be a list of strings.
258 If it is `t', Gnus will not do anything special the first time it is
259 started; it'll just use the normal newsgroups subscription methods.")
261 (defvar gnus-use-cross-reference t
262 "*Non-nil means that cross referenced articles will be marked as read.
263 If nil, ignore cross references. If t, mark articles as read in
264 subscribed newsgroups. If neither t nor nil, mark as read in all
267 (defvar gnus-single-article-buffer t
268 "*If non-nil, display all articles in the same buffer.
269 If nil, each group will get its own article buffer.")
271 (defvar gnus-use-dribble-file t
272 "*Non-nil means that Gnus will use a dribble file to store user updates.
273 If Emacs should crash without saving the .newsrc files, complete
274 information can be restored from the dribble file.")
276 (defvar gnus-dribble-directory nil
277 "*The directory where dribble files will be saved.
278 If this variable is nil, the directory where the .newsrc files are
279 saved will be used.")
281 (defvar gnus-asynchronous nil
282 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
284 (defvar gnus-kill-summary-on-exit t
285 "*If non-nil, kill the summary buffer when you exit from it.
286 If nil, the summary will become a \"*Dead Summary*\" buffer, and
287 it will be killed sometime later.")
289 (defvar gnus-large-newsgroup 200
290 "*The number of articles which indicates a large newsgroup.
291 If the number of articles in a newsgroup is greater than this value,
292 confirmation is required for selecting the newsgroup.")
294 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
295 (defvar gnus-no-groups-message "No news is horrible news"
296 "*Message displayed by Gnus when no groups are available.")
298 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
299 "*Non-nil means that the default name of a file to save articles in is the group name.
300 If it's nil, the directory form of the group name is used instead.
302 If this variable is a list, and the list contains the element
303 `not-score', long file names will not be used for score files; if it
304 contains the element `not-save', long file names will not be used for
305 saving; and if it contains the element `not-kill', long file names
306 will not be used for kill files.
308 Note that the default for this variable varies according to what system
309 type you're using. On `usg-unix-v' and `xenix' this variable defaults
310 to nil while on all other systems it defaults to t.")
312 (defvar gnus-article-save-directory gnus-directory
313 "*Name of the directory articles will be saved in (default \"~/News\").")
315 (defvar gnus-kill-files-directory gnus-directory
316 "*Name of the directory where kill files will be stored (default \"~/News\").")
318 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
319 "*A function to save articles in your favorite format.
320 The function must be interactively callable (in other words, it must
321 be an Emacs command).
323 Gnus provides the following functions:
325 * gnus-summary-save-in-rmail (Rmail format)
326 * gnus-summary-save-in-mail (Unix mail format)
327 * gnus-summary-save-in-folder (MH folder)
328 * gnus-summary-save-in-file (article format).
329 * gnus-summary-save-in-vm (use VM's folder format).")
331 (defvar gnus-prompt-before-saving 'always
332 "*This variable says how much prompting is to be done when saving articles.
333 If it is nil, no prompting will be done, and the articles will be
334 saved to the default files. If this variable is `always', each and
335 every article that is saved will be preceded by a prompt, even when
336 saving large batches of articles. If this variable is neither nil not
337 `always', there the user will be prompted once for a file name for
338 each invocation of the saving commands.")
340 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
341 "*A function generating a file name to save articles in Rmail format.
342 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
344 (defvar gnus-mail-save-name (function gnus-plain-save-name)
345 "*A function generating a file name to save articles in Unix mail format.
346 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
348 (defvar gnus-folder-save-name (function gnus-folder-save-name)
349 "*A function generating a file name to save articles in MH folder.
350 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
352 (defvar gnus-file-save-name (function gnus-numeric-save-name)
353 "*A function generating a file name to save articles in article format.
354 The function is called with NEWSGROUP, HEADERS, and optional
357 (defvar gnus-split-methods
358 '((gnus-article-archive-name))
359 "*Variable used to suggest where articles are to be saved.
360 For instance, if you would like to save articles related to Gnus in
361 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
362 you could set this variable to something like:
364 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
365 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
367 This variable is an alist where the where the key is the match and the
368 value is a list of possible files to save in if the match is non-nil.
370 If the match is a string, it is used as a regexp match on the
371 article. If the match is a symbol, that symbol will be funcalled
372 from the buffer of the article to be saved with the newsgroup as the
373 parameter. If it is a list, it will be evaled in the same buffer.
375 If this form or function returns a string, this string will be used as
376 a possible file name; and if it returns a non-nil list, that list will
377 be used as possible file names.")
379 (defvar gnus-move-split-methods nil
380 "*Variable used to suggest where articles are to be moved to.
381 It uses the same syntax as the `gnus-split-methods' variable.")
383 (defvar gnus-save-score nil
384 "*If non-nil, save group scoring info.")
386 (defvar gnus-use-adaptive-scoring nil
387 "*If non-nil, use some adaptive scoring scheme.")
389 (defvar gnus-use-cache 'passive
390 "*If nil, Gnus will ignore the article cache.
391 If `passive', it will allow entering (and reading) articles
392 explicitly entered into the cache. If anything else, use the
393 cache to the full extent of the law.")
395 (defvar gnus-use-trees nil
396 "*If non-nil, display a thread tree buffer.")
398 (defvar gnus-use-grouplens nil
399 "*If non-nil, use GroupLens ratings.")
401 (defvar gnus-keep-backlog nil
402 "*If non-nil, Gnus will keep read articles for later re-retrieval.
403 If it is a number N, then Gnus will only keep the last N articles
404 read. If it is neither nil nor a number, Gnus will keep all read
405 articles. This is not a good idea.")
407 (defvar gnus-use-nocem nil
408 "*If non-nil, Gnus will read NoCeM cancel messages.")
410 (defvar gnus-use-demon nil
411 "If non-nil, Gnus might use some demons.")
413 (defvar gnus-use-scoring t
414 "*If non-nil, enable scoring.")
416 (defvar gnus-use-picons nil
417 "*If non-nil, display picons.")
419 (defvar gnus-fetch-old-headers nil
420 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
421 If an unread article in the group refers to an older, already read (or
422 just marked as read) article, the old article will not normally be
423 displayed in the Summary buffer. If this variable is non-nil, Gnus
424 will attempt to grab the headers to the old articles, and thereby
425 build complete threads. If it has the value `some', only enough
426 headers to connect otherwise loose threads will be displayed.
427 This variable can also be a number. In that case, no more than that
428 number of old headers will be fetched.
430 The server has to support NOV for any of this to work.")
433 ;(defvar gnus-visual t
434 ; "*If non-nil, will do various highlighting.
435 ;If nil, no mouse highlights (or any other highlights) will be
436 ;performed. This might speed up Gnus some when generating large group
437 ;and summary buffers.")
439 (defvar gnus-novice-user t
440 "*Non-nil means that you are a usenet novice.
441 If non-nil, verbose messages may be displayed and confirmations may be
444 (defvar gnus-expert-user nil
445 "*Non-nil means that you will never be asked for confirmation about anything.
446 And that means *anything*.")
448 (defvar gnus-verbose 7
449 "*Integer that says how verbose Gnus should be.
450 The higher the number, the more messages Gnus will flash to say what
451 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
452 display most important messages; and at ten, Gnus will keep on
453 jabbering all the time.")
455 (defvar gnus-keep-same-level nil
456 "*Non-nil means that the next newsgroup after the current will be on the same level.
457 When you type, for instance, `n' after reading the last article in the
458 current newsgroup, you will go to the next newsgroup. If this variable
459 is nil, the next newsgroup will be the next from the group
461 If this variable is non-nil, Gnus will either put you in the
462 next newsgroup with the same level, or, if no such newsgroup is
463 available, the next newsgroup with the lowest possible level higher
464 than the current level.
465 If this variable is `best', Gnus will make the next newsgroup the one
466 with the best level.")
468 (defvar gnus-summary-make-false-root 'adopt
469 "*nil means that Gnus won't gather loose threads.
470 If the root of a thread has expired or been read in a previous
471 session, the information necessary to build a complete thread has been
472 lost. Instead of having many small sub-threads from this original thread
473 scattered all over the summary buffer, Gnus can gather them.
475 If non-nil, Gnus will try to gather all loose sub-threads from an
476 original thread into one large thread.
478 If this variable is non-nil, it should be one of `none', `adopt',
481 If this variable is `none', Gnus will not make a false root, but just
482 present the sub-threads after another.
483 If this variable is `dummy', Gnus will create a dummy root that will
484 have all the sub-threads as children.
485 If this variable is `adopt', Gnus will make one of the \"children\"
486 the parent and mark all the step-children as such.
487 If this variable is `empty', the \"children\" are printed with empty
488 subject fields. (Or rather, they will be printed with a string
489 given by the `gnus-summary-same-subject' variable.)")
491 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
492 "*A regexp to match subjects to be excluded from loose thread gathering.
493 As loose thread gathering is done on subjects only, that means that
494 there can be many false gatherings performed. By rooting out certain
495 common subjects, gathering might become saner.")
497 (defvar gnus-summary-gather-subject-limit nil
498 "*Maximum length of subject comparisons when gathering loose threads.
499 Use nil to compare full subjects. Setting this variable to a low
500 number will help gather threads that have been corrupted by
501 newsreaders chopping off subject lines, but it might also mean that
502 unrelated articles that have subject that happen to begin with the
503 same few characters will be incorrectly gathered.
505 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
506 comparing subjects.")
508 (defvar gnus-simplify-ignored-prefixes nil
509 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily.")
511 (defvar gnus-build-sparse-threads nil
512 "*If non-nil, fill in the gaps in threads.
513 If `some', only fill in the gaps that are needed to tie loose threads
514 together. If `more', fill in all leaf nodes that Gnus can find. If
515 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
517 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
518 "Function used for gathering loose threads.
519 There are two pre-defined functions: `gnus-gather-threads-by-subject',
520 which only takes Subjects into consideration; and
521 `gnus-gather-threads-by-references', which compared the References
522 headers of the articles to find matches.")
524 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
525 (defvar gnus-summary-same-subject ""
526 "*String indicating that the current article has the same subject as the previous.
527 This variable will only be used if the value of
528 `gnus-summary-make-false-root' is `empty'.")
530 (defvar gnus-summary-goto-unread t
531 "*If non-nil, marking commands will go to the next unread article.
532 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
533 whether it is read or not.")
535 (defvar gnus-group-goto-unread t
536 "*If non-nil, movement commands will go to the next unread and subscribed group.")
538 (defvar gnus-goto-next-group-when-activating t
539 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
541 (defvar gnus-check-new-newsgroups t
542 "*Non-nil means that Gnus will run gnus-find-new-newsgroups at startup.
543 This normally finds new newsgroups by comparing the active groups the
544 servers have already reported with those Gnus already knows, either alive
547 When any of the following are true, gnus-find-new-newsgroups will instead
548 ask the servers (primary, secondary, and archive servers) to list new
549 groups since the last time it checked:
550 1. This variable is `ask-server'.
551 2. This variable is a list of select methods (see below).
552 3. `gnus-read-active-file' is nil or `some'.
553 4. A prefix argument is given to gnus-find-new-newsgroups interactively.
555 Thus, if this variable is `ask-server' or a list of select methods or
556 `gnus-read-active-file' is nil or `some', then the killed list is no
557 longer necessary, so you could safely set `gnus-save-killed-list' to nil.
559 This variable can be a list of select methods which Gnus will query with
560 the `ask-server' method in addition to the primary, secondary, and archive
564 (setq gnus-check-new-newsgroups
565 '((nntp \"some.server\") (nntp \"other.server\")))
567 If this variable is nil, then you have to tell Gnus explicitly to
568 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
570 (defvar gnus-check-bogus-newsgroups nil
571 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
572 If this variable is nil, then you have to tell Gnus explicitly to
573 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
575 (defvar gnus-read-active-file t
576 "*Non-nil means that Gnus will read the entire active file at startup.
577 If this variable is nil, Gnus will only know about the groups in your
580 If this variable is `some', Gnus will try to only read the relevant
581 parts of the active file from the server. Not all servers support
582 this, and it might be quite slow with other servers, but this should
583 generally be faster than both the t and nil value.
585 If you set this variable to nil or `some', you probably still want to
586 be told about new newsgroups that arrive. To do that, set
587 `gnus-check-new-newsgroups' to `ask-server'. This may not work
588 properly with all servers.")
590 (defvar gnus-level-subscribed 5
591 "*Groups with levels less than or equal to this variable are subscribed.")
593 (defvar gnus-level-unsubscribed 7
594 "*Groups with levels less than or equal to this variable are unsubscribed.
595 Groups with levels less than `gnus-level-subscribed', which should be
596 less than this variable, are subscribed.")
598 (defvar gnus-level-zombie 8
599 "*Groups with this level are zombie groups.")
601 (defvar gnus-level-killed 9
602 "*Groups with this level are killed.")
604 (defvar gnus-level-default-subscribed 3
605 "*New subscribed groups will be subscribed at this level.")
607 (defvar gnus-level-default-unsubscribed 6
608 "*New unsubscribed groups will be unsubscribed at this level.")
610 (defvar gnus-activate-level (1+ gnus-level-subscribed)
611 "*Groups higher than this level won't be activated on startup.
612 Setting this variable to something log might save lots of time when
613 you have many groups that you aren't interested in.")
615 (defvar gnus-activate-foreign-newsgroups 4
616 "*If nil, Gnus will not check foreign newsgroups at startup.
617 If it is non-nil, it should be a number between one and nine. Foreign
618 newsgroups that have a level lower or equal to this number will be
619 activated on startup. For instance, if you want to active all
620 subscribed newsgroups, but not the rest, you'd set this variable to
621 `gnus-level-subscribed'.
623 If you subscribe to lots of newsgroups from different servers, startup
624 might take a while. By setting this variable to nil, you'll save time,
625 but you won't be told how many unread articles there are in the
628 (defvar gnus-save-newsrc-file t
629 "*Non-nil means that Gnus will save the `.newsrc' file.
630 Gnus always saves its own startup file, which is called
631 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
632 be readily understood by other newsreaders. If you don't plan on
633 using other newsreaders, set this variable to nil to save some time on
636 (defvar gnus-save-killed-list t
637 "*If non-nil, save the list of killed groups to the startup file.
638 If you set this variable to nil, you'll save both time (when starting
639 and quitting) and space (both memory and disk), but it will also mean
640 that Gnus has no record of which groups are new and which are old, so
641 the automatic new newsgroups subscription methods become meaningless.
643 You should always set `gnus-check-new-newsgroups' to `ask-server' or
644 nil if you set this variable to nil.")
646 (defvar gnus-interactive-catchup t
647 "*If non-nil, require your confirmation when catching up a group.")
649 (defvar gnus-interactive-exit t
650 "*If non-nil, require your confirmation when exiting Gnus.")
652 (defvar gnus-kill-killed t
653 "*If non-nil, Gnus will apply kill files to already killed articles.
654 If it is nil, Gnus will never apply kill files to articles that have
655 already been through the scoring process, which might very well save lots
658 (defvar gnus-extract-address-components 'gnus-extract-address-components
659 "*Function for extracting address components from a From header.
660 Two pre-defined function exist: `gnus-extract-address-components',
661 which is the default, quite fast, and too simplistic solution, and
662 `mail-extract-address-components', which works much better, but is
665 (defvar gnus-summary-default-score 0
666 "*Default article score level.
667 If this variable is nil, scoring will be disabled.")
669 (defvar gnus-summary-zcore-fuzz 0
670 "*Fuzziness factor for the zcore in the summary buffer.
671 Articles with scores closer than this to `gnus-summary-default-score'
672 will not be marked.")
674 (defvar gnus-simplify-subject-fuzzy-regexp nil
675 "*Strings to be removed when doing fuzzy matches.
676 This can either be a regular expression or list of regular expressions
677 that will be removed from subject strings if fuzzy subject
678 simplification is selected.")
680 (defvar gnus-permanently-visible-groups nil
681 "*Regexp to match groups that should always be listed in the group buffer.
682 This means that they will still be listed when there are no unread
683 articles in the groups.")
685 (defvar gnus-list-groups-with-ticked-articles t
686 "*If non-nil, list groups that have only ticked articles.
687 If nil, only list groups that have unread articles.")
689 (defvar gnus-group-default-list-level gnus-level-subscribed
690 "*Default listing level.
691 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
693 (defvar gnus-group-use-permanent-levels nil
694 "*If non-nil, once you set a level, Gnus will use this level.")
696 (defvar gnus-group-list-inactive-groups t
697 "*If non-nil, inactive groups will be listed.")
699 (defvar gnus-show-mime nil
700 "*If non-nil, do mime processing of articles.
701 The articles will simply be fed to the function given by
702 `gnus-show-mime-method'.")
704 (defvar gnus-strict-mime t
705 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
707 (defvar gnus-show-mime-method 'metamail-buffer
708 "*Function to process a MIME message.
709 The function is called from the article buffer.")
711 (defvar gnus-decode-encoded-word-method (lambda ())
712 "*Function to decode a MIME encoded-words.
713 The function is called from the article buffer.")
715 (defvar gnus-show-threads t
716 "*If non-nil, display threads in summary mode.")
718 (defvar gnus-thread-hide-subtree nil
719 "*If non-nil, hide all threads initially.
720 If threads are hidden, you have to run the command
721 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
722 to expose hidden threads.")
724 (defvar gnus-thread-hide-killed t
725 "*If non-nil, hide killed threads automatically.")
727 (defvar gnus-thread-ignore-subject nil
728 "*If non-nil, ignore subjects and do all threading based on the Reference header.
729 If nil, which is the default, articles that have different subjects
730 from their parents will start separate threads.")
732 (defvar gnus-thread-operation-ignore-subject t
733 "*If non-nil, subjects will be ignored when doing thread commands.
734 This affects commands like `gnus-summary-kill-thread' and
735 `gnus-summary-lower-thread'.
737 If this variable is nil, articles in the same thread with different
738 subjects will not be included in the operation in question. If this
739 variable is `fuzzy', only articles that have subjects that are fuzzily
740 equal will be included.")
742 (defvar gnus-thread-indent-level 4
743 "*Number that says how much each sub-thread should be indented.")
745 (defvar gnus-ignored-newsgroups
746 (purecopy (mapconcat 'identity
747 '("^to\\." ; not "real" groups
748 "^[0-9. \t]+ " ; all digits in name
749 "[][\"#'()]" ; bogus characters
752 "*A regexp to match uninteresting newsgroups in the active file.
753 Any lines in the active file matching this regular expression are
754 removed from the newsgroup list before anything else is done to it,
755 thus making them effectively non-existent.")
757 (defvar gnus-ignored-headers
758 "^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:"
759 "*All headers that match this regexp will be hidden.
760 This variable can also be a list of regexps of headers to be ignored.
761 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
763 (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-"
764 "*All headers that do not match this regexp will be hidden.
765 This variable can also be a list of regexp of headers to remain visible.
766 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
768 (defvar gnus-sorted-header-list
769 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
770 "^Cc:" "^Date:" "^Organization:")
771 "*This variable is a list of regular expressions.
772 If it is non-nil, headers that match the regular expressions will
773 be placed first in the article buffer in the sequence specified by
776 (defvar gnus-boring-article-headers
777 '(empty followup-to reply-to)
778 "*Headers that are only to be displayed if they have interesting data.
779 Possible values in this list are `empty', `newsgroups', `followup-to',
780 `reply-to', and `date'.")
782 (defvar gnus-show-all-headers nil
783 "*If non-nil, don't hide any headers.")
785 (defvar gnus-save-all-headers t
786 "*If non-nil, don't remove any headers before saving.")
788 (defvar gnus-saved-headers gnus-visible-headers
789 "*Headers to keep if `gnus-save-all-headers' is nil.
790 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
791 If that variable is nil, however, all headers that match this regexp
792 will be kept while the rest will be deleted before saving.")
794 (defvar gnus-inhibit-startup-message nil
795 "*If non-nil, the startup message will not be displayed.")
797 (defvar gnus-signature-separator "^-- *$"
798 "Regexp matching signature separator.")
800 (defvar gnus-signature-limit nil
801 "Provide a limit to what is considered a signature.
802 If it is a number, no signature may not be longer (in characters) than
803 that number. If it is a function, the function will be called without
804 any parameters, and if it returns nil, there is no signature in the
805 buffer. If it is a string, it will be used as a regexp. If it
806 matches, the text in question is not a signature.")
808 (defvar gnus-auto-extend-newsgroup t
809 "*If non-nil, extend newsgroup forward and backward when requested.")
811 (defvar gnus-auto-select-first t
812 "*If nil, don't select the first unread article when entering a group.
813 If this variable is `best', select the highest-scored unread article
814 in the group. If neither nil nor `best', select the first unread
817 If you want to prevent automatic selection of the first unread article
818 in some newsgroups, set the variable to nil in
819 `gnus-select-group-hook'.")
821 (defvar gnus-auto-select-next t
822 "*If non-nil, offer to go to the next group from the end of the previous.
823 If the value is t and the next newsgroup is empty, Gnus will exit
824 summary mode and go back to group mode. If the value is neither nil
825 nor t, Gnus will select the following unread newsgroup. In
826 particular, if the value is the symbol `quietly', the next unread
827 newsgroup will be selected without any confirmation, and if it is
828 `almost-quietly', the next group will be selected without any
829 confirmation if you are located on the last article in the group.
830 Finally, if this variable is `slightly-quietly', the `Z n' command
831 will go to the next group without confirmation.")
833 (defvar gnus-auto-select-same nil
834 "*If non-nil, select the next article with the same subject.")
836 (defvar gnus-summary-check-current nil
837 "*If non-nil, consider the current article when moving.
838 The \"unread\" movement commands will stay on the same line if the
839 current article is unread.")
841 (defvar gnus-auto-center-summary t
842 "*If non-nil, always center the current summary buffer.
843 In particular, if `vertical' do only vertical recentering. If non-nil
844 and non-`vertical', do both horizontal and vertical recentering.")
846 (defvar gnus-break-pages t
847 "*If non-nil, do page breaking on articles.
848 The page delimiter is specified by the `gnus-page-delimiter'
851 (defvar gnus-page-delimiter "^\^L"
852 "*Regexp describing what to use as article page delimiters.
853 The default value is \"^\^L\", which is a form linefeed at the
854 beginning of a line.")
856 (defvar gnus-use-full-window t
857 "*If non-nil, use the entire Emacs screen.")
859 (defvar gnus-window-configuration nil
860 "Obsolete variable. See `gnus-buffer-configuration'.")
862 (defvar gnus-window-min-width 2
863 "*Minimum width of Gnus buffers.")
865 (defvar gnus-window-min-height 1
866 "*Minimum height of Gnus buffers.")
868 (defvar gnus-buffer-configuration
872 (if gnus-carpal '(group-carpal 4))))
876 (if gnus-carpal '(summary-carpal 4))))
883 (if gnus-carpal '(summary-carpal 4))
885 (vertical ((height . 5) (width . 15)
887 (left . -1) (top . 1))
897 (if gnus-carpal '(summary-carpal 4))
902 (if gnus-carpal '(server-carpal 2))))
906 (if gnus-carpal '(browse-carpal 2))))
909 (message 1.0 point)))
912 (article 1.0 point)))
923 (edit-group 1.0 point)))
927 (edit-server 1.0 point)))
931 (edit-score 1.0 point)))
938 (message 1.0 point)))
941 (message 1.0 point)))
944 (message 1.0 point)))
948 (message 1.0 point)))
955 (if gnus-carpal '(summary-carpal 4))
956 ("*Shell Command Output*" 1.0)))
959 ("*Gnus Help Bug*" 0.5)
960 ("*Gnus Bug*" 1.0 point)))
964 (message 1.0 point))))
965 "Window configuration for all possible Gnus buffers.
966 This variable is a list of lists. Each of these lists has a NAME and
967 a RULE. The NAMEs are commonsense names like `group', which names a
968 rule used when displaying the group buffer; `summary', which names a
969 rule for what happens when you enter a group and do not display an
970 article buffer; and so on. See the value of this variable for a
971 complete list of NAMEs.
973 Each RULE is a list of vectors. The first element in this vector is
974 the name of the buffer to be displayed; the second element is the
975 percentage of the screen this buffer is to occupy (a number in the
976 0.0-0.99 range); the optional third element is `point', which should
977 be present to denote which buffer point is to go to after making this
978 buffer configuration.")
980 (defvar gnus-window-to-buffer
981 '((group . gnus-group-buffer)
982 (summary . gnus-summary-buffer)
983 (article . gnus-article-buffer)
984 (server . gnus-server-buffer)
985 (browse . "*Gnus Browse Server*")
986 (edit-group . gnus-group-edit-buffer)
987 (edit-server . gnus-server-edit-buffer)
988 (group-carpal . gnus-carpal-group-buffer)
989 (summary-carpal . gnus-carpal-summary-buffer)
990 (server-carpal . gnus-carpal-server-buffer)
991 (browse-carpal . gnus-carpal-browse-buffer)
992 (edit-score . gnus-score-edit-buffer)
993 (message . gnus-message-buffer)
994 (mail . gnus-message-buffer)
995 (post-news . gnus-message-buffer)
996 (faq . gnus-faq-buffer)
997 (picons . "*Picons*")
998 (tree . gnus-tree-buffer)
999 (info . gnus-info-buffer)
1000 (article-copy . gnus-article-copy)
1001 (draft . gnus-draft-buffer))
1002 "Mapping from short symbols to buffer names or buffer variables.")
1004 (defvar gnus-carpal nil
1005 "*If non-nil, display clickable icons.")
1007 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
1008 "*Function called with a group name when new group is detected.
1009 A few pre-made functions are supplied: `gnus-subscribe-randomly'
1010 inserts new groups at the beginning of the list of groups;
1011 `gnus-subscribe-alphabetically' inserts new groups in strict
1012 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
1013 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
1014 for your decision; `gnus-subscribe-killed' kills all new groups;
1015 `gnus-subscribe-zombies' will make all new groups into zombies.")
1017 ;; Suggested by a bug report by Hallvard B Furuseth.
1018 ;; <h.b.furuseth@usit.uio.no>.
1019 (defvar gnus-subscribe-options-newsgroup-method
1020 (function gnus-subscribe-alphabetically)
1021 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
1022 If, for instance, you want to subscribe to all newsgroups in the
1023 \"no\" and \"alt\" hierarchies, you'd put the following in your
1026 options -n no.all alt.all
1028 Gnus will the subscribe all new newsgroups in these hierarchies with
1029 the subscription method in this variable.")
1031 (defvar gnus-subscribe-hierarchical-interactive nil
1032 "*If non-nil, Gnus will offer to subscribe hierarchically.
1033 When a new hierarchy appears, Gnus will ask the user:
1035 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1037 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1038 subscribe to all newsgroups in the hierarchy and `s' will skip this
1039 hierarchy in its entirety.")
1041 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1042 "*Function used for sorting the group buffer.
1043 This function will be called with group info entries as the arguments
1044 for the groups to be sorted. Pre-made functions include
1045 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1046 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1047 `gnus-group-sort-by-rank'.
1049 This variable can also be a list of sorting functions. In that case,
1050 the most significant sort function should be the last function in the
1053 ;; Mark variables suggested by Thomas Michanek
1054 ;; <Thomas.Michanek@telelogic.se>.
1055 (defvar gnus-unread-mark ?
1056 "*Mark used for unread articles.")
1057 (defvar gnus-ticked-mark ?!
1058 "*Mark used for ticked articles.")
1059 (defvar gnus-dormant-mark ??
1060 "*Mark used for dormant articles.")
1061 (defvar gnus-del-mark ?r
1062 "*Mark used for del'd articles.")
1063 (defvar gnus-read-mark ?R
1064 "*Mark used for read articles.")
1065 (defvar gnus-expirable-mark ?E
1066 "*Mark used for expirable articles.")
1067 (defvar gnus-killed-mark ?K
1068 "*Mark used for killed articles.")
1069 (defvar gnus-souped-mark ?F
1070 "*Mark used for killed articles.")
1071 (defvar gnus-kill-file-mark ?X
1072 "*Mark used for articles killed by kill files.")
1073 (defvar gnus-low-score-mark ?Y
1074 "*Mark used for articles with a low score.")
1075 (defvar gnus-catchup-mark ?C
1076 "*Mark used for articles that are caught up.")
1077 (defvar gnus-replied-mark ?A
1078 "*Mark used for articles that have been replied to.")
1079 (defvar gnus-cached-mark ?*
1080 "*Mark used for articles that are in the cache.")
1081 (defvar gnus-saved-mark ?S
1082 "*Mark used for articles that have been saved to.")
1083 (defvar gnus-process-mark ?#
1085 (defvar gnus-ancient-mark ?O
1086 "*Mark used for ancient articles.")
1087 (defvar gnus-sparse-mark ?Q
1088 "*Mark used for sparsely reffed articles.")
1089 (defvar gnus-canceled-mark ?G
1090 "*Mark used for canceled articles.")
1091 (defvar gnus-score-over-mark ?+
1092 "*Score mark used for articles with high scores.")
1093 (defvar gnus-score-below-mark ?-
1094 "*Score mark used for articles with low scores.")
1095 (defvar gnus-empty-thread-mark ?
1096 "*There is no thread under the article.")
1097 (defvar gnus-not-empty-thread-mark ?=
1098 "*There is a thread under the article.")
1100 (defvar gnus-view-pseudo-asynchronously nil
1101 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1103 (defvar gnus-view-pseudos nil
1104 "*If `automatic', pseudo-articles will be viewed automatically.
1105 If `not-confirm', pseudos will be viewed automatically, and the user
1106 will not be asked to confirm the command.")
1108 (defvar gnus-view-pseudos-separately t
1109 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1110 If nil, all files that use the same viewing command will be given as a
1111 list of parameters to that command.")
1113 (defvar gnus-insert-pseudo-articles t
1114 "*If non-nil, insert pseudo-articles when decoding articles.")
1116 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1117 "*Format of group lines.
1118 It works along the same lines as a normal formatting string,
1119 with some simple extensions.
1121 %M Only marked articles (character, \"*\" or \" \")
1122 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1123 %L Level of subscribedness (integer)
1124 %N Number of unread articles (integer)
1125 %I Number of dormant articles (integer)
1126 %i Number of ticked and dormant (integer)
1127 %T Number of ticked articles (integer)
1128 %R Number of read articles (integer)
1129 %t Total number of articles (integer)
1130 %y Number of unread, unticked articles (integer)
1131 %G Group name (string)
1132 %g Qualified group name (string)
1133 %D Group description (string)
1134 %s Select method (string)
1135 %o Moderated group (char, \"m\")
1136 %p Process mark (char)
1137 %O Moderated group (string, \"(m)\" or \"\")
1138 %P Topic indentation (string)
1139 %l Whether there are GroupLens predictions for this group (string)
1140 %n Select from where (string)
1141 %z A string that look like `<%s:%n>' if a foreign select method is used
1142 %u User defined specifier. The next character in the format string should
1143 be a letter. Gnus will call the function gnus-user-format-function-X,
1144 where X is the letter following %u. The function will be passed the
1145 current header as argument. The function should return a string, which
1146 will be inserted into the buffer just like information from any other
1149 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1150 the mouse point move inside the area. There can only be one such area.
1152 Note that this format specification is not always respected. For
1153 reasons of efficiency, when listing killed groups, this specification
1154 is ignored altogether. If the spec is changed considerably, your
1155 output may end up looking strange when listing both alive and killed
1158 If you use %o or %O, reading the active file will be slower and quite
1159 a bit of extra memory will be used. %D will also worsen performance.
1160 Also note that if you change the format specification to include any
1161 of these specs, you must probably re-start Gnus to see them go into
1164 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1165 "*The format specification of the lines in the summary buffer.
1167 It works along the same lines as a normal formatting string,
1168 with some simple extensions.
1170 %N Article number, left padded with spaces (string)
1172 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1173 %n Name of the poster (string)
1174 %a Extracted name of the poster (string)
1175 %A Extracted address of the poster (string)
1176 %F Contents of the From: header (string)
1177 %x Contents of the Xref: header (string)
1178 %D Date of the article (string)
1179 %d Date of the article (string) in DD-MMM format
1180 %M Message-id of the article (string)
1181 %r References of the article (string)
1182 %c Number of characters in the article (integer)
1183 %L Number of lines in the article (integer)
1184 %I Indentation based on thread level (a string of spaces)
1185 %T A string with two possible values: 80 spaces if the article
1186 is on thread level two or larger and 0 spaces on level one
1187 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1188 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1189 %[ Opening bracket (character, \"[\" or \"<\")
1190 %] Closing bracket (character, \"]\" or \">\")
1191 %> Spaces of length thread-level (string)
1192 %< Spaces of length (- 20 thread-level) (string)
1193 %i Article score (number)
1194 %z Article zcore (character)
1195 %t Number of articles under the current thread (number).
1196 %e Whether the thread is empty or not (character).
1197 %l GroupLens score (string).
1198 %u User defined specifier. The next character in the format string should
1199 be a letter. Gnus will call the function gnus-user-format-function-X,
1200 where X is the letter following %u. The function will be passed the
1201 current header as argument. The function should return a string, which
1202 will be inserted into the summary just like information from any other
1205 Text between %( and %) will be highlighted with `gnus-mouse-face'
1206 when the mouse point is placed inside the area. There can only be one
1209 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1210 with care. For reasons of efficiency, Gnus will compute what column
1211 these characters will end up in, and \"hard-code\" that. This means that
1212 it is illegal to have these specs after a variable-length spec. Well,
1213 you might not be arrested, but your summary buffer will look strange,
1214 which is bad enough.
1216 The smart choice is to have these specs as for to the left as
1219 This restriction may disappear in later versions of Gnus.")
1221 (defvar gnus-summary-dummy-line-format
1223 "*The format specification for the dummy roots in the summary buffer.
1224 It works along the same lines as a normal formatting string,
1225 with some simple extensions.
1229 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1230 "*The format specification for the summary mode line.
1231 It works along the same lines as a normal formatting string,
1232 with some simple extensions:
1235 %p Unprefixed group name
1236 %A Current article number
1238 %U Number of unread articles in the group
1239 %e Number of unselected articles in the group
1240 %Z A string with unread/unselected article counts
1241 %g Shortish group name
1242 %S Subject of the current article
1243 %u User-defined spec
1244 %s Current score file name
1245 %d Number of dormant articles
1246 %r Number of articles that have been marked as read in this session
1247 %E Number of articles expunged by the score files")
1249 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1250 "*The format specification for the article mode line.
1251 See `gnus-summary-mode-line-format' for a closer description.")
1253 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1254 "*The format specification for the group mode line.
1255 It works along the same lines as a normal formatting string,
1256 with some simple extensions:
1258 %S The native news server.
1259 %M The native select method.
1260 %: \":\" if %S isn't \"\".")
1262 (defvar gnus-valid-select-methods
1263 '(("nntp" post address prompt-address)
1264 ("nnspool" post address)
1265 ("nnvirtual" post-mail virtual prompt-address)
1266 ("nnmbox" mail respool address)
1267 ("nnml" mail respool address)
1268 ("nnmh" mail respool address)
1269 ("nndir" post-mail prompt-address address)
1270 ("nneething" none address prompt-address)
1271 ("nndoc" none address prompt-address)
1272 ("nnbabyl" mail address respool)
1273 ("nnkiboze" post virtual)
1274 ("nnsoup" post-mail address)
1275 ("nndraft" post-mail)
1276 ("nnfolder" mail respool address))
1277 "An alist of valid select methods.
1278 The first element of each list lists should be a string with the name
1279 of the select method. The other elements may be be the category of
1280 this method (ie. `post', `mail', `none' or whatever) or other
1281 properties that this method has (like being respoolable).
1282 If you implement a new select method, all you should have to change is
1283 this variable. I think.")
1285 (defvar gnus-updated-mode-lines '(group article summary tree)
1286 "*List of buffers that should update their mode lines.
1287 The list may contain the symbols `group', `article' and `summary'. If
1288 the corresponding symbol is present, Gnus will keep that mode line
1289 updated with information that may be pertinent.
1290 If this variable is nil, screen refresh may be quicker.")
1292 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1293 (defvar gnus-mode-non-string-length nil
1294 "*Max length of mode-line non-string contents.
1295 If this is nil, Gnus will take space as is needed, leaving the rest
1296 of the modeline intact.")
1299 ;(defvar gnus-mouse-face 'highlight
1300 ; "*Face used for mouse highlighting in Gnus.
1301 ;No mouse highlights will be done if `gnus-visual' is nil.")
1303 (defvar gnus-summary-mark-below 0
1304 "*Mark all articles with a score below this variable as read.
1305 This variable is local to each summary buffer and usually set by the
1308 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1309 "*List of functions used for sorting articles in the summary buffer.
1310 This variable is only used when not using a threaded display.")
1312 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1313 "*List of functions used for sorting threads in the summary buffer.
1314 By default, threads are sorted by article number.
1316 Each function takes two threads and return non-nil if the first thread
1317 should be sorted before the other. If you use more than one function,
1318 the primary sort function should be the last. You should probably
1319 always include `gnus-thread-sort-by-number' in the list of sorting
1320 functions -- preferably first.
1322 Ready-mady functions include `gnus-thread-sort-by-number',
1323 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1324 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1325 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1327 (defvar gnus-thread-score-function '+
1328 "*Function used for calculating the total score of a thread.
1330 The function is called with the scores of the article and each
1331 subthread and should then return the score of the thread.
1333 Some functions you can use are `+', `max', or `min'.")
1335 (defvar gnus-summary-expunge-below nil
1336 "All articles that have a score less than this variable will be expunged.")
1338 (defvar gnus-thread-expunge-below nil
1339 "All threads that have a total score less than this variable will be expunged.
1340 See `gnus-thread-score-function' for en explanation of what a
1341 \"thread score\" is.")
1343 (defvar gnus-auto-subscribed-groups
1344 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1345 "*All new groups that match this regexp will be subscribed automatically.
1346 Note that this variable only deals with new groups. It has no effect
1347 whatsoever on old groups.
1349 New groups that match this regexp will not be handled by
1350 `gnus-subscribe-newsgroup-method'. Instead, they will
1351 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1353 (defvar gnus-options-subscribe nil
1354 "*All new groups matching this regexp will be subscribed unconditionally.
1355 Note that this variable deals only with new newsgroups. This variable
1356 does not affect old newsgroups.
1358 New groups that match this regexp will not be handled by
1359 `gnus-subscribe-newsgroup-method'. Instead, they will
1360 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1362 (defvar gnus-options-not-subscribe nil
1363 "*All new groups matching this regexp will be ignored.
1364 Note that this variable deals only with new newsgroups. This variable
1365 does not affect old (already subscribed) newsgroups.")
1367 (defvar gnus-auto-expirable-newsgroups nil
1368 "*Groups in which to automatically mark read articles as expirable.
1369 If non-nil, this should be a regexp that should match all groups in
1370 which to perform auto-expiry. This only makes sense for mail groups.")
1372 (defvar gnus-total-expirable-newsgroups nil
1373 "*Groups in which to perform expiry of all read articles.
1374 Use with extreme caution. All groups that match this regexp will be
1375 expiring - which means that all read articles will be deleted after
1376 (say) one week. (This only goes for mail groups and the like, of
1379 (defvar gnus-group-uncollapsed-levels 1
1380 "Number of group name elements to leave alone when making a short group name.")
1382 (defvar gnus-hidden-properties '(invisible t intangible t)
1383 "Property list to use for hiding text.")
1385 (defvar gnus-modtime-botch nil
1386 "*Non-nil means .newsrc should be deleted prior to save.
1387 Its use is due to the bogus appearance that .newsrc was modified on
1392 (defvar gnus-group-mode-hook nil
1393 "*A hook for Gnus group mode.")
1395 (defvar gnus-summary-mode-hook nil
1396 "*A hook for Gnus summary mode.
1397 This hook is run before any variables are set in the summary buffer.")
1399 (defvar gnus-article-mode-hook nil
1400 "*A hook for Gnus article mode.")
1402 (defvar gnus-summary-prepare-exit-hook nil
1403 "*A hook called when preparing to exit from the summary buffer.
1404 It calls `gnus-summary-expire-articles' by default.")
1405 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1407 (defvar gnus-summary-exit-hook nil
1408 "*A hook called on exit from the summary buffer.")
1410 (defvar gnus-check-bogus-groups-hook nil
1411 "A hook run after removing bogus groups.")
1413 (defvar gnus-group-catchup-group-hook nil
1414 "*A hook run when catching up a group from the group buffer.")
1416 (defvar gnus-group-update-group-hook nil
1417 "*A hook called when updating group lines.")
1419 (defvar gnus-open-server-hook nil
1420 "*A hook called just before opening connection to the news server.")
1422 (defvar gnus-load-hook nil
1423 "*A hook run while Gnus is loaded.")
1425 (defvar gnus-startup-hook nil
1426 "*A hook called at startup.
1427 This hook is called after Gnus is connected to the NNTP server.")
1429 (defvar gnus-get-new-news-hook nil
1430 "*A hook run just before Gnus checks for new news.")
1432 (defvar gnus-after-getting-new-news-hook nil
1433 "*A hook run after Gnus checks for new news.")
1435 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1436 "*A function that is called to generate the group buffer.
1437 The function is called with three arguments: The first is a number;
1438 all group with a level less or equal to that number should be listed,
1439 if the second is non-nil, empty groups should also be displayed. If
1440 the third is non-nil, it is a number. No groups with a level lower
1441 than this number should be displayed.
1443 The only current function implemented is `gnus-group-prepare-flat'.")
1445 (defvar gnus-group-prepare-hook nil
1446 "*A hook called after the group buffer has been generated.
1447 If you want to modify the group buffer, you can use this hook.")
1449 (defvar gnus-summary-prepare-hook nil
1450 "*A hook called after the summary buffer has been generated.
1451 If you want to modify the summary buffer, you can use this hook.")
1453 (defvar gnus-summary-generate-hook nil
1454 "*A hook run just before generating the summary buffer.
1455 This hook is commonly used to customize threading variables and the
1458 (defvar gnus-article-prepare-hook nil
1459 "*A hook called after an article has been prepared in the article buffer.
1460 If you want to run a special decoding program like nkf, use this hook.")
1462 ;(defvar gnus-article-display-hook nil
1463 ; "*A hook called after the article is displayed in the article buffer.
1464 ;The hook is designed to change the contents of the article
1465 ;buffer. Typical functions that this hook may contain are
1466 ;`gnus-article-hide-headers' (hide selected headers),
1467 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1468 ;`gnus-article-hide-signature' (hide signature) and
1469 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1470 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1471 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1472 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1474 (defvar gnus-article-x-face-too-ugly nil
1475 "Regexp matching posters whose face shouldn't be shown automatically.")
1477 (defvar gnus-select-group-hook nil
1478 "*A hook called when a newsgroup is selected.
1480 If you'd like to simplify subjects like the
1481 `gnus-summary-next-same-subject' command does, you can use the
1484 (setq gnus-select-group-hook
1487 (mapcar (lambda (header)
1488 (mail-header-set-subject
1490 (gnus-simplify-subject
1491 (mail-header-subject header) 're-only)))
1492 gnus-newsgroup-headers))))")
1494 (defvar gnus-select-article-hook nil
1495 "*A hook called when an article is selected.")
1497 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1498 "*A hook called to apply kill files to a group.
1499 This hook is intended to apply a kill file to the selected newsgroup.
1500 The function `gnus-apply-kill-file' is called by default.
1502 Since a general kill file is too heavy to use only for a few
1503 newsgroups, I recommend you to use a lighter hook function. For
1504 example, if you'd like to apply a kill file to articles which contains
1505 a string `rmgroup' in subject in newsgroup `control', you can use the
1508 (setq gnus-apply-kill-hook
1511 (cond ((string-match \"control\" gnus-newsgroup-name)
1512 (gnus-kill \"Subject\" \"rmgroup\")
1513 (gnus-expunge \"X\"))))))")
1515 (defvar gnus-visual-mark-article-hook
1516 (list 'gnus-highlight-selected-summary)
1517 "*Hook run after selecting an article in the summary buffer.
1518 It is meant to be used for highlighting the article in some way. It
1519 is not run if `gnus-visual' is nil.")
1521 (defvar gnus-parse-headers-hook nil
1522 "*A hook called before parsing the headers.")
1523 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1525 (defvar gnus-exit-group-hook nil
1526 "*A hook called when exiting (not quitting) summary mode.")
1528 (defvar gnus-suspend-gnus-hook nil
1529 "*A hook called when suspending (not exiting) Gnus.")
1531 (defvar gnus-exit-gnus-hook nil
1532 "*A hook called when exiting Gnus.")
1534 (defvar gnus-after-exiting-gnus-hook nil
1535 "*A hook called after exiting Gnus.")
1537 (defvar gnus-save-newsrc-hook nil
1538 "*A hook called before saving any of the newsrc files.")
1540 (defvar gnus-save-quick-newsrc-hook nil
1541 "*A hook called just before saving the quick newsrc file.
1542 Can be used to turn version control on or off.")
1544 (defvar gnus-save-standard-newsrc-hook nil
1545 "*A hook called just before saving the standard newsrc file.
1546 Can be used to turn version control on or off.")
1548 (defvar gnus-summary-update-hook
1549 (list 'gnus-summary-highlight-line)
1550 "*A hook called when a summary line is changed.
1551 The hook will not be called if `gnus-visual' is nil.
1553 The default function `gnus-summary-highlight-line' will
1554 highlight the line according to the `gnus-summary-highlight'
1557 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1558 "*A hook called when a group line is changed.
1559 The hook will not be called if `gnus-visual' is nil.
1561 The default function `gnus-group-highlight-line' will
1562 highlight the line according to the `gnus-group-highlight'
1565 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1566 "*A hook called when an article is selected for the first time.
1567 The hook is intended to mark an article as read (or unread)
1568 automatically when it is selected.")
1570 (defvar gnus-group-change-level-function nil
1571 "Function run when a group level is changed.
1572 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1574 ;; Remove any hilit infestation.
1575 (add-hook 'gnus-startup-hook
1577 (remove-hook 'gnus-summary-prepare-hook
1578 'hilit-rehighlight-buffer-quietly)
1579 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1580 (setq gnus-mark-article-hook
1581 '(gnus-summary-mark-read-and-unread-as-read))
1582 (remove-hook 'gnus-article-prepare-hook
1583 'hilit-rehighlight-buffer-quietly)))
1586 ;; Internal variables
1588 (defvar gnus-tree-buffer "*Tree*"
1589 "Buffer where Gnus thread trees are displayed.")
1592 (defvar gnus-use-generic-from nil)
1594 (defvar gnus-thread-indent-array nil)
1595 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1597 (defvar gnus-newsrc-file-version nil)
1599 (defvar gnus-method-history nil)
1600 ;; Variable holding the user answers to all method prompts.
1602 (defvar gnus-group-history nil)
1603 ;; Variable holding the user answers to all group prompts.
1605 (defvar gnus-server-alist nil
1606 "List of available servers.")
1608 (defvar gnus-group-indentation-function nil)
1610 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1612 (defvar gnus-goto-missing-group-function nil)
1614 (defvar gnus-override-subscribe-method nil)
1616 (defvar gnus-group-goto-next-group-function nil
1617 "Function to override finding the next group after listing groups.")
1619 (defconst gnus-article-mark-lists
1620 '((marked . tick) (replied . reply)
1621 (expirable . expire) (killed . killed)
1622 (bookmarks . bookmark) (dormant . dormant)
1623 (scored . score) (saved . save)
1627 ;; Avoid highlighting in kill files.
1628 (defvar gnus-summary-inhibit-highlight nil)
1629 (defvar gnus-newsgroup-selected-overlay nil)
1631 (defvar gnus-inhibit-hiding nil)
1632 (defvar gnus-group-indentation "")
1633 (defvar gnus-inhibit-limiting nil)
1634 (defvar gnus-created-frames nil)
1636 (defvar gnus-article-mode-map nil)
1637 (defvar gnus-dribble-buffer nil)
1638 (defvar gnus-headers-retrieved-by nil)
1639 (defvar gnus-article-reply nil)
1640 (defvar gnus-override-method nil)
1641 (defvar gnus-article-check-size nil)
1643 (defvar gnus-current-score-file nil)
1644 (defvar gnus-newsgroup-adaptive-score-file nil)
1645 (defvar gnus-scores-exclude-files nil)
1647 (defvar gnus-opened-servers nil)
1649 (defvar gnus-current-move-group nil)
1650 (defvar gnus-current-copy-group nil)
1651 (defvar gnus-current-crosspost-group nil)
1653 (defvar gnus-newsgroup-dependencies nil)
1654 (defvar gnus-newsgroup-async nil)
1655 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1657 (defvar gnus-newsgroup-adaptive nil)
1659 (defvar gnus-summary-display-table nil)
1660 (defvar gnus-summary-display-article-function nil)
1662 (defvar gnus-summary-highlight-line-function nil
1663 "Function called after highlighting a summary line.")
1665 (defvar gnus-group-line-format-alist
1666 `((?M gnus-tmp-marked-mark ?c)
1667 (?S gnus-tmp-subscribed ?c)
1668 (?L gnus-tmp-level ?d)
1669 (?N (cond ((eq number t) "*" )
1673 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1674 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1676 (?R gnus-tmp-number-of-read ?s)
1677 (?t gnus-tmp-number-total ?d)
1678 (?y gnus-tmp-number-of-unread ?s)
1679 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1680 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1681 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1682 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1683 (?g gnus-tmp-group ?s)
1684 (?G gnus-tmp-qualified-group ?s)
1685 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1686 (?D gnus-tmp-newsgroup-description ?s)
1687 (?o gnus-tmp-moderated ?c)
1688 (?O gnus-tmp-moderated-string ?s)
1689 (?p gnus-tmp-process-marked ?c)
1690 (?s gnus-tmp-news-server ?s)
1691 (?n gnus-tmp-news-method ?s)
1692 (?P gnus-group-indentation ?s)
1693 (?l gnus-tmp-grouplens ?s)
1694 (?z gnus-tmp-news-method-string ?s)
1695 (?u gnus-tmp-user-defined ?s)))
1697 (defvar gnus-summary-line-format-alist
1698 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1699 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1700 (?s gnus-tmp-subject-or-nil ?s)
1701 (?n gnus-tmp-name ?s)
1702 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1704 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1706 (?F gnus-tmp-from ?s)
1707 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1708 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1709 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1710 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1711 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1712 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1713 (?L gnus-tmp-lines ?d)
1714 (?I gnus-tmp-indentation ?s)
1715 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1716 (?R gnus-tmp-replied ?c)
1717 (?\[ gnus-tmp-opening-bracket ?c)
1718 (?\] gnus-tmp-closing-bracket ?c)
1719 (?\> (make-string gnus-tmp-level ? ) ?s)
1720 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1721 (?i gnus-tmp-score ?d)
1722 (?z gnus-tmp-score-char ?c)
1723 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1724 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1725 (?U gnus-tmp-unread ?c)
1726 (?t (gnus-summary-number-of-articles-in-thread
1727 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1729 (?e (gnus-summary-number-of-articles-in-thread
1730 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1732 (?u gnus-tmp-user-defined ?s))
1733 "An alist of format specifications that can appear in summary lines,
1734 and what variables they correspond with, along with the type of the
1735 variable (string, integer, character, etc).")
1737 (defvar gnus-summary-dummy-line-format-alist
1738 `((?S gnus-tmp-subject ?s)
1739 (?N gnus-tmp-number ?d)
1740 (?u gnus-tmp-user-defined ?s)))
1742 (defvar gnus-summary-mode-line-format-alist
1743 `((?G gnus-tmp-group-name ?s)
1744 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1745 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1746 (?A gnus-tmp-article-number ?d)
1747 (?Z gnus-tmp-unread-and-unselected ?s)
1748 (?V gnus-version ?s)
1749 (?U gnus-tmp-unread-and-unticked ?d)
1750 (?S gnus-tmp-subject ?s)
1751 (?e gnus-tmp-unselected ?d)
1752 (?u gnus-tmp-user-defined ?s)
1753 (?d (length gnus-newsgroup-dormant) ?d)
1754 (?t (length gnus-newsgroup-marked) ?d)
1755 (?r (length gnus-newsgroup-reads) ?d)
1756 (?E gnus-newsgroup-expunged-tally ?d)
1757 (?s (gnus-current-score-file-nondirectory) ?s)))
1759 (defvar gnus-article-mode-line-format-alist
1760 gnus-summary-mode-line-format-alist)
1762 (defvar gnus-group-mode-line-format-alist
1763 `((?S gnus-tmp-news-server ?s)
1764 (?M gnus-tmp-news-method ?s)
1765 (?u gnus-tmp-user-defined ?s)
1766 (?: gnus-tmp-colon ?s)))
1768 (defvar gnus-have-read-active-file nil)
1770 (defconst gnus-maintainer
1771 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1772 "The mail address of the Gnus maintainers.")
1774 (defconst gnus-version-number "5.2.34"
1775 "Version number for this version of Gnus.")
1777 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1778 "Version string for this version of Gnus.")
1780 (defvar gnus-info-nodes
1781 '((gnus-group-mode "(gnus)The Group Buffer")
1782 (gnus-summary-mode "(gnus)The Summary Buffer")
1783 (gnus-article-mode "(gnus)The Article Buffer")
1784 (gnus-server-mode "(gnus)The Server Buffer")
1785 (gnus-browse-mode "(gnus)Browse Foreign Server")
1786 (gnus-tree-mode "(gnus)Tree Display")
1788 "Alist of major modes and related Info nodes.")
1790 (defvar gnus-group-buffer "*Group*")
1791 (defvar gnus-summary-buffer "*Summary*")
1792 (defvar gnus-article-buffer "*Article*")
1793 (defvar gnus-server-buffer "*Server*")
1795 (defvar gnus-work-buffer " *gnus work*")
1797 (defvar gnus-original-article-buffer " *Original Article*")
1798 (defvar gnus-original-article nil)
1800 (defvar gnus-buffer-list nil
1801 "Gnus buffers that should be killed on exit.")
1803 (defvar gnus-slave nil
1804 "Whether this Gnus is a slave or not.")
1806 (defvar gnus-variable-list
1807 '(gnus-newsrc-options gnus-newsrc-options-n
1808 gnus-newsrc-last-checked-date
1809 gnus-newsrc-alist gnus-server-alist
1810 gnus-killed-list gnus-zombie-list
1811 gnus-topic-topology gnus-topic-alist
1813 "Gnus variables saved in the quick startup file.")
1815 (defvar gnus-newsrc-options nil
1816 "Options line in the .newsrc file.")
1818 (defvar gnus-newsrc-options-n nil
1819 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1821 (defvar gnus-newsrc-last-checked-date nil
1822 "Date Gnus last asked server for new newsgroups.")
1824 (defvar gnus-topic-topology nil
1825 "The complete topic hierarchy.")
1827 (defvar gnus-topic-alist nil
1828 "The complete topic-group alist.")
1830 (defvar gnus-newsrc-alist nil
1831 "Assoc list of read articles.
1832 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1834 (defvar gnus-newsrc-hashtb nil
1835 "Hashtable of gnus-newsrc-alist.")
1837 (defvar gnus-killed-list nil
1838 "List of killed newsgroups.")
1840 (defvar gnus-killed-hashtb nil
1841 "Hash table equivalent of gnus-killed-list.")
1843 (defvar gnus-zombie-list nil
1844 "List of almost dead newsgroups.")
1846 (defvar gnus-description-hashtb nil
1847 "Descriptions of newsgroups.")
1849 (defvar gnus-list-of-killed-groups nil
1850 "List of newsgroups that have recently been killed by the user.")
1852 (defvar gnus-active-hashtb nil
1853 "Hashtable of active articles.")
1855 (defvar gnus-moderated-list nil
1856 "List of moderated newsgroups.")
1858 (defvar gnus-group-marked nil)
1860 (defvar gnus-current-startup-file nil
1861 "Startup file for the current host.")
1863 (defvar gnus-last-search-regexp nil
1864 "Default regexp for article search command.")
1866 (defvar gnus-last-shell-command nil
1867 "Default shell command on article.")
1869 (defvar gnus-current-select-method nil
1870 "The current method for selecting a newsgroup.")
1872 (defvar gnus-group-list-mode nil)
1874 (defvar gnus-article-internal-prepare-hook nil)
1876 (defvar gnus-newsgroup-name nil)
1877 (defvar gnus-newsgroup-begin nil)
1878 (defvar gnus-newsgroup-end nil)
1879 (defvar gnus-newsgroup-last-rmail nil)
1880 (defvar gnus-newsgroup-last-mail nil)
1881 (defvar gnus-newsgroup-last-folder nil)
1882 (defvar gnus-newsgroup-last-file nil)
1883 (defvar gnus-newsgroup-auto-expire nil)
1884 (defvar gnus-newsgroup-active nil)
1886 (defvar gnus-newsgroup-data nil)
1887 (defvar gnus-newsgroup-data-reverse nil)
1888 (defvar gnus-newsgroup-limit nil)
1889 (defvar gnus-newsgroup-limits nil)
1891 (defvar gnus-newsgroup-unreads nil
1892 "List of unread articles in the current newsgroup.")
1894 (defvar gnus-newsgroup-unselected nil
1895 "List of unselected unread articles in the current newsgroup.")
1897 (defvar gnus-newsgroup-reads nil
1898 "Alist of read articles and article marks in the current newsgroup.")
1900 (defvar gnus-newsgroup-expunged-tally nil)
1902 (defvar gnus-newsgroup-marked nil
1903 "List of ticked articles in the current newsgroup (a subset of unread art).")
1905 (defvar gnus-newsgroup-killed nil
1906 "List of ranges of articles that have been through the scoring process.")
1908 (defvar gnus-newsgroup-cached nil
1909 "List of articles that come from the article cache.")
1911 (defvar gnus-newsgroup-saved nil
1912 "List of articles that have been saved.")
1914 (defvar gnus-newsgroup-kill-headers nil)
1916 (defvar gnus-newsgroup-replied nil
1917 "List of articles that have been replied to in the current newsgroup.")
1919 (defvar gnus-newsgroup-expirable nil
1920 "List of articles in the current newsgroup that can be expired.")
1922 (defvar gnus-newsgroup-processable nil
1923 "List of articles in the current newsgroup that can be processed.")
1925 (defvar gnus-newsgroup-bookmarks nil
1926 "List of articles in the current newsgroup that have bookmarks.")
1928 (defvar gnus-newsgroup-dormant nil
1929 "List of dormant articles in the current newsgroup.")
1931 (defvar gnus-newsgroup-scored nil
1932 "List of scored articles in the current newsgroup.")
1934 (defvar gnus-newsgroup-headers nil
1935 "List of article headers in the current newsgroup.")
1937 (defvar gnus-newsgroup-threads nil)
1939 (defvar gnus-newsgroup-prepared nil
1940 "Whether the current group has been prepared properly.")
1942 (defvar gnus-newsgroup-ancient nil
1943 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1945 (defvar gnus-newsgroup-sparse nil)
1947 (defvar gnus-current-article nil)
1948 (defvar gnus-article-current nil)
1949 (defvar gnus-current-headers nil)
1950 (defvar gnus-have-all-headers nil)
1951 (defvar gnus-last-article nil)
1952 (defvar gnus-newsgroup-history nil)
1953 (defvar gnus-current-kill-article nil)
1955 ;; Save window configuration.
1956 (defvar gnus-prev-winconf nil)
1958 (defvar gnus-summary-mark-positions nil)
1959 (defvar gnus-group-mark-positions nil)
1961 (defvar gnus-reffed-article-number nil)
1963 ;;; Let the byte-compiler know that we know about this variable.
1964 (defvar rmail-default-rmail-file)
1966 (defvar gnus-cache-removable-articles nil)
1968 (defvar gnus-dead-summary nil)
1970 (defconst gnus-summary-local-variables
1971 '(gnus-newsgroup-name
1972 gnus-newsgroup-begin gnus-newsgroup-end
1973 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1974 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1975 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1976 gnus-newsgroup-unselected gnus-newsgroup-marked
1977 gnus-newsgroup-reads gnus-newsgroup-saved
1978 gnus-newsgroup-replied gnus-newsgroup-expirable
1979 gnus-newsgroup-processable gnus-newsgroup-killed
1980 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1981 gnus-newsgroup-headers gnus-newsgroup-threads
1982 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1983 gnus-current-article gnus-current-headers gnus-have-all-headers
1984 gnus-last-article gnus-article-internal-prepare-hook
1985 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1986 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1987 gnus-newsgroup-async gnus-thread-expunge-below
1988 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1989 (gnus-summary-mark-below . global)
1990 gnus-newsgroup-active gnus-scores-exclude-files
1991 gnus-newsgroup-history gnus-newsgroup-ancient
1992 gnus-newsgroup-sparse
1993 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1994 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1995 (gnus-newsgroup-expunged-tally . 0)
1996 gnus-cache-removable-articles gnus-newsgroup-cached
1997 gnus-newsgroup-data gnus-newsgroup-data-reverse
1998 gnus-newsgroup-limit gnus-newsgroup-limits)
1999 "Variables that are buffer-local to the summary buffers.")
2001 (defconst gnus-bug-message
2002 "Sending a bug report to the Gnus Towers.
2003 ========================================
2005 The buffer below is a mail buffer. When you press `C-c C-c', it will
2006 be sent to the Gnus Bug Exterminators.
2008 At the bottom of the buffer you'll see lots of variable settings.
2009 Please do not delete those. They will tell the Bug People what your
2010 environment is, so that it will be easier to locate the bugs.
2012 If you have found a bug that makes Emacs go \"beep\", set
2013 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
2014 and include the backtrace in your bug report.
2016 Please describe the bug in annoying, painstaking detail.
2018 Thank you for your help in stamping out bugs.
2021 ;;; End of variables.
2023 ;; Define some autoload functions Gnus might use.
2026 ;; This little mapcar goes through the list below and marks the
2027 ;; symbols in question as autoloaded functions.
2030 (let ((interactive (nth 1 (memq ':interactive package))))
2034 (when (consp function)
2035 (setq keymap (car (memq 'keymap function)))
2036 (setq function (car function)))
2037 (autoload function (car package) nil interactive keymap)))
2038 (if (eq (nth 1 package) ':interactive)
2041 '(("metamail" metamail-buffer)
2042 ("info" Info-goto-node)
2043 ("hexl" hexl-hex-string-to-integer)
2044 ("pp" pp pp-to-string pp-eval-expression)
2045 ("mail-extr" mail-extract-address-components)
2046 ("nnmail" nnmail-split-fancy nnmail-article-group)
2047 ("nnvirtual" nnvirtual-catchup-group)
2048 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2049 timezone-make-sortable-date timezone-make-time-string)
2050 ("rmailout" rmail-output)
2051 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2053 ("gnus-soup" :interactive t
2054 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2055 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2056 ("nnsoup" nnsoup-pack-replies)
2057 ("score-mode" :interactive t gnus-score-mode)
2058 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2059 gnus-Folder-save-name gnus-folder-save-name)
2060 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2061 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2062 gnus-server-make-menu-bar gnus-article-make-menu-bar
2063 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2064 gnus-summary-highlight-line gnus-carpal-setup-buffer
2065 gnus-group-highlight-line
2066 gnus-article-add-button gnus-insert-next-page-button
2067 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2068 ("gnus-vis" :interactive t
2069 gnus-article-push-button gnus-article-press-button
2070 gnus-article-highlight gnus-article-highlight-some
2071 gnus-article-highlight-headers gnus-article-highlight-signature
2072 gnus-article-add-buttons gnus-article-add-buttons-to-head
2073 gnus-article-next-button gnus-article-prev-button)
2074 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2075 gnus-demon-add-disconnection gnus-demon-add-handler
2076 gnus-demon-remove-handler)
2077 ("gnus-demon" :interactive t
2078 gnus-demon-init gnus-demon-cancel)
2079 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2080 gnus-tree-open gnus-tree-close)
2081 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2082 gnus-nocem-unwanted-article-p)
2083 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2084 ("gnus-srvr" gnus-browse-foreign-server)
2085 ("gnus-cite" :interactive t
2086 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2087 gnus-article-hide-citation gnus-article-fill-cited-article
2088 gnus-article-hide-citation-in-followups)
2089 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2090 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2091 gnus-execute gnus-expunge)
2092 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2093 gnus-cache-possibly-remove-articles gnus-cache-request-article
2094 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2095 gnus-cache-enter-remove-article gnus-cached-article-p
2096 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2097 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2098 gnus-cache-remove-article)
2099 ("gnus-score" :interactive t
2100 gnus-summary-increase-score gnus-summary-lower-score
2101 gnus-score-flush-cache gnus-score-close
2102 gnus-score-raise-same-subject-and-select
2103 gnus-score-raise-same-subject gnus-score-default
2104 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2105 gnus-score-lower-same-subject gnus-score-lower-thread
2106 gnus-possibly-score-headers gnus-summary-raise-score
2107 gnus-summary-set-score gnus-summary-current-score)
2109 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2110 gnus-current-score-file-nondirectory gnus-score-adaptive
2111 gnus-score-find-trace gnus-score-file-name)
2112 ("gnus-edit" :interactive t gnus-score-customize)
2113 ("gnus-topic" :interactive t gnus-topic-mode)
2114 ("gnus-topic" gnus-topic-remove-group)
2115 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2116 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2117 ("gnus-uu" :interactive t
2118 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2119 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2120 gnus-uu-mark-by-regexp gnus-uu-mark-all
2121 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2122 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2123 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2124 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2125 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2126 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2127 gnus-uu-decode-binhex-view)
2128 ("gnus-msg" (gnus-summary-send-map keymap)
2129 gnus-mail-yank-original gnus-mail-send-and-exit
2130 gnus-article-mail gnus-new-mail gnus-mail-reply)
2131 ("gnus-msg" :interactive t
2132 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2133 gnus-summary-followup gnus-summary-followup-with-original
2134 gnus-summary-cancel-article gnus-summary-supersede-article
2135 gnus-post-news gnus-inews-news
2136 gnus-summary-reply gnus-summary-reply-with-original
2137 gnus-summary-mail-forward gnus-summary-mail-other-window
2139 ("gnus-picon" :interactive t gnus-article-display-picons
2140 gnus-group-display-picons gnus-picons-article-display-x-face
2141 gnus-picons-display-x-face)
2142 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2143 gnus-grouplens-mode)
2144 ("smiley" :interactive t gnus-smiley-display)
2145 ("gnus-vm" gnus-vm-mail-setup)
2146 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2147 gnus-summary-save-article-vm))))
2151 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2152 ;; If you want the cursor to go somewhere else, set these two
2153 ;; functions in some startup hook to whatever you want.
2154 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2155 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2157 ;;; Various macros and substs.
2159 (defun gnus-header-from (header)
2160 (mail-header-from header))
2162 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2163 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2164 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2165 (w (make-symbol "w"))
2166 (buf (make-symbol "buf")))
2167 `(let* ((,tempvar (selected-window))
2169 (,w (get-buffer-window ,buf 'visible)))
2174 (pop-to-buffer ,buf))
2176 (select-window ,tempvar)))))
2178 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2179 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2180 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2182 (defmacro gnus-gethash (string hashtable)
2183 "Get hash value of STRING in HASHTABLE."
2184 `(symbol-value (intern-soft ,string ,hashtable)))
2186 (defmacro gnus-sethash (string value hashtable)
2187 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2188 `(set (intern ,string ,hashtable) ,value))
2190 (defmacro gnus-intern-safe (string hashtable)
2191 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2192 `(let ((symbol (intern ,string ,hashtable)))
2197 (defmacro gnus-group-unread (group)
2198 "Get the currently computed number of unread articles in GROUP."
2199 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2201 (defmacro gnus-group-entry (group)
2202 "Get the newsrc entry for GROUP."
2203 `(gnus-gethash ,group gnus-newsrc-hashtb))
2205 (defmacro gnus-active (group)
2206 "Get active info on GROUP."
2207 `(gnus-gethash ,group gnus-active-hashtb))
2209 (defmacro gnus-set-active (group active)
2210 "Set GROUP's active info."
2211 `(gnus-sethash ,group ,active gnus-active-hashtb))
2213 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2214 ;; function `substring' might cut on a middle of multi-octet
2216 (defun gnus-truncate-string (str width)
2217 (substring str 0 width))
2219 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2220 ;; to limit the length of a string. This function is necessary since
2221 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2222 (defsubst gnus-limit-string (str width)
2223 (if (> (length str) width)
2224 (substring str 0 width)
2227 (defsubst gnus-simplify-subject-re (subject)
2228 "Remove \"Re:\" from subject lines."
2229 (if (string-match "^[Rr][Ee]: *" subject)
2230 (substring subject (match-end 0))
2233 (defsubst gnus-functionp (form)
2234 "Return non-nil if FORM is funcallable."
2235 (or (and (symbolp form) (fboundp form))
2236 (and (listp form) (eq (car form) 'lambda))))
2238 (defsubst gnus-goto-char (point)
2239 (and point (goto-char point)))
2241 (defmacro gnus-buffer-exists-p (buffer)
2242 `(let ((buffer ,buffer))
2244 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2247 (defmacro gnus-kill-buffer (buffer)
2248 `(let ((buf ,buffer))
2249 (if (gnus-buffer-exists-p buf)
2250 (kill-buffer buf))))
2252 (defsubst gnus-point-at-bol ()
2253 "Return point at the beginning of the line."
2260 (defsubst gnus-point-at-eol ()
2261 "Return point at the end of the line."
2268 (defun gnus-alive-p ()
2269 "Say whether Gnus is running or not."
2270 (and gnus-group-buffer
2271 (get-buffer gnus-group-buffer)))
2273 (defun gnus-delete-first (elt list)
2274 "Delete by side effect the first occurrence of ELT as a member of LIST."
2275 (if (equal (car list) elt)
2278 (while (and (cdr list)
2279 (not (equal (cadr list) elt)))
2280 (setq list (cdr list)))
2282 (setcdr list (cddr list)))
2285 ;; Delete the current line (and the next N lines.);
2286 (defmacro gnus-delete-line (&optional n)
2287 `(delete-region (progn (beginning-of-line) (point))
2288 (progn (forward-line ,(or n 1)) (point))))
2290 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2291 (defvar gnus-init-inhibit nil)
2292 (defun gnus-read-init-file (&optional inhibit-next)
2293 (if gnus-init-inhibit
2294 (setq gnus-init-inhibit nil)
2295 (setq gnus-init-inhibit inhibit-next)
2297 (or (and (file-exists-p gnus-init-file)
2298 ;; Don't try to load a directory.
2299 (not (file-directory-p gnus-init-file)))
2300 (file-exists-p (concat gnus-init-file ".el"))
2301 (file-exists-p (concat gnus-init-file ".elc")))
2303 (load gnus-init-file nil t)
2305 (error "Error in %s: %s" gnus-init-file var))))))
2307 ;; Info access macros.
2309 (defmacro gnus-info-group (info)
2311 (defmacro gnus-info-rank (info)
2313 (defmacro gnus-info-read (info)
2315 (defmacro gnus-info-marks (info)
2317 (defmacro gnus-info-method (info)
2319 (defmacro gnus-info-params (info)
2322 (defmacro gnus-info-level (info)
2323 `(let ((rank (gnus-info-rank ,info)))
2327 (defmacro gnus-info-score (info)
2328 `(let ((rank (gnus-info-rank ,info)))
2329 (or (and (consp rank) (cdr rank)) 0)))
2331 (defmacro gnus-info-set-group (info group)
2332 `(setcar ,info ,group))
2333 (defmacro gnus-info-set-rank (info rank)
2334 `(setcar (nthcdr 1 ,info) ,rank))
2335 (defmacro gnus-info-set-read (info read)
2336 `(setcar (nthcdr 2 ,info) ,read))
2337 (defmacro gnus-info-set-marks (info marks)
2338 `(setcar (nthcdr 3 ,info) ,marks))
2339 (defmacro gnus-info-set-method (info method)
2340 `(setcar (nthcdr 4 ,info) ,method))
2341 (defmacro gnus-info-set-params (info params)
2342 `(setcar (nthcdr 5 ,info) ,params))
2344 (defmacro gnus-info-set-level (info level)
2345 `(let ((rank (cdr ,info)))
2346 (if (consp (car rank))
2347 (setcar (car rank) ,level)
2348 (setcar rank ,level))))
2349 (defmacro gnus-info-set-score (info score)
2350 `(let ((rank (cdr ,info)))
2351 (if (consp (car rank))
2352 (setcdr (car rank) ,score)
2353 (setcar rank (cons (car rank) ,score)))))
2355 (defmacro gnus-get-info (group)
2356 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2358 (defun gnus-byte-code (func)
2359 "Return a form that can be `eval'ed based on FUNC."
2360 (let ((fval (symbol-function func)))
2361 (if (byte-code-function-p fval)
2362 (let ((flist (append fval nil)))
2363 (setcar flist 'byte-code)
2365 (cons 'progn (cddr fval)))))
2367 ;; Find out whether the gnus-visual TYPE is wanted.
2368 (defun gnus-visual-p (&optional type class)
2369 (and gnus-visual ; Has to be non-nil, at least.
2370 (if (not type) ; We don't care about type.
2372 (if (listp gnus-visual) ; It's a list, so we check it.
2373 (or (memq type gnus-visual)
2374 (memq class gnus-visual))
2377 ;;; Load the compatability functions.
2387 (defvar gnus-shutdown-alist nil)
2389 (defun gnus-add-shutdown (function &rest symbols)
2390 "Run FUNCTION whenever one of SYMBOLS is shut down."
2391 (push (cons function symbols) gnus-shutdown-alist))
2393 (defun gnus-shutdown (symbol)
2394 "Shut down everything that waits for SYMBOL."
2395 (let ((alist gnus-shutdown-alist)
2397 (while (setq entry (pop alist))
2398 (when (memq symbol (cdr entry))
2399 (funcall (car entry))))))
2403 ;; Format specs. The chunks below are the machine-generated forms
2404 ;; that are to be evaled as the result of the default format strings.
2405 ;; We write them in here to get them byte-compiled. That way the
2406 ;; default actions will be quite fast, while still retaining the full
2407 ;; flexibility of the user-defined format specs.
2409 ;; First we have lots of dummy defvars to let the compiler know these
2410 ;; are really dynamic variables.
2412 (defvar gnus-tmp-unread)
2413 (defvar gnus-tmp-replied)
2414 (defvar gnus-tmp-score-char)
2415 (defvar gnus-tmp-indentation)
2416 (defvar gnus-tmp-opening-bracket)
2417 (defvar gnus-tmp-lines)
2418 (defvar gnus-tmp-name)
2419 (defvar gnus-tmp-closing-bracket)
2420 (defvar gnus-tmp-subject-or-nil)
2421 (defvar gnus-tmp-subject)
2422 (defvar gnus-tmp-marked)
2423 (defvar gnus-tmp-marked-mark)
2424 (defvar gnus-tmp-subscribed)
2425 (defvar gnus-tmp-process-marked)
2426 (defvar gnus-tmp-number-of-unread)
2427 (defvar gnus-tmp-group-name)
2428 (defvar gnus-tmp-group)
2429 (defvar gnus-tmp-article-number)
2430 (defvar gnus-tmp-unread-and-unselected)
2431 (defvar gnus-tmp-news-method)
2432 (defvar gnus-tmp-news-server)
2433 (defvar gnus-tmp-article-number)
2434 (defvar gnus-mouse-face)
2435 (defvar gnus-mouse-face-prop)
2437 (defun gnus-summary-line-format-spec ()
2438 (insert gnus-tmp-unread gnus-tmp-replied
2439 gnus-tmp-score-char gnus-tmp-indentation)
2440 (gnus-put-text-property
2444 gnus-tmp-opening-bracket
2445 (format "%4d: %-20s"
2447 (if (> (length gnus-tmp-name) 20)
2448 (substring gnus-tmp-name 0 20)
2450 gnus-tmp-closing-bracket)
2452 gnus-mouse-face-prop gnus-mouse-face)
2453 (insert " " gnus-tmp-subject-or-nil "\n"))
2455 (defvar gnus-summary-line-format-spec
2456 (gnus-byte-code 'gnus-summary-line-format-spec))
2458 (defun gnus-summary-dummy-line-format-spec ()
2460 (gnus-put-text-property
2465 gnus-mouse-face-prop gnus-mouse-face)
2466 (insert " " gnus-tmp-subject "\n"))
2468 (defvar gnus-summary-dummy-line-format-spec
2469 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2471 (defun gnus-group-line-format-spec ()
2472 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2473 gnus-tmp-process-marked
2474 gnus-group-indentation
2475 (format "%5s: " gnus-tmp-number-of-unread))
2476 (gnus-put-text-property
2479 (insert gnus-tmp-group "\n")
2481 gnus-mouse-face-prop gnus-mouse-face))
2482 (defvar gnus-group-line-format-spec
2483 (gnus-byte-code 'gnus-group-line-format-spec))
2485 (defvar gnus-format-specs
2486 `((version . ,emacs-version)
2487 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2488 (summary-dummy ,gnus-summary-dummy-line-format
2489 ,gnus-summary-dummy-line-format-spec)
2490 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2492 (defvar gnus-article-mode-line-format-spec nil)
2493 (defvar gnus-summary-mode-line-format-spec nil)
2494 (defvar gnus-group-mode-line-format-spec nil)
2496 ;;; Phew. All that gruft is over, fortunately.
2500 ;;; Gnus Utility Functions
2503 (defun gnus-extract-address-components (from)
2505 ;; First find the address - the thing with the @ in it. This may
2506 ;; not be accurate in mail addresses, but does the trick most of
2507 ;; the time in news messages.
2508 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2509 (setq address (substring from (match-beginning 0) (match-end 0))))
2510 ;; Then we check whether the "name <address>" format is used.
2512 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2513 ;; Linear white space is not required.
2514 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2515 (and (setq name (substring from 0 (match-beginning 0)))
2516 ;; Strip any quotes from the name.
2517 (string-match "\".*\"" name)
2518 (setq name (substring name 1 (1- (match-end 0))))))
2519 ;; If not, then "address (name)" is used.
2521 (and (string-match "(.+)" from)
2522 (setq name (substring from (1+ (match-beginning 0))
2523 (1- (match-end 0)))))
2524 (and (string-match "()" from)
2525 (setq name address))
2526 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2527 ;; XOVER might not support folded From headers.
2528 (and (string-match "(.*" from)
2529 (setq name (substring from (1+ (match-beginning 0))
2531 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2532 (list (or name from) (or address from))))
2534 (defun gnus-fetch-field (field)
2535 "Return the value of the header FIELD of current article."
2538 (let ((case-fold-search t)
2539 (inhibit-point-motion-hooks t))
2540 (nnheader-narrow-to-headers)
2541 (message-fetch-field field)))))
2543 (defun gnus-goto-colon ()
2545 (search-forward ":" (gnus-point-at-eol) t))
2548 (defun gnus-update-format (var)
2549 "Update the format specification near point."
2554 ;; Find the end of the current word.
2555 (re-search-forward "[ \t\n]" nil t)
2557 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2558 (match-string 1)))))
2559 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2560 (match-string 1 var))))
2561 (entry (assq type gnus-format-specs))
2564 (setq gnus-format-specs (delq entry gnus-format-specs)))
2566 (intern (format "%s-spec" var))
2567 (gnus-parse-format (setq value (symbol-value (intern var)))
2568 (symbol-value (intern (format "%s-alist" var)))
2569 (not (string-match "mode" var))))
2570 (setq spec (symbol-value (intern (format "%s-spec" var))))
2571 (push (list type value spec) gnus-format-specs)
2573 (pop-to-buffer "*Gnus Format*")
2575 (lisp-interaction-mode)
2576 (insert (pp-to-string spec))))
2578 (defun gnus-update-format-specifications (&optional force)
2579 "Update all (necessary) format specifications."
2580 ;; Make the indentation array.
2581 (gnus-make-thread-indent-array)
2583 ;; See whether all the stored info needs to be flushed.
2585 (not (equal emacs-version
2586 (cdr (assq 'version gnus-format-specs)))))
2587 (setq gnus-format-specs nil))
2589 ;; Go through all the formats and see whether they need updating.
2590 (let ((types '(summary summary-dummy group
2591 summary-mode group-mode article-mode))
2592 new-format entry type val)
2593 (while (setq type (pop types))
2594 ;; Jump to the proper buffer to find out the value of
2595 ;; the variable, if possible. (It may be buffer-local.)
2597 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2599 (when (and (boundp buffer)
2600 (setq val (symbol-value buffer))
2602 (buffer-name (get-buffer val)))
2603 (set-buffer (get-buffer val)))
2604 (setq new-format (symbol-value
2605 (intern (format "gnus-%s-line-format" type))))))
2606 (setq entry (cdr (assq type gnus-format-specs)))
2608 (equal (car entry) new-format))
2609 ;; Use the old format.
2610 (set (intern (format "gnus-%s-line-format-spec" type))
2612 ;; This is a new format.
2614 (if (not (stringp new-format))
2615 ;; This is a function call or something.
2617 ;; This is a "real" format.
2621 (intern (format "gnus-%s-line-format-alist"
2622 (if (eq type 'article-mode)
2623 'summary-mode type))))
2624 (not (string-match "mode$" (symbol-name type))))))
2625 ;; Enter the new format spec into the list.
2628 (setcar (cdr entry) val)
2629 (setcar entry new-format))
2630 (push (list type new-format val) gnus-format-specs))
2631 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2633 (unless (assq 'version gnus-format-specs)
2634 (push (cons 'version emacs-version) gnus-format-specs))
2636 (gnus-update-group-mark-positions)
2637 (gnus-update-summary-mark-positions))
2639 (defun gnus-update-summary-mark-positions ()
2640 "Compute where the summary marks are to go."
2642 (when (and gnus-summary-buffer
2643 (get-buffer gnus-summary-buffer)
2644 (buffer-name (get-buffer gnus-summary-buffer)))
2645 (set-buffer gnus-summary-buffer))
2646 (let ((gnus-replied-mark 129)
2647 (gnus-score-below-mark 130)
2648 (gnus-score-over-mark 130)
2651 (spec gnus-summary-line-format-spec)
2654 (gnus-set-work-buffer)
2655 (let ((gnus-summary-line-format-spec spec))
2656 (gnus-summary-insert-line
2657 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2658 (goto-char (point-min))
2659 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2661 (goto-char (point-min))
2662 (push (cons 'replied (and (search-forward "\201" nil t)
2665 (goto-char (point-min))
2666 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2668 (setq gnus-summary-mark-positions pos))))
2670 (defun gnus-update-group-mark-positions ()
2672 (let ((gnus-process-mark 128)
2673 (gnus-group-marked '("dummy.group"))
2674 (gnus-active-hashtb (make-vector 10 0)))
2675 (gnus-set-active "dummy.group" '(0 . 0))
2676 (gnus-set-work-buffer)
2677 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2678 (goto-char (point-min))
2679 (setq gnus-group-mark-positions
2680 (list (cons 'process (and (search-forward "\200" nil t)
2681 (- (point) 2))))))))
2683 (defvar gnus-mouse-face-0 'highlight)
2684 (defvar gnus-mouse-face-1 'highlight)
2685 (defvar gnus-mouse-face-2 'highlight)
2686 (defvar gnus-mouse-face-3 'highlight)
2687 (defvar gnus-mouse-face-4 'highlight)
2689 (defun gnus-mouse-face-function (form type)
2690 `(gnus-put-text-property
2691 (point) (progn ,@form (point))
2692 gnus-mouse-face-prop
2695 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2697 (defvar gnus-face-0 'bold)
2698 (defvar gnus-face-1 'italic)
2699 (defvar gnus-face-2 'bold-italic)
2700 (defvar gnus-face-3 'bold)
2701 (defvar gnus-face-4 'bold)
2703 (defun gnus-face-face-function (form type)
2704 `(gnus-put-text-property
2705 (point) (progn ,@form (point))
2706 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2708 (defun gnus-max-width-function (el max-width)
2709 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2711 `(if (> (length ,el) ,max-width)
2712 (substring ,el 0 ,max-width)
2714 `(let ((val (eval ,el)))
2716 (setq val (int-to-string val)))
2717 (if (> (length val) ,max-width)
2718 (substring val 0 ,max-width)
2721 (defun gnus-parse-format (format spec-alist &optional insert)
2722 ;; This function parses the FORMAT string with the help of the
2723 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2724 ;; string. If the FORMAT string contains the specifiers %( and %)
2725 ;; the text between them will have the mouse-face text property.
2727 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2729 (gnus-parse-complex-format format spec-alist)
2730 ;; This is a simple format.
2731 (gnus-parse-simple-format format spec-alist insert)))
2733 (defun gnus-parse-complex-format (format spec-alist)
2735 (gnus-set-work-buffer)
2737 (goto-char (point-min))
2738 (while (re-search-forward "\"" nil t)
2739 (replace-match "\\\"" nil t))
2740 (goto-char (point-min))
2742 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2743 (let ((number (if (match-beginning 1)
2744 (match-string 1) "0"))
2745 (delim (aref (match-string 2) 0)))
2746 (if (or (= delim ?\() (= delim ?\{))
2747 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2749 (replace-match "\")\""))))
2750 (goto-char (point-max))
2752 (goto-char (point-min))
2753 (let ((form (read (current-buffer))))
2754 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2756 (defun gnus-complex-form-to-spec (form spec-alist)
2761 (gnus-parse-simple-format sform spec-alist t)
2762 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2763 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2767 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2768 ;; This function parses the FORMAT string with the help of the
2769 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2772 spec flist fstring newspec elem beg result dontinsert)
2774 (gnus-set-work-buffer)
2776 (goto-char (point-min))
2777 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2779 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2781 beg (1+ (match-beginning 0)))
2782 ;; First check if there are any specs that look anything like
2783 ;; "%12,12A", ie. with a "max width specification". These have
2784 ;; to be treated specially.
2785 (if (setq beg (match-beginning 1))
2789 (1+ (match-beginning 1)) (match-end 1))))
2791 (setq beg (match-beginning 2)))
2792 ;; Find the specification from `spec-alist'.
2793 (unless (setq elem (cdr (assq spec spec-alist)))
2794 (setq elem '("*" ?s)))
2795 ;; Treat user defined format specifiers specially.
2796 (when (eq (car elem) 'gnus-tmp-user-defined)
2799 (list (intern (concat "gnus-user-format-function-"
2801 'gnus-tmp-header) ?s))
2802 (delete-region (match-beginning 3) (match-end 3)))
2803 (if (not (zerop max-width))
2804 (let ((el (car elem)))
2805 (cond ((= (cadr elem) ?c)
2806 (setq el (list 'char-to-string el)))
2808 (setq el (list 'int-to-string el))))
2809 (setq flist (cons (gnus-max-width-function el max-width)
2813 (setq flist (cons (car elem) flist))
2814 (setq newspec (cadr elem)))))
2815 ;; Remove the old specification (and possibly a ",12" string).
2816 (delete-region beg (match-end 2))
2817 ;; Insert the new specification.
2820 (setq fstring (buffer-substring 1 (point-max))))
2821 ;; Do some postprocessing to increase efficiency.
2826 ((string= fstring "")
2828 ;; Not a format string.
2829 ((not (string-match "%" fstring))
2831 ;; A format string with just a single string spec.
2832 ((string= fstring "%s")
2834 ;; A single character.
2835 ((string= fstring "%c")
2838 ((string= fstring "%d")
2841 (list `(princ ,(car flist)))
2842 (list `(int-to-string ,(car flist)))))
2843 ;; Just lots of chars and strings.
2844 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2846 ;; A single string spec at the beginning of the spec.
2847 ((string-match "\\`%[sc][^%]+\\'" fstring)
2848 (list (car flist) (substring fstring 2)))
2849 ;; A single string spec in the middle of the spec.
2850 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2851 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2852 ;; A single string spec in the end of the spec.
2853 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2854 (list (match-string 1 fstring) (car flist)))
2855 ;; A more complex spec.
2857 (list (cons 'format (cons fstring (nreverse flist)))))))
2863 (cons 'insert result)))
2864 (cond ((stringp result)
2867 (cons 'concat result))
2870 (defun gnus-eval-format (format &optional alist props)
2871 "Eval the format variable FORMAT, using ALIST.
2872 If PROPS, insert the result."
2873 (let ((form (gnus-parse-format format alist props)))
2875 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2878 (defun gnus-remove-text-with-property (prop)
2879 "Delete all text in the current buffer with text property PROP."
2881 (goto-char (point-min))
2883 (while (get-text-property (point) prop)
2885 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2887 (defun gnus-set-work-buffer ()
2888 (if (get-buffer gnus-work-buffer)
2890 (set-buffer gnus-work-buffer)
2892 (set-buffer (get-buffer-create gnus-work-buffer))
2893 (kill-all-local-variables)
2894 (buffer-disable-undo (current-buffer))
2895 (gnus-add-current-to-buffer-list)))
2897 ;; Article file names when saving.
2899 (defun gnus-Numeric-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 nil, it is ~/News/News.group/num.
2902 Otherwise, it is like ~/News/news/group/num."
2905 (concat (if (gnus-use-long-file-name 'not-save)
2906 (gnus-capitalize-newsgroup newsgroup)
2907 (gnus-newsgroup-directory-form newsgroup))
2908 "/" (int-to-string (mail-header-number headers)))
2909 gnus-article-save-directory)))
2911 (string-equal (file-name-directory default)
2912 (file-name-directory last-file))
2913 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2915 (or last-file default))))
2917 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2918 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2919 If variable `gnus-use-long-file-name' is non-nil, it is
2920 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2923 (concat (if (gnus-use-long-file-name 'not-save)
2925 (gnus-newsgroup-directory-form newsgroup))
2926 "/" (int-to-string (mail-header-number headers)))
2927 gnus-article-save-directory)))
2929 (string-equal (file-name-directory default)
2930 (file-name-directory last-file))
2931 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2933 (or last-file default))))
2935 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2936 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2937 If variable `gnus-use-long-file-name' is non-nil, it is
2938 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2941 (if (gnus-use-long-file-name 'not-save)
2942 (gnus-capitalize-newsgroup newsgroup)
2943 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2944 gnus-article-save-directory)))
2946 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2947 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2948 If variable `gnus-use-long-file-name' is non-nil, it is
2949 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2952 (if (gnus-use-long-file-name 'not-save)
2954 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2955 gnus-article-save-directory)))
2957 ;; For subscribing new newsgroup
2959 (defun gnus-subscribe-hierarchical-interactive (groups)
2960 (let ((groups (sort groups 'string<))
2961 prefixes prefix start ans group starts)
2963 (setq prefixes (list "^"))
2964 (while (and groups prefixes)
2965 (while (not (string-match (car prefixes) (car groups)))
2966 (setq prefixes (cdr prefixes)))
2967 (setq prefix (car prefixes))
2968 (setq start (1- (length prefix)))
2969 (if (and (string-match "[^\\.]\\." (car groups) start)
2972 (concat "^" (substring (car groups) 0 (match-end 0))))
2973 (string-match prefix (cadr groups)))
2975 (setq prefixes (cons prefix prefixes))
2976 (message "Descend hierarchy %s? ([y]nsq): "
2977 (substring prefix 1 (1- (length prefix))))
2978 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2980 (message "Descend hierarchy %s? ([y]nsq): "
2981 (substring prefix 1 (1- (length prefix)))))
2984 (string-match prefix
2985 (setq group (car groups))))
2986 (setq gnus-killed-list
2987 (cons group gnus-killed-list))
2988 (gnus-sethash group group gnus-killed-hashtb)
2989 (setq groups (cdr groups)))
2990 (setq starts (cdr starts)))
2993 (string-match prefix
2994 (setq group (car groups))))
2995 (gnus-sethash group group gnus-killed-hashtb)
2996 (gnus-subscribe-alphabetically (car groups))
2997 (setq groups (cdr groups)))
2998 (setq starts (cdr starts)))
3001 (setq group (car groups))
3002 (setq gnus-killed-list (cons group gnus-killed-list))
3003 (gnus-sethash group group gnus-killed-hashtb)
3004 (setq groups (cdr groups))))
3006 (message "Subscribe %s? ([n]yq)" (car groups))
3007 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
3009 (message "Subscribe %s? ([n]yq)" (car groups)))
3010 (setq group (car groups))
3012 (gnus-subscribe-alphabetically (car groups))
3013 (gnus-sethash group group gnus-killed-hashtb))
3016 (setq group (car groups))
3017 (setq gnus-killed-list (cons group gnus-killed-list))
3018 (gnus-sethash group group gnus-killed-hashtb)
3019 (setq groups (cdr groups))))
3021 (setq gnus-killed-list (cons group gnus-killed-list))
3022 (gnus-sethash group group gnus-killed-hashtb)))
3023 (setq groups (cdr groups)))))))
3025 (defun gnus-subscribe-randomly (newsgroup)
3026 "Subscribe new NEWSGROUP by making it the first newsgroup."
3027 (gnus-subscribe-newsgroup newsgroup))
3029 (defun gnus-subscribe-alphabetically (newgroup)
3030 "Subscribe new NEWSGROUP and insert it in alphabetical order."
3031 (let ((groups (cdr gnus-newsrc-alist))
3033 (while (and (not before) groups)
3034 (if (string< newgroup (caar groups))
3035 (setq before (caar groups))
3036 (setq groups (cdr groups))))
3037 (gnus-subscribe-newsgroup newgroup before)))
3039 (defun gnus-subscribe-hierarchically (newgroup)
3040 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
3041 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3043 (set-buffer (find-file-noselect gnus-current-startup-file))
3044 (let ((groupkey newgroup)
3046 (while (and (not before) groupkey)
3047 (goto-char (point-min))
3049 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3050 (while (and (re-search-forward groupkey-re nil t)
3052 (setq before (match-string 1))
3053 (string< before newgroup)))))
3054 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3056 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3057 (substring groupkey (match-beginning 1) (match-end 1)))))
3058 (gnus-subscribe-newsgroup newgroup before))
3059 (kill-buffer (current-buffer))))
3061 (defun gnus-subscribe-interactively (group)
3062 "Subscribe the new GROUP interactively.
3063 It is inserted in hierarchical newsgroup order if subscribed. If not,
3065 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3066 (gnus-subscribe-hierarchically group)
3067 (push group gnus-killed-list)))
3069 (defun gnus-subscribe-zombies (group)
3070 "Make the new GROUP into a zombie group."
3071 (push group gnus-zombie-list))
3073 (defun gnus-subscribe-killed (group)
3074 "Make the new GROUP a killed group."
3075 (push group gnus-killed-list))
3077 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3078 "Subscribe new NEWSGROUP.
3079 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3080 the first newsgroup."
3081 ;; We subscribe the group by changing its level to `subscribed'.
3082 (gnus-group-change-level
3083 newsgroup gnus-level-default-subscribed
3084 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3085 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3089 (defun gnus-newsgroup-directory-form (newsgroup)
3090 "Make hierarchical directory name from NEWSGROUP name."
3091 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3092 (len (length newsgroup))
3094 ;; If this is a foreign group, we don't want to translate the
3096 (if (setq idx (string-match ":" newsgroup))
3097 (aset newsgroup idx ?/)
3099 ;; Replace all occurrences of `.' with `/'.
3101 (if (= (aref newsgroup idx) ?.)
3102 (aset newsgroup idx ?/))
3103 (setq idx (1+ idx)))
3106 (defun gnus-newsgroup-savable-name (group)
3107 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3109 (nnheader-replace-chars-in-string group ?/ ?.))
3111 (defun gnus-make-directory (dir)
3112 "Make DIRECTORY recursively."
3113 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3114 ;; of the many mysteries of the universe.
3115 (let* ((dir (expand-file-name dir default-directory))
3117 (if (string-match "/$" dir)
3118 (setq dir (substring dir 0 (match-beginning 0))))
3119 ;; First go down the path until we find a directory that exists.
3120 (while (not (file-exists-p dir))
3121 (setq dirs (cons dir dirs))
3122 (string-match "/[^/]+$" dir)
3123 (setq dir (substring dir 0 (match-beginning 0))))
3124 ;; Then create all the subdirs.
3125 (while (and dirs (not err))
3127 (make-directory (car dirs))
3128 (error (setq err t)))
3129 (setq dirs (cdr dirs)))
3130 ;; We return whether we were successful or not.
3133 (defun gnus-capitalize-newsgroup (newsgroup)
3134 "Capitalize NEWSGROUP name."
3135 (and (not (zerop (length newsgroup)))
3136 (concat (char-to-string (upcase (aref newsgroup 0)))
3137 (substring newsgroup 1))))
3139 ;; Various... things.
3141 (defun gnus-simplify-subject (subject &optional re-only)
3142 "Remove `Re:' and words in parentheses.
3143 If RE-ONLY is non-nil, strip leading `Re:'s only."
3144 (let ((case-fold-search t)) ;Ignore case.
3145 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3146 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3147 (setq subject (substring subject (match-end 0))))
3148 ;; Remove uninteresting prefixes.
3149 (if (and (not re-only)
3150 gnus-simplify-ignored-prefixes
3151 (string-match gnus-simplify-ignored-prefixes subject))
3152 (setq subject (substring subject (match-end 0))))
3153 ;; Remove words in parentheses from end.
3155 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3156 (setq subject (substring subject 0 (match-beginning 0)))))
3157 ;; Return subject string.
3160 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3162 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3163 (defun gnus-simplify-buffer-fuzzy ()
3164 (let ((case-fold-search t))
3165 (goto-char (point-min))
3166 (while (search-forward "\t" nil t)
3167 (replace-match " " t t))
3168 (goto-char (point-min))
3169 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3170 (goto-char (match-beginning 0))
3172 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3173 (looking-at "^[[].*: .*[]]$"))
3174 (goto-char (point-min))
3175 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3177 (replace-match "" t t))
3178 (goto-char (point-min))
3179 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3180 (goto-char (match-end 0))
3183 (progn (goto-char (match-beginning 0)))
3184 (re-search-forward ":"))))
3185 (goto-char (point-min))
3186 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3187 (replace-match "" t t))
3188 (goto-char (point-min))
3189 (while (re-search-forward " +" nil t)
3190 (replace-match " " t t))
3191 (goto-char (point-min))
3192 (while (re-search-forward " $" nil t)
3193 (replace-match "" t t))
3194 (goto-char (point-min))
3195 (while (re-search-forward "^ +" nil t)
3196 (replace-match "" t t))
3197 (goto-char (point-min))
3198 (when gnus-simplify-subject-fuzzy-regexp
3199 (if (listp gnus-simplify-subject-fuzzy-regexp)
3200 (let ((list gnus-simplify-subject-fuzzy-regexp))
3202 (goto-char (point-min))
3203 (while (re-search-forward (car list) nil t)
3204 (replace-match "" t t))
3205 (setq list (cdr list))))
3206 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3207 (replace-match "" t t))))))
3209 (defun gnus-simplify-subject-fuzzy (subject)
3210 "Siplify a subject string fuzzily."
3212 (gnus-set-work-buffer)
3213 (let ((case-fold-search t))
3215 (inline (gnus-simplify-buffer-fuzzy))
3218 ;; Add the current buffer to the list of buffers to be killed on exit.
3219 (defun gnus-add-current-to-buffer-list ()
3220 (or (memq (current-buffer) gnus-buffer-list)
3221 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3223 (defun gnus-string> (s1 s2)
3224 (not (or (string< s1 s2)
3227 (defun gnus-read-active-file-p ()
3228 "Say whether the active file has been read from `gnus-select-method'."
3229 (memq gnus-select-method gnus-have-read-active-file))
3231 ;;; General various misc type functions.
3233 (defun gnus-clear-system ()
3234 "Clear all variables and buffers."
3235 ;; Clear Gnus variables.
3236 (let ((variables gnus-variable-list))
3238 (set (car variables) nil)
3239 (setq variables (cdr variables))))
3240 ;; Clear other internal variables.
3241 (setq gnus-list-of-killed-groups nil
3242 gnus-have-read-active-file nil
3243 gnus-newsrc-alist nil
3244 gnus-newsrc-hashtb nil
3245 gnus-killed-list nil
3246 gnus-zombie-list nil
3247 gnus-killed-hashtb nil
3248 gnus-active-hashtb nil
3249 gnus-moderated-list nil
3250 gnus-description-hashtb nil
3251 gnus-current-headers nil
3252 gnus-thread-indent-array nil
3253 gnus-newsgroup-headers nil
3254 gnus-newsgroup-name nil
3255 gnus-server-alist nil
3256 gnus-group-list-mode nil
3257 gnus-opened-servers nil
3258 gnus-group-mark-positions nil
3259 gnus-newsgroup-data nil
3260 gnus-newsgroup-unreads nil
3261 nnoo-state-alist nil
3262 gnus-current-select-method nil)
3263 (gnus-shutdown 'gnus)
3264 ;; Kill the startup file.
3265 (and gnus-current-startup-file
3266 (get-file-buffer gnus-current-startup-file)
3267 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3268 ;; Clear the dribble buffer.
3269 (gnus-dribble-clear)
3270 ;; Kill global KILL file buffer.
3271 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3272 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3273 (gnus-kill-buffer nntp-server-buffer)
3274 ;; Kill Gnus buffers.
3275 (while gnus-buffer-list
3276 (gnus-kill-buffer (pop gnus-buffer-list)))
3277 ;; Remove Gnus frames.
3278 (gnus-kill-gnus-frames))
3280 (defun gnus-kill-gnus-frames ()
3281 "Kill all frames Gnus has created."
3282 (while gnus-created-frames
3283 (when (frame-live-p (car gnus-created-frames))
3284 ;; We slap a condition-case around this `delete-frame' to ensure
3285 ;; against errors if we try do delete the single frame that's left.
3287 (delete-frame (car gnus-created-frames))
3289 (pop gnus-created-frames)))
3291 (defun gnus-windows-old-to-new (setting)
3292 ;; First we take care of the really, really old Gnus 3 actions.
3293 (when (symbolp setting)
3295 ;; Take care of ooold GNUS 3.x values.
3296 (cond ((eq setting 'SelectArticle) 'article)
3297 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3298 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3300 (if (or (listp setting)
3301 (not (and gnus-window-configuration
3302 (memq setting '(group summary article)))))
3304 (let* ((setting (if (eq setting 'group)
3305 (if (assq 'newsgroup gnus-window-configuration)
3307 'newsgroups) setting))
3308 (elem (cadr (assq setting gnus-window-configuration)))
3309 (total (apply '+ elem))
3310 (types '(group summary article))
3311 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3316 (or (not (numberp (nth i elem)))
3317 (zerop (nth i elem))
3319 (setq perc (if (= i 2)
3321 (/ (float (nth 0 elem)) total)))
3322 (setq out (cons (if (eq pbuf (nth i types))
3323 (list (nth i types) perc 'point)
3324 (list (nth i types) perc))
3327 `(vertical 1.0 ,@(nreverse out)))))
3330 (defun gnus-add-configuration (conf)
3331 "Add the window configuration CONF to `gnus-buffer-configuration'."
3332 (setq gnus-buffer-configuration
3333 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3334 gnus-buffer-configuration))))
3336 (defvar gnus-frame-list nil)
3338 (defun gnus-configure-frame (split &optional window)
3339 "Split WINDOW according to SPLIT."
3341 (setq window (get-buffer-window (current-buffer))))
3342 (select-window window)
3343 ;; This might be an old-stylee buffer config.
3344 (when (vectorp split)
3345 (setq split (append split nil)))
3346 (when (or (consp (car split))
3347 (vectorp (car split)))
3349 (push 'vertical split))
3350 ;; The SPLIT might be something that is to be evaled to
3351 ;; return a new SPLIT.
3352 (while (and (not (assq (car split) gnus-window-to-buffer))
3353 (gnus-functionp (car split)))
3354 (setq split (eval split)))
3355 (let* ((type (car split))
3357 (len (if (eq type 'horizontal) (window-width) (window-height)))
3359 (window-min-width (or gnus-window-min-width window-min-width))
3360 (window-min-height (or gnus-window-min-height window-min-height))
3361 s result new-win rest comp-subs size sub)
3363 ;; Nothing to do here.
3365 ;; Don't switch buffers.
3367 (and (memq 'point split) window))
3368 ;; This is a buffer to be selected.
3369 ((not (memq type '(frame horizontal vertical)))
3370 (let ((buffer (cond ((stringp type) type)
3371 (t (cdr (assq type gnus-window-to-buffer)))))
3374 (error "Illegal buffer type: %s" type))
3375 (unless (setq buf (get-buffer (if (symbolp buffer)
3376 (symbol-value buffer) buffer)))
3377 (setq buf (get-buffer-create (if (symbolp buffer)
3378 (symbol-value buffer) buffer))))
3379 (switch-to-buffer buf)
3380 ;; We return the window if it has the `point' spec.
3381 (and (memq 'point split) window)))
3382 ;; This is a frame split.
3384 (unless gnus-frame-list
3385 (setq gnus-frame-list (list (window-frame
3386 (get-buffer-window (current-buffer))))))
3388 params frame fresult)
3389 (while (< i (length subs))
3390 ;; Frame parameter is gotten from the sub-split.
3391 (setq params (cadr (elt subs i)))
3392 ;; It should be a list.
3393 (unless (listp params)
3395 ;; Create a new frame?
3396 (unless (setq frame (elt gnus-frame-list i))
3397 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3398 (push frame gnus-created-frames))
3399 ;; Is the old frame still alive?
3400 (unless (frame-live-p frame)
3401 (setcar (nthcdr i gnus-frame-list)
3402 (setq frame (make-frame params))))
3403 ;; Select the frame in question and do more splits there.
3404 (select-frame frame)
3405 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3407 ;; Select the frame that has the selected buffer.
3409 (select-frame (window-frame fresult)))))
3410 ;; This is a normal split.
3412 (when (> (length subs) 0)
3413 ;; First we have to compute the sizes of all new windows.
3415 (setq sub (append (pop subs) nil))
3416 (while (and (not (assq (car sub) gnus-window-to-buffer))
3417 (gnus-functionp (car sub)))
3418 (setq sub (eval sub)))
3420 (push sub comp-subs)
3421 (setq size (cadar comp-subs))
3422 (cond ((equal size 1.0)
3423 (setq rest (car comp-subs))
3426 (setq s (floor (* size len))))
3430 (error "Illegal size: %s" size)))
3431 ;; Try to make sure that we are inside the safe limits.
3433 ((eq type 'horizontal)
3434 (setq s (max s window-min-width)))
3435 ((eq type 'vertical)
3436 (setq s (max s window-min-height))))
3437 (setcar (cdar comp-subs) s)
3439 ;; Take care of the "1.0" spec.
3441 (setcar (cdr rest) (- len total))
3442 (error "No 1.0 specs in %s" split))
3443 ;; The we do the actual splitting in a nice recursive
3445 (setq comp-subs (nreverse comp-subs))
3447 (if (null (cdr comp-subs))
3448 (setq new-win window)
3450 (split-window window (cadar comp-subs)
3451 (eq type 'horizontal))))
3452 (setq result (or (gnus-configure-frame
3453 (car comp-subs) window) result))
3454 (select-window new-win)
3455 (setq window new-win)
3456 (setq comp-subs (cdr comp-subs))))
3457 ;; Return the proper window, if any.
3459 (select-window result))))))
3461 (defvar gnus-frame-split-p nil)
3463 (defun gnus-configure-windows (setting &optional force)
3464 (setq setting (gnus-windows-old-to-new setting))
3465 (let ((split (if (symbolp setting)
3466 (cadr (assq setting gnus-buffer-configuration))
3470 (setq gnus-frame-split-p nil)
3473 (error "No such setting: %s" setting))
3475 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3477 ;; All the windows mentioned are already visible, so we just
3478 ;; put point in the assigned buffer, and do not touch the
3480 (select-window all-visible)
3482 ;; Either remove all windows or just remove all Gnus windows.
3483 (let ((frame (selected-frame)))
3485 (if gnus-use-full-window
3486 ;; We want to remove all other windows.
3487 (if (not gnus-frame-split-p)
3488 ;; This is not a `frame' split, so we ignore the
3490 (delete-other-windows)
3491 ;; This is a `frame' split, so we delete all windows
3495 (unless (eq (cdr (assq 'minibuffer
3496 (frame-parameters frame)))
3498 (select-frame frame)
3499 (delete-other-windows)))
3501 ;; Just remove some windows.
3502 (gnus-remove-some-windows)
3503 (switch-to-buffer nntp-server-buffer))
3504 (select-frame frame)))
3506 (switch-to-buffer nntp-server-buffer)
3507 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3509 (defun gnus-all-windows-visible-p (split)
3510 "Say whether all buffers in SPLIT are currently visible.
3511 In particular, the value returned will be the window that
3513 (let ((stack (list split))
3515 type buffer win buf)
3516 (while (and (setq split (pop stack))
3518 ;; Be backwards compatible.
3519 (when (vectorp split)
3520 (setq split (append split nil)))
3521 (when (or (consp (car split))
3522 (vectorp (car split)))
3524 (push 'vertical split))
3525 ;; The SPLIT might be something that is to be evaled to
3526 ;; return a new SPLIT.
3527 (while (and (not (assq (car split) gnus-window-to-buffer))
3528 (gnus-functionp (car split)))
3529 (setq split (eval split)))
3531 (setq type (elt split 0))
3536 ((not (memq type '(horizontal vertical frame)))
3537 (setq buffer (cond ((stringp type) type)
3538 (t (cdr (assq type gnus-window-to-buffer)))))
3540 (error "Illegal buffer type: %s" type))
3541 (when (setq buf (get-buffer (if (symbolp buffer)
3542 (symbol-value buffer)
3544 (setq win (get-buffer-window buf t)))
3546 (when (memq 'point split)
3547 (setq all-visible win))
3548 (setq all-visible nil)))
3550 (when (eq type 'frame)
3551 (setq gnus-frame-split-p t))
3552 (setq stack (append (cddr split) stack)))))
3553 (unless (eq all-visible t)
3556 (defun gnus-window-top-edge (&optional window)
3557 (nth 1 (window-edges window)))
3559 (defun gnus-remove-some-windows ()
3560 (let ((buffers gnus-window-to-buffer)
3561 buf bufs lowest-buf lowest)
3563 ;; Remove windows on all known Gnus buffers.
3565 (setq buf (cdar buffers))
3567 (setq buf (and (boundp buf) (symbol-value buf))))
3569 (get-buffer-window buf)
3571 (setq bufs (cons buf bufs))
3573 (if (or (not lowest)
3574 (< (gnus-window-top-edge) lowest))
3576 (setq lowest (gnus-window-top-edge))
3577 (setq lowest-buf buf)))))
3578 (setq buffers (cdr buffers)))
3579 ;; Remove windows on *all* summary buffers.
3582 (let ((buf (window-buffer win)))
3583 (if (string-match "^\\*Summary" (buffer-name buf))
3585 (setq bufs (cons buf bufs))
3587 (if (or (not lowest)
3588 (< (gnus-window-top-edge) lowest))
3590 (setq lowest-buf buf)
3591 (setq lowest (gnus-window-top-edge)))))))))
3594 (pop-to-buffer lowest-buf)
3595 (switch-to-buffer nntp-server-buffer)))
3597 (and (not (eq (car bufs) lowest-buf))
3598 (delete-windows-on (car bufs)))
3599 (setq bufs (cdr bufs))))))
3601 (defun gnus-version (&optional arg)
3602 "Version number of this version of Gnus.
3603 If ARG, insert string at point."
3605 (let ((methods gnus-valid-select-methods)
3608 ;; Go through all the legal select methods and add their version
3609 ;; numbers to the total version string. Only the backends that are
3610 ;; currently in use will have their message numbers taken into
3613 (setq meth (intern (concat (caar methods) "-version")))
3615 (stringp (symbol-value meth))
3616 (setq mess (concat mess "; " (symbol-value meth))))
3617 (setq methods (cdr methods)))
3619 (insert (message mess))
3622 (defun gnus-info-find-node ()
3623 "Find Info documentation of Gnus."
3625 ;; Enlarge info window if needed.
3626 (let ((mode major-mode)
3628 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3629 (setq gnus-info-buffer (current-buffer))
3630 (gnus-configure-windows 'info)))
3632 (defun gnus-days-between (date1 date2)
3633 ;; Return the number of days between date1 and date2.
3634 (- (gnus-day-number date1) (gnus-day-number date2)))
3636 (defun gnus-day-number (date)
3637 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3638 (timezone-parse-date date))))
3639 (timezone-absolute-from-gregorian
3640 (nth 1 dat) (nth 2 dat) (car dat))))
3642 (defun gnus-encode-date (date)
3643 "Convert DATE to internal time."
3644 (let* ((parse (timezone-parse-date date))
3645 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3646 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3647 (encode-time (caddr time) (cadr time) (car time)
3648 (caddr date) (cadr date) (car date) (nth 4 date))))
3650 (defun gnus-time-minus (t1 t2)
3651 "Subtract two internal times."
3652 (let ((borrow (< (cadr t1) (cadr t2))))
3653 (list (- (car t1) (car t2) (if borrow 1 0))
3654 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3656 (defun gnus-file-newer-than (file date)
3657 (let ((fdate (nth 5 (file-attributes file))))
3658 (or (> (car fdate) (car date))
3659 (and (= (car fdate) (car date))
3660 (> (nth 1 fdate) (nth 1 date))))))
3662 (defmacro gnus-local-set-keys (&rest plist)
3663 "Set the keys in PLIST in the current keymap."
3664 `(gnus-define-keys-1 (current-local-map) ',plist))
3666 (defmacro gnus-define-keys (keymap &rest plist)
3667 "Define all keys in PLIST in KEYMAP."
3668 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3670 (put 'gnus-define-keys 'lisp-indent-function 1)
3671 (put 'gnus-define-keys 'lisp-indent-hook 1)
3672 (put 'gnus-define-keymap 'lisp-indent-function 1)
3673 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3675 (defmacro gnus-define-keymap (keymap &rest plist)
3676 "Define all keys in PLIST in KEYMAP."
3677 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3679 (defun gnus-define-keys-1 (keymap plist)
3681 (error "Can't set keys in a null keymap"))
3682 (cond ((symbolp keymap)
3683 (setq keymap (symbol-value keymap)))
3686 (set (car keymap) nil)
3687 (define-prefix-command (car keymap))
3688 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3689 (setq keymap (symbol-value (car keymap)))))
3692 (when (symbolp (setq key (pop plist)))
3693 (setq key (symbol-value key)))
3694 (define-key keymap key (pop plist)))))
3696 (defun gnus-group-read-only-p (&optional group)
3697 "Check whether GROUP supports editing or not.
3698 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3699 that that variable is buffer-local to the summary buffers."
3700 (let ((group (or group gnus-newsgroup-name)))
3701 (not (gnus-check-backend-function 'request-replace-article group))))
3703 (defun gnus-group-total-expirable-p (group)
3704 "Check whether GROUP is total-expirable or not."
3705 (let ((params (gnus-info-params (gnus-get-info group))))
3706 (or (memq 'total-expire params)
3707 (cdr (assq 'total-expire params)) ; (total-expire . t)
3708 (and gnus-total-expirable-newsgroups ; Check var.
3709 (string-match gnus-total-expirable-newsgroups group)))))
3711 (defun gnus-group-auto-expirable-p (group)
3712 "Check whether GROUP is total-expirable or not."
3713 (let ((params (gnus-info-params (gnus-get-info group))))
3714 (or (memq 'auto-expire params)
3715 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3716 (and gnus-auto-expirable-newsgroups ; Check var.
3717 (string-match gnus-auto-expirable-newsgroups group)))))
3719 (defun gnus-virtual-group-p (group)
3720 "Say whether GROUP is virtual or not."
3721 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3722 gnus-valid-select-methods)))
3724 (defun gnus-news-group-p (group &optional article)
3725 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3726 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3727 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3728 (eq (gnus-request-type group article) 'news))))
3730 (defsubst gnus-simplify-subject-fully (subject)
3731 "Simplify a subject string according to the user's wishes."
3733 ((null gnus-summary-gather-subject-limit)
3734 (gnus-simplify-subject-re subject))
3735 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3736 (gnus-simplify-subject-fuzzy subject))
3737 ((numberp gnus-summary-gather-subject-limit)
3738 (gnus-limit-string (gnus-simplify-subject-re subject)
3739 gnus-summary-gather-subject-limit))
3743 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3744 "Check whether two subjects are equal. If optional argument
3745 simple-first is t, first argument is already simplified."
3747 ((null simple-first)
3748 (equal (gnus-simplify-subject-fully s1)
3749 (gnus-simplify-subject-fully s2)))
3752 (gnus-simplify-subject-fully s2)))))
3754 ;; Returns a list of writable groups.
3755 (defun gnus-writable-groups ()
3756 (let ((alist gnus-newsrc-alist)
3758 (while (setq group (car (pop alist)))
3759 (unless (gnus-group-read-only-p group)
3760 (push group groups)))
3763 (defun gnus-completing-read (default prompt &rest args)
3764 ;; Like `completing-read', except that DEFAULT is the default argument.
3765 (let* ((prompt (if default
3766 (concat prompt " (default " default ") ")
3767 (concat prompt " ")))
3768 (answer (apply 'completing-read prompt args)))
3769 (if (or (null answer) (zerop (length answer)))
3773 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3775 (defun gnus-y-or-n-p (prompt)
3780 (defun gnus-yes-or-no-p (prompt)
3782 (yes-or-no-p prompt)
3785 ;; Check whether to use long file names.
3786 (defun gnus-use-long-file-name (symbol)
3787 ;; The variable has to be set...
3788 (and gnus-use-long-file-name
3789 ;; If it isn't a list, then we return t.
3790 (or (not (listp gnus-use-long-file-name))
3791 ;; If it is a list, and the list contains `symbol', we
3793 (not (memq symbol gnus-use-long-file-name)))))
3795 ;; I suspect there's a better way, but I haven't taken the time to do
3796 ;; it yet. -erik selberg@cs.washington.edu
3797 (defun gnus-dd-mmm (messy-date)
3798 "Return a string like DD-MMM from a big messy string"
3799 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3805 ;; Make sure leading zeroes are stripped.
3806 (number-to-string (string-to-number (aref datevec 2)))
3810 (nth (1- (string-to-number (aref datevec 1)))
3811 timezone-months-assoc))
3814 (defun gnus-mode-string-quote (string)
3815 "Quote all \"%\" in STRING."
3817 (gnus-set-work-buffer)
3819 (goto-char (point-min))
3820 (while (search-forward "%" nil t)
3824 ;; Make a hash table (default and minimum size is 255).
3825 ;; Optional argument HASHSIZE specifies the table size.
3826 (defun gnus-make-hashtable (&optional hashsize)
3827 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3829 ;; Make a number that is suitable for hashing; bigger than MIN and one
3831 (defun gnus-create-hash-size (min)
3837 ;; Show message if message has a lower level than `gnus-verbose'.
3838 ;; Guideline for numbers:
3839 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3840 ;; for things that take a long time, 7 - not very important messages
3841 ;; on stuff, 9 - messages inside loops.
3842 (defun gnus-message (level &rest args)
3843 (if (<= level gnus-verbose)
3844 (apply 'message args)
3845 ;; We have to do this format thingy here even if the result isn't
3846 ;; shown - the return value has to be the same as the return value
3848 (apply 'format args)))
3850 (defun gnus-error (level &rest args)
3851 "Beep an error if LEVEL is equal to or less than `gnus-verbose'."
3852 (when (<= (floor level) gnus-verbose)
3853 (apply 'message args)
3856 (when (and (floatp level)
3857 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3858 (sit-for duration))))
3861 ;; Generate a unique new group name.
3862 (defun gnus-generate-new-group-name (leaf)
3865 (while (gnus-gethash name gnus-newsrc-hashtb)
3866 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3869 (defsubst gnus-hide-text (b e props)
3870 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3871 (gnus-add-text-properties b e props)
3872 (when (memq 'intangible props)
3873 (gnus-put-text-property (max (1- b) (point-min))
3874 b 'intangible (cddr (memq 'intangible props)))))
3876 (defsubst gnus-unhide-text (b e)
3877 "Remove hidden text properties from region between B and E."
3878 (remove-text-properties b e gnus-hidden-properties)
3879 (when (memq 'intangible gnus-hidden-properties)
3880 (gnus-put-text-property (max (1- b) (point-min))
3881 b 'intangible nil)))
3883 (defun gnus-hide-text-type (b e type)
3884 "Hide text of TYPE between B and E."
3885 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3887 (defun gnus-parent-headers (headers &optional generation)
3888 "Return the headers of the GENERATIONeth parent of HEADERS."
3890 (setq generation 1))
3891 (let (references parent)
3892 (while (and headers (not (zerop generation)))
3893 (setq references (mail-header-references headers))
3894 (when (and references
3895 (setq parent (gnus-parent-id references))
3896 (setq headers (car (gnus-id-to-thread parent))))
3900 (defun gnus-parent-id (references)
3901 "Return the last Message-ID in REFERENCES."
3902 (when (and references
3903 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3904 (substring references (match-beginning 1) (match-end 1))))
3906 (defun gnus-split-references (references)
3907 "Return a list of Message-IDs in REFERENCES."
3910 (while (string-match "<[^>]+>" references beg)
3911 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3915 (defun gnus-buffer-live-p (buffer)
3916 "Say whether BUFFER is alive or not."
3919 (buffer-name (get-buffer buffer))))
3921 (defun gnus-ephemeral-group-p (group)
3922 "Say whether GROUP is ephemeral or not."
3923 (gnus-group-get-parameter group 'quit-config))
3925 (defun gnus-group-quit-config (group)
3926 "Return the quit-config of GROUP."
3927 (gnus-group-get-parameter group 'quit-config))
3929 (defun gnus-simplify-mode-line ()
3930 "Make mode lines a bit simpler."
3931 (setq mode-line-modified "-- ")
3932 (when (listp mode-line-format)
3933 (make-local-variable 'mode-line-format)
3934 (setq mode-line-format (copy-sequence mode-line-format))
3935 (when (equal (nth 3 mode-line-format) " ")
3936 (setcar (nthcdr 3 mode-line-format) " "))))
3938 ;;; List and range functions
3940 (defun gnus-last-element (list)
3941 "Return last element of LIST."
3943 (setq list (cdr list)))
3946 (defun gnus-copy-sequence (list)
3947 "Do a complete, total copy of a list."
3948 (if (and (consp list) (not (consp (cdr list))))
3949 (cons (car list) (cdr list))
3950 (mapcar (lambda (elem) (if (consp elem)
3951 (if (consp (cdr elem))
3952 (gnus-copy-sequence elem)
3953 (cons (car elem) (cdr elem)))
3957 (defun gnus-set-difference (list1 list2)
3958 "Return a list of elements of LIST1 that do not appear in LIST2."
3959 (let ((list1 (copy-sequence list1)))
3961 (setq list1 (delq (car list2) list1))
3962 (setq list2 (cdr list2)))
3965 (defun gnus-sorted-complement (list1 list2)
3966 "Return a list of elements of LIST1 that do not appear in LIST2.
3967 Both lists have to be sorted over <."
3969 (if (or (null list1) (null list2))
3971 (while (and list1 list2)
3972 (cond ((= (car list1) (car list2))
3973 (setq list1 (cdr list1)
3975 ((< (car list1) (car list2))
3976 (setq out (cons (car list1) out))
3977 (setq list1 (cdr list1)))
3979 (setq out (cons (car list2) out))
3980 (setq list2 (cdr list2)))))
3981 (nconc (nreverse out) (or list1 list2)))))
3983 (defun gnus-intersection (list1 list2)
3986 (if (memq (car list2) list1)
3987 (setq result (cons (car list2) result)))
3988 (setq list2 (cdr list2)))
3991 (defun gnus-sorted-intersection (list1 list2)
3992 ;; LIST1 and LIST2 have to be sorted over <.
3994 (while (and list1 list2)
3995 (cond ((= (car list1) (car list2))
3996 (setq out (cons (car list1) out)
3999 ((< (car list1) (car list2))
4000 (setq list1 (cdr list1)))
4002 (setq list2 (cdr list2)))))
4005 (defun gnus-set-sorted-intersection (list1 list2)
4006 ;; LIST1 and LIST2 have to be sorted over <.
4007 ;; This function modifies LIST1.
4008 (let* ((top (cons nil list1))
4010 (while (and list1 list2)
4011 (cond ((= (car list1) (car list2))
4015 ((< (car list1) (car list2))
4016 (setcdr prev (cdr list1))
4017 (setq list1 (cdr list1)))
4019 (setq list2 (cdr list2)))))
4023 (defun gnus-compress-sequence (numbers &optional always-list)
4024 "Convert list of numbers to a list of ranges or a single range.
4025 If ALWAYS-LIST is non-nil, this function will always release a list of
4027 (let* ((first (car numbers))
4028 (last (car numbers))
4032 (if (not (listp (cdr numbers)))
4035 (cond ((= last (car numbers)) nil) ;Omit duplicated number
4036 ((= (1+ last) (car numbers)) ;Still in sequence
4037 (setq last (car numbers)))
4038 (t ;End of one sequence
4040 (cons (if (= first last) first
4041 (cons first last)) result))
4042 (setq first (car numbers))
4043 (setq last (car numbers))))
4044 (setq numbers (cdr numbers)))
4045 (if (and (not always-list) (null result))
4046 (if (= first last) (list first) (cons first last))
4047 (nreverse (cons (if (= first last) first (cons first last))
4050 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
4051 (defun gnus-uncompress-range (ranges)
4052 "Expand a list of ranges into a list of numbers.
4053 RANGES is either a single range on the form `(num . num)' or a list of
4055 (let (first last result)
4059 ((not (listp (cdr ranges)))
4060 (setq first (car ranges))
4061 (setq last (cdr ranges))
4062 (while (<= first last)
4063 (setq result (cons first result))
4064 (setq first (1+ first)))
4068 (if (atom (car ranges))
4069 (if (numberp (car ranges))
4070 (setq result (cons (car ranges) result)))
4071 (setq first (caar ranges))
4072 (setq last (cdar ranges))
4073 (while (<= first last)
4074 (setq result (cons first result))
4075 (setq first (1+ first))))
4076 (setq ranges (cdr ranges)))
4077 (nreverse result)))))
4079 (defun gnus-add-to-range (ranges list)
4080 "Return a list of ranges that has all articles from both RANGES and LIST.
4081 Note: LIST has to be sorted over `<'."
4083 (gnus-compress-sequence list t)
4084 (setq list (copy-sequence list))
4085 (or (listp (cdr ranges))
4086 (setq ranges (list ranges)))
4088 ilist lowest highest temp)
4089 (while (and ranges list)
4091 (setq lowest (or (and (atom (car ranges)) (car ranges))
4093 (while (and list (cdr list) (< (cadr list) lowest))
4094 (setq list (cdr list)))
4095 (if (< (car ilist) lowest)
4098 (setq list (cdr list))
4100 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4101 (setq highest (or (and (atom (car ranges)) (car ranges))
4103 (while (and list (<= (car list) highest))
4104 (setq list (cdr list)))
4105 (setq ranges (cdr ranges)))
4107 (setq out (nconc (gnus-compress-sequence list t) out)))
4108 (setq out (sort out (lambda (r1 r2)
4109 (< (or (and (atom r1) r1) (car r1))
4110 (or (and (atom r2) r2) (car r2))))))
4113 (if (atom (car ranges))
4115 (if (atom (cadr ranges))
4116 (if (= (1+ (car ranges)) (cadr ranges))
4118 (setcar ranges (cons (car ranges)
4120 (setcdr ranges (cddr ranges))))
4121 (if (= (1+ (car ranges)) (caadr ranges))
4123 (setcar (cadr ranges) (car ranges))
4124 (setcar ranges (cadr ranges))
4125 (setcdr ranges (cddr ranges))))))
4127 (if (atom (cadr ranges))
4128 (if (= (1+ (cdar ranges)) (cadr ranges))
4130 (setcdr (car ranges) (cadr ranges))
4131 (setcdr ranges (cddr ranges))))
4132 (if (= (1+ (cdar ranges)) (caadr ranges))
4134 (setcdr (car ranges) (cdadr ranges))
4135 (setcdr ranges (cddr ranges)))))))
4136 (setq ranges (cdr ranges)))
4139 (defun gnus-remove-from-range (ranges list)
4140 "Return a list of ranges that has all articles from LIST removed from RANGES.
4141 Note: LIST has to be sorted over `<'."
4142 ;; !!! This function shouldn't look like this, but I've got a headache.
4143 (gnus-compress-sequence
4144 (gnus-sorted-complement
4145 (gnus-uncompress-range ranges) list)))
4147 (defun gnus-member-of-range (number ranges)
4148 (if (not (listp (cdr ranges)))
4149 (and (>= number (car ranges))
4150 (<= number (cdr ranges)))
4153 (if (numberp (car ranges))
4154 (>= number (car ranges))
4155 (>= number (caar ranges)))
4157 (if (if (numberp (car ranges))
4158 (= number (car ranges))
4159 (and (>= number (caar ranges))
4160 (<= number (cdar ranges))))
4161 (setq not-stop nil))
4162 (setq ranges (cdr ranges)))
4165 (defun gnus-range-length (range)
4166 "Return the length RANGE would have if uncompressed."
4167 (length (gnus-uncompress-range range)))
4169 (defun gnus-sublist-p (list sublist)
4170 "Test whether all elements in SUBLIST are members of LIST."
4173 (unless (memq (pop sublist) list)
4183 (defvar gnus-group-mode-map nil)
4184 (put 'gnus-group-mode 'mode-class 'special)
4186 (unless gnus-group-mode-map
4187 (setq gnus-group-mode-map (make-keymap))
4188 (suppress-keymap gnus-group-mode-map)
4190 (gnus-define-keys gnus-group-mode-map
4191 " " gnus-group-read-group
4192 "=" gnus-group-select-group
4193 "\r" gnus-group-select-group
4194 "\M-\r" gnus-group-quick-select-group
4195 "j" gnus-group-jump-to-group
4196 "n" gnus-group-next-unread-group
4197 "p" gnus-group-prev-unread-group
4198 "\177" gnus-group-prev-unread-group
4199 [delete] gnus-group-prev-unread-group
4200 "N" gnus-group-next-group
4201 "P" gnus-group-prev-group
4202 "\M-n" gnus-group-next-unread-group-same-level
4203 "\M-p" gnus-group-prev-unread-group-same-level
4204 "," gnus-group-best-unread-group
4205 "." gnus-group-first-unread-group
4206 "u" gnus-group-unsubscribe-current-group
4207 "U" gnus-group-unsubscribe-group
4208 "c" gnus-group-catchup-current
4209 "C" gnus-group-catchup-current-all
4210 "l" gnus-group-list-groups
4211 "L" gnus-group-list-all-groups
4213 "g" gnus-group-get-new-news
4214 "\M-g" gnus-group-get-new-news-this-group
4215 "R" gnus-group-restart
4216 "r" gnus-group-read-init-file
4217 "B" gnus-group-browse-foreign-server
4218 "b" gnus-group-check-bogus-groups
4219 "F" gnus-find-new-newsgroups
4220 "\C-c\C-d" gnus-group-describe-group
4221 "\M-d" gnus-group-describe-all-groups
4222 "\C-c\C-a" gnus-group-apropos
4223 "\C-c\M-\C-a" gnus-group-description-apropos
4224 "a" gnus-group-post-news
4225 "\ek" gnus-group-edit-local-kill
4226 "\eK" gnus-group-edit-global-kill
4227 "\C-k" gnus-group-kill-group
4228 "\C-y" gnus-group-yank-group
4229 "\C-w" gnus-group-kill-region
4230 "\C-x\C-t" gnus-group-transpose-groups
4231 "\C-c\C-l" gnus-group-list-killed
4232 "\C-c\C-x" gnus-group-expire-articles
4233 "\C-c\M-\C-x" gnus-group-expire-all-groups
4235 "s" gnus-group-save-newsrc
4236 "z" gnus-group-suspend
4237 ; "Z" gnus-group-clear-dribble
4240 "?" gnus-group-describe-briefly
4241 "\C-c\C-i" gnus-info-find-node
4242 "\M-e" gnus-group-edit-group-method
4243 "^" gnus-group-enter-server-mode
4244 gnus-mouse-2 gnus-mouse-pick-group
4245 "<" beginning-of-buffer
4248 "\C-c\C-s" gnus-group-sort-groups
4250 "\C-c\M-g" gnus-activate-all-groups
4251 "\M-&" gnus-group-universal-argument
4252 "#" gnus-group-mark-group
4253 "\M-#" gnus-group-unmark-group)
4255 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4256 "m" gnus-group-mark-group
4257 "u" gnus-group-unmark-group
4258 "w" gnus-group-mark-region
4259 "m" gnus-group-mark-buffer
4260 "r" gnus-group-mark-regexp
4261 "U" gnus-group-unmark-all-groups)
4263 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4264 "d" gnus-group-make-directory-group
4265 "h" gnus-group-make-help-group
4266 "a" gnus-group-make-archive-group
4267 "k" gnus-group-make-kiboze-group
4268 "m" gnus-group-make-group
4269 "E" gnus-group-edit-group
4270 "e" gnus-group-edit-group-method
4271 "p" gnus-group-edit-group-parameters
4272 "v" gnus-group-add-to-virtual
4273 "V" gnus-group-make-empty-virtual
4274 "D" gnus-group-enter-directory
4275 "f" gnus-group-make-doc-group
4276 "r" gnus-group-rename-group
4277 "\177" gnus-group-delete-group
4278 [delete] gnus-group-delete-group)
4280 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4281 "b" gnus-group-brew-soup
4282 "w" gnus-soup-save-areas
4283 "s" gnus-soup-send-replies
4284 "p" gnus-soup-pack-packet
4285 "r" nnsoup-pack-replies)
4287 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4288 "s" gnus-group-sort-groups
4289 "a" gnus-group-sort-groups-by-alphabet
4290 "u" gnus-group-sort-groups-by-unread
4291 "l" gnus-group-sort-groups-by-level
4292 "v" gnus-group-sort-groups-by-score
4293 "r" gnus-group-sort-groups-by-rank
4294 "m" gnus-group-sort-groups-by-method)
4296 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4297 "k" gnus-group-list-killed
4298 "z" gnus-group-list-zombies
4299 "s" gnus-group-list-groups
4300 "u" gnus-group-list-all-groups
4301 "A" gnus-group-list-active
4302 "a" gnus-group-apropos
4303 "d" gnus-group-description-apropos
4304 "m" gnus-group-list-matching
4305 "M" gnus-group-list-all-matching
4306 "l" gnus-group-list-level)
4308 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4309 "f" gnus-score-flush-cache)
4311 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4312 "f" gnus-group-fetch-faq)
4314 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4315 "l" gnus-group-set-current-level
4316 "t" gnus-group-unsubscribe-current-group
4317 "s" gnus-group-unsubscribe-group
4318 "k" gnus-group-kill-group
4319 "y" gnus-group-yank-group
4320 "w" gnus-group-kill-region
4321 "\C-k" gnus-group-kill-level
4322 "z" gnus-group-kill-all-zombies))
4324 (defun gnus-group-mode ()
4325 "Major mode for reading news.
4327 All normal editing commands are switched off.
4328 \\<gnus-group-mode-map>
4329 The group buffer lists (some of) the groups available. For instance,
4330 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4331 lists all zombie groups.
4333 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4334 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4336 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4338 The following commands are available:
4340 \\{gnus-group-mode-map}"
4342 (when (and menu-bar-mode
4343 (gnus-visual-p 'group-menu 'menu))
4344 (gnus-group-make-menu-bar))
4345 (kill-all-local-variables)
4346 (gnus-simplify-mode-line)
4347 (setq major-mode 'gnus-group-mode)
4348 (setq mode-name "Group")
4349 (gnus-group-set-mode-line)
4350 (setq mode-line-process nil)
4351 (use-local-map gnus-group-mode-map)
4352 (buffer-disable-undo (current-buffer))
4353 (setq truncate-lines t)
4354 (setq buffer-read-only t)
4355 (gnus-make-local-hook 'post-command-hook)
4356 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4357 (run-hooks 'gnus-group-mode-hook))
4359 (defun gnus-clear-inboxes-moved ()
4360 (setq nnmail-moved-inboxes nil))
4362 (defun gnus-mouse-pick-group (e)
4363 "Enter the group under the mouse pointer."
4366 (gnus-group-read-group nil))
4368 ;; Look at LEVEL and find out what the level is really supposed to be.
4369 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4370 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4371 (defun gnus-group-default-level (&optional level number-or-nil)
4373 (gnus-group-use-permanent-levels
4374 (or (setq gnus-group-use-permanent-levels
4375 (or level (if (numberp gnus-group-use-permanent-levels)
4376 gnus-group-use-permanent-levels
4377 (or gnus-group-default-list-level
4378 gnus-level-subscribed))))
4379 gnus-group-default-list-level gnus-level-subscribed))
4383 (or level gnus-group-default-list-level gnus-level-subscribed))))
4386 (defun gnus-slave-no-server (&optional arg)
4387 "Read network news as a slave, without connecting to local server"
4389 (gnus-no-server arg t))
4392 (defun gnus-no-server (&optional arg slave)
4394 If ARG is a positive number, Gnus will use that as the
4395 startup level. If ARG is nil, Gnus will be started at level 2.
4396 If ARG is non-nil and not a positive number, Gnus will
4397 prompt the user for the name of an NNTP server to use.
4398 As opposed to `gnus', this command will not connect to the local server."
4400 (let ((val (or arg (1- gnus-level-default-subscribed))))
4402 (make-local-variable 'gnus-group-use-permanent-levels)
4403 (setq gnus-group-use-permanent-levels val)))
4406 (defun gnus-slave (&optional arg)
4407 "Read news as a slave."
4409 (gnus arg nil 'slave))
4412 (defun gnus-other-frame (&optional arg)
4413 "Pop up a frame to read news."
4415 (if (get-buffer gnus-group-buffer)
4416 (let ((pop-up-frames t))
4418 (select-frame (make-frame))
4422 (defun gnus (&optional arg dont-connect slave)
4424 If ARG is non-nil and a positive number, Gnus will use that as the
4425 startup level. If ARG is non-nil and not a positive number, Gnus will
4426 prompt the user for the name of an NNTP server to use."
4429 (if (get-buffer gnus-group-buffer)
4431 (switch-to-buffer gnus-group-buffer)
4432 (gnus-group-get-new-news))
4435 (nnheader-init-server-buffer)
4436 (gnus-read-init-file)
4437 (setq gnus-slave slave)
4439 (gnus-group-setup-buffer)
4440 (let ((buffer-read-only nil))
4442 (if (not gnus-inhibit-startup-message)
4444 (gnus-group-startup-message)
4447 (let ((level (and (numberp arg) (> arg 0) arg))
4453 (gnus-start-news-server (and arg (not level))))))
4454 (if (and (not dont-connect)
4457 (run-hooks 'gnus-startup-hook)
4458 ;; NNTP server is successfully open.
4460 ;; Find the current startup file name.
4461 (setq gnus-current-startup-file
4462 (gnus-make-newsrc-file gnus-startup-file))
4464 ;; Read the dribble file.
4465 (when (or gnus-slave gnus-use-dribble-file)
4466 (gnus-dribble-read-file))
4468 ;; Allow using GroupLens predictions.
4469 (when gnus-use-grouplens
4471 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4473 (gnus-summary-make-display-table)
4474 ;; Do the actual startup.
4475 (gnus-setup-news nil level dont-connect)
4476 ;; Generate the group buffer.
4477 (gnus-group-list-groups level)
4478 (gnus-group-first-unread-group)
4479 (gnus-configure-windows 'group)
4480 (gnus-group-set-mode-line))))))
4482 (defun gnus-unload ()
4483 "Unload all Gnus features."
4485 (or (boundp 'load-history)
4486 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4487 (let ((history load-history)
4490 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4491 (setq feature (cdr (assq 'provide (car history))))
4492 (unload-feature feature 'force))
4493 (setq history (cdr history)))))
4495 (defun gnus-compile ()
4496 "Byte-compile the user-defined format specs."
4498 (let ((entries gnus-format-specs)
4499 entry gnus-tmp-func)
4501 (gnus-message 7 "Compiling format specs...")
4504 (setq entry (pop entries))
4505 (if (eq (car entry) 'version)
4506 (setq gnus-format-specs (delq entry gnus-format-specs))
4507 (when (and (listp (caddr entry))
4508 (not (eq 'byte-code (caaddr entry))))
4509 (fset 'gnus-tmp-func
4510 `(lambda () ,(caddr entry)))
4511 (byte-compile 'gnus-tmp-func)
4512 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4514 (push (cons 'version emacs-version) gnus-format-specs)
4515 ;; Mark the .newsrc.eld file as "dirty".
4516 (gnus-dribble-enter " ")
4517 (gnus-message 7 "Compiling user specs...done"))))
4519 (defun gnus-indent-rigidly (start end arg)
4520 "Indent rigidly using only spaces and no tabs."
4523 (narrow-to-region start end)
4524 (indent-rigidly start end arg)
4525 (goto-char (point-min))
4526 (while (search-forward "\t" nil t)
4527 (replace-match " " t t)))))
4529 (defun gnus-group-startup-message (&optional x y)
4530 "Insert startup message in current buffer."
4531 ;; Insert the message.
4536 _ ___ __ ___ __ _ ___
4555 ;; And then hack it.
4556 (gnus-indent-rigidly (point-min) (point-max)
4557 (/ (max (- (window-width) (or x 46)) 0) 2))
4558 (goto-char (point-min))
4560 (let* ((pheight (count-lines (point-min) (point-max)))
4561 (wheight (window-height))
4562 (rest (- wheight pheight)))
4563 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4565 (goto-char (point-min))
4566 (and (search-forward "Praxis" nil t)
4567 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4568 (goto-char (point-min))
4569 (let* ((mode-string (gnus-group-set-mode-line)))
4570 (setq mode-line-buffer-identification
4571 (list (concat gnus-version (substring (car mode-string) 4))))
4572 (set-buffer-modified-p t)))
4574 (defun gnus-group-setup-buffer ()
4575 (or (get-buffer gnus-group-buffer)
4577 (switch-to-buffer gnus-group-buffer)
4578 (gnus-add-current-to-buffer-list)
4580 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4582 (defun gnus-group-list-groups (&optional level unread lowest)
4583 "List newsgroups with level LEVEL or lower that have unread articles.
4584 Default is all subscribed groups.
4585 If argument UNREAD is non-nil, groups with no unread articles are also
4587 (interactive (list (if current-prefix-arg
4588 (prefix-numeric-value current-prefix-arg)
4590 (gnus-group-default-level nil t)
4591 gnus-group-default-list-level
4592 gnus-level-subscribed))))
4594 (setq level (car gnus-group-list-mode)
4595 unread (cdr gnus-group-list-mode)))
4596 (setq level (gnus-group-default-level level))
4597 (gnus-group-setup-buffer) ;May call from out of group buffer
4598 (gnus-update-format-specifications)
4599 (let ((case-fold-search nil)
4600 (props (text-properties-at (gnus-point-at-bol)))
4601 (group (gnus-group-group-name)))
4602 (set-buffer gnus-group-buffer)
4603 (funcall gnus-group-prepare-function level unread lowest)
4604 (if (zerop (buffer-size))
4605 (gnus-message 5 gnus-no-groups-message)
4606 (goto-char (point-max))
4607 (when (or (not gnus-group-goto-next-group-function)
4608 (not (funcall gnus-group-goto-next-group-function
4611 ;; Go to the first group with unread articles.
4612 (gnus-group-search-forward t)
4613 ;; Find the right group to put point on. If the current group
4614 ;; has disappeared in the new listing, try to find the next
4615 ;; one. If no next one can be found, just leave point at the
4616 ;; first newsgroup in the buffer.
4617 (if (not (gnus-goto-char
4619 (point-min) (point-max)
4620 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4621 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4623 (not (gnus-goto-char
4625 (point-min) (point-max) 'gnus-group
4627 (caar newsrc) gnus-active-hashtb)))))
4628 (setq newsrc (cdr newsrc)))
4629 (or newsrc (progn (goto-char (point-max))
4630 (forward-line -1)))))))
4631 ;; Adjust cursor point.
4632 (gnus-group-position-point))))
4634 (defun gnus-group-list-level (level &optional all)
4635 "List groups on LEVEL.
4636 If ALL (the prefix), also list groups that have no unread articles."
4637 (interactive "nList groups on level: \nP")
4638 (gnus-group-list-groups level all level))
4640 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4641 "List all newsgroups with unread articles of level LEVEL or lower.
4642 If ALL is non-nil, list groups that have no unread articles.
4643 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4644 If REGEXP, only list groups matching REGEXP."
4645 (set-buffer gnus-group-buffer)
4646 (let ((buffer-read-only nil)
4647 (newsrc (cdr gnus-newsrc-alist))
4648 (lowest (or lowest 1))
4649 info clevel unread group params)
4651 (if (< lowest gnus-level-zombie)
4652 ;; List living groups.
4654 (setq info (car newsrc)
4655 group (gnus-info-group info)
4656 params (gnus-info-params info)
4658 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4659 (and unread ; This group might be bogus
4661 (string-match regexp group))
4662 (<= (setq clevel (gnus-info-level info)) level)
4664 (or all ; We list all groups?
4665 (if (eq unread t) ; Unactivated?
4666 gnus-group-list-inactive-groups ; We list unactivated
4667 (> unread 0)) ; We list groups with unread articles
4668 (and gnus-list-groups-with-ticked-articles
4669 (cdr (assq 'tick (gnus-info-marks info))))
4670 ; And groups with tickeds
4671 ;; Check for permanent visibility.
4672 (and gnus-permanently-visible-groups
4673 (string-match gnus-permanently-visible-groups
4675 (memq 'visible params)
4676 (cdr (assq 'visible params)))
4677 (gnus-group-insert-group-line
4678 group (gnus-info-level info)
4679 (gnus-info-marks info) unread (gnus-info-method info)))))
4681 ;; List dead groups.
4682 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4683 (gnus-group-prepare-flat-list-dead
4684 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4685 gnus-level-zombie ?Z
4687 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4688 (gnus-group-prepare-flat-list-dead
4689 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4690 gnus-level-killed ?K regexp))
4692 (gnus-group-set-mode-line)
4693 (setq gnus-group-list-mode (cons level all))
4694 (run-hooks 'gnus-group-prepare-hook)))
4696 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4697 ;; List zombies and killed lists somewhat faster, which was
4698 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4699 ;; this by ignoring the group format specification altogether.
4702 ;; This loop is used when listing groups that match some
4705 (setq group (pop groups))
4706 (when (string-match regexp group)
4707 (gnus-add-text-properties
4708 (point) (prog1 (1+ (point))
4709 (insert " " mark " *: " group "\n"))
4710 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4712 'gnus-level level))))
4713 ;; This loop is used when listing all groups.
4715 (gnus-add-text-properties
4716 (point) (prog1 (1+ (point))
4717 (insert " " mark " *: "
4718 (setq group (pop groups)) "\n"))
4719 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4721 'gnus-level level))))))
4723 (defmacro gnus-group-real-name (group)
4724 "Find the real name of a foreign newsgroup."
4725 `(let ((gname ,group))
4726 (if (string-match ":[^:]+$" gname)
4727 (substring gname (1+ (match-beginning 0)))
4730 (defsubst gnus-server-add-address (method)
4731 (let ((method-name (symbol-name (car method))))
4732 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4733 (not (assq (intern (concat method-name "-address")) method)))
4734 (append method (list (list (intern (concat method-name "-address"))
4738 (defsubst gnus-server-get-method (group method)
4739 ;; Input either a server name, and extended server name, or a
4740 ;; select method, and return a select method.
4741 (cond ((stringp method)
4742 (gnus-server-to-method method))
4743 ((equal method gnus-select-method)
4745 ((and (stringp (car method)) group)
4746 (gnus-server-extend-method group method))
4747 ((and method (not group)
4748 (equal (cadr method) ""))
4751 (gnus-server-add-address method))))
4753 (defun gnus-server-to-method (server)
4754 "Map virtual server names to select methods."
4756 ;; Is this a method, perhaps?
4757 (and server (listp server) server)
4758 ;; Perhaps this is the native server?
4759 (and (equal server "native") gnus-select-method)
4760 ;; It should be in the server alist.
4761 (cdr (assoc server gnus-server-alist))
4762 ;; If not, we look through all the opened server
4763 ;; to see whether we can find it there.
4764 (let ((opened gnus-opened-servers))
4766 (not (equal server (format "%s:%s" (caaar opened)
4771 (defmacro gnus-method-equal (ss1 ss2)
4772 "Say whether two servers are equal."
4776 (and (= (length s1) (length s2))
4778 (while (and s1 (member (car s1) s2))
4782 (defun gnus-server-equal (m1 m2)
4783 "Say whether two methods are equal."
4784 (let ((m1 (cond ((null m1) gnus-select-method)
4785 ((stringp m1) (gnus-server-to-method m1))
4787 (m2 (cond ((null m2) gnus-select-method)
4788 ((stringp m2) (gnus-server-to-method m2))
4790 (gnus-method-equal m1 m2)))
4792 (defun gnus-servers-using-backend (backend)
4793 "Return a list of known servers using BACKEND."
4794 (let ((opened gnus-opened-servers)
4797 (when (eq backend (caaar opened))
4798 (push (caar opened) out))
4802 (defun gnus-archive-server-wanted-p ()
4803 "Say whether the user wants to use the archive server."
4805 ((or (not gnus-message-archive-method)
4806 (not gnus-message-archive-group))
4808 ((and gnus-message-archive-method gnus-message-archive-group)
4811 (let ((active (cadr (assq 'nnfolder-active-file
4812 gnus-message-archive-method))))
4814 (file-exists-p active))))))
4816 (defun gnus-group-prefixed-name (group method)
4817 "Return the whole name from GROUP and METHOD."
4818 (and (stringp method) (setq method (gnus-server-to-method method)))
4819 (concat (format "%s" (car method))
4821 (or (assoc (format "%s" (car method))
4822 (gnus-methods-using 'address))
4823 (gnus-server-equal method gnus-message-archive-method))
4825 (not (string= (nth 1 method) "")))
4826 (concat "+" (nth 1 method)))
4829 (defun gnus-group-real-prefix (group)
4830 "Return the prefix of the current group name."
4831 (if (string-match "^[^:]+:" group)
4832 (substring group 0 (match-end 0))
4835 (defun gnus-group-method (group)
4836 "Return the server or method used for selecting GROUP."
4837 (let ((prefix (gnus-group-real-prefix group)))
4838 (if (equal prefix "")
4840 (let ((servers gnus-opened-servers)
4842 backend possible found)
4843 (if (string-match "^[^\\+]+\\+" prefix)
4844 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4845 server (substring prefix (match-end 0) (1- (length prefix))))
4846 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4848 (when (eq (caaar servers) backend)
4849 (setq possible (caar servers))
4850 (when (equal (cadaar servers) server)
4851 (setq found (caar servers))))
4853 (or (car (rassoc found gnus-server-alist))
4855 (car (rassoc possible gnus-server-alist))
4857 (list backend server))))))
4859 (defsubst gnus-secondary-method-p (method)
4860 "Return whether METHOD is a secondary select method."
4861 (let ((methods gnus-secondary-select-methods)
4862 (gmethod (gnus-server-get-method nil method)))
4864 (not (equal (gnus-server-get-method nil (car methods))
4866 (setq methods (cdr methods)))
4869 (defun gnus-group-foreign-p (group)
4870 "Say whether a group is foreign or not."
4871 (and (not (gnus-group-native-p group))
4872 (not (gnus-group-secondary-p group))))
4874 (defun gnus-group-native-p (group)
4875 "Say whether the group is native or not."
4876 (not (string-match ":" group)))
4878 (defun gnus-group-secondary-p (group)
4879 "Say whether the group is secondary or not."
4880 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4882 (defun gnus-group-get-parameter (group &optional symbol)
4883 "Returns the group parameters for GROUP.
4884 If SYMBOL, return the value of that symbol in the group parameters."
4885 (let ((params (gnus-info-params (gnus-get-info group))))
4887 (gnus-group-parameter-value params symbol)
4890 (defun gnus-group-parameter-value (params symbol)
4891 "Return the value of SYMBOL in group PARAMS."
4892 (or (car (memq symbol params)) ; It's either a simple symbol
4893 (cdr (assq symbol params)))) ; or a cons.
4895 (defun gnus-group-add-parameter (group param)
4896 "Add parameter PARAM to GROUP."
4897 (let ((info (gnus-get-info group)))
4899 () ; This is a dead group. We just ignore it.
4900 ;; Cons the new param to the old one and update.
4901 (gnus-group-set-info (cons param (gnus-info-params info))
4904 (defun gnus-group-set-parameter (group name value)
4905 "Set parameter NAME to VALUE in GROUP."
4906 (let ((info (gnus-get-info group)))
4908 () ; This is a dead group. We just ignore it.
4909 (let ((old-params (gnus-info-params info))
4910 (new-params (list (cons name value))))
4912 (if (or (not (listp (car old-params)))
4913 (not (eq (caar old-params) name)))
4914 (setq new-params (append new-params (list (car old-params)))))
4915 (setq old-params (cdr old-params)))
4916 (gnus-group-set-info new-params group 'params)))))
4918 (defun gnus-group-add-score (group &optional score)
4919 "Add SCORE to the GROUP score.
4920 If SCORE is nil, add 1 to the score of GROUP."
4921 (let ((info (gnus-get-info group)))
4923 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4925 (defun gnus-summary-bubble-group ()
4926 "Increase the score of the current group.
4927 This is a handy function to add to `gnus-summary-exit-hook' to
4928 increase the score of each group you read."
4929 (gnus-group-add-score gnus-newsgroup-name))
4931 (defun gnus-group-set-info (info &optional method-only-group part)
4932 (let* ((entry (gnus-gethash
4933 (or method-only-group (gnus-info-group info))
4934 gnus-newsrc-hashtb))
4936 (info (if method-only-group (nth 2 entry) info))
4938 (when method-only-group
4940 (error "Trying to change non-existent group %s" method-only-group))
4941 ;; We have received parts of the actual group info - either the
4942 ;; select method or the group parameters. We first check
4943 ;; whether we have to extend the info, and if so, do that.
4944 (let ((len (length info))
4945 (total (if (eq part 'method) 5 6)))
4947 (setcdr (nthcdr (1- len) info)
4948 (make-list (- total len) nil)))
4949 ;; Then we enter the new info.
4950 (setcar (nthcdr (1- total) info) part-info)))
4952 ;; This is a new group, so we just create it.
4954 (set-buffer gnus-group-buffer)
4955 (setq method (gnus-info-method info))
4956 (when (gnus-server-equal method "native")
4959 (set-buffer gnus-group-buffer)
4961 ;; It's a foreign group...
4962 (gnus-group-make-group
4963 (gnus-group-real-name (gnus-info-group info))
4964 (if (stringp method) method
4965 (prin1-to-string (car method)))
4967 (nth 1 (gnus-info-method info))))
4968 ;; It's a native group.
4969 (gnus-group-make-group (gnus-info-group info))))
4970 (gnus-message 6 "Note: New group created")
4972 (gnus-gethash (gnus-group-prefixed-name
4973 (gnus-group-real-name (gnus-info-group info))
4974 (or (gnus-info-method info) gnus-select-method))
4975 gnus-newsrc-hashtb))))
4976 ;; Whether it was a new group or not, we now have the entry, so we
4977 ;; can do the update.
4980 (setcar (nthcdr 2 entry) info)
4981 (when (and (not (eq (car entry) t))
4982 (gnus-active (gnus-info-group info)))
4983 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4984 (error "No such group: %s" (gnus-info-group info)))))
4986 (defun gnus-group-set-method-info (group select-method)
4987 (gnus-group-set-info select-method group 'method))
4989 (defun gnus-group-set-params-info (group params)
4990 (gnus-group-set-info params group 'params))
4992 (defun gnus-group-update-group-line ()
4993 "Update the current line in the group buffer."
4994 (let* ((buffer-read-only nil)
4995 (group (gnus-group-group-name))
4996 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4997 gnus-group-indentation)
5000 (not (gnus-ephemeral-group-p group))
5002 (concat "(gnus-group-set-info '"
5003 (prin1-to-string (nth 2 entry)) ")")))
5004 (setq gnus-group-indentation (gnus-group-group-indentation))
5006 (gnus-group-insert-group-line-info group)
5008 (gnus-group-position-point))))
5010 (defun gnus-group-insert-group-line-info (group)
5011 "Insert GROUP on the current line."
5012 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
5016 ;; (Un)subscribed group.
5017 (setq info (nth 2 entry))
5018 (gnus-group-insert-group-line
5019 group (gnus-info-level info) (gnus-info-marks info)
5020 (or (car entry) t) (gnus-info-method info)))
5021 ;; This group is dead.
5022 (gnus-group-insert-group-line
5024 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
5026 (if (setq active (gnus-active group))
5027 (- (1+ (cdr active)) (car active)) 0)
5030 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
5031 gnus-tmp-marked number
5033 "Insert a group line in the group buffer."
5034 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
5035 (gnus-tmp-number-total
5037 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
5039 (gnus-tmp-number-of-unread
5040 (if (numberp number) (int-to-string (max 0 number))
5042 (gnus-tmp-number-of-read
5043 (if (numberp number)
5044 (int-to-string (max 0 (- gnus-tmp-number-total number)))
5046 (gnus-tmp-subscribed
5047 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
5048 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
5049 ((= gnus-tmp-level gnus-level-zombie) ?Z)
5051 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
5052 (gnus-tmp-newsgroup-description
5053 (if gnus-description-hashtb
5054 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
5057 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
5058 (gnus-tmp-moderated-string
5059 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
5061 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
5062 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
5063 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
5064 (gnus-tmp-news-method-string
5066 (format "(%s:%s)" (car gnus-tmp-method)
5067 (cadr gnus-tmp-method)) ""))
5068 (gnus-tmp-marked-mark
5069 (if (and (numberp number)
5071 (cdr (assq 'tick gnus-tmp-marked)))
5073 (gnus-tmp-process-marked
5074 (if (member gnus-tmp-group gnus-group-marked)
5075 gnus-process-mark ? ))
5077 (or (and gnus-use-grouplens
5078 (bbb-grouplens-group-p gnus-tmp-group))
5080 (buffer-read-only nil)
5081 header gnus-tmp-header) ; passed as parameter to user-funcs.
5083 (gnus-add-text-properties
5087 (eval gnus-group-line-format-spec))
5088 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5089 gnus-unread ,(if (numberp number)
5090 (string-to-int gnus-tmp-number-of-unread)
5092 gnus-marked ,gnus-tmp-marked-mark
5093 gnus-indentation ,gnus-group-indentation
5094 gnus-level ,gnus-tmp-level))
5095 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5097 (run-hooks 'gnus-group-update-hook)
5099 ;; Allow XEmacs to remove front-sticky text properties.
5100 (gnus-group-remove-excess-properties)))
5102 (defun gnus-group-update-group (group &optional visible-only)
5103 "Update all lines where GROUP appear.
5104 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5107 (set-buffer gnus-group-buffer)
5108 ;; The buffer may be narrowed.
5111 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5113 found buffer-read-only)
5114 ;; Enter the current status into the dribble buffer.
5115 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5116 (if (and entry (not (gnus-ephemeral-group-p group)))
5118 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5120 ;; Find all group instances. If topics are in use, each group
5121 ;; may be listed in more than once.
5122 (while (setq loc (text-property-any
5123 loc (point-max) 'gnus-group ident))
5126 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5128 (gnus-group-insert-group-line-info group)
5131 (run-hooks 'gnus-group-update-group-hook)))
5132 (setq loc (1+ loc)))
5133 (unless (or found visible-only)
5134 ;; No such line in the buffer, find out where it's supposed to
5135 ;; go, and insert it there (or at the end of the buffer).
5136 (if gnus-goto-missing-group-function
5137 (funcall gnus-goto-missing-group-function group)
5138 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5139 (while (and entry (car entry)
5143 (point-min) (point-max)
5144 'gnus-group (gnus-intern-safe
5145 (caar entry) gnus-active-hashtb)))))
5146 (setq entry (cdr entry)))
5147 (or entry (goto-char (point-max)))))
5148 ;; Finally insert the line.
5149 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5150 (gnus-group-insert-group-line-info group)
5153 (run-hooks 'gnus-group-update-group-hook))))
5154 (gnus-group-set-mode-line)))))
5156 (defun gnus-group-set-mode-line ()
5157 "Update the mode line in the group buffer."
5158 (when (memq 'group gnus-updated-mode-lines)
5159 ;; Yes, we want to keep this mode line updated.
5161 (set-buffer gnus-group-buffer)
5162 (let* ((gformat (or gnus-group-mode-line-format-spec
5163 (setq gnus-group-mode-line-format-spec
5165 gnus-group-mode-line-format
5166 gnus-group-mode-line-format-alist))))
5167 (gnus-tmp-news-server (cadr gnus-select-method))
5168 (gnus-tmp-news-method (car gnus-select-method))
5169 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5171 gnus-tmp-header ;Dummy binding for user-defined formats
5172 ;; Get the resulting string.
5174 (and gnus-dribble-buffer
5175 (buffer-name gnus-dribble-buffer)
5176 (buffer-modified-p gnus-dribble-buffer)
5178 (set-buffer gnus-dribble-buffer)
5179 (not (zerop (buffer-size))))))
5180 (mode-string (eval gformat)))
5181 ;; Say whether the dribble buffer has been modified.
5182 (setq mode-line-modified
5183 (if modified "---*- " "----- "))
5184 ;; If the line is too long, we chop it off.
5185 (when (> (length mode-string) max-len)
5186 (setq mode-string (substring mode-string 0 (- max-len 4))))
5188 (setq mode-line-buffer-identification
5189 (gnus-mode-line-buffer-identification
5190 (list mode-string)))
5191 (set-buffer-modified-p modified))))))
5193 (defun gnus-group-group-name ()
5194 "Get the name of the newsgroup on the current line."
5195 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5196 (and group (symbol-name group))))
5198 (defun gnus-group-group-level ()
5199 "Get the level of the newsgroup on the current line."
5200 (get-text-property (gnus-point-at-bol) 'gnus-level))
5202 (defun gnus-group-group-indentation ()
5203 "Get the indentation of the newsgroup on the current line."
5204 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5205 (and gnus-group-indentation-function
5206 (funcall gnus-group-indentation-function))
5209 (defun gnus-group-group-unread ()
5210 "Get the number of unread articles of the newsgroup on the current line."
5211 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5213 (defun gnus-group-search-forward (&optional backward all level first-too)
5214 "Find the next newsgroup with unread articles.
5215 If BACKWARD is non-nil, find the previous newsgroup instead.
5216 If ALL is non-nil, just find any newsgroup.
5217 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5219 If FIRST-TOO, the current line is also eligible as a target."
5220 (let ((way (if backward -1 1))
5221 (low gnus-level-killed)
5224 (if (and backward (progn (beginning-of-line)) (bobp))
5226 (or first-too (forward-line way))
5234 (get-text-property (point) 'gnus-unread)))
5235 (and (numberp unread) (> unread 0)))
5236 (setq lev (get-text-property (point)
5238 (<= lev gnus-level-subscribed)))
5240 (and (setq lev (get-text-property (point)
5249 (zerop (forward-line way)))))
5251 (progn (gnus-group-position-point) t)
5252 (goto-char (or pos beg))
5255 ;;; Gnus group mode commands
5259 (defun gnus-group-mark-group (n &optional unmark no-advance)
5260 "Mark the current group."
5262 (let ((buffer-read-only nil)
5266 (when (setq group (gnus-group-group-name))
5270 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5275 (setq gnus-group-marked (delete group gnus-group-marked)))
5277 (setq gnus-group-marked
5278 (cons group (delete group gnus-group-marked)))))
5279 (or no-advance (gnus-group-next-group 1))
5281 (gnus-summary-position-point)
5284 (defun gnus-group-unmark-group (n)
5285 "Remove the mark from the current group."
5287 (gnus-group-mark-group n 'unmark)
5288 (gnus-group-position-point))
5290 (defun gnus-group-unmark-all-groups ()
5291 "Unmark all groups."
5293 (let ((groups gnus-group-marked))
5296 (gnus-group-remove-mark (pop groups)))))
5297 (gnus-group-position-point))
5299 (defun gnus-group-mark-region (unmark beg end)
5300 "Mark all groups between point and mark.
5301 If UNMARK, remove the mark instead."
5302 (interactive "P\nr")
5303 (let ((num (count-lines beg end)))
5306 (- num (gnus-group-mark-group num unmark)))))
5308 (defun gnus-group-mark-buffer (&optional unmark)
5309 "Mark all groups in the buffer.
5310 If UNMARK, remove the mark instead."
5312 (gnus-group-mark-region unmark (point-min) (point-max)))
5314 (defun gnus-group-mark-regexp (regexp)
5315 "Mark all groups that match some regexp."
5316 (interactive "sMark (regexp): ")
5317 (let ((alist (cdr gnus-newsrc-alist))
5320 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5321 (gnus-group-set-mark group))))
5322 (gnus-group-position-point))
5324 (defun gnus-group-remove-mark (group)
5325 "Remove the process mark from GROUP and move point there.
5326 Return nil if the group isn't displayed."
5327 (if (gnus-group-goto-group group)
5329 (gnus-group-mark-group 1 'unmark t)
5331 (setq gnus-group-marked
5332 (delete group gnus-group-marked))
5335 (defun gnus-group-set-mark (group)
5336 "Set the process mark on GROUP."
5337 (if (gnus-group-goto-group group)
5339 (gnus-group-mark-group 1 nil t))
5340 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5342 (defun gnus-group-universal-argument (arg &optional groups func)
5343 "Perform any command on all groups accoring to the process/prefix convention."
5345 (let ((groups (or groups (gnus-group-process-prefix arg)))
5347 (if (eq (setq func (or func
5350 (substitute-command-keys
5351 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5353 (gnus-error 1 "Undefined key")
5355 (gnus-group-remove-mark (setq group (pop groups)))
5356 (command-execute func))))
5357 (gnus-group-position-point))
5359 (defun gnus-group-process-prefix (n)
5360 "Return a list of groups to work on.
5361 Take into consideration N (the prefix) and the list of marked groups."
5364 (setq n (prefix-numeric-value n))
5365 ;; There is a prefix, so we return a list of the N next
5367 (let ((way (if (< n 0) -1 1))
5372 (setq group (gnus-group-group-name)))
5373 (setq groups (cons group groups))
5375 (gnus-group-next-group way)))
5377 ((and (boundp 'transient-mark-mode)
5379 (boundp 'mark-active)
5381 ;; Work on the region between point and mark.
5382 (let ((max (max (point) (mark)))
5385 (goto-char (min (point) (mark)))
5388 (push (gnus-group-group-name) groups)
5389 (zerop (gnus-group-next-group 1))
5391 (nreverse groups))))
5393 ;; No prefix, but a list of marked articles.
5394 (reverse gnus-group-marked))
5396 ;; Neither marked articles or a prefix, so we return the
5398 (let ((group (gnus-group-group-name)))
5399 (and group (list group))))))
5401 ;; Selecting groups.
5403 (defun gnus-group-read-group (&optional all no-article group)
5404 "Read news in this newsgroup.
5405 If the prefix argument ALL is non-nil, already read articles become
5406 readable. IF ALL is a number, fetch this number of articles. If the
5407 optional argument NO-ARTICLE is non-nil, no article will be
5408 auto-selected upon group entry. If GROUP is non-nil, fetch that
5411 (let ((group (or group (gnus-group-group-name)))
5412 number active marked entry)
5413 (or group (error "No group on current line"))
5414 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5415 group gnus-newsrc-hashtb)))))
5416 ;; This group might be a dead group. In that case we have to get
5417 ;; the number of unread articles from `gnus-active-hashtb'.
5419 (cond ((numberp all) all)
5421 ((setq active (gnus-active group))
5422 (- (1+ (cdr active)) (car active)))))
5423 (gnus-summary-read-group
5424 group (or all (and (numberp number)
5425 (zerop (+ number (length (cdr (assq 'tick marked)))
5426 (length (cdr (assq 'dormant marked)))))))
5429 (defun gnus-group-select-group (&optional all)
5430 "Select this newsgroup.
5431 No article is selected automatically.
5432 If ALL is non-nil, already read articles become readable.
5433 If ALL is a number, fetch this number of articles."
5435 (gnus-group-read-group all t))
5437 (defun gnus-group-quick-select-group (&optional all)
5438 "Select the current group \"quickly\".
5439 This means that no highlighting or scoring will be performed."
5442 gnus-score-find-score-files-function
5443 gnus-apply-kill-hook
5444 gnus-summary-expunge-below)
5445 (gnus-group-read-group all t)))
5447 (defun gnus-group-visible-select-group (&optional all)
5448 "Select the current group without hiding any articles."
5450 (let ((gnus-inhibit-limiting t))
5451 (gnus-group-read-group all t)))
5454 (defun gnus-fetch-group (group)
5455 "Start Gnus if necessary and enter GROUP.
5456 Returns whether the fetching was successful or not."
5457 (interactive "sGroup name: ")
5458 (or (get-buffer gnus-group-buffer)
5460 (gnus-group-read-group nil nil group))
5462 ;; Enter a group that is not in the group buffer. Non-nil is returned
5463 ;; if selection was successful.
5464 (defun gnus-group-read-ephemeral-group
5465 (group method &optional activate quit-config)
5466 (let ((group (if (gnus-group-foreign-p group) group
5467 (gnus-group-prefixed-name group method))))
5470 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5471 ((quit-config . ,(if quit-config quit-config
5472 (cons (current-buffer) 'summary))))))
5474 (set-buffer gnus-group-buffer)
5475 (or (gnus-check-server method)
5476 (error "Unable to contact server: %s" (gnus-status-message method)))
5477 (if activate (or (gnus-request-group group)
5478 (error "Couldn't request group")))
5480 (gnus-group-read-group t t group)
5484 (defun gnus-group-jump-to-group (group)
5485 "Jump to newsgroup GROUP."
5487 (list (completing-read
5488 "Group: " gnus-active-hashtb nil
5489 (gnus-read-active-file-p)
5491 'gnus-group-history)))
5493 (when (equal group "")
5494 (error "Empty group name"))
5496 (when (string-match "[\000-\032]" group)
5497 (error "Control characters in group: %s" group))
5499 (let ((b (text-property-any
5500 (point-min) (point-max)
5501 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5502 (unless (gnus-ephemeral-group-p group)
5504 ;; Either go to the line in the group buffer...
5506 ;; ... or insert the line.
5509 (gnus-activate-group group)
5510 (error "%s error: %s" group (gnus-status-message group)))
5512 (gnus-group-update-group group)
5513 (goto-char (text-property-any
5514 (point-min) (point-max)
5515 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5516 ;; Adjust cursor point.
5517 (gnus-group-position-point)))
5519 (defun gnus-group-goto-group (group)
5520 "Goto to newsgroup GROUP."
5522 (let ((b (text-property-any (point-min) (point-max)
5523 'gnus-group (gnus-intern-safe
5524 group gnus-active-hashtb))))
5525 (and b (goto-char b)))))
5527 (defun gnus-group-next-group (n &optional silent)
5528 "Go to next N'th newsgroup.
5529 If N is negative, search backward instead.
5530 Returns the difference between N and the number of skips actually
5533 (gnus-group-next-unread-group n t nil silent))
5535 (defun gnus-group-next-unread-group (n &optional all level silent)
5536 "Go to next N'th unread newsgroup.
5537 If N is negative, search backward instead.
5538 If ALL is non-nil, choose any newsgroup, unread or not.
5539 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5540 such group can be found, the next group with a level higher than
5542 Returns the difference between N and the number of skips actually
5545 (let ((backward (< n 0))
5548 (gnus-group-search-forward
5549 backward (or (not gnus-group-goto-unread) all) level))
5553 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5554 (if level " on this level or higher" "")))
5557 (defun gnus-group-prev-group (n)
5558 "Go to previous N'th newsgroup.
5559 Returns the difference between N and the number of skips actually
5562 (gnus-group-next-unread-group (- n) t))
5564 (defun gnus-group-prev-unread-group (n)
5565 "Go to previous N'th unread newsgroup.
5566 Returns the difference between N and the number of skips actually
5569 (gnus-group-next-unread-group (- n)))
5571 (defun gnus-group-next-unread-group-same-level (n)
5572 "Go to next N'th unread newsgroup on the same level.
5573 If N is negative, search backward instead.
5574 Returns the difference between N and the number of skips actually
5577 (gnus-group-next-unread-group n t (gnus-group-group-level))
5578 (gnus-group-position-point))
5580 (defun gnus-group-prev-unread-group-same-level (n)
5581 "Go to next N'th unread newsgroup on the same level.
5582 Returns the difference between N and the number of skips actually
5585 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5586 (gnus-group-position-point))
5588 (defun gnus-group-best-unread-group (&optional exclude-group)
5589 "Go to the group with the highest level.
5590 If EXCLUDE-GROUP, do not go to that group."
5592 (goto-char (point-min))
5596 (setq unread (get-text-property (point) 'gnus-unread))
5597 (if (and (numberp unread) (> unread 0))
5599 (if (and (get-text-property (point) 'gnus-level)
5600 (< (get-text-property (point) 'gnus-level) best)
5601 (or (not exclude-group)
5602 (not (equal exclude-group (gnus-group-group-name)))))
5604 (setq best (get-text-property (point) 'gnus-level))
5605 (setq best-point (point))))))
5607 (if best-point (goto-char best-point))
5608 (gnus-summary-position-point)
5609 (and best-point (gnus-group-group-name))))
5611 (defun gnus-group-first-unread-group ()
5612 "Go to the first group with unread articles."
5615 (let ((opoint (point))
5617 (goto-char (point-min))
5618 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5619 (and (numberp unread) ; Not a topic.
5620 (not (zerop unread))) ; Has unread articles.
5621 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5624 nil)) ; Not success.
5625 (gnus-group-position-point)))
5627 (defun gnus-group-enter-server-mode ()
5628 "Jump to the server buffer."
5630 (gnus-enter-server-buffer))
5632 (defun gnus-group-make-group (name &optional method address)
5633 "Add a new newsgroup.
5634 The user will be prompted for a NAME, for a select METHOD, and an
5638 (read-string "Group name: ")
5641 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5642 nil t nil 'gnus-method-history)))
5643 (cond ((assoc method gnus-valid-select-methods)
5645 (if (memq 'prompt-address
5646 (assoc method gnus-valid-select-methods))
5647 (read-string "Address: ")
5649 ((assoc method gnus-server-alist)
5652 (list method ""))))))
5654 (let* ((meth (and method (if address (list (intern method) address)
5656 (nname (if method (gnus-group-prefixed-name name meth) name))
5658 (when (gnus-gethash nname gnus-newsrc-hashtb)
5659 (error "Group %s already exists" nname))
5660 ;; Subscribe to the new group.
5661 (gnus-group-change-level
5662 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5663 gnus-level-default-subscribed gnus-level-killed
5664 (and (gnus-group-group-name)
5665 (gnus-gethash (gnus-group-group-name)
5666 gnus-newsrc-hashtb))
5669 (gnus-set-active nname (cons 1 0))
5670 (or (gnus-ephemeral-group-p name)
5672 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5674 (gnus-group-insert-group-line-info nname)
5676 (gnus-group-position-point)
5678 ;; Load the backend and try to make the backend create
5679 ;; the group as well.
5680 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5682 gnus-valid-select-methods)
5684 (gnus-check-server meth)
5685 (and (gnus-check-backend-function 'request-create-group nname)
5686 (gnus-request-create-group nname))
5689 (defun gnus-group-delete-group (group &optional force)
5690 "Delete the current group. Only meaningful with mail groups.
5691 If FORCE (the prefix) is non-nil, all the articles in the group will
5692 be deleted. This is \"deleted\" as in \"removed forever from the face
5693 of the Earth\". There is no undo. The user will be prompted before
5694 doing the deletion."
5696 (list (gnus-group-group-name)
5697 current-prefix-arg))
5698 (or group (error "No group to rename"))
5699 (or (gnus-check-backend-function 'request-delete-group group)
5700 (error "This backend does not support group deletion"))
5702 (if (not (gnus-yes-or-no-p
5704 "Do you really want to delete %s%s? "
5705 group (if force " and all its contents" ""))))
5707 (gnus-message 6 "Deleting group %s..." group)
5708 (if (not (gnus-request-delete-group group force))
5709 (gnus-error 3 "Couldn't delete group %s" group)
5710 (gnus-message 6 "Deleting group %s...done" group)
5711 (gnus-group-goto-group group)
5712 (gnus-group-kill-group 1 t)
5713 (gnus-sethash group nil gnus-active-hashtb)
5715 (gnus-group-position-point)))
5717 (defun gnus-group-rename-group (group new-name)
5720 (gnus-group-group-name)
5722 (or (gnus-check-backend-function
5723 'request-rename-group (gnus-group-group-name))
5724 (error "This backend does not support renaming groups"))
5725 (read-string "New group name: "))))
5727 (or (gnus-check-backend-function 'request-rename-group group)
5728 (error "This backend does not support renaming groups"))
5730 (or group (error "No group to rename"))
5731 (and (string-match "^[ \t]*$" new-name)
5732 (error "Not a valid group name"))
5734 ;; We find the proper prefixed name.
5736 (gnus-group-prefixed-name
5737 (gnus-group-real-name new-name)
5738 (gnus-info-method (gnus-get-info group))))
5740 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5742 (if (not (gnus-request-rename-group group new-name))
5743 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5744 ;; We rename the group internally by killing it...
5745 (gnus-group-goto-group group)
5746 (gnus-group-kill-group)
5747 ;; ... changing its name ...
5748 (setcar (cdar gnus-list-of-killed-groups) new-name)
5749 ;; ... and then yanking it. Magic!
5750 (gnus-group-yank-group)
5751 (gnus-set-active new-name (gnus-active group))
5752 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5754 (gnus-group-position-point)))
5756 (defun gnus-group-edit-group (group &optional part)
5757 "Edit the group on the current line."
5758 (interactive (list (gnus-group-group-name)))
5759 (let* ((part (or part 'info))
5760 (done-func `(lambda ()
5761 "Exit editing mode and update the information."
5763 (gnus-group-edit-group-done ',part ,group)))
5764 (winconf (current-window-configuration))
5766 (or group (error "No group on current line"))
5767 (or (setq info (gnus-get-info group))
5768 (error "Killed group; can't be edited"))
5769 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5770 (gnus-configure-windows 'edit-group)
5771 (gnus-add-current-to-buffer-list)
5773 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5774 (use-local-map (copy-keymap emacs-lisp-mode-map))
5775 (local-set-key "\C-c\C-c" done-func)
5776 (make-local-variable 'gnus-prev-winconf)
5777 (setq gnus-prev-winconf winconf)
5782 ";; Type `C-c C-c' after editing the select method.\n\n")
5784 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5786 ";; Type `C-c C-c' after editing the group info.\n\n")))
5789 (cond ((eq part 'method)
5790 (or (gnus-info-method info) "native"))
5792 (gnus-info-params info))
5796 (defun gnus-group-edit-group-method (group)
5797 "Edit the select method of GROUP."
5798 (interactive (list (gnus-group-group-name)))
5799 (gnus-group-edit-group group 'method))
5801 (defun gnus-group-edit-group-parameters (group)
5802 "Edit the group parameters of GROUP."
5803 (interactive (list (gnus-group-group-name)))
5804 (gnus-group-edit-group group 'params))
5806 (defun gnus-group-edit-group-done (part group)
5807 "Get info from buffer, update variables and jump to the group buffer."
5808 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5809 (goto-char (point-min))
5810 (let* ((form (read (current-buffer)))
5811 (winconf gnus-prev-winconf)
5812 (method (cond ((eq part 'info) (nth 4 form))
5813 ((eq part 'method) form)
5815 (info (cond ((eq part 'info) form)
5816 ((eq part 'method) (gnus-get-info group))
5819 (if (or (not method)
5821 gnus-select-method method))
5822 (gnus-group-real-name (car info))
5823 (gnus-group-prefixed-name
5824 (gnus-group-real-name (car info)) method))
5826 (when (and new-group
5827 (not (equal new-group group)))
5828 (when (gnus-group-goto-group group)
5829 (gnus-group-kill-group 1))
5830 (gnus-activate-group new-group))
5832 (if (and info new-group)
5834 (setq info (gnus-copy-sequence info))
5835 (setcar info new-group)
5836 (unless (gnus-server-equal method "native")
5837 (unless (nthcdr 3 info)
5838 (nconc info (list nil nil)))
5839 (unless (nthcdr 4 info)
5840 (nconc info (list nil)))
5841 (gnus-info-set-method info method))
5842 (gnus-group-set-info info))
5843 (gnus-group-set-info form (or new-group group) part))
5844 (kill-buffer (current-buffer))
5845 (and winconf (set-window-configuration winconf))
5846 (set-buffer gnus-group-buffer)
5847 (gnus-group-update-group (or new-group group))
5848 (gnus-group-position-point)))
5850 (defun gnus-group-make-help-group ()
5851 "Create the Gnus documentation group."
5853 (let ((path load-path)
5854 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5856 (and (gnus-gethash name gnus-newsrc-hashtb)
5857 (error "Documentation group already exists"))
5859 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5861 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5863 (setq file (concat (file-name-directory
5864 (directory-file-name dir))
5865 "etc/gnus-tut.txt"))))
5868 (gnus-message 1 "Couldn't find doc group")
5869 (gnus-group-make-group
5870 (gnus-group-real-name name)
5871 (list 'nndoc "gnus-help"
5872 (list 'nndoc-address file)
5873 (list 'nndoc-article-type 'mbox)))))
5874 (gnus-group-position-point))
5876 (defun gnus-group-make-doc-group (file type)
5877 "Create a group that uses a single file as the source."
5879 (list (read-file-name "File name: ")
5880 (and current-prefix-arg 'ask)))
5881 (when (eq type 'ask)
5886 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5888 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5889 ((= char ?b) 'babyl)
5890 ((= char ?d) 'digest)
5891 ((= char ?f) 'forward)
5893 (t (setq err (format "%c unknown. " char))
5896 (let* ((file (expand-file-name file))
5897 (name (gnus-generate-new-group-name
5898 (gnus-group-prefixed-name
5899 (file-name-nondirectory file) '(nndoc "")))))
5900 (gnus-group-make-group
5901 (gnus-group-real-name name)
5902 (list 'nndoc (file-name-nondirectory file)
5903 (list 'nndoc-address file)
5904 (list 'nndoc-article-type (or type 'guess))))))
5906 (defun gnus-group-make-archive-group (&optional all)
5907 "Create the (ding) Gnus archive group of the most recent articles.
5908 Given a prefix, create a full group."
5910 (let ((group (gnus-group-prefixed-name
5911 (if all "ding.archives" "ding.recent") '(nndir ""))))
5912 (and (gnus-gethash group gnus-newsrc-hashtb)
5913 (error "Archive group already exists"))
5914 (gnus-group-make-group
5915 (gnus-group-real-name group)
5916 (list 'nndir (if all "hpc" "edu")
5917 (list 'nndir-directory
5918 (if all gnus-group-archive-directory
5919 gnus-group-recent-archive-directory))))))
5921 (defun gnus-group-make-directory-group (dir)
5922 "Create an nndir group.
5923 The user will be prompted for a directory. The contents of this
5924 directory will be used as a newsgroup. The directory should contain
5925 mail messages or news articles in files that have numeric names."
5927 (list (read-file-name "Create group from directory: ")))
5928 (or (file-exists-p dir) (error "No such directory"))
5929 (or (file-directory-p dir) (error "Not a directory"))
5933 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5935 (gnus-group-prefixed-name
5936 (concat (file-name-as-directory (directory-file-name dir))
5939 (setq ext (format "<%d>" (setq i (1+ i)))))
5940 (gnus-group-make-group
5941 (gnus-group-real-name group)
5942 (list 'nndir group (list 'nndir-directory dir)))))
5944 (defun gnus-group-make-kiboze-group (group address scores)
5945 "Create an nnkiboze group.
5946 The user will be prompted for a name, a regexp to match groups, and
5947 score file entries for articles to include in the group."
5950 (read-string "nnkiboze group name: ")
5951 (read-string "Source groups (regexp): ")
5952 (let ((headers (mapcar (lambda (group) (list group))
5953 '("subject" "from" "number" "date" "message-id"
5954 "references" "chars" "lines" "xref"
5955 "followup" "all" "body" "head")))
5956 scores header regexp regexps)
5957 (while (not (equal "" (setq header (completing-read
5958 "Match on header: " headers nil t))))
5960 (while (not (equal "" (setq regexp (read-string
5961 (format "Match on %s (string): "
5963 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5964 (setq scores (cons (cons header regexps) scores)))
5966 (gnus-group-make-group group "nnkiboze" address)
5967 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5968 (let (emacs-lisp-mode-hook)
5969 (pp scores (current-buffer)))))
5971 (defun gnus-group-add-to-virtual (n vgroup)
5972 "Add the current group to a virtual group."
5974 (list current-prefix-arg
5975 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5977 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5978 (error "%s is not an nnvirtual group" vgroup))
5979 (let* ((groups (gnus-group-process-prefix n))
5980 (method (gnus-info-method (gnus-get-info vgroup))))
5981 (setcar (cdr method)
5983 (nth 1 method) "\\|"
5986 (gnus-group-remove-mark s)
5987 (concat "\\(^" (regexp-quote s) "$\\)"))
5989 (gnus-group-position-point))
5991 (defun gnus-group-make-empty-virtual (group)
5992 "Create a new, fresh, empty virtual group."
5993 (interactive "sCreate new, empty virtual group: ")
5994 (let* ((method (list 'nnvirtual "^$"))
5995 (pgroup (gnus-group-prefixed-name group method)))
5996 ;; Check whether it exists already.
5997 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5998 (error "Group %s already exists." pgroup))
5999 ;; Subscribe the new group after the group on the current line.
6000 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
6001 (gnus-group-update-group pgroup)
6003 (gnus-group-position-point)))
6005 (defun gnus-group-enter-directory (dir)
6006 "Enter an ephemeral nneething group."
6007 (interactive "DDirectory to read: ")
6008 (let* ((method (list 'nneething dir))
6009 (leaf (gnus-group-prefixed-name
6010 (file-name-nondirectory (directory-file-name dir))
6012 (name (gnus-generate-new-group-name leaf)))
6013 (let ((nneething-read-only t))
6014 (or (gnus-group-read-ephemeral-group
6016 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
6018 (error "Couldn't enter %s" dir)))))
6020 ;; Group sorting commands
6021 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
6023 (defun gnus-group-sort-groups (func &optional reverse)
6024 "Sort the group buffer according to FUNC.
6025 If REVERSE, reverse the sorting order."
6026 (interactive (list gnus-group-sort-function
6027 current-prefix-arg))
6029 ((not (listp func)) func)
6031 ((= 1 (length func)) (car func))
6033 ,(gnus-make-sort-function
6034 (reverse func)))))))
6035 ;; We peel off the dummy group from the alist.
6037 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
6038 (pop gnus-newsrc-alist))
6040 (setq gnus-newsrc-alist
6041 (sort gnus-newsrc-alist func))
6043 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
6044 ;; Regenerate the hash table.
6045 (gnus-make-hashtable-from-newsrc-alist)
6046 (gnus-group-list-groups))))
6048 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
6049 "Sort the group buffer alphabetically by group name.
6050 If REVERSE, sort in reverse order."
6052 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
6054 (defun gnus-group-sort-groups-by-unread (&optional reverse)
6055 "Sort the group buffer by number of unread articles.
6056 If REVERSE, sort in reverse order."
6058 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
6060 (defun gnus-group-sort-groups-by-level (&optional reverse)
6061 "Sort the group buffer by group level.
6062 If REVERSE, sort in reverse order."
6064 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
6066 (defun gnus-group-sort-groups-by-score (&optional reverse)
6067 "Sort the group buffer by group score.
6068 If REVERSE, sort in reverse order."
6070 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
6072 (defun gnus-group-sort-groups-by-rank (&optional reverse)
6073 "Sort the group buffer by group rank.
6074 If REVERSE, sort in reverse order."
6076 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6078 (defun gnus-group-sort-groups-by-method (&optional reverse)
6079 "Sort the group buffer alphabetically by backend name.
6080 If REVERSE, sort in reverse order."
6082 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6084 (defun gnus-group-sort-by-alphabet (info1 info2)
6085 "Sort alphabetically."
6086 (string< (gnus-info-group info1) (gnus-info-group info2)))
6088 (defun gnus-group-sort-by-unread (info1 info2)
6089 "Sort by number of unread articles."
6090 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6091 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6092 (< (or (and (numberp n1) n1) 0)
6093 (or (and (numberp n2) n2) 0))))
6095 (defun gnus-group-sort-by-level (info1 info2)
6097 (< (gnus-info-level info1) (gnus-info-level info2)))
6099 (defun gnus-group-sort-by-method (info1 info2)
6100 "Sort alphabetically by backend name."
6101 (string< (symbol-name (car (gnus-find-method-for-group
6102 (gnus-info-group info1) info1)))
6103 (symbol-name (car (gnus-find-method-for-group
6104 (gnus-info-group info2) info2)))))
6106 (defun gnus-group-sort-by-score (info1 info2)
6107 "Sort by group score."
6108 (< (gnus-info-score info1) (gnus-info-score info2)))
6110 (defun gnus-group-sort-by-rank (info1 info2)
6111 "Sort by level and score."
6112 (let ((level1 (gnus-info-level info1))
6113 (level2 (gnus-info-level info2)))
6114 (or (< level1 level2)
6115 (and (= level1 level2)
6116 (> (gnus-info-score info1) (gnus-info-score info2))))))
6118 ;; Group catching up.
6120 (defun gnus-group-clear-data (n)
6121 "Clear all marks and read ranges from the current group."
6123 (let ((groups (gnus-group-process-prefix n))
6125 (while (setq group (pop groups))
6126 (setq info (gnus-get-info group))
6127 (gnus-info-set-read info nil)
6128 (when (gnus-info-marks info)
6129 (gnus-info-set-marks info nil))
6130 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6131 (when (gnus-group-goto-group group)
6132 (gnus-group-remove-mark group)
6133 (gnus-group-update-group-line)))))
6135 (defun gnus-group-catchup-current (&optional n all)
6136 "Mark all articles not marked as unread in current newsgroup as read.
6137 If prefix argument N is numeric, the ARG next newsgroups will be
6138 caught up. If ALL is non-nil, marked articles will also be marked as
6139 read. Cross references (Xref: header) of articles are ignored.
6140 The difference between N and actual number of newsgroups that were
6141 caught up is returned."
6143 (unless (gnus-group-group-name)
6144 (error "No group on the current line"))
6145 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6149 "Do you really want to mark all articles as read? "
6150 "Mark all unread articles as read? "))))
6152 (let ((groups (gnus-group-process-prefix n))
6155 ;; Virtual groups have to be given special treatment.
6156 (let ((method (gnus-find-method-for-group (car groups))))
6157 (if (eq 'nnvirtual (car method))
6158 (nnvirtual-catchup-group
6159 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6160 (gnus-group-remove-mark (car groups))
6161 (if (>= (gnus-group-group-level) gnus-level-zombie)
6162 (gnus-message 2 "Dead groups can't be caught up")
6164 (gnus-group-goto-group (car groups))
6165 (gnus-group-catchup (car groups) all))
6166 (gnus-group-update-group-line)
6167 (setq ret (1+ ret))))
6168 (setq groups (cdr groups)))
6169 (gnus-group-next-unread-group 1)
6172 (defun gnus-group-catchup-current-all (&optional n)
6173 "Mark all articles in current newsgroup as read.
6174 Cross references (Xref: header) of articles are ignored."
6176 (gnus-group-catchup-current n 'all))
6178 (defun gnus-group-catchup (group &optional all)
6179 "Mark all articles in GROUP as read.
6180 If ALL is non-nil, all articles are marked as read.
6181 The return value is the number of articles that were marked as read,
6182 or nil if no action could be taken."
6183 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6185 ;; Do the updating only if the newsgroup isn't killed.
6186 (if (not (numberp (car entry)))
6187 (gnus-message 1 "Can't catch up; non-active group")
6188 ;; Do auto-expirable marks if that's required.
6189 (when (gnus-group-auto-expirable-p group)
6190 (gnus-add-marked-articles
6191 group 'expire (gnus-list-of-unread-articles group))
6193 (let ((marks (nth 3 (nth 2 entry))))
6194 (gnus-add-marked-articles
6195 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6196 (gnus-add-marked-articles
6197 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6199 (gnus-update-read-articles group nil)
6200 ;; Also nix out the lists of marks and dormants.
6202 (gnus-add-marked-articles group 'tick nil nil 'force)
6203 (gnus-add-marked-articles group 'dormant nil nil 'force))
6204 (run-hooks 'gnus-group-catchup-group-hook)
6207 (defun gnus-group-expire-articles (&optional n)
6208 "Expire all expirable articles in the current newsgroup."
6210 (let ((groups (gnus-group-process-prefix n))
6213 (error "No groups to expire"))
6214 (while (setq group (pop groups))
6215 (gnus-group-remove-mark group)
6216 (when (gnus-check-backend-function 'request-expire-articles group)
6217 (gnus-message 6 "Expiring articles in %s..." group)
6218 (let* ((info (gnus-get-info group))
6219 (expirable (if (gnus-group-total-expirable-p group)
6220 (cons nil (gnus-list-of-read-articles group))
6221 (assq 'expire (gnus-info-marks info))))
6222 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6226 (gnus-compress-sequence
6228 ;; We set the expiry variables to the groupp
6230 (let ((nnmail-expiry-wait-function nil)
6231 (nnmail-expiry-wait expiry-wait))
6232 (gnus-request-expire-articles
6233 (gnus-uncompress-sequence (cdr expirable)) group))
6234 ;; Just expire using the normal expiry values.
6235 (gnus-request-expire-articles
6236 (gnus-uncompress-sequence (cdr expirable)) group))))
6237 (gnus-close-group group))
6238 (gnus-message 6 "Expiring articles in %s...done" group)))
6239 (gnus-group-position-point))))
6241 (defun gnus-group-expire-all-groups ()
6242 "Expire all expirable articles in all newsgroups."
6245 (gnus-message 5 "Expiring...")
6246 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6247 (cdr gnus-newsrc-alist))))
6248 (gnus-group-expire-articles nil)))
6249 (gnus-group-position-point)
6250 (gnus-message 5 "Expiring...done"))
6252 (defun gnus-group-set-current-level (n level)
6253 "Set the level of the next N groups to LEVEL."
6258 (let ((s (read-string
6259 (format "Level (default %s): "
6260 (or (gnus-group-group-level)
6261 gnus-level-default-subscribed)))))
6262 (if (string-match "^\\s-*$" s)
6263 (int-to-string (or (gnus-group-group-level)
6264 gnus-level-default-subscribed))
6266 (or (and (>= level 1) (<= level gnus-level-killed))
6267 (error "Illegal level: %d" level))
6268 (let ((groups (gnus-group-process-prefix n))
6270 (while (setq group (pop groups))
6271 (gnus-group-remove-mark group)
6272 (gnus-message 6 "Changed level of %s from %d to %d"
6273 group (or (gnus-group-group-level) gnus-level-killed)
6275 (gnus-group-change-level
6276 group level (or (gnus-group-group-level) gnus-level-killed))
6277 (gnus-group-update-group-line)))
6278 (gnus-group-position-point))
6280 (defun gnus-group-unsubscribe-current-group (&optional n)
6281 "Toggle subscription of the current group.
6282 If given numerical prefix, toggle the N next groups."
6284 (let ((groups (gnus-group-process-prefix n))
6287 (setq group (car groups)
6288 groups (cdr groups))
6289 (gnus-group-remove-mark group)
6290 (gnus-group-unsubscribe-group
6291 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6292 gnus-level-default-unsubscribed
6293 gnus-level-default-subscribed) t)
6294 (gnus-group-update-group-line))
6295 (gnus-group-next-group 1)))
6297 (defun gnus-group-unsubscribe-group (group &optional level silent)
6298 "Toggle subscription to GROUP.
6299 Killed newsgroups are subscribed. If SILENT, don't try to update the
6302 (list (completing-read
6303 "Group: " gnus-active-hashtb nil
6304 (gnus-read-active-file-p)
6306 'gnus-group-history)))
6307 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6309 ((string-match "^[ \t]$" group)
6310 (error "Empty group name"))
6312 ;; Toggle subscription flag.
6313 (gnus-group-change-level
6314 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6315 gnus-level-subscribed)
6316 (1+ gnus-level-subscribed)
6317 gnus-level-default-subscribed)))
6319 (gnus-group-update-group group)))
6320 ((and (stringp group)
6321 (or (not (gnus-read-active-file-p))
6322 (gnus-active group)))
6323 ;; Add new newsgroup.
6324 (gnus-group-change-level
6326 (if level level gnus-level-default-subscribed)
6327 (or (and (member group gnus-zombie-list)
6330 (and (gnus-group-group-name)
6331 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6333 (gnus-group-update-group group)))
6334 (t (error "No such newsgroup: %s" group)))
6335 (gnus-group-position-point)))
6337 (defun gnus-group-transpose-groups (n)
6338 "Move the current newsgroup up N places.
6339 If given a negative prefix, move down instead. The difference between
6340 N and the number of steps taken is returned."
6342 (or (gnus-group-group-name)
6343 (error "No group on current line"))
6344 (gnus-group-kill-group 1)
6346 (forward-line (- n))
6347 (gnus-group-yank-group)
6348 (gnus-group-position-point)))
6350 (defun gnus-group-kill-all-zombies ()
6351 "Kill all zombie newsgroups."
6353 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6354 (setq gnus-zombie-list nil)
6355 (gnus-group-list-groups))
6357 (defun gnus-group-kill-region (begin end)
6358 "Kill newsgroups in current region (excluding current point).
6359 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6374 (beginning-of-line) ;Important when LINES < 1
6375 (gnus-group-kill-group lines)))
6377 (defun gnus-group-kill-group (&optional n discard)
6378 "Kill the next N groups.
6379 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6380 However, only groups that were alive can be yanked; already killed
6381 groups or zombie groups can't be yanked.
6382 The return value is the name of the group that was killed, or a list
6385 (let ((buffer-read-only nil)
6386 (groups (gnus-group-process-prefix n))
6387 group entry level out)
6388 (if (< (length groups) 10)
6389 ;; This is faster when there are few groups.
6391 (push (setq group (pop groups)) out)
6392 (gnus-group-remove-mark group)
6393 (setq level (gnus-group-group-level))
6395 (when (and (not discard)
6396 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6397 (push (cons (car entry) (nth 2 entry))
6398 gnus-list-of-killed-groups))
6399 (gnus-group-change-level
6400 (if entry entry group) gnus-level-killed (if entry nil level)))
6401 ;; If there are lots and lots of groups to be killed, we use
6402 ;; this thing instead.
6404 (setq groups (nreverse groups))
6406 (gnus-group-remove-mark (setq group (pop groups)))
6408 (push group gnus-killed-list)
6409 (setq gnus-newsrc-alist
6410 (delq (assoc group gnus-newsrc-alist)
6412 (when gnus-group-change-level-function
6413 (funcall gnus-group-change-level-function group 9 3))
6415 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6416 (push (cons (car entry) (nth 2 entry))
6417 gnus-list-of-killed-groups)
6418 (setcdr (cdr entry) (cdddr entry)))
6419 ((member group gnus-zombie-list)
6420 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6421 (gnus-make-hashtable-from-newsrc-alist)))
6423 (gnus-group-position-point)
6424 (if (< (length out) 2) (car out) (nreverse out))))
6426 (defun gnus-group-yank-group (&optional arg)
6427 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6428 inserting it before the current newsgroup. The numeric ARG specifies
6429 how many newsgroups are to be yanked. The name of the newsgroup yanked
6430 is returned, or (if several groups are yanked) a list of yanked groups
6433 (setq arg (or arg 1))
6434 (let (info group prev out)
6435 (while (>= (decf arg) 0)
6436 (if (not (setq info (pop gnus-list-of-killed-groups)))
6437 (error "No more newsgroups to yank"))
6438 (push (setq group (nth 1 info)) out)
6439 ;; Find which newsgroup to insert this one before - search
6440 ;; backward until something suitable is found. If there are no
6441 ;; other newsgroups in this buffer, just make this newsgroup the
6443 (setq prev (gnus-group-group-name))
6444 (gnus-group-change-level
6445 info (gnus-info-level (cdr info)) gnus-level-killed
6446 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6448 (gnus-group-insert-group-line-info group))
6450 (gnus-group-position-point)
6451 (if (< (length out) 2) (car out) (nreverse out))))
6453 (defun gnus-group-kill-level (level)
6454 "Kill all groups that is on a certain LEVEL."
6455 (interactive "nKill all groups on level: ")
6457 ((= level gnus-level-zombie)
6458 (setq gnus-killed-list
6459 (nconc gnus-zombie-list gnus-killed-list))
6460 (setq gnus-zombie-list nil))
6461 ((and (< level gnus-level-zombie)
6463 (or gnus-expert-user
6466 "Do you really want to kill all groups on level %d? "
6468 (let* ((prev gnus-newsrc-alist)
6471 (if (= (gnus-info-level (car alist)) level)
6473 (push (gnus-info-group (car alist)) gnus-killed-list)
6474 (setcdr prev (cdr alist)))
6476 (setq alist (cdr alist)))
6477 (gnus-make-hashtable-from-newsrc-alist)
6478 (gnus-group-list-groups)))
6480 (error "Can't kill; illegal level: %d" level))))
6482 (defun gnus-group-list-all-groups (&optional arg)
6483 "List all newsgroups with level ARG or lower.
6484 Default is gnus-level-unsubscribed, which lists all subscribed and most
6485 unsubscribed groups."
6487 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6489 ;; Redefine this to list ALL killed groups if prefix arg used.
6490 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6491 (defun gnus-group-list-killed (&optional arg)
6492 "List all killed newsgroups in the group buffer.
6493 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6494 entail asking the server for the groups."
6496 ;; Find all possible killed newsgroups if arg.
6498 (gnus-get-killed-groups))
6499 (if (not gnus-killed-list)
6500 (gnus-message 6 "No killed groups")
6501 (let (gnus-group-list-mode)
6502 (funcall gnus-group-prepare-function
6503 gnus-level-killed t gnus-level-killed))
6504 (goto-char (point-min)))
6505 (gnus-group-position-point))
6507 (defun gnus-group-list-zombies ()
6508 "List all zombie newsgroups in the group buffer."
6510 (if (not gnus-zombie-list)
6511 (gnus-message 6 "No zombie groups")
6512 (let (gnus-group-list-mode)
6513 (funcall gnus-group-prepare-function
6514 gnus-level-zombie t gnus-level-zombie))
6515 (goto-char (point-min)))
6516 (gnus-group-position-point))
6518 (defun gnus-group-list-active ()
6519 "List all groups that are available from the server(s)."
6521 ;; First we make sure that we have really read the active file.
6522 (unless (gnus-read-active-file-p)
6523 (let ((gnus-read-active-file t))
6524 (gnus-read-active-file)))
6525 ;; Find all groups and sort them.
6533 (setq list (cons (symbol-name sym) list))))
6537 (buffer-read-only nil))
6540 (gnus-group-insert-group-line-info (pop groups)))
6541 (goto-char (point-min))))
6543 (defun gnus-activate-all-groups (level)
6544 "Activate absolutely all groups."
6545 (interactive (list 7))
6546 (let ((gnus-activate-level level)
6547 (gnus-activate-foreign-newsgroups level))
6548 (gnus-group-get-new-news)))
6550 (defun gnus-group-get-new-news (&optional arg)
6551 "Get newly arrived articles.
6552 If ARG is a number, it specifies which levels you are interested in
6553 re-scanning. If ARG is non-nil and not a number, this will force
6554 \"hard\" re-reading of the active files from all servers."
6556 (run-hooks 'gnus-get-new-news-hook)
6557 ;; We might read in new NoCeM messages here.
6558 (when (and gnus-use-nocem
6560 (gnus-nocem-scan-groups))
6561 ;; If ARG is not a number, then we read the active file.
6562 (when (and arg (not (numberp arg)))
6563 (let ((gnus-read-active-file t))
6564 (gnus-read-active-file))
6567 (setq arg (gnus-group-default-level arg t))
6568 (if (and gnus-read-active-file (not arg))
6570 (gnus-read-active-file)
6571 (gnus-get-unread-articles arg))
6572 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6573 (gnus-get-unread-articles arg)))
6574 (run-hooks 'gnus-after-getting-new-news-hook)
6575 (gnus-group-list-groups))
6577 (defun gnus-group-get-new-news-this-group (&optional n)
6578 "Check for newly arrived news in the current group (and the N-1 next groups).
6579 The difference between N and the number of newsgroup checked is returned.
6580 If N is negative, this group and the N-1 previous groups will be checked."
6582 (let* ((groups (gnus-group-process-prefix n))
6583 (ret (if (numberp n) (- n (length groups)) 0))
6584 (beg (unless n (point)))
6586 (while (setq group (pop groups))
6587 (gnus-group-remove-mark group)
6588 (if (gnus-activate-group group 'scan)
6590 (gnus-get-unread-articles-in-group
6591 (gnus-get-info group) (gnus-active group) t)
6592 (unless (gnus-virtual-group-p group)
6593 (gnus-close-group group))
6594 (gnus-group-update-group group))
6595 (if (eq (gnus-server-status (gnus-find-method-for-group group))
6597 (gnus-error "Server denied access")
6598 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
6599 (when beg (goto-char beg))
6600 (when gnus-goto-next-group-when-activating
6601 (gnus-group-next-unread-group 1 t))
6602 (gnus-summary-position-point)
6605 (defun gnus-group-fetch-faq (group &optional faq-dir)
6606 "Fetch the FAQ for the current group."
6609 (and (gnus-group-group-name)
6610 (gnus-group-real-name (gnus-group-group-name)))
6611 (cond (current-prefix-arg
6613 "Faq dir: " (and (listp gnus-group-faq-directory)
6614 (mapcar (lambda (file) (list file))
6615 gnus-group-faq-directory)))))))
6617 (setq faq-dir (if (listp gnus-group-faq-directory)
6618 (car gnus-group-faq-directory)
6619 gnus-group-faq-directory)))
6620 (or group (error "No group name given"))
6621 (let ((file (concat (file-name-as-directory faq-dir)
6622 (gnus-group-real-name group))))
6623 (if (not (file-exists-p file))
6624 (error "No such file: %s" file)
6627 (defun gnus-group-describe-group (force &optional group)
6628 "Display a description of the current newsgroup."
6629 (interactive (list current-prefix-arg (gnus-group-group-name)))
6630 (let* ((method (gnus-find-method-for-group group))
6631 (mname (gnus-group-prefixed-name "" method))
6634 gnus-description-hashtb)
6635 (gnus-sethash mname nil gnus-description-hashtb))
6636 (or group (error "No group name given"))
6637 (and (or (and gnus-description-hashtb
6638 ;; We check whether this group's method has been
6639 ;; queried for a description file.
6640 (gnus-gethash mname gnus-description-hashtb))
6641 (setq desc (gnus-group-get-description group))
6642 (gnus-read-descriptions-file method))
6644 (or desc (gnus-gethash group gnus-description-hashtb)
6645 "No description available")))))
6647 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6648 (defun gnus-group-describe-all-groups (&optional force)
6649 "Pop up a buffer with descriptions of all newsgroups."
6651 (and force (setq gnus-description-hashtb nil))
6652 (if (not (or gnus-description-hashtb
6653 (gnus-read-all-descriptions-files)))
6654 (error "Couldn't request descriptions file"))
6655 (let ((buffer-read-only nil)
6661 (insert (format " *: %-20s %s\n" (symbol-name group)
6662 (symbol-value group)))
6663 (gnus-add-text-properties
6664 b (1+ b) (list 'gnus-group group
6665 'gnus-unread t 'gnus-marked nil
6666 'gnus-level (1+ gnus-level-subscribed))))
6667 gnus-description-hashtb)
6668 (goto-char (point-min))
6669 (gnus-group-position-point)))
6671 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6672 (defun gnus-group-apropos (regexp &optional search-description)
6673 "List all newsgroups that have names that match a regexp."
6674 (interactive "sGnus apropos (regexp): ")
6676 (obuf (current-buffer))
6678 ;; Go through all newsgroups that are known to Gnus.
6681 (and (symbol-name group)
6682 (string-match regexp (symbol-name group))
6683 (setq groups (cons (symbol-name group) groups))))
6685 ;; Also go through all descriptions that are known to Gnus.
6686 (when search-description
6689 (and (string-match regexp (symbol-value group))
6690 (gnus-active (symbol-name group))
6691 (setq groups (cons (symbol-name group) groups))))
6692 gnus-description-hashtb))
6694 (gnus-message 3 "No groups matched \"%s\"." regexp)
6695 ;; Print out all the groups.
6697 (pop-to-buffer "*Gnus Help*")
6698 (buffer-disable-undo (current-buffer))
6700 (setq groups (sort groups 'string<))
6702 ;; Groups may be entered twice into the list of groups.
6703 (if (not (string= (car groups) prev))
6705 (insert (setq prev (car groups)) "\n")
6706 (if (and gnus-description-hashtb
6707 (setq des (gnus-gethash (car groups)
6708 gnus-description-hashtb)))
6709 (insert " " des "\n"))))
6710 (setq groups (cdr groups)))
6711 (goto-char (point-min))))
6712 (pop-to-buffer obuf)))
6714 (defun gnus-group-description-apropos (regexp)
6715 "List all newsgroups that have names or descriptions that match a regexp."
6716 (interactive "sGnus description apropos (regexp): ")
6717 (if (not (or gnus-description-hashtb
6718 (gnus-read-all-descriptions-files)))
6719 (error "Couldn't request descriptions file"))
6720 (gnus-group-apropos regexp t))
6722 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6723 (defun gnus-group-list-matching (level regexp &optional all lowest)
6724 "List all groups with unread articles that match REGEXP.
6725 If the prefix LEVEL is non-nil, it should be a number that says which
6726 level to cut off listing groups.
6727 If ALL, also list groups with no unread articles.
6728 If LOWEST, don't list groups with level lower than LOWEST.
6730 This command may read the active file."
6731 (interactive "P\nsList newsgroups matching: ")
6732 ;; First make sure active file has been read.
6734 (> (prefix-numeric-value level) gnus-level-killed))
6735 (gnus-get-killed-groups))
6736 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6737 all (or lowest 1) regexp)
6738 (goto-char (point-min))
6739 (gnus-group-position-point))
6741 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6742 "List all groups that match REGEXP.
6743 If the prefix LEVEL is non-nil, it should be a number that says which
6744 level to cut off listing groups.
6745 If LOWEST, don't list groups with level lower than LOWEST."
6746 (interactive "P\nsList newsgroups matching: ")
6747 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6749 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6750 (defun gnus-group-save-newsrc (&optional force)
6751 "Save the Gnus startup files.
6752 If FORCE, force saving whether it is necessary or not."
6754 (gnus-save-newsrc-file force))
6756 (defun gnus-group-restart (&optional arg)
6757 "Force Gnus to read the .newsrc file."
6759 (when (gnus-yes-or-no-p
6760 (format "Are you sure you want to read %s? "
6761 gnus-current-startup-file))
6762 (gnus-save-newsrc-file)
6763 (gnus-setup-news 'force)
6764 (gnus-group-list-groups arg)))
6766 (defun gnus-group-read-init-file ()
6767 "Read the Gnus elisp init file."
6769 (gnus-read-init-file))
6771 (defun gnus-group-check-bogus-groups (&optional silent)
6772 "Check bogus newsgroups.
6773 If given a prefix, don't ask for confirmation before removing a bogus
6776 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6777 (gnus-group-list-groups))
6779 (defun gnus-group-edit-global-kill (&optional article group)
6780 "Edit the global kill file.
6781 If GROUP, edit that local kill file instead."
6783 (setq gnus-current-kill-article article)
6784 (gnus-kill-file-edit-file group)
6787 (substitute-command-keys
6788 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6789 (if group "local" "global")))))
6791 (defun gnus-group-edit-local-kill (article group)
6792 "Edit a local kill file."
6793 (interactive (list nil (gnus-group-group-name)))
6794 (gnus-group-edit-global-kill article group))
6796 (defun gnus-group-force-update ()
6797 "Update `.newsrc' file."
6799 (gnus-save-newsrc-file))
6801 (defun gnus-group-suspend ()
6802 "Suspend the current Gnus session.
6803 In fact, cleanup buffers except for group mode buffer.
6804 The hook gnus-suspend-gnus-hook is called before actually suspending."
6806 (run-hooks 'gnus-suspend-gnus-hook)
6807 ;; Kill Gnus buffers except for group mode buffer.
6808 (let* ((group-buf (get-buffer gnus-group-buffer))
6809 ;; Do this on a separate list in case the user does a ^G before we finish
6811 (delete group-buf (delete gnus-dribble-buffer
6812 (append gnus-buffer-list nil)))))
6813 (while gnus-buffer-list
6814 (gnus-kill-buffer (pop gnus-buffer-list)))
6815 (gnus-kill-gnus-frames)
6817 (setq gnus-buffer-list (list group-buf))
6818 (bury-buffer group-buf)
6819 (delete-windows-on group-buf t))))
6821 (defun gnus-group-clear-dribble ()
6822 "Clear all information from the dribble buffer."
6824 (gnus-dribble-clear)
6825 (gnus-message 7 "Cleared dribble buffer"))
6827 (defun gnus-group-exit ()
6828 "Quit reading news after updating .newsrc.eld and .newsrc.
6829 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6832 (or noninteractive ;For gnus-batch-kill
6833 (not gnus-interactive-exit) ;Without confirmation
6835 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6836 (run-hooks 'gnus-exit-gnus-hook)
6837 ;; Offer to save data from non-quitted summary buffers.
6838 (gnus-offer-save-summaries)
6839 ;; Save the newsrc file(s).
6840 (gnus-save-newsrc-file)
6842 (gnus-close-backends)
6843 ;; Reset everything.
6845 ;; Allow the user to do things after cleaning up.
6846 (run-hooks 'gnus-after-exiting-gnus-hook)))
6848 (defun gnus-close-backends ()
6849 ;; Send a close request to all backends that support such a request.
6850 (let ((methods gnus-valid-select-methods)
6853 (if (fboundp (setq func (intern (concat (caar methods)
6854 "-request-close"))))
6856 (setq methods (cdr methods)))))
6858 (defun gnus-group-quit ()
6859 "Quit reading news without updating .newsrc.eld or .newsrc.
6860 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6862 (when (or noninteractive ;For gnus-batch-kill
6863 (zerop (buffer-size))
6864 (not (gnus-server-opened gnus-select-method))
6866 (not gnus-current-startup-file)
6868 (format "Quit reading news without saving %s? "
6869 (file-name-nondirectory gnus-current-startup-file))))
6870 (run-hooks 'gnus-exit-gnus-hook)
6871 (if gnus-use-full-window
6872 (delete-other-windows)
6873 (gnus-remove-some-windows))
6875 (gnus-close-backends)
6877 ;; Allow the user to do things after cleaning up.
6878 (run-hooks 'gnus-after-exiting-gnus-hook)))
6880 (defun gnus-offer-save-summaries ()
6881 "Offer to save all active summary buffers."
6883 (let ((buflist (buffer-list))
6885 ;; Go through all buffers and find all summaries.
6887 (and (setq bufname (buffer-name (car buflist)))
6888 (string-match "Summary" bufname)
6890 (set-buffer bufname)
6891 ;; We check that this is, indeed, a summary buffer.
6892 (and (eq major-mode 'gnus-summary-mode)
6893 ;; Also make sure this isn't bogus.
6894 gnus-newsgroup-prepared))
6895 (push bufname buffers))
6896 (setq buflist (cdr buflist)))
6897 ;; Go through all these summary buffers and offer to save them.
6900 "Update summary buffer %s? "
6901 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6904 (defun gnus-group-describe-briefly ()
6905 "Give a one line description of the group mode commands."
6907 (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")))
6909 (defun gnus-group-browse-foreign-server (method)
6910 "Browse a foreign news server.
6911 If called interactively, this function will ask for a select method
6912 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6913 If not, METHOD should be a list where the first element is the method
6914 and the second element is the address."
6916 (list (let ((how (completing-read
6918 (append gnus-valid-select-methods gnus-server-alist)
6919 nil t (cons "nntp" 0) 'gnus-method-history)))
6920 ;; We either got a backend name or a virtual server name.
6921 ;; If the first, we also need an address.
6922 (if (assoc how gnus-valid-select-methods)
6924 ;; Suggested by mapjph@bath.ac.uk.
6927 (mapcar (lambda (server) (list server))
6928 gnus-secondary-servers)))
6929 ;; We got a server name, so we find the method.
6930 (gnus-server-to-method how)))))
6931 (gnus-browse-foreign-server method))
6935 ;;; Gnus summary mode
6938 (defvar gnus-summary-mode-map nil)
6940 (put 'gnus-summary-mode 'mode-class 'special)
6942 (unless gnus-summary-mode-map
6943 (setq gnus-summary-mode-map (make-keymap))
6944 (suppress-keymap gnus-summary-mode-map)
6946 ;; Non-orthogonal keys
6948 (gnus-define-keys gnus-summary-mode-map
6949 " " gnus-summary-next-page
6950 "\177" gnus-summary-prev-page
6951 [delete] gnus-summary-prev-page
6952 "\r" gnus-summary-scroll-up
6953 "n" gnus-summary-next-unread-article
6954 "p" gnus-summary-prev-unread-article
6955 "N" gnus-summary-next-article
6956 "P" gnus-summary-prev-article
6957 "\M-\C-n" gnus-summary-next-same-subject
6958 "\M-\C-p" gnus-summary-prev-same-subject
6959 "\M-n" gnus-summary-next-unread-subject
6960 "\M-p" gnus-summary-prev-unread-subject
6961 "." gnus-summary-first-unread-article
6962 "," gnus-summary-best-unread-article
6963 "\M-s" gnus-summary-search-article-forward
6964 "\M-r" gnus-summary-search-article-backward
6965 "<" gnus-summary-beginning-of-article
6966 ">" gnus-summary-end-of-article
6967 "j" gnus-summary-goto-article
6968 "^" gnus-summary-refer-parent-article
6969 "\M-^" gnus-summary-refer-article
6970 "u" gnus-summary-tick-article-forward
6971 "!" gnus-summary-tick-article-forward
6972 "U" gnus-summary-tick-article-backward
6973 "d" gnus-summary-mark-as-read-forward
6974 "D" gnus-summary-mark-as-read-backward
6975 "E" gnus-summary-mark-as-expirable
6976 "\M-u" gnus-summary-clear-mark-forward
6977 "\M-U" gnus-summary-clear-mark-backward
6978 "k" gnus-summary-kill-same-subject-and-select
6979 "\C-k" gnus-summary-kill-same-subject
6980 "\M-\C-k" gnus-summary-kill-thread
6981 "\M-\C-l" gnus-summary-lower-thread
6982 "e" gnus-summary-edit-article
6983 "#" gnus-summary-mark-as-processable
6984 "\M-#" gnus-summary-unmark-as-processable
6985 "\M-\C-t" gnus-summary-toggle-threads
6986 "\M-\C-s" gnus-summary-show-thread
6987 "\M-\C-h" gnus-summary-hide-thread
6988 "\M-\C-f" gnus-summary-next-thread
6989 "\M-\C-b" gnus-summary-prev-thread
6990 "\M-\C-u" gnus-summary-up-thread
6991 "\M-\C-d" gnus-summary-down-thread
6992 "&" gnus-summary-execute-command
6993 "c" gnus-summary-catchup-and-exit
6994 "\C-w" gnus-summary-mark-region-as-read
6995 "\C-t" gnus-summary-toggle-truncation
6996 "?" gnus-summary-mark-as-dormant
6997 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6998 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6999 "\C-c\C-s\C-a" gnus-summary-sort-by-author
7000 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
7001 "\C-c\C-s\C-d" gnus-summary-sort-by-date
7002 "\C-c\C-s\C-i" gnus-summary-sort-by-score
7003 "=" gnus-summary-expand-window
7004 "\C-x\C-s" gnus-summary-reselect-current-group
7005 "\M-g" gnus-summary-rescan-group
7006 "w" gnus-summary-stop-page-breaking
7007 "\C-c\C-r" gnus-summary-caesar-message
7008 "\M-t" gnus-summary-toggle-mime
7009 "f" gnus-summary-followup
7010 "F" gnus-summary-followup-with-original
7011 "C" gnus-summary-cancel-article
7012 "r" gnus-summary-reply
7013 "R" gnus-summary-reply-with-original
7014 "\C-c\C-f" gnus-summary-mail-forward
7015 "o" gnus-summary-save-article
7016 "\C-o" gnus-summary-save-article-mail
7017 "|" gnus-summary-pipe-output
7018 "\M-k" gnus-summary-edit-local-kill
7019 "\M-K" gnus-summary-edit-global-kill
7021 "\C-c\C-d" gnus-summary-describe-group
7022 "q" gnus-summary-exit
7023 "Q" gnus-summary-exit-no-update
7024 "\C-c\C-i" gnus-info-find-node
7025 gnus-mouse-2 gnus-mouse-pick-article
7026 "m" gnus-summary-mail-other-window
7027 "a" gnus-summary-post-news
7028 "x" gnus-summary-limit-to-unread
7029 "s" gnus-summary-isearch-article
7030 "t" gnus-article-hide-headers
7031 "g" gnus-summary-show-article
7032 "l" gnus-summary-goto-last-article
7033 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
7034 "\C-d" gnus-summary-enter-digest-group
7036 "*" gnus-cache-enter-article
7037 "\M-*" gnus-cache-remove-article
7038 "\M-&" gnus-summary-universal-argument
7039 "\C-l" gnus-recenter
7040 "I" gnus-summary-increase-score
7041 "L" gnus-summary-lower-score
7043 "V" gnus-summary-score-map
7044 "X" gnus-uu-extract-map
7045 "S" gnus-summary-send-map)
7047 ;; Sort of orthogonal keymap
7048 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
7049 "t" gnus-summary-tick-article-forward
7050 "!" gnus-summary-tick-article-forward
7051 "d" gnus-summary-mark-as-read-forward
7052 "r" gnus-summary-mark-as-read-forward
7053 "c" gnus-summary-clear-mark-forward
7054 " " gnus-summary-clear-mark-forward
7055 "e" gnus-summary-mark-as-expirable
7056 "x" gnus-summary-mark-as-expirable
7057 "?" gnus-summary-mark-as-dormant
7058 "b" gnus-summary-set-bookmark
7059 "B" gnus-summary-remove-bookmark
7060 "#" gnus-summary-mark-as-processable
7061 "\M-#" gnus-summary-unmark-as-processable
7062 "S" gnus-summary-limit-include-expunged
7063 "C" gnus-summary-catchup
7064 "H" gnus-summary-catchup-to-here
7065 "\C-c" gnus-summary-catchup-all
7066 "k" gnus-summary-kill-same-subject-and-select
7067 "K" gnus-summary-kill-same-subject
7068 "P" gnus-uu-mark-map)
7070 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7071 "c" gnus-summary-clear-above
7072 "u" gnus-summary-tick-above
7073 "m" gnus-summary-mark-above
7074 "k" gnus-summary-kill-below)
7076 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7077 "/" gnus-summary-limit-to-subject
7078 "n" gnus-summary-limit-to-articles
7079 "w" gnus-summary-pop-limit
7080 "s" gnus-summary-limit-to-subject
7081 "a" gnus-summary-limit-to-author
7082 "u" gnus-summary-limit-to-unread
7083 "m" gnus-summary-limit-to-marks
7084 "v" gnus-summary-limit-to-score
7085 "D" gnus-summary-limit-include-dormant
7086 "d" gnus-summary-limit-exclude-dormant
7087 ;; "t" gnus-summary-limit-exclude-thread
7088 "E" gnus-summary-limit-include-expunged
7089 "c" gnus-summary-limit-exclude-childless-dormant
7090 "C" gnus-summary-limit-mark-excluded-as-read)
7092 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7093 "n" gnus-summary-next-unread-article
7094 "p" gnus-summary-prev-unread-article
7095 "N" gnus-summary-next-article
7096 "P" gnus-summary-prev-article
7097 "\C-n" gnus-summary-next-same-subject
7098 "\C-p" gnus-summary-prev-same-subject
7099 "\M-n" gnus-summary-next-unread-subject
7100 "\M-p" gnus-summary-prev-unread-subject
7101 "f" gnus-summary-first-unread-article
7102 "b" gnus-summary-best-unread-article
7103 "j" gnus-summary-goto-article
7104 "g" gnus-summary-goto-subject
7105 "l" gnus-summary-goto-last-article
7106 "p" gnus-summary-pop-article)
7108 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7109 "k" gnus-summary-kill-thread
7110 "l" gnus-summary-lower-thread
7111 "i" gnus-summary-raise-thread
7112 "T" gnus-summary-toggle-threads
7113 "t" gnus-summary-rethread-current
7114 "^" gnus-summary-reparent-thread
7115 "s" gnus-summary-show-thread
7116 "S" gnus-summary-show-all-threads
7117 "h" gnus-summary-hide-thread
7118 "H" gnus-summary-hide-all-threads
7119 "n" gnus-summary-next-thread
7120 "p" gnus-summary-prev-thread
7121 "u" gnus-summary-up-thread
7122 "o" gnus-summary-top-thread
7123 "d" gnus-summary-down-thread
7124 "#" gnus-uu-mark-thread
7125 "\M-#" gnus-uu-unmark-thread)
7127 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7128 "c" gnus-summary-catchup-and-exit
7129 "C" gnus-summary-catchup-all-and-exit
7130 "E" gnus-summary-exit-no-update
7131 "Q" gnus-summary-exit
7132 "Z" gnus-summary-exit
7133 "n" gnus-summary-catchup-and-goto-next-group
7134 "R" gnus-summary-reselect-current-group
7135 "G" gnus-summary-rescan-group
7136 "N" gnus-summary-next-group
7137 "P" gnus-summary-prev-group)
7139 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7140 " " gnus-summary-next-page
7141 "n" gnus-summary-next-page
7142 "\177" gnus-summary-prev-page
7143 [delete] gnus-summary-prev-page
7144 "p" gnus-summary-prev-page
7145 "\r" gnus-summary-scroll-up
7146 "<" gnus-summary-beginning-of-article
7147 ">" gnus-summary-end-of-article
7148 "b" gnus-summary-beginning-of-article
7149 "e" gnus-summary-end-of-article
7150 "^" gnus-summary-refer-parent-article
7151 "r" gnus-summary-refer-parent-article
7152 "R" gnus-summary-refer-references
7153 "g" gnus-summary-show-article
7154 "s" gnus-summary-isearch-article)
7156 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7157 "b" gnus-article-add-buttons
7158 "B" gnus-article-add-buttons-to-head
7159 "o" gnus-article-treat-overstrike
7160 ;; "w" gnus-article-word-wrap
7161 "w" gnus-article-fill-cited-article
7162 "c" gnus-article-remove-cr
7163 "L" gnus-article-remove-trailing-blank-lines
7164 "q" gnus-article-de-quoted-unreadable
7165 "f" gnus-article-display-x-face
7166 "l" gnus-summary-stop-page-breaking
7167 "r" gnus-summary-caesar-message
7168 "t" gnus-article-hide-headers
7169 "v" gnus-summary-verbose-headers
7170 "m" gnus-summary-toggle-mime)
7172 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7173 "a" gnus-article-hide
7174 "h" gnus-article-hide-headers
7175 "b" gnus-article-hide-boring-headers
7176 "s" gnus-article-hide-signature
7177 "c" gnus-article-hide-citation
7178 "p" gnus-article-hide-pgp
7179 "P" gnus-article-hide-pem
7180 "\C-c" gnus-article-hide-citation-maybe)
7182 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7183 "a" gnus-article-highlight
7184 "h" gnus-article-highlight-headers
7185 "c" gnus-article-highlight-citation
7186 "s" gnus-article-highlight-signature)
7188 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7189 "z" gnus-article-date-ut
7190 "u" gnus-article-date-ut
7191 "l" gnus-article-date-local
7192 "e" gnus-article-date-lapsed
7193 "o" gnus-article-date-original)
7195 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7197 "f" gnus-summary-fetch-faq
7198 "d" gnus-summary-describe-group
7199 "h" gnus-summary-describe-briefly
7200 "i" gnus-info-find-node)
7202 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7203 "e" gnus-summary-expire-articles
7204 "\M-\C-e" gnus-summary-expire-articles-now
7205 "\177" gnus-summary-delete-article
7206 [delete] gnus-summary-delete-article
7207 "m" gnus-summary-move-article
7208 "r" gnus-summary-respool-article
7209 "w" gnus-summary-edit-article
7210 "c" gnus-summary-copy-article
7211 "B" gnus-summary-crosspost-article
7212 "q" gnus-summary-respool-query
7213 "i" gnus-summary-import-article)
7215 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7216 "o" gnus-summary-save-article
7217 "m" gnus-summary-save-article-mail
7218 "r" gnus-summary-save-article-rmail
7219 "f" gnus-summary-save-article-file
7220 "b" gnus-summary-save-article-body-file
7221 "h" gnus-summary-save-article-folder
7222 "v" gnus-summary-save-article-vm
7223 "p" gnus-summary-pipe-output
7224 "s" gnus-soup-add-article)
7229 (defun gnus-summary-mode (&optional group)
7230 "Major mode for reading articles.
7232 All normal editing commands are switched off.
7233 \\<gnus-summary-mode-map>
7234 Each line in this buffer represents one article. To read an
7235 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7236 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7239 You can also post articles and send mail from this buffer. To
7240 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7241 of an article, type `\\[gnus-summary-reply]'.
7243 There are approx. one gazillion commands you can execute in this
7244 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7246 The following commands are available:
7248 \\{gnus-summary-mode-map}"
7250 (when (and menu-bar-mode
7251 (gnus-visual-p 'summary-menu 'menu))
7252 (gnus-summary-make-menu-bar))
7253 (kill-all-local-variables)
7254 (gnus-summary-make-local-variables)
7255 (gnus-make-thread-indent-array)
7256 (gnus-simplify-mode-line)
7257 (setq major-mode 'gnus-summary-mode)
7258 (setq mode-name "Summary")
7259 (make-local-variable 'minor-mode-alist)
7260 (use-local-map gnus-summary-mode-map)
7261 (buffer-disable-undo (current-buffer))
7262 (setq buffer-read-only t) ;Disable modification
7263 (setq truncate-lines t)
7264 (setq selective-display t)
7265 (setq selective-display-ellipses t) ;Display `...'
7266 (setq buffer-display-table gnus-summary-display-table)
7267 (setq gnus-newsgroup-name group)
7268 (make-local-variable 'gnus-summary-line-format)
7269 (make-local-variable 'gnus-summary-line-format-spec)
7270 (make-local-variable 'gnus-summary-mark-positions)
7271 (gnus-make-local-hook 'post-command-hook)
7272 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
7273 (run-hooks 'gnus-summary-mode-hook))
7275 (defun gnus-summary-make-local-variables ()
7276 "Make all the local summary buffer variables."
7277 (let ((locals gnus-summary-local-variables)
7279 (while (setq local (pop locals))
7282 (if (eq (cdr local) 'global)
7283 ;; Copy the global value of the variable.
7284 (setq global (symbol-value (car local)))
7285 ;; Use the value from the list.
7286 (setq global (eval (cdr local))))
7287 (make-local-variable (car local))
7288 (set (car local) global))
7289 ;; Simple nil-valued local variable.
7290 (make-local-variable local)
7293 (defun gnus-summary-make-display-table ()
7294 ;; Change the display table. Odd characters have a tendency to mess
7295 ;; up nicely formatted displays - we make all possible glyphs
7296 ;; display only a single character.
7298 ;; We start from the standard display table, if any.
7299 (setq gnus-summary-display-table
7300 (or (copy-sequence standard-display-table)
7301 (make-display-table)))
7302 ;; Nix out all the control chars...
7304 (while (>= (setq i (1- i)) 0)
7305 (aset gnus-summary-display-table i [??])))
7306 ;; ... but not newline and cr, of course. (cr is necessary for the
7307 ;; selective display).
7308 (aset gnus-summary-display-table ?\n nil)
7309 (aset gnus-summary-display-table ?\r nil)
7310 ;; We nix out any glyphs over 126 that are not set already.
7312 (while (>= (setq i (1- i)) 127)
7313 ;; Only modify if the entry is nil.
7314 (or (aref gnus-summary-display-table i)
7315 (aset gnus-summary-display-table i [??])))))
7317 (defun gnus-summary-clear-local-variables ()
7318 (let ((locals gnus-summary-local-variables))
7320 (if (consp (car locals))
7321 (and (vectorp (caar locals))
7322 (set (caar locals) nil))
7323 (and (vectorp (car locals))
7324 (set (car locals) nil)))
7325 (setq locals (cdr locals)))))
7327 ;; Summary data functions.
7329 (defmacro gnus-data-number (data)
7332 (defmacro gnus-data-set-number (data number)
7333 `(setcar ,data ,number))
7335 (defmacro gnus-data-mark (data)
7338 (defmacro gnus-data-set-mark (data mark)
7339 `(setcar (nthcdr 1 ,data) ,mark))
7341 (defmacro gnus-data-pos (data)
7344 (defmacro gnus-data-set-pos (data pos)
7345 `(setcar (nthcdr 2 ,data) ,pos))
7347 (defmacro gnus-data-header (data)
7350 (defmacro gnus-data-level (data)
7353 (defmacro gnus-data-unread-p (data)
7354 `(= (nth 1 ,data) gnus-unread-mark))
7356 (defmacro gnus-data-pseudo-p (data)
7357 `(consp (nth 3 ,data)))
7359 (defmacro gnus-data-find (number)
7360 `(assq ,number gnus-newsgroup-data))
7362 (defmacro gnus-data-find-list (number &optional data)
7363 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7364 (memq (assq ,number bdata)
7367 (defmacro gnus-data-make (number mark pos header level)
7368 `(list ,number ,mark ,pos ,header ,level))
7370 (defun gnus-data-enter (after-article number mark pos header level offset)
7371 (let ((data (gnus-data-find-list after-article)))
7372 (or data (error "No such article: %d" after-article))
7373 (setcdr data (cons (gnus-data-make number mark pos header level)
7375 (setq gnus-newsgroup-data-reverse nil)
7376 (gnus-data-update-list (cddr data) offset)))
7378 (defun gnus-data-enter-list (after-article list &optional offset)
7380 (let ((data (and after-article (gnus-data-find-list after-article)))
7382 (or data (not after-article) (error "No such article: %d" after-article))
7383 ;; Find the last element in the list to be spliced into the main
7386 (setq list (cdr list)))
7389 (setcdr list gnus-newsgroup-data)
7390 (setq gnus-newsgroup-data ilist)
7391 (and offset (gnus-data-update-list (cdr list) offset)))
7392 (setcdr list (cdr data))
7394 (and offset (gnus-data-update-list (cdr data) offset)))
7395 (setq gnus-newsgroup-data-reverse nil))))
7397 (defun gnus-data-remove (article &optional offset)
7398 (let ((data gnus-newsgroup-data))
7399 (if (= (gnus-data-number (car data)) article)
7400 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7401 gnus-newsgroup-data-reverse nil)
7403 (and (= (gnus-data-number (cadr data)) article)
7405 (setcdr data (cddr data))
7406 (and offset (gnus-data-update-list (cdr data) offset))
7408 gnus-newsgroup-data-reverse nil)))
7409 (setq data (cdr data))))))
7411 (defmacro gnus-data-list (backward)
7413 (or gnus-newsgroup-data-reverse
7414 (setq gnus-newsgroup-data-reverse
7415 (reverse gnus-newsgroup-data)))
7416 gnus-newsgroup-data))
7418 (defun gnus-data-update-list (data offset)
7419 "Add OFFSET to the POS of all data entries in DATA."
7421 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7422 (setq data (cdr data))))
7424 (defun gnus-data-compute-positions ()
7425 "Compute the positions of all articles."
7426 (let ((data gnus-newsgroup-data)
7429 (when (setq pos (text-property-any
7430 (point-min) (point-max)
7431 'gnus-number (gnus-data-number (car data))))
7432 (gnus-data-set-pos (car data) (+ pos 3)))
7433 (setq data (cdr data)))))
7435 (defun gnus-summary-article-pseudo-p (article)
7436 "Say whether this article is a pseudo article or not."
7437 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7439 (defun gnus-article-parent-p (number)
7440 "Say whether this article is a parent or not."
7441 (let ((data (gnus-data-find-list number)))
7442 (and (cdr data) ; There has to be an article after...
7443 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7444 (gnus-data-level (nth 1 data))))))
7446 (defun gnus-article-children (number)
7447 "Return a list of all children to NUMBER."
7448 (let* ((data (gnus-data-find-list number))
7449 (level (gnus-data-level (car data)))
7451 (setq data (cdr data))
7453 (= (gnus-data-level (car data)) (1+ level)))
7454 (push (gnus-data-number (car data)) children)
7455 (setq data (cdr data)))
7458 (defmacro gnus-summary-skip-intangible ()
7459 "If the current article is intangible, then jump to a different article."
7460 '(let ((to (get-text-property (point) 'gnus-intangible)))
7461 (and to (gnus-summary-goto-subject to))))
7463 (defmacro gnus-summary-article-intangible-p ()
7464 "Say whether this article is intangible or not."
7465 '(get-text-property (point) 'gnus-intangible))
7467 ;; Some summary mode macros.
7469 (defmacro gnus-summary-article-number ()
7470 "The article number of the article on the current line.
7471 If there isn's an article number here, then we return the current
7474 (gnus-summary-skip-intangible)
7475 (or (get-text-property (point) 'gnus-number)
7476 (gnus-summary-last-subject))))
7478 (defmacro gnus-summary-article-header (&optional number)
7479 `(gnus-data-header (gnus-data-find
7480 ,(or number '(gnus-summary-article-number)))))
7482 (defmacro gnus-summary-thread-level (&optional number)
7483 `(if (and (eq gnus-summary-make-false-root 'dummy)
7484 (get-text-property (point) 'gnus-intangible))
7486 (gnus-data-level (gnus-data-find
7487 ,(or number '(gnus-summary-article-number))))))
7489 (defmacro gnus-summary-article-mark (&optional number)
7490 `(gnus-data-mark (gnus-data-find
7491 ,(or number '(gnus-summary-article-number)))))
7493 (defmacro gnus-summary-article-pos (&optional number)
7494 `(gnus-data-pos (gnus-data-find
7495 ,(or number '(gnus-summary-article-number)))))
7497 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7498 (defmacro gnus-summary-article-subject (&optional number)
7499 "Return current subject string or nil if nothing."
7502 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7503 '(gnus-data-header (assq (gnus-summary-article-number)
7504 gnus-newsgroup-data)))))
7507 (mail-header-subject headers))))
7509 (defmacro gnus-summary-article-score (&optional number)
7510 "Return current article score."
7511 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7512 gnus-newsgroup-scored))
7513 gnus-summary-default-score 0))
7515 (defun gnus-summary-article-children (&optional number)
7516 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7517 (level (gnus-data-level (car data)))
7519 (while (and (setq data (cdr data))
7520 (> (setq l (gnus-data-level (car data))) level))
7521 (and (= (1+ level) l)
7522 (setq children (cons (gnus-data-number (car data))
7524 (nreverse children)))
7526 (defun gnus-summary-article-parent (&optional number)
7527 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7528 (gnus-data-list t)))
7529 (level (gnus-data-level (car data))))
7531 () ; This is a root.
7532 ;; We search until we find an article with a level less than
7533 ;; this one. That function has to be the parent.
7534 (while (and (setq data (cdr data))
7535 (not (< (gnus-data-level (car data)) level))))
7536 (and data (gnus-data-number (car data))))))
7538 (defun gnus-unread-mark-p (mark)
7539 "Say whether MARK is the unread mark."
7540 (= mark gnus-unread-mark))
7542 (defun gnus-read-mark-p (mark)
7543 "Say whether MARK is one of the marks that mark as read.
7544 This is all marks except unread, ticked, dormant, and expirable."
7545 (not (or (= mark gnus-unread-mark)
7546 (= mark gnus-ticked-mark)
7547 (= mark gnus-dormant-mark)
7548 (= mark gnus-expirable-mark))))
7550 ;; Saving hidden threads.
7552 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7553 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7554 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7556 (defmacro gnus-save-hidden-threads (&rest forms)
7557 "Save hidden threads, eval FORMS, and restore the hidden threads."
7558 (let ((config (make-symbol "config")))
7559 `(let ((,config (gnus-hidden-threads-configuration)))
7563 (gnus-restore-hidden-threads-configuration ,config)))))
7565 (defun gnus-hidden-threads-configuration ()
7566 "Return the current hidden threads configuration."
7569 (goto-char (point-min))
7570 (while (search-forward "\r" nil t)
7571 (push (1- (point)) config))
7574 (defun gnus-restore-hidden-threads-configuration (config)
7575 "Restore hidden threads configuration from CONFIG."
7576 (let (point buffer-read-only)
7577 (while (setq point (pop config))
7578 (when (and (< point (point-max))
7580 (= (following-char) ?\n))
7581 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7583 ;; Various summary mode internalish functions.
7585 (defun gnus-mouse-pick-article (e)
7588 (gnus-summary-next-page nil t))
7590 (defun gnus-summary-setup-buffer (group)
7591 "Initialize summary buffer."
7592 (let ((buffer (concat "*Summary " group "*")))
7593 (if (get-buffer buffer)
7596 (setq gnus-summary-buffer (current-buffer))
7597 (not gnus-newsgroup-prepared))
7598 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7599 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7600 (gnus-add-current-to-buffer-list)
7601 (gnus-summary-mode group)
7603 (gnus-carpal-setup-buffer 'summary))
7604 (unless gnus-single-article-buffer
7605 (make-local-variable 'gnus-article-buffer)
7606 (make-local-variable 'gnus-article-current)
7607 (make-local-variable 'gnus-original-article-buffer))
7608 (setq gnus-newsgroup-name group)
7611 (defun gnus-set-global-variables ()
7612 ;; Set the global equivalents of the summary buffer-local variables
7613 ;; to the latest values they had. These reflect the summary buffer
7614 ;; that was in action when the last article was fetched.
7615 (when (eq major-mode 'gnus-summary-mode)
7616 (setq gnus-summary-buffer (current-buffer))
7617 (let ((name gnus-newsgroup-name)
7618 (marked gnus-newsgroup-marked)
7619 (unread gnus-newsgroup-unreads)
7620 (headers gnus-current-headers)
7621 (data gnus-newsgroup-data)
7622 (summary gnus-summary-buffer)
7623 (article-buffer gnus-article-buffer)
7624 (original gnus-original-article-buffer)
7625 (gac gnus-article-current)
7626 (reffed gnus-reffed-article-number)
7627 (score-file gnus-current-score-file))
7629 (set-buffer gnus-group-buffer)
7630 (setq gnus-newsgroup-name name)
7631 (setq gnus-newsgroup-marked marked)
7632 (setq gnus-newsgroup-unreads unread)
7633 (setq gnus-current-headers headers)
7634 (setq gnus-newsgroup-data data)
7635 (setq gnus-article-current gac)
7636 (setq gnus-summary-buffer summary)
7637 (setq gnus-article-buffer article-buffer)
7638 (setq gnus-original-article-buffer original)
7639 (setq gnus-reffed-article-number reffed)
7640 (setq gnus-current-score-file score-file)))))
7642 (defun gnus-summary-last-article-p (&optional article)
7643 "Return whether ARTICLE is the last article in the buffer."
7644 (if (not (setq article (or article (gnus-summary-article-number))))
7645 t ; All non-existant numbers are the last article. :-)
7646 (not (cdr (gnus-data-find-list article)))))
7648 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7649 "Insert a dummy root in the summary buffer."
7651 (gnus-add-text-properties
7652 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7653 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7655 (defun gnus-make-thread-indent-array ()
7657 (unless (and gnus-thread-indent-array
7658 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7659 (setq gnus-thread-indent-array (make-vector 201 "")
7660 gnus-thread-indent-array-level gnus-thread-indent-level)
7662 (aset gnus-thread-indent-array n
7663 (make-string (* n gnus-thread-indent-level) ? ))
7666 (defun gnus-summary-insert-line
7667 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7668 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7669 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7670 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7671 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7672 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7673 (gnus-tmp-score-char
7674 (if (or (null gnus-summary-default-score)
7675 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7676 gnus-summary-zcore-fuzz)) ?
7677 (if (< gnus-tmp-score gnus-summary-default-score)
7678 gnus-score-below-mark gnus-score-over-mark)))
7679 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7680 ((memq gnus-tmp-current gnus-newsgroup-cached)
7682 (gnus-tmp-replied gnus-replied-mark)
7683 ((memq gnus-tmp-current gnus-newsgroup-saved)
7685 (t gnus-unread-mark)))
7686 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7689 ((string-match "(.+)" gnus-tmp-from)
7690 (substring gnus-tmp-from
7691 (1+ (match-beginning 0)) (1- (match-end 0))))
7692 ((string-match "<[^>]+> *$" gnus-tmp-from)
7693 (let ((beg (match-beginning 0)))
7694 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7695 (substring gnus-tmp-from (1+ (match-beginning 0))
7696 (1- (match-end 0))))
7697 (substring gnus-tmp-from 0 beg))))
7699 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7700 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7701 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7702 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7703 (buffer-read-only nil))
7704 (when (string= gnus-tmp-name "")
7705 (setq gnus-tmp-name gnus-tmp-from))
7706 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7707 (gnus-put-text-property
7709 (progn (eval gnus-summary-line-format-spec) (point))
7710 'gnus-number gnus-tmp-number)
7711 (when (gnus-visual-p 'summary-highlight 'highlight)
7713 (run-hooks 'gnus-summary-update-hook)
7716 (defun gnus-summary-update-line (&optional dont-update)
7717 ;; Update summary line after change.
7718 (when (and gnus-summary-default-score
7719 (not gnus-summary-inhibit-highlight))
7720 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7721 (article (gnus-summary-article-number))
7722 (score (gnus-summary-article-score article)))
7724 (if (and gnus-summary-mark-below
7725 (< (gnus-summary-article-score)
7726 gnus-summary-mark-below))
7727 ;; This article has a low score, so we mark it as read.
7728 (when (memq article gnus-newsgroup-unreads)
7729 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7730 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7731 ;; This article was previously marked as read on account
7732 ;; of a low score, but now it has risen, so we mark it as
7734 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7735 (gnus-summary-update-mark
7736 (if (or (null gnus-summary-default-score)
7737 (<= (abs (- score gnus-summary-default-score))
7738 gnus-summary-zcore-fuzz)) ?
7739 (if (< score gnus-summary-default-score)
7740 gnus-score-below-mark gnus-score-over-mark)) 'score))
7741 ;; Do visual highlighting.
7742 (when (gnus-visual-p 'summary-highlight 'highlight)
7743 (run-hooks 'gnus-summary-update-hook)))))
7745 (defvar gnus-tmp-new-adopts nil)
7747 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7748 ;; Sum up all elements (and sub-elements) in a list.
7750 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7752 ((and (consp thread) (cdr thread))
7755 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7758 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7761 (when (and level (zerop level) gnus-tmp-new-adopts)
7764 'gnus-summary-number-of-articles-in-thread
7765 gnus-tmp-new-adopts))))
7767 (if (> number 1) gnus-not-empty-thread-mark
7768 gnus-empty-thread-mark)
7771 (defun gnus-summary-set-local-parameters (group)
7772 "Go through the local params of GROUP and set all variable specs in that list."
7773 (let ((params (gnus-info-params (gnus-get-info group)))
7776 (setq elem (car params)
7777 params (cdr params))
7778 (and (consp elem) ; Has to be a cons.
7779 (consp (cdr elem)) ; The cdr has to be a list.
7780 (symbolp (car elem)) ; Has to be a symbol in there.
7781 (not (memq (car elem)
7782 '(quit-config to-address to-list to-group)))
7783 (progn ; So we set it.
7784 (make-local-variable (car elem))
7785 (set (car elem) (eval (nth 1 elem))))))))
7787 (defun gnus-summary-read-group (group &optional show-all no-article
7788 kill-buffer no-display)
7789 "Start reading news in newsgroup GROUP.
7790 If SHOW-ALL is non-nil, already read articles are also listed.
7791 If NO-ARTICLE is non-nil, no article is selected initially.
7792 If NO-DISPLAY, don't generate a summary buffer."
7793 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7794 (let* ((new-group (gnus-summary-setup-buffer group))
7795 (quit-config (gnus-group-quit-config group))
7796 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7798 ;; This summary buffer exists already, so we just select it.
7800 (gnus-set-global-variables)
7802 (gnus-kill-or-deaden-summary kill-buffer))
7803 (gnus-configure-windows 'summary 'force)
7804 (gnus-set-mode-line 'summary)
7805 (gnus-summary-position-point)
7808 ;; We couldn't select this group.
7810 (when (and (eq major-mode 'gnus-summary-mode)
7811 (not (equal (current-buffer) kill-buffer)))
7812 (kill-buffer (current-buffer))
7813 (if (not quit-config)
7815 (set-buffer gnus-group-buffer)
7816 (gnus-group-jump-to-group group)
7817 (gnus-group-next-unread-group 1))
7818 (if (not (buffer-name (car quit-config)))
7819 (gnus-configure-windows 'group 'force)
7820 (set-buffer (car quit-config))
7821 (and (eq major-mode 'gnus-summary-mode)
7822 (gnus-set-global-variables))
7823 (gnus-configure-windows (cdr quit-config)))))
7824 (gnus-message 3 "Can't select group")
7826 ;; The user did a `C-g' while prompting for number of articles,
7827 ;; so we exit this group.
7828 ((eq did-select 'quit)
7829 (and (eq major-mode 'gnus-summary-mode)
7830 (not (equal (current-buffer) kill-buffer))
7831 (kill-buffer (current-buffer)))
7833 (gnus-kill-or-deaden-summary kill-buffer))
7834 (if (not quit-config)
7836 (set-buffer gnus-group-buffer)
7837 (gnus-group-jump-to-group group)
7838 (gnus-group-next-unread-group 1)
7839 (gnus-configure-windows 'group 'force))
7840 (if (not (buffer-name (car quit-config)))
7841 (gnus-configure-windows 'group 'force)
7842 (set-buffer (car quit-config))
7843 (and (eq major-mode 'gnus-summary-mode)
7844 (gnus-set-global-variables))
7845 (gnus-configure-windows (cdr quit-config))))
7846 ;; Finally signal the quit.
7848 ;; The group was successfully selected.
7850 (gnus-set-global-variables)
7851 ;; Save the active value in effect when the group was entered.
7852 (setq gnus-newsgroup-active
7854 (gnus-active gnus-newsgroup-name)))
7855 ;; You can change the summary buffer in some way with this hook.
7856 (run-hooks 'gnus-select-group-hook)
7857 ;; Set any local variables in the group parameters.
7858 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7859 (gnus-update-format-specifications)
7860 ;; Do score processing.
7861 (when gnus-use-scoring
7862 (gnus-possibly-score-headers))
7863 ;; Check whether to fill in the gaps in the threads.
7864 (when gnus-build-sparse-threads
7865 (gnus-build-sparse-threads))
7866 ;; Find the initial limit.
7867 (if gnus-show-threads
7869 (let ((gnus-newsgroup-dormant nil))
7870 (gnus-summary-initial-limit show-all))
7871 (gnus-summary-initial-limit show-all))
7872 (setq gnus-newsgroup-limit
7874 (lambda (header) (mail-header-number header))
7875 gnus-newsgroup-headers)))
7876 ;; Generate the summary buffer.
7878 (gnus-summary-prepare))
7879 (when gnus-use-trees
7880 (gnus-tree-open group)
7881 (setq gnus-summary-highlight-line-function
7882 'gnus-tree-highlight-article))
7883 ;; If the summary buffer is empty, but there are some low-scored
7884 ;; articles or some excluded dormants, we include these in the
7886 (when (and (zerop (buffer-size))
7888 (cond (gnus-newsgroup-dormant
7889 (gnus-summary-limit-include-dormant))
7890 ((and gnus-newsgroup-scored show-all)
7891 (gnus-summary-limit-include-expunged t))))
7892 ;; Function `gnus-apply-kill-file' must be called in this hook.
7893 (run-hooks 'gnus-apply-kill-hook)
7894 (if (and (zerop (buffer-size))
7897 ;; This newsgroup is empty.
7898 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7899 (gnus-message 6 "No unread news")
7901 (gnus-kill-or-deaden-summary kill-buffer))
7902 ;; Return nil from this function.
7904 ;; Hide conversation thread subtrees. We cannot do this in
7905 ;; gnus-summary-prepare-hook since kill processing may not
7906 ;; work with hidden articles.
7907 (and gnus-show-threads
7908 gnus-thread-hide-subtree
7909 (gnus-summary-hide-all-threads))
7910 ;; Show first unread article if requested.
7911 (if (and (not no-article)
7913 gnus-newsgroup-unreads
7914 gnus-auto-select-first)
7915 (unless (if (eq gnus-auto-select-first 'best)
7916 (gnus-summary-best-unread-article)
7917 (gnus-summary-first-unread-article))
7918 (gnus-configure-windows 'summary))
7919 ;; Don't select any articles, just move point to the first
7920 ;; article in the group.
7921 (goto-char (point-min))
7922 (gnus-summary-position-point)
7923 (gnus-set-mode-line 'summary)
7924 (gnus-configure-windows 'summary 'force))
7925 ;; If we are in async mode, we send some info to the backend.
7926 (when gnus-newsgroup-async
7927 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7929 (gnus-kill-or-deaden-summary kill-buffer))
7930 (when (get-buffer-window gnus-group-buffer t)
7931 ;; Gotta use windows, because recenter does wierd stuff if
7932 ;; the current buffer ain't the displayed window.
7933 (let ((owin (selected-window)))
7934 (select-window (get-buffer-window gnus-group-buffer t))
7935 (when (gnus-group-goto-group group)
7937 (select-window owin))))
7938 ;; Mark this buffer as "prepared".
7939 (setq gnus-newsgroup-prepared t)
7942 (defun gnus-summary-prepare ()
7943 "Generate the summary buffer."
7944 (let ((buffer-read-only nil))
7946 (setq gnus-newsgroup-data nil
7947 gnus-newsgroup-data-reverse nil)
7948 (run-hooks 'gnus-summary-generate-hook)
7949 ;; Generate the buffer, either with threads or without.
7950 (when gnus-newsgroup-headers
7951 (gnus-summary-prepare-threads
7952 (if gnus-show-threads
7953 (gnus-sort-gathered-threads
7954 (funcall gnus-summary-thread-gathering-function
7956 (gnus-cut-threads (gnus-make-threads)))))
7957 ;; Unthreaded display.
7958 (gnus-sort-articles gnus-newsgroup-headers))))
7959 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7960 ;; Call hooks for modifying summary buffer.
7961 (goto-char (point-min))
7962 (run-hooks 'gnus-summary-prepare-hook)))
7964 (defun gnus-gather-threads-by-subject (threads)
7965 "Gather threads by looking at Subject headers."
7966 (if (not gnus-summary-make-false-root)
7968 (let ((hashtb (gnus-make-hashtable 1023))
7971 subject hthread whole-subject)
7973 (setq whole-subject (mail-header-subject (caar threads)))
7976 ;; Truncate the subject.
7977 ((numberp gnus-summary-gather-subject-limit)
7978 (setq subject (gnus-simplify-subject-re whole-subject))
7979 (if (> (length subject) gnus-summary-gather-subject-limit)
7980 (substring subject 0 gnus-summary-gather-subject-limit)
7982 ;; Fuzzily simplify it.
7983 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7984 (gnus-simplify-subject-fuzzy whole-subject))
7985 ;; Just remove the leading "Re:".
7987 (gnus-simplify-subject-re whole-subject))))
7989 (if (and gnus-summary-gather-exclude-subject
7990 (string-match gnus-summary-gather-exclude-subject
7992 () ; We don't want to do anything with this article.
7993 ;; We simplify the subject before looking it up in the
7996 (if (setq hthread (gnus-gethash subject hashtb))
7998 ;; We enter a dummy root into the thread, if we
7999 ;; haven't done that already.
8000 (unless (stringp (caar hthread))
8001 (setcar hthread (list whole-subject (car hthread))))
8002 ;; We add this new gathered thread to this gathered
8004 (setcdr (car hthread)
8005 (nconc (cdar hthread) (list (car threads))))
8006 ;; Remove it from the list of threads.
8007 (setcdr prev (cdr threads))
8008 (setq threads prev))
8009 ;; Enter this thread into the hash table.
8010 (gnus-sethash subject threads hashtb)))
8012 (setq threads (cdr threads)))
8015 (defun gnus-gather-threads-by-references (threads)
8016 "Gather threads by looking at References headers."
8017 (let ((idhashtb (gnus-make-hashtable 1023))
8018 (thhashtb (gnus-make-hashtable 1023))
8021 ids references id gthread gid entered)
8023 (when (setq references (mail-header-references (caar threads)))
8024 (setq id (mail-header-id (caar threads)))
8025 (setq ids (gnus-split-references references))
8028 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
8030 (gnus-sethash (car ids) id idhashtb)
8031 (gnus-sethash id threads thhashtb))
8032 (setq gthread (gnus-gethash gid thhashtb))
8034 ;; We enter a dummy root into the thread, if we
8035 ;; haven't done that already.
8036 (unless (stringp (caar gthread))
8037 (setcar gthread (list (mail-header-subject (caar gthread))
8039 ;; We add this new gathered thread to this gathered
8041 (setcdr (car gthread)
8042 (nconc (cdar gthread) (list (car threads)))))
8043 ;; Add it into the thread hash table.
8044 (gnus-sethash id gthread thhashtb)
8046 ;; Remove it from the list of threads.
8047 (setcdr prev (cdr threads))
8048 (setq threads prev))
8049 (setq ids (cdr ids))))
8051 (setq threads (cdr threads)))
8054 (defun gnus-sort-gathered-threads (threads)
8055 "Sort subtreads inside each gathered thread by article number."
8056 (let ((result threads))
8058 (when (stringp (caar threads))
8059 (setcdr (car threads)
8060 (sort (cdar threads) 'gnus-thread-sort-by-number)))
8061 (setq threads (cdr threads)))
8064 (defun gnus-make-threads ()
8065 "Go through the dependency hashtb and find the roots. Return all threads."
8069 (unless (car (symbol-value refs))
8070 ;; These threads do not refer back to any other articles,
8071 ;; so they're roots.
8072 (setq threads (append (cdr (symbol-value refs)) threads))))
8073 gnus-newsgroup-dependencies)
8076 (defun gnus-build-sparse-threads ()
8077 (let ((headers gnus-newsgroup-headers)
8078 (deps gnus-newsgroup-dependencies)
8079 header references generation relations
8080 cthread subject child end pthread relation)
8081 ;; First we create an alist of generations/relations, where
8082 ;; generations is how much we trust the ralation, and the relation
8084 (gnus-message 7 "Making sparse threads...")
8086 (nnheader-set-temp-buffer " *gnus sparse threads*")
8087 (while (setq header (pop headers))
8088 (when (and (setq references (mail-header-references header))
8089 (not (string= references "")))
8091 (setq child (mail-header-id header)
8092 subject (mail-header-subject header))
8094 (while (search-backward ">" nil t)
8095 (setq end (1+ (point)))
8096 (when (search-backward "<" nil t)
8097 (push (list (incf generation)
8098 child (setq child (buffer-substring (point) end))
8101 (push (list (1+ generation) child nil subject) relations)
8103 (kill-buffer (current-buffer)))
8104 ;; Sort over trustworthiness.
8105 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8106 (while (setq relation (pop relations))
8107 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8108 (unless (car (symbol-value cthread))
8109 ;; Make this article the parent of these threads.
8110 (setcar (symbol-value cthread)
8111 (vector gnus-reffed-article-number
8115 (or (caddr relation) "") 0 0 "")))
8116 (set cthread (list (vector gnus-reffed-article-number
8118 "" "" (cadr relation)
8119 (or (caddr relation) "") 0 0 ""))))
8120 (push gnus-reffed-article-number gnus-newsgroup-limit)
8121 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8122 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8123 gnus-newsgroup-reads)
8124 (decf gnus-reffed-article-number)
8125 ;; Make this new thread the child of its parent.
8126 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8127 (setcdr (symbol-value pthread)
8128 (nconc (cdr (symbol-value pthread))
8129 (list (symbol-value cthread))))
8130 (set pthread (list nil (symbol-value cthread))))))
8131 (gnus-message 7 "Making sparse threads...done")))
8133 (defun gnus-build-old-threads ()
8134 ;; Look at all the articles that refer back to old articles, and
8135 ;; fetch the headers for the articles that aren't there. This will
8136 ;; build complete threads - if the roots haven't been expired by the
8141 (when (not (car (symbol-value refs)))
8142 (setq heads (cdr (symbol-value refs)))
8144 (if (memq (mail-header-number (caar heads))
8145 gnus-newsgroup-dormant)
8146 (setq heads (cdr heads))
8147 (setq id (symbol-name refs))
8148 (while (and (setq id (gnus-build-get-header id))
8149 (not (car (gnus-gethash
8150 id gnus-newsgroup-dependencies)))))
8151 (setq heads nil)))))
8152 gnus-newsgroup-dependencies)))
8154 (defun gnus-build-get-header (id)
8155 ;; Look through the buffer of NOV lines and find the header to
8156 ;; ID. Enter this line into the dependencies hash table, and return
8157 ;; the id of the parent article (if any).
8158 (let ((deps gnus-newsgroup-dependencies)
8162 (set-buffer nntp-server-buffer)
8163 (goto-char (point-min))
8164 (while (and (not found) (search-forward id nil t))
8166 (setq found (looking-at
8167 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8168 (regexp-quote id))))
8169 (or found (beginning-of-line 2)))
8173 (setq header (gnus-nov-parse-line
8174 (read (current-buffer)) deps))
8175 (gnus-parent-id (mail-header-references header)))))
8177 (let ((number (mail-header-number header)))
8178 (push number gnus-newsgroup-limit)
8179 (push header gnus-newsgroup-headers)
8180 (if (memq number gnus-newsgroup-unselected)
8182 (push number gnus-newsgroup-unreads)
8183 (setq gnus-newsgroup-unselected
8184 (delq number gnus-newsgroup-unselected)))
8185 (push number gnus-newsgroup-ancient)))))))
8187 (defun gnus-summary-update-article (article &optional iheader)
8188 "Update ARTICLE in the summary buffer."
8189 (set-buffer gnus-summary-buffer)
8190 (let* ((header (or iheader (gnus-summary-article-header article)))
8191 (id (mail-header-id header))
8192 (data (gnus-data-find article))
8193 (thread (gnus-id-to-thread id))
8194 (references (mail-header-references header))
8199 (not (equal "" references)))
8202 (buffer-read-only nil)
8204 (number (mail-header-number header))
8207 ;; !!! Should this be in or not?
8209 (setcar thread nil))
8211 (delq thread parent))
8212 (if (gnus-summary-insert-subject id header iheader)
8213 ;; Set the (possibly) new article number in the data structure.
8214 (gnus-data-set-number data (gnus-id-to-article id))
8218 (defun gnus-rebuild-thread (id)
8219 "Rebuild the thread containing ID."
8220 (let ((buffer-read-only nil)
8221 current thread data)
8222 (if (not gnus-show-threads)
8223 (setq thread (list (car (gnus-id-to-thread id))))
8224 ;; Get the thread this article is part of.
8225 (setq thread (gnus-remove-thread id)))
8226 (setq current (save-excursion
8227 (and (zerop (forward-line -1))
8228 (gnus-summary-article-number))))
8229 ;; If this is a gathered thread, we have to go some re-gathering.
8230 (when (stringp (car thread))
8231 (let ((subject (car thread))
8233 (setq thread (cdr thread))
8235 (unless (memq (setq thr (gnus-id-to-thread
8237 (mail-header-id (caar thread)))))
8240 (setq thread (cdr thread)))
8241 ;; We now have all (unique) roots.
8242 (if (= (length roots) 1)
8243 ;; All the loose roots are now one solid root.
8244 (setq thread (car roots))
8245 (setq thread (cons subject (gnus-sort-threads roots))))))
8247 ;; We then insert this thread into the summary buffer.
8248 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8249 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8250 (setq data (nreverse gnus-newsgroup-data))
8251 (setq threads gnus-newsgroup-threads))
8252 ;; We splice the new data into the data structure.
8253 (gnus-data-enter-list current data)
8254 (gnus-data-compute-positions)
8255 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8257 (defun gnus-number-to-header (number)
8258 "Return the header for article NUMBER."
8259 (let ((headers gnus-newsgroup-headers))
8261 (not (= number (mail-header-number (car headers)))))
8266 (defun gnus-id-to-thread (id)
8267 "Return the (sub-)thread where ID appears."
8268 (gnus-gethash id gnus-newsgroup-dependencies))
8270 (defun gnus-id-to-article (id)
8271 "Return the article number of ID."
8272 (let ((thread (gnus-id-to-thread id)))
8275 (mail-header-number (car thread)))))
8277 (defun gnus-id-to-header (id)
8278 "Return the article headers of ID."
8279 (car (gnus-id-to-thread id)))
8281 (defun gnus-article-displayed-root-p (article)
8282 "Say whether ARTICLE is a root(ish) article."
8283 (let ((level (gnus-summary-thread-level article))
8284 (refs (mail-header-references (gnus-summary-article-header article)))
8290 ((null (gnus-parent-id refs)) t)
8292 (null (setq particle (gnus-id-to-article
8293 (gnus-parent-id refs))))
8294 (null (gnus-summary-thread-level particle)))))))
8296 (defun gnus-root-id (id)
8297 "Return the id of the root of the thread where ID appears."
8299 (while (and id (setq prev (car (gnus-gethash
8300 id gnus-newsgroup-dependencies))))
8302 id (gnus-parent-id (mail-header-references prev))))
8305 (defun gnus-remove-thread (id &optional dont-remove)
8306 "Remove the thread that has ID in it."
8307 (let ((dep gnus-newsgroup-dependencies)
8308 headers thread last-id)
8309 ;; First go up in this thread until we find the root.
8310 (setq last-id (gnus-root-id id))
8311 (setq headers (list (car (gnus-id-to-thread last-id))
8312 (caadr (gnus-id-to-thread last-id))))
8313 ;; We have now found the real root of this thread. It might have
8314 ;; been gathered into some loose thread, so we have to search
8315 ;; through the threads to find the thread we wanted.
8316 (let ((threads gnus-newsgroup-threads)
8319 (setq sub (car threads))
8320 (if (stringp (car sub))
8321 ;; This is a gathered threads, so we look at the roots
8322 ;; below it to find whether this article in in this
8325 (setq sub (cdr sub))
8327 (when (member (caar sub) headers)
8328 (setq thread (car threads)
8331 (setq sub (cdr sub))))
8332 ;; It's an ordinary thread, so we check it.
8333 (when (eq (car sub) (car headers))
8336 (setq threads (cdr threads)))
8337 ;; If this article is in no thread, then it's a root.
8340 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8341 (setq thread (gnus-gethash last-id dep)))
8344 thread ; We return this thread.
8346 (if (stringp (car thread))
8348 ;; If we use dummy roots, then we have to remove the
8349 ;; dummy root as well.
8350 (when (eq gnus-summary-make-false-root 'dummy)
8353 (setq thread (cdr thread))
8355 (gnus-remove-thread-1 (car thread))
8356 (setq thread (cdr thread))))
8357 (gnus-remove-thread-1 thread))))))))
8359 (defun gnus-remove-thread-1 (thread)
8360 "Remove the thread THREAD recursively."
8361 (let ((number (mail-header-number (car thread)))
8363 (when (setq pos (text-property-any
8364 (point-min) (point-max) 'gnus-number number))
8367 (gnus-data-remove number))
8368 (setq thread (cdr thread))
8370 (gnus-remove-thread-1 (pop thread)))))
8372 (defun gnus-sort-threads (threads)
8374 (if (not gnus-thread-sort-functions)
8376 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8377 (car gnus-thread-sort-functions)
8379 ,(gnus-make-sort-function
8380 (reverse gnus-thread-sort-functions))))))
8381 (gnus-message 7 "Sorting threads...")
8384 (gnus-message 7 "Sorting threads...done")))))
8386 (defun gnus-sort-articles (articles)
8388 (when gnus-article-sort-functions
8389 (let ((func (if (= 1 (length gnus-article-sort-functions))
8390 (car gnus-article-sort-functions)
8392 ,(gnus-make-sort-function
8393 (reverse gnus-article-sort-functions))))))
8394 (gnus-message 7 "Sorting articles...")
8396 (setq gnus-newsgroup-headers (sort articles func))
8397 (gnus-message 7 "Sorting articles...done")))))
8399 (defun gnus-make-sort-function (funs)
8400 "Return a composite sort condition based on the functions in FUNC."
8402 `(or (,(car funs) t1 t2)
8403 (and (not (,(car funs) t2 t1))
8404 ,(gnus-make-sort-function (cdr funs))))
8405 `(,(car funs) t1 t2)))
8407 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8408 (defmacro gnus-thread-header (thread)
8409 ;; Return header of first article in THREAD.
8410 ;; Note that THREAD must never, ever be anything else than a variable -
8411 ;; using some other form will lead to serious barfage.
8412 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8413 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8414 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8417 (defsubst gnus-article-sort-by-number (h1 h2)
8418 "Sort articles by article number."
8419 (< (mail-header-number h1)
8420 (mail-header-number h2)))
8422 (defun gnus-thread-sort-by-number (h1 h2)
8423 "Sort threads by root article number."
8424 (gnus-article-sort-by-number
8425 (gnus-thread-header h1) (gnus-thread-header h2)))
8427 (defsubst gnus-article-sort-by-author (h1 h2)
8428 "Sort articles by root author."
8430 (let ((extract (funcall
8431 gnus-extract-address-components
8432 (mail-header-from h1))))
8433 (or (car extract) (cdr extract)))
8434 (let ((extract (funcall
8435 gnus-extract-address-components
8436 (mail-header-from h2))))
8437 (or (car extract) (cdr extract)))))
8439 (defun gnus-thread-sort-by-author (h1 h2)
8440 "Sort threads by root author."
8441 (gnus-article-sort-by-author
8442 (gnus-thread-header h1) (gnus-thread-header h2)))
8444 (defsubst gnus-article-sort-by-subject (h1 h2)
8445 "Sort articles by root subject."
8447 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8448 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8450 (defun gnus-thread-sort-by-subject (h1 h2)
8451 "Sort threads by root subject."
8452 (gnus-article-sort-by-subject
8453 (gnus-thread-header h1) (gnus-thread-header h2)))
8455 (defsubst gnus-article-sort-by-date (h1 h2)
8456 "Sort articles by root article date."
8458 (inline (gnus-sortable-date (mail-header-date h1)))
8459 (inline (gnus-sortable-date (mail-header-date h2)))))
8461 (defun gnus-thread-sort-by-date (h1 h2)
8462 "Sort threads by root article date."
8463 (gnus-article-sort-by-date
8464 (gnus-thread-header h1) (gnus-thread-header h2)))
8466 (defsubst gnus-article-sort-by-score (h1 h2)
8467 "Sort articles by root article score.
8468 Unscored articles will be counted as having a score of zero."
8469 (> (or (cdr (assq (mail-header-number h1)
8470 gnus-newsgroup-scored))
8471 gnus-summary-default-score 0)
8472 (or (cdr (assq (mail-header-number h2)
8473 gnus-newsgroup-scored))
8474 gnus-summary-default-score 0)))
8476 (defun gnus-thread-sort-by-score (h1 h2)
8477 "Sort threads by root article score."
8478 (gnus-article-sort-by-score
8479 (gnus-thread-header h1) (gnus-thread-header h2)))
8481 (defun gnus-thread-sort-by-total-score (h1 h2)
8482 "Sort threads by the sum of all scores in the thread.
8483 Unscored articles will be counted as having a score of zero."
8484 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8486 (defun gnus-thread-total-score (thread)
8487 ;; This function find the total score of THREAD.
8488 (cond ((null thread)
8491 (if (stringp (car thread))
8492 (apply gnus-thread-score-function 0
8493 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8494 (gnus-thread-total-score-1 thread)))
8496 (gnus-thread-total-score-1 (list thread)))))
8498 (defun gnus-thread-total-score-1 (root)
8499 ;; This function find the total score of the thread below ROOT.
8500 (setq root (car root))
8501 (apply gnus-thread-score-function
8503 (mapcar 'gnus-thread-total-score
8504 (cdr (gnus-gethash (mail-header-id root)
8505 gnus-newsgroup-dependencies)))
8506 (if (> (mail-header-number root) 0)
8507 (list (or (cdr (assq (mail-header-number root)
8508 gnus-newsgroup-scored))
8509 gnus-summary-default-score 0))))
8510 (list gnus-summary-default-score)
8513 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8514 (defvar gnus-tmp-prev-subject nil)
8515 (defvar gnus-tmp-false-parent nil)
8516 (defvar gnus-tmp-root-expunged nil)
8517 (defvar gnus-tmp-dummy-line nil)
8519 (defun gnus-summary-prepare-threads (threads)
8520 "Prepare summary buffer from THREADS and indentation LEVEL.
8521 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8522 or a straight list of headers."
8523 (gnus-message 7 "Generating summary...")
8525 (setq gnus-newsgroup-threads threads)
8528 (let ((gnus-tmp-level 0)
8529 (default-score (or gnus-summary-default-score 0))
8530 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8531 thread number subject stack state gnus-tmp-gathered beg-match
8532 new-roots gnus-tmp-new-adopts thread-end
8533 gnus-tmp-header gnus-tmp-unread
8534 gnus-tmp-replied gnus-tmp-subject-or-nil
8535 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8536 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8537 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8539 (setq gnus-tmp-prev-subject nil)
8541 (if (vectorp (car threads))
8542 ;; If this is a straight (sic) list of headers, then a
8543 ;; threaded summary display isn't required, so we just create
8544 ;; an unthreaded one.
8545 (gnus-summary-prepare-unthreaded threads)
8547 ;; Do the threaded display.
8549 (while (or threads stack gnus-tmp-new-adopts new-roots)
8551 (if (and (= gnus-tmp-level 0)
8552 (not (setq gnus-tmp-dummy-line nil))
8555 (not gnus-tmp-false-parent)
8556 (or gnus-tmp-new-adopts new-roots))
8557 (if gnus-tmp-new-adopts
8558 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8559 thread (list (car gnus-tmp-new-adopts))
8560 gnus-tmp-header (caar thread)
8561 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8563 (setq thread (list (car new-roots))
8564 gnus-tmp-header (caar thread)
8565 new-roots (cdr new-roots))))
8568 ;; If there are some threads, we do them before the
8569 ;; threads on the stack.
8570 (setq thread threads
8571 gnus-tmp-header (caar thread))
8572 ;; There were no current threads, so we pop something off
8574 (setq state (car stack)
8575 gnus-tmp-level (car state)
8578 gnus-tmp-header (caar thread))))
8580 (setq gnus-tmp-false-parent nil)
8581 (setq gnus-tmp-root-expunged nil)
8582 (setq thread-end nil)
8584 (if (stringp gnus-tmp-header)
8585 ;; The header is a dummy root.
8587 ((eq gnus-summary-make-false-root 'adopt)
8588 ;; We let the first article adopt the rest.
8589 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8591 (setq gnus-tmp-gathered
8593 (lambda (h) (mail-header-number (car h)))
8596 (setq thread (cons (list (caar thread)
8599 (setq gnus-tmp-level -1
8600 gnus-tmp-false-parent t))
8601 ((eq gnus-summary-make-false-root 'empty)
8602 ;; We print adopted articles with empty subject fields.
8603 (setq gnus-tmp-gathered
8605 (lambda (h) (mail-header-number (car h)))
8608 (setq gnus-tmp-level -1))
8609 ((eq gnus-summary-make-false-root 'dummy)
8610 ;; We remember that we probably want to output a dummy
8612 (setq gnus-tmp-dummy-line gnus-tmp-header)
8613 (setq gnus-tmp-prev-subject gnus-tmp-header))
8615 ;; We do not make a root for the gathered
8616 ;; sub-threads at all.
8617 (setq gnus-tmp-level -1)))
8619 (setq number (mail-header-number gnus-tmp-header)
8620 subject (mail-header-subject gnus-tmp-header))
8623 ;; If the thread has changed subject, we might want to make
8624 ;; this subthread into a root.
8625 ((and (null gnus-thread-ignore-subject)
8626 (not (zerop gnus-tmp-level))
8627 gnus-tmp-prev-subject
8629 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8630 (setq new-roots (nconc new-roots (list (car thread)))
8632 gnus-tmp-header nil))
8633 ;; If the article lies outside the current limit,
8634 ;; then we do not display it.
8635 ((and (not (memq number gnus-newsgroup-limit))
8636 (not gnus-tmp-dummy-line))
8637 (setq gnus-tmp-gathered
8639 (lambda (h) (mail-header-number (car h)))
8642 (setq gnus-tmp-new-adopts (if (cdar thread)
8643 (append gnus-tmp-new-adopts
8645 gnus-tmp-new-adopts)
8647 gnus-tmp-header nil)
8648 (when (zerop gnus-tmp-level)
8649 (setq gnus-tmp-root-expunged t)))
8650 ;; Perhaps this article is to be marked as read?
8651 ((and gnus-summary-mark-below
8652 (< (or (cdr (assq number gnus-newsgroup-scored))
8654 gnus-summary-mark-below)
8655 ;; Don't touch sparse articles.
8656 (not (memq number gnus-newsgroup-sparse))
8657 (not (memq number gnus-newsgroup-ancient)))
8658 (setq gnus-newsgroup-unreads
8659 (delq number gnus-newsgroup-unreads))
8660 (if gnus-newsgroup-auto-expire
8661 (push number gnus-newsgroup-expirable)
8662 (push (cons number gnus-low-score-mark)
8663 gnus-newsgroup-reads))))
8665 (when gnus-tmp-header
8666 ;; We may have an old dummy line to output before this
8668 (when gnus-tmp-dummy-line
8669 (gnus-summary-insert-dummy-line
8670 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8671 (setq gnus-tmp-dummy-line nil))
8673 ;; Compute the mark.
8677 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8678 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8679 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8680 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8681 (t (or (cdr (assq number gnus-newsgroup-reads))
8682 gnus-ancient-mark))))
8684 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8685 gnus-tmp-header gnus-tmp-level)
8686 gnus-newsgroup-data)
8688 ;; Actually insert the line.
8690 gnus-tmp-subject-or-nil
8692 ((and gnus-thread-ignore-subject
8693 gnus-tmp-prev-subject
8694 (not (inline (gnus-subject-equal
8695 gnus-tmp-prev-subject subject))))
8697 ((zerop gnus-tmp-level)
8698 (if (and (eq gnus-summary-make-false-root 'empty)
8699 (memq number gnus-tmp-gathered)
8700 gnus-tmp-prev-subject
8701 (inline (gnus-subject-equal
8702 gnus-tmp-prev-subject subject)))
8703 gnus-summary-same-subject
8705 (t gnus-summary-same-subject)))
8706 (if (and (eq gnus-summary-make-false-root 'adopt)
8707 (= gnus-tmp-level 1)
8708 (memq number gnus-tmp-gathered))
8709 (setq gnus-tmp-opening-bracket ?\<
8710 gnus-tmp-closing-bracket ?\>)
8711 (setq gnus-tmp-opening-bracket ?\[
8712 gnus-tmp-closing-bracket ?\]))
8714 gnus-tmp-indentation
8715 (aref gnus-thread-indent-array gnus-tmp-level)
8716 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8717 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8718 gnus-summary-default-score 0)
8720 (if (or (null gnus-summary-default-score)
8721 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8722 gnus-summary-zcore-fuzz)) ?
8723 (if (< gnus-tmp-score gnus-summary-default-score)
8724 gnus-score-below-mark gnus-score-over-mark))
8726 (cond ((memq number gnus-newsgroup-processable)
8728 ((memq number gnus-newsgroup-cached)
8730 ((memq number gnus-newsgroup-replied)
8732 ((memq number gnus-newsgroup-saved)
8734 (t gnus-unread-mark))
8735 gnus-tmp-from (mail-header-from gnus-tmp-header)
8738 ((string-match "(.+)" gnus-tmp-from)
8739 (substring gnus-tmp-from
8740 (1+ (match-beginning 0)) (1- (match-end 0))))
8741 ((string-match "<[^>]+> *$" gnus-tmp-from)
8742 (setq beg-match (match-beginning 0))
8743 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8744 (substring gnus-tmp-from (1+ (match-beginning 0))
8745 (1- (match-end 0))))
8746 (substring gnus-tmp-from 0 beg-match)))
8748 (when (string= gnus-tmp-name "")
8749 (setq gnus-tmp-name gnus-tmp-from))
8750 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8751 (gnus-put-text-property
8753 (progn (eval gnus-summary-line-format-spec) (point))
8754 'gnus-number number)
8757 (run-hooks 'gnus-summary-update-hook)
8760 (setq gnus-tmp-prev-subject subject)))
8762 (when (nth 1 thread)
8763 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8764 (incf gnus-tmp-level)
8765 (setq threads (if thread-end nil (cdar thread)))
8767 (setq gnus-tmp-level 0)))))
8768 (gnus-message 7 "Generating summary...done"))
8770 (defun gnus-summary-prepare-unthreaded (headers)
8771 "Generate an unthreaded summary buffer based on HEADERS."
8772 (let (header number mark)
8775 ;; We may have to root out some bad articles...
8776 (when (memq (setq number (mail-header-number
8777 (setq header (pop headers))))
8778 gnus-newsgroup-limit)
8779 ;; Mark article as read when it has a low score.
8780 (when (and gnus-summary-mark-below
8781 (< (or (cdr (assq number gnus-newsgroup-scored))
8782 gnus-summary-default-score 0)
8783 gnus-summary-mark-below)
8784 (not (memq number gnus-newsgroup-ancient)))
8785 (setq gnus-newsgroup-unreads
8786 (delq number gnus-newsgroup-unreads))
8787 (if gnus-newsgroup-auto-expire
8788 (push number gnus-newsgroup-expirable)
8789 (push (cons number gnus-low-score-mark)
8790 gnus-newsgroup-reads)))
8794 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8795 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8796 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8797 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8798 (t (or (cdr (assq number gnus-newsgroup-reads))
8799 gnus-ancient-mark))))
8800 (setq gnus-newsgroup-data
8801 (cons (gnus-data-make number mark (1+ (point)) header 0)
8802 gnus-newsgroup-data))
8803 (gnus-summary-insert-line
8804 header 0 nil mark (memq number gnus-newsgroup-replied)
8805 (memq number gnus-newsgroup-expirable)
8806 (mail-header-subject header) nil
8807 (cdr (assq number gnus-newsgroup-scored))
8808 (memq number gnus-newsgroup-processable))))))
8810 (defun gnus-select-newsgroup (group &optional read-all)
8811 "Select newsgroup GROUP.
8812 If READ-ALL is non-nil, all articles in the group are selected."
8813 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8814 (info (nth 2 entry))
8815 articles fetched-articles cached)
8817 (or (gnus-check-server
8818 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8819 (error "Couldn't open server"))
8821 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8822 (gnus-activate-group group) ; Or we can activate it...
8823 (progn ; Or we bug out.
8824 (when (equal major-mode 'gnus-summary-mode)
8825 (kill-buffer (current-buffer)))
8826 (error "Couldn't request group %s: %s"
8827 group (gnus-status-message group))))
8829 (unless (gnus-request-group group t)
8830 (when (equal major-mode 'gnus-summary-mode)
8831 (kill-buffer (current-buffer)))
8832 (error "Couldn't request group %s: %s"
8833 group (gnus-status-message group)))
8835 (setq gnus-newsgroup-name group)
8836 (setq gnus-newsgroup-unselected nil)
8837 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8839 (and gnus-asynchronous
8840 (gnus-check-backend-function
8841 'request-asynchronous gnus-newsgroup-name)
8842 (setq gnus-newsgroup-async
8843 (gnus-request-asynchronous gnus-newsgroup-name)))
8845 ;; Adjust and set lists of article marks.
8847 (gnus-adjust-marked-articles info))
8849 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8850 (when (gnus-virtual-group-p group)
8851 (setq cached gnus-newsgroup-cached))
8853 (setq gnus-newsgroup-unreads
8854 (gnus-set-difference
8855 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8856 gnus-newsgroup-dormant))
8858 (setq gnus-newsgroup-processable nil)
8860 (setq articles (gnus-articles-to-read group read-all))
8864 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8866 ((eq articles 0) nil)
8868 ;; Init the dependencies hash table.
8869 (setq gnus-newsgroup-dependencies
8870 (gnus-make-hashtable (length articles)))
8871 ;; Retrieve the headers and read them in.
8872 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8873 (setq gnus-newsgroup-headers
8875 (setq gnus-headers-retrieved-by
8876 (gnus-retrieve-headers
8877 articles gnus-newsgroup-name
8878 ;; We might want to fetch old headers, but
8879 ;; not if there is only 1 article.
8880 (and gnus-fetch-old-headers
8882 (not (eq gnus-fetch-old-headers 'some))
8883 (not (numberp gnus-fetch-old-headers)))
8884 (> (length articles) 1))))))
8885 (gnus-get-newsgroup-headers-xover articles)
8886 (gnus-get-newsgroup-headers)))
8887 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8889 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8891 (setq gnus-newsgroup-cached cached))
8893 ;; Set the initial limit.
8894 (setq gnus-newsgroup-limit (copy-sequence articles))
8895 ;; Remove canceled articles from the list of unread articles.
8896 (setq gnus-newsgroup-unreads
8897 (gnus-set-sorted-intersection
8898 gnus-newsgroup-unreads
8899 (setq fetched-articles
8900 (mapcar (lambda (headers) (mail-header-number headers))
8901 gnus-newsgroup-headers))))
8902 ;; Removed marked articles that do not exist.
8903 (gnus-update-missing-marks
8904 (gnus-sorted-complement fetched-articles articles))
8905 ;; We might want to build some more threads first.
8906 (and gnus-fetch-old-headers
8907 (eq gnus-headers-retrieved-by 'nov)
8908 (gnus-build-old-threads))
8909 ;; Check whether auto-expire is to be done in this group.
8910 (setq gnus-newsgroup-auto-expire
8911 (gnus-group-auto-expirable-p group))
8912 ;; Set up the article buffer now, if necessary.
8913 (unless gnus-single-article-buffer
8914 (gnus-article-setup-buffer))
8915 ;; First and last article in this newsgroup.
8916 (when gnus-newsgroup-headers
8917 (setq gnus-newsgroup-begin
8918 (mail-header-number (car gnus-newsgroup-headers))
8921 (gnus-last-element gnus-newsgroup-headers))))
8922 ;; GROUP is successfully selected.
8923 (or gnus-newsgroup-headers t)))))
8925 (defun gnus-articles-to-read (group read-all)
8926 ;; Find out what articles the user wants to read.
8928 ;; Select all articles if `read-all' is non-nil, or if there
8929 ;; are no unread articles.
8931 (and (zerop (length gnus-newsgroup-marked))
8932 (zerop (length gnus-newsgroup-unreads))))
8933 (gnus-uncompress-range (gnus-active group))
8934 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8935 (copy-sequence gnus-newsgroup-unreads))
8937 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8938 (scored (length scored-list))
8939 (number (length articles))
8940 (marked (+ (length gnus-newsgroup-marked)
8941 (length gnus-newsgroup-dormant)))
8949 ((and (or (<= scored marked) (= scored number))
8950 (numberp gnus-large-newsgroup)
8951 (> number gnus-large-newsgroup))
8955 "How many articles from %s (default %d): "
8956 gnus-newsgroup-name number))))
8957 (if (string-match "^[ \t]*$" input) number input)))
8958 ((and (> scored marked) (< scored number)
8959 (> (- scored number) 20))
8962 (format "%s %s (%d scored, %d total): "
8963 "How many articles from"
8964 group scored number))))
8965 (if (string-match "^[ \t]*$" input)
8969 (setq select (if (stringp select) (string-to-number select) select))
8970 (if (or (null select) (zerop select))
8972 (if (and (not (zerop scored)) (<= (abs select) scored))
8974 (setq articles (sort scored-list '<))
8975 (setq number (length articles)))
8976 (setq articles (copy-sequence articles)))
8978 (if (< (abs select) number)
8980 ;; Select the N oldest articles.
8981 (setcdr (nthcdr (1- (abs select)) articles) nil)
8982 ;; Select the N most recent articles.
8983 (setq articles (nthcdr (- number select) articles))))
8984 (setq gnus-newsgroup-unselected
8985 (gnus-sorted-intersection
8986 gnus-newsgroup-unreads
8987 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8990 (defun gnus-killed-articles (killed articles)
8993 (if (inline (gnus-member-of-range (car articles) killed))
8994 (setq out (cons (car articles) out)))
8995 (setq articles (cdr articles)))
8998 (defun gnus-uncompress-marks (marks)
8999 "Uncompress the mark ranges in MARKS."
9000 (let ((uncompressed '(score bookmark))
9003 (if (memq (caar marks) uncompressed)
9004 (push (car marks) out)
9005 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
9006 (setq marks (cdr marks)))
9009 (defun gnus-adjust-marked-articles (info)
9010 "Set all article lists and remove all marks that are no longer legal."
9011 (let* ((marked-lists (gnus-info-marks info))
9012 (active (gnus-active (gnus-info-group info)))
9015 (types gnus-article-mark-lists)
9016 (uncompressed '(score bookmark killed))
9017 marks var articles article mark)
9020 (setq marks (pop marked-lists))
9021 (set (setq var (intern (format "gnus-newsgroup-%s"
9022 (car (rassq (setq mark (car marks))
9024 (if (memq (car marks) uncompressed) (cdr marks)
9025 (gnus-uncompress-range (cdr marks))))
9027 (setq articles (symbol-value var))
9029 ;; All articles have to be subsets of the active articles.
9031 ;; Adjust "simple" lists.
9032 ((memq mark '(tick dormant expirable reply save))
9034 (when (or (< (setq article (pop articles)) min) (> article max))
9035 (set var (delq article (symbol-value var))))))
9037 ((memq mark uncompressed)
9039 (when (or (not (consp (setq article (pop articles))))
9040 (< (car article) min)
9041 (> (car article) max))
9042 (set var (delq article (symbol-value var))))))))))
9044 (defun gnus-update-missing-marks (missing)
9045 "Go through the list of MISSING articles and remove them mark lists."
9047 (let ((types gnus-article-mark-lists)
9049 ;; Go through all types.
9051 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
9052 (when (symbol-value var)
9053 ;; This list has articles. So we delete all missing articles
9057 (set var (delq (pop m) (symbol-value var)))))))))
9059 (defun gnus-update-marks ()
9060 "Enter the various lists of marked articles into the newsgroup info list."
9061 (let ((types gnus-article-mark-lists)
9062 (info (gnus-get-info gnus-newsgroup-name))
9063 (uncompressed '(score bookmark killed))
9064 type list newmarked symbol)
9066 ;; Add all marks lists that are non-nil to the list of marks lists.
9068 (setq type (pop types))
9069 (when (setq list (symbol-value
9071 (intern (format "gnus-newsgroup-%s"
9073 (push (cons (cdr type)
9074 (if (memq (cdr type) uncompressed) list
9075 (gnus-compress-sequence
9076 (set symbol (sort list '<)) t)))
9079 ;; Enter these new marks into the info of the group.
9081 (setcar (nthcdr 3 info) newmarked)
9082 ;; Add the marks lists to the end of the info.
9084 (setcdr (nthcdr 2 info) (list newmarked))))
9086 ;; Cut off the end of the info if there's nothing else there.
9090 (when (nthcdr (decf i) info)
9091 (setcdr (nthcdr i info) nil)))))))
9093 (defun gnus-add-marked-articles (group type articles &optional info force)
9094 ;; Add ARTICLES of TYPE to the info of GROUP.
9095 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9096 ;; add, but replace marked articles of TYPE with ARTICLES.
9097 (let ((info (or info (gnus-get-info group)))
9098 (uncompressed '(score bookmark killed))
9101 (and (not (setq marked (nthcdr 3 info)))
9103 (setcdr (nthcdr 2 info)
9104 (list (list (cons type (gnus-compress-sequence
9106 (and (not (setq m (assq type (car marked))))
9109 (cons (cons type (gnus-compress-sequence articles t) )
9113 (setcar (nthcdr 3 info)
9114 (delq (assq type (car marked)) (car marked)))
9115 (setcdr m (gnus-compress-sequence articles t)))
9116 (setcdr m (gnus-compress-sequence
9117 (sort (nconc (gnus-uncompress-range (cdr m))
9118 (copy-sequence articles)) '<) t))))))
9120 (defun gnus-set-mode-line (where)
9121 "This function sets the mode line of the article or summary buffers.
9122 If WHERE is `summary', the summary mode line format will be used."
9123 ;; Is this mode line one we keep updated?
9124 (when (memq where gnus-updated-mode-lines)
9127 ;; We evaluate this in the summary buffer since these
9128 ;; variables are buffer-local to that buffer.
9129 (set-buffer gnus-summary-buffer)
9130 ;; We bind all these variables that are used in the `eval' form
9132 (let* ((mformat (symbol-value
9134 (format "gnus-%s-mode-line-format-spec" where))))
9135 (gnus-tmp-group-name gnus-newsgroup-name)
9136 (gnus-tmp-article-number (or gnus-current-article 0))
9137 (gnus-tmp-unread gnus-newsgroup-unreads)
9138 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9139 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9140 (gnus-tmp-unread-and-unselected
9141 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9142 (zerop gnus-tmp-unselected)) "")
9143 ((zerop gnus-tmp-unselected)
9144 (format "{%d more}" gnus-tmp-unread-and-unticked))
9145 (t (format "{%d(+%d) more}"
9146 gnus-tmp-unread-and-unticked
9147 gnus-tmp-unselected))))
9149 (if (and gnus-current-headers
9150 (vectorp gnus-current-headers))
9151 (gnus-mode-string-quote
9152 (mail-header-subject gnus-current-headers)) ""))
9154 gnus-tmp-header);; passed as argument to any user-format-funcs
9155 (setq mode-string (eval mformat))
9156 (setq max-len (max 4 (if gnus-mode-non-string-length
9158 gnus-mode-non-string-length)
9159 (length mode-string))))
9160 ;; We might have to chop a bit of the string off...
9161 (when (> (length mode-string) max-len)
9163 (concat (gnus-truncate-string mode-string (- max-len 3))
9165 ;; Pad the mode string a bit.
9166 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9167 ;; Update the mode line.
9168 (setq mode-line-buffer-identification
9169 (gnus-mode-line-buffer-identification
9170 (list mode-string)))
9171 (set-buffer-modified-p t))))
9173 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9174 "Go through the HEADERS list and add all Xrefs to a hash table.
9175 The resulting hash table is returned, or nil if no Xrefs were found."
9176 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9177 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9178 (xref-hashtb (make-vector 63 0))
9179 start group entry number xrefs header)
9181 (setq header (pop headers))
9182 (when (and (setq xrefs (mail-header-xref header))
9183 (not (memq (setq number (mail-header-number header))
9186 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9187 (setq start (match-end 0))
9188 (setq group (if prefix
9189 (concat prefix (substring xrefs (match-beginning 1)
9191 (substring xrefs (match-beginning 1) (match-end 1))))
9193 (string-to-int (substring xrefs (match-beginning 2)
9195 (if (setq entry (gnus-gethash group xref-hashtb))
9196 (setcdr entry (cons number (cdr entry)))
9197 (gnus-sethash group (cons number nil) xref-hashtb)))))
9198 (and start xref-hashtb)))
9200 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9201 "Look through all the headers and mark the Xrefs as read."
9202 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9203 name entry info xref-hashtb idlist method nth4)
9205 (set-buffer gnus-group-buffer)
9206 (when (setq xref-hashtb
9207 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9210 (unless (string= from-newsgroup (setq name (symbol-name group)))
9211 (setq idlist (symbol-value group))
9212 ;; Dead groups are not updated.
9214 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9216 (if (stringp (setq nth4 (gnus-info-method info)))
9217 (setq nth4 (gnus-server-to-method nth4))))
9218 ;; Only do the xrefs if the group has the same
9219 ;; select method as the group we have just read.
9220 (or (gnus-methods-equal-p
9221 nth4 (gnus-find-method-for-group from-newsgroup))
9223 (equal nth4 (setq method (gnus-find-method-for-group
9225 (and (equal (car nth4) (car method))
9226 (equal (nth 1 nth4) (nth 1 method))))
9227 gnus-use-cross-reference
9228 (or (not (eq gnus-use-cross-reference t))
9230 ;; Only do cross-references on subscribed
9231 ;; groups, if that is what is wanted.
9232 (<= (gnus-info-level info) gnus-level-subscribed))
9233 (gnus-group-make-articles-read name idlist))))
9236 (defun gnus-group-make-articles-read (group articles)
9238 (entry (gnus-gethash group gnus-newsrc-hashtb))
9239 (info (nth 2 entry))
9240 (active (gnus-active group))
9242 ;; First peel off all illegal article numbers.
9244 (let ((ids articles)
9248 (if (and first (> id (cdr active)))
9250 ;; We'll end up in this situation in one particular
9251 ;; obscure situation. If you re-scan a group and get
9252 ;; a new article that is cross-posted to a different
9253 ;; group that has not been re-scanned, you might get
9254 ;; crossposted article that has a higher number than
9255 ;; Gnus believes possible. So we re-activate this
9256 ;; group as well. This might mean doing the
9257 ;; crossposting thingy will *increase* the number
9258 ;; of articles in some groups. Tsk, tsk.
9259 (setq active (or (gnus-activate-group group) active))))
9260 (if (or (> id (cdr active))
9261 (< id (car active)))
9262 (setq articles (delq id articles)))
9263 (setq ids (cdr ids)))))
9264 ;; If the read list is nil, we init it.
9266 (null (gnus-info-read info))
9268 (gnus-info-set-read info (cons 1 (1- (car active)))))
9269 ;; Then we add the read articles to the range.
9274 (gnus-info-read info) (setq articles (sort articles '<)))))
9275 ;; Then we have to re-compute how many unread
9276 ;; articles there are in this group.
9281 (setq num (- (1+ (cdr active)) (car active))))
9282 ((not (listp (cdr range)))
9283 (setq num (- (cdr active) (- (1+ (cdr range))
9287 (if (numberp (car range))
9289 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9290 (setq range (cdr range)))
9291 (setq num (- (cdr active) num))))
9292 ;; Update the number of unread articles.
9294 ;; Update the group buffer.
9295 (gnus-group-update-group group t)))))
9297 (defun gnus-methods-equal-p (m1 m2)
9298 (let ((m1 (or m1 gnus-select-method))
9299 (m2 (or m2 gnus-select-method)))
9301 (and (eq (car m1) (car m2))
9302 (or (not (memq 'address (assoc (symbol-name (car m1))
9303 gnus-valid-select-methods)))
9304 (equal (nth 1 m1) (nth 1 m2)))))))
9306 (defsubst gnus-header-value ()
9307 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9309 (defvar gnus-newsgroup-none-id 0)
9311 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9312 (let ((cur nntp-server-buffer)
9315 (save-excursion (set-buffer gnus-summary-buffer)
9316 gnus-newsgroup-dependencies)))
9317 headers id id-dep ref-dep end ref)
9319 (set-buffer nntp-server-buffer)
9320 (run-hooks 'gnus-parse-headers-hook)
9321 (let ((case-fold-search t)
9322 in-reply-to header p lines)
9323 (goto-char (point-min))
9324 ;; Search to the beginning of the next header. Error messages
9325 ;; do not begin with 2 or 3.
9326 (while (re-search-forward "^[23][0-9]+ " nil t)
9329 ;; This implementation of this function, with nine
9330 ;; search-forwards instead of the one re-search-forward and
9331 ;; a case (which basically was the old function) is actually
9332 ;; about twice as fast, even though it looks messier. You
9333 ;; can't have everything, I guess. Speed and elegance
9334 ;; doesn't always go hand in hand.
9343 (narrow-to-region (point)
9344 (or (and (search-forward "\n.\n" nil t)
9350 (if (search-forward "\nsubject: " nil t)
9351 (gnus-header-value) "(none)"))
9355 (if (search-forward "\nfrom: " nil t)
9356 (gnus-header-value) "(nobody)"))
9360 (if (search-forward "\ndate: " nil t)
9361 (gnus-header-value) ""))
9365 (if (search-forward "\nmessage-id: " nil t)
9366 (setq id (gnus-header-value))
9367 ;; If there was no message-id, we just fake one to make
9368 ;; subsequent routines simpler.
9369 (setq id (concat "none+"
9371 (setq gnus-newsgroup-none-id
9372 (1+ gnus-newsgroup-none-id)))))))
9376 (if (search-forward "\nreferences: " nil t)
9385 (search-backward ">" end t)
9388 (search-backward "<" end t)
9390 ;; Get the references from the in-reply-to header if there
9391 ;; were no references and the in-reply-to header looks
9393 (if (and (search-forward "\nin-reply-to: " nil t)
9394 (setq in-reply-to (gnus-header-value))
9395 (string-match "<[^>]+>" in-reply-to))
9396 (setq ref (substring in-reply-to (match-beginning 0)
9404 (if (search-forward "\nlines: " nil t)
9405 (if (numberp (setq lines (read cur)))
9411 (and (search-forward "\nxref: " nil t)
9412 (gnus-header-value)))))
9413 ;; We do the threading while we read the headers. The
9414 ;; message-id and the last reference are both entered into
9415 ;; the same hash table. Some tippy-toeing around has to be
9416 ;; done in case an article has arrived before the article
9417 ;; which it refers to.
9418 (if (boundp (setq id-dep (intern id dependencies)))
9419 (if (and (car (symbol-value id-dep))
9421 ;; An article with this Message-ID has already
9422 ;; been seen, so we ignore this one, except we add
9423 ;; any additional Xrefs (in case the two articles
9424 ;; came from different servers).
9426 (mail-header-set-xref
9427 (car (symbol-value id-dep))
9428 (concat (or (mail-header-xref
9429 (car (symbol-value id-dep))) "")
9430 (or (mail-header-xref header) "")))
9432 (setcar (symbol-value id-dep) header))
9433 (set id-dep (list header)))
9435 (if (boundp (setq ref-dep (intern ref dependencies)))
9436 (setcdr (symbol-value ref-dep)
9437 (nconc (cdr (symbol-value ref-dep))
9438 (list (symbol-value id-dep))))
9439 (set ref-dep (list nil (symbol-value id-dep))))
9440 (setq headers (cons header headers)))
9441 (goto-char (point-max))
9443 (nreverse headers)))))
9445 ;; The following macros and functions were written by Felix Lee
9446 ;; <flee@cse.psu.edu>.
9448 (defmacro gnus-nov-read-integer ()
9450 (if (= (following-char) ?\t)
9452 (let ((num (condition-case nil (read buffer) (error nil))))
9453 (if (numberp num) num 0)))
9454 (or (eobp) (forward-char 1))))
9456 (defmacro gnus-nov-skip-field ()
9457 '(search-forward "\t" eol 'move))
9459 (defmacro gnus-nov-field ()
9460 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9462 ;; Goes through the xover lines and returns a list of vectors
9463 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9464 force-new dependencies)
9465 "Parse the news overview data in the server buffer, and return a
9466 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9467 ;; Get the Xref when the users reads the articles since most/some
9468 ;; NNTP servers do not include Xrefs when using XOVER.
9469 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9470 (let ((cur nntp-server-buffer)
9471 (dependencies (or dependencies gnus-newsgroup-dependencies))
9472 number headers header)
9474 (set-buffer nntp-server-buffer)
9475 ;; Allow the user to mangle the headers before parsing them.
9476 (run-hooks 'gnus-parse-headers-hook)
9477 (goto-char (point-min))
9478 (while (and sequence (not (eobp)))
9479 (setq number (read cur))
9480 (while (and sequence (< (car sequence) number))
9481 (setq sequence (cdr sequence)))
9483 (eq number (car sequence))
9485 (setq sequence (cdr sequence))
9487 (inline (gnus-nov-parse-line
9488 number dependencies force-new)))
9489 (setq headers (cons header headers)))))
9491 (setq headers (nreverse headers)))
9494 ;; This function has to be called with point after the article number
9495 ;; on the beginning of the line.
9496 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9498 (eol (gnus-point-at-eol))
9499 (buffer (current-buffer))
9500 header ref id id-dep ref-dep)
9502 ;; overview: [num subject from date id refs chars lines misc]
9503 (narrow-to-region (point) eol)
9504 (or (eobp) (forward-char))
9510 (gnus-nov-field) ; subject
9511 (gnus-nov-field) ; from
9512 (gnus-nov-field) ; date
9513 (setq id (or (gnus-nov-field)
9516 (setq none (1+ none)))))) ; id
9519 (let ((beg (point)))
9520 (search-forward "\t" eol)
9521 (if (search-backward ">" beg t)
9525 (search-backward "<" beg t)))
9527 (gnus-nov-field)) ; refs
9528 (gnus-nov-read-integer) ; chars
9529 (gnus-nov-read-integer) ; lines
9530 (if (= (following-char) ?\n)
9532 (gnus-nov-field)) ; misc
9535 (gnus-error 4 "Strange nov line")
9541 ;; We build the thread tree.
9543 (if (boundp (setq id-dep (intern id dependencies)))
9544 (if (and (car (symbol-value id-dep))
9546 ;; An article with this Message-ID has already been seen,
9547 ;; so we ignore this one, except we add any additional
9548 ;; Xrefs (in case the two articles came from different
9551 (mail-header-set-xref
9552 (car (symbol-value id-dep))
9553 (concat (or (mail-header-xref
9554 (car (symbol-value id-dep))) "")
9555 (or (mail-header-xref header) "")))
9557 (setcar (symbol-value id-dep) header))
9558 (set id-dep (list header))))
9560 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9561 (setcdr (symbol-value ref-dep)
9562 (nconc (cdr (symbol-value ref-dep))
9563 (list (symbol-value id-dep))))
9564 (set ref-dep (list nil (symbol-value id-dep)))))
9567 (defun gnus-article-get-xrefs ()
9568 "Fill in the Xref value in `gnus-current-headers', if necessary.
9569 This is meant to be called in `gnus-article-internal-prepare-hook'."
9570 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9571 gnus-current-headers)))
9572 (or (not gnus-use-cross-reference)
9574 (and (mail-header-xref headers)
9575 (not (string= (mail-header-xref headers) "")))
9576 (let ((case-fold-search t)
9579 (nnheader-narrow-to-headers)
9580 (goto-char (point-min))
9581 (if (or (and (eq (downcase (following-char)) ?x)
9582 (looking-at "Xref:"))
9583 (search-forward "\nXref:" nil t))
9585 (goto-char (1+ (match-end 0)))
9586 (setq xref (buffer-substring (point)
9587 (progn (end-of-line) (point))))
9588 (mail-header-set-xref headers xref))))))))
9590 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9591 "Find article ID and insert the summary line for that article."
9592 (let ((header (if (and old-header use-old-header)
9593 old-header (gnus-read-header id)))
9594 (number (and (numberp id) id))
9597 ;; Rebuild the thread that this article is part of and go to the
9598 ;; article we have fetched.
9599 (when (and (not gnus-show-threads)
9601 (when (setq pos (text-property-any
9602 (point-min) (point-max) 'gnus-number
9603 (mail-header-number old-header)))
9606 (gnus-data-remove (mail-header-number old-header))))
9608 (mail-header-set-number header (mail-header-number old-header)))
9609 (setq gnus-newsgroup-sparse
9610 (delq (setq number (mail-header-number header))
9611 gnus-newsgroup-sparse))
9612 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9613 (gnus-rebuild-thread (mail-header-id header))
9614 (gnus-summary-goto-subject number nil t))
9615 (when (and (numberp number)
9617 ;; We have to update the boundaries even if we can't fetch the
9618 ;; article if ID is a number -- so that the next `P' or `N'
9619 ;; command will fetch the previous (or next) article even
9620 ;; if the one we tried to fetch this time has been canceled.
9621 (and (> number gnus-newsgroup-end)
9622 (setq gnus-newsgroup-end number))
9623 (and (< number gnus-newsgroup-begin)
9624 (setq gnus-newsgroup-begin number))
9625 (setq gnus-newsgroup-unselected
9626 (delq number gnus-newsgroup-unselected)))
9627 ;; Report back a success?
9628 (and header (mail-header-number header))))
9630 (defun gnus-summary-work-articles (n)
9631 "Return a list of articles to be worked upon. The prefix argument,
9632 the list of process marked articles, and the current article will be
9633 taken into consideration."
9636 ;; A numerical prefix has been given.
9637 (let ((backward (< n 0))
9638 (n (abs (prefix-numeric-value n)))
9643 (push (setq article (gnus-summary-article-number))
9646 (gnus-summary-find-prev nil article)
9647 (gnus-summary-find-next nil article)))
9649 (nreverse articles)))
9650 ((and (boundp 'transient-mark-mode)
9653 ;; Work on the region between point and mark.
9654 (let ((max (max (point) (mark)))
9657 (goto-char (min (point) (mark)))
9660 (push (setq article (gnus-summary-article-number)) articles)
9661 (gnus-summary-find-next nil article)
9663 (nreverse articles))))
9664 (gnus-newsgroup-processable
9665 ;; There are process-marked articles present.
9666 (reverse gnus-newsgroup-processable))
9668 ;; Just return the current article.
9669 (list (gnus-summary-article-number)))))
9671 (defun gnus-summary-search-group (&optional backward use-level)
9672 "Search for next unread newsgroup.
9673 If optional argument BACKWARD is non-nil, search backward instead."
9675 (set-buffer gnus-group-buffer)
9676 (if (gnus-group-search-forward
9677 backward nil (if use-level (gnus-group-group-level) nil))
9678 (gnus-group-group-name))))
9680 (defun gnus-summary-best-group (&optional exclude-group)
9681 "Find the name of the best unread group.
9682 If EXCLUDE-GROUP, do not go to this group."
9684 (set-buffer gnus-group-buffer)
9686 (gnus-group-best-unread-group exclude-group))))
9688 (defun gnus-summary-find-next (&optional unread article backward)
9689 (if backward (gnus-summary-find-prev)
9690 (let* ((dummy (gnus-summary-article-intangible-p))
9691 (article (or article (gnus-summary-article-number)))
9692 (arts (gnus-data-find-list article))
9694 (when (and (not dummy)
9695 (or (not gnus-summary-check-current)
9697 (not (gnus-data-unread-p (car arts)))))
9698 (setq arts (cdr arts)))
9703 (when (gnus-data-unread-p (car arts))
9704 (setq result (car arts)
9706 (setq arts (cdr arts)))
9709 (goto-char (gnus-data-pos result))
9710 (gnus-data-number result)))))
9712 (defun gnus-summary-find-prev (&optional unread article)
9713 (let* ((eobp (eobp))
9714 (article (or article (gnus-summary-article-number)))
9715 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9717 (when (and (not eobp)
9718 (or (not gnus-summary-check-current)
9720 (not (gnus-data-unread-p (car arts)))))
9721 (setq arts (cdr arts)))
9726 (and (gnus-data-unread-p (car arts))
9727 (setq result (car arts)
9729 (setq arts (cdr arts)))
9733 (goto-char (gnus-data-pos result))
9734 (gnus-data-number result)))))
9736 (defun gnus-summary-find-subject (subject &optional unread backward article)
9737 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9738 (article (or article (gnus-summary-article-number)))
9739 (articles (gnus-data-list backward))
9740 (arts (gnus-data-find-list article articles))
9742 (when (or (not gnus-summary-check-current)
9744 (not (gnus-data-unread-p (car arts))))
9745 (setq arts (cdr arts)))
9747 (and (or (not unread)
9748 (gnus-data-unread-p (car arts)))
9749 (vectorp (gnus-data-header (car arts)))
9751 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9752 (setq result (car arts)
9754 (setq arts (cdr arts)))
9756 (goto-char (gnus-data-pos result))
9757 (gnus-data-number result))))
9759 (defun gnus-summary-search-forward (&optional unread subject backward)
9760 "Search forward for an article.
9761 If UNREAD, look for unread articles. If SUBJECT, look for
9762 articles with that subject. If BACKWARD, search backward instead."
9763 (cond (subject (gnus-summary-find-subject subject unread backward))
9764 (backward (gnus-summary-find-prev unread))
9765 (t (gnus-summary-find-next unread))))
9767 (defun gnus-recenter (&optional n)
9768 "Center point in window and redisplay frame.
9769 Also do horizontal recentering."
9771 (when (and gnus-auto-center-summary
9772 (not (eq gnus-auto-center-summary 'vertical)))
9773 (gnus-horizontal-recenter))
9776 (defun gnus-summary-recenter ()
9777 "Center point in the summary window.
9778 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9779 displayed, no centering will be performed."
9780 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9781 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9782 (let* ((top (cond ((< (window-height) 4) 0)
9783 ((< (window-height) 7) 1)
9785 (height (1- (window-height)))
9786 (bottom (save-excursion (goto-char (point-max))
9787 (forward-line (- height))
9789 (window (get-buffer-window (current-buffer))))
9790 ;; The user has to want it.
9791 (when gnus-auto-center-summary
9792 (when (get-buffer-window gnus-article-buffer)
9793 ;; Only do recentering when the article buffer is displayed,
9794 ;; Set the window start to either `bottom', which is the biggest
9795 ;; possible valid number, or the second line from the top,
9796 ;; whichever is the least.
9798 window (min bottom (save-excursion
9799 (forward-line (- top)) (point)))))
9800 ;; Do horizontal recentering while we're at it.
9801 (when (and (get-buffer-window (current-buffer) t)
9802 (not (eq gnus-auto-center-summary 'vertical)))
9803 (let ((selected (selected-window)))
9804 (select-window (get-buffer-window (current-buffer) t))
9805 (gnus-summary-position-point)
9806 (gnus-horizontal-recenter)
9807 (select-window selected))))))
9809 (defun gnus-horizontal-recenter ()
9810 "Recenter the current buffer horizontally."
9811 (if (< (current-column) (/ (window-width) 2))
9812 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9813 (let* ((orig (point))
9814 (end (window-end (get-buffer-window (current-buffer) t)))
9816 ;; Find the longest line currently displayed in the window.
9817 (goto-char (window-start))
9818 (while (and (not (eobp))
9821 (setq max (max max (current-column)))
9824 ;; Scroll horizontally to center (sort of) the point.
9825 (if (> max (window-width))
9827 (get-buffer-window (current-buffer) t)
9828 (min (- (current-column) (/ (window-width) 3))
9829 (+ 2 (- max (window-width)))))
9830 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9833 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9834 (defun gnus-short-group-name (group &optional levels)
9835 "Collapse GROUP name LEVELS."
9842 (while (string-match "\\." group skip)
9843 (setq skip (match-end 0)
9846 (if (string-match ":" group)
9847 (setq foreign (substring group 0 (match-end 0))
9848 group (substring group (match-end 0))))
9850 (if (and (string-match "\\." group)
9851 (> levels (- gnus-group-uncollapsed-levels 1)))
9852 (setq name (concat name (substring group 0 1))
9853 group (substring group (match-end 0))
9855 name (concat name "."))
9856 (setq name (concat foreign name group)
9860 (defun gnus-summary-jump-to-group (newsgroup)
9861 "Move point to NEWSGROUP in group mode buffer."
9862 ;; Keep update point of group mode buffer if visible.
9863 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9864 (save-window-excursion
9865 ;; Take care of tree window mode.
9866 (if (get-buffer-window gnus-group-buffer)
9867 (pop-to-buffer gnus-group-buffer))
9868 (gnus-group-jump-to-group newsgroup))
9870 ;; Take care of tree window mode.
9871 (if (get-buffer-window gnus-group-buffer)
9872 (pop-to-buffer gnus-group-buffer)
9873 (set-buffer gnus-group-buffer))
9874 (gnus-group-jump-to-group newsgroup))))
9876 ;; This function returns a list of article numbers based on the
9877 ;; difference between the ranges of read articles in this group and
9878 ;; the range of active articles.
9879 (defun gnus-list-of-unread-articles (group)
9880 (let* ((read (gnus-info-read (gnus-get-info group)))
9881 (active (gnus-active group))
9884 ;; If none are read, then all are unread.
9886 (setq first (car active))
9887 ;; If the range of read articles is a single range, then the
9888 ;; first unread article is the article after the last read
9889 ;; article. Sounds logical, doesn't it?
9890 (if (not (listp (cdr read)))
9891 (setq first (1+ (cdr read)))
9892 ;; `read' is a list of ranges.
9893 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9898 (while (< first nlast)
9899 (setq unread (cons first unread))
9900 (setq first (1+ first))))
9901 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9902 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9903 (setq read (cdr read)))))
9904 ;; And add the last unread articles.
9905 (while (<= first last)
9906 (setq unread (cons first unread))
9907 (setq first (1+ first)))
9908 ;; Return the list of unread articles.
9911 (defun gnus-list-of-read-articles (group)
9912 "Return a list of unread, unticked and non-dormant articles."
9913 (let* ((info (gnus-get-info group))
9914 (marked (gnus-info-marks info))
9915 (active (gnus-active group)))
9917 (gnus-set-difference
9918 (gnus-sorted-complement
9919 (gnus-uncompress-range active)
9920 (gnus-list-of-unread-articles group))
9922 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9923 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9925 ;; Various summary commands
9927 (defun gnus-summary-universal-argument (arg)
9928 "Perform any operation on all articles that are process/prefixed."
9930 (gnus-set-global-variables)
9931 (let ((articles (gnus-summary-work-articles arg))
9938 (substitute-command-keys
9939 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9942 (gnus-error 1 "Undefined key")
9945 (gnus-summary-goto-subject (setq article (pop articles)))
9946 (command-execute func)
9947 (gnus-summary-remove-process-mark article)))))
9948 (gnus-summary-position-point))
9950 (defun gnus-summary-toggle-truncation (&optional arg)
9951 "Toggle truncation of summary lines.
9952 With arg, turn line truncation on iff arg is positive."
9954 (setq truncate-lines
9955 (if (null arg) (not truncate-lines)
9956 (> (prefix-numeric-value arg) 0)))
9959 (defun gnus-summary-reselect-current-group (&optional all rescan)
9960 "Exit and then reselect the current newsgroup.
9961 The prefix argument ALL means to select all articles."
9963 (gnus-set-global-variables)
9964 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9965 (error "Ephemeral groups can't be reselected"))
9966 (let ((current-subject (gnus-summary-article-number))
9967 (group gnus-newsgroup-name))
9968 (setq gnus-newsgroup-begin nil)
9970 ;; We have to adjust the point of group mode buffer because the
9971 ;; current point was moved to the next unread newsgroup by
9973 (gnus-summary-jump-to-group group)
9976 (gnus-group-get-new-news-this-group 1)))
9977 (gnus-group-read-group all t)
9978 (gnus-summary-goto-subject current-subject nil t)))
9980 (defun gnus-summary-rescan-group (&optional all)
9981 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9983 (gnus-summary-reselect-current-group all t))
9985 (defun gnus-summary-update-info ()
9986 (let* ((group gnus-newsgroup-name))
9987 (when gnus-newsgroup-kill-headers
9988 (setq gnus-newsgroup-killed
9989 (gnus-compress-sequence
9991 (gnus-set-sorted-intersection
9992 (gnus-uncompress-range gnus-newsgroup-killed)
9993 (setq gnus-newsgroup-unselected
9994 (sort gnus-newsgroup-unselected '<)))
9995 (setq gnus-newsgroup-unreads
9996 (sort gnus-newsgroup-unreads '<))) t)))
9997 (unless (listp (cdr gnus-newsgroup-killed))
9998 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9999 (let ((headers gnus-newsgroup-headers))
10000 (run-hooks 'gnus-exit-group-hook)
10001 (unless gnus-save-score
10002 (setq gnus-newsgroup-scored nil))
10003 ;; Set the new ranges of read articles.
10004 (gnus-update-read-articles
10005 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
10006 ;; Set the current article marks.
10007 (gnus-update-marks)
10008 ;; Do the cross-ref thing.
10009 (when gnus-use-cross-reference
10010 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
10011 ;; Do adaptive scoring, and possibly save score files.
10012 (when gnus-newsgroup-adaptive
10013 (gnus-score-adaptive))
10014 (when gnus-use-scoring
10016 ;; Do not switch windows but change the buffer to work.
10017 (set-buffer gnus-group-buffer)
10018 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10019 (gnus-group-update-group group)))))
10021 (defun gnus-summary-exit (&optional temporary)
10022 "Exit reading current newsgroup, and then return to group selection mode.
10023 gnus-exit-group-hook is called with no arguments if that value is non-nil."
10025 (gnus-set-global-variables)
10026 (gnus-kill-save-kill-buffer)
10027 (let* ((group gnus-newsgroup-name)
10028 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
10030 (buf (current-buffer)))
10031 (run-hooks 'gnus-summary-prepare-exit-hook)
10032 ;; If we have several article buffers, we kill them at exit.
10033 (unless gnus-single-article-buffer
10034 (gnus-kill-buffer gnus-original-article-buffer)
10035 (setq gnus-article-current nil))
10036 (when gnus-use-cache
10037 (gnus-cache-possibly-remove-articles)
10038 (gnus-cache-save-buffers))
10039 (when gnus-use-trees
10040 (gnus-tree-close group))
10041 ;; Make all changes in this group permanent.
10042 (unless quit-config
10043 (gnus-summary-update-info))
10044 (gnus-close-group group)
10045 ;; Make sure where I was, and go to next newsgroup.
10046 (set-buffer gnus-group-buffer)
10047 (unless quit-config
10048 (gnus-group-jump-to-group group))
10049 (run-hooks 'gnus-summary-exit-hook)
10050 (unless quit-config
10051 (gnus-group-next-unread-group 1))
10053 nil ;Nothing to do.
10054 ;; If we have several article buffers, we kill them at exit.
10055 (unless gnus-single-article-buffer
10056 (gnus-kill-buffer gnus-article-buffer)
10057 (gnus-kill-buffer gnus-original-article-buffer)
10058 (setq gnus-article-current nil))
10060 (if (not gnus-kill-summary-on-exit)
10061 (gnus-deaden-summary)
10062 ;; We set all buffer-local variables to nil. It is unclear why
10063 ;; this is needed, but if we don't, buffer-local variables are
10064 ;; not garbage-collected, it seems. This would the lead to en
10065 ;; ever-growing Emacs.
10066 (gnus-summary-clear-local-variables)
10067 (when (get-buffer gnus-article-buffer)
10068 (bury-buffer gnus-article-buffer))
10069 ;; We clear the global counterparts of the buffer-local
10070 ;; variables as well, just to be on the safe side.
10071 (gnus-configure-windows 'group 'force)
10072 (gnus-summary-clear-local-variables)
10073 ;; Return to group mode buffer.
10074 (if (eq mode 'gnus-summary-mode)
10075 (gnus-kill-buffer buf)))
10076 (setq gnus-current-select-method gnus-select-method)
10077 (pop-to-buffer gnus-group-buffer)
10078 ;; Clear the current group name.
10079 (if (not quit-config)
10081 (gnus-group-jump-to-group group)
10082 (gnus-group-next-unread-group 1)
10083 (gnus-configure-windows 'group 'force))
10084 (if (not (buffer-name (car quit-config)))
10085 (gnus-configure-windows 'group 'force)
10086 (set-buffer (car quit-config))
10087 (and (eq major-mode 'gnus-summary-mode)
10088 (gnus-set-global-variables))
10089 (gnus-configure-windows (cdr quit-config))))
10090 (unless quit-config
10091 (setq gnus-newsgroup-name nil)))))
10093 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10094 (defun gnus-summary-exit-no-update (&optional no-questions)
10095 "Quit reading current newsgroup without updating read article info."
10097 (gnus-set-global-variables)
10098 (let* ((group gnus-newsgroup-name)
10099 (quit-config (gnus-group-quit-config group)))
10100 (when (or no-questions
10102 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10103 ;; If we have several article buffers, we kill them at exit.
10104 (unless gnus-single-article-buffer
10105 (gnus-kill-buffer gnus-article-buffer)
10106 (gnus-kill-buffer gnus-original-article-buffer)
10107 (setq gnus-article-current nil))
10108 (if (not gnus-kill-summary-on-exit)
10109 (gnus-deaden-summary)
10110 (gnus-close-group group)
10111 (gnus-summary-clear-local-variables)
10112 (set-buffer gnus-group-buffer)
10113 (gnus-summary-clear-local-variables)
10114 (when (get-buffer gnus-summary-buffer)
10115 (kill-buffer gnus-summary-buffer)))
10116 (unless gnus-single-article-buffer
10117 (setq gnus-article-current nil))
10118 (when gnus-use-trees
10119 (gnus-tree-close group))
10120 (when (get-buffer gnus-article-buffer)
10121 (bury-buffer gnus-article-buffer))
10122 ;; Return to the group buffer.
10123 (gnus-configure-windows 'group 'force)
10124 ;; Clear the current group name.
10125 (setq gnus-newsgroup-name nil)
10126 (when (equal (gnus-group-group-name) group)
10127 (gnus-group-next-unread-group 1))
10129 (if (not (buffer-name (car quit-config)))
10130 (gnus-configure-windows 'group 'force)
10131 (set-buffer (car quit-config))
10132 (when (eq major-mode 'gnus-summary-mode)
10133 (gnus-set-global-variables))
10134 (gnus-configure-windows (cdr quit-config)))))))
10136 ;;; Dead summaries.
10138 (defvar gnus-dead-summary-mode-map nil)
10140 (if gnus-dead-summary-mode-map
10142 (setq gnus-dead-summary-mode-map (make-keymap))
10143 (suppress-keymap gnus-dead-summary-mode-map)
10144 (substitute-key-definition
10145 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10146 (let ((keys '("\C-d" "\r" "\177")))
10148 (define-key gnus-dead-summary-mode-map
10149 (pop keys) 'gnus-summary-wake-up-the-dead))))
10151 (defvar gnus-dead-summary-mode nil
10152 "Minor mode for Gnus summary buffers.")
10154 (defun gnus-dead-summary-mode (&optional arg)
10155 "Minor mode for Gnus summary buffers."
10157 (when (eq major-mode 'gnus-summary-mode)
10158 (make-local-variable 'gnus-dead-summary-mode)
10159 (setq gnus-dead-summary-mode
10160 (if (null arg) (not gnus-dead-summary-mode)
10161 (> (prefix-numeric-value arg) 0)))
10162 (when gnus-dead-summary-mode
10163 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10164 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10165 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10166 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10167 minor-mode-map-alist)))))
10169 (defun gnus-deaden-summary ()
10170 "Make the current summary buffer into a dead summary buffer."
10171 ;; Kill any previous dead summary buffer.
10172 (when (and gnus-dead-summary
10173 (buffer-name gnus-dead-summary))
10175 (set-buffer gnus-dead-summary)
10176 (when gnus-dead-summary-mode
10177 (kill-buffer (current-buffer)))))
10178 ;; Make this the current dead summary.
10179 (setq gnus-dead-summary (current-buffer))
10180 (gnus-dead-summary-mode 1)
10181 (let ((name (buffer-name)))
10182 (when (string-match "Summary" name)
10184 (concat (substring name 0 (match-beginning 0)) "Dead "
10185 (substring name (match-beginning 0))) t))))
10187 (defun gnus-kill-or-deaden-summary (buffer)
10188 "Kill or deaden the summary BUFFER."
10189 (when (and (buffer-name buffer)
10190 (not gnus-single-article-buffer))
10192 (set-buffer buffer)
10193 (gnus-kill-buffer gnus-article-buffer)
10194 (gnus-kill-buffer gnus-original-article-buffer)))
10195 (cond (gnus-kill-summary-on-exit
10196 (when (and gnus-use-trees
10197 (and (get-buffer buffer)
10198 (buffer-name (get-buffer buffer))))
10200 (set-buffer (get-buffer buffer))
10201 (gnus-tree-close gnus-newsgroup-name)))
10202 (gnus-kill-buffer buffer))
10203 ((and (get-buffer buffer)
10204 (buffer-name (get-buffer buffer)))
10206 (set-buffer buffer)
10207 (gnus-deaden-summary)))))
10209 (defun gnus-summary-wake-up-the-dead (&rest args)
10210 "Wake up the dead summary buffer."
10212 (gnus-dead-summary-mode -1)
10213 (let ((name (buffer-name)))
10214 (when (string-match "Dead " name)
10216 (concat (substring name 0 (match-beginning 0))
10217 (substring name (match-end 0))) t)))
10218 (gnus-message 3 "This dead summary is now alive again"))
10220 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10221 (defun gnus-summary-fetch-faq (&optional faq-dir)
10222 "Fetch the FAQ for the current group.
10223 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10227 (if current-prefix-arg
10229 "Faq dir: " (and (listp gnus-group-faq-directory)
10230 gnus-group-faq-directory)))))
10231 (let (gnus-faq-buffer)
10232 (and (setq gnus-faq-buffer
10233 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10234 (gnus-configure-windows 'summary-faq))))
10236 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10237 (defun gnus-summary-describe-group (&optional force)
10238 "Describe the current newsgroup."
10240 (gnus-group-describe-group force gnus-newsgroup-name))
10242 (defun gnus-summary-describe-briefly ()
10243 "Describe summary mode commands briefly."
10246 (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")))
10248 ;; Walking around group mode buffer from summary mode.
10250 (defun gnus-summary-next-group (&optional no-article target-group backward)
10251 "Exit current newsgroup and then select next unread newsgroup.
10252 If prefix argument NO-ARTICLE is non-nil, no article is selected
10253 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10254 previous group instead."
10256 (gnus-set-global-variables)
10257 (let ((current-group gnus-newsgroup-name)
10258 (current-buffer (current-buffer))
10260 ;; First we semi-exit this group to update Xrefs and all variables.
10261 ;; We can't do a real exit, because the window conf must remain
10262 ;; the same in case the user is prompted for info, and we don't
10263 ;; want the window conf to change before that...
10264 (gnus-summary-exit t)
10265 (while (not entered)
10266 ;; Then we find what group we are supposed to enter.
10267 (set-buffer gnus-group-buffer)
10268 (gnus-group-jump-to-group current-group)
10271 (if (eq gnus-keep-same-level 'best)
10272 (gnus-summary-best-group gnus-newsgroup-name)
10273 (gnus-summary-search-group backward gnus-keep-same-level))))
10274 (if (not target-group)
10275 ;; There are no further groups, so we return to the group
10278 (gnus-message 5 "Returning to the group buffer")
10280 (set-buffer current-buffer)
10281 (gnus-summary-exit))
10282 ;; We try to enter the target group.
10283 (gnus-group-jump-to-group target-group)
10284 (let ((unreads (gnus-group-group-unread)))
10285 (if (and (or (eq t unreads)
10286 (and unreads (not (zerop unreads))))
10287 (gnus-summary-read-group
10288 target-group nil no-article current-buffer))
10290 (setq current-group target-group
10291 target-group nil)))))))
10293 (defun gnus-summary-prev-group (&optional no-article)
10294 "Exit current newsgroup and then select previous unread newsgroup.
10295 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10297 (gnus-summary-next-group no-article nil t))
10299 ;; Walking around summary lines.
10301 (defun gnus-summary-first-subject (&optional unread)
10302 "Go to the first unread subject.
10303 If UNREAD is non-nil, go to the first unread article.
10304 Returns the article selected or nil if there are no unread articles."
10309 ((null gnus-newsgroup-data)
10310 (gnus-message 3 "No articles in the group")
10312 ;; Pick the first article.
10314 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10315 (gnus-data-number (car gnus-newsgroup-data)))
10316 ;; No unread articles.
10317 ((null gnus-newsgroup-unreads)
10318 (gnus-message 3 "No more unread articles")
10320 ;; Find the first unread article.
10322 (let ((data gnus-newsgroup-data))
10324 (not (gnus-data-unread-p (car data))))
10325 (setq data (cdr data)))
10328 (goto-char (gnus-data-pos (car data)))
10329 (gnus-data-number (car data)))))))
10330 (gnus-summary-position-point)))
10332 (defun gnus-summary-next-subject (n &optional unread dont-display)
10333 "Go to next N'th summary line.
10334 If N is negative, go to the previous N'th subject line.
10335 If UNREAD is non-nil, only unread articles are selected.
10336 The difference between N and the actual number of steps taken is
10339 (let ((backward (< n 0))
10341 (while (and (> n 0)
10343 (gnus-summary-find-prev unread)
10344 (gnus-summary-find-next unread)))
10346 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10347 (if unread " unread" "")))
10348 (unless dont-display
10349 (gnus-summary-recenter)
10350 (gnus-summary-position-point))
10353 (defun gnus-summary-next-unread-subject (n)
10354 "Go to next N'th unread summary line."
10356 (gnus-summary-next-subject n t))
10358 (defun gnus-summary-prev-subject (n &optional unread)
10359 "Go to previous N'th summary line.
10360 If optional argument UNREAD is non-nil, only unread article is selected."
10362 (gnus-summary-next-subject (- n) unread))
10364 (defun gnus-summary-prev-unread-subject (n)
10365 "Go to previous N'th unread summary line."
10367 (gnus-summary-next-subject (- n) t))
10369 (defun gnus-summary-goto-subject (article &optional force silent)
10370 "Go the subject line of ARTICLE.
10371 If FORCE, also allow jumping to articles not currently shown."
10373 (data (gnus-data-find article)))
10374 ;; We read in the article if we have to.
10377 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10378 (setq data (gnus-data-find article)))
10383 (gnus-message 3 "Can't find article %d" article))
10385 (goto-char (gnus-data-pos data))
10388 ;; Walking around summary lines with displaying articles.
10390 (defun gnus-summary-expand-window (&optional arg)
10391 "Make the summary buffer take up the entire Emacs frame.
10392 Given a prefix, will force an `article' buffer configuration."
10394 (gnus-set-global-variables)
10396 (gnus-configure-windows 'article 'force)
10397 (gnus-configure-windows 'summary 'force)))
10399 (defun gnus-summary-display-article (article &optional all-header)
10400 "Display ARTICLE in article buffer."
10401 (gnus-set-global-variables)
10405 (if gnus-summary-display-article-function
10406 (funcall gnus-summary-display-article-function article all-header)
10407 (gnus-article-prepare article all-header))
10408 (run-hooks 'gnus-select-article-hook)
10409 (unless (zerop gnus-current-article)
10410 (gnus-summary-goto-subject gnus-current-article))
10411 (gnus-summary-recenter)
10412 (when gnus-use-trees
10413 (gnus-possibly-generate-tree article)
10414 (gnus-highlight-selected-tree article))
10415 ;; Successfully display article.
10416 (gnus-article-set-window-start
10417 (cdr (assq article gnus-newsgroup-bookmarks))))))
10419 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10420 "Select the current article.
10421 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10422 non-nil, the article will be re-fetched even if it already present in
10423 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10425 ;; Make sure we are in the summary buffer to work around bbdb bug.
10426 (unless (eq major-mode 'gnus-summary-mode)
10427 (set-buffer gnus-summary-buffer))
10428 (let ((article (or article (gnus-summary-article-number)))
10429 (all-headers (not (not all-headers))) ;Must be T or NIL.
10430 gnus-summary-display-article-function
10433 (gnus-summary-article-pseudo-p article)
10434 (error "This is a pseudo-article."))
10437 (set-buffer gnus-summary-buffer)
10438 (if (or (and gnus-single-article-buffer
10439 (or (null gnus-current-article)
10440 (null gnus-article-current)
10441 (null (get-buffer gnus-article-buffer))
10442 (not (eq article (cdr gnus-article-current)))
10443 (not (equal (car gnus-article-current)
10444 gnus-newsgroup-name))))
10445 (and (not gnus-single-article-buffer)
10446 (or (null gnus-current-article)
10447 (not (eq gnus-current-article article))))
10449 ;; The requested article is different from the current article.
10451 (gnus-summary-display-article article all-headers)
10452 (setq did article))
10453 (if (or all-headers gnus-show-all-headers)
10454 (gnus-article-show-all-headers))
10457 (gnus-article-set-window-start
10458 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10460 (defun gnus-summary-set-current-mark (&optional current-mark)
10461 "Obsolete function."
10464 (defun gnus-summary-next-article (&optional unread subject backward push)
10465 "Select the next article.
10466 If UNREAD, only unread articles are selected.
10467 If SUBJECT, only articles with SUBJECT are selected.
10468 If BACKWARD, the previous article is selected instead of the next."
10470 (gnus-set-global-variables)
10472 ;; Is there such an article?
10473 ((and (gnus-summary-search-forward unread subject backward)
10474 (or (gnus-summary-display-article (gnus-summary-article-number))
10475 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10476 (gnus-summary-position-point))
10477 ;; If not, we try the first unread, if that is wanted.
10479 gnus-auto-select-same
10480 (gnus-summary-first-unread-article))
10481 (gnus-summary-position-point)
10482 (gnus-message 6 "Wrapped"))
10483 ;; Try to get next/previous article not displayed in this group.
10484 ((and gnus-auto-extend-newsgroup
10485 (not unread) (not subject))
10486 (gnus-summary-goto-article
10487 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10489 ;; Go to next/previous group.
10491 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10492 (gnus-summary-jump-to-group gnus-newsgroup-name))
10493 (let ((cmd last-command-char)
10495 (if (eq gnus-keep-same-level 'best)
10496 (gnus-summary-best-group gnus-newsgroup-name)
10497 (gnus-summary-search-group backward gnus-keep-same-level))))
10498 ;; For some reason, the group window gets selected. We change
10500 (select-window (get-buffer-window (current-buffer)))
10501 ;; Select next unread newsgroup automagically.
10503 ((or (not gnus-auto-select-next)
10505 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10506 ((or (eq gnus-auto-select-next 'quietly)
10507 (and (eq gnus-auto-select-next 'slightly-quietly)
10509 (and (eq gnus-auto-select-next 'almost-quietly)
10510 (gnus-summary-last-article-p)))
10512 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10513 (gnus-summary-exit)
10514 (gnus-message 7 "No more%s articles (%s)..."
10515 (if unread " unread" "")
10516 (if group (concat "selecting " group)
10518 (gnus-summary-next-group nil group backward)))
10520 (gnus-summary-walk-group-buffer
10521 gnus-newsgroup-name cmd unread backward)))))))
10523 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10524 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10525 (?\C-p (gnus-group-prev-unread-group 1))))
10526 keve key group ended)
10528 (set-buffer gnus-group-buffer)
10529 (gnus-summary-jump-to-group from-group)
10531 (if (eq gnus-keep-same-level 'best)
10532 (gnus-summary-best-group gnus-newsgroup-name)
10533 (gnus-summary-search-group backward gnus-keep-same-level))))
10536 5 "No more%s articles%s" (if unread " unread" "")
10538 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10539 (format " (Type %s for %s [%s])"
10540 (single-key-description cmd) group
10541 (car (gnus-gethash group gnus-newsrc-hashtb)))
10542 (format " (Type %s to exit %s)"
10543 (single-key-description cmd)
10544 gnus-newsgroup-name)))
10545 ;; Confirm auto selection.
10546 (setq key (car (setq keve (gnus-read-event-char))))
10549 ((assq key keystrokes)
10550 (let ((obuf (current-buffer)))
10551 (switch-to-buffer gnus-group-buffer)
10553 (gnus-group-jump-to-group group))
10554 (eval (cadr (assq key keystrokes)))
10555 (setq group (gnus-group-group-name))
10556 (switch-to-buffer obuf))
10559 (if (or (not group)
10560 (gnus-ephemeral-group-p gnus-newsgroup-name))
10561 (gnus-summary-exit)
10562 (gnus-summary-next-group nil group backward)))
10564 (push (cdr keve) unread-command-events))))))
10566 (defun gnus-read-event-char ()
10567 "Get the next event."
10568 (let ((event (read-event)))
10569 (cons (and (numberp event) event) event)))
10571 (defun gnus-summary-next-unread-article ()
10572 "Select unread article after current one."
10574 (gnus-summary-next-article t (and gnus-auto-select-same
10575 (gnus-summary-article-subject))))
10577 (defun gnus-summary-prev-article (&optional unread subject)
10578 "Select the article after the current one.
10579 If UNREAD is non-nil, only unread articles are selected."
10581 (gnus-summary-next-article unread subject t))
10583 (defun gnus-summary-prev-unread-article ()
10584 "Select unred article before current one."
10586 (gnus-summary-prev-article t (and gnus-auto-select-same
10587 (gnus-summary-article-subject))))
10589 (defun gnus-summary-next-page (&optional lines circular)
10590 "Show next page of the selected article.
10591 If at the end of the current article, select the next article.
10592 LINES says how many lines should be scrolled up.
10594 If CIRCULAR is non-nil, go to the start of the article instead of
10595 selecting the next article when reaching the end of the current
10598 (setq gnus-summary-buffer (current-buffer))
10599 (gnus-set-global-variables)
10600 (let ((article (gnus-summary-article-number))
10602 (gnus-configure-windows 'article)
10603 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10604 (if (and (eq gnus-summary-goto-unread 'never)
10605 (not (gnus-summary-last-article-p article)))
10606 (gnus-summary-next-article)
10607 (gnus-summary-next-unread-article))
10608 (if (or (null gnus-current-article)
10609 (null gnus-article-current)
10610 (/= article (cdr gnus-article-current))
10611 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10612 ;; Selected subject is different from current article's.
10613 (gnus-summary-display-article article)
10614 (gnus-eval-in-buffer-window gnus-article-buffer
10615 (setq endp (gnus-article-next-page lines)))
10618 (gnus-summary-beginning-of-article))
10620 (gnus-message 3 "End of message"))
10622 (if (and (eq gnus-summary-goto-unread 'never)
10623 (not (gnus-summary-last-article-p article)))
10624 (gnus-summary-next-article)
10625 (gnus-summary-next-unread-article)))))))
10626 (gnus-summary-recenter)
10627 (gnus-summary-position-point)))
10629 (defun gnus-summary-prev-page (&optional lines)
10630 "Show previous page of selected article.
10631 Argument LINES specifies lines to be scrolled down."
10633 (gnus-set-global-variables)
10634 (let ((article (gnus-summary-article-number)))
10635 (gnus-configure-windows 'article)
10636 (if (or (null gnus-current-article)
10637 (null gnus-article-current)
10638 (/= article (cdr gnus-article-current))
10639 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10640 ;; Selected subject is different from current article's.
10641 (gnus-summary-display-article article)
10642 (gnus-summary-recenter)
10643 (gnus-eval-in-buffer-window gnus-article-buffer
10644 (gnus-article-prev-page lines))))
10645 (gnus-summary-position-point))
10647 (defun gnus-summary-scroll-up (lines)
10648 "Scroll up (or down) one line current article.
10649 Argument LINES specifies lines to be scrolled up (or down if negative)."
10651 (gnus-set-global-variables)
10652 (gnus-configure-windows 'article)
10653 (gnus-summary-show-thread)
10654 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10655 (gnus-eval-in-buffer-window gnus-article-buffer
10657 (if (gnus-article-next-page lines)
10658 (gnus-message 3 "End of message")))
10660 (gnus-article-prev-page (- lines))))))
10661 (gnus-summary-recenter)
10662 (gnus-summary-position-point))
10664 (defun gnus-summary-next-same-subject ()
10665 "Select next article which has the same subject as current one."
10667 (gnus-set-global-variables)
10668 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10670 (defun gnus-summary-prev-same-subject ()
10671 "Select previous article which has the same subject as current one."
10673 (gnus-set-global-variables)
10674 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10676 (defun gnus-summary-next-unread-same-subject ()
10677 "Select next unread article which has the same subject as current one."
10679 (gnus-set-global-variables)
10680 (gnus-summary-next-article t (gnus-summary-article-subject)))
10682 (defun gnus-summary-prev-unread-same-subject ()
10683 "Select previous unread article which has the same subject as current one."
10685 (gnus-set-global-variables)
10686 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10688 (defun gnus-summary-first-unread-article ()
10689 "Select the first unread article.
10690 Return nil if there are no unread articles."
10692 (gnus-set-global-variables)
10694 (if (gnus-summary-first-subject t)
10696 (gnus-summary-show-thread)
10697 (gnus-summary-first-subject t)
10698 (gnus-summary-display-article (gnus-summary-article-number))))
10699 (gnus-summary-position-point)))
10701 (defun gnus-summary-best-unread-article ()
10702 "Select the unread article with the highest score."
10704 (gnus-set-global-variables)
10705 (let ((best -1000000)
10706 (data gnus-newsgroup-data)
10709 (and (gnus-data-unread-p (car data))
10711 (gnus-summary-article-score (gnus-data-number (car data))))
10714 article (gnus-data-number (car data))))
10715 (setq data (cdr data)))
10718 (gnus-summary-goto-article article)
10719 (error "No unread articles"))
10720 (gnus-summary-position-point))))
10722 (defun gnus-summary-last-subject ()
10723 "Go to the last displayed subject line in the group."
10724 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10726 (gnus-summary-goto-subject article))))
10728 (defun gnus-summary-goto-article (article &optional all-headers force)
10729 "Fetch ARTICLE and display it if it exists.
10730 If ALL-HEADERS is non-nil, no header lines are hidden."
10736 (mapcar (lambda (number) (list (int-to-string number)))
10737 gnus-newsgroup-limit)))
10741 (if (gnus-summary-goto-subject article force)
10742 (gnus-summary-display-article article all-headers)
10743 (gnus-message 4 "Couldn't go to article %s" article) nil)
10744 (gnus-summary-position-point)))
10746 (defun gnus-summary-goto-last-article ()
10747 "Go to the previously read article."
10750 (and gnus-last-article
10751 (gnus-summary-goto-article gnus-last-article))
10752 (gnus-summary-position-point)))
10754 (defun gnus-summary-pop-article (number)
10755 "Pop one article off the history and go to the previous.
10756 NUMBER articles will be popped off."
10759 (setq gnus-newsgroup-history
10760 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10762 (gnus-summary-goto-article (car to))
10763 (error "Article history empty")))
10764 (gnus-summary-position-point))
10766 ;; Summary commands and functions for limiting the summary buffer.
10768 (defun gnus-summary-limit-to-articles (n)
10769 "Limit the summary buffer to the next N articles.
10770 If not given a prefix, use the process marked articles instead."
10772 (gnus-set-global-variables)
10774 (let ((articles (gnus-summary-work-articles n)))
10775 (setq gnus-newsgroup-processable nil)
10776 (gnus-summary-limit articles))
10777 (gnus-summary-position-point)))
10779 (defun gnus-summary-pop-limit (&optional total)
10780 "Restore the previous limit.
10781 If given a prefix, remove all limits."
10783 (gnus-set-global-variables)
10785 (setq gnus-newsgroup-limits
10786 (list (mapcar (lambda (h) (mail-header-number h))
10787 gnus-newsgroup-headers))))
10788 (unless gnus-newsgroup-limits
10789 (error "No limit to pop"))
10791 (gnus-summary-limit nil 'pop)
10792 (gnus-summary-position-point)))
10794 (defun gnus-summary-limit-to-subject (subject &optional header)
10795 "Limit the summary buffer to articles that have subjects that match a regexp."
10796 (interactive "sRegexp: ")
10798 (setq header "subject"))
10799 (when (not (equal "" subject))
10801 (let ((articles (gnus-summary-find-matching
10802 (or header "subject") subject 'all)))
10803 (or articles (error "Found no matches for \"%s\"" subject))
10804 (gnus-summary-limit articles))
10805 (gnus-summary-position-point))))
10807 (defun gnus-summary-limit-to-author (from)
10808 "Limit the summary buffer to articles that have authors that match a regexp."
10809 (interactive "sRegexp: ")
10810 (gnus-summary-limit-to-subject from "from"))
10812 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10814 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10816 (defun gnus-summary-limit-to-unread (&optional all)
10817 "Limit the summary buffer to articles that are not marked as read.
10818 If ALL is non-nil, limit strictly to unread articles."
10821 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10822 (gnus-summary-limit-to-marks
10823 ;; Concat all the marks that say that an article is read and have
10825 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10826 gnus-killed-mark gnus-kill-file-mark
10827 gnus-low-score-mark gnus-expirable-mark
10828 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10831 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10832 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10834 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10835 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10836 If REVERSE, limit the summary buffer to articles that are not marked
10837 with MARKS. MARKS can either be a string of marks or a list of marks.
10838 Returns how many articles were removed."
10839 (interactive "sMarks: ")
10840 (gnus-set-global-variables)
10842 (let ((data gnus-newsgroup-data)
10843 (marks (if (listp marks) marks
10844 (append marks nil))) ; Transform to list.
10847 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10848 (memq (gnus-data-mark (car data)) marks))
10849 (setq articles (cons (gnus-data-number (car data)) articles)))
10850 (setq data (cdr data)))
10851 (gnus-summary-limit articles))
10852 (gnus-summary-position-point)))
10854 (defun gnus-summary-limit-to-score (&optional score)
10855 "Limit to articles with score at or above SCORE."
10857 (gnus-set-global-variables)
10858 (setq score (if score
10859 (prefix-numeric-value score)
10860 (or gnus-summary-default-score 0)))
10861 (let ((data gnus-newsgroup-data)
10864 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10866 (push (gnus-data-number (car data)) articles))
10867 (setq data (cdr data)))
10869 (gnus-summary-limit articles)
10870 (gnus-summary-position-point))))
10872 (defun gnus-summary-limit-include-dormant ()
10873 "Display all the hidden articles that are marked as dormant."
10875 (gnus-set-global-variables)
10876 (or gnus-newsgroup-dormant
10877 (error "There are no dormant articles in this group"))
10879 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10880 (gnus-summary-position-point)))
10882 (defun gnus-summary-limit-exclude-dormant ()
10883 "Hide all dormant articles."
10885 (gnus-set-global-variables)
10887 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10888 (gnus-summary-position-point)))
10890 (defun gnus-summary-limit-exclude-childless-dormant ()
10891 "Hide all dormant articles that have no children."
10893 (gnus-set-global-variables)
10894 (let ((data (gnus-data-list t))
10895 articles d children)
10896 ;; Find all articles that are either not dormant or have
10898 (while (setq d (pop data))
10899 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10900 (and (setq children
10901 (gnus-article-children (gnus-data-number d)))
10904 (when (memq (car children) articles)
10909 (push (gnus-data-number d) articles)))
10910 ;; Do the limiting.
10912 (gnus-summary-limit articles)
10913 (gnus-summary-position-point))))
10915 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10916 "Mark all unread excluded articles as read.
10917 If ALL, mark even excluded ticked and dormants as read."
10919 (let ((articles (gnus-sorted-complement
10921 (mapcar (lambda (h) (mail-header-number h))
10922 gnus-newsgroup-headers)
10924 (sort gnus-newsgroup-limit '<)))
10926 (setq gnus-newsgroup-unreads nil)
10928 (setq gnus-newsgroup-dormant nil
10929 gnus-newsgroup-marked nil
10930 gnus-newsgroup-reads
10932 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10933 gnus-newsgroup-reads))
10934 (while (setq article (pop articles))
10935 (unless (or (memq article gnus-newsgroup-dormant)
10936 (memq article gnus-newsgroup-marked))
10937 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10939 (defun gnus-summary-limit (articles &optional pop)
10941 ;; We pop the previous limit off the stack and use that.
10942 (setq articles (car gnus-newsgroup-limits)
10943 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10944 ;; We use the new limit, so we push the old limit on the stack.
10945 (setq gnus-newsgroup-limits
10946 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10948 (setq gnus-newsgroup-limit articles)
10949 (let ((total (length gnus-newsgroup-data))
10950 (data (gnus-data-find-list (gnus-summary-article-number)))
10951 (gnus-summary-mark-below nil) ; Inhibit this.
10953 ;; This will do all the work of generating the new summary buffer
10954 ;; according to the new limit.
10955 (gnus-summary-prepare)
10956 ;; Hide any threads, possibly.
10957 (and gnus-show-threads
10958 gnus-thread-hide-subtree
10959 (gnus-summary-hide-all-threads))
10960 ;; Try to return to the article you were at, or one in the
10963 ;; We try to find some article after the current one.
10965 (and (gnus-summary-goto-subject
10966 (gnus-data-number (car data)) nil t)
10969 (setq data (cdr data))))
10971 ;; If there is no data, that means that we were after the last
10972 ;; article. The same goes when we can't find any articles
10973 ;; after the current one.
10975 (goto-char (point-max))
10976 (gnus-summary-find-prev)))
10977 ;; We return how many articles were removed from the summary
10978 ;; buffer as a result of the new limit.
10979 (- total (length gnus-newsgroup-data))))
10981 (defsubst gnus-invisible-cut-children (threads)
10984 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10989 (defsubst gnus-cut-thread (thread)
10990 "Go forwards in the thread until we find an article that we want to display."
10991 (when (or (eq gnus-fetch-old-headers 'some)
10992 (eq gnus-build-sparse-threads 'some)
10993 (eq gnus-build-sparse-threads 'more))
10994 ;; Deal with old-fetched headers and sparse threads.
10998 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10999 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
11000 (or (<= (length (cdr thread)) 1)
11001 (gnus-invisible-cut-children (cdr thread))))
11002 (setq thread (cadr thread))))
11005 (defun gnus-cut-threads (threads)
11006 "Cut off all uninteresting articles from the beginning of threads."
11007 (when (or (eq gnus-fetch-old-headers 'some)
11008 (eq gnus-build-sparse-threads 'some)
11009 (eq gnus-build-sparse-threads 'more))
11010 (let ((th threads))
11012 (setcar th (gnus-cut-thread (car th)))
11013 (setq th (cdr th)))))
11014 ;; Remove nixed out threads.
11015 (delq nil threads))
11017 (defun gnus-summary-initial-limit (&optional show-if-empty)
11018 "Figure out what the initial limit is supposed to be on group entry.
11019 This entails weeding out unwanted dormants, low-scored articles,
11020 fetch-old-headers verbiage, and so on."
11021 ;; Most groups have nothing to remove.
11022 (if (or gnus-inhibit-limiting
11023 (and (null gnus-newsgroup-dormant)
11024 (not (eq gnus-fetch-old-headers 'some))
11025 (null gnus-summary-expunge-below)
11026 (not (eq gnus-build-sparse-threads 'some))
11027 (not (eq gnus-build-sparse-threads 'more))
11028 (null gnus-thread-expunge-below)
11029 (not gnus-use-nocem)))
11031 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11032 (setq gnus-newsgroup-limit nil)
11035 (unless (car (symbol-value node))
11036 ;; These threads have no parents -- they are roots.
11037 (let ((nodes (cdr (symbol-value node)))
11040 (if (and gnus-thread-expunge-below
11041 (< (gnus-thread-total-score (car nodes))
11042 gnus-thread-expunge-below))
11043 (gnus-expunge-thread (pop nodes))
11044 (setq thread (pop nodes))
11045 (gnus-summary-limit-children thread))))))
11046 gnus-newsgroup-dependencies)
11047 ;; If this limitation resulted in an empty group, we might
11048 ;; pop the previous limit and use it instead.
11049 (when (and (not gnus-newsgroup-limit)
11051 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
11052 gnus-newsgroup-limit))
11054 (defun gnus-summary-limit-children (thread)
11055 "Return 1 if this subthread is visible and 0 if it is not."
11056 ;; First we get the number of visible children to this thread. This
11057 ;; is done by recursing down the thread using this function, so this
11058 ;; will really go down to a leaf article first, before slowly
11059 ;; working its way up towards the root.
11063 (apply '+ (mapcar 'gnus-summary-limit-children
11066 (number (mail-header-number (car thread)))
11069 ;; If this article is dormant and has absolutely no visible
11070 ;; children, then this article isn't visible.
11071 (and (memq number gnus-newsgroup-dormant)
11073 ;; If this is "fetch-old-headered" and there is only one
11074 ;; visible child (or less), then we don't want this article.
11075 (and (eq gnus-fetch-old-headers 'some)
11076 (memq number gnus-newsgroup-ancient)
11078 ;; If this is a sparsely inserted article with no children,
11079 ;; we don't want it.
11080 (and (eq gnus-build-sparse-threads 'some)
11081 (memq number gnus-newsgroup-sparse)
11083 ;; If we use expunging, and this article is really
11084 ;; low-scored, then we don't want this article.
11085 (when (and gnus-summary-expunge-below
11087 (or (cdr (assq number gnus-newsgroup-scored))
11088 gnus-summary-default-score))
11089 gnus-summary-expunge-below))
11090 ;; We increase the expunge-tally here, but that has
11091 ;; nothing to do with the limits, really.
11092 (incf gnus-newsgroup-expunged-tally)
11093 ;; We also mark as read here, if that's wanted.
11094 (when (and gnus-summary-mark-below
11095 (< score gnus-summary-mark-below))
11096 (setq gnus-newsgroup-unreads
11097 (delq number gnus-newsgroup-unreads))
11098 (if gnus-newsgroup-auto-expire
11099 (push number gnus-newsgroup-expirable)
11100 (push (cons number gnus-low-score-mark)
11101 gnus-newsgroup-reads)))
11103 (and gnus-use-nocem
11104 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11105 ;; Nope, invisible article.
11107 ;; Ok, this article is to be visible, so we add it to the limit
11109 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11112 (defun gnus-expunge-thread (thread)
11113 "Mark all articles in THREAD as read."
11114 (let* ((number (mail-header-number (car thread))))
11115 (incf gnus-newsgroup-expunged-tally)
11116 ;; We also mark as read here, if that's wanted.
11117 (setq gnus-newsgroup-unreads
11118 (delq number gnus-newsgroup-unreads))
11119 (if gnus-newsgroup-auto-expire
11120 (push number gnus-newsgroup-expirable)
11121 (push (cons number gnus-low-score-mark)
11122 gnus-newsgroup-reads)))
11123 ;; Go recursively through all subthreads.
11124 (mapcar 'gnus-expunge-thread (cdr thread)))
11126 ;; Summary article oriented commands
11128 (defun gnus-summary-refer-parent-article (n)
11129 "Refer parent article N times.
11130 The difference between N and the number of articles fetched is returned."
11132 (gnus-set-global-variables)
11136 (let* ((header (gnus-summary-article-header))
11138 ;; If we try to find the parent of the currently
11139 ;; displayed article, then we take a look at the actual
11140 ;; References header, since this is slightly more
11141 ;; reliable than the References field we got from the
11143 (if (and (eq (mail-header-number header)
11144 (cdr gnus-article-current))
11145 (equal gnus-newsgroup-name
11146 (car gnus-article-current)))
11148 (set-buffer gnus-original-article-buffer)
11149 (nnheader-narrow-to-headers)
11151 (message-fetch-field "references")
11153 ;; It's not the current article, so we take a bet on
11154 ;; the value we got from the server.
11155 (mail-header-references header))))
11156 (if (setq ref (or ref (mail-header-references header)))
11157 (or (gnus-summary-refer-article (gnus-parent-id ref))
11158 (gnus-message 1 "Couldn't find parent"))
11159 (gnus-message 1 "No references in article %d"
11160 (gnus-summary-article-number))
11163 (gnus-summary-position-point)
11166 (defun gnus-summary-refer-references ()
11167 "Fetch all articles mentioned in the References header.
11168 Return how many articles were fetched."
11170 (gnus-set-global-variables)
11171 (let ((ref (mail-header-references (gnus-summary-article-header)))
11172 (current (gnus-summary-article-number))
11174 ;; For each Message-ID in the References header...
11175 (while (string-match "<[^>]*>" ref)
11177 ;; ... fetch that article.
11178 (gnus-summary-refer-article
11179 (prog1 (match-string 0 ref)
11180 (setq ref (substring ref (match-end 0))))))
11181 (gnus-summary-goto-subject current)
11182 (gnus-summary-position-point)
11185 (defun gnus-summary-refer-article (message-id)
11186 "Fetch an article specified by MESSAGE-ID."
11187 (interactive "sMessage-ID: ")
11188 (when (and (stringp message-id)
11189 (not (zerop (length message-id))))
11190 ;; Construct the correct Message-ID if necessary.
11191 ;; Suggested by tale@pawl.rpi.edu.
11192 (unless (string-match "^<" message-id)
11193 (setq message-id (concat "<" message-id)))
11194 (unless (string-match ">$" message-id)
11195 (setq message-id (concat message-id ">")))
11196 (let* ((header (gnus-id-to-header message-id))
11197 (sparse (and header
11198 (memq (mail-header-number header)
11199 gnus-newsgroup-sparse))))
11202 ;; The article is present in the buffer, to we just go to it.
11203 (gnus-summary-goto-article
11204 (mail-header-number header) nil header)
11206 (gnus-summary-update-article (mail-header-number header))))
11207 ;; We fetch the article
11208 (let ((gnus-override-method
11209 (and (gnus-news-group-p gnus-newsgroup-name)
11210 gnus-refer-article-method))
11212 ;; Start the special refer-article method, if necessary.
11213 (when (and gnus-refer-article-method
11214 (gnus-news-group-p gnus-newsgroup-name))
11215 (gnus-check-server gnus-refer-article-method))
11216 ;; Fetch the header, and display the article.
11217 (if (setq number (gnus-summary-insert-subject message-id))
11218 (gnus-summary-select-article nil nil nil number)
11219 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11221 (defun gnus-summary-enter-digest-group (&optional force)
11222 "Enter a digest group based on the current article."
11224 (gnus-set-global-variables)
11225 (gnus-summary-select-article)
11226 (let ((name (format "%s-%d"
11227 (gnus-group-prefixed-name
11228 gnus-newsgroup-name (list 'nndoc ""))
11229 gnus-current-article))
11230 (ogroup gnus-newsgroup-name)
11231 (case-fold-search t)
11232 (buf (current-buffer))
11235 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11236 (insert-buffer-substring gnus-original-article-buffer)
11238 (goto-char (point-min))
11239 (or (search-forward "\n\n" nil t) (point)))
11240 (goto-char (point-min))
11241 (delete-matching-lines "^\\(Path\\):\\|^From ")
11244 (if (gnus-group-read-ephemeral-group
11245 name `(nndoc ,name (nndoc-address
11247 (nndoc-article-type ,(if force 'digest 'guess))) t)
11248 ;; Make all postings to this group go to the parent group.
11249 (nconc (gnus-info-params (gnus-get-info name))
11250 (list (cons 'to-group ogroup)))
11251 ;; Couldn't select this doc group.
11252 (switch-to-buffer buf)
11253 (gnus-set-global-variables)
11254 (gnus-configure-windows 'summary)
11255 (gnus-message 3 "Article couldn't be entered?"))
11256 (kill-buffer dig))))
11258 (defun gnus-summary-isearch-article (&optional regexp-p)
11259 "Do incremental search forward on the current article.
11260 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11262 (gnus-set-global-variables)
11263 (gnus-summary-select-article)
11264 (gnus-configure-windows 'article)
11265 (gnus-eval-in-buffer-window gnus-article-buffer
11266 ;;(goto-char (point-min))
11267 (isearch-forward regexp-p)))
11269 (defun gnus-summary-search-article-forward (regexp &optional backward)
11270 "Search for an article containing REGEXP forward.
11271 If BACKWARD, search backward instead."
11274 (format "Search article %s (regexp%s): "
11275 (if current-prefix-arg "backward" "forward")
11276 (if gnus-last-search-regexp
11277 (concat ", default " gnus-last-search-regexp)
11279 current-prefix-arg))
11280 (gnus-set-global-variables)
11281 (if (string-equal regexp "")
11282 (setq regexp (or gnus-last-search-regexp ""))
11283 (setq gnus-last-search-regexp regexp))
11284 (unless (gnus-summary-search-article regexp backward)
11285 (error "Search failed: \"%s\"" regexp)))
11287 (defun gnus-summary-search-article-backward (regexp)
11288 "Search for an article containing REGEXP backward."
11291 (format "Search article backward (regexp%s): "
11292 (if gnus-last-search-regexp
11293 (concat ", default " gnus-last-search-regexp)
11295 (gnus-summary-search-article-forward regexp 'backward))
11297 (defun gnus-summary-search-article (regexp &optional backward)
11298 "Search for an article containing REGEXP.
11299 Optional argument BACKWARD means do search for backward.
11300 `gnus-select-article-hook' is not called during the search."
11301 (let ((gnus-select-article-hook nil) ;Disable hook.
11302 (gnus-article-display-hook nil)
11303 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11306 're-search-backward 're-search-forward))
11307 (sum (current-buffer))
11309 (gnus-save-hidden-threads
11310 (gnus-summary-select-article)
11311 (set-buffer gnus-article-buffer)
11315 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11317 (re-search-backward regexp nil t)
11318 (re-search-forward regexp nil t))
11319 ;; We found the regexp.
11321 (setq found 'found)
11322 (beginning-of-line)
11324 (get-buffer-window (current-buffer))
11328 ;; We didn't find it, so we go to the next article.
11330 (if (not (if backward (gnus-summary-find-prev)
11331 (gnus-summary-find-next)))
11332 ;; No more articles.
11334 ;; Select the next article and adjust point.
11335 (gnus-summary-select-article)
11336 (set-buffer gnus-article-buffer)
11338 (goto-char (if backward (point-max) (point-min))))))
11339 (gnus-message 7 ""))
11340 ;; Return whether we found the regexp.
11341 (when (eq found 'found)
11342 (gnus-summary-show-thread)
11343 (gnus-summary-goto-subject gnus-current-article)
11344 (gnus-summary-position-point)
11347 (defun gnus-summary-find-matching (header regexp &optional backward unread
11349 "Return a list of all articles that match REGEXP on HEADER.
11350 The search stars on the current article and goes forwards unless
11351 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11352 If UNREAD is non-nil, only unread articles will
11353 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11354 in the comparisons."
11355 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11356 (gnus-data-find-list
11357 (gnus-summary-article-number) (gnus-data-list backward))))
11358 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11359 (case-fold-search (not not-case-fold))
11361 (or (fboundp (intern (concat "mail-header-" header)))
11362 (error "%s is not a valid header" header))
11364 (setq d (car data))
11365 (and (or (not unread) ; We want all articles...
11366 (gnus-data-unread-p d)) ; Or just unreads.
11367 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11368 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11369 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11370 (setq data (cdr data)))
11371 (nreverse articles)))
11373 (defun gnus-summary-execute-command (header regexp command &optional backward)
11374 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11375 If HEADER is an empty string (or nil), the match is done on the entire
11376 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11378 (list (let ((completion-ignore-case t))
11381 (mapcar (lambda (string) (list string))
11382 '("Number" "Subject" "From" "Lines" "Date"
11383 "Message-ID" "Xref" "References" "Body"))
11384 nil 'require-match))
11385 (read-string "Regexp: ")
11386 (read-key-sequence "Command: ")
11387 current-prefix-arg))
11388 (when (equal header "Body")
11390 (gnus-set-global-variables)
11391 ;; Hidden thread subtrees must be searched as well.
11392 (gnus-summary-show-all-threads)
11393 ;; We don't want to change current point nor window configuration.
11395 (save-window-excursion
11396 (gnus-message 6 "Executing %s..." (key-description command))
11397 ;; We'd like to execute COMMAND interactively so as to give arguments.
11398 (gnus-execute header regexp
11399 `(lambda () (call-interactively ',(key-binding command)))
11401 (gnus-message 6 "Executing %s...done" (key-description command)))))
11403 (defun gnus-summary-beginning-of-article ()
11404 "Scroll the article back to the beginning."
11406 (gnus-set-global-variables)
11407 (gnus-summary-select-article)
11408 (gnus-configure-windows 'article)
11409 (gnus-eval-in-buffer-window gnus-article-buffer
11411 (goto-char (point-min))
11412 (and gnus-break-pages (gnus-narrow-to-page))))
11414 (defun gnus-summary-end-of-article ()
11415 "Scroll to the end of the article."
11417 (gnus-set-global-variables)
11418 (gnus-summary-select-article)
11419 (gnus-configure-windows 'article)
11420 (gnus-eval-in-buffer-window gnus-article-buffer
11422 (goto-char (point-max))
11424 (and gnus-break-pages (gnus-narrow-to-page))))
11426 (defun gnus-summary-show-article (&optional arg)
11427 "Force re-fetching of the current article.
11428 If ARG (the prefix) is non-nil, show the raw article without any
11429 article massaging functions being run."
11431 (gnus-set-global-variables)
11433 ;; Select the article the normal way.
11434 (gnus-summary-select-article nil 'force)
11435 ;; Bind the article treatment functions to nil.
11436 (let ((gnus-have-all-headers t)
11437 gnus-article-display-hook
11438 gnus-article-prepare-hook
11441 (gnus-summary-select-article nil 'force)))
11442 (gnus-summary-goto-subject gnus-current-article)
11443 ; (gnus-configure-windows 'article)
11444 (gnus-summary-position-point))
11446 (defun gnus-summary-verbose-headers (&optional arg)
11447 "Toggle permanent full header display.
11448 If ARG is a positive number, turn header display on.
11449 If ARG is a negative number, turn header display off."
11451 (gnus-set-global-variables)
11452 (gnus-summary-toggle-header arg)
11453 (setq gnus-show-all-headers
11454 (cond ((or (not (numberp arg))
11456 (not gnus-show-all-headers))
11460 (defun gnus-summary-toggle-header (&optional arg)
11461 "Show the headers if they are hidden, or hide them if they are shown.
11462 If ARG is a positive number, show the entire header.
11463 If ARG is a negative number, hide the unwanted header lines."
11465 (gnus-set-global-variables)
11467 (set-buffer gnus-article-buffer)
11468 (let* ((buffer-read-only nil)
11469 (inhibit-point-motion-hooks t)
11470 (hidden (text-property-any
11471 (goto-char (point-min)) (search-forward "\n\n")
11474 (goto-char (point-min))
11475 (when (search-forward "\n\n" nil t)
11476 (delete-region (point-min) (1- (point))))
11477 (goto-char (point-min))
11479 (set-buffer gnus-original-article-buffer)
11480 (goto-char (point-min))
11481 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11482 (insert-buffer-substring gnus-original-article-buffer 1 e)
11483 (let ((gnus-inhibit-hiding t))
11484 (run-hooks 'gnus-article-display-hook))
11485 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11486 (gnus-article-hide-headers)))))
11488 (defun gnus-summary-show-all-headers ()
11489 "Make all header lines visible."
11491 (gnus-set-global-variables)
11492 (gnus-article-show-all-headers))
11494 (defun gnus-summary-toggle-mime (&optional arg)
11495 "Toggle MIME processing.
11496 If ARG is a positive number, turn MIME processing on."
11498 (gnus-set-global-variables)
11499 (setq gnus-show-mime
11500 (if (null arg) (not gnus-show-mime)
11501 (> (prefix-numeric-value arg) 0)))
11502 (gnus-summary-select-article t 'force))
11504 (defun gnus-summary-caesar-message (&optional arg)
11505 "Caesar rotate the current article by 13.
11506 The numerical prefix specifies how manu places to rotate each letter
11509 (gnus-set-global-variables)
11510 (gnus-summary-select-article)
11511 (let ((mail-header-separator ""))
11512 (gnus-eval-in-buffer-window gnus-article-buffer
11515 (let ((start (window-start))
11517 (message-caesar-buffer-body arg)
11518 (set-window-start (get-buffer-window (current-buffer)) start))))))
11520 (defun gnus-summary-stop-page-breaking ()
11521 "Stop page breaking in the current article."
11523 (gnus-set-global-variables)
11524 (gnus-summary-select-article)
11525 (gnus-eval-in-buffer-window gnus-article-buffer
11528 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11529 "Move the current article to a different newsgroup.
11530 If N is a positive number, move the N next articles.
11531 If N is a negative number, move the N previous articles.
11532 If N is nil and any articles have been marked with the process mark,
11533 move those articles instead.
11534 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11535 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11536 re-spool using this method.
11538 For this function to work, both the current newsgroup and the
11539 newsgroup that you want to move to have to support the `request-move'
11540 and `request-accept' functions."
11542 (unless action (setq action 'move))
11543 (gnus-set-global-variables)
11544 ;; Check whether the source group supports the required functions.
11545 (cond ((and (eq action 'move)
11546 (not (gnus-check-backend-function
11547 'request-move-article gnus-newsgroup-name)))
11548 (error "The current group does not support article moving"))
11549 ((and (eq action 'crosspost)
11550 (not (gnus-check-backend-function
11551 'request-replace-article gnus-newsgroup-name)))
11552 (error "The current group does not support article editing")))
11553 (let ((articles (gnus-summary-work-articles n))
11554 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11555 (names '((move "Move" "Moving")
11556 (copy "Copy" "Copying")
11557 (crosspost "Crosspost" "Crossposting")))
11558 (copy-buf (save-excursion
11559 (nnheader-set-temp-buffer " *copy article*")))
11560 art-group to-method new-xref article to-groups)
11561 (unless (assq action names)
11562 (error "Unknown action %s" action))
11563 ;; Read the newsgroup name.
11564 (when (and (not to-newsgroup)
11565 (not select-method))
11567 (gnus-read-move-group-name
11568 (cadr (assq action names))
11569 (symbol-value (intern (format "gnus-current-%s-group" action)))
11571 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11572 (setq to-method (or select-method
11573 (gnus-group-name-to-method to-newsgroup)))
11574 ;; Check the method we are to move this article to...
11575 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11576 (error "%s does not support article copying" (car to-method)))
11577 (or (gnus-check-server to-method)
11578 (error "Can't open server %s" (car to-method)))
11579 (gnus-message 6 "%s to %s: %s..."
11580 (caddr (assq action names))
11581 (or (car select-method) to-newsgroup) articles)
11583 (setq article (pop articles))
11587 ;; Move the article.
11589 (gnus-request-move-article
11590 article ; Article to move
11591 gnus-newsgroup-name ; From newsgrouo
11592 (nth 1 (gnus-find-method-for-group
11593 gnus-newsgroup-name)) ; Server
11594 (list 'gnus-request-accept-article
11595 to-newsgroup (list 'quote select-method)
11596 (not articles)) ; Accept form
11597 (not articles))) ; Only save nov last time
11598 ;; Copy the article.
11601 (set-buffer copy-buf)
11602 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11603 (gnus-request-accept-article
11604 to-newsgroup select-method (not articles))))
11605 ;; Crosspost the article.
11606 ((eq action 'crosspost)
11607 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11608 (setq new-xref (concat gnus-newsgroup-name ":" article))
11609 (if (and xref (not (string= xref "")))
11611 (when (string-match "^Xref: " xref)
11612 (setq xref (substring xref (match-end 0))))
11613 (setq new-xref (concat xref " " new-xref)))
11614 (setq new-xref (concat (system-name) " " new-xref)))
11616 (set-buffer copy-buf)
11617 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11618 (nnheader-replace-header "xref" new-xref)
11619 (gnus-request-accept-article
11620 to-newsgroup select-method (not articles)))))))
11621 (if (not art-group)
11622 (gnus-message 1 "Couldn't %s article %s"
11623 (cadr (assq action names)) article)
11626 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11628 (gnus-group-prefixed-name
11631 (gnus-find-method-for-group to-newsgroup)))
11632 gnus-newsrc-hashtb)))
11633 (info (nth 2 entry))
11634 (to-group (gnus-info-group info)))
11635 ;; Update the group that has been moved to.
11637 (memq action '(move copy)))
11638 (unless (member to-group to-groups)
11639 (push to-group to-groups))
11641 (unless (memq article gnus-newsgroup-unreads)
11642 (gnus-info-set-read
11643 info (gnus-add-to-range (gnus-info-read info)
11644 (list (cdr art-group)))))
11646 ;; Copy any marks over to the new group.
11647 (let ((marks gnus-article-mark-lists)
11648 (to-article (cdr art-group)))
11650 ;; See whether the article is to be put in the cache.
11651 (when gnus-use-cache
11652 (gnus-cache-possibly-enter-article
11653 to-group to-article
11654 (let ((header (copy-sequence
11655 (gnus-summary-article-header article))))
11656 (mail-header-set-number header to-article)
11658 (memq article gnus-newsgroup-marked)
11659 (memq article gnus-newsgroup-dormant)
11660 (memq article gnus-newsgroup-unreads)))
11663 (when (memq article (symbol-value
11664 (intern (format "gnus-newsgroup-%s"
11666 ;; If the other group is the same as this group,
11667 ;; then we have to add the mark to the list.
11668 (when (equal to-group gnus-newsgroup-name)
11669 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11672 (intern (format "gnus-newsgroup-%s"
11674 ;; Copy mark to other group.
11675 (gnus-add-marked-articles
11676 to-group (cdar marks) (list to-article) info))
11677 (setq marks (cdr marks)))))
11679 ;; Update the Xref header in this article to point to
11680 ;; the new crossposted article we have just created.
11681 (when (eq action 'crosspost)
11683 (set-buffer copy-buf)
11684 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11685 (nnheader-replace-header
11686 "xref" (concat new-xref " " (gnus-group-prefixed-name
11687 (car art-group) to-method)
11688 ":" (cdr art-group)))
11689 (gnus-request-replace-article
11690 article gnus-newsgroup-name (current-buffer)))))
11692 (gnus-summary-goto-subject article)
11693 (when (eq action 'move)
11694 (gnus-summary-mark-article article gnus-canceled-mark)))
11695 (gnus-summary-remove-process-mark article))
11696 ;; Re-activate all groups that have been moved to.
11698 (gnus-activate-group (pop to-groups)))
11700 (gnus-kill-buffer copy-buf)
11701 (gnus-summary-position-point)
11702 (gnus-set-mode-line 'summary)))
11704 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11705 "Move the current article to a different newsgroup.
11706 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11707 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11708 re-spool using this method."
11710 (gnus-summary-move-article n nil select-method 'copy))
11712 (defun gnus-summary-crosspost-article (&optional n)
11713 "Crosspost the current article to some other group."
11715 (gnus-summary-move-article n nil nil 'crosspost))
11717 (defvar gnus-summary-respool-default-method nil
11718 "Default method for respooling an article.
11719 If nil, use to the current newsgroup method.")
11721 (defun gnus-summary-respool-article (&optional n method)
11722 "Respool the current article.
11723 The article will be squeezed through the mail spooling process again,
11724 which means that it will be put in some mail newsgroup or other
11725 depending on `nnmail-split-methods'.
11726 If N is a positive number, respool the N next articles.
11727 If N is a negative number, respool the N previous articles.
11728 If N is nil and any articles have been marked with the process mark,
11729 respool those articles instead.
11731 Respooling can be done both from mail groups and \"real\" newsgroups.
11732 In the former case, the articles in question will be moved from the
11733 current group into whatever groups they are destined to. In the
11734 latter case, they will be copied into the relevant groups."
11736 (list current-prefix-arg
11737 (let* ((methods (gnus-methods-using 'respool))
11739 (symbol-name (or gnus-summary-respool-default-method
11740 (car (gnus-find-method-for-group
11741 gnus-newsgroup-name)))))
11743 (gnus-completing-read
11744 methname "What backend do you want to use when respooling?"
11745 methods nil t nil 'gnus-method-history))
11748 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11749 (list (intern method) ""))
11753 (cdr (completing-read
11755 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11756 (gnus-set-global-variables)
11758 (error "No method given for respooling"))
11759 (if (assoc (symbol-name
11760 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11761 (gnus-methods-using 'respool))
11762 (gnus-summary-move-article n nil method)
11763 (gnus-summary-copy-article n nil method)))
11765 (defun gnus-summary-import-article (file)
11766 "Import a random file into a mail newsgroup."
11767 (interactive "fImport file: ")
11768 (gnus-set-global-variables)
11769 (let ((group gnus-newsgroup-name)
11770 (now (current-time))
11772 (or (gnus-check-backend-function 'request-accept-article group)
11773 (error "%s does not support article importing" group))
11774 (or (file-readable-p file)
11775 (not (file-regular-p file))
11776 (error "Can't read %s" file))
11778 (set-buffer (get-buffer-create " *import file*"))
11779 (buffer-disable-undo (current-buffer))
11781 (insert-file-contents file)
11782 (goto-char (point-min))
11783 (unless (nnheader-article-p)
11784 ;; This doesn't look like an article, so we fudge some headers.
11785 (setq atts (file-attributes file)
11786 lines (count-lines (point-min) (point-max)))
11787 (insert "From: " (read-string "From: ") "\n"
11788 "Subject: " (read-string "Subject: ") "\n"
11789 "Date: " (timezone-make-date-arpa-standard
11790 (current-time-string (nth 5 atts))
11791 (current-time-zone now)
11792 (current-time-zone now)) "\n"
11793 "Message-ID: " (message-make-message-id) "\n"
11794 "Lines: " (int-to-string lines) "\n"
11795 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11796 (gnus-request-accept-article group nil t)
11797 (kill-buffer (current-buffer)))))
11799 (defun gnus-summary-expire-articles (&optional now)
11800 "Expire all articles that are marked as expirable in the current group."
11802 (gnus-set-global-variables)
11803 (when (gnus-check-backend-function
11804 'request-expire-articles gnus-newsgroup-name)
11805 ;; This backend supports expiry.
11806 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11807 (expirable (if total
11808 (gnus-list-of-read-articles gnus-newsgroup-name)
11809 (setq gnus-newsgroup-expirable
11810 (sort gnus-newsgroup-expirable '<))))
11811 (expiry-wait (if now 'immediate
11812 (gnus-group-get-parameter
11813 gnus-newsgroup-name 'expiry-wait)))
11816 ;; There are expirable articles in this group, so we run them
11817 ;; through the expiry process.
11818 (gnus-message 6 "Expiring articles...")
11819 ;; The list of articles that weren't expired is returned.
11821 (let ((nnmail-expiry-wait-function nil)
11822 (nnmail-expiry-wait expiry-wait))
11823 (setq es (gnus-request-expire-articles
11824 expirable gnus-newsgroup-name)))
11825 (setq es (gnus-request-expire-articles
11826 expirable gnus-newsgroup-name)))
11827 (or total (setq gnus-newsgroup-expirable es))
11828 ;; We go through the old list of expirable, and mark all
11829 ;; really expired articles as nonexistent.
11830 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11831 (let ((gnus-use-cache nil))
11833 (unless (memq (car expirable) es)
11834 (when (gnus-data-find (car expirable))
11835 (gnus-summary-mark-article
11836 (car expirable) gnus-canceled-mark)))
11837 (setq expirable (cdr expirable)))))
11838 (gnus-message 6 "Expiring articles...done")))))
11840 (defun gnus-summary-expire-articles-now ()
11841 "Expunge all expirable articles in the current group.
11842 This means that *all* articles that are marked as expirable will be
11843 deleted forever, right now."
11845 (gnus-set-global-variables)
11846 (or gnus-expert-user
11848 "Are you really, really, really sure you want to delete all these messages? ")
11850 (gnus-summary-expire-articles t))
11852 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11853 (defun gnus-summary-delete-article (&optional n)
11854 "Delete the N next (mail) articles.
11855 This command actually deletes articles. This is not a marking
11856 command. The article will disappear forever from your life, never to
11858 If N is negative, delete backwards.
11859 If N is nil and articles have been marked with the process mark,
11860 delete these instead."
11862 (gnus-set-global-variables)
11863 (or (gnus-check-backend-function 'request-expire-articles
11864 gnus-newsgroup-name)
11865 (error "The current newsgroup does not support article deletion."))
11866 ;; Compute the list of articles to delete.
11867 (let ((articles (gnus-summary-work-articles n))
11869 (if (and gnus-novice-user
11870 (not (gnus-y-or-n-p
11871 (format "Do you really want to delete %s forever? "
11872 (if (> (length articles) 1)
11873 (format "these %s articles" (length articles))
11874 "this article")))))
11876 ;; Delete the articles.
11877 (setq not-deleted (gnus-request-expire-articles
11878 articles gnus-newsgroup-name 'force))
11880 (gnus-summary-remove-process-mark (car articles))
11881 ;; The backend might not have been able to delete the article
11883 (or (memq (car articles) not-deleted)
11884 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11885 (setq articles (cdr articles))))
11886 (gnus-summary-position-point)
11887 (gnus-set-mode-line 'summary)
11890 (defun gnus-summary-edit-article (&optional force)
11891 "Enter into a buffer and edit the current article.
11892 This will have permanent effect only in mail groups.
11893 If FORCE is non-nil, allow editing of articles even in read-only
11897 (set-buffer gnus-summary-buffer)
11898 (gnus-set-global-variables)
11899 (when (and (not force)
11900 (gnus-group-read-only-p))
11901 (error "The current newsgroup does not support article editing."))
11902 (gnus-summary-select-article t nil t)
11903 (gnus-configure-windows 'article)
11904 (select-window (get-buffer-window gnus-article-buffer))
11905 (gnus-message 6 "C-c C-c to end edits")
11906 (setq buffer-read-only nil)
11908 (use-local-map (copy-keymap (current-local-map)))
11909 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11910 (buffer-enable-undo)
11912 (goto-char (point-min))
11913 (search-forward "\n\n" nil t)))
11915 (defun gnus-summary-edit-article-done ()
11916 "Make edits to the current article permanent."
11918 (if (gnus-group-read-only-p)
11920 (let ((beep (not (eq major-mode 'text-mode))))
11921 (gnus-summary-edit-article-postpone)
11924 3 "The current newsgroup does not support article editing."))))
11925 (let ((buf (format "%s" (buffer-string))))
11928 (if (not (gnus-request-replace-article
11929 (cdr gnus-article-current) (car gnus-article-current)
11931 (error "Couldn't replace article.")
11932 (gnus-article-mode)
11933 (use-local-map gnus-article-mode-map)
11934 (setq buffer-read-only t)
11935 (buffer-disable-undo (current-buffer))
11936 (gnus-configure-windows 'summary)
11937 (gnus-summary-update-article (cdr gnus-article-current))
11938 (when gnus-use-cache
11939 (gnus-cache-update-article
11940 (car gnus-article-current) (cdr gnus-article-current)))
11941 (when gnus-keep-backlog
11942 (gnus-backlog-remove-article
11943 (car gnus-article-current) (cdr gnus-article-current))))
11945 (when (get-buffer gnus-original-article-buffer)
11946 (set-buffer gnus-original-article-buffer)
11947 (setq gnus-original-article nil)))
11948 (setq gnus-article-current nil
11949 gnus-current-article nil)
11950 (run-hooks 'gnus-article-display-hook)
11951 (and (gnus-visual-p 'summary-highlight 'highlight)
11952 (run-hooks 'gnus-visual-mark-article-hook)))))
11954 (defun gnus-summary-edit-article-postpone ()
11955 "Postpone changes to the current article."
11957 (gnus-article-mode)
11958 (use-local-map gnus-article-mode-map)
11959 (setq buffer-read-only t)
11960 (buffer-disable-undo (current-buffer))
11961 (gnus-configure-windows 'summary)
11962 (and (gnus-visual-p 'summary-highlight 'highlight)
11963 (run-hooks 'gnus-visual-mark-article-hook)))
11965 (defun gnus-summary-respool-query ()
11966 "Query where the respool algorithm would put this article."
11968 (gnus-set-global-variables)
11969 (gnus-summary-select-article)
11971 (set-buffer gnus-article-buffer)
11973 (goto-char (point-min))
11974 (search-forward "\n\n")
11975 (narrow-to-region (point-min) (point))
11976 (pp-eval-expression
11977 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11979 ;; Summary marking commands.
11981 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11982 "Mark articles which has the same subject as read, and then select the next.
11983 If UNMARK is positive, remove any kind of mark.
11984 If UNMARK is negative, tick articles."
11986 (gnus-set-global-variables)
11988 (setq unmark (prefix-numeric-value unmark)))
11990 (gnus-summary-mark-same-subject
11991 (gnus-summary-article-subject) unmark)))
11992 ;; Select next unread article. If auto-select-same mode, should
11993 ;; select the first unread article.
11994 (gnus-summary-next-article t (and gnus-auto-select-same
11995 (gnus-summary-article-subject)))
11996 (gnus-message 7 "%d article%s marked as %s"
11997 count (if (= count 1) " is" "s are")
11998 (if unmark "unread" "read"))))
12000 (defun gnus-summary-kill-same-subject (&optional unmark)
12001 "Mark articles which has the same subject as read.
12002 If UNMARK is positive, remove any kind of mark.
12003 If UNMARK is negative, tick articles."
12005 (gnus-set-global-variables)
12007 (setq unmark (prefix-numeric-value unmark)))
12009 (gnus-summary-mark-same-subject
12010 (gnus-summary-article-subject) unmark)))
12011 ;; If marked as read, go to next unread subject.
12013 ;; Go to next unread subject.
12014 (gnus-summary-next-subject 1 t))
12015 (gnus-message 7 "%d articles are marked as %s"
12016 count (if unmark "unread" "read"))))
12018 (defun gnus-summary-mark-same-subject (subject &optional unmark)
12019 "Mark articles with same SUBJECT as read, and return marked number.
12020 If optional argument UNMARK is positive, remove any kinds of marks.
12021 If optional argument UNMARK is negative, mark articles as unread instead."
12025 ((null unmark) ; Mark as read.
12028 (gnus-summary-mark-article-as-read gnus-killed-mark)
12029 (gnus-summary-show-thread) t)
12030 (gnus-summary-find-subject subject))
12031 (setq count (1+ count))))
12032 ((> unmark 0) ; Tick.
12035 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
12036 (gnus-summary-show-thread) t)
12037 (gnus-summary-find-subject subject))
12038 (setq count (1+ count))))
12039 (t ; Mark as unread.
12042 (gnus-summary-mark-article-as-unread gnus-unread-mark)
12043 (gnus-summary-show-thread) t)
12044 (gnus-summary-find-subject subject))
12045 (setq count (1+ count)))))
12046 (gnus-set-mode-line 'summary)
12047 ;; Return the number of marked articles.
12050 (defun gnus-summary-mark-as-processable (n &optional unmark)
12051 "Set the process mark on the next N articles.
12052 If N is negative, mark backward instead. If UNMARK is non-nil, remove
12053 the process mark instead. The difference between N and the actual
12054 number of articles marked is returned."
12056 (gnus-set-global-variables)
12057 (let ((backward (< n 0))
12062 (gnus-summary-remove-process-mark
12063 (gnus-summary-article-number))
12064 (gnus-summary-set-process-mark (gnus-summary-article-number)))
12065 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
12067 (if (/= 0 n) (gnus-message 7 "No more articles"))
12068 (gnus-summary-recenter)
12069 (gnus-summary-position-point)
12072 (defun gnus-summary-unmark-as-processable (n)
12073 "Remove the process mark from the next N articles.
12074 If N is negative, mark backward instead. The difference between N and
12075 the actual number of articles marked is returned."
12077 (gnus-set-global-variables)
12078 (gnus-summary-mark-as-processable n t))
12080 (defun gnus-summary-unmark-all-processable ()
12081 "Remove the process mark from all articles."
12083 (gnus-set-global-variables)
12085 (while gnus-newsgroup-processable
12086 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12087 (gnus-summary-position-point))
12089 (defun gnus-summary-mark-as-expirable (n)
12090 "Mark N articles forward as expirable.
12091 If N is negative, mark backward instead. The difference between N and
12092 the actual number of articles marked is returned."
12094 (gnus-set-global-variables)
12095 (gnus-summary-mark-forward n gnus-expirable-mark))
12097 (defun gnus-summary-mark-article-as-replied (article)
12098 "Mark ARTICLE replied and update the summary line."
12099 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12100 (let ((buffer-read-only nil))
12101 (when (gnus-summary-goto-subject article)
12102 (gnus-summary-update-secondary-mark article))))
12104 (defun gnus-summary-set-bookmark (article)
12105 "Set a bookmark in current article."
12106 (interactive (list (gnus-summary-article-number)))
12107 (gnus-set-global-variables)
12108 (if (or (not (get-buffer gnus-article-buffer))
12109 (not gnus-current-article)
12110 (not gnus-article-current)
12111 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12112 (error "No current article selected"))
12113 ;; Remove old bookmark, if one exists.
12114 (let ((old (assq article gnus-newsgroup-bookmarks)))
12115 (if old (setq gnus-newsgroup-bookmarks
12116 (delq old gnus-newsgroup-bookmarks))))
12117 ;; Set the new bookmark, which is on the form
12118 ;; (article-number . line-number-in-body).
12119 (setq gnus-newsgroup-bookmarks
12123 (set-buffer gnus-article-buffer)
12127 (goto-char (point-min))
12128 (search-forward "\n\n" nil t)
12131 gnus-newsgroup-bookmarks))
12132 (gnus-message 6 "A bookmark has been added to the current article."))
12134 (defun gnus-summary-remove-bookmark (article)
12135 "Remove the bookmark from the current article."
12136 (interactive (list (gnus-summary-article-number)))
12137 (gnus-set-global-variables)
12138 ;; Remove old bookmark, if one exists.
12139 (let ((old (assq article gnus-newsgroup-bookmarks)))
12142 (setq gnus-newsgroup-bookmarks
12143 (delq old gnus-newsgroup-bookmarks))
12144 (gnus-message 6 "Removed bookmark."))
12145 (gnus-message 6 "No bookmark in current article."))))
12147 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12148 (defun gnus-summary-mark-as-dormant (n)
12149 "Mark N articles forward as dormant.
12150 If N is negative, mark backward instead. The difference between N and
12151 the actual number of articles marked is returned."
12153 (gnus-set-global-variables)
12154 (gnus-summary-mark-forward n gnus-dormant-mark))
12156 (defun gnus-summary-set-process-mark (article)
12157 "Set the process mark on ARTICLE and update the summary line."
12158 (setq gnus-newsgroup-processable
12160 (delq article gnus-newsgroup-processable)))
12161 (when (gnus-summary-goto-subject article)
12162 (gnus-summary-show-thread)
12163 (gnus-summary-update-secondary-mark article)))
12165 (defun gnus-summary-remove-process-mark (article)
12166 "Remove the process mark from ARTICLE and update the summary line."
12167 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12168 (when (gnus-summary-goto-subject article)
12169 (gnus-summary-show-thread)
12170 (gnus-summary-update-secondary-mark article)))
12172 (defun gnus-summary-set-saved-mark (article)
12173 "Set the process mark on ARTICLE and update the summary line."
12174 (push article gnus-newsgroup-saved)
12175 (when (gnus-summary-goto-subject article)
12176 (gnus-summary-update-secondary-mark article)))
12178 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12179 "Mark N articles as read forwards.
12180 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12181 The difference between N and the actual number of articles marked is
12184 (gnus-set-global-variables)
12185 (let ((backward (< n 0))
12186 (gnus-summary-goto-unread
12187 (and gnus-summary-goto-unread
12188 (not (eq gnus-summary-goto-unread 'never))
12189 (not (memq mark (list gnus-unread-mark
12190 gnus-ticked-mark gnus-dormant-mark)))))
12192 (mark (or mark gnus-del-mark)))
12193 (while (and (> n 0)
12194 (gnus-summary-mark-article nil mark no-expire)
12195 (zerop (gnus-summary-next-subject
12197 (and gnus-summary-goto-unread
12198 (not (eq gnus-summary-goto-unread 'never)))
12201 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12202 (gnus-summary-recenter)
12203 (gnus-summary-position-point)
12204 (gnus-set-mode-line 'summary)
12207 (defun gnus-summary-mark-article-as-read (mark)
12208 "Mark the current article quickly as read with MARK."
12209 (let ((article (gnus-summary-article-number)))
12210 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12211 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12212 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12213 (setq gnus-newsgroup-reads
12214 (cons (cons article mark) gnus-newsgroup-reads))
12215 ;; Possibly remove from cache, if that is used.
12216 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12217 ;; Allow the backend to change the mark.
12218 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12219 ;; Check for auto-expiry.
12220 (when (and gnus-newsgroup-auto-expire
12221 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12222 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12223 (= mark gnus-ancient-mark)
12224 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12225 (setq mark gnus-expirable-mark)
12226 (push article gnus-newsgroup-expirable))
12227 ;; Set the mark in the buffer.
12228 (gnus-summary-update-mark mark 'unread)
12231 (defun gnus-summary-mark-article-as-unread (mark)
12232 "Mark the current article quickly as unread with MARK."
12233 (let ((article (gnus-summary-article-number)))
12235 (gnus-error 1 "Unmarkable article")
12236 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12237 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12238 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12239 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12240 (cond ((= mark gnus-ticked-mark)
12241 (push article gnus-newsgroup-marked))
12242 ((= mark gnus-dormant-mark)
12243 (push article gnus-newsgroup-dormant))
12245 (push article gnus-newsgroup-unreads)))
12246 (setq gnus-newsgroup-reads
12247 (delq (assq article gnus-newsgroup-reads)
12248 gnus-newsgroup-reads))
12250 ;; See whether the article is to be put in the cache.
12251 (and gnus-use-cache
12252 (vectorp (gnus-summary-article-header article))
12254 (gnus-cache-possibly-enter-article
12255 gnus-newsgroup-name article
12256 (gnus-summary-article-header article)
12257 (= mark gnus-ticked-mark)
12258 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12261 (gnus-summary-update-mark mark 'unread))
12264 (defun gnus-summary-mark-article (&optional article mark no-expire)
12265 "Mark ARTICLE with MARK. MARK can be any character.
12266 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12267 `??' (dormant) and `?E' (expirable).
12268 If MARK is nil, then the default character `?D' is used.
12269 If ARTICLE is nil, then the article on the current line will be
12271 ;; The mark might be a string.
12272 (and (stringp mark)
12273 (setq mark (aref mark 0)))
12274 ;; If no mark is given, then we check auto-expiring.
12275 (and (not no-expire)
12276 gnus-newsgroup-auto-expire
12278 (and (numberp mark)
12279 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12280 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12281 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12282 (setq mark gnus-expirable-mark))
12283 (let* ((mark (or mark gnus-del-mark))
12284 (article (or article (gnus-summary-article-number))))
12285 (or article (error "No article on current line"))
12286 (if (or (= mark gnus-unread-mark)
12287 (= mark gnus-ticked-mark)
12288 (= mark gnus-dormant-mark))
12289 (gnus-mark-article-as-unread article mark)
12290 (gnus-mark-article-as-read article mark))
12292 ;; See whether the article is to be put in the cache.
12293 (and gnus-use-cache
12294 (not (= mark gnus-canceled-mark))
12295 (vectorp (gnus-summary-article-header article))
12297 (gnus-cache-possibly-enter-article
12298 gnus-newsgroup-name article
12299 (gnus-summary-article-header article)
12300 (= mark gnus-ticked-mark)
12301 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12303 (if (gnus-summary-goto-subject article nil t)
12304 (let ((buffer-read-only nil))
12305 (gnus-summary-show-thread)
12307 (gnus-summary-update-mark mark 'unread)
12310 (defun gnus-summary-update-secondary-mark (article)
12311 "Update the secondary (read, process, cache) mark."
12312 (gnus-summary-update-mark
12313 (cond ((memq article gnus-newsgroup-processable)
12315 ((memq article gnus-newsgroup-cached)
12317 ((memq article gnus-newsgroup-replied)
12319 ((memq article gnus-newsgroup-saved)
12321 (t gnus-unread-mark))
12323 (when (gnus-visual-p 'summary-highlight 'highlight)
12324 (run-hooks 'gnus-summary-update-hook))
12327 (defun gnus-summary-update-mark (mark type)
12328 (beginning-of-line)
12329 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12330 (buffer-read-only nil))
12332 (<= (+ forward (point)) (point-max)))
12333 ;; Go to the right position on the line.
12334 (goto-char (+ forward (point)))
12335 ;; Replace the old mark with the new mark.
12336 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12337 ;; Optionally update the marks by some user rule.
12338 (when (eq type 'unread)
12339 (gnus-data-set-mark
12340 (gnus-data-find (gnus-summary-article-number)) mark)
12341 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12343 (defun gnus-mark-article-as-read (article &optional mark)
12344 "Enter ARTICLE in the pertinent lists and remove it from others."
12345 ;; Make the article expirable.
12346 (let ((mark (or mark gnus-del-mark)))
12347 (if (= mark gnus-expirable-mark)
12348 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12349 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12350 ;; Remove from unread and marked lists.
12351 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12352 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12353 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12354 (push (cons article mark) gnus-newsgroup-reads)
12355 ;; Possibly remove from cache, if that is used.
12356 (when gnus-use-cache
12357 (gnus-cache-enter-remove-article article))))
12359 (defun gnus-mark-article-as-unread (article &optional mark)
12360 "Enter ARTICLE in the pertinent lists and remove it from others."
12361 (let ((mark (or mark gnus-ticked-mark)))
12362 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12363 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12364 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12365 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12366 (cond ((= mark gnus-ticked-mark)
12367 (push article gnus-newsgroup-marked))
12368 ((= mark gnus-dormant-mark)
12369 (push article gnus-newsgroup-dormant))
12371 (push article gnus-newsgroup-unreads)))
12372 (setq gnus-newsgroup-reads
12373 (delq (assq article gnus-newsgroup-reads)
12374 gnus-newsgroup-reads))))
12376 (defalias 'gnus-summary-mark-as-unread-forward
12377 'gnus-summary-tick-article-forward)
12378 (make-obsolete 'gnus-summary-mark-as-unread-forward
12379 'gnus-summary-tick-article-forward)
12380 (defun gnus-summary-tick-article-forward (n)
12381 "Tick N articles forwards.
12382 If N is negative, tick backwards instead.
12383 The difference between N and the number of articles ticked is returned."
12385 (gnus-summary-mark-forward n gnus-ticked-mark))
12387 (defalias 'gnus-summary-mark-as-unread-backward
12388 'gnus-summary-tick-article-backward)
12389 (make-obsolete 'gnus-summary-mark-as-unread-backward
12390 'gnus-summary-tick-article-backward)
12391 (defun gnus-summary-tick-article-backward (n)
12392 "Tick N articles backwards.
12393 The difference between N and the number of articles ticked is returned."
12395 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12397 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12398 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12399 (defun gnus-summary-tick-article (&optional article clear-mark)
12400 "Mark current article as unread.
12401 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12402 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12404 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12405 gnus-ticked-mark)))
12407 (defun gnus-summary-mark-as-read-forward (n)
12408 "Mark N articles as read forwards.
12409 If N is negative, mark backwards instead.
12410 The difference between N and the actual number of articles marked is
12413 (gnus-summary-mark-forward n gnus-del-mark t))
12415 (defun gnus-summary-mark-as-read-backward (n)
12416 "Mark the N articles as read backwards.
12417 The difference between N and the actual number of articles marked is
12420 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12422 (defun gnus-summary-mark-as-read (&optional article mark)
12423 "Mark current article as read.
12424 ARTICLE specifies the article to be marked as read.
12425 MARK specifies a string to be inserted at the beginning of the line."
12426 (gnus-summary-mark-article article mark))
12428 (defun gnus-summary-clear-mark-forward (n)
12429 "Clear marks from N articles forward.
12430 If N is negative, clear backward instead.
12431 The difference between N and the number of marks cleared is returned."
12433 (gnus-summary-mark-forward n gnus-unread-mark))
12435 (defun gnus-summary-clear-mark-backward (n)
12436 "Clear marks from N articles backward.
12437 The difference between N and the number of marks cleared is returned."
12439 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12441 (defun gnus-summary-mark-unread-as-read ()
12442 "Intended to be used by `gnus-summary-mark-article-hook'."
12443 (when (memq gnus-current-article gnus-newsgroup-unreads)
12444 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12446 (defun gnus-summary-mark-read-and-unread-as-read ()
12447 "Intended to be used by `gnus-summary-mark-article-hook'."
12448 (let ((mark (gnus-summary-article-mark)))
12449 (when (or (gnus-unread-mark-p mark)
12450 (gnus-read-mark-p mark))
12451 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12453 (defun gnus-summary-mark-region-as-read (point mark all)
12454 "Mark all unread articles between point and mark as read.
12455 If given a prefix, mark all articles between point and mark as read,
12456 even ticked and dormant ones."
12457 (interactive "r\nP")
12461 (beginning-of-line)
12466 (memq (setq article (gnus-summary-article-number))
12467 gnus-newsgroup-unreads))
12468 (gnus-summary-mark-article article gnus-del-mark))
12470 (gnus-summary-find-next))))))
12472 (defun gnus-summary-mark-below (score mark)
12473 "Mark articles with score less than SCORE with MARK."
12474 (interactive "P\ncMark: ")
12475 (gnus-set-global-variables)
12476 (setq score (if score
12477 (prefix-numeric-value score)
12478 (or gnus-summary-default-score 0)))
12480 (set-buffer gnus-summary-buffer)
12481 (goto-char (point-min))
12484 (and (< (gnus-summary-article-score) score)
12485 (gnus-summary-mark-article nil mark))
12486 (gnus-summary-find-next)))))
12488 (defun gnus-summary-kill-below (&optional score)
12489 "Mark articles with score below SCORE as read."
12491 (gnus-set-global-variables)
12492 (gnus-summary-mark-below score gnus-killed-mark))
12494 (defun gnus-summary-clear-above (&optional score)
12495 "Clear all marks from articles with score above SCORE."
12497 (gnus-set-global-variables)
12498 (gnus-summary-mark-above score gnus-unread-mark))
12500 (defun gnus-summary-tick-above (&optional score)
12501 "Tick all articles with score above SCORE."
12503 (gnus-set-global-variables)
12504 (gnus-summary-mark-above score gnus-ticked-mark))
12506 (defun gnus-summary-mark-above (score mark)
12507 "Mark articles with score over SCORE with MARK."
12508 (interactive "P\ncMark: ")
12509 (gnus-set-global-variables)
12510 (setq score (if score
12511 (prefix-numeric-value score)
12512 (or gnus-summary-default-score 0)))
12514 (set-buffer gnus-summary-buffer)
12515 (goto-char (point-min))
12517 (if (> (gnus-summary-article-score) score)
12518 (gnus-summary-mark-article nil mark))
12520 (gnus-summary-find-next)))))
12522 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12523 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12524 (defun gnus-summary-limit-include-expunged (&optional no-error)
12525 "Display all the hidden articles that were expunged for low scores."
12527 (gnus-set-global-variables)
12528 (let ((buffer-read-only nil))
12529 (let ((scored gnus-newsgroup-scored)
12532 (or (gnus-summary-goto-subject (caar scored))
12533 (and (setq h (gnus-summary-article-header (caar scored)))
12534 (< (cdar scored) gnus-summary-expunge-below)
12535 (setq headers (cons h headers))))
12536 (setq scored (cdr scored)))
12538 (when (not no-error)
12539 (error "No expunged articles hidden."))
12540 (goto-char (point-min))
12541 (gnus-summary-prepare-unthreaded (nreverse headers))
12542 (goto-char (point-min))
12543 (gnus-summary-position-point)
12546 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12547 "Mark all articles not marked as unread in this newsgroup as read.
12548 If prefix argument ALL is non-nil, all articles are marked as read.
12549 If QUIETLY is non-nil, no questions will be asked.
12550 If TO-HERE is non-nil, it should be a point in the buffer. All
12551 articles before this point will be marked as read.
12552 The number of articles marked as read is returned."
12554 (gnus-set-global-variables)
12557 (not gnus-interactive-catchup) ;Without confirmation?
12561 "Mark absolutely all articles as read? "
12562 "Mark all unread articles as read? ")))
12564 (not gnus-newsgroup-adaptive)
12565 (not gnus-newsgroup-auto-expire))
12568 (setq gnus-newsgroup-marked nil
12569 gnus-newsgroup-dormant nil))
12570 (setq gnus-newsgroup-unreads nil))
12571 ;; We actually mark all articles as canceled, which we
12572 ;; have to do when using auto-expiry or adaptive scoring.
12573 (gnus-summary-show-all-threads)
12574 (if (gnus-summary-first-subject (not all))
12576 (if to-here (< (point) to-here) t)
12577 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12578 (gnus-summary-find-next (not all)))))
12580 (setq gnus-newsgroup-unreads nil))
12581 (gnus-set-mode-line 'summary)))
12582 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12583 (if (and (not to-here) (eq 'nnvirtual (car method)))
12584 (nnvirtual-catchup-group
12585 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12586 (gnus-summary-position-point)))
12588 (defun gnus-summary-catchup-to-here (&optional all)
12589 "Mark all unticked articles before the current one as read.
12590 If ALL is non-nil, also mark ticked and dormant articles as read."
12592 (gnus-set-global-variables)
12594 (gnus-save-hidden-threads
12595 (let ((beg (point)))
12596 ;; We check that there are unread articles.
12597 (when (or all (gnus-summary-find-prev))
12598 (gnus-summary-catchup all t beg)))))
12599 (gnus-summary-position-point))
12601 (defun gnus-summary-catchup-all (&optional quietly)
12602 "Mark all articles in this newsgroup as read."
12604 (gnus-set-global-variables)
12605 (gnus-summary-catchup t quietly))
12607 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12608 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12609 If prefix argument ALL is non-nil, all articles are marked as read."
12611 (gnus-set-global-variables)
12612 (gnus-summary-catchup all quietly nil 'fast)
12613 ;; Select next newsgroup or exit.
12614 (if (eq gnus-auto-select-next 'quietly)
12615 (gnus-summary-next-group nil)
12616 (gnus-summary-exit)))
12618 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12619 "Mark all articles in this newsgroup as read, and then exit."
12621 (gnus-set-global-variables)
12622 (gnus-summary-catchup-and-exit t quietly))
12624 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12625 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12626 "Mark all articles in this group as read and select the next group.
12627 If given a prefix, mark all articles, unread as well as ticked, as
12630 (gnus-set-global-variables)
12632 (gnus-summary-catchup all))
12633 (gnus-summary-next-article t nil nil t))
12635 ;; Thread-based commands.
12637 (defun gnus-summary-articles-in-thread (&optional article)
12638 "Return a list of all articles in the current thread.
12639 If ARTICLE is non-nil, return all articles in the thread that starts
12640 with that article."
12641 (let* ((article (or article (gnus-summary-article-number)))
12642 (data (gnus-data-find-list article))
12643 (top-level (gnus-data-level (car data)))
12645 (cond ((null gnus-thread-operation-ignore-subject)
12646 (gnus-simplify-subject-re
12647 (mail-header-subject (gnus-data-header (car data)))))
12648 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12649 (gnus-simplify-subject-fuzzy
12650 (mail-header-subject (gnus-data-header (car data)))))
12652 (end-point (save-excursion
12653 (if (gnus-summary-go-to-next-thread)
12654 (point) (point-max))))
12657 (< (gnus-data-pos (car data)) end-point))
12658 (when (or (not top-subject)
12659 (string= top-subject
12660 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12661 (gnus-simplify-subject-fuzzy
12662 (mail-header-subject
12663 (gnus-data-header (car data))))
12664 (gnus-simplify-subject-re
12665 (mail-header-subject
12666 (gnus-data-header (car data)))))))
12667 (push (gnus-data-number (car data)) articles))
12668 (unless (and (setq data (cdr data))
12669 (> (gnus-data-level (car data)) top-level))
12671 ;; Return the list of articles.
12672 (nreverse articles)))
12674 (defun gnus-summary-rethread-current ()
12675 "Rethread the thread the current article is part of."
12677 (gnus-set-global-variables)
12678 (let* ((gnus-show-threads t)
12679 (article (gnus-summary-article-number))
12680 (id (mail-header-id (gnus-summary-article-header)))
12681 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12683 (error "No article on the current line"))
12684 (gnus-rebuild-thread id)
12685 (gnus-summary-goto-subject article)))
12687 (defun gnus-summary-reparent-thread ()
12688 "Make current article child of the marked (or previous) article.
12690 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12691 is non-nil or the Subject: of both articles are the same."
12693 (or (not (gnus-group-read-only-p))
12694 (error "The current newsgroup does not support article editing."))
12695 (or (<= (length gnus-newsgroup-processable) 1)
12696 (error "No more than one article may be marked."))
12697 (save-window-excursion
12698 (let ((gnus-article-buffer " *reparent*")
12699 (current-article (gnus-summary-article-number))
12700 ; first grab the marked article, otherwise one line up.
12701 (parent-article (if (not (null gnus-newsgroup-processable))
12702 (car gnus-newsgroup-processable)
12704 (if (eq (forward-line -1) 0)
12705 (gnus-summary-article-number)
12706 (error "Beginning of summary buffer."))))))
12707 (or (not (eq current-article parent-article))
12708 (error "An article may not be self-referential."))
12709 (let ((message-id (mail-header-id
12710 (gnus-summary-article-header parent-article))))
12711 (or (and message-id (not (equal message-id "")))
12712 (error "No message-id in desired parent."))
12713 (gnus-summary-select-article t t nil current-article)
12714 (set-buffer gnus-article-buffer)
12715 (setq buffer-read-only nil)
12716 (let ((buf (format "%s" (buffer-string))))
12719 (goto-char (point-min))
12720 (if (search-forward-regexp "^References: " nil t)
12721 (insert message-id " " )
12722 (insert "References: " message-id "\n"))
12723 (or (gnus-request-replace-article current-article
12724 (car gnus-article-current)
12725 gnus-article-buffer)
12726 (error "Couldn't replace article."))
12727 (set-buffer gnus-summary-buffer)
12728 (gnus-summary-unmark-all-processable)
12729 (gnus-summary-rethread-current)
12730 (gnus-message 3 "Article %d is now the child of article %d."
12731 current-article parent-article)))))
12733 (defun gnus-summary-toggle-threads (&optional arg)
12734 "Toggle showing conversation threads.
12735 If ARG is positive number, turn showing conversation threads on."
12737 (gnus-set-global-variables)
12738 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12739 (setq gnus-show-threads
12740 (if (null arg) (not gnus-show-threads)
12741 (> (prefix-numeric-value arg) 0)))
12742 (gnus-summary-prepare)
12743 (gnus-summary-goto-subject current)
12744 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
12745 (gnus-summary-position-point)))
12747 (defun gnus-summary-show-all-threads ()
12748 "Show all threads."
12750 (gnus-set-global-variables)
12752 (let ((buffer-read-only nil))
12753 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12754 (gnus-summary-position-point))
12756 (defun gnus-summary-show-thread ()
12757 "Show thread subtrees.
12758 Returns nil if no thread was there to be shown."
12760 (gnus-set-global-variables)
12761 (let ((buffer-read-only nil)
12763 ;; first goto end then to beg, to have point at beg after let
12764 (end (progn (end-of-line) (point)))
12765 (beg (progn (beginning-of-line) (point))))
12767 ;; Any hidden lines here?
12768 (search-forward "\r" end t)
12769 (subst-char-in-region beg end ?\^M ?\n t)
12771 (gnus-summary-position-point))))
12773 (defun gnus-summary-hide-all-threads ()
12774 "Hide all thread subtrees."
12776 (gnus-set-global-variables)
12778 (goto-char (point-min))
12779 (gnus-summary-hide-thread)
12780 (while (zerop (gnus-summary-next-thread 1 t))
12781 (gnus-summary-hide-thread)))
12782 (gnus-summary-position-point))
12784 (defun gnus-summary-hide-thread ()
12785 "Hide thread subtrees.
12786 Returns nil if no threads were there to be hidden."
12788 (gnus-set-global-variables)
12789 (let ((buffer-read-only nil)
12791 (article (gnus-summary-article-number)))
12793 ;; Go forward until either the buffer ends or the subthread
12795 (when (and (not (eobp))
12796 (or (zerop (gnus-summary-next-thread 1 t))
12797 (goto-char (point-max))))
12799 (if (and (> (point) start)
12800 (search-backward "\n" start t))
12802 (subst-char-in-region start (point) ?\n ?\^M)
12803 (gnus-summary-goto-subject article))
12806 ;;(gnus-summary-position-point)
12809 (defun gnus-summary-go-to-next-thread (&optional previous)
12810 "Go to the same level (or less) next thread.
12811 If PREVIOUS is non-nil, go to previous thread instead.
12812 Return the article number moved to, or nil if moving was impossible."
12813 (let ((level (gnus-summary-thread-level))
12814 (way (if previous -1 1))
12817 (while (and (not (eobp))
12818 (< level (gnus-summary-thread-level)))
12819 (forward-line way))
12826 (gnus-summary-article-number)
12827 (goto-char beg)))))
12829 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12830 "Go to the same level (or less) next thread.
12831 If PREVIOUS is non-nil, go to previous thread instead.
12832 Return the article number moved to, or nil if moving was impossible."
12833 (if (and (eq gnus-summary-make-false-root 'dummy)
12834 (gnus-summary-article-intangible-p))
12835 (let ((beg (point)))
12836 (while (and (zerop (forward-line 1))
12837 (not (gnus-summary-article-intangible-p))
12838 (not (zerop (save-excursion
12839 (gnus-summary-thread-level))))))
12845 (let* ((level (gnus-summary-thread-level))
12846 (article (gnus-summary-article-number))
12847 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12850 (if (<= (gnus-data-level (car data)) level)
12851 (setq oart (gnus-data-number (car data))
12853 (setq data (cdr data))))
12855 (gnus-summary-goto-subject oart)))))
12857 (defun gnus-summary-next-thread (n &optional silent)
12858 "Go to the same level next N'th thread.
12859 If N is negative, search backward instead.
12860 Returns the difference between N and the number of skips actually
12863 If SILENT, don't output messages."
12865 (gnus-set-global-variables)
12866 (let ((backward (< n 0))
12869 (while (and (> n 0)
12870 (gnus-summary-go-to-next-thread backward))
12873 (gnus-summary-position-point))
12874 (when (and (not silent) (/= 0 n))
12875 (gnus-message 7 "No more threads"))
12878 (defun gnus-summary-prev-thread (n)
12879 "Go to the same level previous N'th thread.
12880 Returns the difference between N and the number of skips actually
12883 (gnus-set-global-variables)
12884 (gnus-summary-next-thread (- n)))
12886 (defun gnus-summary-go-down-thread ()
12887 "Go down one level in the current thread."
12888 (let ((children (gnus-summary-article-children)))
12890 (gnus-summary-goto-subject (car children)))))
12892 (defun gnus-summary-go-up-thread ()
12893 "Go up one level in the current thread."
12894 (let ((parent (gnus-summary-article-parent)))
12896 (gnus-summary-goto-subject parent))))
12898 (defun gnus-summary-down-thread (n)
12899 "Go down thread N steps.
12900 If N is negative, go up instead.
12901 Returns the difference between N and how many steps down that were
12904 (gnus-set-global-variables)
12907 (while (and (> n 0)
12908 (if up (gnus-summary-go-up-thread)
12909 (gnus-summary-go-down-thread)))
12911 (gnus-summary-position-point)
12912 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12915 (defun gnus-summary-up-thread (n)
12916 "Go up thread N steps.
12917 If N is negative, go up instead.
12918 Returns the difference between N and how many steps down that were
12921 (gnus-set-global-variables)
12922 (gnus-summary-down-thread (- n)))
12924 (defun gnus-summary-top-thread ()
12925 "Go to the top of the thread."
12927 (gnus-set-global-variables)
12928 (while (gnus-summary-go-up-thread))
12929 (gnus-summary-article-number))
12931 (defun gnus-summary-kill-thread (&optional unmark)
12932 "Mark articles under current thread as read.
12933 If the prefix argument is positive, remove any kinds of marks.
12934 If the prefix argument is negative, tick articles instead."
12936 (gnus-set-global-variables)
12938 (setq unmark (prefix-numeric-value unmark)))
12939 (let ((articles (gnus-summary-articles-in-thread)))
12941 ;; Expand the thread.
12942 (gnus-summary-show-thread)
12943 ;; Mark all the articles.
12945 (gnus-summary-goto-subject (car articles))
12946 (cond ((null unmark)
12947 (gnus-summary-mark-article-as-read gnus-killed-mark))
12949 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12951 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12952 (setq articles (cdr articles))))
12953 ;; Hide killed subtrees.
12955 gnus-thread-hide-killed
12956 (gnus-summary-hide-thread))
12957 ;; If marked as read, go to next unread subject.
12959 ;; Go to next unread subject.
12960 (gnus-summary-next-subject 1 t)))
12961 (gnus-set-mode-line 'summary))
12963 ;; Summary sorting commands
12965 (defun gnus-summary-sort-by-number (&optional reverse)
12966 "Sort summary buffer by article number.
12967 Argument REVERSE means reverse order."
12969 (gnus-summary-sort 'number reverse))
12971 (defun gnus-summary-sort-by-author (&optional reverse)
12972 "Sort summary buffer by author name alphabetically.
12973 If case-fold-search is non-nil, case of letters is ignored.
12974 Argument REVERSE means reverse order."
12976 (gnus-summary-sort 'author reverse))
12978 (defun gnus-summary-sort-by-subject (&optional reverse)
12979 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12980 If case-fold-search is non-nil, case of letters is ignored.
12981 Argument REVERSE means reverse order."
12983 (gnus-summary-sort 'subject reverse))
12985 (defun gnus-summary-sort-by-date (&optional reverse)
12986 "Sort summary buffer by date.
12987 Argument REVERSE means reverse order."
12989 (gnus-summary-sort 'date reverse))
12991 (defun gnus-summary-sort-by-score (&optional reverse)
12992 "Sort summary buffer by score.
12993 Argument REVERSE means reverse order."
12995 (gnus-summary-sort 'score reverse))
12997 (defun gnus-summary-sort (predicate reverse)
12998 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12999 (gnus-set-global-variables)
13000 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
13001 (article (intern (format "gnus-article-sort-by-%s" predicate)))
13002 (gnus-thread-sort-functions
13007 (,thread t2 t1)))))
13008 (gnus-article-sort-functions
13013 (,article t2 t1)))))
13015 (gnus-summary-prepare-hook nil))
13016 ;; We do the sorting by regenerating the threads.
13017 (gnus-summary-prepare)
13018 ;; Hide subthreads if needed.
13019 (when (and gnus-show-threads gnus-thread-hide-subtree)
13020 (gnus-summary-hide-all-threads)))
13021 ;; If in async mode, we send some info to the backend.
13022 (when gnus-newsgroup-async
13023 (gnus-request-asynchronous
13024 gnus-newsgroup-name gnus-newsgroup-data)))
13026 (defun gnus-sortable-date (date)
13027 "Make sortable string by string-lessp from DATE.
13028 Timezone package is used."
13031 (setq date (inline (timezone-fix-time
13033 (aref (inline (timezone-parse-date date)) 4))))
13035 (timezone-make-sortable-date
13036 (aref date 0) (aref date 1) (aref date 2)
13038 (timezone-make-time-string
13039 (aref date 3) (aref date 4) (aref date 5))))))
13042 ;; Summary saving commands.
13044 (defun gnus-summary-save-article (&optional n not-saved)
13045 "Save the current article using the default saver function.
13046 If N is a positive number, save the N next articles.
13047 If N is a negative number, save the N previous articles.
13048 If N is nil and any articles have been marked with the process mark,
13049 save those articles instead.
13050 The variable `gnus-default-article-saver' specifies the saver function."
13052 (gnus-set-global-variables)
13053 (let ((articles (gnus-summary-work-articles n))
13054 (save-buffer (save-excursion
13055 (nnheader-set-temp-buffer " *Gnus Save*")))
13056 file header article)
13058 (setq header (gnus-summary-article-header
13059 (setq article (pop articles))))
13060 (if (not (vectorp header))
13061 ;; This is a pseudo-article.
13062 (if (assq 'name header)
13063 (gnus-copy-file (cdr (assq 'name header)))
13064 (gnus-message 1 "Article %d is unsaveable" article))
13065 ;; This is a real article.
13066 (save-window-excursion
13067 (gnus-summary-select-article t nil nil article))
13069 (set-buffer save-buffer)
13071 (insert-buffer-substring gnus-original-article-buffer))
13072 (unless gnus-save-all-headers
13073 ;; Remove headers accoring to `gnus-saved-headers'.
13074 (let ((gnus-visible-headers
13075 (or gnus-saved-headers gnus-visible-headers))
13076 (gnus-article-buffer save-buffer))
13077 (gnus-article-hide-headers 1 t)))
13078 (save-window-excursion
13079 (if (not gnus-default-article-saver)
13080 (error "No default saver is defined.")
13081 ;; !!! Magic! The saving functions all save
13082 ;; `gnus-original-article-buffer' (or so they think),
13083 ;; but we bind that variable to our save-buffer.
13084 (set-buffer gnus-article-buffer)
13085 (let ((gnus-original-article-buffer save-buffer))
13086 (set-buffer gnus-summary-buffer)
13087 (setq file (funcall
13088 gnus-default-article-saver
13090 ((not gnus-prompt-before-saving)
13092 ((eq gnus-prompt-before-saving 'always)
13095 (gnus-summary-remove-process-mark article)
13097 (gnus-summary-set-saved-mark article))))
13098 (gnus-kill-buffer save-buffer)
13099 (gnus-summary-position-point)
13102 (defun gnus-summary-pipe-output (&optional arg)
13103 "Pipe the current article to a subprocess.
13104 If N is a positive number, pipe the N next articles.
13105 If N is a negative number, pipe the N previous articles.
13106 If N is nil and any articles have been marked with the process mark,
13107 pipe those articles instead."
13109 (gnus-set-global-variables)
13110 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13111 (gnus-summary-save-article arg t))
13112 (gnus-configure-windows 'pipe))
13114 (defun gnus-summary-save-article-mail (&optional arg)
13115 "Append the current article to an mail file.
13116 If N is a positive number, save the N next articles.
13117 If N is a negative number, save the N previous articles.
13118 If N is nil and any articles have been marked with the process mark,
13119 save those articles instead."
13121 (gnus-set-global-variables)
13122 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13123 (gnus-summary-save-article arg)))
13125 (defun gnus-summary-save-article-rmail (&optional arg)
13126 "Append the current article to an rmail file.
13127 If N is a positive number, save the N next articles.
13128 If N is a negative number, save the N previous articles.
13129 If N is nil and any articles have been marked with the process mark,
13130 save those articles instead."
13132 (gnus-set-global-variables)
13133 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13134 (gnus-summary-save-article arg)))
13136 (defun gnus-summary-save-article-file (&optional arg)
13137 "Append the current article to a file.
13138 If N is a positive number, save the N next articles.
13139 If N is a negative number, save the N previous articles.
13140 If N is nil and any articles have been marked with the process mark,
13141 save those articles instead."
13143 (gnus-set-global-variables)
13144 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13145 (gnus-summary-save-article arg)))
13147 (defun gnus-summary-save-article-body-file (&optional arg)
13148 "Append the current article body to a file.
13149 If N is a positive number, save the N next articles.
13150 If N is a negative number, save the N previous articles.
13151 If N is nil and any articles have been marked with the process mark,
13152 save those articles instead."
13154 (gnus-set-global-variables)
13155 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13156 (gnus-summary-save-article arg)))
13158 (defun gnus-get-split-value (methods)
13159 "Return a value based on the split METHODS."
13160 (let (split-name method result match)
13163 (set-buffer gnus-original-article-buffer)
13165 (nnheader-narrow-to-headers)
13167 (goto-char (point-min))
13168 (setq method (pop methods))
13169 (setq match (car method))
13172 ;; Regular expression.
13174 (re-search-forward match nil t)
13176 ((gnus-functionp match)
13180 (setq result (funcall match gnus-newsgroup-name))))
13185 (setq result (eval match)))))
13186 (setq split-name (append (cdr method) split-name))
13187 (cond ((stringp result)
13188 (push result split-name))
13190 (setq split-name (append result split-name)))))))))
13193 (defun gnus-read-move-group-name (prompt default articles prefix)
13194 "Read a group name."
13195 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13196 (minibuffer-confirm-incomplete nil) ; XEmacs
13203 (assoc (symbol-name
13204 (car (gnus-find-method-for-group
13206 gnus-valid-select-methods))
13207 (push (list (symbol-name g)) group-map)))
13208 gnus-active-hashtb))
13210 (format "%s %s to:"
13212 (if (> (length articles) 1)
13213 (format "these %d articles" (length articles))
13218 (gnus-completing-read default prom
13219 group-map nil nil prefix
13220 'gnus-group-history))
13221 ((= 1 (length split-name))
13222 (gnus-completing-read (car split-name) prom group-map
13224 'gnus-group-history))
13226 (gnus-completing-read nil prom
13227 (mapcar (lambda (el) (list el))
13228 (nreverse split-name))
13230 'gnus-group-history)))))
13232 (if (or (string= to-newsgroup "")
13233 (string= to-newsgroup prefix))
13234 (setq to-newsgroup (or default "")))
13235 (or (gnus-active to-newsgroup)
13236 (gnus-activate-group to-newsgroup)
13237 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13239 (or (and (gnus-request-create-group
13240 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13241 (gnus-activate-group to-newsgroup nil nil
13242 (gnus-group-name-to-method
13244 (error "Couldn't create group %s" to-newsgroup)))
13245 (error "No such group: %s" to-newsgroup)))
13248 (defun gnus-read-save-file-name (prompt default-name)
13249 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13251 ;; Let the split methods have their say.
13253 ;; No split name was found.
13256 (concat prompt " (default "
13257 (file-name-nondirectory default-name) ") ")
13258 (file-name-directory default-name)
13260 ;; A single split name was found
13261 ((= 1 (length split-name))
13262 (let* ((name (car split-name))
13263 (dir (cond ((file-directory-p name)
13264 (file-name-as-directory name))
13265 ((file-exists-p name) name)
13266 (t gnus-article-save-directory))))
13268 (concat prompt " (default " name ") ")
13270 ;; A list of splits was found.
13272 (setq split-name (nreverse split-name))
13274 (let ((file-name-history (nconc split-name file-name-history)))
13277 (concat prompt " (`M-p' for defaults) ")
13278 gnus-article-save-directory
13279 (car split-name))))
13280 (car (push result file-name-history)))))))
13281 ;; If we have read a directory, we append the default file name.
13282 (when (file-directory-p file)
13283 (setq file (concat (file-name-as-directory file)
13284 (file-name-nondirectory default-name))))
13285 ;; Possibly translate some charaters.
13286 (nnheader-translate-file-chars file)))
13288 (defun gnus-article-archive-name (group)
13289 "Return the first instance of an \"Archive-name\" in the current buffer."
13290 (let ((case-fold-search t))
13291 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13292 (match-string 1))))
13294 (defun gnus-summary-save-in-rmail (&optional filename)
13295 "Append this article to Rmail file.
13296 Optional argument FILENAME specifies file name.
13297 Directory to save to is default to `gnus-article-save-directory'."
13299 (gnus-set-global-variables)
13300 (let ((default-name
13301 (funcall gnus-rmail-save-name gnus-newsgroup-name
13302 gnus-current-headers gnus-newsgroup-last-rmail)))
13304 (cond ((eq filename 'default)
13306 (filename filename)
13307 (t (gnus-read-save-file-name
13308 "Save in rmail file:" default-name))))
13309 (gnus-make-directory (file-name-directory filename))
13310 (gnus-eval-in-buffer-window gnus-original-article-buffer
13314 (gnus-output-to-rmail filename))))
13315 ;; Remember the directory name to save articles
13316 (setq gnus-newsgroup-last-rmail filename)))
13318 (defun gnus-summary-save-in-mail (&optional filename)
13319 "Append this article to Unix mail file.
13320 Optional argument FILENAME specifies file name.
13321 Directory to save to is default to `gnus-article-save-directory'."
13323 (gnus-set-global-variables)
13324 (let ((default-name
13325 (funcall gnus-mail-save-name gnus-newsgroup-name
13326 gnus-current-headers gnus-newsgroup-last-mail)))
13328 (cond ((eq filename 'default)
13330 (filename filename)
13331 (t (gnus-read-save-file-name
13332 "Save in Unix mail file:" default-name))))
13334 (expand-file-name filename
13336 (file-name-directory default-name))))
13337 (gnus-make-directory (file-name-directory filename))
13338 (gnus-eval-in-buffer-window gnus-original-article-buffer
13342 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13343 (gnus-output-to-rmail filename)
13344 (let ((mail-use-rfc822 t))
13345 (rmail-output filename 1 t t))))))
13346 ;; Remember the directory name to save articles.
13347 (setq gnus-newsgroup-last-mail filename)))
13349 (defun gnus-summary-save-in-file (&optional filename)
13350 "Append this article to file.
13351 Optional argument FILENAME specifies file name.
13352 Directory to save to is default to `gnus-article-save-directory'."
13354 (gnus-set-global-variables)
13355 (let ((default-name
13356 (funcall gnus-file-save-name gnus-newsgroup-name
13357 gnus-current-headers gnus-newsgroup-last-file)))
13359 (cond ((eq filename 'default)
13361 (filename filename)
13362 (t (gnus-read-save-file-name
13363 "Save in file:" default-name))))
13364 (gnus-make-directory (file-name-directory filename))
13365 (gnus-eval-in-buffer-window gnus-original-article-buffer
13369 (gnus-output-to-file filename))))
13370 ;; Remember the directory name to save articles.
13371 (setq gnus-newsgroup-last-file filename)))
13373 (defun gnus-summary-save-body-in-file (&optional filename)
13374 "Append this article body to a file.
13375 Optional argument FILENAME specifies file name.
13376 The directory to save in defaults to `gnus-article-save-directory'."
13378 (gnus-set-global-variables)
13379 (let ((default-name
13380 (funcall gnus-file-save-name gnus-newsgroup-name
13381 gnus-current-headers gnus-newsgroup-last-file)))
13383 (cond ((eq filename 'default)
13385 (filename filename)
13386 (t (gnus-read-save-file-name
13387 "Save body in file:" default-name))))
13388 (gnus-make-directory (file-name-directory filename))
13389 (gnus-eval-in-buffer-window gnus-original-article-buffer
13393 (goto-char (point-min))
13394 (and (search-forward "\n\n" nil t)
13395 (narrow-to-region (point) (point-max)))
13396 (gnus-output-to-file filename))))
13397 ;; Remember the directory name to save articles.
13398 (setq gnus-newsgroup-last-file filename)))
13400 (defun gnus-summary-save-in-pipe (&optional command)
13401 "Pipe this article to subprocess."
13403 (gnus-set-global-variables)
13405 (cond ((eq command 'default)
13406 gnus-last-shell-command)
13408 (t (read-string "Shell command on article: "
13409 gnus-last-shell-command))))
13410 (if (string-equal command "")
13411 (setq command gnus-last-shell-command))
13412 (gnus-eval-in-buffer-window gnus-article-buffer
13415 (shell-command-on-region (point-min) (point-max) command nil)))
13416 (setq gnus-last-shell-command command))
13418 ;; Summary extract commands
13420 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13421 (let ((buffer-read-only nil)
13422 (article (gnus-summary-article-number))
13424 (or (gnus-summary-goto-subject article)
13425 (error (format "No such article: %d" article)))
13426 (gnus-summary-position-point)
13427 ;; If all commands are to be bunched up on one line, we collect
13429 (if gnus-view-pseudos-separately
13431 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13434 (setq action (cdr (assq 'action (car ps))))
13435 (setq files (list (cdr (assq 'name (car ps)))))
13436 (while (and ps (cdr ps)
13437 (string= (or action "1")
13438 (or (cdr (assq 'action (cadr ps))) "2")))
13439 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13440 (setcdr ps (cddr ps)))
13443 (if (not (string-match "%s" action))
13444 (setq files (cons " " files)))
13445 (setq files (cons " " files))
13446 (and (assq 'execute (car ps))
13447 (setcdr (assq 'execute (car ps))
13448 (funcall (if (string-match "%s" action)
13451 (mapconcat (lambda (f) f) files " ")))))
13452 (setq ps (cdr ps)))))
13453 (if (and gnus-view-pseudos (not not-view))
13455 (and (assq 'execute (car pslist))
13456 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13457 (eq gnus-view-pseudos 'not-confirm)))
13458 (setq pslist (cdr pslist)))
13461 (setq after-article (or (cdr (assq 'article (car pslist)))
13462 (gnus-summary-article-number)))
13463 (gnus-summary-goto-subject after-article)
13466 (insert " " (file-name-nondirectory
13467 (cdr (assq 'name (car pslist))))
13468 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13470 (forward-line -1) ; back to `b'
13471 (gnus-add-text-properties
13472 b (1- e) (list 'gnus-number gnus-reffed-article-number
13473 gnus-mouse-face-prop gnus-mouse-face))
13475 after-article gnus-reffed-article-number
13476 gnus-unread-mark b (car pslist) 0 (- e b))
13477 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13478 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13479 (setq pslist (cdr pslist)))))))
13481 (defun gnus-pseudos< (p1 p2)
13482 (let ((c1 (cdr (assq 'action p1)))
13483 (c2 (cdr (assq 'action p2))))
13484 (and c1 c2 (string< c1 c2))))
13486 (defun gnus-request-pseudo-article (props)
13487 (cond ((assq 'execute props)
13488 (gnus-execute-command (cdr (assq 'execute props)))))
13489 (let ((gnus-current-article (gnus-summary-article-number)))
13490 (run-hooks 'gnus-mark-article-hook)))
13492 (defun gnus-execute-command (command &optional automatic)
13494 (gnus-article-setup-buffer)
13495 (set-buffer gnus-article-buffer)
13496 (setq buffer-read-only nil)
13497 (let ((command (if automatic command (read-string "Command: " command)))
13498 ;; Just binding this here doesn't help, because there might
13499 ;; be output from the process after exiting the scope of
13501 ;; (buffer-read-only nil)
13504 (insert "$ " command "\n\n")
13505 (if gnus-view-pseudo-asynchronously
13506 (start-process "gnus-execute" nil shell-file-name
13507 shell-command-switch command)
13508 (call-process shell-file-name nil t nil
13509 shell-command-switch command)))))
13511 (defun gnus-copy-file (file &optional to)
13514 (list (read-file-name "Copy file: " default-directory)
13515 (read-file-name "Copy file to: " default-directory)))
13516 (gnus-set-global-variables)
13517 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13518 (and (file-directory-p to)
13519 (setq to (concat (file-name-as-directory to)
13520 (file-name-nondirectory file))))
13521 (copy-file file to))
13523 ;; Summary kill commands.
13525 (defun gnus-summary-edit-global-kill (article)
13526 "Edit the \"global\" kill file."
13527 (interactive (list (gnus-summary-article-number)))
13528 (gnus-set-global-variables)
13529 (gnus-group-edit-global-kill article))
13531 (defun gnus-summary-edit-local-kill ()
13532 "Edit a local kill file applied to the current newsgroup."
13534 (gnus-set-global-variables)
13535 (setq gnus-current-headers (gnus-summary-article-header))
13536 (gnus-set-global-variables)
13537 (gnus-group-edit-local-kill
13538 (gnus-summary-article-number) gnus-newsgroup-name))
13542 ;;; Gnus article mode
13545 (put 'gnus-article-mode 'mode-class 'special)
13547 (if gnus-article-mode-map
13549 (setq gnus-article-mode-map (make-keymap))
13550 (suppress-keymap gnus-article-mode-map)
13552 (gnus-define-keys gnus-article-mode-map
13553 " " gnus-article-goto-next-page
13554 "\177" gnus-article-goto-prev-page
13555 [delete] gnus-article-goto-prev-page
13556 "\C-c^" gnus-article-refer-article
13557 "h" gnus-article-show-summary
13558 "s" gnus-article-show-summary
13559 "\C-c\C-m" gnus-article-mail
13560 "?" gnus-article-describe-briefly
13561 gnus-mouse-2 gnus-article-push-button
13562 "\r" gnus-article-press-button
13563 "\t" gnus-article-next-button
13564 "\M-\t" gnus-article-prev-button
13565 "<" beginning-of-buffer
13567 "\C-c\C-i" gnus-info-find-node
13568 "\C-c\C-b" gnus-bug)
13570 (substitute-key-definition
13571 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13573 (defun gnus-article-mode ()
13574 "Major mode for displaying an article.
13576 All normal editing commands are switched off.
13578 The following commands are available:
13580 \\<gnus-article-mode-map>
13581 \\[gnus-article-next-page]\t Scroll the article one page forwards
13582 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13583 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13584 \\[gnus-article-show-summary]\t Display the summary buffer
13585 \\[gnus-article-mail]\t Send a reply to the address near point
13586 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13587 \\[gnus-info-find-node]\t Go to the Gnus info node"
13589 (when (and menu-bar-mode
13590 (gnus-visual-p 'article-menu 'menu))
13591 (gnus-article-make-menu-bar))
13592 (kill-all-local-variables)
13593 (gnus-simplify-mode-line)
13594 (setq mode-name "Article")
13595 (setq major-mode 'gnus-article-mode)
13596 (make-local-variable 'minor-mode-alist)
13597 (or (assq 'gnus-show-mime minor-mode-alist)
13598 (setq minor-mode-alist
13599 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13600 (use-local-map gnus-article-mode-map)
13601 (make-local-variable 'page-delimiter)
13602 (setq page-delimiter gnus-page-delimiter)
13603 (buffer-disable-undo (current-buffer))
13604 (setq buffer-read-only t) ;Disable modification
13605 (run-hooks 'gnus-article-mode-hook))
13607 (defun gnus-article-setup-buffer ()
13608 "Initialize the article buffer."
13609 (let* ((name (if gnus-single-article-buffer "*Article*"
13610 (concat "*Article " gnus-newsgroup-name "*")))
13612 (progn (string-match "\\*Article" name)
13613 (concat " *Original Article"
13614 (substring name (match-end 0))))))
13615 (setq gnus-article-buffer name)
13616 (setq gnus-original-article-buffer original)
13617 ;; This might be a variable local to the summary buffer.
13618 (unless gnus-single-article-buffer
13620 (set-buffer gnus-summary-buffer)
13621 (setq gnus-article-buffer name)
13622 (setq gnus-original-article-buffer original)
13623 (gnus-set-global-variables))
13624 (make-local-variable 'gnus-summary-buffer))
13625 ;; Init original article buffer.
13627 (set-buffer (get-buffer-create gnus-original-article-buffer))
13628 (buffer-disable-undo (current-buffer))
13629 (setq major-mode 'gnus-original-article-mode)
13630 (gnus-add-current-to-buffer-list)
13631 (make-local-variable 'gnus-original-article))
13632 (if (get-buffer name)
13635 (buffer-disable-undo (current-buffer))
13636 (setq buffer-read-only t)
13637 (gnus-add-current-to-buffer-list)
13638 (or (eq major-mode 'gnus-article-mode)
13639 (gnus-article-mode))
13642 (set-buffer (get-buffer-create name))
13643 (gnus-add-current-to-buffer-list)
13644 (gnus-article-mode)
13645 (current-buffer)))))
13647 ;; Set article window start at LINE, where LINE is the number of lines
13648 ;; from the head of the article.
13649 (defun gnus-article-set-window-start (&optional line)
13651 (get-buffer-window gnus-article-buffer t)
13653 (set-buffer gnus-article-buffer)
13654 (goto-char (point-min))
13657 (gnus-message 6 "Moved to bookmark")
13658 (search-forward "\n\n" nil t)
13659 (forward-line line)
13662 (defun gnus-kill-all-overlays ()
13663 "Delete all overlays in the current buffer."
13664 (when (fboundp 'overlay-lists)
13665 (let* ((overlayss (overlay-lists))
13666 (buffer-read-only nil)
13667 (overlays (nconc (car overlayss) (cdr overlayss))))
13669 (delete-overlay (pop overlays))))))
13671 (defun gnus-request-article-this-buffer (article group)
13672 "Get an article and insert it into this buffer."
13673 (let (do-update-line)
13677 (gnus-kill-all-overlays)
13678 (setq group (or group gnus-newsgroup-name))
13680 ;; Open server if it has closed.
13681 (gnus-check-server (gnus-find-method-for-group group))
13683 ;; Using `gnus-request-article' directly will insert the article into
13684 ;; `nntp-server-buffer' - so we'll save some time by not having to
13685 ;; copy it from the server buffer into the article buffer.
13687 ;; We only request an article by message-id when we do not have the
13688 ;; headers for it, so we'll have to get those.
13689 (when (stringp article)
13690 (let ((gnus-override-method gnus-refer-article-method))
13691 (gnus-read-header article)))
13693 ;; If the article number is negative, that means that this article
13694 ;; doesn't belong in this newsgroup (possibly), so we find its
13695 ;; message-id and request it by id instead of number.
13696 (when (and (numberp article)
13697 gnus-summary-buffer
13698 (get-buffer gnus-summary-buffer)
13699 (buffer-name (get-buffer gnus-summary-buffer)))
13701 (set-buffer gnus-summary-buffer)
13702 (let ((header (gnus-summary-article-header article)))
13705 ((memq article gnus-newsgroup-sparse)
13706 ;; This is a sparse gap article.
13707 (setq do-update-line article)
13708 (setq article (mail-header-id header))
13709 (let ((gnus-override-method gnus-refer-article-method))
13710 (gnus-read-header article))
13711 (setq gnus-newsgroup-sparse
13712 (delq article gnus-newsgroup-sparse)))
13714 ;; It's a real article.
13715 (setq article (mail-header-id header)))
13717 ;; It is an extracted pseudo-article.
13718 (setq article 'pseudo)
13719 (gnus-request-pseudo-article header))))
13721 (let ((method (gnus-find-method-for-group
13722 gnus-newsgroup-name)))
13723 (if (not (eq (car method) 'nneething))
13725 (let ((dir (concat (file-name-as-directory (nth 1 method))
13726 (mail-header-subject header))))
13727 (if (file-directory-p dir)
13729 (setq article 'nneething)
13730 (gnus-group-enter-directory dir)))))))))
13733 ;; Refuse to select canceled articles.
13734 ((and (numberp article)
13735 gnus-summary-buffer
13736 (get-buffer gnus-summary-buffer)
13737 (buffer-name (get-buffer gnus-summary-buffer))
13738 (eq (cdr (save-excursion
13739 (set-buffer gnus-summary-buffer)
13740 (assq article gnus-newsgroup-reads)))
13741 gnus-canceled-mark))
13743 ;; We first check `gnus-original-article-buffer'.
13744 ((and (get-buffer gnus-original-article-buffer)
13747 (set-buffer gnus-original-article-buffer)
13748 (and (equal (car gnus-original-article) group)
13749 (eq (cdr gnus-original-article) article))))
13750 (insert-buffer-substring gnus-original-article-buffer)
13752 ;; Check the backlog.
13753 ((and gnus-keep-backlog
13754 (gnus-backlog-request-article group article (current-buffer)))
13756 ;; Check the cache.
13757 ((and gnus-use-cache
13759 (gnus-cache-request-article article group))
13761 ;; Get the article and put into the article buffer.
13762 ((or (stringp article) (numberp article))
13763 (let ((gnus-override-method
13764 (and (stringp article) gnus-refer-article-method))
13765 (buffer-read-only nil))
13767 (gnus-kill-all-overlays)
13768 (if (gnus-request-article article group (current-buffer))
13770 (and gnus-keep-backlog
13772 (gnus-backlog-enter-article
13773 group article (current-buffer)))
13775 ;; It was a pseudo.
13778 ;; Take the article from the original article buffer
13779 ;; and place it in the buffer it's supposed to be in.
13780 (when (and (get-buffer gnus-article-buffer)
13781 ;;(numberp article)
13782 (equal (buffer-name (current-buffer))
13783 (buffer-name (get-buffer gnus-article-buffer))))
13785 (if (get-buffer gnus-original-article-buffer)
13786 (set-buffer (get-buffer gnus-original-article-buffer))
13787 (set-buffer (get-buffer-create gnus-original-article-buffer))
13788 (buffer-disable-undo (current-buffer))
13789 (setq major-mode 'gnus-original-article-mode)
13790 (setq buffer-read-only t)
13791 (gnus-add-current-to-buffer-list))
13792 (let (buffer-read-only)
13794 (insert-buffer-substring gnus-article-buffer))
13795 (setq gnus-original-article (cons group article))))
13797 ;; Update sparse articles.
13798 (when (and do-update-line
13799 (or (numberp article)
13800 (stringp article)))
13801 (let ((buf (current-buffer)))
13802 (set-buffer gnus-summary-buffer)
13803 (gnus-summary-update-article do-update-line)
13804 (gnus-summary-goto-subject do-update-line nil t)
13805 (set-window-point (get-buffer-window (current-buffer) t)
13807 (set-buffer buf))))))
13809 (defun gnus-read-header (id &optional header)
13810 "Read the headers of article ID and enter them into the Gnus system."
13811 (let ((group gnus-newsgroup-name)
13812 (gnus-override-method
13813 (and (gnus-news-group-p gnus-newsgroup-name)
13814 gnus-refer-article-method))
13816 ;; First we check to see whether the header in question is already
13819 ;; This is a Message-ID.
13820 (setq header (or header (gnus-id-to-header id)))
13821 ;; This is an article number.
13822 (setq header (or header (gnus-summary-article-header id))))
13824 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13825 ;; We have found the header.
13827 ;; We have to really fetch the header to this article.
13828 (when (setq where (gnus-request-head id group))
13830 (set-buffer nntp-server-buffer)
13831 (goto-char (point-max))
13833 (goto-char (point-min))
13837 ((cdr where) (cdr where))
13838 (header (mail-header-number header))
13839 (t gnus-reffed-article-number))
13841 (insert " Article retrieved.\n"))
13843 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13844 ; (setcar (gnus-id-to-thread id) nil))
13845 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13846 () ; Malformed head.
13847 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13848 (if (and (stringp id)
13849 (not (string= (gnus-group-real-name group)
13851 ;; If we fetched by Message-ID and the article came
13852 ;; from a different group, we fudge some bogus article
13853 ;; numbers for this article.
13854 (mail-header-set-number header gnus-reffed-article-number))
13855 (decf gnus-reffed-article-number)
13856 (gnus-remove-header (mail-header-number header))
13857 (push header gnus-newsgroup-headers)
13858 (setq gnus-current-headers header)
13859 (push (mail-header-number header) gnus-newsgroup-limit))
13862 (defun gnus-remove-header (number)
13863 "Remove header NUMBER from `gnus-newsgroup-headers'."
13864 (if (and gnus-newsgroup-headers
13865 (= number (mail-header-number (car gnus-newsgroup-headers))))
13866 (pop gnus-newsgroup-headers)
13867 (let ((headers gnus-newsgroup-headers))
13868 (while (and (cdr headers)
13869 (not (= number (mail-header-number (cadr headers)))))
13871 (when (cdr headers)
13872 (setcdr headers (cddr headers))))))
13874 (defun gnus-article-prepare (article &optional all-headers header)
13875 "Prepare ARTICLE in article mode buffer.
13876 ARTICLE should either be an article number or a Message-ID.
13877 If ARTICLE is an id, HEADER should be the article headers.
13878 If ALL-HEADERS is non-nil, no headers are hidden."
13880 ;; Make sure we start in a summary buffer.
13881 (unless (eq major-mode 'gnus-summary-mode)
13882 (set-buffer gnus-summary-buffer))
13883 (setq gnus-summary-buffer (current-buffer))
13884 ;; Make sure the connection to the server is alive.
13885 (unless (gnus-server-opened
13886 (gnus-find-method-for-group gnus-newsgroup-name))
13887 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13888 (gnus-request-group gnus-newsgroup-name t))
13889 (let* ((article (if header (mail-header-number header) article))
13890 (summary-buffer (current-buffer))
13891 (internal-hook gnus-article-internal-prepare-hook)
13892 (group gnus-newsgroup-name)
13895 (gnus-article-setup-buffer)
13896 (set-buffer gnus-article-buffer)
13897 ;; Deactivate active regions.
13898 (when (and (boundp 'transient-mark-mode)
13899 transient-mark-mode)
13900 (setq mark-active nil))
13901 (if (not (setq result (let ((buffer-read-only nil))
13902 (gnus-request-article-this-buffer
13904 ;; There is no such article.
13906 (when (and (numberp article)
13907 (not (memq article gnus-newsgroup-sparse)))
13908 (setq gnus-article-current
13909 (cons gnus-newsgroup-name article))
13910 (set-buffer gnus-summary-buffer)
13911 (setq gnus-current-article article)
13912 (gnus-summary-mark-article article gnus-canceled-mark))
13913 (unless (memq article gnus-newsgroup-sparse)
13915 1 "No such article (may have expired or been canceled)")))
13916 (if (or (eq result 'pseudo) (eq result 'nneething))
13919 (set-buffer summary-buffer)
13920 (setq gnus-last-article gnus-current-article
13921 gnus-newsgroup-history (cons gnus-current-article
13922 gnus-newsgroup-history)
13923 gnus-current-article 0
13924 gnus-current-headers nil
13925 gnus-article-current nil)
13926 (if (eq result 'nneething)
13927 (gnus-configure-windows 'summary)
13928 (gnus-configure-windows 'article))
13929 (gnus-set-global-variables))
13930 (gnus-set-mode-line 'article))
13931 ;; The result from the `request' was an actual article -
13932 ;; or at least some text that is now displayed in the
13934 (if (and (numberp article)
13935 (not (eq article gnus-current-article)))
13936 ;; Seems like a new article has been selected.
13937 ;; `gnus-current-article' must be an article number.
13939 (set-buffer summary-buffer)
13940 (setq gnus-last-article gnus-current-article
13941 gnus-newsgroup-history (cons gnus-current-article
13942 gnus-newsgroup-history)
13943 gnus-current-article article
13944 gnus-current-headers
13945 (gnus-summary-article-header gnus-current-article)
13946 gnus-article-current
13947 (cons gnus-newsgroup-name gnus-current-article))
13948 (unless (vectorp gnus-current-headers)
13949 (setq gnus-current-headers nil))
13950 (gnus-summary-show-thread)
13951 (run-hooks 'gnus-mark-article-hook)
13952 (gnus-set-mode-line 'summary)
13953 (and (gnus-visual-p 'article-highlight 'highlight)
13954 (run-hooks 'gnus-visual-mark-article-hook))
13955 ;; Set the global newsgroup variables here.
13956 ;; Suggested by Jim Sisolak
13957 ;; <sisolak@trans4.neep.wisc.edu>.
13958 (gnus-set-global-variables)
13959 (setq gnus-have-all-headers
13960 (or all-headers gnus-show-all-headers))
13961 (and gnus-use-cache
13962 (vectorp (gnus-summary-article-header article))
13963 (gnus-cache-possibly-enter-article
13965 (gnus-summary-article-header article)
13966 (memq article gnus-newsgroup-marked)
13967 (memq article gnus-newsgroup-dormant)
13968 (memq article gnus-newsgroup-unreads)))))
13969 (when (or (numberp article)
13971 ;; Hooks for getting information from the article.
13972 ;; This hook must be called before being narrowed.
13973 (let (buffer-read-only)
13974 (run-hooks 'internal-hook)
13975 (run-hooks 'gnus-article-prepare-hook)
13976 ;; Decode MIME message.
13978 (if (or (not gnus-strict-mime)
13979 (gnus-fetch-field "Mime-Version"))
13980 (funcall gnus-show-mime-method)
13981 (funcall gnus-decode-encoded-word-method)))
13982 ;; Perform the article display hooks.
13983 (run-hooks 'gnus-article-display-hook))
13985 (goto-char (point-min))
13986 (and gnus-break-pages (gnus-narrow-to-page)))
13987 (gnus-set-mode-line 'article)
13988 (gnus-configure-windows 'article)
13989 (goto-char (point-min))
13992 (defun gnus-article-show-all-headers ()
13993 "Show all article headers in article mode buffer."
13995 (gnus-article-setup-buffer)
13996 (set-buffer gnus-article-buffer)
13997 (let ((buffer-read-only nil))
13998 (gnus-unhide-text (point-min) (point-max)))))
14000 (defun gnus-article-hide-headers-if-wanted ()
14001 "Hide unwanted headers if `gnus-have-all-headers' is nil.
14002 Provided for backwards compatibility."
14003 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
14004 gnus-inhibit-hiding
14005 (gnus-article-hide-headers)))
14007 (defsubst gnus-article-header-rank ()
14008 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
14009 (let ((list gnus-sorted-header-list)
14012 (when (looking-at (car list))
14014 (setq list (cdr list))
14018 (defun gnus-article-hide-headers (&optional arg delete)
14019 "Toggle whether to hide unwanted headers and possibly sort them as well.
14020 If given a negative prefix, always show; if given a positive prefix,
14022 (interactive (gnus-hidden-arg))
14023 (if (gnus-article-check-hidden-text 'headers arg)
14024 ;; Show boring headers as well.
14025 (gnus-article-show-hidden-text 'boring-headers)
14026 ;; This function might be inhibited.
14027 (unless gnus-inhibit-hiding
14029 (set-buffer gnus-article-buffer)
14031 (let ((buffer-read-only nil)
14032 (props (nconc (list 'gnus-type 'headers)
14033 gnus-hidden-properties))
14034 (max (1+ (length gnus-sorted-header-list)))
14035 (ignored (when (not (stringp gnus-visible-headers))
14036 (cond ((stringp gnus-ignored-headers)
14037 gnus-ignored-headers)
14038 ((listp gnus-ignored-headers)
14039 (mapconcat 'identity gnus-ignored-headers
14042 (cond ((stringp gnus-visible-headers)
14043 gnus-visible-headers)
14044 ((and gnus-visible-headers
14045 (listp gnus-visible-headers))
14046 (mapconcat 'identity gnus-visible-headers "\\|"))))
14047 (inhibit-point-motion-hooks t)
14049 ;; First we narrow to just the headers.
14051 (goto-char (point-min))
14052 ;; Hide any "From " lines at the beginning of (mail) articles.
14053 (while (looking-at "From ")
14057 (delete-region (point-min) (point))
14058 (gnus-hide-text (point-min) (point) props)))
14059 ;; Then treat the rest of the header lines.
14062 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
14063 ;; Then we use the two regular expressions
14064 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
14065 ;; select which header lines is to remain visible in the
14067 (goto-char (point-min))
14068 (while (re-search-forward "^[^ \t]*:" nil t)
14069 (beginning-of-line)
14070 ;; We add the headers we want to keep to a list and delete
14071 ;; them from the buffer.
14072 (gnus-put-text-property
14073 (point) (1+ (point)) 'message-rank
14074 (if (or (and visible (looking-at visible))
14076 (not (looking-at ignored))))
14077 (gnus-article-header-rank)
14080 (message-sort-headers-1)
14081 (when (setq beg (text-property-any
14082 (point-min) (point-max) 'message-rank (+ 2 max)))
14083 ;; We make the unwanted headers invisible.
14085 (delete-region beg (point-max))
14086 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
14087 (gnus-hide-text-type beg (point-max) 'headers))
14088 ;; Work around XEmacs lossage.
14089 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
14091 (defun gnus-article-hide-boring-headers (&optional arg)
14092 "Toggle hiding of headers that aren't very interesting.
14093 If given a negative prefix, always show; if given a positive prefix,
14095 (interactive (gnus-hidden-arg))
14096 (unless (gnus-article-check-hidden-text 'boring-headers arg)
14098 (set-buffer gnus-article-buffer)
14100 (let ((buffer-read-only nil)
14101 (list gnus-boring-article-headers)
14102 (inhibit-point-motion-hooks t)
14104 (nnheader-narrow-to-headers)
14106 (setq elem (pop list))
14107 (goto-char (point-min))
14109 ;; Hide empty headers.
14111 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14113 (gnus-hide-text-type
14114 (progn (beginning-of-line) (point))
14117 (if (re-search-forward "^[^ \t]" nil t)
14118 (match-beginning 0)
14121 ;; Hide boring Newsgroups header.
14122 ((eq elem 'newsgroups)
14123 (when (equal (message-fetch-field "newsgroups")
14124 (gnus-group-real-name gnus-newsgroup-name))
14125 (gnus-article-hide-header "newsgroups")))
14126 ((eq elem 'followup-to)
14127 (when (equal (message-fetch-field "followup-to")
14128 (message-fetch-field "newsgroups"))
14129 (gnus-article-hide-header "followup-to")))
14130 ((eq elem 'reply-to)
14131 (let ((from (message-fetch-field "from"))
14132 (reply-to (message-fetch-field "reply-to")))
14136 (nth 1 (funcall gnus-extract-address-components from))
14137 (nth 1 (funcall gnus-extract-address-components
14139 (gnus-article-hide-header "reply-to"))))
14141 (let ((date (message-fetch-field "date")))
14143 (< (gnus-days-between date (current-time-string))
14145 (gnus-article-hide-header "date")))))))))))
14147 (defun gnus-article-hide-header (header)
14149 (goto-char (point-min))
14150 (when (re-search-forward (concat "^" header ":") nil t)
14151 (gnus-hide-text-type
14152 (progn (beginning-of-line) (point))
14155 (if (re-search-forward "^[^ \t]" nil t)
14156 (match-beginning 0)
14158 'boring-headers))))
14160 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14161 (defun gnus-article-treat-overstrike ()
14162 "Translate overstrikes into bold text."
14165 (set-buffer gnus-article-buffer)
14166 (let ((buffer-read-only nil))
14167 (while (search-forward "\b" nil t)
14168 (let ((next (following-char))
14169 (previous (char-after (- (point) 2))))
14171 ((eq next previous)
14172 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14173 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14175 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14176 (gnus-put-text-property
14177 (- (point) 2) (1- (point)) 'face 'underline))
14179 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14180 (gnus-put-text-property
14181 (point) (1+ (point)) 'face 'underline))))))))
14183 (defun gnus-article-word-wrap ()
14184 "Format too long lines."
14187 (set-buffer gnus-article-buffer)
14188 (let ((buffer-read-only nil))
14190 (goto-char (point-min))
14191 (search-forward "\n\n" nil t)
14193 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14194 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14195 (adaptive-fill-mode t))
14196 (while (not (eobp))
14197 (and (>= (current-column) (min fill-column (window-width)))
14198 (/= (preceding-char) ?:)
14199 (fill-paragraph nil))
14200 (end-of-line 2))))))
14202 (defun gnus-article-remove-cr ()
14203 "Remove carriage returns from an article."
14206 (set-buffer gnus-article-buffer)
14207 (let ((buffer-read-only nil))
14208 (goto-char (point-min))
14209 (while (search-forward "\r" nil t)
14210 (replace-match "" t t)))))
14212 (defun gnus-article-remove-trailing-blank-lines ()
14213 "Remove all trailing blank lines from the article."
14216 (set-buffer gnus-article-buffer)
14217 (let ((buffer-read-only nil))
14218 (goto-char (point-max))
14222 (while (looking-at "^[ \t]*$")
14227 (defun gnus-article-display-x-face (&optional force)
14228 "Look for an X-Face header and display it if present."
14229 (interactive (list 'force))
14231 (set-buffer gnus-article-buffer)
14232 ;; Delete the old process, if any.
14233 (when (process-status "gnus-x-face")
14234 (delete-process "gnus-x-face"))
14235 (let ((inhibit-point-motion-hooks t)
14236 (case-fold-search nil)
14239 (nnheader-narrow-to-headers)
14240 (setq from (message-fetch-field "from"))
14241 (goto-char (point-min))
14242 (when (and gnus-article-x-face-command
14244 ;; Check whether this face is censored.
14245 (not gnus-article-x-face-too-ugly)
14246 (and gnus-article-x-face-too-ugly from
14247 (not (string-match gnus-article-x-face-too-ugly
14249 ;; Has to be present.
14250 (re-search-forward "^X-Face: " nil t))
14251 ;; We now have the area of the buffer where the X-Face is stored.
14252 (let ((beg (point))
14253 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14254 ;; We display the face.
14255 (if (symbolp gnus-article-x-face-command)
14256 ;; The command is a lisp function, so we call it.
14257 (if (gnus-functionp gnus-article-x-face-command)
14258 (funcall gnus-article-x-face-command beg end)
14259 (error "%s is not a function" gnus-article-x-face-command))
14260 ;; The command is a string, so we interpret the command
14261 ;; as a, well, command, and fork it off.
14262 (let ((process-connection-type nil))
14263 (process-kill-without-query
14265 "gnus-x-face" nil shell-file-name shell-command-switch
14266 gnus-article-x-face-command))
14267 (process-send-region "gnus-x-face" beg end)
14268 (process-send-eof "gnus-x-face")))))))))
14270 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14271 (defun gnus-decode-rfc1522 ()
14272 "Hack to remove QP encoding from headers."
14273 (let ((case-fold-search t)
14274 (inhibit-point-motion-hooks t)
14275 (buffer-read-only nil)
14279 (goto-char (point-min))
14280 (or (search-forward "\n\n" nil t) (point-max)))
14282 (while (re-search-forward
14283 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14284 (setq string (match-string 1))
14285 (narrow-to-region (match-beginning 0) (match-end 0))
14286 (delete-region (point-min) (point-max))
14288 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14289 (subst-char-in-region (point-min) (point-max) ?_ ? )
14291 (goto-char (point-min))))))
14293 (defun gnus-article-de-quoted-unreadable (&optional force)
14294 "Do a naive translation of a quoted-printable-encoded article.
14295 This is in no way, shape or form meant as a replacement for real MIME
14296 processing, but is simply a stop-gap measure until MIME support is
14298 If FORCE, decode the article whether it is marked as quoted-printable
14300 (interactive (list 'force))
14302 (set-buffer gnus-article-buffer)
14303 (let ((case-fold-search t)
14304 (buffer-read-only nil)
14305 (type (gnus-fetch-field "content-transfer-encoding")))
14306 (gnus-decode-rfc1522)
14308 (and type (string-match "quoted-printable" (downcase type))))
14309 (goto-char (point-min))
14310 (search-forward "\n\n" nil 'move)
14311 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14313 (defun gnus-mime-decode-quoted-printable (from to)
14314 "Decode Quoted-Printable in the region between FROM and TO."
14317 (while (search-forward "=" to t)
14318 (cond ((eq (following-char) ?\n)
14321 ((looking-at "[0-9A-F][0-9A-F]")
14322 (subst-char-in-region
14323 (1- (point)) (point) ?=
14324 (hexl-hex-string-to-integer
14325 (buffer-substring (point) (+ 2 (point)))))
14329 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14331 (defun gnus-article-hide-pgp (&optional arg)
14332 "Toggle hiding of any PGP headers and signatures in the current article.
14333 If given a negative prefix, always show; if given a positive prefix,
14335 (interactive (gnus-hidden-arg))
14336 (unless (gnus-article-check-hidden-text 'pgp arg)
14338 (set-buffer gnus-article-buffer)
14339 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14340 buffer-read-only beg end)
14342 (goto-char (point-min))
14343 ;; Hide the "header".
14344 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14345 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14347 ;; Hide the actual signature.
14348 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14349 (setq end (1+ (match-beginning 0)))
14352 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14354 ;; Perhaps we shouldn't hide to the end of the buffer
14355 ;; if there is no end to the signature?
14358 ;; Hide "- " PGP quotation markers.
14359 (when (and beg end)
14360 (narrow-to-region beg end)
14361 (goto-char (point-min))
14362 (while (re-search-forward "^- " nil t)
14363 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14366 (defun gnus-article-hide-pem (&optional arg)
14367 "Toggle hiding of any PEM headers and signatures in the current article.
14368 If given a negative prefix, always show; if given a positive prefix,
14370 (interactive (gnus-hidden-arg))
14371 (unless (gnus-article-check-hidden-text 'pem arg)
14373 (set-buffer gnus-article-buffer)
14374 (let ((props (nconc (list 'gnus-type 'pem) gnus-hidden-properties))
14375 buffer-read-only end)
14377 (goto-char (point-min))
14378 ;; hide the horrendously ugly "header".
14379 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
14382 (setq end (1+ (match-beginning 0)))
14385 (if (search-forward "\n\n" nil t)
14389 ;; hide the trailer as well
14390 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
14393 (gnus-hide-text (match-beginning 0) (match-end 0) props))))))
14395 (defun gnus-article-hide-signature (&optional arg)
14396 "Hide the signature in the current article.
14397 If given a negative prefix, always show; if given a positive prefix,
14399 (interactive (gnus-hidden-arg))
14400 (unless (gnus-article-check-hidden-text 'signature arg)
14402 (set-buffer gnus-article-buffer)
14404 (let ((buffer-read-only nil))
14405 (when (gnus-narrow-to-signature)
14406 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14408 (defun gnus-article-strip-leading-blank-lines ()
14409 "Remove all blank lines from the beginning of the article."
14412 (set-buffer gnus-article-buffer)
14413 (let (buffer-read-only)
14414 (goto-char (point-min))
14415 (when (search-forward "\n\n" nil t)
14416 (while (looking-at "[ \t]$")
14417 (gnus-delete-line))))))
14419 (defvar mime::preview/content-list)
14420 (defvar mime::preview-content-info/point-min)
14421 (defun gnus-narrow-to-signature ()
14422 "Narrow to the signature."
14424 (if (and (boundp 'mime::preview/content-list)
14425 mime::preview/content-list)
14426 (let ((pcinfo (car (last mime::preview/content-list))))
14429 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14432 (goto-char (point-max))
14433 (when (re-search-backward gnus-signature-separator nil t)
14435 (when (or (null gnus-signature-limit)
14436 (and (numberp gnus-signature-limit)
14437 (< (- (point-max) (point)) gnus-signature-limit))
14438 (and (gnus-functionp gnus-signature-limit)
14439 (funcall gnus-signature-limit))
14440 (and (stringp gnus-signature-limit)
14441 (not (re-search-forward gnus-signature-limit nil t))))
14442 (narrow-to-region (point) (point-max))
14445 (defun gnus-hidden-arg ()
14446 "Return the current prefix arg as a number, or 0 if no prefix."
14447 (list (if current-prefix-arg
14448 (prefix-numeric-value current-prefix-arg)
14451 (defun gnus-article-check-hidden-text (type arg)
14452 "Return nil if hiding is necessary.
14453 Arg can be nil or a number. Nil and positive means hide, negative
14454 means show, 0 means toggle."
14456 (set-buffer gnus-article-buffer)
14457 (let ((hide (gnus-article-hidden-text-p type)))
14463 (gnus-article-show-hidden-text type))
14465 (if (eq hide 'hidden)
14466 (gnus-article-show-hidden-text type)
14469 (defun gnus-article-hidden-text-p (type)
14470 "Say whether the current buffer contains hidden text of type TYPE."
14471 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14473 (if (get-text-property pos 'invisible)
14477 (defun gnus-article-hide (&optional arg force)
14478 "Hide all the gruft in the current article.
14479 This means that PGP stuff, signatures, cited text and (some)
14480 headers will be hidden.
14481 If given a prefix, show the hidden text instead."
14482 (interactive (list current-prefix-arg 'force))
14483 (gnus-article-hide-headers arg)
14484 (gnus-article-hide-pgp arg)
14485 (gnus-article-hide-citation-maybe arg force)
14486 (gnus-article-hide-signature arg))
14488 (defun gnus-article-show-hidden-text (type &optional hide)
14489 "Show all hidden text of type TYPE.
14490 If HIDE, hide the text instead."
14492 (set-buffer gnus-article-buffer)
14493 (let ((buffer-read-only nil)
14494 (inhibit-point-motion-hooks t)
14496 (while (gnus-goto-char (text-property-any
14497 beg (point-max) 'gnus-type type))
14501 (gnus-hide-text beg (point) gnus-hidden-properties)
14502 (gnus-unhide-text beg (point)))
14503 (setq beg (point)))
14506 (defvar gnus-article-time-units
14507 `((year . ,(* 365.25 24 60 60))
14508 (week . ,(* 7 24 60 60))
14509 (day . ,(* 24 60 60))
14510 (hour . ,(* 60 60))
14513 "Mapping from time units to seconds.")
14515 (defun gnus-article-date-ut (&optional type highlight)
14516 "Convert DATE date to universal time in the current article.
14517 If TYPE is `local', convert to local time; if it is `lapsed', output
14518 how much time has lapsed since DATE."
14519 (interactive (list 'ut t))
14520 (let* ((header (or gnus-current-headers
14521 (gnus-summary-article-header) ""))
14522 (date (and (vectorp header) (mail-header-date header)))
14523 (date-regexp "^Date: \\|^X-Sent: ")
14524 (now (current-time))
14525 (inhibit-point-motion-hooks t)
14527 (when (and date (not (string= date "")))
14529 (set-buffer gnus-article-buffer)
14531 (nnheader-narrow-to-headers)
14532 (let ((buffer-read-only nil))
14533 ;; Delete any old Date headers.
14534 (if (re-search-forward date-regexp nil t)
14536 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14537 eface (get-text-property (1- (gnus-point-at-eol))
14539 (message-remove-header date-regexp t)
14540 (beginning-of-line))
14541 (goto-char (point-max)))
14542 (insert (gnus-make-date-line date type))
14543 ;; Do highlighting.
14545 (when (and (gnus-visual-p 'article-highlight 'highlight)
14546 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14547 (gnus-put-text-property (match-beginning 1) (match-end 1)
14549 (gnus-put-text-property (match-beginning 2) (match-end 2)
14550 'face eface))))))))
14552 (defun gnus-make-date-line (date type)
14553 "Return a DATE line of TYPE."
14555 ;; Convert to the local timezone. We have to slap a
14556 ;; `condition-case' round the calls to the timezone
14557 ;; functions since they aren't particularly resistant to
14560 (concat "Date: " (condition-case ()
14561 (timezone-make-date-arpa-standard date)
14564 ;; Convert to Universal Time.
14568 (timezone-make-date-arpa-standard date nil "UT")
14571 ;; Get the original date from the article.
14572 ((eq type 'original)
14573 (concat "Date: " date "\n"))
14574 ;; Do an X-Sent lapsed format.
14576 ;; If the date is seriously mangled, the timezone
14577 ;; functions are liable to bug out, so we condition-case
14578 ;; the entire thing.
14579 (let* ((now (current-time))
14584 (timezone-make-date-arpa-standard
14585 (current-time-string now)
14586 (current-time-zone now) "UT"))
14588 (timezone-make-date-arpa-standard
14591 (real-sec (+ (* (float (car real-time)) 65536)
14593 (sec (abs real-sec))
14596 ((equal real-time '(0 0))
14597 "X-Sent: Unknown\n")
14603 ;; This is a bit convoluted, but basically we go
14604 ;; through the time units for years, weeks, etc,
14605 ;; and divide things to see whether that results
14606 ;; in positive answers.
14609 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14610 ;; The (remaining) seconds are too few to
14611 ;; be divided into this time unit.
14613 ;; It's big enough, so we output it.
14614 (setq sec (- sec (* num (cdr unit))))
14616 (concat (if prev ", " "") (int-to-string
14618 " " (symbol-name (car unit))
14619 (if (> num 1) "s" ""))
14621 gnus-article-time-units "")
14622 ;; If dates are odd, then it might appear like the
14623 ;; article was sent in the future.
14626 " in the future\n"))))))
14628 (error "Unknown conversion type: %s" type))))
14630 (defun gnus-article-date-local (&optional highlight)
14631 "Convert the current article date to the local timezone."
14632 (interactive (list t))
14633 (gnus-article-date-ut 'local highlight))
14635 (defun gnus-article-date-original (&optional highlight)
14636 "Convert the current article date to what it was originally.
14637 This is only useful if you have used some other date conversion
14638 function and want to see what the date was before converting."
14639 (interactive (list t))
14640 (gnus-article-date-ut 'original highlight))
14642 (defun gnus-article-date-lapsed (&optional highlight)
14643 "Convert the current article date to time lapsed since it was sent."
14644 (interactive (list t))
14645 (gnus-article-date-ut 'lapsed highlight))
14647 (defun gnus-article-maybe-highlight ()
14648 "Do some article highlighting if `gnus-visual' is non-nil."
14649 (if (gnus-visual-p 'article-highlight 'highlight)
14650 (gnus-article-highlight-some)))
14652 ;;; Article savers.
14654 (defun gnus-output-to-rmail (file-name)
14655 "Append the current article to an Rmail file named FILE-NAME."
14657 ;; Most of these codes are borrowed from rmailout.el.
14658 (setq file-name (expand-file-name file-name))
14659 (setq rmail-default-rmail-file file-name)
14660 (let ((artbuf (current-buffer))
14661 (tmpbuf (get-buffer-create " *Gnus-output*")))
14663 (or (get-file-buffer file-name)
14664 (file-exists-p file-name)
14665 (if (gnus-yes-or-no-p
14666 (concat "\"" file-name "\" does not exist, create it? "))
14667 (let ((file-buffer (create-file-buffer file-name)))
14669 (set-buffer file-buffer)
14670 (rmail-insert-rmail-file-header)
14671 (let ((require-final-newline nil))
14672 (write-region (point-min) (point-max) file-name t 1)))
14673 (kill-buffer file-buffer))
14674 (error "Output file does not exist")))
14675 (set-buffer tmpbuf)
14676 (buffer-disable-undo (current-buffer))
14678 (insert-buffer-substring artbuf)
14679 (gnus-convert-article-to-rmail)
14680 ;; Decide whether to append to a file or to an Emacs buffer.
14681 (let ((outbuf (get-file-buffer file-name)))
14683 (append-to-file (point-min) (point-max) file-name)
14684 ;; File has been visited, in buffer OUTBUF.
14685 (set-buffer outbuf)
14686 (let ((buffer-read-only nil)
14687 (msg (and (boundp 'rmail-current-message)
14688 (symbol-value 'rmail-current-message))))
14689 ;; If MSG is non-nil, buffer is in RMAIL mode.
14692 (narrow-to-region (point-max) (point-max))))
14693 (insert-buffer-substring tmpbuf)
14696 (goto-char (point-min))
14698 (search-backward "\^_")
14699 (narrow-to-region (point) (point-max))
14700 (goto-char (1+ (point-min)))
14701 (rmail-count-new-messages t)
14702 (rmail-show-message msg)))))))
14703 (kill-buffer tmpbuf)))
14705 (defun gnus-output-to-file (file-name)
14706 "Append the current article to a file named FILE-NAME."
14707 (let ((artbuf (current-buffer)))
14708 (nnheader-temp-write nil
14709 (insert-buffer-substring artbuf)
14710 ;; Append newline at end of the buffer as separator, and then
14711 ;; save it to file.
14712 (goto-char (point-max))
14714 (append-to-file (point-min) (point-max) file-name))))
14716 (defun gnus-convert-article-to-rmail ()
14717 "Convert article in current buffer to Rmail message format."
14718 (let ((buffer-read-only nil))
14719 ;; Convert article directly into Babyl format.
14720 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14721 (goto-char (point-min))
14722 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14723 (while (search-forward "\n\^_" nil t) ;single char
14724 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14725 (goto-char (point-max))
14728 (defun gnus-narrow-to-page (&optional arg)
14729 "Narrow the article buffer to a page.
14730 If given a numerical ARG, move forward ARG pages."
14732 (setq arg (if arg (prefix-numeric-value arg) 0))
14734 (set-buffer gnus-article-buffer)
14735 (goto-char (point-min))
14737 (when (gnus-visual-p 'page-marker)
14738 (let ((buffer-read-only nil))
14739 (gnus-remove-text-with-property 'gnus-prev)
14740 (gnus-remove-text-with-property 'gnus-next)))
14743 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14745 (re-search-forward page-delimiter nil 'move arg)))
14746 (goto-char (match-end 0)))
14749 (if (re-search-forward page-delimiter nil 'move)
14750 (match-beginning 0)
14752 (when (and (gnus-visual-p 'page-marker)
14753 (not (= (point-min) 1)))
14755 (goto-char (point-min))
14756 (gnus-insert-prev-page-button)))
14757 (when (and (gnus-visual-p 'page-marker)
14758 (not (= (1- (point-max)) (buffer-size))))
14760 (goto-char (point-max))
14761 (gnus-insert-next-page-button)))))
14763 ;; Article mode commands
14765 (defun gnus-article-goto-next-page ()
14766 "Show the next page of the article."
14768 (when (gnus-article-next-page)
14769 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14771 (defun gnus-article-goto-prev-page ()
14772 "Show the next page of the article."
14774 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14775 (gnus-article-prev-page nil)))
14777 (defun gnus-article-next-page (&optional lines)
14778 "Show the next page of the current article.
14779 If end of article, return non-nil. Otherwise return nil.
14780 Argument LINES specifies lines to be scrolled up."
14782 (move-to-window-line -1)
14783 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14784 (if (save-excursion
14786 (and (pos-visible-in-window-p) ;Not continuation line.
14788 ;; Nothing in this page.
14789 (if (or (not gnus-break-pages)
14792 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14794 (gnus-narrow-to-page 1) ;Go to next page.
14796 ;; More in this page.
14800 ;; Long lines may cause an end-of-buffer error.
14801 (goto-char (point-max))))
14802 (move-to-window-line 0)
14805 (defun gnus-article-prev-page (&optional lines)
14806 "Show previous page of current article.
14807 Argument LINES specifies lines to be scrolled down."
14809 (move-to-window-line 0)
14810 (if (and gnus-break-pages
14812 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14814 (gnus-narrow-to-page -1) ;Go to previous page.
14815 (goto-char (point-max))
14819 (scroll-down lines)
14821 (move-to-window-line 0))))
14823 (defun gnus-article-refer-article ()
14824 "Read article specified by message-id around point."
14826 (let ((point (point)))
14827 (search-forward ">" nil t) ;Move point to end of "<....>".
14828 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14829 (let ((message-id (match-string 1)))
14831 (set-buffer gnus-summary-buffer)
14832 (gnus-summary-refer-article message-id))
14833 (goto-char (point))
14834 (error "No references around point"))))
14836 (defun gnus-article-show-summary ()
14837 "Reconfigure windows to show summary buffer."
14839 (gnus-configure-windows 'article)
14840 (gnus-summary-goto-subject gnus-current-article))
14842 (defun gnus-article-describe-briefly ()
14843 "Describe article mode commands briefly."
14846 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14848 (defun gnus-article-summary-command ()
14849 "Execute the last keystroke in the summary buffer."
14851 (let ((obuf (current-buffer))
14852 (owin (current-window-configuration))
14854 (switch-to-buffer gnus-summary-buffer 'norecord)
14855 (setq func (lookup-key (current-local-map) (this-command-keys)))
14856 (call-interactively func)
14858 (set-window-configuration owin)
14859 (set-window-point (get-buffer-window (current-buffer)) (point))))
14861 (defun gnus-article-summary-command-nosave ()
14862 "Execute the last keystroke in the summary buffer."
14865 (pop-to-buffer gnus-summary-buffer 'norecord)
14866 (setq func (lookup-key (current-local-map) (this-command-keys)))
14867 (call-interactively func)))
14869 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14870 "Read a summary buffer key sequence and execute it from the article buffer."
14873 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14874 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14875 "=" "^" "\M-^" "|"))
14876 (nosave-but-article
14880 (set-buffer gnus-summary-buffer)
14881 (push (or key last-command-event) unread-command-events)
14882 (setq keys (read-key-sequence nil)))
14885 (if (or (member keys nosaves)
14886 (member keys nosave-but-article))
14888 (save-window-excursion
14889 (pop-to-buffer gnus-summary-buffer 'norecord)
14890 (setq func (lookup-key (current-local-map) keys)))
14893 (set-buffer gnus-summary-buffer)
14894 (call-interactively func))
14895 (when (member keys nosave-but-article)
14896 (pop-to-buffer gnus-article-buffer 'norecord)))
14897 (let ((obuf (current-buffer))
14898 (owin (current-window-configuration))
14901 (if not-restore-window
14902 (pop-to-buffer gnus-summary-buffer 'norecord)
14903 (switch-to-buffer gnus-summary-buffer 'norecord))
14904 (setq in-buffer (current-buffer))
14905 (if (setq func (lookup-key (current-local-map) keys))
14906 (call-interactively func)
14908 (when (eq in-buffer (current-buffer))
14910 (unless not-restore-window
14911 (set-window-configuration owin))
14912 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14916 ;;; Kill file handling.
14920 (defalias 'gnus-batch-kill 'gnus-batch-score)
14922 (defun gnus-batch-score ()
14923 "Run batched scoring.
14924 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14925 Newsgroups is a list of strings in Bnews format. If you want to score
14926 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14927 score the alt hierarchy, you'd say \"!alt.all\"."
14930 (gnus-newsrc-parse-options
14931 (apply (function concat)
14932 (mapcar (lambda (g) (concat g " "))
14933 command-line-args-left))))
14934 (gnus-expert-user t)
14935 (nnmail-spool-file nil)
14936 (gnus-use-dribble-file nil)
14937 (yes (car yes-and-no))
14938 (no (cdr yes-and-no))
14940 ;; Disable verbose message.
14941 gnus-novice-user gnus-large-newsgroup)
14942 ;; Eat all arguments.
14943 (setq command-line-args-left nil)
14946 ;; Apply kills to specified newsgroups in command line arguments.
14947 (setq newsrc (cdr gnus-newsrc-alist))
14949 (setq group (caar newsrc))
14950 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14951 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14953 (or (eq (car entry) t)
14954 (not (zerop (car entry)))))
14955 (if yes (string-match yes group) t)
14956 (or (null no) (not (string-match no group))))
14958 (gnus-summary-read-group group nil t nil t)
14959 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14960 (gnus-summary-exit))))
14961 (setq newsrc (cdr newsrc)))
14963 (switch-to-buffer gnus-group-buffer)
14964 (gnus-group-save-newsrc)))
14966 (defun gnus-apply-kill-file ()
14967 "Apply a kill file to the current newsgroup.
14968 Returns the number of articles marked as read."
14969 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14970 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14971 (gnus-apply-kill-file-internal)
14974 (defun gnus-kill-save-kill-buffer ()
14975 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14976 (when (get-file-buffer file)
14978 (set-buffer (get-file-buffer file))
14979 (and (buffer-modified-p) (save-buffer))
14980 (kill-buffer (current-buffer))))))
14982 (defvar gnus-kill-file-name "KILL"
14983 "Suffix of the kill files.")
14985 (defun gnus-newsgroup-kill-file (newsgroup)
14986 "Return the name of a kill file name for NEWSGROUP.
14987 If NEWSGROUP is nil, return the global kill file name instead."
14989 ;; The global KILL file is placed at top of the directory.
14990 ((or (null newsgroup)
14991 (string-equal newsgroup ""))
14992 (expand-file-name gnus-kill-file-name
14993 gnus-kill-files-directory))
14994 ;; Append ".KILL" to newsgroup name.
14995 ((gnus-use-long-file-name 'not-kill)
14996 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14997 "." gnus-kill-file-name)
14998 gnus-kill-files-directory))
14999 ;; Place "KILL" under the hierarchical directory.
15001 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
15002 "/" gnus-kill-file-name)
15003 gnus-kill-files-directory))))
15010 (defvar gnus-dribble-ignore nil)
15011 (defvar gnus-dribble-eval-file nil)
15013 (defun gnus-dribble-file-name ()
15014 "Return the dribble file for the current .newsrc."
15016 (if gnus-dribble-directory
15017 (concat (file-name-as-directory gnus-dribble-directory)
15018 (file-name-nondirectory gnus-current-startup-file))
15019 gnus-current-startup-file)
15022 (defun gnus-dribble-enter (string)
15023 "Enter STRING into the dribble buffer."
15024 (if (and (not gnus-dribble-ignore)
15025 gnus-dribble-buffer
15026 (buffer-name gnus-dribble-buffer))
15027 (let ((obuf (current-buffer)))
15028 (set-buffer gnus-dribble-buffer)
15029 (insert string "\n")
15030 (set-window-point (get-buffer-window (current-buffer)) (point-max))
15031 (bury-buffer gnus-dribble-buffer)
15032 (set-buffer obuf))))
15034 (defun gnus-dribble-read-file ()
15035 "Read the dribble file from disk."
15036 (let ((dribble-file (gnus-dribble-file-name)))
15038 (set-buffer (setq gnus-dribble-buffer
15040 (file-name-nondirectory dribble-file))))
15041 (gnus-add-current-to-buffer-list)
15043 (setq buffer-file-name dribble-file)
15045 (buffer-disable-undo (current-buffer))
15046 (bury-buffer (current-buffer))
15047 (set-buffer-modified-p nil)
15048 (let ((auto (make-auto-save-file-name))
15049 (gnus-dribble-ignore t)
15051 (when (or (file-exists-p auto) (file-exists-p dribble-file))
15052 ;; Load whichever file is newest -- the auto save file
15053 ;; or the "real" file.
15054 (if (file-newer-than-file-p auto dribble-file)
15055 (insert-file-contents auto)
15056 (insert-file-contents dribble-file))
15057 (unless (zerop (buffer-size))
15058 (set-buffer-modified-p t))
15059 ;; Set the file modes to reflect the .newsrc file modes.
15061 (when (and (file-exists-p gnus-current-startup-file)
15062 (setq modes (file-modes gnus-current-startup-file)))
15063 (set-file-modes dribble-file modes))
15064 ;; Possibly eval the file later.
15065 (when (gnus-y-or-n-p
15066 "Auto-save file exists. Do you want to read it? ")
15067 (setq gnus-dribble-eval-file t)))))))
15069 (defun gnus-dribble-eval-file ()
15070 (when gnus-dribble-eval-file
15071 (setq gnus-dribble-eval-file nil)
15073 (let ((gnus-dribble-ignore t))
15074 (set-buffer gnus-dribble-buffer)
15075 (eval-buffer (current-buffer))))))
15077 (defun gnus-dribble-delete-file ()
15078 (when (file-exists-p (gnus-dribble-file-name))
15079 (delete-file (gnus-dribble-file-name)))
15080 (when gnus-dribble-buffer
15082 (set-buffer gnus-dribble-buffer)
15083 (let ((auto (make-auto-save-file-name)))
15084 (if (file-exists-p auto)
15085 (delete-file auto))
15087 (set-buffer-modified-p nil)))))
15089 (defun gnus-dribble-save ()
15090 (when (and gnus-dribble-buffer
15091 (buffer-name gnus-dribble-buffer))
15093 (set-buffer gnus-dribble-buffer)
15096 (defun gnus-dribble-clear ()
15097 (when (gnus-buffer-exists-p gnus-dribble-buffer)
15099 (set-buffer gnus-dribble-buffer)
15101 (set-buffer-modified-p nil)
15102 (setq buffer-saved-size (buffer-size)))))
15106 ;;; Server Communication
15109 (defun gnus-start-news-server (&optional confirm)
15110 "Open a method for getting news.
15111 If CONFIRM is non-nil, the user will be asked for an NNTP server."
15113 (if gnus-current-select-method
15114 ;; Stream is already opened.
15116 ;; Open NNTP server.
15117 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
15120 ;; Read server name with completion.
15121 (setq gnus-nntp-server
15122 (completing-read "NNTP server: "
15123 (mapcar (lambda (server) (list server))
15124 (cons (list gnus-nntp-server)
15125 gnus-secondary-servers))
15126 nil nil gnus-nntp-server))))
15128 (if (and gnus-nntp-server
15129 (stringp gnus-nntp-server)
15130 (not (string= gnus-nntp-server "")))
15131 (setq gnus-select-method
15132 (cond ((or (string= gnus-nntp-server "")
15133 (string= gnus-nntp-server "::"))
15134 (list 'nnspool (system-name)))
15135 ((string-match "^:" gnus-nntp-server)
15136 (list 'nnmh gnus-nntp-server
15137 (list 'nnmh-directory
15138 (file-name-as-directory
15140 (concat "~/" (substring
15141 gnus-nntp-server 1)))))
15142 (list 'nnmh-get-new-mail nil)))
15144 (list 'nntp gnus-nntp-server)))))
15146 (setq how (car gnus-select-method))
15147 (cond ((eq how 'nnspool)
15149 (gnus-message 5 "Looking up local news spool..."))
15152 (gnus-message 5 "Looking up mh spool..."))
15155 (setq gnus-current-select-method gnus-select-method)
15156 (run-hooks 'gnus-open-server-hook)
15158 ;; gnus-open-server-hook might have opened it
15159 (gnus-server-opened gnus-select-method)
15160 (gnus-open-server gnus-select-method)
15163 "%s (%s) open error: '%s'. Continue? "
15164 (car gnus-select-method) (cadr gnus-select-method)
15165 (gnus-status-message gnus-select-method)))
15166 (gnus-error 1 "Couldn't open server on %s"
15167 (nth 1 gnus-select-method))))))
15169 (defun gnus-check-group (group)
15170 "Try to make sure that the server where GROUP exists is alive."
15171 (let ((method (gnus-find-method-for-group group)))
15172 (or (gnus-server-opened method)
15173 (gnus-open-server method))))
15175 (defun gnus-check-server (&optional method silent)
15176 "Check whether the connection to METHOD is down.
15177 If METHOD is nil, use `gnus-select-method'.
15178 If it is down, start it up (again)."
15179 (let ((method (or method gnus-select-method)))
15180 ;; Transform virtual server names into select methods.
15181 (when (stringp method)
15182 (setq method (gnus-server-to-method method)))
15183 (if (gnus-server-opened method)
15184 ;; The stream is already opened.
15186 ;; Open the server.
15188 (gnus-message 5 "Opening %s server%s..." (car method)
15189 (if (equal (nth 1 method) "") ""
15190 (format " on %s" (nth 1 method)))))
15191 (run-hooks 'gnus-open-server-hook)
15193 (gnus-open-server method)
15197 (defun gnus-get-function (method function &optional noerror)
15198 "Return a function symbol based on METHOD and FUNCTION."
15199 ;; Translate server names into methods.
15201 (error "Attempted use of a nil select method"))
15202 (when (stringp method)
15203 (setq method (gnus-server-to-method method)))
15204 (let ((func (intern (format "%s-%s" (car method) function))))
15205 ;; If the functions isn't bound, we require the backend in
15207 (unless (fboundp func)
15208 (require (car method))
15209 (when (and (not (fboundp func))
15211 ;; This backend doesn't implement this function.
15212 (error "No such function: %s" func)))
15217 ;;; Interface functions to the backends.
15220 (defun gnus-open-server (method)
15221 "Open a connection to METHOD."
15222 (when (stringp method)
15223 (setq method (gnus-server-to-method method)))
15224 (let ((elem (assoc method gnus-opened-servers)))
15225 ;; If this method was previously denied, we just return nil.
15226 (if (eq (nth 1 elem) 'denied)
15228 (gnus-message 1 "Denied server")
15230 ;; Open the server.
15232 (funcall (gnus-get-function method 'open-server)
15233 (nth 1 method) (nthcdr 2 method))))
15234 ;; If this hasn't been opened before, we add it to the list.
15236 (setq elem (list method nil)
15237 gnus-opened-servers (cons elem gnus-opened-servers)))
15238 ;; Set the status of this server.
15239 (setcar (cdr elem) (if result 'ok 'denied))
15240 ;; Return the result from the "open" call.
15243 (defun gnus-close-server (method)
15244 "Close the connection to METHOD."
15245 (when (stringp method)
15246 (setq method (gnus-server-to-method method)))
15247 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15249 (defun gnus-request-list (method)
15250 "Request the active file from METHOD."
15251 (when (stringp method)
15252 (setq method (gnus-server-to-method method)))
15253 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15255 (defun gnus-request-list-newsgroups (method)
15256 "Request the newsgroups file from METHOD."
15257 (when (stringp method)
15258 (setq method (gnus-server-to-method method)))
15259 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15261 (defun gnus-request-newgroups (date method)
15262 "Request all new groups since DATE from METHOD."
15263 (when (stringp method)
15264 (setq method (gnus-server-to-method method)))
15265 (funcall (gnus-get-function method 'request-newgroups)
15266 date (nth 1 method)))
15268 (defun gnus-server-opened (method)
15269 "Check whether a connection to METHOD has been opened."
15270 (when (stringp method)
15271 (setq method (gnus-server-to-method method)))
15272 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15274 (defun gnus-status-message (method)
15275 "Return the status message from METHOD.
15276 If METHOD is a string, it is interpreted as a group name. The method
15277 this group uses will be queried."
15278 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15280 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15282 (defun gnus-request-group (group &optional dont-check method)
15283 "Request GROUP. If DONT-CHECK, no information is required."
15284 (let ((method (or method (gnus-find-method-for-group group))))
15285 (when (stringp method)
15286 (setq method (gnus-server-to-method method)))
15287 (funcall (gnus-get-function method 'request-group)
15288 (gnus-group-real-name group) (nth 1 method) dont-check)))
15290 (defun gnus-request-asynchronous (group &optional articles)
15291 "Request that GROUP behave asynchronously.
15292 ARTICLES is the `data' of the group."
15293 (let ((method (gnus-find-method-for-group group)))
15294 (funcall (gnus-get-function method 'request-asynchronous)
15295 (gnus-group-real-name group) (nth 1 method) articles)))
15297 (defun gnus-list-active-group (group)
15298 "Request active information on GROUP."
15299 (let ((method (gnus-find-method-for-group group))
15300 (func 'list-active-group))
15301 (when (gnus-check-backend-function func group)
15302 (funcall (gnus-get-function method func)
15303 (gnus-group-real-name group) (nth 1 method)))))
15305 (defun gnus-request-group-description (group)
15306 "Request a description of GROUP."
15307 (let ((method (gnus-find-method-for-group group))
15308 (func 'request-group-description))
15309 (when (gnus-check-backend-function func group)
15310 (funcall (gnus-get-function method func)
15311 (gnus-group-real-name group) (nth 1 method)))))
15313 (defun gnus-close-group (group)
15314 "Request the GROUP be closed."
15315 (let ((method (gnus-find-method-for-group group)))
15316 (funcall (gnus-get-function method 'close-group)
15317 (gnus-group-real-name group) (nth 1 method))))
15319 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15320 "Request headers for ARTICLES in GROUP.
15321 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15322 (let ((method (gnus-find-method-for-group group)))
15323 (if (and gnus-use-cache (numberp (car articles)))
15324 (gnus-cache-retrieve-headers articles group fetch-old)
15325 (funcall (gnus-get-function method 'retrieve-headers)
15326 articles (gnus-group-real-name group) (nth 1 method)
15329 (defun gnus-retrieve-groups (groups method)
15330 "Request active information on GROUPS from METHOD."
15331 (when (stringp method)
15332 (setq method (gnus-server-to-method method)))
15333 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15335 (defun gnus-request-type (group &optional article)
15336 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15337 (let ((method (gnus-find-method-for-group group)))
15338 (if (not (gnus-check-backend-function 'request-type (car method)))
15340 (funcall (gnus-get-function method 'request-type)
15341 (gnus-group-real-name group) article))))
15343 (defun gnus-request-update-mark (group article mark)
15344 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15345 (let ((method (gnus-find-method-for-group group)))
15346 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15348 (funcall (gnus-get-function method 'request-update-mark)
15349 (gnus-group-real-name group) article mark))))
15351 (defun gnus-request-article (article group &optional buffer)
15352 "Request the ARTICLE in GROUP.
15353 ARTICLE can either be an article number or an article Message-ID.
15354 If BUFFER, insert the article in that group."
15355 (let ((method (gnus-find-method-for-group group)))
15356 (funcall (gnus-get-function method 'request-article)
15357 article (gnus-group-real-name group) (nth 1 method) buffer)))
15359 (defun gnus-request-head (article group)
15360 "Request the head of ARTICLE in GROUP."
15361 (let* ((method (gnus-find-method-for-group group))
15362 (head (gnus-get-function method 'request-head t)))
15364 (funcall head article (gnus-group-real-name group) (nth 1 method))
15365 (let ((res (gnus-request-article article group)))
15368 (set-buffer nntp-server-buffer)
15369 (goto-char (point-min))
15370 (when (search-forward "\n\n" nil t)
15371 (delete-region (1- (point)) (point-max)))
15372 (nnheader-fold-continuation-lines)))
15375 (defun gnus-request-body (article group)
15376 "Request the body of ARTICLE in GROUP."
15377 (let ((method (gnus-find-method-for-group group)))
15378 (funcall (gnus-get-function method 'request-body)
15379 article (gnus-group-real-name group) (nth 1 method))))
15381 (defun gnus-request-post (method)
15382 "Post the current buffer using METHOD."
15383 (when (stringp method)
15384 (setq method (gnus-server-to-method method)))
15385 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15387 (defun gnus-request-scan (group method)
15388 "Request a SCAN being performed in GROUP from METHOD.
15389 If GROUP is nil, all groups on METHOD are scanned."
15390 (let ((method (if group (gnus-find-method-for-group group) method)))
15391 (funcall (gnus-get-function method 'request-scan)
15392 (and group (gnus-group-real-name group)) (nth 1 method))))
15394 (defsubst gnus-request-update-info (info method)
15395 "Request that METHOD update INFO."
15396 (when (stringp method)
15397 (setq method (gnus-server-to-method method)))
15398 (when (gnus-check-backend-function 'request-update-info (car method))
15399 (funcall (gnus-get-function method 'request-update-info)
15400 (gnus-group-real-name (gnus-info-group info))
15401 info (nth 1 method))))
15403 (defun gnus-request-expire-articles (articles group &optional force)
15404 (let ((method (gnus-find-method-for-group group)))
15405 (funcall (gnus-get-function method 'request-expire-articles)
15406 articles (gnus-group-real-name group) (nth 1 method)
15409 (defun gnus-request-move-article
15410 (article group server accept-function &optional last)
15411 (let ((method (gnus-find-method-for-group group)))
15412 (funcall (gnus-get-function method 'request-move-article)
15413 article (gnus-group-real-name group)
15414 (nth 1 method) accept-function last)))
15416 (defun gnus-request-accept-article (group method &optional last)
15417 ;; Make sure there's a newline at the end of the article.
15418 (when (stringp method)
15419 (setq method (gnus-server-to-method method)))
15420 (when (and (not method)
15422 (setq method (gnus-group-name-to-method group)))
15423 (goto-char (point-max))
15426 (let ((func (car (or method (gnus-find-method-for-group group)))))
15427 (funcall (intern (format "%s-request-accept-article" func))
15428 (if (stringp group) (gnus-group-real-name group) group)
15432 (defun gnus-request-replace-article (article group buffer)
15433 (let ((func (car (gnus-find-method-for-group group))))
15434 (funcall (intern (format "%s-request-replace-article" func))
15435 article (gnus-group-real-name group) buffer)))
15437 (defun gnus-request-associate-buffer (group)
15438 (let ((method (gnus-find-method-for-group group)))
15439 (funcall (gnus-get-function method 'request-associate-buffer)
15440 (gnus-group-real-name group))))
15442 (defun gnus-request-restore-buffer (article group)
15443 "Request a new buffer restored to the state of ARTICLE."
15444 (let ((method (gnus-find-method-for-group group)))
15445 (funcall (gnus-get-function method 'request-restore-buffer)
15446 article (gnus-group-real-name group) (nth 1 method))))
15448 (defun gnus-request-create-group (group &optional method)
15449 (when (stringp method)
15450 (setq method (gnus-server-to-method method)))
15451 (let ((method (or method (gnus-find-method-for-group group))))
15452 (funcall (gnus-get-function method 'request-create-group)
15453 (gnus-group-real-name group) (nth 1 method))))
15455 (defun gnus-request-delete-group (group &optional force)
15456 (let ((method (gnus-find-method-for-group group)))
15457 (funcall (gnus-get-function method 'request-delete-group)
15458 (gnus-group-real-name group) force (nth 1 method))))
15460 (defun gnus-request-rename-group (group new-name)
15461 (let ((method (gnus-find-method-for-group group)))
15462 (funcall (gnus-get-function method 'request-rename-group)
15463 (gnus-group-real-name group)
15464 (gnus-group-real-name new-name) (nth 1 method))))
15466 (defun gnus-member-of-valid (symbol group)
15467 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15468 (memq symbol (assoc
15469 (symbol-name (car (gnus-find-method-for-group group)))
15470 gnus-valid-select-methods)))
15472 (defun gnus-method-option-p (method option)
15473 "Return non-nil if select METHOD has OPTION as a parameter."
15474 (when (stringp method)
15475 (setq method (gnus-server-to-method method)))
15476 (memq option (assoc (format "%s" (car method))
15477 gnus-valid-select-methods)))
15479 (defun gnus-server-extend-method (group method)
15480 ;; This function "extends" a virtual server. If the server is
15481 ;; "hello", and the select method is ("hello" (my-var "something"))
15482 ;; in the group "alt.alt", this will result in a new virtual server
15483 ;; called "hello+alt.alt".
15485 (gnus-copy-sequence
15486 (if (equal (car method) "native") gnus-select-method
15487 (cdr (assoc (car method) gnus-server-alist))))))
15488 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15489 (nconc entry (cdr method))))
15491 (defun gnus-server-status (method)
15492 "Return the status of METHOD."
15493 (nth 1 (assoc method gnus-opened-servers)))
15495 (defun gnus-group-name-to-method (group)
15496 "Return a select method suitable for GROUP."
15497 (if (string-match ":" group)
15498 (let ((server (substring group 0 (match-beginning 0))))
15499 (if (string-match "\\+" server)
15500 (list (intern (substring server 0 (match-beginning 0)))
15501 (substring server (match-end 0)))
15502 (list (intern server) "")))
15503 gnus-select-method))
15505 (defun gnus-find-method-for-group (group &optional info)
15506 "Find the select method that GROUP uses."
15507 (or gnus-override-method
15509 gnus-select-method)
15510 (let ((info (or info (gnus-get-info group)))
15513 (not (setq method (gnus-info-method info)))
15514 (equal method "native"))
15517 (cond ((stringp method)
15518 (gnus-server-to-method method))
15519 ((stringp (car method))
15520 (gnus-server-extend-method group method))
15523 (cond ((equal (cadr method) "")
15525 ((null (cadr method))
15526 (list (car method) ""))
15528 (gnus-server-add-address method)))))))
15530 (defun gnus-check-backend-function (func group)
15531 "Check whether GROUP supports function FUNC."
15532 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15534 (fboundp (intern (format "%s-%s" method func)))))
15536 (defun gnus-methods-using (feature)
15537 "Find all methods that have FEATURE."
15538 (let ((valids gnus-valid-select-methods)
15541 (if (memq feature (car valids))
15542 (setq outs (cons (car valids) outs)))
15543 (setq valids (cdr valids)))
15548 ;;; Active & Newsrc File Handling
15551 (defun gnus-setup-news (&optional rawfile level dont-connect)
15552 "Setup news information.
15553 If RAWFILE is non-nil, the .newsrc file will also be read.
15554 If LEVEL is non-nil, the news will be set up at level LEVEL."
15555 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15558 ;; Clear some variables to re-initialize news information.
15559 (setq gnus-newsrc-alist nil
15560 gnus-active-hashtb nil)
15561 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15562 (gnus-read-newsrc-file rawfile))
15564 (when (and (not (assoc "archive" gnus-server-alist))
15565 (gnus-archive-server-wanted-p))
15566 (push (cons "archive" gnus-message-archive-method)
15567 gnus-server-alist))
15569 ;; If we don't read the complete active file, we fill in the
15571 (if (or (null gnus-read-active-file)
15572 (eq gnus-read-active-file 'some))
15573 (gnus-update-active-hashtb-from-killed))
15575 ;; Read the active file and create `gnus-active-hashtb'.
15576 ;; If `gnus-read-active-file' is nil, then we just create an empty
15577 ;; hash table. The partial filling out of the hash table will be
15578 ;; done in `gnus-get-unread-articles'.
15579 (and gnus-read-active-file
15581 (gnus-read-active-file))
15583 (or gnus-active-hashtb
15584 (setq gnus-active-hashtb (make-vector 4095 0)))
15586 ;; Initialize the cache.
15587 (when gnus-use-cache
15590 ;; Possibly eval the dribble file.
15591 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15593 ;; Slave Gnusii should then clear the dribble buffer.
15594 (when (and init gnus-slave)
15595 (gnus-dribble-clear))
15597 (gnus-update-format-specifications)
15599 ;; See whether we need to read the description file.
15600 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15601 (not gnus-description-hashtb)
15603 gnus-read-active-file)
15604 (gnus-read-all-descriptions-files))
15606 ;; Find new newsgroups and treat them.
15607 (if (and init gnus-check-new-newsgroups (not level)
15608 (gnus-check-server gnus-select-method))
15609 (gnus-find-new-newsgroups))
15611 ;; We might read in new NoCeM messages here.
15612 (when (and gnus-use-nocem
15614 (not dont-connect))
15615 (gnus-nocem-scan-groups))
15617 ;; Find the number of unread articles in each non-dead group.
15618 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15619 (gnus-get-unread-articles level))
15621 (if (and init gnus-check-bogus-newsgroups
15622 gnus-read-active-file (not level)
15623 (gnus-server-opened gnus-select-method))
15624 (gnus-check-bogus-newsgroups))))
15626 (defun gnus-find-new-newsgroups (&optional arg)
15627 "Search for new newsgroups and add them.
15628 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15629 The `-n' option line from .newsrc is respected.
15630 If ARG (the prefix), use the `ask-server' method to query
15631 the server for new groups."
15633 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15634 (null gnus-read-active-file)
15635 (eq gnus-read-active-file 'some))
15636 'ask-server gnus-check-new-newsgroups)))
15637 (unless (gnus-check-first-time-used)
15638 (if (or (consp check)
15639 (eq check 'ask-server))
15640 ;; Ask the server for new groups.
15641 (gnus-ask-server-for-new-groups)
15642 ;; Go through the active hashtb and look for new groups.
15644 group new-newsgroups)
15645 (gnus-message 5 "Looking for new newsgroups...")
15646 (unless gnus-have-read-active-file
15647 (gnus-read-active-file))
15648 (setq gnus-newsrc-last-checked-date (current-time-string))
15649 (unless gnus-killed-hashtb
15650 (gnus-make-hashtable-from-killed))
15651 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15652 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15655 (if (or (null (setq group (symbol-name sym)))
15657 (null (symbol-value sym))
15658 (gnus-gethash group gnus-killed-hashtb)
15659 (gnus-gethash group gnus-newsrc-hashtb))
15661 (let ((do-sub (gnus-matches-options-n group)))
15663 ((eq do-sub 'subscribe)
15664 (setq groups (1+ groups))
15665 (gnus-sethash group group gnus-killed-hashtb)
15666 (funcall gnus-subscribe-options-newsgroup-method group))
15667 ((eq do-sub 'ignore)
15670 (setq groups (1+ groups))
15671 (gnus-sethash group group gnus-killed-hashtb)
15672 (if gnus-subscribe-hierarchical-interactive
15673 (setq new-newsgroups (cons group new-newsgroups))
15674 (funcall gnus-subscribe-newsgroup-method group)))))))
15675 gnus-active-hashtb)
15676 (when new-newsgroups
15677 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15678 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15680 (gnus-message 6 "%d new newsgroup%s arrived."
15681 groups (if (> groups 1) "s have" " has"))
15682 (gnus-message 6 "No new newsgroups.")))))))
15684 (defun gnus-matches-options-n (group)
15685 ;; Returns `subscribe' if the group is to be unconditionally
15686 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15687 ;; no match for the group.
15689 ;; First we check the two user variables.
15691 ((and gnus-options-subscribe
15692 (string-match gnus-options-subscribe group))
15694 ((and gnus-auto-subscribed-groups
15695 (string-match gnus-auto-subscribed-groups group))
15697 ((and gnus-options-not-subscribe
15698 (string-match gnus-options-not-subscribe group))
15700 ;; Then we go through the list that was retrieved from the .newsrc
15701 ;; file. This list has elements on the form
15702 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15703 ;; is in the reverse order of the options line) is returned.
15705 (let ((regs gnus-newsrc-options-n))
15707 (not (string-match (caar regs) group)))
15708 (setq regs (cdr regs)))
15709 (and regs (cdar regs))))))
15711 (defun gnus-ask-server-for-new-groups ()
15712 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15713 (methods (cons gnus-select-method
15715 (when (gnus-archive-server-wanted-p)
15718 (and (consp gnus-check-new-newsgroups)
15719 gnus-check-new-newsgroups)
15720 gnus-secondary-select-methods))))
15722 (new-date (current-time-string))
15723 group new-newsgroups got-new method hashtb
15724 gnus-override-subscribe-method)
15725 ;; Go through both primary and secondary select methods and
15726 ;; request new newsgroups.
15727 (while (setq method (gnus-server-get-method nil (pop methods)))
15728 (setq new-newsgroups nil)
15729 (setq gnus-override-subscribe-method method)
15730 (when (and (gnus-check-server method)
15731 (gnus-request-newgroups date method))
15734 (setq hashtb (gnus-make-hashtable 100))
15735 (set-buffer nntp-server-buffer)
15736 ;; Enter all the new groups into a hashtable.
15737 (gnus-active-to-gnus-format method hashtb 'ignore))
15738 ;; Now all new groups from `method' are in `hashtb'.
15740 (lambda (group-sym)
15741 (if (or (null (setq group (symbol-name group-sym)))
15742 (not (boundp group-sym))
15743 (null (symbol-value group-sym))
15744 (gnus-gethash group gnus-newsrc-hashtb)
15745 (member group gnus-zombie-list)
15746 (member group gnus-killed-list))
15747 ;; The group is already known.
15749 ;; Make this group active.
15750 (when (symbol-value group-sym)
15751 (gnus-set-active group (symbol-value group-sym)))
15752 ;; Check whether we want it or not.
15753 (let ((do-sub (gnus-matches-options-n group)))
15755 ((eq do-sub 'subscribe)
15757 (gnus-sethash group group gnus-killed-hashtb)
15758 (funcall gnus-subscribe-options-newsgroup-method group))
15759 ((eq do-sub 'ignore)
15763 (gnus-sethash group group gnus-killed-hashtb)
15764 (if gnus-subscribe-hierarchical-interactive
15765 (push group new-newsgroups)
15766 (funcall gnus-subscribe-newsgroup-method group)))))))
15768 (when new-newsgroups
15769 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15770 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15772 (gnus-message 6 "%d new newsgroup%s arrived."
15773 groups (if (> groups 1) "s have" " has")))
15774 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15777 (defun gnus-check-first-time-used ()
15778 (if (or (> (length gnus-newsrc-alist) 1)
15779 (file-exists-p gnus-startup-file)
15780 (file-exists-p (concat gnus-startup-file ".el"))
15781 (file-exists-p (concat gnus-startup-file ".eld")))
15783 (gnus-message 6 "First time user; subscribing you to default groups")
15784 (unless (gnus-read-active-file-p)
15785 (gnus-read-active-file))
15786 (setq gnus-newsrc-last-checked-date (current-time-string))
15787 (let ((groups gnus-default-subscribed-newsgroups)
15791 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15794 (if (null (setq group (symbol-name sym)))
15796 (let ((do-sub (gnus-matches-options-n group)))
15798 ((eq do-sub 'subscribe)
15799 (gnus-sethash group group gnus-killed-hashtb)
15800 (funcall gnus-subscribe-options-newsgroup-method group))
15801 ((eq do-sub 'ignore)
15804 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15805 gnus-active-hashtb)
15807 (if (gnus-active (car groups))
15808 (gnus-group-change-level
15809 (car groups) gnus-level-default-subscribed gnus-level-killed))
15810 (setq groups (cdr groups)))
15811 (gnus-group-make-help-group)
15812 (and gnus-novice-user
15813 (gnus-message 7 "`A k' to list killed groups"))))))
15815 (defun gnus-subscribe-group (group previous &optional method)
15816 (gnus-group-change-level
15818 (list t group gnus-level-default-subscribed nil nil method)
15820 gnus-level-default-subscribed gnus-level-killed previous t))
15822 ;; `gnus-group-change-level' is the fundamental function for changing
15823 ;; subscription levels of newsgroups. This might mean just changing
15824 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15825 ;; again, which subscribes/unsubscribes a group, which is equally
15826 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15827 ;; from 8-9 to 1-7 means that you remove the group from the list of
15828 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15829 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15830 ;; which is trivial.
15831 ;; ENTRY can either be a string (newsgroup name) or a list (if
15832 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15833 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15835 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15836 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15838 (defun gnus-group-change-level (entry level &optional oldlevel
15839 previous fromkilled)
15840 (let (group info active num)
15841 ;; Glean what info we can from the arguments
15843 (if fromkilled (setq group (nth 1 entry))
15844 (setq group (car (nth 2 entry))))
15845 (setq group entry))
15846 (if (and (stringp entry)
15848 (< oldlevel gnus-level-zombie))
15849 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15850 (if (and (not oldlevel)
15852 (setq oldlevel (gnus-info-level (nth 2 entry)))
15853 (setq oldlevel (or oldlevel 9)))
15854 (if (stringp previous)
15855 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15857 (if (and (>= oldlevel gnus-level-zombie)
15858 (gnus-gethash group gnus-newsrc-hashtb))
15859 ;; We are trying to subscribe a group that is already
15863 (or (gnus-ephemeral-group-p group)
15864 (gnus-dribble-enter
15865 (format "(gnus-group-change-level %S %S %S %S %S)"
15866 group level oldlevel (car (nth 2 previous)) fromkilled)))
15868 ;; Then we remove the newgroup from any old structures, if needed.
15869 ;; If the group was killed, we remove it from the killed or zombie
15870 ;; list. If not, and it is in fact going to be killed, we remove
15871 ;; it from the newsrc hash table and assoc.
15873 ((>= oldlevel gnus-level-zombie)
15874 (if (= oldlevel gnus-level-zombie)
15875 (setq gnus-zombie-list (delete group gnus-zombie-list))
15876 (setq gnus-killed-list (delete group gnus-killed-list))))
15878 (if (and (>= level gnus-level-zombie)
15881 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15883 (setcdr (gnus-gethash (car (nth 3 entry))
15884 gnus-newsrc-hashtb)
15886 (setcdr (cdr entry) (cdddr entry))))))
15888 ;; Finally we enter (if needed) the list where it is supposed to
15889 ;; go, and change the subscription level. If it is to be killed,
15890 ;; we enter it into the killed or zombie list.
15892 ((>= level gnus-level-zombie)
15893 ;; Remove from the hash table.
15894 (gnus-sethash group nil gnus-newsrc-hashtb)
15895 ;; We do not enter foreign groups into the list of dead
15897 (unless (gnus-group-foreign-p group)
15898 (if (= level gnus-level-zombie)
15899 (setq gnus-zombie-list (cons group gnus-zombie-list))
15900 (setq gnus-killed-list (cons group gnus-killed-list)))))
15902 ;; If the list is to be entered into the newsrc assoc, and
15903 ;; it was killed, we have to create an entry in the newsrc
15904 ;; hashtb format and fix the pointers in the newsrc assoc.
15905 (if (< oldlevel gnus-level-zombie)
15906 ;; It was alive, and it is going to stay alive, so we
15907 ;; just change the level and don't change any pointers or
15908 ;; hash table entries.
15909 (setcar (cdaddr entry) level)
15911 (setq info (cdr entry)
15913 (setq active (gnus-active group))
15915 (if active (- (1+ (cdr active)) (car active)) t))
15916 ;; Check whether the group is foreign. If so, the
15917 ;; foreign select method has to be entered into the
15919 (let ((method (or gnus-override-subscribe-method
15920 (gnus-group-method group))))
15921 (if (eq method gnus-select-method)
15922 (setq info (list group level nil))
15923 (setq info (list group level nil nil method)))))
15926 (let ((p gnus-newsrc-alist))
15930 (setq entry (cons info (cddr previous)))
15933 (setcdr (cdr previous) entry)
15934 (gnus-sethash group (cons num (cdr previous))
15935 gnus-newsrc-hashtb))
15936 (setcdr previous entry)
15937 (gnus-sethash group (cons num previous)
15938 gnus-newsrc-hashtb))
15940 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15941 (when gnus-group-change-level-function
15942 (funcall gnus-group-change-level-function group level oldlevel)))))
15944 (defun gnus-kill-newsgroup (newsgroup)
15945 "Obsolete function. Kills a newsgroup."
15946 (gnus-group-change-level
15947 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15949 (defun gnus-check-bogus-newsgroups (&optional confirm)
15950 "Remove bogus newsgroups.
15951 If CONFIRM is non-nil, the user has to confirm the deletion of every
15953 (let ((newsrc (cdr gnus-newsrc-alist))
15954 bogus group entry info)
15955 (gnus-message 5 "Checking bogus newsgroups...")
15956 (unless (gnus-read-active-file-p)
15957 (gnus-read-active-file))
15958 (when (gnus-read-active-file-p)
15959 ;; Find all bogus newsgroup that are subscribed.
15961 (setq info (pop newsrc)
15962 group (gnus-info-group info))
15963 (unless (or (gnus-active group) ; Active
15964 (gnus-info-method info) ; Foreign
15966 (not (gnus-y-or-n-p
15967 (format "Remove bogus newsgroup: %s " group)))))
15968 ;; Found a bogus newsgroup.
15969 (push group bogus)))
15970 ;; Remove all bogus subscribed groups by first killing them, and
15971 ;; then removing them from the list of killed groups.
15973 (when (setq entry (gnus-gethash (setq group (pop bogus))
15974 gnus-newsrc-hashtb))
15975 (gnus-group-change-level entry gnus-level-killed)
15976 (setq gnus-killed-list (delete group gnus-killed-list))))
15977 ;; Then we remove all bogus groups from the list of killed and
15978 ;; zombie groups. They are are removed without confirmation.
15979 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15982 (setq killed (symbol-value (car dead-lists)))
15984 (unless (gnus-active (setq group (pop killed)))
15985 ;; The group is bogus.
15986 ;; !!!Slow as hell.
15987 (set (car dead-lists)
15988 (delete group (symbol-value (car dead-lists))))))
15989 (setq dead-lists (cdr dead-lists))))
15990 (run-hooks 'gnus-check-bogus-groups-hook)
15991 (gnus-message 5 "Checking bogus newsgroups...done"))))
15993 (defun gnus-check-duplicate-killed-groups ()
15994 "Remove duplicates from the list of killed groups."
15996 (let ((killed gnus-killed-list))
15998 (gnus-message 9 "%d" (length killed))
15999 (setcdr killed (delete (car killed) (cdr killed)))
16000 (setq killed (cdr killed)))))
16002 ;; We want to inline a function from gnus-cache, so we cheat here:
16005 (require 'gnus-cache))
16007 (defun gnus-get-unread-articles-in-group (info active &optional update)
16009 ;; Allow the backend to update the info in the group.
16011 (gnus-request-update-info
16012 info (gnus-find-method-for-group (gnus-info-group info))))
16013 (gnus-activate-group (gnus-info-group info) nil t))
16014 (let* ((range (gnus-info-read info))
16016 ;; If a cache is present, we may have to alter the active info.
16017 (when (and gnus-use-cache info)
16018 (inline (gnus-cache-possibly-alter-active
16019 (gnus-info-group info) active)))
16020 ;; Modify the list of read articles according to what articles
16021 ;; are available; then tally the unread articles and add the
16022 ;; number to the group hash table entry.
16024 ((zerop (cdr active))
16027 (setq num (- (1+ (cdr active)) (car active))))
16028 ((not (listp (cdr range)))
16029 ;; Fix a single (num . num) range according to the
16030 ;; active hash table.
16031 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
16032 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
16033 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
16034 ;; Compute number of unread articles.
16035 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
16037 ;; The read list is a list of ranges. Fix them according to
16038 ;; the active hash table.
16039 ;; First peel off any elements that are below the lower
16041 (while (and (cdr range)
16043 (or (and (atom (cadr range)) (cadr range))
16045 (if (numberp (car range))
16048 (or (and (numberp (cadr range))
16051 (setcdr (car range)
16052 (or (and (numberp (nth 1 range)) (nth 1 range))
16054 (setcdr range (cddr range)))
16055 ;; Adjust the first element to be the same as the lower limit.
16056 (if (and (not (atom (car range)))
16057 (< (cdar range) (car active)))
16058 (setcdr (car range) (1- (car active))))
16059 ;; Then we want to peel off any elements that are higher
16060 ;; than the upper active limit.
16061 (let ((srange range))
16062 ;; Go past all legal elements.
16063 (while (and (cdr srange)
16064 (<= (or (and (atom (cadr srange))
16066 (caadr srange)) (cdr active)))
16067 (setq srange (cdr srange)))
16069 ;; Nuke all remaining illegal elements.
16070 (setcdr srange nil))
16072 ;; Adjust the final element.
16073 (if (and (not (atom (car srange)))
16074 (> (cdar srange) (cdr active)))
16075 (setcdr (car srange) (cdr active))))
16076 ;; Compute the number of unread articles.
16078 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
16080 (or (and (atom (car range)) (car range))
16082 (setq range (cdr range)))
16083 (setq num (max 0 (- (cdr active) num)))))
16084 ;; Set the number of unread articles.
16086 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
16089 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
16090 ;; and compute how many unread articles there are in each group.
16091 (defun gnus-get-unread-articles (&optional level)
16092 (let* ((newsrc (cdr gnus-newsrc-alist))
16093 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
16096 (cond ((and gnus-activate-foreign-newsgroups
16097 (not (numberp gnus-activate-foreign-newsgroups)))
16098 (1+ gnus-level-subscribed))
16099 ((numberp gnus-activate-foreign-newsgroups)
16100 gnus-activate-foreign-newsgroups)
16103 info group active method)
16104 (gnus-message 5 "Checking new news...")
16107 (setq active (gnus-active (setq group (gnus-info-group
16108 (setq info (pop newsrc))))))
16110 ;; Check newsgroups. If the user doesn't want to check them, or
16111 ;; they can't be checked (for instance, if the news server can't
16112 ;; be reached) we just set the number of unread articles in this
16113 ;; newsgroup to t. This means that Gnus thinks that there are
16114 ;; unread articles, but it has no idea how many.
16115 (if (and (setq method (gnus-info-method info))
16116 (not (gnus-server-equal
16118 (setq method (gnus-server-get-method nil method))))
16119 (not (gnus-secondary-method-p method)))
16120 ;; These groups are foreign. Check the level.
16121 (when (<= (gnus-info-level info) foreign-level)
16122 (setq active (gnus-activate-group group 'scan))
16123 (unless (inline (gnus-virtual-group-p group))
16124 (inline (gnus-close-group group)))
16125 (when (fboundp (intern (concat (symbol-name (car method))
16126 "-request-update-info")))
16127 (inline (gnus-request-update-info info method))))
16128 ;; These groups are native or secondary.
16129 (when (and (<= (gnus-info-level info) level)
16130 (not gnus-read-active-file))
16131 (setq active (gnus-activate-group group 'scan))
16132 (inline (gnus-close-group group))))
16134 ;; Get the number of unread articles in the group.
16136 (inline (gnus-get-unread-articles-in-group info active))
16137 ;; The group couldn't be reached, so we nix out the number of
16138 ;; unread articles and stuff.
16139 (gnus-set-active group nil)
16140 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
16142 (gnus-message 5 "Checking new news...done")))
16144 ;; Create a hash table out of the newsrc alist. The `car's of the
16145 ;; alist elements are used as keys.
16146 (defun gnus-make-hashtable-from-newsrc-alist ()
16147 (let ((alist gnus-newsrc-alist)
16148 (ohashtb gnus-newsrc-hashtb)
16150 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
16152 (setq prev (setq gnus-newsrc-alist
16153 (if (equal (caar gnus-newsrc-alist)
16156 (cons (list "dummy.group" 0 nil) alist)))))
16160 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
16162 gnus-newsrc-hashtb)
16164 alist (cdr alist)))))
16166 (defun gnus-make-hashtable-from-killed ()
16167 "Create a hash table from the killed and zombie lists."
16168 (let ((lists '(gnus-killed-list gnus-zombie-list))
16170 (setq gnus-killed-hashtb
16171 (gnus-make-hashtable
16172 (+ (length gnus-killed-list) (length gnus-zombie-list))))
16173 (while (setq list (pop lists))
16174 (setq list (symbol-value list))
16176 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16178 (defun gnus-activate-group (group &optional scan dont-check method)
16179 ;; Check whether a group has been activated or not.
16180 ;; If SCAN, request a scan of that group as well.
16181 (let ((method (or method (gnus-find-method-for-group group)))
16183 (and (gnus-check-server method)
16184 ;; We escape all bugs and quit here to make it possible to
16185 ;; continue if a group is so out-there that it reports bugs
16189 (gnus-check-backend-function 'request-scan (car method))
16190 (gnus-request-scan group method))
16193 (gnus-request-group group dont-check method)
16197 (set-buffer nntp-server-buffer)
16198 (goto-char (point-min))
16199 ;; Parse the result we got from `gnus-request-group'.
16200 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16202 (goto-char (match-beginning 1))
16204 group (setq active (cons (read (current-buffer))
16205 (read (current-buffer)))))
16206 ;; Return the new active info.
16209 (defun gnus-update-read-articles (group unread)
16210 "Update the list of read and ticked articles in GROUP using the
16211 UNREAD and TICKED lists.
16212 Note: UNSELECTED has to be sorted over `<'.
16213 Returns whether the updating was successful."
16214 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16215 (entry (gnus-gethash group gnus-newsrc-hashtb))
16216 (info (nth 2 entry))
16218 (unread (sort (copy-sequence unread) '<))
16220 (if (or (not info) (not active))
16221 ;; There is no info on this group if it was, in fact,
16222 ;; killed. Gnus stores no information on killed groups, so
16223 ;; there's nothing to be done.
16224 ;; One could store the information somewhere temporarily,
16225 ;; perhaps... Hmmm...
16227 ;; Remove any negative articles numbers.
16228 (while (and unread (< (car unread) 0))
16229 (setq unread (cdr unread)))
16230 ;; Remove any expired article numbers
16231 (while (and unread (< (car unread) (car active)))
16232 (setq unread (cdr unread)))
16233 ;; Compute the ranges of read articles by looking at the list of
16234 ;; unread articles.
16236 (if (/= (car unread) prev)
16237 (setq read (cons (if (= prev (1- (car unread))) prev
16238 (cons prev (1- (car unread)))) read)))
16239 (setq prev (1+ (car unread)))
16240 (setq unread (cdr unread)))
16241 (when (<= prev (cdr active))
16242 (setq read (cons (cons prev (cdr active)) read)))
16243 ;; Enter this list into the group info.
16244 (gnus-info-set-read
16245 info (if (> (length read) 1) (nreverse read) read))
16246 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16247 (gnus-get-unread-articles-in-group info (gnus-active group))
16250 (defun gnus-make-articles-unread (group articles)
16251 "Mark ARTICLES in GROUP as unread."
16252 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16253 (gnus-gethash (gnus-group-real-name group)
16254 gnus-newsrc-hashtb))))
16255 (ranges (gnus-info-read info))
16258 (when (gnus-member-of-range
16259 (setq article (pop articles)) ranges)
16260 (setq news (cons article news))))
16262 (gnus-info-set-read
16263 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16264 (gnus-group-update-group group t))))
16266 ;; Enter all dead groups into the hashtb.
16267 (defun gnus-update-active-hashtb-from-killed ()
16268 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16269 (lists (list gnus-killed-list gnus-zombie-list))
16272 (setq killed (car lists))
16274 (gnus-sethash (car killed) nil hashtb)
16275 (setq killed (cdr killed)))
16276 (setq lists (cdr lists)))))
16278 (defun gnus-get-killed-groups ()
16279 "Go through the active hashtb and all all unknown groups as killed."
16280 ;; First make sure active file has been read.
16281 (unless (gnus-read-active-file-p)
16282 (let ((gnus-read-active-file t))
16283 (gnus-read-active-file)))
16284 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16285 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16289 (group (symbol-name sym)))
16290 (if (or (null group)
16291 (gnus-gethash group gnus-killed-hashtb)
16292 (gnus-gethash group gnus-newsrc-hashtb))
16294 (let ((do-sub (gnus-matches-options-n group)))
16295 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16297 (setq groups (1+ groups))
16298 (setq gnus-killed-list
16299 (cons group gnus-killed-list))
16300 (gnus-sethash group group gnus-killed-hashtb))))))
16301 gnus-active-hashtb))
16303 ;; Get the active file(s) from the backend(s).
16304 (defun gnus-read-active-file ()
16305 (gnus-group-set-mode-line)
16308 (if (gnus-check-server gnus-select-method)
16309 ;; The native server is available.
16310 (cons gnus-select-method gnus-secondary-select-methods)
16311 ;; The native server is down, so we just do the
16313 gnus-secondary-select-methods)
16314 ;; Also read from the archive server.
16315 (when (gnus-archive-server-wanted-p)
16316 (list "archive"))))
16318 (setq gnus-have-read-active-file nil)
16320 (set-buffer nntp-server-buffer)
16322 (let* ((method (if (stringp (car methods))
16323 (gnus-server-get-method nil (car methods))
16325 (where (nth 1 method))
16326 (mesg (format "Reading active file%s via %s..."
16327 (if (and where (not (zerop (length where))))
16328 (concat " from " where) "")
16330 (gnus-message 5 mesg)
16331 (when (gnus-check-server method)
16332 ;; Request that the backend scan its incoming messages.
16333 (and (gnus-check-backend-function 'request-scan (car method))
16334 (gnus-request-scan nil method))
16336 ((and (eq gnus-read-active-file 'some)
16337 (gnus-check-backend-function 'retrieve-groups (car method)))
16338 (let ((newsrc (cdr gnus-newsrc-alist))
16339 (gmethod (gnus-server-get-method nil method))
16341 (while (setq info (pop newsrc))
16342 (when (gnus-server-equal
16343 (gnus-find-method-for-group
16344 (gnus-info-group info) info)
16346 (push (gnus-group-real-name (gnus-info-group info))
16349 (gnus-check-server method)
16350 (setq list-type (gnus-retrieve-groups groups method))
16354 1.2 "Cannot read partial active file from %s server."
16356 ((eq list-type 'active)
16357 (gnus-active-to-gnus-format method gnus-active-hashtb))
16359 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16361 (if (not (gnus-request-list method))
16362 (unless (equal method gnus-message-archive-method)
16363 (gnus-error 1 "Cannot read active file from %s server."
16365 (gnus-message 5 mesg)
16366 (gnus-active-to-gnus-format method gnus-active-hashtb)
16367 ;; We mark this active file as read.
16368 (push method gnus-have-read-active-file)
16369 (gnus-message 5 "%sdone" mesg))))))
16370 (setq methods (cdr methods))))))
16372 ;; Read an active file and place the results in `gnus-active-hashtb'.
16373 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16375 (setq method gnus-select-method))
16376 (let ((cur (current-buffer))
16378 (if (and gnus-active-hashtb
16379 (not (equal method gnus-select-method)))
16381 (setq gnus-active-hashtb
16382 (if (equal method gnus-select-method)
16383 (gnus-make-hashtable
16384 (count-lines (point-min) (point-max)))
16385 (gnus-make-hashtable 4096)))))))
16386 ;; Delete unnecessary lines.
16387 (goto-char (point-min))
16388 (while (search-forward "\nto." nil t)
16389 (delete-region (1+ (match-beginning 0))
16390 (progn (forward-line 1) (point))))
16391 (or (string= gnus-ignored-newsgroups "")
16393 (goto-char (point-min))
16394 (delete-matching-lines gnus-ignored-newsgroups)))
16395 ;; Make the group names readable as a lisp expression even if they
16396 ;; contain special characters.
16397 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16398 (goto-char (point-max))
16399 (while (re-search-backward "[][';?()#]" nil t)
16401 ;; If these are groups from a foreign select method, we insert the
16402 ;; group prefix in front of the group names.
16403 (and method (not (gnus-server-equal
16404 (gnus-server-get-method nil method)
16405 (gnus-server-get-method nil gnus-select-method)))
16406 (let ((prefix (gnus-group-prefixed-name "" method)))
16407 (goto-char (point-min))
16408 (while (and (not (eobp))
16409 (progn (insert prefix)
16410 (zerop (forward-line 1)))))))
16411 ;; Store the active file in a hash table.
16412 (goto-char (point-min))
16413 (if (string-match "%[oO]" gnus-group-line-format)
16414 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16415 ;; If we want information on moderated groups, we use this
16417 (let* ((mod-hashtb (make-vector 7 0))
16418 (m (intern "m" mod-hashtb))
16420 (while (not (eobp))
16421 (condition-case nil
16423 (narrow-to-region (point) (gnus-point-at-eol))
16424 (setq group (let ((obarray hashtb)) (read cur)))
16425 (if (and (numberp (setq max (read cur)))
16426 (numberp (setq min (read cur)))
16428 (skip-chars-forward " \t")
16430 (or (= (following-char) ?=)
16431 (= (following-char) ?x)
16432 (= (following-char) ?j)))))
16433 (set group (cons min max))
16435 ;; Enter moderated groups into a list.
16436 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16437 (setq gnus-moderated-list
16438 (cons (symbol-name group) gnus-moderated-list))))
16445 ;; And if we do not care about moderation, we use this loop,
16446 ;; which is faster.
16447 (let (group max min)
16448 (while (not (eobp))
16451 (narrow-to-region (point) (gnus-point-at-eol))
16452 ;; group gets set to a symbol interned in the hash table
16453 ;; (what a hack!!) - jwz
16454 (setq group (let ((obarray hashtb)) (read cur)))
16455 (if (and (numberp (setq max (read cur)))
16456 (numberp (setq min (read cur)))
16458 (skip-chars-forward " \t")
16460 (or (= (following-char) ?=)
16461 (= (following-char) ?x)
16462 (= (following-char) ?j)))))
16463 (set group (cons min max))
16471 (gnus-message 3 "Warning - illegal active: %s"
16473 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16475 (forward-line 1))))))
16477 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16478 ;; Parse a "groups" active file.
16479 (let ((cur (current-buffer))
16481 (if (and method gnus-active-hashtb)
16483 (setq gnus-active-hashtb
16484 (gnus-make-hashtable
16485 (count-lines (point-min) (point-max)))))))
16486 (prefix (and method
16487 (not (gnus-server-equal
16488 (gnus-server-get-method nil method)
16489 (gnus-server-get-method nil gnus-select-method)))
16490 (gnus-group-prefixed-name "" method))))
16492 (goto-char (point-min))
16493 ;; We split this into to separate loops, one with the prefix
16494 ;; and one without to speed the reading up somewhat.
16496 (let (min max opoint group)
16497 (while (not (eobp))
16500 (read cur) (read cur)
16501 (setq min (read cur)
16504 (skip-chars-forward " \t")
16507 (set (let ((obarray hashtb)) (read cur))
16509 (error (and group (symbolp group) (set group nil))))
16511 (let (min max group)
16512 (while (not (eobp))
16514 (if (= (following-char) ?2)
16516 (read cur) (read cur)
16517 (setq min (read cur)
16519 (set (setq group (let ((obarray hashtb)) (read cur)))
16521 (error (and group (symbolp group) (set group nil))))
16522 (forward-line 1))))))
16524 (defun gnus-read-newsrc-file (&optional force)
16525 "Read startup file.
16526 If FORCE is non-nil, the .newsrc file is read."
16527 ;; Reset variables that might be defined in the .newsrc.eld file.
16528 (let ((variables gnus-variable-list))
16530 (set (car variables) nil)
16531 (setq variables (cdr variables))))
16532 (let* ((newsrc-file gnus-current-startup-file)
16533 (quick-file (concat newsrc-file ".el")))
16535 ;; We always load the .newsrc.eld file. If always contains
16536 ;; much information that can not be gotten from the .newsrc
16537 ;; file (ticked articles, killed groups, foreign methods, etc.)
16538 (gnus-read-newsrc-el-file quick-file)
16540 (if (and (file-exists-p gnus-current-startup-file)
16542 (and (file-newer-than-file-p newsrc-file quick-file)
16543 (file-newer-than-file-p newsrc-file
16544 (concat quick-file "d")))
16545 (not gnus-newsrc-alist)))
16546 ;; We read the .newsrc file. Note that if there if a
16547 ;; .newsrc.eld file exists, it has already been read, and
16548 ;; the `gnus-newsrc-hashtb' has been created. While reading
16549 ;; the .newsrc file, Gnus will only use the information it
16550 ;; can find there for changing the data already read -
16551 ;; ie. reading the .newsrc file will not trash the data
16552 ;; already read (except for read articles).
16554 (gnus-message 5 "Reading %s..." newsrc-file)
16555 (set-buffer (find-file-noselect newsrc-file))
16556 (buffer-disable-undo (current-buffer))
16557 (gnus-newsrc-to-gnus-format)
16558 (kill-buffer (current-buffer))
16559 (gnus-message 5 "Reading %s...done" newsrc-file)))
16561 ;; Read any slave files.
16563 (gnus-master-read-slave-newsrc))
16565 ;; Convert old to new.
16566 (gnus-convert-old-newsrc))))
16568 (defun gnus-continuum-version (version)
16569 "Return VERSION as a floating point number."
16570 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16571 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16572 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16573 (number (match-string 2 version))
16575 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16576 (setq major (string-to-number (match-string 1 number)))
16577 (setq minor (string-to-number (match-string 2 number)))
16578 (setq least (if (match-beginning 3)
16579 (string-to-number (match-string 3 number))
16583 (format "%s00%02d%02d"
16585 ((member alpha '("(ding)" "d")) "4.99")
16586 ((member alpha '("September" "s")) "5.01")
16587 ((member alpha '("Red" "r")) "5.03"))
16589 (format "%d.%02d%02d" major minor least))))))
16591 (defun gnus-convert-old-newsrc ()
16592 "Convert old newsrc into the new format, if needed."
16593 (let ((fcv (and gnus-newsrc-file-version
16594 (gnus-continuum-version gnus-newsrc-file-version))))
16596 ;; No .newsrc.eld file was loaded.
16598 ;; Gnus 5 .newsrc.eld was loaded.
16599 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16600 (gnus-convert-old-ticks)))))
16602 (defun gnus-convert-old-ticks ()
16603 (let ((newsrc (cdr gnus-newsrc-alist))
16604 marks info dormant ticked)
16605 (while (setq info (pop newsrc))
16606 (when (setq marks (gnus-info-marks info))
16607 (setq dormant (cdr (assq 'dormant marks))
16608 ticked (cdr (assq 'tick marks)))
16609 (when (or dormant ticked)
16610 (gnus-info-set-read
16613 (gnus-info-read info)
16614 (nconc (gnus-uncompress-range dormant)
16615 (gnus-uncompress-range ticked)))))))))
16617 (defun gnus-read-newsrc-el-file (file)
16618 (let ((ding-file (concat file "d")))
16619 ;; We always, always read the .eld file.
16620 (gnus-message 5 "Reading %s..." ding-file)
16621 (let (gnus-newsrc-assoc)
16622 (condition-case nil
16623 (load ding-file t t t)
16625 (gnus-error 1 "Error in %s" ding-file)))
16626 (when gnus-newsrc-assoc
16627 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16628 (gnus-make-hashtable-from-newsrc-alist)
16629 (when (file-newer-than-file-p file ding-file)
16630 ;; Old format quick file
16631 (gnus-message 5 "Reading %s..." file)
16632 ;; The .el file is newer than the .eld file, so we read that one
16634 (gnus-read-old-newsrc-el-file file))))
16636 ;; Parse the old-style quick startup file
16637 (defun gnus-read-old-newsrc-el-file (file)
16638 (let (newsrc killed marked group m info)
16640 (let ((gnus-killed-assoc nil)
16641 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16643 (condition-case nil
16646 (setq newsrc gnus-newsrc-assoc
16647 killed gnus-killed-assoc
16648 marked gnus-marked-assoc)))
16649 (setq gnus-newsrc-alist nil)
16650 (while (setq group (pop newsrc))
16651 (if (setq info (gnus-get-info (car group)))
16653 (gnus-info-set-read info (cddr group))
16654 (gnus-info-set-level
16655 info (if (nth 1 group) gnus-level-default-subscribed
16656 gnus-level-default-unsubscribed))
16657 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16660 (if (nth 1 group) gnus-level-default-subscribed
16661 gnus-level-default-unsubscribed)
16663 gnus-newsrc-alist))
16664 ;; Copy marks into info.
16665 (when (setq m (assoc (car group) marked))
16666 (unless (nthcdr 3 info)
16667 (nconc info (list nil)))
16668 (gnus-info-set-marks
16669 info (list (cons 'tick (gnus-compress-sequence
16670 (sort (cdr m) '<) t))))))
16671 (setq newsrc killed)
16673 (setcar newsrc (caar newsrc))
16674 (setq newsrc (cdr newsrc)))
16675 (setq gnus-killed-list killed))
16676 ;; The .el file version of this variable does not begin with
16677 ;; "options", while the .eld version does, so we just add it if it
16680 gnus-newsrc-options
16682 (and (not (string-match "^ *options" gnus-newsrc-options))
16683 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16684 (and (not (string-match "\n$" gnus-newsrc-options))
16685 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16686 ;; Finally, if we read some options lines, we parse them.
16687 (or (string= gnus-newsrc-options "")
16688 (gnus-newsrc-parse-options gnus-newsrc-options))))
16690 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16691 (gnus-make-hashtable-from-newsrc-alist)))
16693 (defun gnus-make-newsrc-file (file)
16694 "Make server dependent file name by catenating FILE and server host name."
16695 (let* ((file (expand-file-name file nil))
16696 (real-file (concat file "-" (nth 1 gnus-select-method))))
16697 (if (or (file-exists-p real-file)
16698 (file-exists-p (concat real-file ".el"))
16699 (file-exists-p (concat real-file ".eld")))
16702 (defun gnus-newsrc-to-gnus-format ()
16703 (setq gnus-newsrc-options "")
16704 (setq gnus-newsrc-options-n nil)
16706 (or gnus-active-hashtb
16707 (setq gnus-active-hashtb (make-vector 4095 0)))
16708 (let ((buf (current-buffer))
16709 (already-read (> (length gnus-newsrc-alist) 1))
16710 group subscribed options-symbol newsrc Options-symbol
16712 (goto-char (point-min))
16713 ;; We intern the symbol `options' in the active hashtb so that we
16714 ;; can `eq' against it later.
16715 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16716 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16718 (while (not (eobp))
16719 ;; We first read the first word on the line by narrowing and
16720 ;; then reading into `gnus-active-hashtb'. Most groups will
16721 ;; already exist in that hashtb, so this will save some string
16725 (progn (skip-chars-forward "^ \t!:\n") (point)))
16726 (goto-char (point-min))
16728 (and (/= (point-min) (point-max))
16729 (let ((obarray gnus-active-hashtb)) (read buf))))
16731 ;; Now, the symbol we have read is either `options' or a group
16732 ;; name. If it is an options line, we just add it to a string.
16734 ((or (eq symbol options-symbol)
16735 (eq symbol Options-symbol))
16736 (setq gnus-newsrc-options
16737 ;; This concating is quite inefficient, but since our
16738 ;; thorough studies show that approx 99.37% of all
16739 ;; .newsrc files only contain a single options line, we
16740 ;; don't give a damn, frankly, my dear.
16741 (concat gnus-newsrc-options
16743 (gnus-point-at-bol)
16744 ;; Options may continue on the next line.
16745 (or (and (re-search-forward "^[^ \t]" nil 'move)
16746 (progn (beginning-of-line) (point)))
16750 ;; Group names can be just numbers.
16751 (when (numberp symbol)
16752 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16753 (or (boundp symbol) (set symbol nil))
16754 ;; It was a group name.
16755 (setq subscribed (= (following-char) ?:)
16756 group (symbol-name symbol)
16759 ;; If the line ends here, this is clearly a buggy line, so
16760 ;; we put point a the beginning of line and let the cond
16761 ;; below do the error handling.
16762 (beginning-of-line)
16763 ;; We skip to the beginning of the ranges.
16764 (skip-chars-forward "!: \t"))
16765 ;; We are now at the beginning of the list of read articles.
16766 ;; We read them range by range.
16769 ((looking-at "[0-9]+")
16770 ;; We narrow and read a number instead of buffer-substring/
16771 ;; string-to-int because it's faster. narrow/widen is
16772 ;; faster than save-restriction/narrow, and save-restriction
16773 ;; produces a garbage object.
16775 (narrow-to-region (match-beginning 0) (match-end 0))
16778 ;; If the next character is a dash, then this is a range.
16779 (if (= (following-char) ?-)
16781 ;; We read the upper bound of the range.
16783 (if (not (looking-at "[0-9]+"))
16784 ;; This is a buggy line, by we pretend that
16785 ;; it's kinda OK. Perhaps the user should be
16787 (setq reads (cons num1 reads))
16792 (narrow-to-region (match-beginning 0)
16797 ;; It was just a simple number, so we add it to the
16799 (setq reads (cons num1 reads)))
16800 ;; If the next char in ?\n, then we have reached the end
16801 ;; of the line and return nil.
16802 (/= (following-char) ?\n))
16803 ((= (following-char) ?\n)
16804 ;; End of line, so we end.
16807 ;; Not numbers and not eol, so this might be a buggy
16810 ;; If it was eob instead of ?\n, we allow it.
16812 ;; The line was buggy.
16814 (gnus-error 3.1 "Mangled line: %s"
16815 (buffer-substring (gnus-point-at-bol)
16816 (gnus-point-at-eol)))))
16818 ;; Skip past ", ". Spaces are illegal in these ranges, but
16819 ;; we allow them, because it's a common mistake to put a
16820 ;; space after the comma.
16821 (skip-chars-forward ", "))
16823 ;; We have already read .newsrc.eld, so we gently update the
16824 ;; data in the hash table with the information we have just
16827 (let ((info (gnus-get-info group))
16830 ;; There is an entry for this file in the alist.
16832 (gnus-info-set-read info (nreverse reads))
16833 ;; We update the level very gently. In fact, we
16834 ;; only change it if there's been a status change
16835 ;; from subscribed to unsubscribed, or vice versa.
16836 (setq level (gnus-info-level info))
16837 (cond ((and (<= level gnus-level-subscribed)
16839 (setq level (if reads
16840 gnus-level-default-unsubscribed
16841 (1+ gnus-level-default-unsubscribed))))
16842 ((and (> level gnus-level-subscribed) subscribed)
16843 (setq level gnus-level-default-subscribed)))
16844 (gnus-info-set-level info level))
16845 ;; This is a new group.
16846 (setq info (list group
16848 gnus-level-default-subscribed
16850 (1+ gnus-level-subscribed)
16851 gnus-level-default-unsubscribed))
16852 (nreverse reads))))
16853 (setq newsrc (cons info newsrc))))))
16856 (setq newsrc (nreverse newsrc))
16858 (if (not already-read)
16860 ;; We now have two newsrc lists - `newsrc', which is what we
16861 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16862 ;; what we've read from .newsrc.eld. We have to merge these
16863 ;; lists. We do this by "attaching" any (foreign) groups in the
16864 ;; gnus-newsrc-alist to the (native) group that precedes them.
16865 (let ((rc (cdr gnus-newsrc-alist))
16866 (prev gnus-newsrc-alist)
16869 (or (null (nth 4 (car rc))) ; It's a native group.
16870 (assoc (caar rc) newsrc) ; It's already in the alist.
16871 (if (setq entry (assoc (caar prev) newsrc))
16872 (setcdr (setq mentry (memq entry newsrc))
16873 (cons (car rc) (cdr mentry)))
16874 (setq newsrc (cons (car rc) newsrc))))
16878 (setq gnus-newsrc-alist newsrc)
16879 ;; We make the newsrc hashtb.
16880 (gnus-make-hashtable-from-newsrc-alist)
16882 ;; Finally, if we read some options lines, we parse them.
16883 (or (string= gnus-newsrc-options "")
16884 (gnus-newsrc-parse-options gnus-newsrc-options))))
16886 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16887 ;; The return value will be a list on the form
16888 ;; ((regexp1 . ignore)
16889 ;; (regexp2 . subscribe)...)
16890 ;; When handling new newsgroups, groups that match a `ignore' regexp
16891 ;; will be ignored, and groups that match a `subscribe' regexp will be
16892 ;; subscribed. A line like
16893 ;; options -n !all rec.all
16894 ;; will lead to a list that looks like
16895 ;; (("^rec\\..+" . subscribe)
16896 ;; ("^.+" . ignore))
16897 ;; So all "rec.*" groups will be subscribed, while all the other
16898 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16899 ;; different from "options -n rec.all !all".
16900 (defun gnus-newsrc-parse-options (options)
16903 (gnus-set-work-buffer)
16904 (insert (regexp-quote options))
16905 ;; First we treat all continuation lines.
16906 (goto-char (point-min))
16907 (while (re-search-forward "\n[ \t]+" nil t)
16908 (replace-match " " t t))
16909 ;; Then we transform all "all"s into ".+"s.
16910 (goto-char (point-min))
16911 (while (re-search-forward "\\ball\\b" nil t)
16912 (replace-match ".+" t t))
16913 (goto-char (point-min))
16914 ;; We remove all other options than the "-n" ones.
16915 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16916 (replace-match " ")
16918 (goto-char (point-min))
16920 ;; We are only interested in "options -n" lines - we
16921 ;; ignore the other option lines.
16922 (while (re-search-forward "[ \t]-n" nil t)
16924 (or (save-excursion
16925 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16927 (gnus-point-at-eol)))
16928 ;; Search for all "words"...
16929 (while (re-search-forward "[^ \t,\n]+" eol t)
16930 (if (= (char-after (match-beginning 0)) ?!)
16931 ;; If the word begins with a bang (!), this is a "not"
16932 ;; spec. We put this spec (minus the bang) and the
16933 ;; symbol `ignore' into the list.
16934 (setq out (cons (cons (concat
16935 "^" (buffer-substring
16936 (1+ (match-beginning 0))
16939 ;; There was no bang, so this is a "yes" spec.
16940 (setq out (cons (cons (concat "^" (match-string 0))
16941 'subscribe) out)))))
16943 (setq gnus-newsrc-options-n out))))
16945 (defun gnus-save-newsrc-file (&optional force)
16946 "Save .newsrc file."
16947 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16948 ;; from the variable gnus-newsrc-alist.
16949 (when (and (or gnus-newsrc-alist gnus-killed-list)
16950 gnus-current-startup-file)
16952 (if (and (or gnus-use-dribble-file gnus-slave)
16954 (or (not gnus-dribble-buffer)
16955 (not (buffer-name gnus-dribble-buffer))
16956 (zerop (save-excursion
16957 (set-buffer gnus-dribble-buffer)
16959 (gnus-message 4 "(No changes need to be saved)")
16960 (run-hooks 'gnus-save-newsrc-hook)
16962 (gnus-slave-save-newsrc)
16964 (when gnus-save-newsrc-file
16965 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16966 (gnus-gnus-to-newsrc-format)
16967 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16968 ;; Save .newsrc.eld.
16969 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16970 (make-local-variable 'version-control)
16971 (setq version-control 'never)
16972 (setq buffer-file-name
16973 (concat gnus-current-startup-file ".eld"))
16974 (setq default-directory (file-name-directory buffer-file-name))
16975 (gnus-add-current-to-buffer-list)
16976 (buffer-disable-undo (current-buffer))
16978 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16979 (gnus-gnus-to-quick-newsrc-format)
16980 (run-hooks 'gnus-save-quick-newsrc-hook)
16982 (kill-buffer (current-buffer))
16984 5 "Saving %s.eld...done" gnus-current-startup-file))
16985 (gnus-dribble-delete-file)
16986 (gnus-group-set-mode-line)))))
16988 (defun gnus-gnus-to-quick-newsrc-format ()
16989 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16990 (insert ";; Gnus startup file.\n")
16991 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16992 (insert ";; to read .newsrc.\n")
16993 (insert "(setq gnus-newsrc-file-version "
16994 (prin1-to-string gnus-version) ")\n")
16996 (if gnus-save-killed-list gnus-variable-list
16997 ;; Remove the `gnus-killed-list' from the list of variables
16998 ;; to be saved, if required.
16999 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
17000 ;; Peel off the "dummy" group.
17001 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
17003 ;; Insert the variables into the file.
17005 (when (and (boundp (setq variable (pop variables)))
17006 (symbol-value variable))
17007 (insert "(setq " (symbol-name variable) " '")
17008 (prin1 (symbol-value variable) (current-buffer))
17011 (defun gnus-gnus-to-newsrc-format ()
17012 ;; Generate and save the .newsrc file.
17014 (set-buffer (create-file-buffer gnus-current-startup-file))
17015 (let ((newsrc (cdr gnus-newsrc-alist))
17016 (standard-output (current-buffer))
17017 info ranges range method)
17018 (setq buffer-file-name gnus-current-startup-file)
17019 (setq default-directory (file-name-directory buffer-file-name))
17020 (buffer-disable-undo (current-buffer))
17023 (if gnus-newsrc-options (insert gnus-newsrc-options))
17024 ;; Write subscribed and unsubscribed.
17025 (while (setq info (pop newsrc))
17026 ;; Don't write foreign groups to .newsrc.
17027 (when (or (null (setq method (gnus-info-method info)))
17028 (equal method "native")
17029 (gnus-server-equal method gnus-select-method))
17030 (insert (gnus-info-group info)
17031 (if (> (gnus-info-level info) gnus-level-subscribed)
17033 (when (setq ranges (gnus-info-read info))
17035 (if (not (listp (cdr ranges)))
17036 (if (= (car ranges) (cdr ranges))
17037 (princ (car ranges))
17038 (princ (car ranges))
17040 (princ (cdr ranges)))
17041 (while (setq range (pop ranges))
17042 (if (or (atom range) (= (car range) (cdr range)))
17043 (princ (or (and (atom range) range) (car range)))
17044 (princ (car range))
17046 (princ (cdr range)))
17047 (if ranges (insert ",")))))
17049 (make-local-variable 'version-control)
17050 (setq version-control 'never)
17051 ;; It has been reported that sometime the modtime on the .newsrc
17052 ;; file seems to be off. We really do want to overwrite it, so
17053 ;; we clear the modtime here before saving. It's a bit odd,
17055 ;; sometimes the modtime clear isn't sufficient. most brute force:
17056 ;; delete the silly thing entirely first. but this fails to provide
17057 ;; such niceties as .newsrc~ creation.
17058 (if gnus-modtime-botch
17059 (delete-file gnus-startup-file)
17060 (clear-visited-file-modtime))
17061 (run-hooks 'gnus-save-standard-newsrc-hook)
17063 (kill-buffer (current-buffer)))))
17067 ;;; Slave functions.
17070 (defun gnus-slave-save-newsrc ()
17072 (set-buffer gnus-dribble-buffer)
17074 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
17075 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
17077 (defun gnus-master-read-slave-newsrc ()
17080 (file-name-directory gnus-current-startup-file)
17084 (file-name-nondirectory gnus-current-startup-file)
17088 (if (not slave-files)
17089 () ; There are no slave files to read.
17090 (gnus-message 7 "Reading slave newsrcs...")
17092 (set-buffer (get-buffer-create " *gnus slave*"))
17093 (buffer-disable-undo (current-buffer))
17095 (sort (mapcar (lambda (file)
17096 (list (nth 5 (file-attributes file)) file))
17099 (or (< (caar f1) (caar f2))
17100 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
17103 (setq file (nth 1 (car slave-files)))
17104 (insert-file-contents file)
17105 (if (condition-case ()
17107 (eval-buffer (current-buffer))
17110 (gnus-error 3.2 "Possible error in %s" file)
17112 (or gnus-slave ; Slaves shouldn't delete these files.
17116 (setq slave-files (cdr slave-files))))
17117 (gnus-message 7 "Reading slave newsrcs...done"))))
17121 ;;; Group description.
17124 (defun gnus-read-all-descriptions-files ()
17125 (let ((methods (cons gnus-select-method
17127 (when (gnus-archive-server-wanted-p)
17129 gnus-secondary-select-methods))))
17131 (gnus-read-descriptions-file (car methods))
17132 (setq methods (cdr methods)))
17135 (defun gnus-read-descriptions-file (&optional method)
17136 (let ((method (or method gnus-select-method))
17138 (when (stringp method)
17139 (setq method (gnus-server-to-method method)))
17140 ;; We create the hashtable whether we manage to read the desc file
17141 ;; to avoid trying to re-read after a failed read.
17142 (or gnus-description-hashtb
17143 (setq gnus-description-hashtb
17144 (gnus-make-hashtable (length gnus-active-hashtb))))
17145 ;; Mark this method's desc file as read.
17146 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
17147 gnus-description-hashtb)
17149 (gnus-message 5 "Reading descriptions file via %s..." (car method))
17151 ((not (gnus-check-server method))
17152 (gnus-message 1 "Couldn't open server")
17154 ((not (gnus-request-list-newsgroups method))
17155 (gnus-message 1 "Couldn't read newsgroups descriptions")
17160 (set-buffer nntp-server-buffer)
17161 (goto-char (point-min))
17162 (when (or (search-forward "\n.\n" nil t)
17163 (goto-char (point-max)))
17164 (beginning-of-line)
17165 (narrow-to-region (point-min) (point)))
17166 ;; If these are groups from a foreign select method, we insert the
17167 ;; group prefix in front of the group names.
17168 (and method (not (gnus-server-equal
17169 (gnus-server-get-method nil method)
17170 (gnus-server-get-method nil gnus-select-method)))
17171 (let ((prefix (gnus-group-prefixed-name "" method)))
17172 (goto-char (point-min))
17173 (while (and (not (eobp))
17174 (progn (insert prefix)
17175 (zerop (forward-line 1)))))))
17176 (goto-char (point-min))
17177 (while (not (eobp))
17178 ;; If we get an error, we set group to 0, which is not a
17182 (let ((obarray gnus-description-hashtb))
17183 ;; Group is set to a symbol interned in this
17185 (read nntp-server-buffer))
17187 (skip-chars-forward " \t")
17188 ;; ... which leads to this line being effectively ignored.
17189 (and (symbolp group)
17190 (set group (buffer-substring
17191 (point) (progn (end-of-line) (point)))))
17192 (forward-line 1))))
17193 (gnus-message 5 "Reading descriptions file...done")
17196 (defun gnus-group-get-description (group)
17197 "Get the description of a group by sending XGTITLE to the server."
17198 (when (gnus-request-group-description group)
17200 (set-buffer nntp-server-buffer)
17201 (goto-char (point-min))
17202 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17203 (match-string 1)))))
17207 ;;; Buffering of read articles.
17210 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17211 (defvar gnus-backlog-articles nil)
17212 (defvar gnus-backlog-hashtb nil)
17214 (defun gnus-backlog-buffer ()
17215 "Return the backlog buffer."
17216 (or (get-buffer gnus-backlog-buffer)
17218 (set-buffer (get-buffer-create gnus-backlog-buffer))
17219 (buffer-disable-undo (current-buffer))
17220 (setq buffer-read-only t)
17221 (gnus-add-current-to-buffer-list)
17222 (get-buffer gnus-backlog-buffer))))
17224 (defun gnus-backlog-setup ()
17225 "Initialize backlog variables."
17226 (unless gnus-backlog-hashtb
17227 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17229 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17231 (defun gnus-backlog-shutdown ()
17232 "Clear all backlog variables and buffers."
17233 (when (get-buffer gnus-backlog-buffer)
17234 (kill-buffer gnus-backlog-buffer))
17235 (setq gnus-backlog-hashtb nil
17236 gnus-backlog-articles nil))
17238 (defun gnus-backlog-enter-article (group number buffer)
17239 (gnus-backlog-setup)
17240 (let ((ident (intern (concat group ":" (int-to-string number))
17241 gnus-backlog-hashtb))
17243 (if (memq ident gnus-backlog-articles)
17244 () ; It's already kept.
17245 ;; Remove the oldest article, if necessary.
17246 (and (numberp gnus-keep-backlog)
17247 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17248 (gnus-backlog-remove-oldest-article))
17249 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17250 ;; Insert the new article.
17252 (set-buffer (gnus-backlog-buffer))
17253 (let (buffer-read-only)
17254 (goto-char (point-max))
17255 (or (bolp) (insert "\n"))
17257 (insert-buffer-substring buffer)
17258 ;; Tag the beginning of the article with the ident.
17259 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17261 (defun gnus-backlog-remove-oldest-article ()
17263 (set-buffer (gnus-backlog-buffer))
17264 (goto-char (point-min))
17265 (if (zerop (buffer-size))
17266 () ; The buffer is empty.
17267 (let ((ident (get-text-property (point) 'gnus-backlog))
17269 ;; Remove the ident from the list of articles.
17271 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17272 ;; Delete the article itself.
17274 (point) (next-single-property-change
17275 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17277 (defun gnus-backlog-remove-article (group number)
17278 "Remove article NUMBER in GROUP from the backlog."
17279 (when (numberp number)
17280 (gnus-backlog-setup)
17281 (let ((ident (intern (concat group ":" (int-to-string number))
17282 gnus-backlog-hashtb))
17284 (when (memq ident gnus-backlog-articles)
17285 ;; It was in the backlog.
17287 (set-buffer (gnus-backlog-buffer))
17288 (let (buffer-read-only)
17289 (when (setq beg (text-property-any
17290 (point-min) (point-max) 'gnus-backlog
17292 ;; Find the end (i. e., the beginning of the next article).
17294 (next-single-property-change
17295 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17296 (delete-region beg end)
17300 (defun gnus-backlog-request-article (group number buffer)
17301 (when (numberp number)
17302 (gnus-backlog-setup)
17303 (let ((ident (intern (concat group ":" (int-to-string number))
17304 gnus-backlog-hashtb))
17306 (when (memq ident gnus-backlog-articles)
17307 ;; It was in the backlog.
17309 (set-buffer (gnus-backlog-buffer))
17310 (if (not (setq beg (text-property-any
17311 (point-min) (point-max) 'gnus-backlog
17313 ;; It wasn't in the backlog after all.
17315 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17316 ;; Find the end (i. e., the beginning of the next article).
17318 (next-single-property-change
17319 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17320 (let ((buffer-read-only nil))
17322 (insert-buffer-substring gnus-backlog-buffer beg end)
17325 ;; Allow redefinition of Gnus functions.
17327 (gnus-ems-redefine)
17331 ;;; gnus.el ends here