1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
38 (eval-when-compile (require 'cl))
40 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
41 "*Directory variable from which all other Gnus file variables are derived.")
43 ;; Site dependent variables. These variables should be defined in
46 (defvar gnus-default-nntp-server nil
47 "Specify a default NNTP server.
48 This variable should be defined in paths.el, and should never be set
50 If you want to change servers, you should use `gnus-select-method'.
51 See the documentation to that variable.")
53 (defvar gnus-backup-default-subscribed-newsgroups
54 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
55 "Default default new newsgroups the first time Gnus is run.
56 Should be set in paths.el, and shouldn't be touched by the user.")
58 (defvar gnus-local-domain nil
59 "Local domain name without a host name.
60 The DOMAINNAME environment variable is used instead if it is defined.
61 If the `system-name' function returns the full Internet name, there is
62 no need to set this variable.")
64 (defvar gnus-local-organization nil
65 "String with a description of what organization (if any) the user belongs to.
66 The ORGANIZATION environment variable is used instead if it is defined.
67 If this variable contains a function, this function will be called
68 with the current newsgroup name as the argument. The function should
71 In any case, if the string (either in the variable, in the environment
72 variable, or returned by the function) is a file name, the contents of
73 this file will be used as the organization.")
75 ;; Customization variables
77 ;; Don't touch this variable.
78 (defvar gnus-nntp-service "nntp"
79 "*NNTP service name (\"nntp\" or 119).
80 This is an obsolete variable, which is scarcely used. If you use an
81 nntp server for your newsgroup and want to change the port number
82 used to 899, you would say something along these lines:
84 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
86 (defvar gnus-nntpserver-file "/etc/nntpserver"
87 "*A file with only the name of the nntp server in it.")
89 ;; This function is used to check both the environment variable
90 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
91 ;; an nntp server name default.
92 (defun gnus-getenv-nntpserver ()
93 (or (getenv "NNTPSERVER")
94 (and (file-readable-p gnus-nntpserver-file)
96 (set-buffer (get-buffer-create " *gnus nntp*"))
97 (buffer-disable-undo (current-buffer))
98 (insert-file-contents gnus-nntpserver-file)
99 (let ((name (buffer-string)))
101 (if (string-match "^[ \t\n]*$" name)
104 (kill-buffer (current-buffer))))))))
106 (defvar gnus-select-method
108 (list 'nntp (or (condition-case ()
109 (gnus-getenv-nntpserver)
111 (if (and gnus-default-nntp-server
112 (not (string= gnus-default-nntp-server "")))
113 gnus-default-nntp-server)
115 (if (or (null gnus-nntp-service)
116 (equal gnus-nntp-service "nntp"))
118 (list gnus-nntp-service)))
119 "*Default method for selecting a newsgroup.
120 This variable should be a list, where the first element is how the
121 news is to be fetched, the second is the address.
123 For instance, if you want to get your news via NNTP from
124 \"flab.flab.edu\", you could say:
126 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
128 If you want to use your local spool, say:
130 (setq gnus-select-method (list 'nnspool (system-name)))
132 If you use this variable, you must set `gnus-nntp-server' to nil.
134 There is a lot more to know about select methods and virtual servers -
135 see the manual for details.")
137 (defvar gnus-message-archive-method
140 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
141 (nnfolder-active-file
142 ,(nnheader-concat message-directory "archive/active"))
143 (nnfolder-get-new-mail nil)
144 (nnfolder-inhibit-expiry t))
145 "*Method used for archiving messages you've sent.
146 This should be a mail method.
148 It's probably not a very effective to change this variable once you've
149 run Gnus once. After doing that, you must edit this server from the
152 (defvar gnus-message-archive-group nil
153 "*Name of the group in which to save the messages you've written.
154 This can either be a string, a list of strings; or an alist
155 of regexps/functions/forms to be evaluated to return a string (or a list
156 of strings). The functions are called with the name of the current
157 group (or nil) as a parameter.
159 If you want to save your mail in one group and the news articles you
160 write in another group, you could say something like:
162 \(setq gnus-message-archive-group
163 '((if (message-news-p)
167 Normally the group names returned by this variable should be
168 unprefixed -- which implictly means \"store on the archive server\".
169 However, you may wish to store the message on some other server. In
170 that case, just return a fully prefixed name of the group --
171 \"nnml+private:mail.misc\", for instance.")
173 (defvar gnus-refer-article-method nil
174 "*Preferred method for fetching an article by Message-ID.
175 If you are reading news from the local spool (with nnspool), fetching
176 articles by Message-ID is painfully slow. By setting this method to an
177 nntp method, you might get acceptable results.
179 The value of this variable must be a valid select method as discussed
180 in the documentation of `gnus-select-method'.")
182 (defvar gnus-secondary-select-methods nil
183 "*A list of secondary methods that will be used for reading news.
184 This is a list where each element is a complete select method (see
185 `gnus-select-method').
187 If, for instance, you want to read your mail with the nnml backend,
188 you could set this variable:
190 (setq gnus-secondary-select-methods '((nnml \"\")))")
192 (defvar gnus-secondary-servers nil
193 "*List of NNTP servers that the user can choose between interactively.
194 To make Gnus query you for a server, you have to give `gnus' a
195 non-numeric prefix - `C-u M-x gnus', in short.")
197 (defvar gnus-nntp-server nil
198 "*The name of the host running the NNTP server.
199 This variable is semi-obsolete. Use the `gnus-select-method'
202 (defvar gnus-startup-file "~/.newsrc"
203 "*Your `.newsrc' file.
204 `.newsrc-SERVER' will be used instead if that exists.")
206 (defvar gnus-init-file "~/.gnus"
207 "*Your Gnus elisp startup file.
208 If a file with the .el or .elc suffixes exist, it will be read
211 (defvar gnus-group-faq-directory
212 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
213 "/ftp@sunsite.auc.dk:/pub/usenet/"
214 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
215 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
216 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
217 "/ftp@rtfm.mit.edu:/pub/usenet/"
218 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
219 "/ftp@ftp.sunet.se:/pub/usenet/"
220 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
221 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
222 "/ftp@ftp.hk.super.net:/mirror/faqs/")
223 "*Directory where the group FAQs are stored.
224 This will most commonly be on a remote machine, and the file will be
227 This variable can also be a list of directories. In that case, the
228 first element in the list will be used by default. The others can
229 be used when being prompted for a site.
231 Note that Gnus uses an aol machine as the default directory. If this
232 feels fundamentally unclean, just think of it as a way to finally get
233 something of value back from them.
235 If the default site is too slow, try one of these:
237 North America: mirrors.aol.com /pub/rtfm/usenet
238 ftp.seas.gwu.edu /pub/rtfm
239 rtfm.mit.edu /pub/usenet
240 Europe: ftp.uni-paderborn.de /pub/FAQ
241 src.doc.ic.ac.uk /usenet/news-FAQS
242 ftp.sunet.se /pub/usenet
243 sunsite.auc.dk /pub/usenet
244 Asia: nctuccca.edu.tw /USENET/FAQ
245 hwarang.postech.ac.kr /pub/usenet
246 ftp.hk.super.net /mirror/faqs")
248 (defvar gnus-group-archive-directory
249 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
250 "*The address of the (ding) archives.")
252 (defvar gnus-group-recent-archive-directory
253 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
254 "*The address of the most recent (ding) articles.")
256 (defvar gnus-default-subscribed-newsgroups nil
257 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
258 It should be a list of strings.
259 If it is `t', Gnus will not do anything special the first time it is
260 started; it'll just use the normal newsgroups subscription methods.")
262 (defvar gnus-use-cross-reference t
263 "*Non-nil means that cross referenced articles will be marked as read.
264 If nil, ignore cross references. If t, mark articles as read in
265 subscribed newsgroups. If neither t nor nil, mark as read in all
268 (defvar gnus-single-article-buffer t
269 "*If non-nil, display all articles in the same buffer.
270 If nil, each group will get its own article buffer.")
272 (defvar gnus-use-dribble-file t
273 "*Non-nil means that Gnus will use a dribble file to store user updates.
274 If Emacs should crash without saving the .newsrc files, complete
275 information can be restored from the dribble file.")
277 (defvar gnus-dribble-directory nil
278 "*The directory where dribble files will be saved.
279 If this variable is nil, the directory where the .newsrc files are
280 saved will be used.")
282 (defvar gnus-asynchronous nil
283 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
285 (defvar gnus-kill-summary-on-exit t
286 "*If non-nil, kill the summary buffer when you exit from it.
287 If nil, the summary will become a \"*Dead Summary*\" buffer, and
288 it will be killed sometime later.")
290 (defvar gnus-large-newsgroup 200
291 "*The number of articles which indicates a large newsgroup.
292 If the number of articles in a newsgroup is greater than this value,
293 confirmation is required for selecting the newsgroup.")
295 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
296 (defvar gnus-no-groups-message "No news is horrible news"
297 "*Message displayed by Gnus when no groups are available.")
299 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
300 "*Non-nil means that the default name of a file to save articles in is the group name.
301 If it's nil, the directory form of the group name is used instead.
303 If this variable is a list, and the list contains the element
304 `not-score', long file names will not be used for score files; if it
305 contains the element `not-save', long file names will not be used for
306 saving; and if it contains the element `not-kill', long file names
307 will not be used for kill files.
309 Note that the default for this variable varies according to what system
310 type you're using. On `usg-unix-v' and `xenix' this variable defaults
311 to nil while on all other systems it defaults to t.")
313 (defvar gnus-article-save-directory gnus-directory
314 "*Name of the directory articles will be saved in (default \"~/News\").")
316 (defvar gnus-kill-files-directory gnus-directory
317 "*Name of the directory where kill files will be stored (default \"~/News\").")
319 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
320 "*A function to save articles in your favorite format.
321 The function must be interactively callable (in other words, it must
322 be an Emacs command).
324 Gnus provides the following functions:
326 * gnus-summary-save-in-rmail (Rmail format)
327 * gnus-summary-save-in-mail (Unix mail format)
328 * gnus-summary-save-in-folder (MH folder)
329 * gnus-summary-save-in-file (article format).
330 * gnus-summary-save-in-vm (use VM's folder format).")
332 (defvar gnus-prompt-before-saving 'always
333 "*This variable says how much prompting is to be done when saving articles.
334 If it is nil, no prompting will be done, and the articles will be
335 saved to the default files. If this variable is `always', each and
336 every article that is saved will be preceded by a prompt, even when
337 saving large batches of articles. If this variable is neither nil not
338 `always', there the user will be prompted once for a file name for
339 each invocation of the saving commands.")
341 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
342 "*A function generating a file name to save articles in Rmail format.
343 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
345 (defvar gnus-mail-save-name (function gnus-plain-save-name)
346 "*A function generating a file name to save articles in Unix mail format.
347 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
349 (defvar gnus-folder-save-name (function gnus-folder-save-name)
350 "*A function generating a file name to save articles in MH folder.
351 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
353 (defvar gnus-file-save-name (function gnus-numeric-save-name)
354 "*A function generating a file name to save articles in article format.
355 The function is called with NEWSGROUP, HEADERS, and optional
358 (defvar gnus-split-methods
359 '((gnus-article-archive-name))
360 "*Variable used to suggest where articles are to be saved.
361 For instance, if you would like to save articles related to Gnus in
362 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
363 you could set this variable to something like:
365 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
366 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
368 This variable is an alist where the where the key is the match and the
369 value is a list of possible files to save in if the match is non-nil.
371 If the match is a string, it is used as a regexp match on the
372 article. If the match is a symbol, that symbol will be funcalled
373 from the buffer of the article to be saved with the newsgroup as the
374 parameter. If it is a list, it will be evaled in the same buffer.
376 If this form or function returns a string, this string will be used as
377 a possible file name; and if it returns a non-nil list, that list will
378 be used as possible file names.")
380 (defvar gnus-move-split-methods nil
381 "*Variable used to suggest where articles are to be moved to.
382 It uses the same syntax as the `gnus-split-methods' variable.")
384 (defvar gnus-save-score nil
385 "*If non-nil, save group scoring info.")
387 (defvar gnus-use-adaptive-scoring nil
388 "*If non-nil, use some adaptive scoring scheme.")
390 (defvar gnus-use-cache 'passive
391 "*If nil, Gnus will ignore the article cache.
392 If `passive', it will allow entering (and reading) articles
393 explicitly entered into the cache. If anything else, use the
394 cache to the full extent of the law.")
396 (defvar gnus-use-trees nil
397 "*If non-nil, display a thread tree buffer.")
399 (defvar gnus-use-grouplens nil
400 "*If non-nil, use GroupLens ratings.")
402 (defvar gnus-keep-backlog nil
403 "*If non-nil, Gnus will keep read articles for later re-retrieval.
404 If it is a number N, then Gnus will only keep the last N articles
405 read. If it is neither nil nor a number, Gnus will keep all read
406 articles. This is not a good idea.")
408 (defvar gnus-use-nocem nil
409 "*If non-nil, Gnus will read NoCeM cancel messages.")
411 (defvar gnus-use-demon nil
412 "If non-nil, Gnus might use some demons.")
414 (defvar gnus-use-scoring t
415 "*If non-nil, enable scoring.")
417 (defvar gnus-use-picons nil
418 "*If non-nil, display picons.")
420 (defvar gnus-fetch-old-headers nil
421 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
422 If an unread article in the group refers to an older, already read (or
423 just marked as read) article, the old article will not normally be
424 displayed in the Summary buffer. If this variable is non-nil, Gnus
425 will attempt to grab the headers to the old articles, and thereby
426 build complete threads. If it has the value `some', only enough
427 headers to connect otherwise loose threads will be displayed.
428 This variable can also be a number. In that case, no more than that
429 number of old headers will be fetched.
431 The server has to support NOV for any of this to work.")
434 ;(defvar gnus-visual t
435 ; "*If non-nil, will do various highlighting.
436 ;If nil, no mouse highlights (or any other highlights) will be
437 ;performed. This might speed up Gnus some when generating large group
438 ;and summary buffers.")
440 (defvar gnus-novice-user t
441 "*Non-nil means that you are a usenet novice.
442 If non-nil, verbose messages may be displayed and confirmations may be
445 (defvar gnus-expert-user nil
446 "*Non-nil means that you will never be asked for confirmation about anything.
447 And that means *anything*.")
449 (defvar gnus-verbose 7
450 "*Integer that says how verbose Gnus should be.
451 The higher the number, the more messages Gnus will flash to say what
452 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
453 display most important messages; and at ten, Gnus will keep on
454 jabbering all the time.")
456 (defvar gnus-keep-same-level nil
457 "*Non-nil means that the next newsgroup after the current will be on the same level.
458 When you type, for instance, `n' after reading the last article in the
459 current newsgroup, you will go to the next newsgroup. If this variable
460 is nil, the next newsgroup will be the next from the group
462 If this variable is non-nil, Gnus will either put you in the
463 next newsgroup with the same level, or, if no such newsgroup is
464 available, the next newsgroup with the lowest possible level higher
465 than the current level.
466 If this variable is `best', Gnus will make the next newsgroup the one
467 with the best level.")
469 (defvar gnus-summary-make-false-root 'adopt
470 "*nil means that Gnus won't gather loose threads.
471 If the root of a thread has expired or been read in a previous
472 session, the information necessary to build a complete thread has been
473 lost. Instead of having many small sub-threads from this original thread
474 scattered all over the summary buffer, Gnus can gather them.
476 If non-nil, Gnus will try to gather all loose sub-threads from an
477 original thread into one large thread.
479 If this variable is non-nil, it should be one of `none', `adopt',
482 If this variable is `none', Gnus will not make a false root, but just
483 present the sub-threads after another.
484 If this variable is `dummy', Gnus will create a dummy root that will
485 have all the sub-threads as children.
486 If this variable is `adopt', Gnus will make one of the \"children\"
487 the parent and mark all the step-children as such.
488 If this variable is `empty', the \"children\" are printed with empty
489 subject fields. (Or rather, they will be printed with a string
490 given by the `gnus-summary-same-subject' variable.)")
492 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
493 "*A regexp to match subjects to be excluded from loose thread gathering.
494 As loose thread gathering is done on subjects only, that means that
495 there can be many false gatherings performed. By rooting out certain
496 common subjects, gathering might become saner.")
498 (defvar gnus-summary-gather-subject-limit nil
499 "*Maximum length of subject comparisons when gathering loose threads.
500 Use nil to compare full subjects. Setting this variable to a low
501 number will help gather threads that have been corrupted by
502 newsreaders chopping off subject lines, but it might also mean that
503 unrelated articles that have subject that happen to begin with the
504 same few characters will be incorrectly gathered.
506 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
507 comparing subjects.")
509 (defvar gnus-simplify-ignored-prefixes nil
510 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily.")
512 (defvar gnus-build-sparse-threads nil
513 "*If non-nil, fill in the gaps in threads.
514 If `some', only fill in the gaps that are needed to tie loose threads
515 together. If `more', fill in all leaf nodes that Gnus can find. If
516 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
518 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
519 "Function used for gathering loose threads.
520 There are two pre-defined functions: `gnus-gather-threads-by-subject',
521 which only takes Subjects into consideration; and
522 `gnus-gather-threads-by-references', which compared the References
523 headers of the articles to find matches.")
525 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
526 (defvar gnus-summary-same-subject ""
527 "*String indicating that the current article has the same subject as the previous.
528 This variable will only be used if the value of
529 `gnus-summary-make-false-root' is `empty'.")
531 (defvar gnus-summary-goto-unread t
532 "*If non-nil, marking commands will go to the next unread article.
533 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
534 whether it is read or not.")
536 (defvar gnus-group-goto-unread t
537 "*If non-nil, movement commands will go to the next unread and subscribed group.")
539 (defvar gnus-goto-next-group-when-activating t
540 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
542 (defvar gnus-check-new-newsgroups t
543 "*Non-nil means that Gnus will add new newsgroups at startup.
544 If this variable is `ask-server', Gnus will ask the server for new
545 groups since the last time it checked. This means that the killed list
546 is no longer necessary, so you could set `gnus-save-killed-list' to
549 A variant is to have this variable be a list of select methods. Gnus
550 will then use the `ask-server' method on all these select methods to
551 query for new groups from all those servers.
554 (setq gnus-check-new-newsgroups
555 '((nntp \"some.server\") (nntp \"other.server\")))
557 If this variable is nil, then you have to tell Gnus explicitly to
558 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
560 (defvar gnus-check-bogus-newsgroups nil
561 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
562 If this variable is nil, then you have to tell Gnus explicitly to
563 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
565 (defvar gnus-read-active-file t
566 "*Non-nil means that Gnus will read the entire active file at startup.
567 If this variable is nil, Gnus will only know about the groups in your
570 If this variable is `some', Gnus will try to only read the relevant
571 parts of the active file from the server. Not all servers support
572 this, and it might be quite slow with other servers, but this should
573 generally be faster than both the t and nil value.
575 If you set this variable to nil or `some', you probably still want to
576 be told about new newsgroups that arrive. To do that, set
577 `gnus-check-new-newsgroups' to `ask-server'. This may not work
578 properly with all servers.")
580 (defvar gnus-level-subscribed 5
581 "*Groups with levels less than or equal to this variable are subscribed.")
583 (defvar gnus-level-unsubscribed 7
584 "*Groups with levels less than or equal to this variable are unsubscribed.
585 Groups with levels less than `gnus-level-subscribed', which should be
586 less than this variable, are subscribed.")
588 (defvar gnus-level-zombie 8
589 "*Groups with this level are zombie groups.")
591 (defvar gnus-level-killed 9
592 "*Groups with this level are killed.")
594 (defvar gnus-level-default-subscribed 3
595 "*New subscribed groups will be subscribed at this level.")
597 (defvar gnus-level-default-unsubscribed 6
598 "*New unsubscribed groups will be unsubscribed at this level.")
600 (defvar gnus-activate-level (1+ gnus-level-subscribed)
601 "*Groups higher than this level won't be activated on startup.
602 Setting this variable to something log might save lots of time when
603 you have many groups that you aren't interested in.")
605 (defvar gnus-activate-foreign-newsgroups 4
606 "*If nil, Gnus will not check foreign newsgroups at startup.
607 If it is non-nil, it should be a number between one and nine. Foreign
608 newsgroups that have a level lower or equal to this number will be
609 activated on startup. For instance, if you want to active all
610 subscribed newsgroups, but not the rest, you'd set this variable to
611 `gnus-level-subscribed'.
613 If you subscribe to lots of newsgroups from different servers, startup
614 might take a while. By setting this variable to nil, you'll save time,
615 but you won't be told how many unread articles there are in the
618 (defvar gnus-save-newsrc-file t
619 "*Non-nil means that Gnus will save the `.newsrc' file.
620 Gnus always saves its own startup file, which is called
621 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
622 be readily understood by other newsreaders. If you don't plan on
623 using other newsreaders, set this variable to nil to save some time on
626 (defvar gnus-save-killed-list t
627 "*If non-nil, save the list of killed groups to the startup file.
628 If you set this variable to nil, you'll save both time (when starting
629 and quitting) and space (both memory and disk), but it will also mean
630 that Gnus has no record of which groups are new and which are old, so
631 the automatic new newsgroups subscription methods become meaningless.
633 You should always set `gnus-check-new-newsgroups' to `ask-server' or
634 nil if you set this variable to nil.")
636 (defvar gnus-interactive-catchup t
637 "*If non-nil, require your confirmation when catching up a group.")
639 (defvar gnus-interactive-exit t
640 "*If non-nil, require your confirmation when exiting Gnus.")
642 (defvar gnus-kill-killed t
643 "*If non-nil, Gnus will apply kill files to already killed articles.
644 If it is nil, Gnus will never apply kill files to articles that have
645 already been through the scoring process, which might very well save lots
648 (defvar gnus-extract-address-components 'gnus-extract-address-components
649 "*Function for extracting address components from a From header.
650 Two pre-defined function exist: `gnus-extract-address-components',
651 which is the default, quite fast, and too simplistic solution, and
652 `mail-extract-address-components', which works much better, but is
655 (defvar gnus-summary-default-score 0
656 "*Default article score level.
657 If this variable is nil, scoring will be disabled.")
659 (defvar gnus-summary-zcore-fuzz 0
660 "*Fuzziness factor for the zcore in the summary buffer.
661 Articles with scores closer than this to `gnus-summary-default-score'
662 will not be marked.")
664 (defvar gnus-simplify-subject-fuzzy-regexp nil
665 "*Strings to be removed when doing fuzzy matches.
666 This can either be a regular expression or list of regular expressions
667 that will be removed from subject strings if fuzzy subject
668 simplification is selected.")
670 (defvar gnus-permanently-visible-groups nil
671 "*Regexp to match groups that should always be listed in the group buffer.
672 This means that they will still be listed when there are no unread
673 articles in the groups.")
675 (defvar gnus-list-groups-with-ticked-articles t
676 "*If non-nil, list groups that have only ticked articles.
677 If nil, only list groups that have unread articles.")
679 (defvar gnus-group-default-list-level gnus-level-subscribed
680 "*Default listing level.
681 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
683 (defvar gnus-group-use-permanent-levels nil
684 "*If non-nil, once you set a level, Gnus will use this level.")
686 (defvar gnus-group-list-inactive-groups t
687 "*If non-nil, inactive groups will be listed.")
689 (defvar gnus-show-mime nil
690 "*If non-nil, do mime processing of articles.
691 The articles will simply be fed to the function given by
692 `gnus-show-mime-method'.")
694 (defvar gnus-strict-mime t
695 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
697 (defvar gnus-show-mime-method 'metamail-buffer
698 "*Function to process a MIME message.
699 The function is called from the article buffer.")
701 (defvar gnus-decode-encoded-word-method (lambda ())
702 "*Function to decode a MIME encoded-words.
703 The function is called from the article buffer.")
705 (defvar gnus-show-threads t
706 "*If non-nil, display threads in summary mode.")
708 (defvar gnus-thread-hide-subtree nil
709 "*If non-nil, hide all threads initially.
710 If threads are hidden, you have to run the command
711 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
712 to expose hidden threads.")
714 (defvar gnus-thread-hide-killed t
715 "*If non-nil, hide killed threads automatically.")
717 (defvar gnus-thread-ignore-subject nil
718 "*If non-nil, ignore subjects and do all threading based on the Reference header.
719 If nil, which is the default, articles that have different subjects
720 from their parents will start separate threads.")
722 (defvar gnus-thread-operation-ignore-subject t
723 "*If non-nil, subjects will be ignored when doing thread commands.
724 This affects commands like `gnus-summary-kill-thread' and
725 `gnus-summary-lower-thread'.
727 If this variable is nil, articles in the same thread with different
728 subjects will not be included in the operation in question. If this
729 variable is `fuzzy', only articles that have subjects that are fuzzily
730 equal will be included.")
732 (defvar gnus-thread-indent-level 4
733 "*Number that says how much each sub-thread should be indented.")
735 (defvar gnus-ignored-newsgroups
736 (purecopy (mapconcat 'identity
737 '("^to\\." ; not "real" groups
738 "^[0-9. \t]+ " ; all digits in name
739 "[][\"#'()]" ; bogus characters
742 "*A regexp to match uninteresting newsgroups in the active file.
743 Any lines in the active file matching this regular expression are
744 removed from the newsgroup list before anything else is done to it,
745 thus making them effectively non-existent.")
747 (defvar gnus-ignored-headers
748 "^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:"
749 "*All headers that match this regexp will be hidden.
750 This variable can also be a list of regexps of headers to be ignored.
751 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
753 (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-"
754 "*All headers that do not match this regexp will be hidden.
755 This variable can also be a list of regexp of headers to remain visible.
756 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
758 (defvar gnus-sorted-header-list
759 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
760 "^Cc:" "^Date:" "^Organization:")
761 "*This variable is a list of regular expressions.
762 If it is non-nil, headers that match the regular expressions will
763 be placed first in the article buffer in the sequence specified by
766 (defvar gnus-boring-article-headers
767 '(empty followup-to reply-to)
768 "*Headers that are only to be displayed if they have interesting data.
769 Possible values in this list are `empty', `newsgroups', `followup-to',
770 `reply-to', and `date'.")
772 (defvar gnus-show-all-headers nil
773 "*If non-nil, don't hide any headers.")
775 (defvar gnus-save-all-headers t
776 "*If non-nil, don't remove any headers before saving.")
778 (defvar gnus-saved-headers gnus-visible-headers
779 "*Headers to keep if `gnus-save-all-headers' is nil.
780 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
781 If that variable is nil, however, all headers that match this regexp
782 will be kept while the rest will be deleted before saving.")
784 (defvar gnus-inhibit-startup-message nil
785 "*If non-nil, the startup message will not be displayed.")
787 (defvar gnus-signature-separator "^-- *$"
788 "Regexp matching signature separator.")
790 (defvar gnus-signature-limit nil
791 "Provide a limit to what is considered a signature.
792 If it is a number, no signature may not be longer (in characters) than
793 that number. If it is a function, the function will be called without
794 any parameters, and if it returns nil, there is no signature in the
795 buffer. If it is a string, it will be used as a regexp. If it
796 matches, the text in question is not a signature.")
798 (defvar gnus-auto-extend-newsgroup t
799 "*If non-nil, extend newsgroup forward and backward when requested.")
801 (defvar gnus-auto-select-first t
802 "*If nil, don't select the first unread article when entering a group.
803 If this variable is `best', select the highest-scored unread article
804 in the group. If neither nil nor `best', select the first unread
807 If you want to prevent automatic selection of the first unread article
808 in some newsgroups, set the variable to nil in
809 `gnus-select-group-hook'.")
811 (defvar gnus-auto-select-next t
812 "*If non-nil, offer to go to the next group from the end of the previous.
813 If the value is t and the next newsgroup is empty, Gnus will exit
814 summary mode and go back to group mode. If the value is neither nil
815 nor t, Gnus will select the following unread newsgroup. In
816 particular, if the value is the symbol `quietly', the next unread
817 newsgroup will be selected without any confirmation, and if it is
818 `almost-quietly', the next group will be selected without any
819 confirmation if you are located on the last article in the group.
820 Finally, if this variable is `slightly-quietly', the `Z n' command
821 will go to the next group without confirmation.")
823 (defvar gnus-auto-select-same nil
824 "*If non-nil, select the next article with the same subject.")
826 (defvar gnus-summary-check-current nil
827 "*If non-nil, consider the current article when moving.
828 The \"unread\" movement commands will stay on the same line if the
829 current article is unread.")
831 (defvar gnus-auto-center-summary t
832 "*If non-nil, always center the current summary buffer.
833 In particular, if `vertical' do only vertical recentering. If non-nil
834 and non-`vertical', do both horizontal and vertical recentering.")
836 (defvar gnus-break-pages t
837 "*If non-nil, do page breaking on articles.
838 The page delimiter is specified by the `gnus-page-delimiter'
841 (defvar gnus-page-delimiter "^\^L"
842 "*Regexp describing what to use as article page delimiters.
843 The default value is \"^\^L\", which is a form linefeed at the
844 beginning of a line.")
846 (defvar gnus-use-full-window t
847 "*If non-nil, use the entire Emacs screen.")
849 (defvar gnus-window-configuration nil
850 "Obsolete variable. See `gnus-buffer-configuration'.")
852 (defvar gnus-window-min-width 2
853 "*Minimum width of Gnus buffers.")
855 (defvar gnus-window-min-height 1
856 "*Minimum height of Gnus buffers.")
858 (defvar gnus-buffer-configuration
862 (if gnus-carpal '(group-carpal 4))))
866 (if gnus-carpal '(summary-carpal 4))))
873 (if gnus-carpal '(summary-carpal 4))
875 (vertical ((height . 5) (width . 15)
877 (left . -1) (top . 1))
887 (if gnus-carpal '(summary-carpal 4))
892 (if gnus-carpal '(server-carpal 2))))
896 (if gnus-carpal '(browse-carpal 2))))
899 (message 1.0 point)))
902 (article 1.0 point)))
913 (edit-group 1.0 point)))
917 (edit-server 1.0 point)))
921 (edit-score 1.0 point)))
928 (message 1.0 point)))
931 (message 1.0 point)))
934 (message 1.0 point)))
938 (message 1.0 point)))
945 (if gnus-carpal '(summary-carpal 4))
946 ("*Shell Command Output*" 1.0)))
949 ("*Gnus Help Bug*" 0.5)
950 ("*Gnus Bug*" 1.0 point)))
954 (message 1.0 point))))
955 "Window configuration for all possible Gnus buffers.
956 This variable is a list of lists. Each of these lists has a NAME and
957 a RULE. The NAMEs are commonsense names like `group', which names a
958 rule used when displaying the group buffer; `summary', which names a
959 rule for what happens when you enter a group and do not display an
960 article buffer; and so on. See the value of this variable for a
961 complete list of NAMEs.
963 Each RULE is a list of vectors. The first element in this vector is
964 the name of the buffer to be displayed; the second element is the
965 percentage of the screen this buffer is to occupy (a number in the
966 0.0-0.99 range); the optional third element is `point', which should
967 be present to denote which buffer point is to go to after making this
968 buffer configuration.")
970 (defvar gnus-window-to-buffer
971 '((group . gnus-group-buffer)
972 (summary . gnus-summary-buffer)
973 (article . gnus-article-buffer)
974 (server . gnus-server-buffer)
975 (browse . "*Gnus Browse Server*")
976 (edit-group . gnus-group-edit-buffer)
977 (edit-server . gnus-server-edit-buffer)
978 (group-carpal . gnus-carpal-group-buffer)
979 (summary-carpal . gnus-carpal-summary-buffer)
980 (server-carpal . gnus-carpal-server-buffer)
981 (browse-carpal . gnus-carpal-browse-buffer)
982 (edit-score . gnus-score-edit-buffer)
983 (message . gnus-message-buffer)
984 (mail . gnus-message-buffer)
985 (post-news . gnus-message-buffer)
986 (faq . gnus-faq-buffer)
987 (picons . "*Picons*")
988 (tree . gnus-tree-buffer)
989 (info . gnus-info-buffer)
990 (article-copy . gnus-article-copy)
991 (draft . gnus-draft-buffer))
992 "Mapping from short symbols to buffer names or buffer variables.")
994 (defvar gnus-carpal nil
995 "*If non-nil, display clickable icons.")
997 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
998 "*Function called with a group name when new group is detected.
999 A few pre-made functions are supplied: `gnus-subscribe-randomly'
1000 inserts new groups at the beginning of the list of groups;
1001 `gnus-subscribe-alphabetically' inserts new groups in strict
1002 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
1003 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
1004 for your decision; `gnus-subscribe-killed' kills all new groups;
1005 `gnus-subscribe-zombies' will make all new groups into zombies.")
1007 ;; Suggested by a bug report by Hallvard B Furuseth.
1008 ;; <h.b.furuseth@usit.uio.no>.
1009 (defvar gnus-subscribe-options-newsgroup-method
1010 (function gnus-subscribe-alphabetically)
1011 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
1012 If, for instance, you want to subscribe to all newsgroups in the
1013 \"no\" and \"alt\" hierarchies, you'd put the following in your
1016 options -n no.all alt.all
1018 Gnus will the subscribe all new newsgroups in these hierarchies with
1019 the subscription method in this variable.")
1021 (defvar gnus-subscribe-hierarchical-interactive nil
1022 "*If non-nil, Gnus will offer to subscribe hierarchically.
1023 When a new hierarchy appears, Gnus will ask the user:
1025 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1027 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1028 subscribe to all newsgroups in the hierarchy and `s' will skip this
1029 hierarchy in its entirety.")
1031 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1032 "*Function used for sorting the group buffer.
1033 This function will be called with group info entries as the arguments
1034 for the groups to be sorted. Pre-made functions include
1035 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1036 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1037 `gnus-group-sort-by-rank'.
1039 This variable can also be a list of sorting functions. In that case,
1040 the most significant sort function should be the last function in the
1043 ;; Mark variables suggested by Thomas Michanek
1044 ;; <Thomas.Michanek@telelogic.se>.
1045 (defvar gnus-unread-mark ?
1046 "*Mark used for unread articles.")
1047 (defvar gnus-ticked-mark ?!
1048 "*Mark used for ticked articles.")
1049 (defvar gnus-dormant-mark ??
1050 "*Mark used for dormant articles.")
1051 (defvar gnus-del-mark ?r
1052 "*Mark used for del'd articles.")
1053 (defvar gnus-read-mark ?R
1054 "*Mark used for read articles.")
1055 (defvar gnus-expirable-mark ?E
1056 "*Mark used for expirable articles.")
1057 (defvar gnus-killed-mark ?K
1058 "*Mark used for killed articles.")
1059 (defvar gnus-souped-mark ?F
1060 "*Mark used for killed articles.")
1061 (defvar gnus-kill-file-mark ?X
1062 "*Mark used for articles killed by kill files.")
1063 (defvar gnus-low-score-mark ?Y
1064 "*Mark used for articles with a low score.")
1065 (defvar gnus-catchup-mark ?C
1066 "*Mark used for articles that are caught up.")
1067 (defvar gnus-replied-mark ?A
1068 "*Mark used for articles that have been replied to.")
1069 (defvar gnus-cached-mark ?*
1070 "*Mark used for articles that are in the cache.")
1071 (defvar gnus-saved-mark ?S
1072 "*Mark used for articles that have been saved to.")
1073 (defvar gnus-process-mark ?#
1075 (defvar gnus-ancient-mark ?O
1076 "*Mark used for ancient articles.")
1077 (defvar gnus-sparse-mark ?Q
1078 "*Mark used for sparsely reffed articles.")
1079 (defvar gnus-canceled-mark ?G
1080 "*Mark used for canceled articles.")
1081 (defvar gnus-score-over-mark ?+
1082 "*Score mark used for articles with high scores.")
1083 (defvar gnus-score-below-mark ?-
1084 "*Score mark used for articles with low scores.")
1085 (defvar gnus-empty-thread-mark ?
1086 "*There is no thread under the article.")
1087 (defvar gnus-not-empty-thread-mark ?=
1088 "*There is a thread under the article.")
1090 (defvar gnus-view-pseudo-asynchronously nil
1091 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1093 (defvar gnus-view-pseudos nil
1094 "*If `automatic', pseudo-articles will be viewed automatically.
1095 If `not-confirm', pseudos will be viewed automatically, and the user
1096 will not be asked to confirm the command.")
1098 (defvar gnus-view-pseudos-separately t
1099 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1100 If nil, all files that use the same viewing command will be given as a
1101 list of parameters to that command.")
1103 (defvar gnus-insert-pseudo-articles t
1104 "*If non-nil, insert pseudo-articles when decoding articles.")
1106 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1107 "*Format of group lines.
1108 It works along the same lines as a normal formatting string,
1109 with some simple extensions.
1111 %M Only marked articles (character, \"*\" or \" \")
1112 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1113 %L Level of subscribedness (integer)
1114 %N Number of unread articles (integer)
1115 %I Number of dormant articles (integer)
1116 %i Number of ticked and dormant (integer)
1117 %T Number of ticked articles (integer)
1118 %R Number of read articles (integer)
1119 %t Total number of articles (integer)
1120 %y Number of unread, unticked articles (integer)
1121 %G Group name (string)
1122 %g Qualified group name (string)
1123 %D Group description (string)
1124 %s Select method (string)
1125 %o Moderated group (char, \"m\")
1126 %p Process mark (char)
1127 %O Moderated group (string, \"(m)\" or \"\")
1128 %P Topic indentation (string)
1129 %l Whether there are GroupLens predictions for this group (string)
1130 %n Select from where (string)
1131 %z A string that look like `<%s:%n>' if a foreign select method is used
1132 %u User defined specifier. The next character in the format string should
1133 be a letter. Gnus will call the function gnus-user-format-function-X,
1134 where X is the letter following %u. The function will be passed the
1135 current header as argument. The function should return a string, which
1136 will be inserted into the buffer just like information from any other
1139 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1140 the mouse point move inside the area. There can only be one such area.
1142 Note that this format specification is not always respected. For
1143 reasons of efficiency, when listing killed groups, this specification
1144 is ignored altogether. If the spec is changed considerably, your
1145 output may end up looking strange when listing both alive and killed
1148 If you use %o or %O, reading the active file will be slower and quite
1149 a bit of extra memory will be used. %D will also worsen performance.
1150 Also note that if you change the format specification to include any
1151 of these specs, you must probably re-start Gnus to see them go into
1154 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1155 "*The format specification of the lines in the summary buffer.
1157 It works along the same lines as a normal formatting string,
1158 with some simple extensions.
1160 %N Article number, left padded with spaces (string)
1162 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1163 %n Name of the poster (string)
1164 %a Extracted name of the poster (string)
1165 %A Extracted address of the poster (string)
1166 %F Contents of the From: header (string)
1167 %x Contents of the Xref: header (string)
1168 %D Date of the article (string)
1169 %d Date of the article (string) in DD-MMM format
1170 %M Message-id of the article (string)
1171 %r References of the article (string)
1172 %c Number of characters in the article (integer)
1173 %L Number of lines in the article (integer)
1174 %I Indentation based on thread level (a string of spaces)
1175 %T A string with two possible values: 80 spaces if the article
1176 is on thread level two or larger and 0 spaces on level one
1177 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1178 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1179 %[ Opening bracket (character, \"[\" or \"<\")
1180 %] Closing bracket (character, \"]\" or \">\")
1181 %> Spaces of length thread-level (string)
1182 %< Spaces of length (- 20 thread-level) (string)
1183 %i Article score (number)
1184 %z Article zcore (character)
1185 %t Number of articles under the current thread (number).
1186 %e Whether the thread is empty or not (character).
1187 %l GroupLens score (string).
1188 %u User defined specifier. The next character in the format string should
1189 be a letter. Gnus will call the function gnus-user-format-function-X,
1190 where X is the letter following %u. The function will be passed the
1191 current header as argument. The function should return a string, which
1192 will be inserted into the summary just like information from any other
1195 Text between %( and %) will be highlighted with `gnus-mouse-face'
1196 when the mouse point is placed inside the area. There can only be one
1199 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1200 with care. For reasons of efficiency, Gnus will compute what column
1201 these characters will end up in, and \"hard-code\" that. This means that
1202 it is illegal to have these specs after a variable-length spec. Well,
1203 you might not be arrested, but your summary buffer will look strange,
1204 which is bad enough.
1206 The smart choice is to have these specs as for to the left as
1209 This restriction may disappear in later versions of Gnus.")
1211 (defvar gnus-summary-dummy-line-format
1213 "*The format specification for the dummy roots in the summary buffer.
1214 It works along the same lines as a normal formatting string,
1215 with some simple extensions.
1219 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1220 "*The format specification for the summary mode line.
1221 It works along the same lines as a normal formatting string,
1222 with some simple extensions:
1225 %p Unprefixed group name
1226 %A Current article number
1228 %U Number of unread articles in the group
1229 %e Number of unselected articles in the group
1230 %Z A string with unread/unselected article counts
1231 %g Shortish group name
1232 %S Subject of the current article
1233 %u User-defined spec
1234 %s Current score file name
1235 %d Number of dormant articles
1236 %r Number of articles that have been marked as read in this session
1237 %E Number of articles expunged by the score files")
1239 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1240 "*The format specification for the article mode line.
1241 See `gnus-summary-mode-line-format' for a closer description.")
1243 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1244 "*The format specification for the group mode line.
1245 It works along the same lines as a normal formatting string,
1246 with some simple extensions:
1248 %S The native news server.
1249 %M The native select method.
1250 %: \":\" if %S isn't \"\".")
1252 (defvar gnus-valid-select-methods
1253 '(("nntp" post address prompt-address)
1254 ("nnspool" post address)
1255 ("nnvirtual" post-mail virtual prompt-address)
1256 ("nnmbox" mail respool address)
1257 ("nnml" mail respool address)
1258 ("nnmh" mail respool address)
1259 ("nndir" post-mail prompt-address address)
1260 ("nneething" none address prompt-address)
1261 ("nndoc" none address prompt-address)
1262 ("nnbabyl" mail address respool)
1263 ("nnkiboze" post virtual)
1264 ("nnsoup" post-mail address)
1265 ("nndraft" post-mail)
1266 ("nnfolder" mail respool address))
1267 "An alist of valid select methods.
1268 The first element of each list lists should be a string with the name
1269 of the select method. The other elements may be be the category of
1270 this method (ie. `post', `mail', `none' or whatever) or other
1271 properties that this method has (like being respoolable).
1272 If you implement a new select method, all you should have to change is
1273 this variable. I think.")
1275 (defvar gnus-updated-mode-lines '(group article summary tree)
1276 "*List of buffers that should update their mode lines.
1277 The list may contain the symbols `group', `article' and `summary'. If
1278 the corresponding symbol is present, Gnus will keep that mode line
1279 updated with information that may be pertinent.
1280 If this variable is nil, screen refresh may be quicker.")
1282 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1283 (defvar gnus-mode-non-string-length nil
1284 "*Max length of mode-line non-string contents.
1285 If this is nil, Gnus will take space as is needed, leaving the rest
1286 of the modeline intact.")
1289 ;(defvar gnus-mouse-face 'highlight
1290 ; "*Face used for mouse highlighting in Gnus.
1291 ;No mouse highlights will be done if `gnus-visual' is nil.")
1293 (defvar gnus-summary-mark-below 0
1294 "*Mark all articles with a score below this variable as read.
1295 This variable is local to each summary buffer and usually set by the
1298 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1299 "*List of functions used for sorting articles in the summary buffer.
1300 This variable is only used when not using a threaded display.")
1302 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1303 "*List of functions used for sorting threads in the summary buffer.
1304 By default, threads are sorted by article number.
1306 Each function takes two threads and return non-nil if the first thread
1307 should be sorted before the other. If you use more than one function,
1308 the primary sort function should be the last. You should probably
1309 always include `gnus-thread-sort-by-number' in the list of sorting
1310 functions -- preferably first.
1312 Ready-mady functions include `gnus-thread-sort-by-number',
1313 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1314 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1315 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1317 (defvar gnus-thread-score-function '+
1318 "*Function used for calculating the total score of a thread.
1320 The function is called with the scores of the article and each
1321 subthread and should then return the score of the thread.
1323 Some functions you can use are `+', `max', or `min'.")
1325 (defvar gnus-summary-expunge-below nil
1326 "All articles that have a score less than this variable will be expunged.")
1328 (defvar gnus-thread-expunge-below nil
1329 "All threads that have a total score less than this variable will be expunged.
1330 See `gnus-thread-score-function' for en explanation of what a
1331 \"thread score\" is.")
1333 (defvar gnus-auto-subscribed-groups
1334 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1335 "*All new groups that match this regexp will be subscribed automatically.
1336 Note that this variable only deals with new groups. It has no effect
1337 whatsoever on old groups.
1339 New groups that match this regexp will not be handled by
1340 `gnus-subscribe-newsgroup-method'. Instead, they will
1341 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1343 (defvar gnus-options-subscribe nil
1344 "*All new groups matching this regexp will be subscribed unconditionally.
1345 Note that this variable deals only with new newsgroups. This variable
1346 does not affect old newsgroups.
1348 New groups that match this regexp will not be handled by
1349 `gnus-subscribe-newsgroup-method'. Instead, they will
1350 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1352 (defvar gnus-options-not-subscribe nil
1353 "*All new groups matching this regexp will be ignored.
1354 Note that this variable deals only with new newsgroups. This variable
1355 does not affect old (already subscribed) newsgroups.")
1357 (defvar gnus-auto-expirable-newsgroups nil
1358 "*Groups in which to automatically mark read articles as expirable.
1359 If non-nil, this should be a regexp that should match all groups in
1360 which to perform auto-expiry. This only makes sense for mail groups.")
1362 (defvar gnus-total-expirable-newsgroups nil
1363 "*Groups in which to perform expiry of all read articles.
1364 Use with extreme caution. All groups that match this regexp will be
1365 expiring - which means that all read articles will be deleted after
1366 (say) one week. (This only goes for mail groups and the like, of
1369 (defvar gnus-group-uncollapsed-levels 1
1370 "Number of group name elements to leave alone when making a short group name.")
1372 (defvar gnus-hidden-properties '(invisible t intangible t)
1373 "Property list to use for hiding text.")
1375 (defvar gnus-modtime-botch nil
1376 "*Non-nil means .newsrc should be deleted prior to save.
1377 Its use is due to the bogus appearance that .newsrc was modified on
1382 (defvar gnus-group-mode-hook nil
1383 "*A hook for Gnus group mode.")
1385 (defvar gnus-summary-mode-hook nil
1386 "*A hook for Gnus summary mode.
1387 This hook is run before any variables are set in the summary buffer.")
1389 (defvar gnus-article-mode-hook nil
1390 "*A hook for Gnus article mode.")
1392 (defvar gnus-summary-prepare-exit-hook nil
1393 "*A hook called when preparing to exit from the summary buffer.
1394 It calls `gnus-summary-expire-articles' by default.")
1395 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1397 (defvar gnus-summary-exit-hook nil
1398 "*A hook called on exit from the summary buffer.")
1400 (defvar gnus-check-bogus-groups-hook nil
1401 "A hook run after removing bogus groups.")
1403 (defvar gnus-group-catchup-group-hook nil
1404 "*A hook run when catching up a group from the group buffer.")
1406 (defvar gnus-group-update-group-hook nil
1407 "*A hook called when updating group lines.")
1409 (defvar gnus-open-server-hook nil
1410 "*A hook called just before opening connection to the news server.")
1412 (defvar gnus-load-hook nil
1413 "*A hook run while Gnus is loaded.")
1415 (defvar gnus-startup-hook nil
1416 "*A hook called at startup.
1417 This hook is called after Gnus is connected to the NNTP server.")
1419 (defvar gnus-get-new-news-hook nil
1420 "*A hook run just before Gnus checks for new news.")
1422 (defvar gnus-after-getting-new-news-hook nil
1423 "*A hook run after Gnus checks for new news.")
1425 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1426 "*A function that is called to generate the group buffer.
1427 The function is called with three arguments: The first is a number;
1428 all group with a level less or equal to that number should be listed,
1429 if the second is non-nil, empty groups should also be displayed. If
1430 the third is non-nil, it is a number. No groups with a level lower
1431 than this number should be displayed.
1433 The only current function implemented is `gnus-group-prepare-flat'.")
1435 (defvar gnus-group-prepare-hook nil
1436 "*A hook called after the group buffer has been generated.
1437 If you want to modify the group buffer, you can use this hook.")
1439 (defvar gnus-summary-prepare-hook nil
1440 "*A hook called after the summary buffer has been generated.
1441 If you want to modify the summary buffer, you can use this hook.")
1443 (defvar gnus-summary-generate-hook nil
1444 "*A hook run just before generating the summary buffer.
1445 This hook is commonly used to customize threading variables and the
1448 (defvar gnus-article-prepare-hook nil
1449 "*A hook called after an article has been prepared in the article buffer.
1450 If you want to run a special decoding program like nkf, use this hook.")
1452 ;(defvar gnus-article-display-hook nil
1453 ; "*A hook called after the article is displayed in the article buffer.
1454 ;The hook is designed to change the contents of the article
1455 ;buffer. Typical functions that this hook may contain are
1456 ;`gnus-article-hide-headers' (hide selected headers),
1457 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1458 ;`gnus-article-hide-signature' (hide signature) and
1459 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1460 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1461 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1462 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1464 (defvar gnus-article-x-face-too-ugly nil
1465 "Regexp matching posters whose face shouldn't be shown automatically.")
1467 (defvar gnus-select-group-hook nil
1468 "*A hook called when a newsgroup is selected.
1470 If you'd like to simplify subjects like the
1471 `gnus-summary-next-same-subject' command does, you can use the
1474 (setq gnus-select-group-hook
1477 (mapcar (lambda (header)
1478 (mail-header-set-subject
1480 (gnus-simplify-subject
1481 (mail-header-subject header) 're-only)))
1482 gnus-newsgroup-headers))))")
1484 (defvar gnus-select-article-hook nil
1485 "*A hook called when an article is selected.")
1487 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1488 "*A hook called to apply kill files to a group.
1489 This hook is intended to apply a kill file to the selected newsgroup.
1490 The function `gnus-apply-kill-file' is called by default.
1492 Since a general kill file is too heavy to use only for a few
1493 newsgroups, I recommend you to use a lighter hook function. For
1494 example, if you'd like to apply a kill file to articles which contains
1495 a string `rmgroup' in subject in newsgroup `control', you can use the
1498 (setq gnus-apply-kill-hook
1501 (cond ((string-match \"control\" gnus-newsgroup-name)
1502 (gnus-kill \"Subject\" \"rmgroup\")
1503 (gnus-expunge \"X\"))))))")
1505 (defvar gnus-visual-mark-article-hook
1506 (list 'gnus-highlight-selected-summary)
1507 "*Hook run after selecting an article in the summary buffer.
1508 It is meant to be used for highlighting the article in some way. It
1509 is not run if `gnus-visual' is nil.")
1511 (defvar gnus-parse-headers-hook nil
1512 "*A hook called before parsing the headers.")
1513 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1515 (defvar gnus-exit-group-hook nil
1516 "*A hook called when exiting (not quitting) summary mode.")
1518 (defvar gnus-suspend-gnus-hook nil
1519 "*A hook called when suspending (not exiting) Gnus.")
1521 (defvar gnus-exit-gnus-hook nil
1522 "*A hook called when exiting Gnus.")
1524 (defvar gnus-after-exiting-gnus-hook nil
1525 "*A hook called after exiting Gnus.")
1527 (defvar gnus-save-newsrc-hook nil
1528 "*A hook called before saving any of the newsrc files.")
1530 (defvar gnus-save-quick-newsrc-hook nil
1531 "*A hook called just before saving the quick newsrc file.
1532 Can be used to turn version control on or off.")
1534 (defvar gnus-save-standard-newsrc-hook nil
1535 "*A hook called just before saving the standard newsrc file.
1536 Can be used to turn version control on or off.")
1538 (defvar gnus-summary-update-hook
1539 (list 'gnus-summary-highlight-line)
1540 "*A hook called when a summary line is changed.
1541 The hook will not be called if `gnus-visual' is nil.
1543 The default function `gnus-summary-highlight-line' will
1544 highlight the line according to the `gnus-summary-highlight'
1547 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1548 "*A hook called when a group line is changed.
1549 The hook will not be called if `gnus-visual' is nil.
1551 The default function `gnus-group-highlight-line' will
1552 highlight the line according to the `gnus-group-highlight'
1555 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1556 "*A hook called when an article is selected for the first time.
1557 The hook is intended to mark an article as read (or unread)
1558 automatically when it is selected.")
1560 (defvar gnus-group-change-level-function nil
1561 "Function run when a group level is changed.
1562 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1564 ;; Remove any hilit infestation.
1565 (add-hook 'gnus-startup-hook
1567 (remove-hook 'gnus-summary-prepare-hook
1568 'hilit-rehighlight-buffer-quietly)
1569 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1570 (setq gnus-mark-article-hook
1571 '(gnus-summary-mark-read-and-unread-as-read))
1572 (remove-hook 'gnus-article-prepare-hook
1573 'hilit-rehighlight-buffer-quietly)))
1576 ;; Internal variables
1578 (defvar gnus-tree-buffer "*Tree*"
1579 "Buffer where Gnus thread trees are displayed.")
1582 (defvar gnus-use-generic-from nil)
1584 (defvar gnus-thread-indent-array nil)
1585 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1587 (defvar gnus-newsrc-file-version nil)
1589 (defvar gnus-method-history nil)
1590 ;; Variable holding the user answers to all method prompts.
1592 (defvar gnus-group-history nil)
1593 ;; Variable holding the user answers to all group prompts.
1595 (defvar gnus-server-alist nil
1596 "List of available servers.")
1598 (defvar gnus-group-indentation-function nil)
1600 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1602 (defvar gnus-goto-missing-group-function nil)
1604 (defvar gnus-override-subscribe-method nil)
1606 (defvar gnus-group-goto-next-group-function nil
1607 "Function to override finding the next group after listing groups.")
1609 (defconst gnus-article-mark-lists
1610 '((marked . tick) (replied . reply)
1611 (expirable . expire) (killed . killed)
1612 (bookmarks . bookmark) (dormant . dormant)
1613 (scored . score) (saved . save)
1617 ;; Avoid highlighting in kill files.
1618 (defvar gnus-summary-inhibit-highlight nil)
1619 (defvar gnus-newsgroup-selected-overlay nil)
1621 (defvar gnus-inhibit-hiding nil)
1622 (defvar gnus-group-indentation "")
1623 (defvar gnus-inhibit-limiting nil)
1624 (defvar gnus-created-frames nil)
1626 (defvar gnus-article-mode-map nil)
1627 (defvar gnus-dribble-buffer nil)
1628 (defvar gnus-headers-retrieved-by nil)
1629 (defvar gnus-article-reply nil)
1630 (defvar gnus-override-method nil)
1631 (defvar gnus-article-check-size nil)
1633 (defvar gnus-current-score-file nil)
1634 (defvar gnus-newsgroup-adaptive-score-file nil)
1635 (defvar gnus-scores-exclude-files nil)
1637 (defvar gnus-opened-servers nil)
1639 (defvar gnus-current-move-group nil)
1640 (defvar gnus-current-copy-group nil)
1641 (defvar gnus-current-crosspost-group nil)
1643 (defvar gnus-newsgroup-dependencies nil)
1644 (defvar gnus-newsgroup-async nil)
1645 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1647 (defvar gnus-newsgroup-adaptive nil)
1649 (defvar gnus-summary-display-table nil)
1650 (defvar gnus-summary-display-article-function nil)
1652 (defvar gnus-summary-highlight-line-function nil
1653 "Function called after highlighting a summary line.")
1655 (defvar gnus-group-line-format-alist
1656 `((?M gnus-tmp-marked-mark ?c)
1657 (?S gnus-tmp-subscribed ?c)
1658 (?L gnus-tmp-level ?d)
1659 (?N (cond ((eq number t) "*" )
1663 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1664 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1666 (?R gnus-tmp-number-of-read ?s)
1667 (?t gnus-tmp-number-total ?d)
1668 (?y gnus-tmp-number-of-unread ?s)
1669 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1670 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1671 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1672 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1673 (?g gnus-tmp-group ?s)
1674 (?G gnus-tmp-qualified-group ?s)
1675 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1676 (?D gnus-tmp-newsgroup-description ?s)
1677 (?o gnus-tmp-moderated ?c)
1678 (?O gnus-tmp-moderated-string ?s)
1679 (?p gnus-tmp-process-marked ?c)
1680 (?s gnus-tmp-news-server ?s)
1681 (?n gnus-tmp-news-method ?s)
1682 (?P gnus-group-indentation ?s)
1683 (?l gnus-tmp-grouplens ?s)
1684 (?z gnus-tmp-news-method-string ?s)
1685 (?u gnus-tmp-user-defined ?s)))
1687 (defvar gnus-summary-line-format-alist
1688 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1689 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1690 (?s gnus-tmp-subject-or-nil ?s)
1691 (?n gnus-tmp-name ?s)
1692 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1694 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1696 (?F gnus-tmp-from ?s)
1697 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1698 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1699 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1700 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1701 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1702 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1703 (?L gnus-tmp-lines ?d)
1704 (?I gnus-tmp-indentation ?s)
1705 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1706 (?R gnus-tmp-replied ?c)
1707 (?\[ gnus-tmp-opening-bracket ?c)
1708 (?\] gnus-tmp-closing-bracket ?c)
1709 (?\> (make-string gnus-tmp-level ? ) ?s)
1710 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1711 (?i gnus-tmp-score ?d)
1712 (?z gnus-tmp-score-char ?c)
1713 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1714 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1715 (?U gnus-tmp-unread ?c)
1716 (?t (gnus-summary-number-of-articles-in-thread
1717 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1719 (?e (gnus-summary-number-of-articles-in-thread
1720 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1722 (?u gnus-tmp-user-defined ?s))
1723 "An alist of format specifications that can appear in summary lines,
1724 and what variables they correspond with, along with the type of the
1725 variable (string, integer, character, etc).")
1727 (defvar gnus-summary-dummy-line-format-alist
1728 `((?S gnus-tmp-subject ?s)
1729 (?N gnus-tmp-number ?d)
1730 (?u gnus-tmp-user-defined ?s)))
1732 (defvar gnus-summary-mode-line-format-alist
1733 `((?G gnus-tmp-group-name ?s)
1734 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1735 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1736 (?A gnus-tmp-article-number ?d)
1737 (?Z gnus-tmp-unread-and-unselected ?s)
1738 (?V gnus-version ?s)
1739 (?U gnus-tmp-unread-and-unticked ?d)
1740 (?S gnus-tmp-subject ?s)
1741 (?e gnus-tmp-unselected ?d)
1742 (?u gnus-tmp-user-defined ?s)
1743 (?d (length gnus-newsgroup-dormant) ?d)
1744 (?t (length gnus-newsgroup-marked) ?d)
1745 (?r (length gnus-newsgroup-reads) ?d)
1746 (?E gnus-newsgroup-expunged-tally ?d)
1747 (?s (gnus-current-score-file-nondirectory) ?s)))
1749 (defvar gnus-article-mode-line-format-alist
1750 gnus-summary-mode-line-format-alist)
1752 (defvar gnus-group-mode-line-format-alist
1753 `((?S gnus-tmp-news-server ?s)
1754 (?M gnus-tmp-news-method ?s)
1755 (?u gnus-tmp-user-defined ?s)
1756 (?: gnus-tmp-colon ?s)))
1758 (defvar gnus-have-read-active-file nil)
1760 (defconst gnus-maintainer
1761 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1762 "The mail address of the Gnus maintainers.")
1764 (defconst gnus-version-number "5.2.32"
1765 "Version number for this version of Gnus.")
1767 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1768 "Version string for this version of Gnus.")
1770 (defvar gnus-info-nodes
1771 '((gnus-group-mode "(gnus)The Group Buffer")
1772 (gnus-summary-mode "(gnus)The Summary Buffer")
1773 (gnus-article-mode "(gnus)The Article Buffer")
1774 (gnus-server-mode "(gnus)The Server Buffer")
1775 (gnus-browse-mode "(gnus)Browse Foreign Server")
1776 (gnus-tree-mode "(gnus)Tree Display")
1778 "Alist of major modes and related Info nodes.")
1780 (defvar gnus-group-buffer "*Group*")
1781 (defvar gnus-summary-buffer "*Summary*")
1782 (defvar gnus-article-buffer "*Article*")
1783 (defvar gnus-server-buffer "*Server*")
1785 (defvar gnus-work-buffer " *gnus work*")
1787 (defvar gnus-original-article-buffer " *Original Article*")
1788 (defvar gnus-original-article nil)
1790 (defvar gnus-buffer-list nil
1791 "Gnus buffers that should be killed on exit.")
1793 (defvar gnus-slave nil
1794 "Whether this Gnus is a slave or not.")
1796 (defvar gnus-variable-list
1797 '(gnus-newsrc-options gnus-newsrc-options-n
1798 gnus-newsrc-last-checked-date
1799 gnus-newsrc-alist gnus-server-alist
1800 gnus-killed-list gnus-zombie-list
1801 gnus-topic-topology gnus-topic-alist
1803 "Gnus variables saved in the quick startup file.")
1805 (defvar gnus-newsrc-options nil
1806 "Options line in the .newsrc file.")
1808 (defvar gnus-newsrc-options-n nil
1809 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1811 (defvar gnus-newsrc-last-checked-date nil
1812 "Date Gnus last asked server for new newsgroups.")
1814 (defvar gnus-topic-topology nil
1815 "The complete topic hierarchy.")
1817 (defvar gnus-topic-alist nil
1818 "The complete topic-group alist.")
1820 (defvar gnus-newsrc-alist nil
1821 "Assoc list of read articles.
1822 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1824 (defvar gnus-newsrc-hashtb nil
1825 "Hashtable of gnus-newsrc-alist.")
1827 (defvar gnus-killed-list nil
1828 "List of killed newsgroups.")
1830 (defvar gnus-killed-hashtb nil
1831 "Hash table equivalent of gnus-killed-list.")
1833 (defvar gnus-zombie-list nil
1834 "List of almost dead newsgroups.")
1836 (defvar gnus-description-hashtb nil
1837 "Descriptions of newsgroups.")
1839 (defvar gnus-list-of-killed-groups nil
1840 "List of newsgroups that have recently been killed by the user.")
1842 (defvar gnus-active-hashtb nil
1843 "Hashtable of active articles.")
1845 (defvar gnus-moderated-list nil
1846 "List of moderated newsgroups.")
1848 (defvar gnus-group-marked nil)
1850 (defvar gnus-current-startup-file nil
1851 "Startup file for the current host.")
1853 (defvar gnus-last-search-regexp nil
1854 "Default regexp for article search command.")
1856 (defvar gnus-last-shell-command nil
1857 "Default shell command on article.")
1859 (defvar gnus-current-select-method nil
1860 "The current method for selecting a newsgroup.")
1862 (defvar gnus-group-list-mode nil)
1864 (defvar gnus-article-internal-prepare-hook nil)
1866 (defvar gnus-newsgroup-name nil)
1867 (defvar gnus-newsgroup-begin nil)
1868 (defvar gnus-newsgroup-end nil)
1869 (defvar gnus-newsgroup-last-rmail nil)
1870 (defvar gnus-newsgroup-last-mail nil)
1871 (defvar gnus-newsgroup-last-folder nil)
1872 (defvar gnus-newsgroup-last-file nil)
1873 (defvar gnus-newsgroup-auto-expire nil)
1874 (defvar gnus-newsgroup-active nil)
1876 (defvar gnus-newsgroup-data nil)
1877 (defvar gnus-newsgroup-data-reverse nil)
1878 (defvar gnus-newsgroup-limit nil)
1879 (defvar gnus-newsgroup-limits nil)
1881 (defvar gnus-newsgroup-unreads nil
1882 "List of unread articles in the current newsgroup.")
1884 (defvar gnus-newsgroup-unselected nil
1885 "List of unselected unread articles in the current newsgroup.")
1887 (defvar gnus-newsgroup-reads nil
1888 "Alist of read articles and article marks in the current newsgroup.")
1890 (defvar gnus-newsgroup-expunged-tally nil)
1892 (defvar gnus-newsgroup-marked nil
1893 "List of ticked articles in the current newsgroup (a subset of unread art).")
1895 (defvar gnus-newsgroup-killed nil
1896 "List of ranges of articles that have been through the scoring process.")
1898 (defvar gnus-newsgroup-cached nil
1899 "List of articles that come from the article cache.")
1901 (defvar gnus-newsgroup-saved nil
1902 "List of articles that have been saved.")
1904 (defvar gnus-newsgroup-kill-headers nil)
1906 (defvar gnus-newsgroup-replied nil
1907 "List of articles that have been replied to in the current newsgroup.")
1909 (defvar gnus-newsgroup-expirable nil
1910 "List of articles in the current newsgroup that can be expired.")
1912 (defvar gnus-newsgroup-processable nil
1913 "List of articles in the current newsgroup that can be processed.")
1915 (defvar gnus-newsgroup-bookmarks nil
1916 "List of articles in the current newsgroup that have bookmarks.")
1918 (defvar gnus-newsgroup-dormant nil
1919 "List of dormant articles in the current newsgroup.")
1921 (defvar gnus-newsgroup-scored nil
1922 "List of scored articles in the current newsgroup.")
1924 (defvar gnus-newsgroup-headers nil
1925 "List of article headers in the current newsgroup.")
1927 (defvar gnus-newsgroup-threads nil)
1929 (defvar gnus-newsgroup-prepared nil
1930 "Whether the current group has been prepared properly.")
1932 (defvar gnus-newsgroup-ancient nil
1933 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1935 (defvar gnus-newsgroup-sparse nil)
1937 (defvar gnus-current-article nil)
1938 (defvar gnus-article-current nil)
1939 (defvar gnus-current-headers nil)
1940 (defvar gnus-have-all-headers nil)
1941 (defvar gnus-last-article nil)
1942 (defvar gnus-newsgroup-history nil)
1943 (defvar gnus-current-kill-article nil)
1945 ;; Save window configuration.
1946 (defvar gnus-prev-winconf nil)
1948 (defvar gnus-summary-mark-positions nil)
1949 (defvar gnus-group-mark-positions nil)
1951 (defvar gnus-reffed-article-number nil)
1953 ;;; Let the byte-compiler know that we know about this variable.
1954 (defvar rmail-default-rmail-file)
1956 (defvar gnus-cache-removable-articles nil)
1958 (defvar gnus-dead-summary nil)
1960 (defconst gnus-summary-local-variables
1961 '(gnus-newsgroup-name
1962 gnus-newsgroup-begin gnus-newsgroup-end
1963 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1964 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1965 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1966 gnus-newsgroup-unselected gnus-newsgroup-marked
1967 gnus-newsgroup-reads gnus-newsgroup-saved
1968 gnus-newsgroup-replied gnus-newsgroup-expirable
1969 gnus-newsgroup-processable gnus-newsgroup-killed
1970 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1971 gnus-newsgroup-headers gnus-newsgroup-threads
1972 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1973 gnus-current-article gnus-current-headers gnus-have-all-headers
1974 gnus-last-article gnus-article-internal-prepare-hook
1975 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1976 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1977 gnus-newsgroup-async gnus-thread-expunge-below
1978 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1979 (gnus-summary-mark-below . global)
1980 gnus-newsgroup-active gnus-scores-exclude-files
1981 gnus-newsgroup-history gnus-newsgroup-ancient
1982 gnus-newsgroup-sparse
1983 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1984 gnus-newsgroup-adaptive-score-file
1985 (gnus-newsgroup-expunged-tally . 0)
1986 gnus-cache-removable-articles gnus-newsgroup-cached
1987 gnus-newsgroup-data gnus-newsgroup-data-reverse
1988 gnus-newsgroup-limit gnus-newsgroup-limits)
1989 "Variables that are buffer-local to the summary buffers.")
1991 (defconst gnus-bug-message
1992 "Sending a bug report to the Gnus Towers.
1993 ========================================
1995 The buffer below is a mail buffer. When you press `C-c C-c', it will
1996 be sent to the Gnus Bug Exterminators.
1998 At the bottom of the buffer you'll see lots of variable settings.
1999 Please do not delete those. They will tell the Bug People what your
2000 environment is, so that it will be easier to locate the bugs.
2002 If you have found a bug that makes Emacs go \"beep\", set
2003 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
2004 and include the backtrace in your bug report.
2006 Please describe the bug in annoying, painstaking detail.
2008 Thank you for your help in stamping out bugs.
2011 ;;; End of variables.
2013 ;; Define some autoload functions Gnus might use.
2016 ;; This little mapcar goes through the list below and marks the
2017 ;; symbols in question as autoloaded functions.
2020 (let ((interactive (nth 1 (memq ':interactive package))))
2024 (when (consp function)
2025 (setq keymap (car (memq 'keymap function)))
2026 (setq function (car function)))
2027 (autoload function (car package) nil interactive keymap)))
2028 (if (eq (nth 1 package) ':interactive)
2031 '(("metamail" metamail-buffer)
2032 ("info" Info-goto-node)
2033 ("hexl" hexl-hex-string-to-integer)
2034 ("pp" pp pp-to-string pp-eval-expression)
2035 ("mail-extr" mail-extract-address-components)
2036 ("nnmail" nnmail-split-fancy nnmail-article-group)
2037 ("nnvirtual" nnvirtual-catchup-group)
2038 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2039 timezone-make-sortable-date timezone-make-time-string)
2040 ("rmailout" rmail-output)
2041 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2043 ("gnus-soup" :interactive t
2044 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2045 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2046 ("nnsoup" nnsoup-pack-replies)
2047 ("score-mode" :interactive t gnus-score-mode)
2048 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2049 gnus-Folder-save-name gnus-folder-save-name)
2050 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2051 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2052 gnus-server-make-menu-bar gnus-article-make-menu-bar
2053 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2054 gnus-summary-highlight-line gnus-carpal-setup-buffer
2055 gnus-group-highlight-line
2056 gnus-article-add-button gnus-insert-next-page-button
2057 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2058 ("gnus-vis" :interactive t
2059 gnus-article-push-button gnus-article-press-button
2060 gnus-article-highlight gnus-article-highlight-some
2061 gnus-article-highlight-headers gnus-article-highlight-signature
2062 gnus-article-add-buttons gnus-article-add-buttons-to-head
2063 gnus-article-next-button gnus-article-prev-button)
2064 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2065 gnus-demon-add-disconnection gnus-demon-add-handler
2066 gnus-demon-remove-handler)
2067 ("gnus-demon" :interactive t
2068 gnus-demon-init gnus-demon-cancel)
2069 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2070 gnus-tree-open gnus-tree-close)
2071 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2072 gnus-nocem-unwanted-article-p)
2073 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2074 ("gnus-srvr" gnus-browse-foreign-server)
2075 ("gnus-cite" :interactive t
2076 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2077 gnus-article-hide-citation gnus-article-fill-cited-article
2078 gnus-article-hide-citation-in-followups)
2079 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2080 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2081 gnus-execute gnus-expunge)
2082 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2083 gnus-cache-possibly-remove-articles gnus-cache-request-article
2084 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2085 gnus-cache-enter-remove-article gnus-cached-article-p
2086 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2087 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2088 gnus-cache-remove-article)
2089 ("gnus-score" :interactive t
2090 gnus-summary-increase-score gnus-summary-lower-score
2091 gnus-score-flush-cache gnus-score-close
2092 gnus-score-raise-same-subject-and-select
2093 gnus-score-raise-same-subject gnus-score-default
2094 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2095 gnus-score-lower-same-subject gnus-score-lower-thread
2096 gnus-possibly-score-headers gnus-summary-raise-score
2097 gnus-summary-set-score gnus-summary-current-score)
2099 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2100 gnus-current-score-file-nondirectory gnus-score-adaptive
2101 gnus-score-find-trace gnus-score-file-name)
2102 ("gnus-edit" :interactive t gnus-score-customize)
2103 ("gnus-topic" :interactive t gnus-topic-mode)
2104 ("gnus-topic" gnus-topic-remove-group)
2105 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2106 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2107 ("gnus-uu" :interactive t
2108 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2109 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2110 gnus-uu-mark-by-regexp gnus-uu-mark-all
2111 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2112 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2113 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2114 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2115 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2116 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2117 gnus-uu-decode-binhex-view)
2118 ("gnus-msg" (gnus-summary-send-map keymap)
2119 gnus-mail-yank-original gnus-mail-send-and-exit
2120 gnus-article-mail gnus-new-mail gnus-mail-reply)
2121 ("gnus-msg" :interactive t
2122 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2123 gnus-summary-followup gnus-summary-followup-with-original
2124 gnus-summary-cancel-article gnus-summary-supersede-article
2125 gnus-post-news gnus-inews-news
2126 gnus-summary-reply gnus-summary-reply-with-original
2127 gnus-summary-mail-forward gnus-summary-mail-other-window
2129 ("gnus-picon" :interactive t gnus-article-display-picons
2130 gnus-group-display-picons gnus-picons-article-display-x-face
2131 gnus-picons-display-x-face)
2132 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2133 gnus-grouplens-mode)
2134 ("smiley" :interactive t gnus-smiley-display)
2135 ("gnus-vm" gnus-vm-mail-setup)
2136 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2137 gnus-summary-save-article-vm))))
2141 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2142 ;; If you want the cursor to go somewhere else, set these two
2143 ;; functions in some startup hook to whatever you want.
2144 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2145 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2147 ;;; Various macros and substs.
2149 (defun gnus-header-from (header)
2150 (mail-header-from header))
2152 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2153 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2154 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2155 (w (make-symbol "w"))
2156 (buf (make-symbol "buf")))
2157 `(let* ((,tempvar (selected-window))
2159 (,w (get-buffer-window ,buf 'visible)))
2164 (pop-to-buffer ,buf))
2166 (select-window ,tempvar)))))
2168 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2169 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2170 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2172 (defmacro gnus-gethash (string hashtable)
2173 "Get hash value of STRING in HASHTABLE."
2174 `(symbol-value (intern-soft ,string ,hashtable)))
2176 (defmacro gnus-sethash (string value hashtable)
2177 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2178 `(set (intern ,string ,hashtable) ,value))
2180 (defmacro gnus-intern-safe (string hashtable)
2181 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2182 `(let ((symbol (intern ,string ,hashtable)))
2187 (defmacro gnus-group-unread (group)
2188 "Get the currently computed number of unread articles in GROUP."
2189 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2191 (defmacro gnus-group-entry (group)
2192 "Get the newsrc entry for GROUP."
2193 `(gnus-gethash ,group gnus-newsrc-hashtb))
2195 (defmacro gnus-active (group)
2196 "Get active info on GROUP."
2197 `(gnus-gethash ,group gnus-active-hashtb))
2199 (defmacro gnus-set-active (group active)
2200 "Set GROUP's active info."
2201 `(gnus-sethash ,group ,active gnus-active-hashtb))
2203 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2204 ;; function `substring' might cut on a middle of multi-octet
2206 (defun gnus-truncate-string (str width)
2207 (substring str 0 width))
2209 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2210 ;; to limit the length of a string. This function is necessary since
2211 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2212 (defsubst gnus-limit-string (str width)
2213 (if (> (length str) width)
2214 (substring str 0 width)
2217 (defsubst gnus-simplify-subject-re (subject)
2218 "Remove \"Re:\" from subject lines."
2219 (if (string-match "^[Rr][Ee]: *" subject)
2220 (substring subject (match-end 0))
2223 (defsubst gnus-functionp (form)
2224 "Return non-nil if FORM is funcallable."
2225 (or (and (symbolp form) (fboundp form))
2226 (and (listp form) (eq (car form) 'lambda))))
2228 (defsubst gnus-goto-char (point)
2229 (and point (goto-char point)))
2231 (defmacro gnus-buffer-exists-p (buffer)
2232 `(let ((buffer ,buffer))
2234 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2237 (defmacro gnus-kill-buffer (buffer)
2238 `(let ((buf ,buffer))
2239 (if (gnus-buffer-exists-p buf)
2240 (kill-buffer buf))))
2242 (defsubst gnus-point-at-bol ()
2243 "Return point at the beginning of the line."
2250 (defsubst gnus-point-at-eol ()
2251 "Return point at the end of the line."
2258 (defun gnus-alive-p ()
2259 "Say whether Gnus is running or not."
2260 (and gnus-group-buffer
2261 (get-buffer gnus-group-buffer)))
2263 (defun gnus-delete-first (elt list)
2264 "Delete by side effect the first occurrence of ELT as a member of LIST."
2265 (if (equal (car list) elt)
2268 (while (and (cdr list)
2269 (not (equal (cadr list) elt)))
2270 (setq list (cdr list)))
2272 (setcdr list (cddr list)))
2275 ;; Delete the current line (and the next N lines.);
2276 (defmacro gnus-delete-line (&optional n)
2277 `(delete-region (progn (beginning-of-line) (point))
2278 (progn (forward-line ,(or n 1)) (point))))
2280 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2281 (defvar gnus-init-inhibit nil)
2282 (defun gnus-read-init-file (&optional inhibit-next)
2283 (if gnus-init-inhibit
2284 (setq gnus-init-inhibit nil)
2285 (setq gnus-init-inhibit inhibit-next)
2287 (or (and (file-exists-p gnus-init-file)
2288 ;; Don't try to load a directory.
2289 (not (file-directory-p gnus-init-file)))
2290 (file-exists-p (concat gnus-init-file ".el"))
2291 (file-exists-p (concat gnus-init-file ".elc")))
2293 (load gnus-init-file nil t)
2295 (error "Error in %s: %s" gnus-init-file var))))))
2297 ;; Info access macros.
2299 (defmacro gnus-info-group (info)
2301 (defmacro gnus-info-rank (info)
2303 (defmacro gnus-info-read (info)
2305 (defmacro gnus-info-marks (info)
2307 (defmacro gnus-info-method (info)
2309 (defmacro gnus-info-params (info)
2312 (defmacro gnus-info-level (info)
2313 `(let ((rank (gnus-info-rank ,info)))
2317 (defmacro gnus-info-score (info)
2318 `(let ((rank (gnus-info-rank ,info)))
2319 (or (and (consp rank) (cdr rank)) 0)))
2321 (defmacro gnus-info-set-group (info group)
2322 `(setcar ,info ,group))
2323 (defmacro gnus-info-set-rank (info rank)
2324 `(setcar (nthcdr 1 ,info) ,rank))
2325 (defmacro gnus-info-set-read (info read)
2326 `(setcar (nthcdr 2 ,info) ,read))
2327 (defmacro gnus-info-set-marks (info marks)
2328 `(setcar (nthcdr 3 ,info) ,marks))
2329 (defmacro gnus-info-set-method (info method)
2330 `(setcar (nthcdr 4 ,info) ,method))
2331 (defmacro gnus-info-set-params (info params)
2332 `(setcar (nthcdr 5 ,info) ,params))
2334 (defmacro gnus-info-set-level (info level)
2335 `(let ((rank (cdr ,info)))
2336 (if (consp (car rank))
2337 (setcar (car rank) ,level)
2338 (setcar rank ,level))))
2339 (defmacro gnus-info-set-score (info score)
2340 `(let ((rank (cdr ,info)))
2341 (if (consp (car rank))
2342 (setcdr (car rank) ,score)
2343 (setcar rank (cons (car rank) ,score)))))
2345 (defmacro gnus-get-info (group)
2346 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2348 (defun gnus-byte-code (func)
2349 "Return a form that can be `eval'ed based on FUNC."
2350 (let ((fval (symbol-function func)))
2351 (if (byte-code-function-p fval)
2352 (let ((flist (append fval nil)))
2353 (setcar flist 'byte-code)
2355 (cons 'progn (cddr fval)))))
2357 ;; Find out whether the gnus-visual TYPE is wanted.
2358 (defun gnus-visual-p (&optional type class)
2359 (and gnus-visual ; Has to be non-nil, at least.
2360 (if (not type) ; We don't care about type.
2362 (if (listp gnus-visual) ; It's a list, so we check it.
2363 (or (memq type gnus-visual)
2364 (memq class gnus-visual))
2367 ;;; Load the compatability functions.
2377 (defvar gnus-shutdown-alist nil)
2379 (defun gnus-add-shutdown (function &rest symbols)
2380 "Run FUNCTION whenever one of SYMBOLS is shut down."
2381 (push (cons function symbols) gnus-shutdown-alist))
2383 (defun gnus-shutdown (symbol)
2384 "Shut down everything that waits for SYMBOL."
2385 (let ((alist gnus-shutdown-alist)
2387 (while (setq entry (pop alist))
2388 (when (memq symbol (cdr entry))
2389 (funcall (car entry))))))
2393 ;; Format specs. The chunks below are the machine-generated forms
2394 ;; that are to be evaled as the result of the default format strings.
2395 ;; We write them in here to get them byte-compiled. That way the
2396 ;; default actions will be quite fast, while still retaining the full
2397 ;; flexibility of the user-defined format specs.
2399 ;; First we have lots of dummy defvars to let the compiler know these
2400 ;; are really dynamic variables.
2402 (defvar gnus-tmp-unread)
2403 (defvar gnus-tmp-replied)
2404 (defvar gnus-tmp-score-char)
2405 (defvar gnus-tmp-indentation)
2406 (defvar gnus-tmp-opening-bracket)
2407 (defvar gnus-tmp-lines)
2408 (defvar gnus-tmp-name)
2409 (defvar gnus-tmp-closing-bracket)
2410 (defvar gnus-tmp-subject-or-nil)
2411 (defvar gnus-tmp-subject)
2412 (defvar gnus-tmp-marked)
2413 (defvar gnus-tmp-marked-mark)
2414 (defvar gnus-tmp-subscribed)
2415 (defvar gnus-tmp-process-marked)
2416 (defvar gnus-tmp-number-of-unread)
2417 (defvar gnus-tmp-group-name)
2418 (defvar gnus-tmp-group)
2419 (defvar gnus-tmp-article-number)
2420 (defvar gnus-tmp-unread-and-unselected)
2421 (defvar gnus-tmp-news-method)
2422 (defvar gnus-tmp-news-server)
2423 (defvar gnus-tmp-article-number)
2424 (defvar gnus-mouse-face)
2425 (defvar gnus-mouse-face-prop)
2427 (defun gnus-summary-line-format-spec ()
2428 (insert gnus-tmp-unread gnus-tmp-replied
2429 gnus-tmp-score-char gnus-tmp-indentation)
2430 (gnus-put-text-property
2434 gnus-tmp-opening-bracket
2435 (format "%4d: %-20s"
2437 (if (> (length gnus-tmp-name) 20)
2438 (substring gnus-tmp-name 0 20)
2440 gnus-tmp-closing-bracket)
2442 gnus-mouse-face-prop gnus-mouse-face)
2443 (insert " " gnus-tmp-subject-or-nil "\n"))
2445 (defvar gnus-summary-line-format-spec
2446 (gnus-byte-code 'gnus-summary-line-format-spec))
2448 (defun gnus-summary-dummy-line-format-spec ()
2450 (gnus-put-text-property
2455 gnus-mouse-face-prop gnus-mouse-face)
2456 (insert " " gnus-tmp-subject "\n"))
2458 (defvar gnus-summary-dummy-line-format-spec
2459 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2461 (defun gnus-group-line-format-spec ()
2462 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2463 gnus-tmp-process-marked
2464 gnus-group-indentation
2465 (format "%5s: " gnus-tmp-number-of-unread))
2466 (gnus-put-text-property
2469 (insert gnus-tmp-group "\n")
2471 gnus-mouse-face-prop gnus-mouse-face))
2472 (defvar gnus-group-line-format-spec
2473 (gnus-byte-code 'gnus-group-line-format-spec))
2475 (defvar gnus-format-specs
2476 `((version . ,emacs-version)
2477 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2478 (summary-dummy ,gnus-summary-dummy-line-format
2479 ,gnus-summary-dummy-line-format-spec)
2480 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2482 (defvar gnus-article-mode-line-format-spec nil)
2483 (defvar gnus-summary-mode-line-format-spec nil)
2484 (defvar gnus-group-mode-line-format-spec nil)
2486 ;;; Phew. All that gruft is over, fortunately.
2490 ;;; Gnus Utility Functions
2493 (defun gnus-extract-address-components (from)
2495 ;; First find the address - the thing with the @ in it. This may
2496 ;; not be accurate in mail addresses, but does the trick most of
2497 ;; the time in news messages.
2498 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2499 (setq address (substring from (match-beginning 0) (match-end 0))))
2500 ;; Then we check whether the "name <address>" format is used.
2502 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2503 ;; Linear white space is not required.
2504 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2505 (and (setq name (substring from 0 (match-beginning 0)))
2506 ;; Strip any quotes from the name.
2507 (string-match "\".*\"" name)
2508 (setq name (substring name 1 (1- (match-end 0))))))
2509 ;; If not, then "address (name)" is used.
2511 (and (string-match "(.+)" from)
2512 (setq name (substring from (1+ (match-beginning 0))
2513 (1- (match-end 0)))))
2514 (and (string-match "()" from)
2515 (setq name address))
2516 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2517 ;; XOVER might not support folded From headers.
2518 (and (string-match "(.*" from)
2519 (setq name (substring from (1+ (match-beginning 0))
2521 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2522 (list (or name from) (or address from))))
2524 (defun gnus-fetch-field (field)
2525 "Return the value of the header FIELD of current article."
2528 (let ((case-fold-search t)
2529 (inhibit-point-motion-hooks t))
2530 (nnheader-narrow-to-headers)
2531 (message-fetch-field field)))))
2533 (defun gnus-goto-colon ()
2535 (search-forward ":" (gnus-point-at-eol) t))
2538 (defun gnus-update-format (var)
2539 "Update the format specification near point."
2544 ;; Find the end of the current word.
2545 (re-search-forward "[ \t\n]" nil t)
2547 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2548 (match-string 1)))))
2549 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2550 (match-string 1 var))))
2551 (entry (assq type gnus-format-specs))
2554 (setq gnus-format-specs (delq entry gnus-format-specs)))
2556 (intern (format "%s-spec" var))
2557 (gnus-parse-format (setq value (symbol-value (intern var)))
2558 (symbol-value (intern (format "%s-alist" var)))
2559 (not (string-match "mode" var))))
2560 (setq spec (symbol-value (intern (format "%s-spec" var))))
2561 (push (list type value spec) gnus-format-specs)
2563 (pop-to-buffer "*Gnus Format*")
2565 (lisp-interaction-mode)
2566 (insert (pp-to-string spec))))
2568 (defun gnus-update-format-specifications (&optional force)
2569 "Update all (necessary) format specifications."
2570 ;; Make the indentation array.
2571 (gnus-make-thread-indent-array)
2573 ;; See whether all the stored info needs to be flushed.
2575 (not (equal emacs-version
2576 (cdr (assq 'version gnus-format-specs)))))
2577 (setq gnus-format-specs nil))
2579 ;; Go through all the formats and see whether they need updating.
2580 (let ((types '(summary summary-dummy group
2581 summary-mode group-mode article-mode))
2582 new-format entry type val)
2583 (while (setq type (pop types))
2584 ;; Jump to the proper buffer to find out the value of
2585 ;; the variable, if possible. (It may be buffer-local.)
2587 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2589 (when (and (boundp buffer)
2590 (setq val (symbol-value buffer))
2592 (buffer-name (get-buffer val)))
2593 (set-buffer (get-buffer val)))
2594 (setq new-format (symbol-value
2595 (intern (format "gnus-%s-line-format" type))))))
2596 (setq entry (cdr (assq type gnus-format-specs)))
2598 (equal (car entry) new-format))
2599 ;; Use the old format.
2600 (set (intern (format "gnus-%s-line-format-spec" type))
2602 ;; This is a new format.
2604 (if (not (stringp new-format))
2605 ;; This is a function call or something.
2607 ;; This is a "real" format.
2611 (intern (format "gnus-%s-line-format-alist"
2612 (if (eq type 'article-mode)
2613 'summary-mode type))))
2614 (not (string-match "mode$" (symbol-name type))))))
2615 ;; Enter the new format spec into the list.
2618 (setcar (cdr entry) val)
2619 (setcar entry new-format))
2620 (push (list type new-format val) gnus-format-specs))
2621 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2623 (unless (assq 'version gnus-format-specs)
2624 (push (cons 'version emacs-version) gnus-format-specs))
2626 (gnus-update-group-mark-positions)
2627 (gnus-update-summary-mark-positions))
2629 (defun gnus-update-summary-mark-positions ()
2630 "Compute where the summary marks are to go."
2632 (when (and gnus-summary-buffer
2633 (get-buffer gnus-summary-buffer)
2634 (buffer-name (get-buffer gnus-summary-buffer)))
2635 (set-buffer gnus-summary-buffer))
2636 (let ((gnus-replied-mark 129)
2637 (gnus-score-below-mark 130)
2638 (gnus-score-over-mark 130)
2641 (spec gnus-summary-line-format-spec)
2644 (gnus-set-work-buffer)
2645 (let ((gnus-summary-line-format-spec spec))
2646 (gnus-summary-insert-line
2647 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2648 (goto-char (point-min))
2649 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2651 (goto-char (point-min))
2652 (push (cons 'replied (and (search-forward "\201" nil t)
2655 (goto-char (point-min))
2656 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2658 (setq gnus-summary-mark-positions pos))))
2660 (defun gnus-update-group-mark-positions ()
2662 (let ((gnus-process-mark 128)
2663 (gnus-group-marked '("dummy.group"))
2664 (gnus-active-hashtb (make-vector 10 0)))
2665 (gnus-set-active "dummy.group" '(0 . 0))
2666 (gnus-set-work-buffer)
2667 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2668 (goto-char (point-min))
2669 (setq gnus-group-mark-positions
2670 (list (cons 'process (and (search-forward "\200" nil t)
2671 (- (point) 2))))))))
2673 (defvar gnus-mouse-face-0 'highlight)
2674 (defvar gnus-mouse-face-1 'highlight)
2675 (defvar gnus-mouse-face-2 'highlight)
2676 (defvar gnus-mouse-face-3 'highlight)
2677 (defvar gnus-mouse-face-4 'highlight)
2679 (defun gnus-mouse-face-function (form type)
2680 `(gnus-put-text-property
2681 (point) (progn ,@form (point))
2682 gnus-mouse-face-prop
2685 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2687 (defvar gnus-face-0 'bold)
2688 (defvar gnus-face-1 'italic)
2689 (defvar gnus-face-2 'bold-italic)
2690 (defvar gnus-face-3 'bold)
2691 (defvar gnus-face-4 'bold)
2693 (defun gnus-face-face-function (form type)
2694 `(gnus-put-text-property
2695 (point) (progn ,@form (point))
2696 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2698 (defun gnus-max-width-function (el max-width)
2699 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2701 `(if (> (length ,el) ,max-width)
2702 (substring ,el 0 ,max-width)
2704 `(let ((val (eval ,el)))
2706 (setq val (int-to-string val)))
2707 (if (> (length val) ,max-width)
2708 (substring val 0 ,max-width)
2711 (defun gnus-parse-format (format spec-alist &optional insert)
2712 ;; This function parses the FORMAT string with the help of the
2713 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2714 ;; string. If the FORMAT string contains the specifiers %( and %)
2715 ;; the text between them will have the mouse-face text property.
2717 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2719 (gnus-parse-complex-format format spec-alist)
2720 ;; This is a simple format.
2721 (gnus-parse-simple-format format spec-alist insert)))
2723 (defun gnus-parse-complex-format (format spec-alist)
2725 (gnus-set-work-buffer)
2727 (goto-char (point-min))
2728 (while (re-search-forward "\"" nil t)
2729 (replace-match "\\\"" nil t))
2730 (goto-char (point-min))
2732 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2733 (let ((number (if (match-beginning 1)
2734 (match-string 1) "0"))
2735 (delim (aref (match-string 2) 0)))
2736 (if (or (= delim ?\() (= delim ?\{))
2737 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2739 (replace-match "\")\""))))
2740 (goto-char (point-max))
2742 (goto-char (point-min))
2743 (let ((form (read (current-buffer))))
2744 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2746 (defun gnus-complex-form-to-spec (form spec-alist)
2751 (gnus-parse-simple-format sform spec-alist t)
2752 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2753 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2757 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2758 ;; This function parses the FORMAT string with the help of the
2759 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2762 spec flist fstring newspec elem beg result dontinsert)
2764 (gnus-set-work-buffer)
2766 (goto-char (point-min))
2767 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2769 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2771 beg (1+ (match-beginning 0)))
2772 ;; First check if there are any specs that look anything like
2773 ;; "%12,12A", ie. with a "max width specification". These have
2774 ;; to be treated specially.
2775 (if (setq beg (match-beginning 1))
2779 (1+ (match-beginning 1)) (match-end 1))))
2781 (setq beg (match-beginning 2)))
2782 ;; Find the specification from `spec-alist'.
2783 (unless (setq elem (cdr (assq spec spec-alist)))
2784 (setq elem '("*" ?s)))
2785 ;; Treat user defined format specifiers specially.
2786 (when (eq (car elem) 'gnus-tmp-user-defined)
2789 (list (intern (concat "gnus-user-format-function-"
2791 'gnus-tmp-header) ?s))
2792 (delete-region (match-beginning 3) (match-end 3)))
2793 (if (not (zerop max-width))
2794 (let ((el (car elem)))
2795 (cond ((= (cadr elem) ?c)
2796 (setq el (list 'char-to-string el)))
2798 (setq el (list 'int-to-string el))))
2799 (setq flist (cons (gnus-max-width-function el max-width)
2803 (setq flist (cons (car elem) flist))
2804 (setq newspec (cadr elem)))))
2805 ;; Remove the old specification (and possibly a ",12" string).
2806 (delete-region beg (match-end 2))
2807 ;; Insert the new specification.
2810 (setq fstring (buffer-substring 1 (point-max))))
2811 ;; Do some postprocessing to increase efficiency.
2816 ((string= fstring "")
2818 ;; Not a format string.
2819 ((not (string-match "%" fstring))
2821 ;; A format string with just a single string spec.
2822 ((string= fstring "%s")
2824 ;; A single character.
2825 ((string= fstring "%c")
2828 ((string= fstring "%d")
2831 (list `(princ ,(car flist)))
2832 (list `(int-to-string ,(car flist)))))
2833 ;; Just lots of chars and strings.
2834 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2836 ;; A single string spec at the beginning of the spec.
2837 ((string-match "\\`%[sc][^%]+\\'" fstring)
2838 (list (car flist) (substring fstring 2)))
2839 ;; A single string spec in the middle of the spec.
2840 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2841 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2842 ;; A single string spec in the end of the spec.
2843 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2844 (list (match-string 1 fstring) (car flist)))
2845 ;; A more complex spec.
2847 (list (cons 'format (cons fstring (nreverse flist)))))))
2853 (cons 'insert result)))
2854 (cond ((stringp result)
2857 (cons 'concat result))
2860 (defun gnus-eval-format (format &optional alist props)
2861 "Eval the format variable FORMAT, using ALIST.
2862 If PROPS, insert the result."
2863 (let ((form (gnus-parse-format format alist props)))
2865 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2868 (defun gnus-remove-text-with-property (prop)
2869 "Delete all text in the current buffer with text property PROP."
2871 (goto-char (point-min))
2873 (while (get-text-property (point) prop)
2875 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2877 (defun gnus-set-work-buffer ()
2878 (if (get-buffer gnus-work-buffer)
2880 (set-buffer gnus-work-buffer)
2882 (set-buffer (get-buffer-create gnus-work-buffer))
2883 (kill-all-local-variables)
2884 (buffer-disable-undo (current-buffer))
2885 (gnus-add-current-to-buffer-list)))
2887 ;; Article file names when saving.
2889 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2890 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2891 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2892 Otherwise, it is like ~/News/news/group/num."
2895 (concat (if (gnus-use-long-file-name 'not-save)
2896 (gnus-capitalize-newsgroup newsgroup)
2897 (gnus-newsgroup-directory-form newsgroup))
2898 "/" (int-to-string (mail-header-number headers)))
2899 gnus-article-save-directory)))
2901 (string-equal (file-name-directory default)
2902 (file-name-directory last-file))
2903 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2905 (or last-file default))))
2907 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2908 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2909 If variable `gnus-use-long-file-name' is non-nil, it is
2910 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2913 (concat (if (gnus-use-long-file-name 'not-save)
2915 (gnus-newsgroup-directory-form newsgroup))
2916 "/" (int-to-string (mail-header-number headers)))
2917 gnus-article-save-directory)))
2919 (string-equal (file-name-directory default)
2920 (file-name-directory last-file))
2921 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2923 (or last-file default))))
2925 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2926 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2927 If variable `gnus-use-long-file-name' is non-nil, it is
2928 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2931 (if (gnus-use-long-file-name 'not-save)
2932 (gnus-capitalize-newsgroup newsgroup)
2933 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2934 gnus-article-save-directory)))
2936 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2937 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2938 If variable `gnus-use-long-file-name' is non-nil, it is
2939 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2942 (if (gnus-use-long-file-name 'not-save)
2944 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2945 gnus-article-save-directory)))
2947 ;; For subscribing new newsgroup
2949 (defun gnus-subscribe-hierarchical-interactive (groups)
2950 (let ((groups (sort groups 'string<))
2951 prefixes prefix start ans group starts)
2953 (setq prefixes (list "^"))
2954 (while (and groups prefixes)
2955 (while (not (string-match (car prefixes) (car groups)))
2956 (setq prefixes (cdr prefixes)))
2957 (setq prefix (car prefixes))
2958 (setq start (1- (length prefix)))
2959 (if (and (string-match "[^\\.]\\." (car groups) start)
2962 (concat "^" (substring (car groups) 0 (match-end 0))))
2963 (string-match prefix (cadr groups)))
2965 (setq prefixes (cons prefix prefixes))
2966 (message "Descend hierarchy %s? ([y]nsq): "
2967 (substring prefix 1 (1- (length prefix))))
2968 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2970 (message "Descend hierarchy %s? ([y]nsq): "
2971 (substring prefix 1 (1- (length prefix)))))
2974 (string-match prefix
2975 (setq group (car groups))))
2976 (setq gnus-killed-list
2977 (cons group gnus-killed-list))
2978 (gnus-sethash group group gnus-killed-hashtb)
2979 (setq groups (cdr groups)))
2980 (setq starts (cdr starts)))
2983 (string-match prefix
2984 (setq group (car groups))))
2985 (gnus-sethash group group gnus-killed-hashtb)
2986 (gnus-subscribe-alphabetically (car groups))
2987 (setq groups (cdr groups)))
2988 (setq starts (cdr starts)))
2991 (setq group (car groups))
2992 (setq gnus-killed-list (cons group gnus-killed-list))
2993 (gnus-sethash group group gnus-killed-hashtb)
2994 (setq groups (cdr groups))))
2996 (message "Subscribe %s? ([n]yq)" (car groups))
2997 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2999 (message "Subscribe %s? ([n]yq)" (car groups)))
3000 (setq group (car groups))
3002 (gnus-subscribe-alphabetically (car groups))
3003 (gnus-sethash group group gnus-killed-hashtb))
3006 (setq group (car groups))
3007 (setq gnus-killed-list (cons group gnus-killed-list))
3008 (gnus-sethash group group gnus-killed-hashtb)
3009 (setq groups (cdr groups))))
3011 (setq gnus-killed-list (cons group gnus-killed-list))
3012 (gnus-sethash group group gnus-killed-hashtb)))
3013 (setq groups (cdr groups)))))))
3015 (defun gnus-subscribe-randomly (newsgroup)
3016 "Subscribe new NEWSGROUP by making it the first newsgroup."
3017 (gnus-subscribe-newsgroup newsgroup))
3019 (defun gnus-subscribe-alphabetically (newgroup)
3020 "Subscribe new NEWSGROUP and insert it in alphabetical order."
3021 (let ((groups (cdr gnus-newsrc-alist))
3023 (while (and (not before) groups)
3024 (if (string< newgroup (caar groups))
3025 (setq before (caar groups))
3026 (setq groups (cdr groups))))
3027 (gnus-subscribe-newsgroup newgroup before)))
3029 (defun gnus-subscribe-hierarchically (newgroup)
3030 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
3031 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3033 (set-buffer (find-file-noselect gnus-current-startup-file))
3034 (let ((groupkey newgroup)
3036 (while (and (not before) groupkey)
3037 (goto-char (point-min))
3039 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3040 (while (and (re-search-forward groupkey-re nil t)
3042 (setq before (match-string 1))
3043 (string< before newgroup)))))
3044 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3046 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3047 (substring groupkey (match-beginning 1) (match-end 1)))))
3048 (gnus-subscribe-newsgroup newgroup before))
3049 (kill-buffer (current-buffer))))
3051 (defun gnus-subscribe-interactively (group)
3052 "Subscribe the new GROUP interactively.
3053 It is inserted in hierarchical newsgroup order if subscribed. If not,
3055 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3056 (gnus-subscribe-hierarchically group)
3057 (push group gnus-killed-list)))
3059 (defun gnus-subscribe-zombies (group)
3060 "Make the new GROUP into a zombie group."
3061 (push group gnus-zombie-list))
3063 (defun gnus-subscribe-killed (group)
3064 "Make the new GROUP a killed group."
3065 (push group gnus-killed-list))
3067 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3068 "Subscribe new NEWSGROUP.
3069 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3070 the first newsgroup."
3071 ;; We subscribe the group by changing its level to `subscribed'.
3072 (gnus-group-change-level
3073 newsgroup gnus-level-default-subscribed
3074 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3075 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3079 (defun gnus-newsgroup-directory-form (newsgroup)
3080 "Make hierarchical directory name from NEWSGROUP name."
3081 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3082 (len (length newsgroup))
3084 ;; If this is a foreign group, we don't want to translate the
3086 (if (setq idx (string-match ":" newsgroup))
3087 (aset newsgroup idx ?/)
3089 ;; Replace all occurrences of `.' with `/'.
3091 (if (= (aref newsgroup idx) ?.)
3092 (aset newsgroup idx ?/))
3093 (setq idx (1+ idx)))
3096 (defun gnus-newsgroup-savable-name (group)
3097 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3099 (nnheader-replace-chars-in-string group ?/ ?.))
3101 (defun gnus-make-directory (dir)
3102 "Make DIRECTORY recursively."
3103 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3104 ;; of the many mysteries of the universe.
3105 (let* ((dir (expand-file-name dir default-directory))
3107 (if (string-match "/$" dir)
3108 (setq dir (substring dir 0 (match-beginning 0))))
3109 ;; First go down the path until we find a directory that exists.
3110 (while (not (file-exists-p dir))
3111 (setq dirs (cons dir dirs))
3112 (string-match "/[^/]+$" dir)
3113 (setq dir (substring dir 0 (match-beginning 0))))
3114 ;; Then create all the subdirs.
3115 (while (and dirs (not err))
3117 (make-directory (car dirs))
3118 (error (setq err t)))
3119 (setq dirs (cdr dirs)))
3120 ;; We return whether we were successful or not.
3123 (defun gnus-capitalize-newsgroup (newsgroup)
3124 "Capitalize NEWSGROUP name."
3125 (and (not (zerop (length newsgroup)))
3126 (concat (char-to-string (upcase (aref newsgroup 0)))
3127 (substring newsgroup 1))))
3129 ;; Various... things.
3131 (defun gnus-simplify-subject (subject &optional re-only)
3132 "Remove `Re:' and words in parentheses.
3133 If RE-ONLY is non-nil, strip leading `Re:'s only."
3134 (let ((case-fold-search t)) ;Ignore case.
3135 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3136 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3137 (setq subject (substring subject (match-end 0))))
3138 ;; Remove uninteresting prefixes.
3139 (if (and (not re-only)
3140 gnus-simplify-ignored-prefixes
3141 (string-match gnus-simplify-ignored-prefixes subject))
3142 (setq subject (substring subject (match-end 0))))
3143 ;; Remove words in parentheses from end.
3145 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3146 (setq subject (substring subject 0 (match-beginning 0)))))
3147 ;; Return subject string.
3150 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3152 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3153 (defun gnus-simplify-buffer-fuzzy ()
3154 (let ((case-fold-search t))
3155 (goto-char (point-min))
3156 (while (search-forward "\t" nil t)
3157 (replace-match " " t t))
3158 (goto-char (point-min))
3159 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3160 (goto-char (match-beginning 0))
3162 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3163 (looking-at "^[[].*: .*[]]$"))
3164 (goto-char (point-min))
3165 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3167 (replace-match "" t t))
3168 (goto-char (point-min))
3169 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3170 (goto-char (match-end 0))
3173 (progn (goto-char (match-beginning 0)))
3174 (re-search-forward ":"))))
3175 (goto-char (point-min))
3176 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3177 (replace-match "" t t))
3178 (goto-char (point-min))
3179 (while (re-search-forward " +" nil t)
3180 (replace-match " " t t))
3181 (goto-char (point-min))
3182 (while (re-search-forward " $" nil t)
3183 (replace-match "" t t))
3184 (goto-char (point-min))
3185 (while (re-search-forward "^ +" nil t)
3186 (replace-match "" t t))
3187 (goto-char (point-min))
3188 (when gnus-simplify-subject-fuzzy-regexp
3189 (if (listp gnus-simplify-subject-fuzzy-regexp)
3190 (let ((list gnus-simplify-subject-fuzzy-regexp))
3192 (goto-char (point-min))
3193 (while (re-search-forward (car list) nil t)
3194 (replace-match "" t t))
3195 (setq list (cdr list))))
3196 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3197 (replace-match "" t t))))))
3199 (defun gnus-simplify-subject-fuzzy (subject)
3200 "Siplify a subject string fuzzily."
3202 (gnus-set-work-buffer)
3203 (let ((case-fold-search t))
3205 (inline (gnus-simplify-buffer-fuzzy))
3208 ;; Add the current buffer to the list of buffers to be killed on exit.
3209 (defun gnus-add-current-to-buffer-list ()
3210 (or (memq (current-buffer) gnus-buffer-list)
3211 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3213 (defun gnus-string> (s1 s2)
3214 (not (or (string< s1 s2)
3217 (defun gnus-read-active-file-p ()
3218 "Say whether the active file has been read from `gnus-select-method'."
3219 (memq gnus-select-method gnus-have-read-active-file))
3221 ;;; General various misc type functions.
3223 (defun gnus-clear-system ()
3224 "Clear all variables and buffers."
3225 ;; Clear Gnus variables.
3226 (let ((variables gnus-variable-list))
3228 (set (car variables) nil)
3229 (setq variables (cdr variables))))
3230 ;; Clear other internal variables.
3231 (setq gnus-list-of-killed-groups nil
3232 gnus-have-read-active-file nil
3233 gnus-newsrc-alist nil
3234 gnus-newsrc-hashtb nil
3235 gnus-killed-list nil
3236 gnus-zombie-list nil
3237 gnus-killed-hashtb nil
3238 gnus-active-hashtb nil
3239 gnus-moderated-list nil
3240 gnus-description-hashtb nil
3241 gnus-current-headers nil
3242 gnus-thread-indent-array nil
3243 gnus-newsgroup-headers nil
3244 gnus-newsgroup-name nil
3245 gnus-server-alist nil
3246 gnus-group-list-mode nil
3247 gnus-opened-servers nil
3248 gnus-group-mark-positions nil
3249 gnus-newsgroup-data nil
3250 gnus-newsgroup-unreads nil
3251 nnoo-state-alist nil
3252 gnus-current-select-method nil)
3253 (gnus-shutdown 'gnus)
3254 ;; Kill the startup file.
3255 (and gnus-current-startup-file
3256 (get-file-buffer gnus-current-startup-file)
3257 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3258 ;; Clear the dribble buffer.
3259 (gnus-dribble-clear)
3260 ;; Kill global KILL file buffer.
3261 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3262 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3263 (gnus-kill-buffer nntp-server-buffer)
3264 ;; Kill Gnus buffers.
3265 (while gnus-buffer-list
3266 (gnus-kill-buffer (pop gnus-buffer-list)))
3267 ;; Remove Gnus frames.
3268 (gnus-kill-gnus-frames))
3270 (defun gnus-kill-gnus-frames ()
3271 "Kill all frames Gnus has created."
3272 (while gnus-created-frames
3273 (when (frame-live-p (car gnus-created-frames))
3274 ;; We slap a condition-case around this `delete-frame' to ensure
3275 ;; against errors if we try do delete the single frame that's left.
3277 (delete-frame (car gnus-created-frames))
3279 (pop gnus-created-frames)))
3281 (defun gnus-windows-old-to-new (setting)
3282 ;; First we take care of the really, really old Gnus 3 actions.
3283 (when (symbolp setting)
3285 ;; Take care of ooold GNUS 3.x values.
3286 (cond ((eq setting 'SelectArticle) 'article)
3287 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3288 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3290 (if (or (listp setting)
3291 (not (and gnus-window-configuration
3292 (memq setting '(group summary article)))))
3294 (let* ((setting (if (eq setting 'group)
3295 (if (assq 'newsgroup gnus-window-configuration)
3297 'newsgroups) setting))
3298 (elem (cadr (assq setting gnus-window-configuration)))
3299 (total (apply '+ elem))
3300 (types '(group summary article))
3301 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3306 (or (not (numberp (nth i elem)))
3307 (zerop (nth i elem))
3309 (setq perc (if (= i 2)
3311 (/ (float (nth 0 elem)) total)))
3312 (setq out (cons (if (eq pbuf (nth i types))
3313 (list (nth i types) perc 'point)
3314 (list (nth i types) perc))
3317 `(vertical 1.0 ,@(nreverse out)))))
3320 (defun gnus-add-configuration (conf)
3321 "Add the window configuration CONF to `gnus-buffer-configuration'."
3322 (setq gnus-buffer-configuration
3323 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3324 gnus-buffer-configuration))))
3326 (defvar gnus-frame-list nil)
3328 (defun gnus-configure-frame (split &optional window)
3329 "Split WINDOW according to SPLIT."
3331 (setq window (get-buffer-window (current-buffer))))
3332 (select-window window)
3333 ;; This might be an old-stylee buffer config.
3334 (when (vectorp split)
3335 (setq split (append split nil)))
3336 (when (or (consp (car split))
3337 (vectorp (car split)))
3339 (push 'vertical split))
3340 ;; The SPLIT might be something that is to be evaled to
3341 ;; return a new SPLIT.
3342 (while (and (not (assq (car split) gnus-window-to-buffer))
3343 (gnus-functionp (car split)))
3344 (setq split (eval split)))
3345 (let* ((type (car split))
3347 (len (if (eq type 'horizontal) (window-width) (window-height)))
3349 (window-min-width (or gnus-window-min-width window-min-width))
3350 (window-min-height (or gnus-window-min-height window-min-height))
3351 s result new-win rest comp-subs size sub)
3353 ;; Nothing to do here.
3355 ;; Don't switch buffers.
3357 (and (memq 'point split) window))
3358 ;; This is a buffer to be selected.
3359 ((not (memq type '(frame horizontal vertical)))
3360 (let ((buffer (cond ((stringp type) type)
3361 (t (cdr (assq type gnus-window-to-buffer)))))
3364 (error "Illegal buffer type: %s" type))
3365 (unless (setq buf (get-buffer (if (symbolp buffer)
3366 (symbol-value buffer) buffer)))
3367 (setq buf (get-buffer-create (if (symbolp buffer)
3368 (symbol-value buffer) buffer))))
3369 (switch-to-buffer buf)
3370 ;; We return the window if it has the `point' spec.
3371 (and (memq 'point split) window)))
3372 ;; This is a frame split.
3374 (unless gnus-frame-list
3375 (setq gnus-frame-list (list (window-frame
3376 (get-buffer-window (current-buffer))))))
3378 params frame fresult)
3379 (while (< i (length subs))
3380 ;; Frame parameter is gotten from the sub-split.
3381 (setq params (cadr (elt subs i)))
3382 ;; It should be a list.
3383 (unless (listp params)
3385 ;; Create a new frame?
3386 (unless (setq frame (elt gnus-frame-list i))
3387 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3388 (push frame gnus-created-frames))
3389 ;; Is the old frame still alive?
3390 (unless (frame-live-p frame)
3391 (setcar (nthcdr i gnus-frame-list)
3392 (setq frame (make-frame params))))
3393 ;; Select the frame in question and do more splits there.
3394 (select-frame frame)
3395 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3397 ;; Select the frame that has the selected buffer.
3399 (select-frame (window-frame fresult)))))
3400 ;; This is a normal split.
3402 (when (> (length subs) 0)
3403 ;; First we have to compute the sizes of all new windows.
3405 (setq sub (append (pop subs) nil))
3406 (while (and (not (assq (car sub) gnus-window-to-buffer))
3407 (gnus-functionp (car sub)))
3408 (setq sub (eval sub)))
3410 (push sub comp-subs)
3411 (setq size (cadar comp-subs))
3412 (cond ((equal size 1.0)
3413 (setq rest (car comp-subs))
3416 (setq s (floor (* size len))))
3420 (error "Illegal size: %s" size)))
3421 ;; Try to make sure that we are inside the safe limits.
3423 ((eq type 'horizontal)
3424 (setq s (max s window-min-width)))
3425 ((eq type 'vertical)
3426 (setq s (max s window-min-height))))
3427 (setcar (cdar comp-subs) s)
3429 ;; Take care of the "1.0" spec.
3431 (setcar (cdr rest) (- len total))
3432 (error "No 1.0 specs in %s" split))
3433 ;; The we do the actual splitting in a nice recursive
3435 (setq comp-subs (nreverse comp-subs))
3437 (if (null (cdr comp-subs))
3438 (setq new-win window)
3440 (split-window window (cadar comp-subs)
3441 (eq type 'horizontal))))
3442 (setq result (or (gnus-configure-frame
3443 (car comp-subs) window) result))
3444 (select-window new-win)
3445 (setq window new-win)
3446 (setq comp-subs (cdr comp-subs))))
3447 ;; Return the proper window, if any.
3449 (select-window result))))))
3451 (defvar gnus-frame-split-p nil)
3453 (defun gnus-configure-windows (setting &optional force)
3454 (setq setting (gnus-windows-old-to-new setting))
3455 (let ((split (if (symbolp setting)
3456 (cadr (assq setting gnus-buffer-configuration))
3460 (setq gnus-frame-split-p nil)
3463 (error "No such setting: %s" setting))
3465 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3467 ;; All the windows mentioned are already visible, so we just
3468 ;; put point in the assigned buffer, and do not touch the
3470 (select-window all-visible)
3472 ;; Either remove all windows or just remove all Gnus windows.
3473 (let ((frame (selected-frame)))
3475 (if gnus-use-full-window
3476 ;; We want to remove all other windows.
3477 (if (not gnus-frame-split-p)
3478 ;; This is not a `frame' split, so we ignore the
3480 (delete-other-windows)
3481 ;; This is a `frame' split, so we delete all windows
3485 (unless (eq (cdr (assq 'minibuffer
3486 (frame-parameters frame)))
3488 (select-frame frame)
3489 (delete-other-windows)))
3491 ;; Just remove some windows.
3492 (gnus-remove-some-windows)
3493 (switch-to-buffer nntp-server-buffer))
3494 (select-frame frame)))
3496 (switch-to-buffer nntp-server-buffer)
3497 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3499 (defun gnus-all-windows-visible-p (split)
3500 "Say whether all buffers in SPLIT are currently visible.
3501 In particular, the value returned will be the window that
3503 (let ((stack (list split))
3505 type buffer win buf)
3506 (while (and (setq split (pop stack))
3508 ;; Be backwards compatible.
3509 (when (vectorp split)
3510 (setq split (append split nil)))
3511 (when (or (consp (car split))
3512 (vectorp (car split)))
3514 (push 'vertical split))
3515 ;; The SPLIT might be something that is to be evaled to
3516 ;; return a new SPLIT.
3517 (while (and (not (assq (car split) gnus-window-to-buffer))
3518 (gnus-functionp (car split)))
3519 (setq split (eval split)))
3521 (setq type (elt split 0))
3526 ((not (memq type '(horizontal vertical frame)))
3527 (setq buffer (cond ((stringp type) type)
3528 (t (cdr (assq type gnus-window-to-buffer)))))
3530 (error "Illegal buffer type: %s" type))
3531 (when (setq buf (get-buffer (if (symbolp buffer)
3532 (symbol-value buffer)
3534 (setq win (get-buffer-window buf t)))
3536 (when (memq 'point split)
3537 (setq all-visible win))
3538 (setq all-visible nil)))
3540 (when (eq type 'frame)
3541 (setq gnus-frame-split-p t))
3542 (setq stack (append (cddr split) stack)))))
3543 (unless (eq all-visible t)
3546 (defun gnus-window-top-edge (&optional window)
3547 (nth 1 (window-edges window)))
3549 (defun gnus-remove-some-windows ()
3550 (let ((buffers gnus-window-to-buffer)
3551 buf bufs lowest-buf lowest)
3553 ;; Remove windows on all known Gnus buffers.
3555 (setq buf (cdar buffers))
3557 (setq buf (and (boundp buf) (symbol-value buf))))
3559 (get-buffer-window buf)
3561 (setq bufs (cons buf bufs))
3563 (if (or (not lowest)
3564 (< (gnus-window-top-edge) lowest))
3566 (setq lowest (gnus-window-top-edge))
3567 (setq lowest-buf buf)))))
3568 (setq buffers (cdr buffers)))
3569 ;; Remove windows on *all* summary buffers.
3572 (let ((buf (window-buffer win)))
3573 (if (string-match "^\\*Summary" (buffer-name buf))
3575 (setq bufs (cons buf bufs))
3577 (if (or (not lowest)
3578 (< (gnus-window-top-edge) lowest))
3580 (setq lowest-buf buf)
3581 (setq lowest (gnus-window-top-edge)))))))))
3584 (pop-to-buffer lowest-buf)
3585 (switch-to-buffer nntp-server-buffer)))
3587 (and (not (eq (car bufs) lowest-buf))
3588 (delete-windows-on (car bufs)))
3589 (setq bufs (cdr bufs))))))
3591 (defun gnus-version (&optional arg)
3592 "Version number of this version of Gnus.
3593 If ARG, insert string at point."
3595 (let ((methods gnus-valid-select-methods)
3598 ;; Go through all the legal select methods and add their version
3599 ;; numbers to the total version string. Only the backends that are
3600 ;; currently in use will have their message numbers taken into
3603 (setq meth (intern (concat (caar methods) "-version")))
3605 (stringp (symbol-value meth))
3606 (setq mess (concat mess "; " (symbol-value meth))))
3607 (setq methods (cdr methods)))
3609 (insert (message mess))
3612 (defun gnus-info-find-node ()
3613 "Find Info documentation of Gnus."
3615 ;; Enlarge info window if needed.
3616 (let ((mode major-mode)
3618 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3619 (setq gnus-info-buffer (current-buffer))
3620 (gnus-configure-windows 'info)))
3622 (defun gnus-days-between (date1 date2)
3623 ;; Return the number of days between date1 and date2.
3624 (- (gnus-day-number date1) (gnus-day-number date2)))
3626 (defun gnus-day-number (date)
3627 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3628 (timezone-parse-date date))))
3629 (timezone-absolute-from-gregorian
3630 (nth 1 dat) (nth 2 dat) (car dat))))
3632 (defun gnus-encode-date (date)
3633 "Convert DATE to internal time."
3634 (let* ((parse (timezone-parse-date date))
3635 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3636 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3637 (encode-time (caddr time) (cadr time) (car time)
3638 (caddr date) (cadr date) (car date) (nth 4 date))))
3640 (defun gnus-time-minus (t1 t2)
3641 "Subtract two internal times."
3642 (let ((borrow (< (cadr t1) (cadr t2))))
3643 (list (- (car t1) (car t2) (if borrow 1 0))
3644 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3646 (defun gnus-file-newer-than (file date)
3647 (let ((fdate (nth 5 (file-attributes file))))
3648 (or (> (car fdate) (car date))
3649 (and (= (car fdate) (car date))
3650 (> (nth 1 fdate) (nth 1 date))))))
3652 (defmacro gnus-local-set-keys (&rest plist)
3653 "Set the keys in PLIST in the current keymap."
3654 `(gnus-define-keys-1 (current-local-map) ',plist))
3656 (defmacro gnus-define-keys (keymap &rest plist)
3657 "Define all keys in PLIST in KEYMAP."
3658 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3660 (put 'gnus-define-keys 'lisp-indent-function 1)
3661 (put 'gnus-define-keys 'lisp-indent-hook 1)
3662 (put 'gnus-define-keymap 'lisp-indent-function 1)
3663 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3665 (defmacro gnus-define-keymap (keymap &rest plist)
3666 "Define all keys in PLIST in KEYMAP."
3667 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3669 (defun gnus-define-keys-1 (keymap plist)
3671 (error "Can't set keys in a null keymap"))
3672 (cond ((symbolp keymap)
3673 (setq keymap (symbol-value keymap)))
3676 (set (car keymap) nil)
3677 (define-prefix-command (car keymap))
3678 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3679 (setq keymap (symbol-value (car keymap)))))
3682 (when (symbolp (setq key (pop plist)))
3683 (setq key (symbol-value key)))
3684 (define-key keymap key (pop plist)))))
3686 (defun gnus-group-read-only-p (&optional group)
3687 "Check whether GROUP supports editing or not.
3688 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3689 that that variable is buffer-local to the summary buffers."
3690 (let ((group (or group gnus-newsgroup-name)))
3691 (not (gnus-check-backend-function 'request-replace-article group))))
3693 (defun gnus-group-total-expirable-p (group)
3694 "Check whether GROUP is total-expirable or not."
3695 (let ((params (gnus-info-params (gnus-get-info group))))
3696 (or (memq 'total-expire params)
3697 (cdr (assq 'total-expire params)) ; (total-expire . t)
3698 (and gnus-total-expirable-newsgroups ; Check var.
3699 (string-match gnus-total-expirable-newsgroups group)))))
3701 (defun gnus-group-auto-expirable-p (group)
3702 "Check whether GROUP is total-expirable or not."
3703 (let ((params (gnus-info-params (gnus-get-info group))))
3704 (or (memq 'auto-expire params)
3705 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3706 (and gnus-auto-expirable-newsgroups ; Check var.
3707 (string-match gnus-auto-expirable-newsgroups group)))))
3709 (defun gnus-virtual-group-p (group)
3710 "Say whether GROUP is virtual or not."
3711 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3712 gnus-valid-select-methods)))
3714 (defun gnus-news-group-p (group &optional article)
3715 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3716 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3717 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3718 (eq (gnus-request-type group article) 'news))))
3720 (defsubst gnus-simplify-subject-fully (subject)
3721 "Simplify a subject string according to the user's wishes."
3723 ((null gnus-summary-gather-subject-limit)
3724 (gnus-simplify-subject-re subject))
3725 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3726 (gnus-simplify-subject-fuzzy subject))
3727 ((numberp gnus-summary-gather-subject-limit)
3728 (gnus-limit-string (gnus-simplify-subject-re subject)
3729 gnus-summary-gather-subject-limit))
3733 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3734 "Check whether two subjects are equal. If optional argument
3735 simple-first is t, first argument is already simplified."
3737 ((null simple-first)
3738 (equal (gnus-simplify-subject-fully s1)
3739 (gnus-simplify-subject-fully s2)))
3742 (gnus-simplify-subject-fully s2)))))
3744 ;; Returns a list of writable groups.
3745 (defun gnus-writable-groups ()
3746 (let ((alist gnus-newsrc-alist)
3748 (while (setq group (car (pop alist)))
3749 (unless (gnus-group-read-only-p group)
3750 (push group groups)))
3753 (defun gnus-completing-read (default prompt &rest args)
3754 ;; Like `completing-read', except that DEFAULT is the default argument.
3755 (let* ((prompt (if default
3756 (concat prompt " (default " default ") ")
3757 (concat prompt " ")))
3758 (answer (apply 'completing-read prompt args)))
3759 (if (or (null answer) (zerop (length answer)))
3763 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3765 (defun gnus-y-or-n-p (prompt)
3770 (defun gnus-yes-or-no-p (prompt)
3772 (yes-or-no-p prompt)
3775 ;; Check whether to use long file names.
3776 (defun gnus-use-long-file-name (symbol)
3777 ;; The variable has to be set...
3778 (and gnus-use-long-file-name
3779 ;; If it isn't a list, then we return t.
3780 (or (not (listp gnus-use-long-file-name))
3781 ;; If it is a list, and the list contains `symbol', we
3783 (not (memq symbol gnus-use-long-file-name)))))
3785 ;; I suspect there's a better way, but I haven't taken the time to do
3786 ;; it yet. -erik selberg@cs.washington.edu
3787 (defun gnus-dd-mmm (messy-date)
3788 "Return a string like DD-MMM from a big messy string"
3789 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3795 ;; Make sure leading zeroes are stripped.
3796 (number-to-string (string-to-number (aref datevec 2)))
3800 (nth (1- (string-to-number (aref datevec 1)))
3801 timezone-months-assoc))
3804 (defun gnus-mode-string-quote (string)
3805 "Quote all \"%\" in STRING."
3807 (gnus-set-work-buffer)
3809 (goto-char (point-min))
3810 (while (search-forward "%" nil t)
3814 ;; Make a hash table (default and minimum size is 255).
3815 ;; Optional argument HASHSIZE specifies the table size.
3816 (defun gnus-make-hashtable (&optional hashsize)
3817 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3819 ;; Make a number that is suitable for hashing; bigger than MIN and one
3821 (defun gnus-create-hash-size (min)
3827 ;; Show message if message has a lower level than `gnus-verbose'.
3828 ;; Guideline for numbers:
3829 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3830 ;; for things that take a long time, 7 - not very important messages
3831 ;; on stuff, 9 - messages inside loops.
3832 (defun gnus-message (level &rest args)
3833 (if (<= level gnus-verbose)
3834 (apply 'message args)
3835 ;; We have to do this format thingy here even if the result isn't
3836 ;; shown - the return value has to be the same as the return value
3838 (apply 'format args)))
3840 (defun gnus-error (level &rest args)
3841 "Beep an error if LEVEL is equal to or less than `gnus-verbose'."
3842 (when (<= (floor level) gnus-verbose)
3843 (apply 'message args)
3846 (when (and (floatp level)
3847 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3848 (sit-for duration))))
3851 ;; Generate a unique new group name.
3852 (defun gnus-generate-new-group-name (leaf)
3855 (while (gnus-gethash name gnus-newsrc-hashtb)
3856 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3859 (defsubst gnus-hide-text (b e props)
3860 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3861 (gnus-add-text-properties b e props)
3862 (when (memq 'intangible props)
3863 (gnus-put-text-property (max (1- b) (point-min))
3864 b 'intangible (cddr (memq 'intangible props)))))
3866 (defsubst gnus-unhide-text (b e)
3867 "Remove hidden text properties from region between B and E."
3868 (remove-text-properties b e gnus-hidden-properties)
3869 (when (memq 'intangible gnus-hidden-properties)
3870 (gnus-put-text-property (max (1- b) (point-min))
3871 b 'intangible nil)))
3873 (defun gnus-hide-text-type (b e type)
3874 "Hide text of TYPE between B and E."
3875 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3877 (defun gnus-parent-headers (headers &optional generation)
3878 "Return the headers of the GENERATIONeth parent of HEADERS."
3880 (setq generation 1))
3881 (let (references parent)
3882 (while (and headers (not (zerop generation)))
3883 (setq references (mail-header-references headers))
3884 (when (and references
3885 (setq parent (gnus-parent-id references))
3886 (setq headers (car (gnus-id-to-thread parent))))
3890 (defun gnus-parent-id (references)
3891 "Return the last Message-ID in REFERENCES."
3892 (when (and references
3893 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3894 (substring references (match-beginning 1) (match-end 1))))
3896 (defun gnus-split-references (references)
3897 "Return a list of Message-IDs in REFERENCES."
3900 (while (string-match "<[^>]+>" references beg)
3901 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3905 (defun gnus-buffer-live-p (buffer)
3906 "Say whether BUFFER is alive or not."
3909 (buffer-name (get-buffer buffer))))
3911 (defun gnus-ephemeral-group-p (group)
3912 "Say whether GROUP is ephemeral or not."
3913 (gnus-group-get-parameter group 'quit-config))
3915 (defun gnus-group-quit-config (group)
3916 "Return the quit-config of GROUP."
3917 (gnus-group-get-parameter group 'quit-config))
3919 (defun gnus-simplify-mode-line ()
3920 "Make mode lines a bit simpler."
3921 (setq mode-line-modified "-- ")
3922 (when (listp mode-line-format)
3923 (make-local-variable 'mode-line-format)
3924 (setq mode-line-format (copy-sequence mode-line-format))
3925 (when (equal (nth 3 mode-line-format) " ")
3926 (setcar (nthcdr 3 mode-line-format) " "))))
3928 ;;; List and range functions
3930 (defun gnus-last-element (list)
3931 "Return last element of LIST."
3933 (setq list (cdr list)))
3936 (defun gnus-copy-sequence (list)
3937 "Do a complete, total copy of a list."
3938 (if (and (consp list) (not (consp (cdr list))))
3939 (cons (car list) (cdr list))
3940 (mapcar (lambda (elem) (if (consp elem)
3941 (if (consp (cdr elem))
3942 (gnus-copy-sequence elem)
3943 (cons (car elem) (cdr elem)))
3947 (defun gnus-set-difference (list1 list2)
3948 "Return a list of elements of LIST1 that do not appear in LIST2."
3949 (let ((list1 (copy-sequence list1)))
3951 (setq list1 (delq (car list2) list1))
3952 (setq list2 (cdr list2)))
3955 (defun gnus-sorted-complement (list1 list2)
3956 "Return a list of elements of LIST1 that do not appear in LIST2.
3957 Both lists have to be sorted over <."
3959 (if (or (null list1) (null list2))
3961 (while (and list1 list2)
3962 (cond ((= (car list1) (car list2))
3963 (setq list1 (cdr list1)
3965 ((< (car list1) (car list2))
3966 (setq out (cons (car list1) out))
3967 (setq list1 (cdr list1)))
3969 (setq out (cons (car list2) out))
3970 (setq list2 (cdr list2)))))
3971 (nconc (nreverse out) (or list1 list2)))))
3973 (defun gnus-intersection (list1 list2)
3976 (if (memq (car list2) list1)
3977 (setq result (cons (car list2) result)))
3978 (setq list2 (cdr list2)))
3981 (defun gnus-sorted-intersection (list1 list2)
3982 ;; LIST1 and LIST2 have to be sorted over <.
3984 (while (and list1 list2)
3985 (cond ((= (car list1) (car list2))
3986 (setq out (cons (car list1) out)
3989 ((< (car list1) (car list2))
3990 (setq list1 (cdr list1)))
3992 (setq list2 (cdr list2)))))
3995 (defun gnus-set-sorted-intersection (list1 list2)
3996 ;; LIST1 and LIST2 have to be sorted over <.
3997 ;; This function modifies LIST1.
3998 (let* ((top (cons nil list1))
4000 (while (and list1 list2)
4001 (cond ((= (car list1) (car list2))
4005 ((< (car list1) (car list2))
4006 (setcdr prev (cdr list1))
4007 (setq list1 (cdr list1)))
4009 (setq list2 (cdr list2)))))
4013 (defun gnus-compress-sequence (numbers &optional always-list)
4014 "Convert list of numbers to a list of ranges or a single range.
4015 If ALWAYS-LIST is non-nil, this function will always release a list of
4017 (let* ((first (car numbers))
4018 (last (car numbers))
4022 (if (not (listp (cdr numbers)))
4025 (cond ((= last (car numbers)) nil) ;Omit duplicated number
4026 ((= (1+ last) (car numbers)) ;Still in sequence
4027 (setq last (car numbers)))
4028 (t ;End of one sequence
4030 (cons (if (= first last) first
4031 (cons first last)) result))
4032 (setq first (car numbers))
4033 (setq last (car numbers))))
4034 (setq numbers (cdr numbers)))
4035 (if (and (not always-list) (null result))
4036 (if (= first last) (list first) (cons first last))
4037 (nreverse (cons (if (= first last) first (cons first last))
4040 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
4041 (defun gnus-uncompress-range (ranges)
4042 "Expand a list of ranges into a list of numbers.
4043 RANGES is either a single range on the form `(num . num)' or a list of
4045 (let (first last result)
4049 ((not (listp (cdr ranges)))
4050 (setq first (car ranges))
4051 (setq last (cdr ranges))
4052 (while (<= first last)
4053 (setq result (cons first result))
4054 (setq first (1+ first)))
4058 (if (atom (car ranges))
4059 (if (numberp (car ranges))
4060 (setq result (cons (car ranges) result)))
4061 (setq first (caar ranges))
4062 (setq last (cdar ranges))
4063 (while (<= first last)
4064 (setq result (cons first result))
4065 (setq first (1+ first))))
4066 (setq ranges (cdr ranges)))
4067 (nreverse result)))))
4069 (defun gnus-add-to-range (ranges list)
4070 "Return a list of ranges that has all articles from both RANGES and LIST.
4071 Note: LIST has to be sorted over `<'."
4073 (gnus-compress-sequence list t)
4074 (setq list (copy-sequence list))
4075 (or (listp (cdr ranges))
4076 (setq ranges (list ranges)))
4078 ilist lowest highest temp)
4079 (while (and ranges list)
4081 (setq lowest (or (and (atom (car ranges)) (car ranges))
4083 (while (and list (cdr list) (< (cadr list) lowest))
4084 (setq list (cdr list)))
4085 (if (< (car ilist) lowest)
4088 (setq list (cdr list))
4090 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4091 (setq highest (or (and (atom (car ranges)) (car ranges))
4093 (while (and list (<= (car list) highest))
4094 (setq list (cdr list)))
4095 (setq ranges (cdr ranges)))
4097 (setq out (nconc (gnus-compress-sequence list t) out)))
4098 (setq out (sort out (lambda (r1 r2)
4099 (< (or (and (atom r1) r1) (car r1))
4100 (or (and (atom r2) r2) (car r2))))))
4103 (if (atom (car ranges))
4105 (if (atom (cadr ranges))
4106 (if (= (1+ (car ranges)) (cadr ranges))
4108 (setcar ranges (cons (car ranges)
4110 (setcdr ranges (cddr ranges))))
4111 (if (= (1+ (car ranges)) (caadr ranges))
4113 (setcar (cadr ranges) (car ranges))
4114 (setcar ranges (cadr ranges))
4115 (setcdr ranges (cddr ranges))))))
4117 (if (atom (cadr ranges))
4118 (if (= (1+ (cdar ranges)) (cadr ranges))
4120 (setcdr (car ranges) (cadr ranges))
4121 (setcdr ranges (cddr ranges))))
4122 (if (= (1+ (cdar ranges)) (caadr ranges))
4124 (setcdr (car ranges) (cdadr ranges))
4125 (setcdr ranges (cddr ranges)))))))
4126 (setq ranges (cdr ranges)))
4129 (defun gnus-remove-from-range (ranges list)
4130 "Return a list of ranges that has all articles from LIST removed from RANGES.
4131 Note: LIST has to be sorted over `<'."
4132 ;; !!! This function shouldn't look like this, but I've got a headache.
4133 (gnus-compress-sequence
4134 (gnus-sorted-complement
4135 (gnus-uncompress-range ranges) list)))
4137 (defun gnus-member-of-range (number ranges)
4138 (if (not (listp (cdr ranges)))
4139 (and (>= number (car ranges))
4140 (<= number (cdr ranges)))
4143 (if (numberp (car ranges))
4144 (>= number (car ranges))
4145 (>= number (caar ranges)))
4147 (if (if (numberp (car ranges))
4148 (= number (car ranges))
4149 (and (>= number (caar ranges))
4150 (<= number (cdar ranges))))
4151 (setq not-stop nil))
4152 (setq ranges (cdr ranges)))
4155 (defun gnus-range-length (range)
4156 "Return the length RANGE would have if uncompressed."
4157 (length (gnus-uncompress-range range)))
4159 (defun gnus-sublist-p (list sublist)
4160 "Test whether all elements in SUBLIST are members of LIST."
4163 (unless (memq (pop sublist) list)
4173 (defvar gnus-group-mode-map nil)
4174 (put 'gnus-group-mode 'mode-class 'special)
4176 (unless gnus-group-mode-map
4177 (setq gnus-group-mode-map (make-keymap))
4178 (suppress-keymap gnus-group-mode-map)
4180 (gnus-define-keys gnus-group-mode-map
4181 " " gnus-group-read-group
4182 "=" gnus-group-select-group
4183 "\r" gnus-group-select-group
4184 "\M-\r" gnus-group-quick-select-group
4185 "j" gnus-group-jump-to-group
4186 "n" gnus-group-next-unread-group
4187 "p" gnus-group-prev-unread-group
4188 "\177" gnus-group-prev-unread-group
4189 [delete] gnus-group-prev-unread-group
4190 "N" gnus-group-next-group
4191 "P" gnus-group-prev-group
4192 "\M-n" gnus-group-next-unread-group-same-level
4193 "\M-p" gnus-group-prev-unread-group-same-level
4194 "," gnus-group-best-unread-group
4195 "." gnus-group-first-unread-group
4196 "u" gnus-group-unsubscribe-current-group
4197 "U" gnus-group-unsubscribe-group
4198 "c" gnus-group-catchup-current
4199 "C" gnus-group-catchup-current-all
4200 "l" gnus-group-list-groups
4201 "L" gnus-group-list-all-groups
4203 "g" gnus-group-get-new-news
4204 "\M-g" gnus-group-get-new-news-this-group
4205 "R" gnus-group-restart
4206 "r" gnus-group-read-init-file
4207 "B" gnus-group-browse-foreign-server
4208 "b" gnus-group-check-bogus-groups
4209 "F" gnus-find-new-newsgroups
4210 "\C-c\C-d" gnus-group-describe-group
4211 "\M-d" gnus-group-describe-all-groups
4212 "\C-c\C-a" gnus-group-apropos
4213 "\C-c\M-\C-a" gnus-group-description-apropos
4214 "a" gnus-group-post-news
4215 "\ek" gnus-group-edit-local-kill
4216 "\eK" gnus-group-edit-global-kill
4217 "\C-k" gnus-group-kill-group
4218 "\C-y" gnus-group-yank-group
4219 "\C-w" gnus-group-kill-region
4220 "\C-x\C-t" gnus-group-transpose-groups
4221 "\C-c\C-l" gnus-group-list-killed
4222 "\C-c\C-x" gnus-group-expire-articles
4223 "\C-c\M-\C-x" gnus-group-expire-all-groups
4225 "s" gnus-group-save-newsrc
4226 "z" gnus-group-suspend
4227 ; "Z" gnus-group-clear-dribble
4230 "?" gnus-group-describe-briefly
4231 "\C-c\C-i" gnus-info-find-node
4232 "\M-e" gnus-group-edit-group-method
4233 "^" gnus-group-enter-server-mode
4234 gnus-mouse-2 gnus-mouse-pick-group
4235 "<" beginning-of-buffer
4238 "\C-c\C-s" gnus-group-sort-groups
4240 "\C-c\M-g" gnus-activate-all-groups
4241 "\M-&" gnus-group-universal-argument
4242 "#" gnus-group-mark-group
4243 "\M-#" gnus-group-unmark-group)
4245 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4246 "m" gnus-group-mark-group
4247 "u" gnus-group-unmark-group
4248 "w" gnus-group-mark-region
4249 "m" gnus-group-mark-buffer
4250 "r" gnus-group-mark-regexp
4251 "U" gnus-group-unmark-all-groups)
4253 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4254 "d" gnus-group-make-directory-group
4255 "h" gnus-group-make-help-group
4256 "a" gnus-group-make-archive-group
4257 "k" gnus-group-make-kiboze-group
4258 "m" gnus-group-make-group
4259 "E" gnus-group-edit-group
4260 "e" gnus-group-edit-group-method
4261 "p" gnus-group-edit-group-parameters
4262 "v" gnus-group-add-to-virtual
4263 "V" gnus-group-make-empty-virtual
4264 "D" gnus-group-enter-directory
4265 "f" gnus-group-make-doc-group
4266 "r" gnus-group-rename-group
4267 "\177" gnus-group-delete-group
4268 [delete] gnus-group-delete-group)
4270 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4271 "b" gnus-group-brew-soup
4272 "w" gnus-soup-save-areas
4273 "s" gnus-soup-send-replies
4274 "p" gnus-soup-pack-packet
4275 "r" nnsoup-pack-replies)
4277 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4278 "s" gnus-group-sort-groups
4279 "a" gnus-group-sort-groups-by-alphabet
4280 "u" gnus-group-sort-groups-by-unread
4281 "l" gnus-group-sort-groups-by-level
4282 "v" gnus-group-sort-groups-by-score
4283 "r" gnus-group-sort-groups-by-rank
4284 "m" gnus-group-sort-groups-by-method)
4286 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4287 "k" gnus-group-list-killed
4288 "z" gnus-group-list-zombies
4289 "s" gnus-group-list-groups
4290 "u" gnus-group-list-all-groups
4291 "A" gnus-group-list-active
4292 "a" gnus-group-apropos
4293 "d" gnus-group-description-apropos
4294 "m" gnus-group-list-matching
4295 "M" gnus-group-list-all-matching
4296 "l" gnus-group-list-level)
4298 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4299 "f" gnus-score-flush-cache)
4301 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4302 "f" gnus-group-fetch-faq)
4304 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4305 "l" gnus-group-set-current-level
4306 "t" gnus-group-unsubscribe-current-group
4307 "s" gnus-group-unsubscribe-group
4308 "k" gnus-group-kill-group
4309 "y" gnus-group-yank-group
4310 "w" gnus-group-kill-region
4311 "\C-k" gnus-group-kill-level
4312 "z" gnus-group-kill-all-zombies))
4314 (defun gnus-group-mode ()
4315 "Major mode for reading news.
4317 All normal editing commands are switched off.
4318 \\<gnus-group-mode-map>
4319 The group buffer lists (some of) the groups available. For instance,
4320 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4321 lists all zombie groups.
4323 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4324 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4326 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4328 The following commands are available:
4330 \\{gnus-group-mode-map}"
4332 (when (and menu-bar-mode
4333 (gnus-visual-p 'group-menu 'menu))
4334 (gnus-group-make-menu-bar))
4335 (kill-all-local-variables)
4336 (gnus-simplify-mode-line)
4337 (setq major-mode 'gnus-group-mode)
4338 (setq mode-name "Group")
4339 (gnus-group-set-mode-line)
4340 (setq mode-line-process nil)
4341 (use-local-map gnus-group-mode-map)
4342 (buffer-disable-undo (current-buffer))
4343 (setq truncate-lines t)
4344 (setq buffer-read-only t)
4345 (gnus-make-local-hook 'post-command-hook)
4346 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4347 (run-hooks 'gnus-group-mode-hook))
4349 (defun gnus-clear-inboxes-moved ()
4350 (setq nnmail-moved-inboxes nil))
4352 (defun gnus-mouse-pick-group (e)
4353 "Enter the group under the mouse pointer."
4356 (gnus-group-read-group nil))
4358 ;; Look at LEVEL and find out what the level is really supposed to be.
4359 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4360 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4361 (defun gnus-group-default-level (&optional level number-or-nil)
4363 (gnus-group-use-permanent-levels
4364 (or (setq gnus-group-use-permanent-levels
4365 (or level (if (numberp gnus-group-use-permanent-levels)
4366 gnus-group-use-permanent-levels
4367 (or gnus-group-default-list-level
4368 gnus-level-subscribed))))
4369 gnus-group-default-list-level gnus-level-subscribed))
4373 (or level gnus-group-default-list-level gnus-level-subscribed))))
4376 (defun gnus-slave-no-server (&optional arg)
4377 "Read network news as a slave, without connecting to local server"
4379 (gnus-no-server arg t))
4382 (defun gnus-no-server (&optional arg slave)
4384 If ARG is a positive number, Gnus will use that as the
4385 startup level. If ARG is nil, Gnus will be started at level 2.
4386 If ARG is non-nil and not a positive number, Gnus will
4387 prompt the user for the name of an NNTP server to use.
4388 As opposed to `gnus', this command will not connect to the local server."
4390 (let ((val (or arg (1- gnus-level-default-subscribed))))
4392 (make-local-variable 'gnus-group-use-permanent-levels)
4393 (setq gnus-group-use-permanent-levels val)))
4396 (defun gnus-slave (&optional arg)
4397 "Read news as a slave."
4399 (gnus arg nil 'slave))
4402 (defun gnus-other-frame (&optional arg)
4403 "Pop up a frame to read news."
4405 (if (get-buffer gnus-group-buffer)
4406 (let ((pop-up-frames t))
4408 (select-frame (make-frame))
4412 (defun gnus (&optional arg dont-connect slave)
4414 If ARG is non-nil and a positive number, Gnus will use that as the
4415 startup level. If ARG is non-nil and not a positive number, Gnus will
4416 prompt the user for the name of an NNTP server to use."
4419 (if (get-buffer gnus-group-buffer)
4421 (switch-to-buffer gnus-group-buffer)
4422 (gnus-group-get-new-news))
4425 (nnheader-init-server-buffer)
4426 (gnus-read-init-file)
4427 (setq gnus-slave slave)
4429 (gnus-group-setup-buffer)
4430 (let ((buffer-read-only nil))
4432 (if (not gnus-inhibit-startup-message)
4434 (gnus-group-startup-message)
4437 (let ((level (and (numberp arg) (> arg 0) arg))
4443 (gnus-start-news-server (and arg (not level))))))
4444 (if (and (not dont-connect)
4447 (run-hooks 'gnus-startup-hook)
4448 ;; NNTP server is successfully open.
4450 ;; Find the current startup file name.
4451 (setq gnus-current-startup-file
4452 (gnus-make-newsrc-file gnus-startup-file))
4454 ;; Read the dribble file.
4455 (when (or gnus-slave gnus-use-dribble-file)
4456 (gnus-dribble-read-file))
4458 ;; Allow using GroupLens predictions.
4459 (when gnus-use-grouplens
4461 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4463 (gnus-summary-make-display-table)
4464 ;; Do the actual startup.
4465 (gnus-setup-news nil level dont-connect)
4466 ;; Generate the group buffer.
4467 (gnus-group-list-groups level)
4468 (gnus-group-first-unread-group)
4469 (gnus-configure-windows 'group)
4470 (gnus-group-set-mode-line))))))
4472 (defun gnus-unload ()
4473 "Unload all Gnus features."
4475 (or (boundp 'load-history)
4476 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4477 (let ((history load-history)
4480 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4481 (setq feature (cdr (assq 'provide (car history))))
4482 (unload-feature feature 'force))
4483 (setq history (cdr history)))))
4485 (defun gnus-compile ()
4486 "Byte-compile the user-defined format specs."
4488 (let ((entries gnus-format-specs)
4489 entry gnus-tmp-func)
4491 (gnus-message 7 "Compiling format specs...")
4494 (setq entry (pop entries))
4495 (if (eq (car entry) 'version)
4496 (setq gnus-format-specs (delq entry gnus-format-specs))
4497 (when (and (listp (caddr entry))
4498 (not (eq 'byte-code (caaddr entry))))
4499 (fset 'gnus-tmp-func
4500 `(lambda () ,(caddr entry)))
4501 (byte-compile 'gnus-tmp-func)
4502 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4504 (push (cons 'version emacs-version) gnus-format-specs)
4505 ;; Mark the .newsrc.eld file as "dirty".
4506 (gnus-dribble-enter " ")
4507 (gnus-message 7 "Compiling user specs...done"))))
4509 (defun gnus-indent-rigidly (start end arg)
4510 "Indent rigidly using only spaces and no tabs."
4513 (narrow-to-region start end)
4514 (indent-rigidly start end arg)
4515 (goto-char (point-min))
4516 (while (search-forward "\t" nil t)
4517 (replace-match " " t t)))))
4519 (defun gnus-group-startup-message (&optional x y)
4520 "Insert startup message in current buffer."
4521 ;; Insert the message.
4526 _ ___ __ ___ __ _ ___
4545 ;; And then hack it.
4546 (gnus-indent-rigidly (point-min) (point-max)
4547 (/ (max (- (window-width) (or x 46)) 0) 2))
4548 (goto-char (point-min))
4550 (let* ((pheight (count-lines (point-min) (point-max)))
4551 (wheight (window-height))
4552 (rest (- wheight pheight)))
4553 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4555 (goto-char (point-min))
4556 (and (search-forward "Praxis" nil t)
4557 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4558 (goto-char (point-min))
4559 (let* ((mode-string (gnus-group-set-mode-line)))
4560 (setq mode-line-buffer-identification
4561 (list (concat gnus-version (substring (car mode-string) 4))))
4562 (set-buffer-modified-p t)))
4564 (defun gnus-group-setup-buffer ()
4565 (or (get-buffer gnus-group-buffer)
4567 (switch-to-buffer gnus-group-buffer)
4568 (gnus-add-current-to-buffer-list)
4570 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4572 (defun gnus-group-list-groups (&optional level unread lowest)
4573 "List newsgroups with level LEVEL or lower that have unread articles.
4574 Default is all subscribed groups.
4575 If argument UNREAD is non-nil, groups with no unread articles are also
4577 (interactive (list (if current-prefix-arg
4578 (prefix-numeric-value current-prefix-arg)
4580 (gnus-group-default-level nil t)
4581 gnus-group-default-list-level
4582 gnus-level-subscribed))))
4584 (setq level (car gnus-group-list-mode)
4585 unread (cdr gnus-group-list-mode)))
4586 (setq level (gnus-group-default-level level))
4587 (gnus-group-setup-buffer) ;May call from out of group buffer
4588 (gnus-update-format-specifications)
4589 (let ((case-fold-search nil)
4590 (props (text-properties-at (gnus-point-at-bol)))
4591 (group (gnus-group-group-name)))
4592 (set-buffer gnus-group-buffer)
4593 (funcall gnus-group-prepare-function level unread lowest)
4594 (if (zerop (buffer-size))
4595 (gnus-message 5 gnus-no-groups-message)
4596 (goto-char (point-max))
4597 (when (or (not gnus-group-goto-next-group-function)
4598 (not (funcall gnus-group-goto-next-group-function
4601 ;; Go to the first group with unread articles.
4602 (gnus-group-search-forward t)
4603 ;; Find the right group to put point on. If the current group
4604 ;; has disappeared in the new listing, try to find the next
4605 ;; one. If no next one can be found, just leave point at the
4606 ;; first newsgroup in the buffer.
4607 (if (not (gnus-goto-char
4609 (point-min) (point-max)
4610 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4611 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4613 (not (gnus-goto-char
4615 (point-min) (point-max) 'gnus-group
4617 (caar newsrc) gnus-active-hashtb)))))
4618 (setq newsrc (cdr newsrc)))
4619 (or newsrc (progn (goto-char (point-max))
4620 (forward-line -1)))))))
4621 ;; Adjust cursor point.
4622 (gnus-group-position-point))))
4624 (defun gnus-group-list-level (level &optional all)
4625 "List groups on LEVEL.
4626 If ALL (the prefix), also list groups that have no unread articles."
4627 (interactive "nList groups on level: \nP")
4628 (gnus-group-list-groups level all level))
4630 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4631 "List all newsgroups with unread articles of level LEVEL or lower.
4632 If ALL is non-nil, list groups that have no unread articles.
4633 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4634 If REGEXP, only list groups matching REGEXP."
4635 (set-buffer gnus-group-buffer)
4636 (let ((buffer-read-only nil)
4637 (newsrc (cdr gnus-newsrc-alist))
4638 (lowest (or lowest 1))
4639 info clevel unread group params)
4641 (if (< lowest gnus-level-zombie)
4642 ;; List living groups.
4644 (setq info (car newsrc)
4645 group (gnus-info-group info)
4646 params (gnus-info-params info)
4648 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4649 (and unread ; This group might be bogus
4651 (string-match regexp group))
4652 (<= (setq clevel (gnus-info-level info)) level)
4654 (or all ; We list all groups?
4655 (if (eq unread t) ; Unactivated?
4656 gnus-group-list-inactive-groups ; We list unactivated
4657 (> unread 0)) ; We list groups with unread articles
4658 (and gnus-list-groups-with-ticked-articles
4659 (cdr (assq 'tick (gnus-info-marks info))))
4660 ; And groups with tickeds
4661 ;; Check for permanent visibility.
4662 (and gnus-permanently-visible-groups
4663 (string-match gnus-permanently-visible-groups
4665 (memq 'visible params)
4666 (cdr (assq 'visible params)))
4667 (gnus-group-insert-group-line
4668 group (gnus-info-level info)
4669 (gnus-info-marks info) unread (gnus-info-method info)))))
4671 ;; List dead groups.
4672 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4673 (gnus-group-prepare-flat-list-dead
4674 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4675 gnus-level-zombie ?Z
4677 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4678 (gnus-group-prepare-flat-list-dead
4679 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4680 gnus-level-killed ?K regexp))
4682 (gnus-group-set-mode-line)
4683 (setq gnus-group-list-mode (cons level all))
4684 (run-hooks 'gnus-group-prepare-hook)))
4686 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4687 ;; List zombies and killed lists somewhat faster, which was
4688 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4689 ;; this by ignoring the group format specification altogether.
4692 ;; This loop is used when listing groups that match some
4695 (setq group (pop groups))
4696 (when (string-match regexp group)
4697 (gnus-add-text-properties
4698 (point) (prog1 (1+ (point))
4699 (insert " " mark " *: " group "\n"))
4700 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4702 'gnus-level level))))
4703 ;; This loop is used when listing all groups.
4705 (gnus-add-text-properties
4706 (point) (prog1 (1+ (point))
4707 (insert " " mark " *: "
4708 (setq group (pop groups)) "\n"))
4709 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4711 'gnus-level level))))))
4713 (defmacro gnus-group-real-name (group)
4714 "Find the real name of a foreign newsgroup."
4715 `(let ((gname ,group))
4716 (if (string-match ":[^:]+$" gname)
4717 (substring gname (1+ (match-beginning 0)))
4720 (defsubst gnus-server-add-address (method)
4721 (let ((method-name (symbol-name (car method))))
4722 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4723 (not (assq (intern (concat method-name "-address")) method)))
4724 (append method (list (list (intern (concat method-name "-address"))
4728 (defsubst gnus-server-get-method (group method)
4729 ;; Input either a server name, and extended server name, or a
4730 ;; select method, and return a select method.
4731 (cond ((stringp method)
4732 (gnus-server-to-method method))
4733 ((equal method gnus-select-method)
4735 ((and (stringp (car method)) group)
4736 (gnus-server-extend-method group method))
4737 ((and method (not group)
4738 (equal (cadr method) ""))
4741 (gnus-server-add-address method))))
4743 (defun gnus-server-to-method (server)
4744 "Map virtual server names to select methods."
4746 ;; Is this a method, perhaps?
4747 (and server (listp server) server)
4748 ;; Perhaps this is the native server?
4749 (and (equal server "native") gnus-select-method)
4750 ;; It should be in the server alist.
4751 (cdr (assoc server gnus-server-alist))
4752 ;; If not, we look through all the opened server
4753 ;; to see whether we can find it there.
4754 (let ((opened gnus-opened-servers))
4756 (not (equal server (format "%s:%s" (caaar opened)
4761 (defmacro gnus-method-equal (ss1 ss2)
4762 "Say whether two servers are equal."
4766 (and (= (length s1) (length s2))
4768 (while (and s1 (member (car s1) s2))
4772 (defun gnus-server-equal (m1 m2)
4773 "Say whether two methods are equal."
4774 (let ((m1 (cond ((null m1) gnus-select-method)
4775 ((stringp m1) (gnus-server-to-method m1))
4777 (m2 (cond ((null m2) gnus-select-method)
4778 ((stringp m2) (gnus-server-to-method m2))
4780 (gnus-method-equal m1 m2)))
4782 (defun gnus-servers-using-backend (backend)
4783 "Return a list of known servers using BACKEND."
4784 (let ((opened gnus-opened-servers)
4787 (when (eq backend (caaar opened))
4788 (push (caar opened) out))
4792 (defun gnus-archive-server-wanted-p ()
4793 "Say whether the user wants to use the archive server."
4795 ((or (not gnus-message-archive-method)
4796 (not gnus-message-archive-group))
4798 ((and gnus-message-archive-method gnus-message-archive-group)
4801 (let ((active (cadr (assq 'nnfolder-active-file
4802 gnus-message-archive-method))))
4804 (file-exists-p active))))))
4806 (defun gnus-group-prefixed-name (group method)
4807 "Return the whole name from GROUP and METHOD."
4808 (and (stringp method) (setq method (gnus-server-to-method method)))
4809 (concat (format "%s" (car method))
4811 (or (assoc (format "%s" (car method))
4812 (gnus-methods-using 'address))
4813 (gnus-server-equal method gnus-message-archive-method))
4815 (not (string= (nth 1 method) "")))
4816 (concat "+" (nth 1 method)))
4819 (defun gnus-group-real-prefix (group)
4820 "Return the prefix of the current group name."
4821 (if (string-match "^[^:]+:" group)
4822 (substring group 0 (match-end 0))
4825 (defun gnus-group-method (group)
4826 "Return the server or method used for selecting GROUP."
4827 (let ((prefix (gnus-group-real-prefix group)))
4828 (if (equal prefix "")
4830 (let ((servers gnus-opened-servers)
4832 backend possible found)
4833 (if (string-match "^[^\\+]+\\+" prefix)
4834 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4835 server (substring prefix (match-end 0) (1- (length prefix))))
4836 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4838 (when (eq (caaar servers) backend)
4839 (setq possible (caar servers))
4840 (when (equal (cadaar servers) server)
4841 (setq found (caar servers))))
4843 (or (car (rassoc found gnus-server-alist))
4845 (car (rassoc possible gnus-server-alist))
4847 (list backend server))))))
4849 (defsubst gnus-secondary-method-p (method)
4850 "Return whether METHOD is a secondary select method."
4851 (let ((methods gnus-secondary-select-methods)
4852 (gmethod (gnus-server-get-method nil method)))
4854 (not (equal (gnus-server-get-method nil (car methods))
4856 (setq methods (cdr methods)))
4859 (defun gnus-group-foreign-p (group)
4860 "Say whether a group is foreign or not."
4861 (and (not (gnus-group-native-p group))
4862 (not (gnus-group-secondary-p group))))
4864 (defun gnus-group-native-p (group)
4865 "Say whether the group is native or not."
4866 (not (string-match ":" group)))
4868 (defun gnus-group-secondary-p (group)
4869 "Say whether the group is secondary or not."
4870 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4872 (defun gnus-group-get-parameter (group &optional symbol)
4873 "Returns the group parameters for GROUP.
4874 If SYMBOL, return the value of that symbol in the group parameters."
4875 (let ((params (gnus-info-params (gnus-get-info group))))
4877 (gnus-group-parameter-value params symbol)
4880 (defun gnus-group-parameter-value (params symbol)
4881 "Return the value of SYMBOL in group PARAMS."
4882 (or (car (memq symbol params)) ; It's either a simple symbol
4883 (cdr (assq symbol params)))) ; or a cons.
4885 (defun gnus-group-add-parameter (group param)
4886 "Add parameter PARAM to GROUP."
4887 (let ((info (gnus-get-info group)))
4889 () ; This is a dead group. We just ignore it.
4890 ;; Cons the new param to the old one and update.
4891 (gnus-group-set-info (cons param (gnus-info-params info))
4894 (defun gnus-group-set-parameter (group name value)
4895 "Set parameter NAME to VALUE in GROUP."
4896 (let ((info (gnus-get-info group)))
4898 () ; This is a dead group. We just ignore it.
4899 (let ((old-params (gnus-info-params info))
4900 (new-params (list (cons name value))))
4902 (if (or (not (listp (car old-params)))
4903 (not (eq (caar old-params) name)))
4904 (setq new-params (append new-params (list (car old-params)))))
4905 (setq old-params (cdr old-params)))
4906 (gnus-group-set-info new-params group 'params)))))
4908 (defun gnus-group-add-score (group &optional score)
4909 "Add SCORE to the GROUP score.
4910 If SCORE is nil, add 1 to the score of GROUP."
4911 (let ((info (gnus-get-info group)))
4913 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4915 (defun gnus-summary-bubble-group ()
4916 "Increase the score of the current group.
4917 This is a handy function to add to `gnus-summary-exit-hook' to
4918 increase the score of each group you read."
4919 (gnus-group-add-score gnus-newsgroup-name))
4921 (defun gnus-group-set-info (info &optional method-only-group part)
4922 (let* ((entry (gnus-gethash
4923 (or method-only-group (gnus-info-group info))
4924 gnus-newsrc-hashtb))
4926 (info (if method-only-group (nth 2 entry) info))
4928 (when method-only-group
4930 (error "Trying to change non-existent group %s" method-only-group))
4931 ;; We have received parts of the actual group info - either the
4932 ;; select method or the group parameters. We first check
4933 ;; whether we have to extend the info, and if so, do that.
4934 (let ((len (length info))
4935 (total (if (eq part 'method) 5 6)))
4937 (setcdr (nthcdr (1- len) info)
4938 (make-list (- total len) nil)))
4939 ;; Then we enter the new info.
4940 (setcar (nthcdr (1- total) info) part-info)))
4942 ;; This is a new group, so we just create it.
4944 (set-buffer gnus-group-buffer)
4945 (setq method (gnus-info-method info))
4946 (when (gnus-server-equal method "native")
4949 (set-buffer gnus-group-buffer)
4951 ;; It's a foreign group...
4952 (gnus-group-make-group
4953 (gnus-group-real-name (gnus-info-group info))
4954 (if (stringp method) method
4955 (prin1-to-string (car method)))
4957 (nth 1 (gnus-info-method info))))
4958 ;; It's a native group.
4959 (gnus-group-make-group (gnus-info-group info))))
4960 (gnus-message 6 "Note: New group created")
4962 (gnus-gethash (gnus-group-prefixed-name
4963 (gnus-group-real-name (gnus-info-group info))
4964 (or (gnus-info-method info) gnus-select-method))
4965 gnus-newsrc-hashtb))))
4966 ;; Whether it was a new group or not, we now have the entry, so we
4967 ;; can do the update.
4970 (setcar (nthcdr 2 entry) info)
4971 (when (and (not (eq (car entry) t))
4972 (gnus-active (gnus-info-group info)))
4973 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4974 (error "No such group: %s" (gnus-info-group info)))))
4976 (defun gnus-group-set-method-info (group select-method)
4977 (gnus-group-set-info select-method group 'method))
4979 (defun gnus-group-set-params-info (group params)
4980 (gnus-group-set-info params group 'params))
4982 (defun gnus-group-update-group-line ()
4983 "Update the current line in the group buffer."
4984 (let* ((buffer-read-only nil)
4985 (group (gnus-group-group-name))
4986 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4987 gnus-group-indentation)
4990 (not (gnus-ephemeral-group-p group))
4992 (concat "(gnus-group-set-info '"
4993 (prin1-to-string (nth 2 entry)) ")")))
4994 (setq gnus-group-indentation (gnus-group-group-indentation))
4996 (gnus-group-insert-group-line-info group)
4998 (gnus-group-position-point))))
5000 (defun gnus-group-insert-group-line-info (group)
5001 "Insert GROUP on the current line."
5002 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
5006 ;; (Un)subscribed group.
5007 (setq info (nth 2 entry))
5008 (gnus-group-insert-group-line
5009 group (gnus-info-level info) (gnus-info-marks info)
5010 (or (car entry) t) (gnus-info-method info)))
5011 ;; This group is dead.
5012 (gnus-group-insert-group-line
5014 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
5016 (if (setq active (gnus-active group))
5017 (- (1+ (cdr active)) (car active)) 0)
5020 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
5021 gnus-tmp-marked number
5023 "Insert a group line in the group buffer."
5024 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
5025 (gnus-tmp-number-total
5027 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
5029 (gnus-tmp-number-of-unread
5030 (if (numberp number) (int-to-string (max 0 number))
5032 (gnus-tmp-number-of-read
5033 (if (numberp number)
5034 (int-to-string (max 0 (- gnus-tmp-number-total number)))
5036 (gnus-tmp-subscribed
5037 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
5038 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
5039 ((= gnus-tmp-level gnus-level-zombie) ?Z)
5041 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
5042 (gnus-tmp-newsgroup-description
5043 (if gnus-description-hashtb
5044 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
5047 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
5048 (gnus-tmp-moderated-string
5049 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
5051 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
5052 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
5053 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
5054 (gnus-tmp-news-method-string
5056 (format "(%s:%s)" (car gnus-tmp-method)
5057 (cadr gnus-tmp-method)) ""))
5058 (gnus-tmp-marked-mark
5059 (if (and (numberp number)
5061 (cdr (assq 'tick gnus-tmp-marked)))
5063 (gnus-tmp-process-marked
5064 (if (member gnus-tmp-group gnus-group-marked)
5065 gnus-process-mark ? ))
5067 (or (and gnus-use-grouplens
5068 (bbb-grouplens-group-p gnus-tmp-group))
5070 (buffer-read-only nil)
5071 header gnus-tmp-header) ; passed as parameter to user-funcs.
5073 (gnus-add-text-properties
5077 (eval gnus-group-line-format-spec))
5078 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5079 gnus-unread ,(if (numberp number)
5080 (string-to-int gnus-tmp-number-of-unread)
5082 gnus-marked ,gnus-tmp-marked-mark
5083 gnus-indentation ,gnus-group-indentation
5084 gnus-level ,gnus-tmp-level))
5085 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5087 (run-hooks 'gnus-group-update-hook)
5089 ;; Allow XEmacs to remove front-sticky text properties.
5090 (gnus-group-remove-excess-properties)))
5092 (defun gnus-group-update-group (group &optional visible-only)
5093 "Update all lines where GROUP appear.
5094 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5097 (set-buffer gnus-group-buffer)
5098 ;; The buffer may be narrowed.
5101 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5103 found buffer-read-only)
5104 ;; Enter the current status into the dribble buffer.
5105 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5106 (if (and entry (not (gnus-ephemeral-group-p group)))
5108 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5110 ;; Find all group instances. If topics are in use, each group
5111 ;; may be listed in more than once.
5112 (while (setq loc (text-property-any
5113 loc (point-max) 'gnus-group ident))
5116 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5118 (gnus-group-insert-group-line-info group)
5121 (run-hooks 'gnus-group-update-group-hook)))
5122 (setq loc (1+ loc)))
5123 (unless (or found visible-only)
5124 ;; No such line in the buffer, find out where it's supposed to
5125 ;; go, and insert it there (or at the end of the buffer).
5126 (if gnus-goto-missing-group-function
5127 (funcall gnus-goto-missing-group-function group)
5128 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5129 (while (and entry (car entry)
5133 (point-min) (point-max)
5134 'gnus-group (gnus-intern-safe
5135 (caar entry) gnus-active-hashtb)))))
5136 (setq entry (cdr entry)))
5137 (or entry (goto-char (point-max)))))
5138 ;; Finally insert the line.
5139 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5140 (gnus-group-insert-group-line-info group)
5143 (run-hooks 'gnus-group-update-group-hook))))
5144 (gnus-group-set-mode-line)))))
5146 (defun gnus-group-set-mode-line ()
5147 "Update the mode line in the group buffer."
5148 (when (memq 'group gnus-updated-mode-lines)
5149 ;; Yes, we want to keep this mode line updated.
5151 (set-buffer gnus-group-buffer)
5152 (let* ((gformat (or gnus-group-mode-line-format-spec
5153 (setq gnus-group-mode-line-format-spec
5155 gnus-group-mode-line-format
5156 gnus-group-mode-line-format-alist))))
5157 (gnus-tmp-news-server (cadr gnus-select-method))
5158 (gnus-tmp-news-method (car gnus-select-method))
5159 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5161 gnus-tmp-header ;Dummy binding for user-defined formats
5162 ;; Get the resulting string.
5164 (and gnus-dribble-buffer
5165 (buffer-name gnus-dribble-buffer)
5166 (buffer-modified-p gnus-dribble-buffer)
5168 (set-buffer gnus-dribble-buffer)
5169 (not (zerop (buffer-size))))))
5170 (mode-string (eval gformat)))
5171 ;; Say whether the dribble buffer has been modified.
5172 (setq mode-line-modified
5173 (if modified "---*- " "----- "))
5174 ;; If the line is too long, we chop it off.
5175 (when (> (length mode-string) max-len)
5176 (setq mode-string (substring mode-string 0 (- max-len 4))))
5178 (setq mode-line-buffer-identification
5179 (gnus-mode-line-buffer-identification
5180 (list mode-string)))
5181 (set-buffer-modified-p modified))))))
5183 (defun gnus-group-group-name ()
5184 "Get the name of the newsgroup on the current line."
5185 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5186 (and group (symbol-name group))))
5188 (defun gnus-group-group-level ()
5189 "Get the level of the newsgroup on the current line."
5190 (get-text-property (gnus-point-at-bol) 'gnus-level))
5192 (defun gnus-group-group-indentation ()
5193 "Get the indentation of the newsgroup on the current line."
5194 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5195 (and gnus-group-indentation-function
5196 (funcall gnus-group-indentation-function))
5199 (defun gnus-group-group-unread ()
5200 "Get the number of unread articles of the newsgroup on the current line."
5201 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5203 (defun gnus-group-search-forward (&optional backward all level first-too)
5204 "Find the next newsgroup with unread articles.
5205 If BACKWARD is non-nil, find the previous newsgroup instead.
5206 If ALL is non-nil, just find any newsgroup.
5207 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5209 If FIRST-TOO, the current line is also eligible as a target."
5210 (let ((way (if backward -1 1))
5211 (low gnus-level-killed)
5214 (if (and backward (progn (beginning-of-line)) (bobp))
5216 (or first-too (forward-line way))
5224 (get-text-property (point) 'gnus-unread)))
5225 (and (numberp unread) (> unread 0)))
5226 (setq lev (get-text-property (point)
5228 (<= lev gnus-level-subscribed)))
5230 (and (setq lev (get-text-property (point)
5239 (zerop (forward-line way)))))
5241 (progn (gnus-group-position-point) t)
5242 (goto-char (or pos beg))
5245 ;;; Gnus group mode commands
5249 (defun gnus-group-mark-group (n &optional unmark no-advance)
5250 "Mark the current group."
5252 (let ((buffer-read-only nil)
5256 (when (setq group (gnus-group-group-name))
5260 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5265 (setq gnus-group-marked (delete group gnus-group-marked)))
5267 (setq gnus-group-marked
5268 (cons group (delete group gnus-group-marked)))))
5269 (or no-advance (gnus-group-next-group 1))
5271 (gnus-summary-position-point)
5274 (defun gnus-group-unmark-group (n)
5275 "Remove the mark from the current group."
5277 (gnus-group-mark-group n 'unmark)
5278 (gnus-group-position-point))
5280 (defun gnus-group-unmark-all-groups ()
5281 "Unmark all groups."
5283 (let ((groups gnus-group-marked))
5286 (gnus-group-remove-mark (pop groups)))))
5287 (gnus-group-position-point))
5289 (defun gnus-group-mark-region (unmark beg end)
5290 "Mark all groups between point and mark.
5291 If UNMARK, remove the mark instead."
5292 (interactive "P\nr")
5293 (let ((num (count-lines beg end)))
5296 (- num (gnus-group-mark-group num unmark)))))
5298 (defun gnus-group-mark-buffer (&optional unmark)
5299 "Mark all groups in the buffer.
5300 If UNMARK, remove the mark instead."
5302 (gnus-group-mark-region unmark (point-min) (point-max)))
5304 (defun gnus-group-mark-regexp (regexp)
5305 "Mark all groups that match some regexp."
5306 (interactive "sMark (regexp): ")
5307 (let ((alist (cdr gnus-newsrc-alist))
5310 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5311 (gnus-group-set-mark group))))
5312 (gnus-group-position-point))
5314 (defun gnus-group-remove-mark (group)
5315 "Remove the process mark from GROUP and move point there.
5316 Return nil if the group isn't displayed."
5317 (if (gnus-group-goto-group group)
5319 (gnus-group-mark-group 1 'unmark t)
5321 (setq gnus-group-marked
5322 (delete group gnus-group-marked))
5325 (defun gnus-group-set-mark (group)
5326 "Set the process mark on GROUP."
5327 (if (gnus-group-goto-group group)
5329 (gnus-group-mark-group 1 nil t))
5330 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5332 (defun gnus-group-universal-argument (arg &optional groups func)
5333 "Perform any command on all groups accoring to the process/prefix convention."
5335 (let ((groups (or groups (gnus-group-process-prefix arg)))
5337 (if (eq (setq func (or func
5340 (substitute-command-keys
5341 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5343 (gnus-error 1 "Undefined key")
5345 (gnus-group-remove-mark (setq group (pop groups)))
5346 (command-execute func))))
5347 (gnus-group-position-point))
5349 (defun gnus-group-process-prefix (n)
5350 "Return a list of groups to work on.
5351 Take into consideration N (the prefix) and the list of marked groups."
5354 (setq n (prefix-numeric-value n))
5355 ;; There is a prefix, so we return a list of the N next
5357 (let ((way (if (< n 0) -1 1))
5362 (setq group (gnus-group-group-name)))
5363 (setq groups (cons group groups))
5365 (gnus-group-next-group way)))
5367 ((and (boundp 'transient-mark-mode)
5369 (boundp 'mark-active)
5371 ;; Work on the region between point and mark.
5372 (let ((max (max (point) (mark)))
5375 (goto-char (min (point) (mark)))
5378 (push (gnus-group-group-name) groups)
5379 (zerop (gnus-group-next-group 1))
5381 (nreverse groups))))
5383 ;; No prefix, but a list of marked articles.
5384 (reverse gnus-group-marked))
5386 ;; Neither marked articles or a prefix, so we return the
5388 (let ((group (gnus-group-group-name)))
5389 (and group (list group))))))
5391 ;; Selecting groups.
5393 (defun gnus-group-read-group (&optional all no-article group)
5394 "Read news in this newsgroup.
5395 If the prefix argument ALL is non-nil, already read articles become
5396 readable. IF ALL is a number, fetch this number of articles. If the
5397 optional argument NO-ARTICLE is non-nil, no article will be
5398 auto-selected upon group entry. If GROUP is non-nil, fetch that
5401 (let ((group (or group (gnus-group-group-name)))
5402 number active marked entry)
5403 (or group (error "No group on current line"))
5404 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5405 group gnus-newsrc-hashtb)))))
5406 ;; This group might be a dead group. In that case we have to get
5407 ;; the number of unread articles from `gnus-active-hashtb'.
5409 (cond ((numberp all) all)
5411 ((setq active (gnus-active group))
5412 (- (1+ (cdr active)) (car active)))))
5413 (gnus-summary-read-group
5414 group (or all (and (numberp number)
5415 (zerop (+ number (length (cdr (assq 'tick marked)))
5416 (length (cdr (assq 'dormant marked)))))))
5419 (defun gnus-group-select-group (&optional all)
5420 "Select this newsgroup.
5421 No article is selected automatically.
5422 If ALL is non-nil, already read articles become readable.
5423 If ALL is a number, fetch this number of articles."
5425 (gnus-group-read-group all t))
5427 (defun gnus-group-quick-select-group (&optional all)
5428 "Select the current group \"quickly\".
5429 This means that no highlighting or scoring will be performed."
5432 gnus-score-find-score-files-function
5433 gnus-apply-kill-hook
5434 gnus-summary-expunge-below)
5435 (gnus-group-read-group all t)))
5437 (defun gnus-group-visible-select-group (&optional all)
5438 "Select the current group without hiding any articles."
5440 (let ((gnus-inhibit-limiting t))
5441 (gnus-group-read-group all t)))
5444 (defun gnus-fetch-group (group)
5445 "Start Gnus if necessary and enter GROUP.
5446 Returns whether the fetching was successful or not."
5447 (interactive "sGroup name: ")
5448 (or (get-buffer gnus-group-buffer)
5450 (gnus-group-read-group nil nil group))
5452 ;; Enter a group that is not in the group buffer. Non-nil is returned
5453 ;; if selection was successful.
5454 (defun gnus-group-read-ephemeral-group
5455 (group method &optional activate quit-config)
5456 (let ((group (if (gnus-group-foreign-p group) group
5457 (gnus-group-prefixed-name group method))))
5460 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5461 ((quit-config . ,(if quit-config quit-config
5462 (cons (current-buffer) 'summary))))))
5464 (set-buffer gnus-group-buffer)
5465 (or (gnus-check-server method)
5466 (error "Unable to contact server: %s" (gnus-status-message method)))
5467 (if activate (or (gnus-request-group group)
5468 (error "Couldn't request group")))
5470 (gnus-group-read-group t t group)
5474 (defun gnus-group-jump-to-group (group)
5475 "Jump to newsgroup GROUP."
5477 (list (completing-read
5478 "Group: " gnus-active-hashtb nil
5479 (gnus-read-active-file-p)
5481 'gnus-group-history)))
5483 (when (equal group "")
5484 (error "Empty group name"))
5486 (when (string-match "[\000-\032]" group)
5487 (error "Control characters in group: %s" group))
5489 (let ((b (text-property-any
5490 (point-min) (point-max)
5491 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5492 (unless (gnus-ephemeral-group-p group)
5494 ;; Either go to the line in the group buffer...
5496 ;; ... or insert the line.
5499 (gnus-activate-group group)
5500 (error "%s error: %s" group (gnus-status-message group)))
5502 (gnus-group-update-group group)
5503 (goto-char (text-property-any
5504 (point-min) (point-max)
5505 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5506 ;; Adjust cursor point.
5507 (gnus-group-position-point)))
5509 (defun gnus-group-goto-group (group)
5510 "Goto to newsgroup GROUP."
5512 (let ((b (text-property-any (point-min) (point-max)
5513 'gnus-group (gnus-intern-safe
5514 group gnus-active-hashtb))))
5515 (and b (goto-char b)))))
5517 (defun gnus-group-next-group (n &optional silent)
5518 "Go to next N'th newsgroup.
5519 If N is negative, search backward instead.
5520 Returns the difference between N and the number of skips actually
5523 (gnus-group-next-unread-group n t nil silent))
5525 (defun gnus-group-next-unread-group (n &optional all level silent)
5526 "Go to next N'th unread newsgroup.
5527 If N is negative, search backward instead.
5528 If ALL is non-nil, choose any newsgroup, unread or not.
5529 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5530 such group can be found, the next group with a level higher than
5532 Returns the difference between N and the number of skips actually
5535 (let ((backward (< n 0))
5538 (gnus-group-search-forward
5539 backward (or (not gnus-group-goto-unread) all) level))
5543 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5544 (if level " on this level or higher" "")))
5547 (defun gnus-group-prev-group (n)
5548 "Go to previous N'th newsgroup.
5549 Returns the difference between N and the number of skips actually
5552 (gnus-group-next-unread-group (- n) t))
5554 (defun gnus-group-prev-unread-group (n)
5555 "Go to previous N'th unread newsgroup.
5556 Returns the difference between N and the number of skips actually
5559 (gnus-group-next-unread-group (- n)))
5561 (defun gnus-group-next-unread-group-same-level (n)
5562 "Go to next N'th unread newsgroup on the same level.
5563 If N is negative, search backward instead.
5564 Returns the difference between N and the number of skips actually
5567 (gnus-group-next-unread-group n t (gnus-group-group-level))
5568 (gnus-group-position-point))
5570 (defun gnus-group-prev-unread-group-same-level (n)
5571 "Go to next N'th unread newsgroup on the same level.
5572 Returns the difference between N and the number of skips actually
5575 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5576 (gnus-group-position-point))
5578 (defun gnus-group-best-unread-group (&optional exclude-group)
5579 "Go to the group with the highest level.
5580 If EXCLUDE-GROUP, do not go to that group."
5582 (goto-char (point-min))
5586 (setq unread (get-text-property (point) 'gnus-unread))
5587 (if (and (numberp unread) (> unread 0))
5589 (if (and (get-text-property (point) 'gnus-level)
5590 (< (get-text-property (point) 'gnus-level) best)
5591 (or (not exclude-group)
5592 (not (equal exclude-group (gnus-group-group-name)))))
5594 (setq best (get-text-property (point) 'gnus-level))
5595 (setq best-point (point))))))
5597 (if best-point (goto-char best-point))
5598 (gnus-summary-position-point)
5599 (and best-point (gnus-group-group-name))))
5601 (defun gnus-group-first-unread-group ()
5602 "Go to the first group with unread articles."
5605 (let ((opoint (point))
5607 (goto-char (point-min))
5608 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5609 (and (numberp unread) ; Not a topic.
5610 (not (zerop unread))) ; Has unread articles.
5611 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5614 nil)) ; Not success.
5615 (gnus-group-position-point)))
5617 (defun gnus-group-enter-server-mode ()
5618 "Jump to the server buffer."
5620 (gnus-enter-server-buffer))
5622 (defun gnus-group-make-group (name &optional method address)
5623 "Add a new newsgroup.
5624 The user will be prompted for a NAME, for a select METHOD, and an
5628 (read-string "Group name: ")
5631 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5632 nil t nil 'gnus-method-history)))
5633 (cond ((assoc method gnus-valid-select-methods)
5635 (if (memq 'prompt-address
5636 (assoc method gnus-valid-select-methods))
5637 (read-string "Address: ")
5639 ((assoc method gnus-server-alist)
5642 (list method ""))))))
5644 (let* ((meth (and method (if address (list (intern method) address)
5646 (nname (if method (gnus-group-prefixed-name name meth) name))
5648 (when (gnus-gethash nname gnus-newsrc-hashtb)
5649 (error "Group %s already exists" nname))
5650 ;; Subscribe to the new group.
5651 (gnus-group-change-level
5652 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5653 gnus-level-default-subscribed gnus-level-killed
5654 (and (gnus-group-group-name)
5655 (gnus-gethash (gnus-group-group-name)
5656 gnus-newsrc-hashtb))
5659 (gnus-set-active nname (cons 1 0))
5660 (or (gnus-ephemeral-group-p name)
5662 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5664 (gnus-group-insert-group-line-info nname)
5666 (gnus-group-position-point)
5668 ;; Load the backend and try to make the backend create
5669 ;; the group as well.
5670 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5672 gnus-valid-select-methods)
5674 (gnus-check-server meth)
5675 (and (gnus-check-backend-function 'request-create-group nname)
5676 (gnus-request-create-group nname))
5679 (defun gnus-group-delete-group (group &optional force)
5680 "Delete the current group. Only meaningful with mail groups.
5681 If FORCE (the prefix) is non-nil, all the articles in the group will
5682 be deleted. This is \"deleted\" as in \"removed forever from the face
5683 of the Earth\". There is no undo. The user will be prompted before
5684 doing the deletion."
5686 (list (gnus-group-group-name)
5687 current-prefix-arg))
5688 (or group (error "No group to rename"))
5689 (or (gnus-check-backend-function 'request-delete-group group)
5690 (error "This backend does not support group deletion"))
5692 (if (not (gnus-yes-or-no-p
5694 "Do you really want to delete %s%s? "
5695 group (if force " and all its contents" ""))))
5697 (gnus-message 6 "Deleting group %s..." group)
5698 (if (not (gnus-request-delete-group group force))
5699 (gnus-error 3 "Couldn't delete group %s" group)
5700 (gnus-message 6 "Deleting group %s...done" group)
5701 (gnus-group-goto-group group)
5702 (gnus-group-kill-group 1 t)
5703 (gnus-sethash group nil gnus-active-hashtb)
5705 (gnus-group-position-point)))
5707 (defun gnus-group-rename-group (group new-name)
5710 (gnus-group-group-name)
5712 (or (gnus-check-backend-function
5713 'request-rename-group (gnus-group-group-name))
5714 (error "This backend does not support renaming groups"))
5715 (read-string "New group name: "))))
5717 (or (gnus-check-backend-function 'request-rename-group group)
5718 (error "This backend does not support renaming groups"))
5720 (or group (error "No group to rename"))
5721 (and (string-match "^[ \t]*$" new-name)
5722 (error "Not a valid group name"))
5724 ;; We find the proper prefixed name.
5726 (gnus-group-prefixed-name
5727 (gnus-group-real-name new-name)
5728 (gnus-info-method (gnus-get-info group))))
5730 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5732 (if (not (gnus-request-rename-group group new-name))
5733 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5734 ;; We rename the group internally by killing it...
5735 (gnus-group-goto-group group)
5736 (gnus-group-kill-group)
5737 ;; ... changing its name ...
5738 (setcar (cdar gnus-list-of-killed-groups) new-name)
5739 ;; ... and then yanking it. Magic!
5740 (gnus-group-yank-group)
5741 (gnus-set-active new-name (gnus-active group))
5742 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5744 (gnus-group-position-point)))
5746 (defun gnus-group-edit-group (group &optional part)
5747 "Edit the group on the current line."
5748 (interactive (list (gnus-group-group-name)))
5749 (let* ((part (or part 'info))
5750 (done-func `(lambda ()
5751 "Exit editing mode and update the information."
5753 (gnus-group-edit-group-done ',part ,group)))
5754 (winconf (current-window-configuration))
5756 (or group (error "No group on current line"))
5757 (or (setq info (gnus-get-info group))
5758 (error "Killed group; can't be edited"))
5759 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5760 (gnus-configure-windows 'edit-group)
5761 (gnus-add-current-to-buffer-list)
5763 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5764 (use-local-map (copy-keymap emacs-lisp-mode-map))
5765 (local-set-key "\C-c\C-c" done-func)
5766 (make-local-variable 'gnus-prev-winconf)
5767 (setq gnus-prev-winconf winconf)
5772 ";; Type `C-c C-c' after editing the select method.\n\n")
5774 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5776 ";; Type `C-c C-c' after editing the group info.\n\n")))
5779 (cond ((eq part 'method)
5780 (or (gnus-info-method info) "native"))
5782 (gnus-info-params info))
5786 (defun gnus-group-edit-group-method (group)
5787 "Edit the select method of GROUP."
5788 (interactive (list (gnus-group-group-name)))
5789 (gnus-group-edit-group group 'method))
5791 (defun gnus-group-edit-group-parameters (group)
5792 "Edit the group parameters of GROUP."
5793 (interactive (list (gnus-group-group-name)))
5794 (gnus-group-edit-group group 'params))
5796 (defun gnus-group-edit-group-done (part group)
5797 "Get info from buffer, update variables and jump to the group buffer."
5798 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5799 (goto-char (point-min))
5800 (let* ((form (read (current-buffer)))
5801 (winconf gnus-prev-winconf)
5802 (method (cond ((eq part 'info) (nth 4 form))
5803 ((eq part 'method) form)
5805 (info (cond ((eq part 'info) form)
5806 ((eq part 'method) (gnus-get-info group))
5809 (if (or (not method)
5811 gnus-select-method method))
5812 (gnus-group-real-name (car info))
5813 (gnus-group-prefixed-name
5814 (gnus-group-real-name (car info)) method))
5816 (when (and new-group
5817 (not (equal new-group group)))
5818 (when (gnus-group-goto-group group)
5819 (gnus-group-kill-group 1))
5820 (gnus-activate-group new-group))
5822 (if (and info new-group)
5824 (setq info (gnus-copy-sequence info))
5825 (setcar info new-group)
5826 (unless (gnus-server-equal method "native")
5827 (unless (nthcdr 3 info)
5828 (nconc info (list nil nil)))
5829 (unless (nthcdr 4 info)
5830 (nconc info (list nil)))
5831 (gnus-info-set-method info method))
5832 (gnus-group-set-info info))
5833 (gnus-group-set-info form (or new-group group) part))
5834 (kill-buffer (current-buffer))
5835 (and winconf (set-window-configuration winconf))
5836 (set-buffer gnus-group-buffer)
5837 (gnus-group-update-group (or new-group group))
5838 (gnus-group-position-point)))
5840 (defun gnus-group-make-help-group ()
5841 "Create the Gnus documentation group."
5843 (let ((path load-path)
5844 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5846 (and (gnus-gethash name gnus-newsrc-hashtb)
5847 (error "Documentation group already exists"))
5849 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5851 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5853 (setq file (concat (file-name-directory
5854 (directory-file-name dir))
5855 "etc/gnus-tut.txt"))))
5858 (gnus-message 1 "Couldn't find doc group")
5859 (gnus-group-make-group
5860 (gnus-group-real-name name)
5861 (list 'nndoc "gnus-help"
5862 (list 'nndoc-address file)
5863 (list 'nndoc-article-type 'mbox)))))
5864 (gnus-group-position-point))
5866 (defun gnus-group-make-doc-group (file type)
5867 "Create a group that uses a single file as the source."
5869 (list (read-file-name "File name: ")
5870 (and current-prefix-arg 'ask)))
5871 (when (eq type 'ask)
5876 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5878 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5879 ((= char ?b) 'babyl)
5880 ((= char ?d) 'digest)
5881 ((= char ?f) 'forward)
5883 (t (setq err (format "%c unknown. " char))
5886 (let* ((file (expand-file-name file))
5887 (name (gnus-generate-new-group-name
5888 (gnus-group-prefixed-name
5889 (file-name-nondirectory file) '(nndoc "")))))
5890 (gnus-group-make-group
5891 (gnus-group-real-name name)
5892 (list 'nndoc (file-name-nondirectory file)
5893 (list 'nndoc-address file)
5894 (list 'nndoc-article-type (or type 'guess))))))
5896 (defun gnus-group-make-archive-group (&optional all)
5897 "Create the (ding) Gnus archive group of the most recent articles.
5898 Given a prefix, create a full group."
5900 (let ((group (gnus-group-prefixed-name
5901 (if all "ding.archives" "ding.recent") '(nndir ""))))
5902 (and (gnus-gethash group gnus-newsrc-hashtb)
5903 (error "Archive group already exists"))
5904 (gnus-group-make-group
5905 (gnus-group-real-name group)
5906 (list 'nndir (if all "hpc" "edu")
5907 (list 'nndir-directory
5908 (if all gnus-group-archive-directory
5909 gnus-group-recent-archive-directory))))))
5911 (defun gnus-group-make-directory-group (dir)
5912 "Create an nndir group.
5913 The user will be prompted for a directory. The contents of this
5914 directory will be used as a newsgroup. The directory should contain
5915 mail messages or news articles in files that have numeric names."
5917 (list (read-file-name "Create group from directory: ")))
5918 (or (file-exists-p dir) (error "No such directory"))
5919 (or (file-directory-p dir) (error "Not a directory"))
5923 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5925 (gnus-group-prefixed-name
5926 (concat (file-name-as-directory (directory-file-name dir))
5929 (setq ext (format "<%d>" (setq i (1+ i)))))
5930 (gnus-group-make-group
5931 (gnus-group-real-name group)
5932 (list 'nndir group (list 'nndir-directory dir)))))
5934 (defun gnus-group-make-kiboze-group (group address scores)
5935 "Create an nnkiboze group.
5936 The user will be prompted for a name, a regexp to match groups, and
5937 score file entries for articles to include in the group."
5940 (read-string "nnkiboze group name: ")
5941 (read-string "Source groups (regexp): ")
5942 (let ((headers (mapcar (lambda (group) (list group))
5943 '("subject" "from" "number" "date" "message-id"
5944 "references" "chars" "lines" "xref"
5945 "followup" "all" "body" "head")))
5946 scores header regexp regexps)
5947 (while (not (equal "" (setq header (completing-read
5948 "Match on header: " headers nil t))))
5950 (while (not (equal "" (setq regexp (read-string
5951 (format "Match on %s (string): "
5953 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5954 (setq scores (cons (cons header regexps) scores)))
5956 (gnus-group-make-group group "nnkiboze" address)
5957 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5958 (let (emacs-lisp-mode-hook)
5959 (pp scores (current-buffer)))))
5961 (defun gnus-group-add-to-virtual (n vgroup)
5962 "Add the current group to a virtual group."
5964 (list current-prefix-arg
5965 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5967 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5968 (error "%s is not an nnvirtual group" vgroup))
5969 (let* ((groups (gnus-group-process-prefix n))
5970 (method (gnus-info-method (gnus-get-info vgroup))))
5971 (setcar (cdr method)
5973 (nth 1 method) "\\|"
5976 (gnus-group-remove-mark s)
5977 (concat "\\(^" (regexp-quote s) "$\\)"))
5979 (gnus-group-position-point))
5981 (defun gnus-group-make-empty-virtual (group)
5982 "Create a new, fresh, empty virtual group."
5983 (interactive "sCreate new, empty virtual group: ")
5984 (let* ((method (list 'nnvirtual "^$"))
5985 (pgroup (gnus-group-prefixed-name group method)))
5986 ;; Check whether it exists already.
5987 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5988 (error "Group %s already exists." pgroup))
5989 ;; Subscribe the new group after the group on the current line.
5990 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5991 (gnus-group-update-group pgroup)
5993 (gnus-group-position-point)))
5995 (defun gnus-group-enter-directory (dir)
5996 "Enter an ephemeral nneething group."
5997 (interactive "DDirectory to read: ")
5998 (let* ((method (list 'nneething dir))
5999 (leaf (gnus-group-prefixed-name
6000 (file-name-nondirectory (directory-file-name dir))
6002 (name (gnus-generate-new-group-name leaf)))
6003 (let ((nneething-read-only t))
6004 (or (gnus-group-read-ephemeral-group
6006 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
6008 (error "Couldn't enter %s" dir)))))
6010 ;; Group sorting commands
6011 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
6013 (defun gnus-group-sort-groups (func &optional reverse)
6014 "Sort the group buffer according to FUNC.
6015 If REVERSE, reverse the sorting order."
6016 (interactive (list gnus-group-sort-function
6017 current-prefix-arg))
6019 ((not (listp func)) func)
6021 ((= 1 (length func)) (car func))
6023 ,(gnus-make-sort-function
6024 (reverse func)))))))
6025 ;; We peel off the dummy group from the alist.
6027 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
6028 (pop gnus-newsrc-alist))
6030 (setq gnus-newsrc-alist
6031 (sort gnus-newsrc-alist func))
6033 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
6034 ;; Regenerate the hash table.
6035 (gnus-make-hashtable-from-newsrc-alist)
6036 (gnus-group-list-groups))))
6038 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
6039 "Sort the group buffer alphabetically by group name.
6040 If REVERSE, sort in reverse order."
6042 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
6044 (defun gnus-group-sort-groups-by-unread (&optional reverse)
6045 "Sort the group buffer by number of unread articles.
6046 If REVERSE, sort in reverse order."
6048 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
6050 (defun gnus-group-sort-groups-by-level (&optional reverse)
6051 "Sort the group buffer by group level.
6052 If REVERSE, sort in reverse order."
6054 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
6056 (defun gnus-group-sort-groups-by-score (&optional reverse)
6057 "Sort the group buffer by group score.
6058 If REVERSE, sort in reverse order."
6060 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
6062 (defun gnus-group-sort-groups-by-rank (&optional reverse)
6063 "Sort the group buffer by group rank.
6064 If REVERSE, sort in reverse order."
6066 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6068 (defun gnus-group-sort-groups-by-method (&optional reverse)
6069 "Sort the group buffer alphabetically by backend name.
6070 If REVERSE, sort in reverse order."
6072 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6074 (defun gnus-group-sort-by-alphabet (info1 info2)
6075 "Sort alphabetically."
6076 (string< (gnus-info-group info1) (gnus-info-group info2)))
6078 (defun gnus-group-sort-by-unread (info1 info2)
6079 "Sort by number of unread articles."
6080 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6081 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6082 (< (or (and (numberp n1) n1) 0)
6083 (or (and (numberp n2) n2) 0))))
6085 (defun gnus-group-sort-by-level (info1 info2)
6087 (< (gnus-info-level info1) (gnus-info-level info2)))
6089 (defun gnus-group-sort-by-method (info1 info2)
6090 "Sort alphabetically by backend name."
6091 (string< (symbol-name (car (gnus-find-method-for-group
6092 (gnus-info-group info1) info1)))
6093 (symbol-name (car (gnus-find-method-for-group
6094 (gnus-info-group info2) info2)))))
6096 (defun gnus-group-sort-by-score (info1 info2)
6097 "Sort by group score."
6098 (< (gnus-info-score info1) (gnus-info-score info2)))
6100 (defun gnus-group-sort-by-rank (info1 info2)
6101 "Sort by level and score."
6102 (let ((level1 (gnus-info-level info1))
6103 (level2 (gnus-info-level info2)))
6104 (or (< level1 level2)
6105 (and (= level1 level2)
6106 (> (gnus-info-score info1) (gnus-info-score info2))))))
6108 ;; Group catching up.
6110 (defun gnus-group-clear-data (n)
6111 "Clear all marks and read ranges from the current group."
6113 (let ((groups (gnus-group-process-prefix n))
6115 (while (setq group (pop groups))
6116 (setq info (gnus-get-info group))
6117 (gnus-info-set-read info nil)
6118 (when (gnus-info-marks info)
6119 (gnus-info-set-marks info nil))
6120 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6121 (when (gnus-group-goto-group group)
6122 (gnus-group-remove-mark group)
6123 (gnus-group-update-group-line)))))
6125 (defun gnus-group-catchup-current (&optional n all)
6126 "Mark all articles not marked as unread in current newsgroup as read.
6127 If prefix argument N is numeric, the ARG next newsgroups will be
6128 caught up. If ALL is non-nil, marked articles will also be marked as
6129 read. Cross references (Xref: header) of articles are ignored.
6130 The difference between N and actual number of newsgroups that were
6131 caught up is returned."
6133 (unless (gnus-group-group-name)
6134 (error "No group on the current line"))
6135 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6139 "Do you really want to mark all articles as read? "
6140 "Mark all unread articles as read? "))))
6142 (let ((groups (gnus-group-process-prefix n))
6145 ;; Virtual groups have to be given special treatment.
6146 (let ((method (gnus-find-method-for-group (car groups))))
6147 (if (eq 'nnvirtual (car method))
6148 (nnvirtual-catchup-group
6149 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6150 (gnus-group-remove-mark (car groups))
6151 (if (>= (gnus-group-group-level) gnus-level-zombie)
6152 (gnus-message 2 "Dead groups can't be caught up")
6154 (gnus-group-goto-group (car groups))
6155 (gnus-group-catchup (car groups) all))
6156 (gnus-group-update-group-line)
6157 (setq ret (1+ ret))))
6158 (setq groups (cdr groups)))
6159 (gnus-group-next-unread-group 1)
6162 (defun gnus-group-catchup-current-all (&optional n)
6163 "Mark all articles in current newsgroup as read.
6164 Cross references (Xref: header) of articles are ignored."
6166 (gnus-group-catchup-current n 'all))
6168 (defun gnus-group-catchup (group &optional all)
6169 "Mark all articles in GROUP as read.
6170 If ALL is non-nil, all articles are marked as read.
6171 The return value is the number of articles that were marked as read,
6172 or nil if no action could be taken."
6173 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6175 ;; Do the updating only if the newsgroup isn't killed.
6176 (if (not (numberp (car entry)))
6177 (gnus-message 1 "Can't catch up; non-active group")
6178 ;; Do auto-expirable marks if that's required.
6179 (when (gnus-group-auto-expirable-p group)
6180 (gnus-add-marked-articles
6181 group 'expire (gnus-list-of-unread-articles group))
6183 (let ((marks (nth 3 (nth 2 entry))))
6184 (gnus-add-marked-articles
6185 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6186 (gnus-add-marked-articles
6187 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6189 (gnus-update-read-articles group nil)
6190 ;; Also nix out the lists of marks and dormants.
6192 (gnus-add-marked-articles group 'tick nil nil 'force)
6193 (gnus-add-marked-articles group 'dormant nil nil 'force))
6194 (run-hooks 'gnus-group-catchup-group-hook)
6197 (defun gnus-group-expire-articles (&optional n)
6198 "Expire all expirable articles in the current newsgroup."
6200 (let ((groups (gnus-group-process-prefix n))
6203 (error "No groups to expire"))
6204 (while (setq group (pop groups))
6205 (gnus-group-remove-mark group)
6206 (when (gnus-check-backend-function 'request-expire-articles group)
6207 (gnus-message 6 "Expiring articles in %s..." group)
6208 (let* ((info (gnus-get-info group))
6209 (expirable (if (gnus-group-total-expirable-p group)
6210 (cons nil (gnus-list-of-read-articles group))
6211 (assq 'expire (gnus-info-marks info))))
6212 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6216 (gnus-compress-sequence
6218 ;; We set the expiry variables to the groupp
6220 (let ((nnmail-expiry-wait-function nil)
6221 (nnmail-expiry-wait expiry-wait))
6222 (gnus-request-expire-articles
6223 (gnus-uncompress-sequence (cdr expirable)) group))
6224 ;; Just expire using the normal expiry values.
6225 (gnus-request-expire-articles
6226 (gnus-uncompress-sequence (cdr expirable)) group))))
6227 (gnus-close-group group))
6228 (gnus-message 6 "Expiring articles in %s...done" group)))
6229 (gnus-group-position-point))))
6231 (defun gnus-group-expire-all-groups ()
6232 "Expire all expirable articles in all newsgroups."
6235 (gnus-message 5 "Expiring...")
6236 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6237 (cdr gnus-newsrc-alist))))
6238 (gnus-group-expire-articles nil)))
6239 (gnus-group-position-point)
6240 (gnus-message 5 "Expiring...done"))
6242 (defun gnus-group-set-current-level (n level)
6243 "Set the level of the next N groups to LEVEL."
6248 (let ((s (read-string
6249 (format "Level (default %s): "
6250 (or (gnus-group-group-level)
6251 gnus-level-default-subscribed)))))
6252 (if (string-match "^\\s-*$" s)
6253 (int-to-string (or (gnus-group-group-level)
6254 gnus-level-default-subscribed))
6256 (or (and (>= level 1) (<= level gnus-level-killed))
6257 (error "Illegal level: %d" level))
6258 (let ((groups (gnus-group-process-prefix n))
6260 (while (setq group (pop groups))
6261 (gnus-group-remove-mark group)
6262 (gnus-message 6 "Changed level of %s from %d to %d"
6263 group (or (gnus-group-group-level) gnus-level-killed)
6265 (gnus-group-change-level
6266 group level (or (gnus-group-group-level) gnus-level-killed))
6267 (gnus-group-update-group-line)))
6268 (gnus-group-position-point))
6270 (defun gnus-group-unsubscribe-current-group (&optional n)
6271 "Toggle subscription of the current group.
6272 If given numerical prefix, toggle the N next groups."
6274 (let ((groups (gnus-group-process-prefix n))
6277 (setq group (car groups)
6278 groups (cdr groups))
6279 (gnus-group-remove-mark group)
6280 (gnus-group-unsubscribe-group
6281 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6282 gnus-level-default-unsubscribed
6283 gnus-level-default-subscribed) t)
6284 (gnus-group-update-group-line))
6285 (gnus-group-next-group 1)))
6287 (defun gnus-group-unsubscribe-group (group &optional level silent)
6288 "Toggle subscription to GROUP.
6289 Killed newsgroups are subscribed. If SILENT, don't try to update the
6292 (list (completing-read
6293 "Group: " gnus-active-hashtb nil
6294 (gnus-read-active-file-p)
6296 'gnus-group-history)))
6297 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6299 ((string-match "^[ \t]$" group)
6300 (error "Empty group name"))
6302 ;; Toggle subscription flag.
6303 (gnus-group-change-level
6304 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6305 gnus-level-subscribed)
6306 (1+ gnus-level-subscribed)
6307 gnus-level-default-subscribed)))
6309 (gnus-group-update-group group)))
6310 ((and (stringp group)
6311 (or (not (gnus-read-active-file-p))
6312 (gnus-active group)))
6313 ;; Add new newsgroup.
6314 (gnus-group-change-level
6316 (if level level gnus-level-default-subscribed)
6317 (or (and (member group gnus-zombie-list)
6320 (and (gnus-group-group-name)
6321 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6323 (gnus-group-update-group group)))
6324 (t (error "No such newsgroup: %s" group)))
6325 (gnus-group-position-point)))
6327 (defun gnus-group-transpose-groups (n)
6328 "Move the current newsgroup up N places.
6329 If given a negative prefix, move down instead. The difference between
6330 N and the number of steps taken is returned."
6332 (or (gnus-group-group-name)
6333 (error "No group on current line"))
6334 (gnus-group-kill-group 1)
6336 (forward-line (- n))
6337 (gnus-group-yank-group)
6338 (gnus-group-position-point)))
6340 (defun gnus-group-kill-all-zombies ()
6341 "Kill all zombie newsgroups."
6343 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6344 (setq gnus-zombie-list nil)
6345 (gnus-group-list-groups))
6347 (defun gnus-group-kill-region (begin end)
6348 "Kill newsgroups in current region (excluding current point).
6349 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6364 (beginning-of-line) ;Important when LINES < 1
6365 (gnus-group-kill-group lines)))
6367 (defun gnus-group-kill-group (&optional n discard)
6368 "Kill the next N groups.
6369 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6370 However, only groups that were alive can be yanked; already killed
6371 groups or zombie groups can't be yanked.
6372 The return value is the name of the group that was killed, or a list
6375 (let ((buffer-read-only nil)
6376 (groups (gnus-group-process-prefix n))
6377 group entry level out)
6378 (if (< (length groups) 10)
6379 ;; This is faster when there are few groups.
6381 (push (setq group (pop groups)) out)
6382 (gnus-group-remove-mark group)
6383 (setq level (gnus-group-group-level))
6385 (when (and (not discard)
6386 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6387 (push (cons (car entry) (nth 2 entry))
6388 gnus-list-of-killed-groups))
6389 (gnus-group-change-level
6390 (if entry entry group) gnus-level-killed (if entry nil level)))
6391 ;; If there are lots and lots of groups to be killed, we use
6392 ;; this thing instead.
6394 (setq groups (nreverse groups))
6396 (gnus-group-remove-mark (setq group (pop groups)))
6398 (push group gnus-killed-list)
6399 (setq gnus-newsrc-alist
6400 (delq (assoc group gnus-newsrc-alist)
6402 (when gnus-group-change-level-function
6403 (funcall gnus-group-change-level-function group 9 3))
6405 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6406 (push (cons (car entry) (nth 2 entry))
6407 gnus-list-of-killed-groups)
6408 (setcdr (cdr entry) (cdddr entry)))
6409 ((member group gnus-zombie-list)
6410 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6411 (gnus-make-hashtable-from-newsrc-alist)))
6413 (gnus-group-position-point)
6414 (if (< (length out) 2) (car out) (nreverse out))))
6416 (defun gnus-group-yank-group (&optional arg)
6417 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6418 inserting it before the current newsgroup. The numeric ARG specifies
6419 how many newsgroups are to be yanked. The name of the newsgroup yanked
6420 is returned, or (if several groups are yanked) a list of yanked groups
6423 (setq arg (or arg 1))
6424 (let (info group prev out)
6425 (while (>= (decf arg) 0)
6426 (if (not (setq info (pop gnus-list-of-killed-groups)))
6427 (error "No more newsgroups to yank"))
6428 (push (setq group (nth 1 info)) out)
6429 ;; Find which newsgroup to insert this one before - search
6430 ;; backward until something suitable is found. If there are no
6431 ;; other newsgroups in this buffer, just make this newsgroup the
6433 (setq prev (gnus-group-group-name))
6434 (gnus-group-change-level
6435 info (gnus-info-level (cdr info)) gnus-level-killed
6436 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6438 (gnus-group-insert-group-line-info group))
6440 (gnus-group-position-point)
6441 (if (< (length out) 2) (car out) (nreverse out))))
6443 (defun gnus-group-kill-level (level)
6444 "Kill all groups that is on a certain LEVEL."
6445 (interactive "nKill all groups on level: ")
6447 ((= level gnus-level-zombie)
6448 (setq gnus-killed-list
6449 (nconc gnus-zombie-list gnus-killed-list))
6450 (setq gnus-zombie-list nil))
6451 ((and (< level gnus-level-zombie)
6453 (or gnus-expert-user
6456 "Do you really want to kill all groups on level %d? "
6458 (let* ((prev gnus-newsrc-alist)
6461 (if (= (gnus-info-level (car alist)) level)
6463 (push (gnus-info-group (car alist)) gnus-killed-list)
6464 (setcdr prev (cdr alist)))
6466 (setq alist (cdr alist)))
6467 (gnus-make-hashtable-from-newsrc-alist)
6468 (gnus-group-list-groups)))
6470 (error "Can't kill; illegal level: %d" level))))
6472 (defun gnus-group-list-all-groups (&optional arg)
6473 "List all newsgroups with level ARG or lower.
6474 Default is gnus-level-unsubscribed, which lists all subscribed and most
6475 unsubscribed groups."
6477 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6479 ;; Redefine this to list ALL killed groups if prefix arg used.
6480 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6481 (defun gnus-group-list-killed (&optional arg)
6482 "List all killed newsgroups in the group buffer.
6483 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6484 entail asking the server for the groups."
6486 ;; Find all possible killed newsgroups if arg.
6488 (gnus-get-killed-groups))
6489 (if (not gnus-killed-list)
6490 (gnus-message 6 "No killed groups")
6491 (let (gnus-group-list-mode)
6492 (funcall gnus-group-prepare-function
6493 gnus-level-killed t gnus-level-killed))
6494 (goto-char (point-min)))
6495 (gnus-group-position-point))
6497 (defun gnus-group-list-zombies ()
6498 "List all zombie newsgroups in the group buffer."
6500 (if (not gnus-zombie-list)
6501 (gnus-message 6 "No zombie groups")
6502 (let (gnus-group-list-mode)
6503 (funcall gnus-group-prepare-function
6504 gnus-level-zombie t gnus-level-zombie))
6505 (goto-char (point-min)))
6506 (gnus-group-position-point))
6508 (defun gnus-group-list-active ()
6509 "List all groups that are available from the server(s)."
6511 ;; First we make sure that we have really read the active file.
6512 (unless (gnus-read-active-file-p)
6513 (let ((gnus-read-active-file t))
6514 (gnus-read-active-file)))
6515 ;; Find all groups and sort them.
6523 (setq list (cons (symbol-name sym) list))))
6527 (buffer-read-only nil))
6530 (gnus-group-insert-group-line-info (pop groups)))
6531 (goto-char (point-min))))
6533 (defun gnus-activate-all-groups (level)
6534 "Activate absolutely all groups."
6535 (interactive (list 7))
6536 (let ((gnus-activate-level level)
6537 (gnus-activate-foreign-newsgroups level))
6538 (gnus-group-get-new-news)))
6540 (defun gnus-group-get-new-news (&optional arg)
6541 "Get newly arrived articles.
6542 If ARG is a number, it specifies which levels you are interested in
6543 re-scanning. If ARG is non-nil and not a number, this will force
6544 \"hard\" re-reading of the active files from all servers."
6546 (run-hooks 'gnus-get-new-news-hook)
6547 ;; We might read in new NoCeM messages here.
6548 (when (and gnus-use-nocem
6550 (gnus-nocem-scan-groups))
6551 ;; If ARG is not a number, then we read the active file.
6552 (when (and arg (not (numberp arg)))
6553 (let ((gnus-read-active-file t))
6554 (gnus-read-active-file))
6557 (setq arg (gnus-group-default-level arg t))
6558 (if (and gnus-read-active-file (not arg))
6560 (gnus-read-active-file)
6561 (gnus-get-unread-articles arg))
6562 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6563 (gnus-get-unread-articles arg)))
6564 (run-hooks 'gnus-after-getting-new-news-hook)
6565 (gnus-group-list-groups))
6567 (defun gnus-group-get-new-news-this-group (&optional n)
6568 "Check for newly arrived news in the current group (and the N-1 next groups).
6569 The difference between N and the number of newsgroup checked is returned.
6570 If N is negative, this group and the N-1 previous groups will be checked."
6572 (let* ((groups (gnus-group-process-prefix n))
6573 (ret (if (numberp n) (- n (length groups)) 0))
6574 (beg (unless n (point)))
6576 (while (setq group (pop groups))
6577 (gnus-group-remove-mark group)
6578 (if (gnus-activate-group group 'scan)
6580 (gnus-get-unread-articles-in-group
6581 (gnus-get-info group) (gnus-active group) t)
6582 (unless (gnus-virtual-group-p group)
6583 (gnus-close-group group))
6584 (gnus-group-update-group group))
6585 (if (eq (gnus-server-status (gnus-find-method-for-group group))
6587 (gnus-error "Server denied access")
6588 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
6589 (when beg (goto-char beg))
6590 (when gnus-goto-next-group-when-activating
6591 (gnus-group-next-unread-group 1 t))
6592 (gnus-summary-position-point)
6595 (defun gnus-group-fetch-faq (group &optional faq-dir)
6596 "Fetch the FAQ for the current group."
6599 (and (gnus-group-group-name)
6600 (gnus-group-real-name (gnus-group-group-name)))
6601 (cond (current-prefix-arg
6603 "Faq dir: " (and (listp gnus-group-faq-directory)
6604 (mapcar (lambda (file) (list file))
6605 gnus-group-faq-directory)))))))
6607 (setq faq-dir (if (listp gnus-group-faq-directory)
6608 (car gnus-group-faq-directory)
6609 gnus-group-faq-directory)))
6610 (or group (error "No group name given"))
6611 (let ((file (concat (file-name-as-directory faq-dir)
6612 (gnus-group-real-name group))))
6613 (if (not (file-exists-p file))
6614 (error "No such file: %s" file)
6617 (defun gnus-group-describe-group (force &optional group)
6618 "Display a description of the current newsgroup."
6619 (interactive (list current-prefix-arg (gnus-group-group-name)))
6620 (let* ((method (gnus-find-method-for-group group))
6621 (mname (gnus-group-prefixed-name "" method))
6624 gnus-description-hashtb)
6625 (gnus-sethash mname nil gnus-description-hashtb))
6626 (or group (error "No group name given"))
6627 (and (or (and gnus-description-hashtb
6628 ;; We check whether this group's method has been
6629 ;; queried for a description file.
6630 (gnus-gethash mname gnus-description-hashtb))
6631 (setq desc (gnus-group-get-description group))
6632 (gnus-read-descriptions-file method))
6634 (or desc (gnus-gethash group gnus-description-hashtb)
6635 "No description available")))))
6637 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6638 (defun gnus-group-describe-all-groups (&optional force)
6639 "Pop up a buffer with descriptions of all newsgroups."
6641 (and force (setq gnus-description-hashtb nil))
6642 (if (not (or gnus-description-hashtb
6643 (gnus-read-all-descriptions-files)))
6644 (error "Couldn't request descriptions file"))
6645 (let ((buffer-read-only nil)
6651 (insert (format " *: %-20s %s\n" (symbol-name group)
6652 (symbol-value group)))
6653 (gnus-add-text-properties
6654 b (1+ b) (list 'gnus-group group
6655 'gnus-unread t 'gnus-marked nil
6656 'gnus-level (1+ gnus-level-subscribed))))
6657 gnus-description-hashtb)
6658 (goto-char (point-min))
6659 (gnus-group-position-point)))
6661 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6662 (defun gnus-group-apropos (regexp &optional search-description)
6663 "List all newsgroups that have names that match a regexp."
6664 (interactive "sGnus apropos (regexp): ")
6666 (obuf (current-buffer))
6668 ;; Go through all newsgroups that are known to Gnus.
6671 (and (symbol-name group)
6672 (string-match regexp (symbol-name group))
6673 (setq groups (cons (symbol-name group) groups))))
6675 ;; Also go through all descriptions that are known to Gnus.
6676 (when search-description
6679 (and (string-match regexp (symbol-value group))
6680 (gnus-active (symbol-name group))
6681 (setq groups (cons (symbol-name group) groups))))
6682 gnus-description-hashtb))
6684 (gnus-message 3 "No groups matched \"%s\"." regexp)
6685 ;; Print out all the groups.
6687 (pop-to-buffer "*Gnus Help*")
6688 (buffer-disable-undo (current-buffer))
6690 (setq groups (sort groups 'string<))
6692 ;; Groups may be entered twice into the list of groups.
6693 (if (not (string= (car groups) prev))
6695 (insert (setq prev (car groups)) "\n")
6696 (if (and gnus-description-hashtb
6697 (setq des (gnus-gethash (car groups)
6698 gnus-description-hashtb)))
6699 (insert " " des "\n"))))
6700 (setq groups (cdr groups)))
6701 (goto-char (point-min))))
6702 (pop-to-buffer obuf)))
6704 (defun gnus-group-description-apropos (regexp)
6705 "List all newsgroups that have names or descriptions that match a regexp."
6706 (interactive "sGnus description apropos (regexp): ")
6707 (if (not (or gnus-description-hashtb
6708 (gnus-read-all-descriptions-files)))
6709 (error "Couldn't request descriptions file"))
6710 (gnus-group-apropos regexp t))
6712 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6713 (defun gnus-group-list-matching (level regexp &optional all lowest)
6714 "List all groups with unread articles that match REGEXP.
6715 If the prefix LEVEL is non-nil, it should be a number that says which
6716 level to cut off listing groups.
6717 If ALL, also list groups with no unread articles.
6718 If LOWEST, don't list groups with level lower than LOWEST.
6720 This command may read the active file."
6721 (interactive "P\nsList newsgroups matching: ")
6722 ;; First make sure active file has been read.
6724 (> (prefix-numeric-value level) gnus-level-killed))
6725 (gnus-get-killed-groups))
6726 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6727 all (or lowest 1) regexp)
6728 (goto-char (point-min))
6729 (gnus-group-position-point))
6731 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6732 "List all groups that match REGEXP.
6733 If the prefix LEVEL is non-nil, it should be a number that says which
6734 level to cut off listing groups.
6735 If LOWEST, don't list groups with level lower than LOWEST."
6736 (interactive "P\nsList newsgroups matching: ")
6737 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6739 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6740 (defun gnus-group-save-newsrc (&optional force)
6741 "Save the Gnus startup files.
6742 If FORCE, force saving whether it is necessary or not."
6744 (gnus-save-newsrc-file force))
6746 (defun gnus-group-restart (&optional arg)
6747 "Force Gnus to read the .newsrc file."
6749 (when (gnus-yes-or-no-p
6750 (format "Are you sure you want to read %s? "
6751 gnus-current-startup-file))
6752 (gnus-save-newsrc-file)
6753 (gnus-setup-news 'force)
6754 (gnus-group-list-groups arg)))
6756 (defun gnus-group-read-init-file ()
6757 "Read the Gnus elisp init file."
6759 (gnus-read-init-file))
6761 (defun gnus-group-check-bogus-groups (&optional silent)
6762 "Check bogus newsgroups.
6763 If given a prefix, don't ask for confirmation before removing a bogus
6766 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6767 (gnus-group-list-groups))
6769 (defun gnus-group-edit-global-kill (&optional article group)
6770 "Edit the global kill file.
6771 If GROUP, edit that local kill file instead."
6773 (setq gnus-current-kill-article article)
6774 (gnus-kill-file-edit-file group)
6777 (substitute-command-keys
6778 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6779 (if group "local" "global")))))
6781 (defun gnus-group-edit-local-kill (article group)
6782 "Edit a local kill file."
6783 (interactive (list nil (gnus-group-group-name)))
6784 (gnus-group-edit-global-kill article group))
6786 (defun gnus-group-force-update ()
6787 "Update `.newsrc' file."
6789 (gnus-save-newsrc-file))
6791 (defun gnus-group-suspend ()
6792 "Suspend the current Gnus session.
6793 In fact, cleanup buffers except for group mode buffer.
6794 The hook gnus-suspend-gnus-hook is called before actually suspending."
6796 (run-hooks 'gnus-suspend-gnus-hook)
6797 ;; Kill Gnus buffers except for group mode buffer.
6798 (let* ((group-buf (get-buffer gnus-group-buffer))
6799 ;; Do this on a separate list in case the user does a ^G before we finish
6801 (delete group-buf (delete gnus-dribble-buffer
6802 (append gnus-buffer-list nil)))))
6803 (while gnus-buffer-list
6804 (gnus-kill-buffer (pop gnus-buffer-list)))
6805 (gnus-kill-gnus-frames)
6807 (setq gnus-buffer-list (list group-buf))
6808 (bury-buffer group-buf)
6809 (delete-windows-on group-buf t))))
6811 (defun gnus-group-clear-dribble ()
6812 "Clear all information from the dribble buffer."
6814 (gnus-dribble-clear)
6815 (gnus-message 7 "Cleared dribble buffer"))
6817 (defun gnus-group-exit ()
6818 "Quit reading news after updating .newsrc.eld and .newsrc.
6819 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6822 (or noninteractive ;For gnus-batch-kill
6823 (not gnus-interactive-exit) ;Without confirmation
6825 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6826 (run-hooks 'gnus-exit-gnus-hook)
6827 ;; Offer to save data from non-quitted summary buffers.
6828 (gnus-offer-save-summaries)
6829 ;; Save the newsrc file(s).
6830 (gnus-save-newsrc-file)
6832 (gnus-close-backends)
6833 ;; Reset everything.
6835 ;; Allow the user to do things after cleaning up.
6836 (run-hooks 'gnus-after-exiting-gnus-hook)))
6838 (defun gnus-close-backends ()
6839 ;; Send a close request to all backends that support such a request.
6840 (let ((methods gnus-valid-select-methods)
6843 (if (fboundp (setq func (intern (concat (caar methods)
6844 "-request-close"))))
6846 (setq methods (cdr methods)))))
6848 (defun gnus-group-quit ()
6849 "Quit reading news without updating .newsrc.eld or .newsrc.
6850 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6852 (when (or noninteractive ;For gnus-batch-kill
6853 (zerop (buffer-size))
6854 (not (gnus-server-opened gnus-select-method))
6856 (not gnus-current-startup-file)
6858 (format "Quit reading news without saving %s? "
6859 (file-name-nondirectory gnus-current-startup-file))))
6860 (run-hooks 'gnus-exit-gnus-hook)
6861 (if gnus-use-full-window
6862 (delete-other-windows)
6863 (gnus-remove-some-windows))
6865 (gnus-close-backends)
6867 ;; Allow the user to do things after cleaning up.
6868 (run-hooks 'gnus-after-exiting-gnus-hook)))
6870 (defun gnus-offer-save-summaries ()
6871 "Offer to save all active summary buffers."
6873 (let ((buflist (buffer-list))
6875 ;; Go through all buffers and find all summaries.
6877 (and (setq bufname (buffer-name (car buflist)))
6878 (string-match "Summary" bufname)
6880 (set-buffer bufname)
6881 ;; We check that this is, indeed, a summary buffer.
6882 (and (eq major-mode 'gnus-summary-mode)
6883 ;; Also make sure this isn't bogus.
6884 gnus-newsgroup-prepared))
6885 (push bufname buffers))
6886 (setq buflist (cdr buflist)))
6887 ;; Go through all these summary buffers and offer to save them.
6890 "Update summary buffer %s? "
6891 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6894 (defun gnus-group-describe-briefly ()
6895 "Give a one line description of the group mode commands."
6897 (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")))
6899 (defun gnus-group-browse-foreign-server (method)
6900 "Browse a foreign news server.
6901 If called interactively, this function will ask for a select method
6902 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6903 If not, METHOD should be a list where the first element is the method
6904 and the second element is the address."
6906 (list (let ((how (completing-read
6908 (append gnus-valid-select-methods gnus-server-alist)
6909 nil t (cons "nntp" 0) 'gnus-method-history)))
6910 ;; We either got a backend name or a virtual server name.
6911 ;; If the first, we also need an address.
6912 (if (assoc how gnus-valid-select-methods)
6914 ;; Suggested by mapjph@bath.ac.uk.
6917 (mapcar (lambda (server) (list server))
6918 gnus-secondary-servers)))
6919 ;; We got a server name, so we find the method.
6920 (gnus-server-to-method how)))))
6921 (gnus-browse-foreign-server method))
6925 ;;; Gnus summary mode
6928 (defvar gnus-summary-mode-map nil)
6930 (put 'gnus-summary-mode 'mode-class 'special)
6932 (unless gnus-summary-mode-map
6933 (setq gnus-summary-mode-map (make-keymap))
6934 (suppress-keymap gnus-summary-mode-map)
6936 ;; Non-orthogonal keys
6938 (gnus-define-keys gnus-summary-mode-map
6939 " " gnus-summary-next-page
6940 "\177" gnus-summary-prev-page
6941 [delete] gnus-summary-prev-page
6942 "\r" gnus-summary-scroll-up
6943 "n" gnus-summary-next-unread-article
6944 "p" gnus-summary-prev-unread-article
6945 "N" gnus-summary-next-article
6946 "P" gnus-summary-prev-article
6947 "\M-\C-n" gnus-summary-next-same-subject
6948 "\M-\C-p" gnus-summary-prev-same-subject
6949 "\M-n" gnus-summary-next-unread-subject
6950 "\M-p" gnus-summary-prev-unread-subject
6951 "." gnus-summary-first-unread-article
6952 "," gnus-summary-best-unread-article
6953 "\M-s" gnus-summary-search-article-forward
6954 "\M-r" gnus-summary-search-article-backward
6955 "<" gnus-summary-beginning-of-article
6956 ">" gnus-summary-end-of-article
6957 "j" gnus-summary-goto-article
6958 "^" gnus-summary-refer-parent-article
6959 "\M-^" gnus-summary-refer-article
6960 "u" gnus-summary-tick-article-forward
6961 "!" gnus-summary-tick-article-forward
6962 "U" gnus-summary-tick-article-backward
6963 "d" gnus-summary-mark-as-read-forward
6964 "D" gnus-summary-mark-as-read-backward
6965 "E" gnus-summary-mark-as-expirable
6966 "\M-u" gnus-summary-clear-mark-forward
6967 "\M-U" gnus-summary-clear-mark-backward
6968 "k" gnus-summary-kill-same-subject-and-select
6969 "\C-k" gnus-summary-kill-same-subject
6970 "\M-\C-k" gnus-summary-kill-thread
6971 "\M-\C-l" gnus-summary-lower-thread
6972 "e" gnus-summary-edit-article
6973 "#" gnus-summary-mark-as-processable
6974 "\M-#" gnus-summary-unmark-as-processable
6975 "\M-\C-t" gnus-summary-toggle-threads
6976 "\M-\C-s" gnus-summary-show-thread
6977 "\M-\C-h" gnus-summary-hide-thread
6978 "\M-\C-f" gnus-summary-next-thread
6979 "\M-\C-b" gnus-summary-prev-thread
6980 "\M-\C-u" gnus-summary-up-thread
6981 "\M-\C-d" gnus-summary-down-thread
6982 "&" gnus-summary-execute-command
6983 "c" gnus-summary-catchup-and-exit
6984 "\C-w" gnus-summary-mark-region-as-read
6985 "\C-t" gnus-summary-toggle-truncation
6986 "?" gnus-summary-mark-as-dormant
6987 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6988 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6989 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6990 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6991 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6992 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6993 "=" gnus-summary-expand-window
6994 "\C-x\C-s" gnus-summary-reselect-current-group
6995 "\M-g" gnus-summary-rescan-group
6996 "w" gnus-summary-stop-page-breaking
6997 "\C-c\C-r" gnus-summary-caesar-message
6998 "\M-t" gnus-summary-toggle-mime
6999 "f" gnus-summary-followup
7000 "F" gnus-summary-followup-with-original
7001 "C" gnus-summary-cancel-article
7002 "r" gnus-summary-reply
7003 "R" gnus-summary-reply-with-original
7004 "\C-c\C-f" gnus-summary-mail-forward
7005 "o" gnus-summary-save-article
7006 "\C-o" gnus-summary-save-article-mail
7007 "|" gnus-summary-pipe-output
7008 "\M-k" gnus-summary-edit-local-kill
7009 "\M-K" gnus-summary-edit-global-kill
7011 "\C-c\C-d" gnus-summary-describe-group
7012 "q" gnus-summary-exit
7013 "Q" gnus-summary-exit-no-update
7014 "\C-c\C-i" gnus-info-find-node
7015 gnus-mouse-2 gnus-mouse-pick-article
7016 "m" gnus-summary-mail-other-window
7017 "a" gnus-summary-post-news
7018 "x" gnus-summary-limit-to-unread
7019 "s" gnus-summary-isearch-article
7020 "t" gnus-article-hide-headers
7021 "g" gnus-summary-show-article
7022 "l" gnus-summary-goto-last-article
7023 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
7024 "\C-d" gnus-summary-enter-digest-group
7026 "*" gnus-cache-enter-article
7027 "\M-*" gnus-cache-remove-article
7028 "\M-&" gnus-summary-universal-argument
7029 "\C-l" gnus-recenter
7030 "I" gnus-summary-increase-score
7031 "L" gnus-summary-lower-score
7033 "V" gnus-summary-score-map
7034 "X" gnus-uu-extract-map
7035 "S" gnus-summary-send-map)
7037 ;; Sort of orthogonal keymap
7038 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
7039 "t" gnus-summary-tick-article-forward
7040 "!" gnus-summary-tick-article-forward
7041 "d" gnus-summary-mark-as-read-forward
7042 "r" gnus-summary-mark-as-read-forward
7043 "c" gnus-summary-clear-mark-forward
7044 " " gnus-summary-clear-mark-forward
7045 "e" gnus-summary-mark-as-expirable
7046 "x" gnus-summary-mark-as-expirable
7047 "?" gnus-summary-mark-as-dormant
7048 "b" gnus-summary-set-bookmark
7049 "B" gnus-summary-remove-bookmark
7050 "#" gnus-summary-mark-as-processable
7051 "\M-#" gnus-summary-unmark-as-processable
7052 "S" gnus-summary-limit-include-expunged
7053 "C" gnus-summary-catchup
7054 "H" gnus-summary-catchup-to-here
7055 "\C-c" gnus-summary-catchup-all
7056 "k" gnus-summary-kill-same-subject-and-select
7057 "K" gnus-summary-kill-same-subject
7058 "P" gnus-uu-mark-map)
7060 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7061 "c" gnus-summary-clear-above
7062 "u" gnus-summary-tick-above
7063 "m" gnus-summary-mark-above
7064 "k" gnus-summary-kill-below)
7066 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7067 "/" gnus-summary-limit-to-subject
7068 "n" gnus-summary-limit-to-articles
7069 "w" gnus-summary-pop-limit
7070 "s" gnus-summary-limit-to-subject
7071 "a" gnus-summary-limit-to-author
7072 "u" gnus-summary-limit-to-unread
7073 "m" gnus-summary-limit-to-marks
7074 "v" gnus-summary-limit-to-score
7075 "D" gnus-summary-limit-include-dormant
7076 "d" gnus-summary-limit-exclude-dormant
7077 ;; "t" gnus-summary-limit-exclude-thread
7078 "E" gnus-summary-limit-include-expunged
7079 "c" gnus-summary-limit-exclude-childless-dormant
7080 "C" gnus-summary-limit-mark-excluded-as-read)
7082 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7083 "n" gnus-summary-next-unread-article
7084 "p" gnus-summary-prev-unread-article
7085 "N" gnus-summary-next-article
7086 "P" gnus-summary-prev-article
7087 "\C-n" gnus-summary-next-same-subject
7088 "\C-p" gnus-summary-prev-same-subject
7089 "\M-n" gnus-summary-next-unread-subject
7090 "\M-p" gnus-summary-prev-unread-subject
7091 "f" gnus-summary-first-unread-article
7092 "b" gnus-summary-best-unread-article
7093 "j" gnus-summary-goto-article
7094 "g" gnus-summary-goto-subject
7095 "l" gnus-summary-goto-last-article
7096 "p" gnus-summary-pop-article)
7098 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7099 "k" gnus-summary-kill-thread
7100 "l" gnus-summary-lower-thread
7101 "i" gnus-summary-raise-thread
7102 "T" gnus-summary-toggle-threads
7103 "t" gnus-summary-rethread-current
7104 "^" gnus-summary-reparent-thread
7105 "s" gnus-summary-show-thread
7106 "S" gnus-summary-show-all-threads
7107 "h" gnus-summary-hide-thread
7108 "H" gnus-summary-hide-all-threads
7109 "n" gnus-summary-next-thread
7110 "p" gnus-summary-prev-thread
7111 "u" gnus-summary-up-thread
7112 "o" gnus-summary-top-thread
7113 "d" gnus-summary-down-thread
7114 "#" gnus-uu-mark-thread
7115 "\M-#" gnus-uu-unmark-thread)
7117 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7118 "c" gnus-summary-catchup-and-exit
7119 "C" gnus-summary-catchup-all-and-exit
7120 "E" gnus-summary-exit-no-update
7121 "Q" gnus-summary-exit
7122 "Z" gnus-summary-exit
7123 "n" gnus-summary-catchup-and-goto-next-group
7124 "R" gnus-summary-reselect-current-group
7125 "G" gnus-summary-rescan-group
7126 "N" gnus-summary-next-group
7127 "P" gnus-summary-prev-group)
7129 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7130 " " gnus-summary-next-page
7131 "n" gnus-summary-next-page
7132 "\177" gnus-summary-prev-page
7133 [delete] gnus-summary-prev-page
7134 "p" gnus-summary-prev-page
7135 "\r" gnus-summary-scroll-up
7136 "<" gnus-summary-beginning-of-article
7137 ">" gnus-summary-end-of-article
7138 "b" gnus-summary-beginning-of-article
7139 "e" gnus-summary-end-of-article
7140 "^" gnus-summary-refer-parent-article
7141 "r" gnus-summary-refer-parent-article
7142 "R" gnus-summary-refer-references
7143 "g" gnus-summary-show-article
7144 "s" gnus-summary-isearch-article)
7146 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7147 "b" gnus-article-add-buttons
7148 "B" gnus-article-add-buttons-to-head
7149 "o" gnus-article-treat-overstrike
7150 ;; "w" gnus-article-word-wrap
7151 "w" gnus-article-fill-cited-article
7152 "c" gnus-article-remove-cr
7153 "L" gnus-article-remove-trailing-blank-lines
7154 "q" gnus-article-de-quoted-unreadable
7155 "f" gnus-article-display-x-face
7156 "l" gnus-summary-stop-page-breaking
7157 "r" gnus-summary-caesar-message
7158 "t" gnus-article-hide-headers
7159 "v" gnus-summary-verbose-headers
7160 "m" gnus-summary-toggle-mime)
7162 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7163 "a" gnus-article-hide
7164 "h" gnus-article-hide-headers
7165 "b" gnus-article-hide-boring-headers
7166 "s" gnus-article-hide-signature
7167 "c" gnus-article-hide-citation
7168 "p" gnus-article-hide-pgp
7169 "\C-c" gnus-article-hide-citation-maybe)
7171 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7172 "a" gnus-article-highlight
7173 "h" gnus-article-highlight-headers
7174 "c" gnus-article-highlight-citation
7175 "s" gnus-article-highlight-signature)
7177 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7178 "z" gnus-article-date-ut
7179 "u" gnus-article-date-ut
7180 "l" gnus-article-date-local
7181 "e" gnus-article-date-lapsed
7182 "o" gnus-article-date-original)
7184 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7186 "f" gnus-summary-fetch-faq
7187 "d" gnus-summary-describe-group
7188 "h" gnus-summary-describe-briefly
7189 "i" gnus-info-find-node)
7191 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7192 "e" gnus-summary-expire-articles
7193 "\M-\C-e" gnus-summary-expire-articles-now
7194 "\177" gnus-summary-delete-article
7195 [delete] gnus-summary-delete-article
7196 "m" gnus-summary-move-article
7197 "r" gnus-summary-respool-article
7198 "w" gnus-summary-edit-article
7199 "c" gnus-summary-copy-article
7200 "B" gnus-summary-crosspost-article
7201 "q" gnus-summary-respool-query
7202 "i" gnus-summary-import-article)
7204 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7205 "o" gnus-summary-save-article
7206 "m" gnus-summary-save-article-mail
7207 "r" gnus-summary-save-article-rmail
7208 "f" gnus-summary-save-article-file
7209 "b" gnus-summary-save-article-body-file
7210 "h" gnus-summary-save-article-folder
7211 "v" gnus-summary-save-article-vm
7212 "p" gnus-summary-pipe-output
7213 "s" gnus-soup-add-article)
7218 (defun gnus-summary-mode (&optional group)
7219 "Major mode for reading articles.
7221 All normal editing commands are switched off.
7222 \\<gnus-summary-mode-map>
7223 Each line in this buffer represents one article. To read an
7224 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7225 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7228 You can also post articles and send mail from this buffer. To
7229 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7230 of an article, type `\\[gnus-summary-reply]'.
7232 There are approx. one gazillion commands you can execute in this
7233 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7235 The following commands are available:
7237 \\{gnus-summary-mode-map}"
7239 (when (and menu-bar-mode
7240 (gnus-visual-p 'summary-menu 'menu))
7241 (gnus-summary-make-menu-bar))
7242 (kill-all-local-variables)
7243 (gnus-summary-make-local-variables)
7244 (gnus-make-thread-indent-array)
7245 (gnus-simplify-mode-line)
7246 (setq major-mode 'gnus-summary-mode)
7247 (setq mode-name "Summary")
7248 (make-local-variable 'minor-mode-alist)
7249 (use-local-map gnus-summary-mode-map)
7250 (buffer-disable-undo (current-buffer))
7251 (setq buffer-read-only t) ;Disable modification
7252 (setq truncate-lines t)
7253 (setq selective-display t)
7254 (setq selective-display-ellipses t) ;Display `...'
7255 (setq buffer-display-table gnus-summary-display-table)
7256 (setq gnus-newsgroup-name group)
7257 (make-local-variable 'gnus-summary-line-format)
7258 (make-local-variable 'gnus-summary-line-format-spec)
7259 (make-local-variable 'gnus-summary-mark-positions)
7260 (gnus-make-local-hook 'post-command-hook)
7261 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
7262 (run-hooks 'gnus-summary-mode-hook))
7264 (defun gnus-summary-make-local-variables ()
7265 "Make all the local summary buffer variables."
7266 (let ((locals gnus-summary-local-variables)
7268 (while (setq local (pop locals))
7271 (if (eq (cdr local) 'global)
7272 ;; Copy the global value of the variable.
7273 (setq global (symbol-value (car local)))
7274 ;; Use the value from the list.
7275 (setq global (eval (cdr local))))
7276 (make-local-variable (car local))
7277 (set (car local) global))
7278 ;; Simple nil-valued local variable.
7279 (make-local-variable local)
7282 (defun gnus-summary-make-display-table ()
7283 ;; Change the display table. Odd characters have a tendency to mess
7284 ;; up nicely formatted displays - we make all possible glyphs
7285 ;; display only a single character.
7287 ;; We start from the standard display table, if any.
7288 (setq gnus-summary-display-table
7289 (or (copy-sequence standard-display-table)
7290 (make-display-table)))
7291 ;; Nix out all the control chars...
7293 (while (>= (setq i (1- i)) 0)
7294 (aset gnus-summary-display-table i [??])))
7295 ;; ... but not newline and cr, of course. (cr is necessary for the
7296 ;; selective display).
7297 (aset gnus-summary-display-table ?\n nil)
7298 (aset gnus-summary-display-table ?\r nil)
7299 ;; We nix out any glyphs over 126 that are not set already.
7301 (while (>= (setq i (1- i)) 127)
7302 ;; Only modify if the entry is nil.
7303 (or (aref gnus-summary-display-table i)
7304 (aset gnus-summary-display-table i [??])))))
7306 (defun gnus-summary-clear-local-variables ()
7307 (let ((locals gnus-summary-local-variables))
7309 (if (consp (car locals))
7310 (and (vectorp (caar locals))
7311 (set (caar locals) nil))
7312 (and (vectorp (car locals))
7313 (set (car locals) nil)))
7314 (setq locals (cdr locals)))))
7316 ;; Summary data functions.
7318 (defmacro gnus-data-number (data)
7321 (defmacro gnus-data-set-number (data number)
7322 `(setcar ,data ,number))
7324 (defmacro gnus-data-mark (data)
7327 (defmacro gnus-data-set-mark (data mark)
7328 `(setcar (nthcdr 1 ,data) ,mark))
7330 (defmacro gnus-data-pos (data)
7333 (defmacro gnus-data-set-pos (data pos)
7334 `(setcar (nthcdr 2 ,data) ,pos))
7336 (defmacro gnus-data-header (data)
7339 (defmacro gnus-data-level (data)
7342 (defmacro gnus-data-unread-p (data)
7343 `(= (nth 1 ,data) gnus-unread-mark))
7345 (defmacro gnus-data-pseudo-p (data)
7346 `(consp (nth 3 ,data)))
7348 (defmacro gnus-data-find (number)
7349 `(assq ,number gnus-newsgroup-data))
7351 (defmacro gnus-data-find-list (number &optional data)
7352 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7353 (memq (assq ,number bdata)
7356 (defmacro gnus-data-make (number mark pos header level)
7357 `(list ,number ,mark ,pos ,header ,level))
7359 (defun gnus-data-enter (after-article number mark pos header level offset)
7360 (let ((data (gnus-data-find-list after-article)))
7361 (or data (error "No such article: %d" after-article))
7362 (setcdr data (cons (gnus-data-make number mark pos header level)
7364 (setq gnus-newsgroup-data-reverse nil)
7365 (gnus-data-update-list (cddr data) offset)))
7367 (defun gnus-data-enter-list (after-article list &optional offset)
7369 (let ((data (and after-article (gnus-data-find-list after-article)))
7371 (or data (not after-article) (error "No such article: %d" after-article))
7372 ;; Find the last element in the list to be spliced into the main
7375 (setq list (cdr list)))
7378 (setcdr list gnus-newsgroup-data)
7379 (setq gnus-newsgroup-data ilist)
7380 (and offset (gnus-data-update-list (cdr list) offset)))
7381 (setcdr list (cdr data))
7383 (and offset (gnus-data-update-list (cdr data) offset)))
7384 (setq gnus-newsgroup-data-reverse nil))))
7386 (defun gnus-data-remove (article &optional offset)
7387 (let ((data gnus-newsgroup-data))
7388 (if (= (gnus-data-number (car data)) article)
7389 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7390 gnus-newsgroup-data-reverse nil)
7392 (and (= (gnus-data-number (cadr data)) article)
7394 (setcdr data (cddr data))
7395 (and offset (gnus-data-update-list (cdr data) offset))
7397 gnus-newsgroup-data-reverse nil)))
7398 (setq data (cdr data))))))
7400 (defmacro gnus-data-list (backward)
7402 (or gnus-newsgroup-data-reverse
7403 (setq gnus-newsgroup-data-reverse
7404 (reverse gnus-newsgroup-data)))
7405 gnus-newsgroup-data))
7407 (defun gnus-data-update-list (data offset)
7408 "Add OFFSET to the POS of all data entries in DATA."
7410 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7411 (setq data (cdr data))))
7413 (defun gnus-data-compute-positions ()
7414 "Compute the positions of all articles."
7415 (let ((data gnus-newsgroup-data)
7418 (when (setq pos (text-property-any
7419 (point-min) (point-max)
7420 'gnus-number (gnus-data-number (car data))))
7421 (gnus-data-set-pos (car data) (+ pos 3)))
7422 (setq data (cdr data)))))
7424 (defun gnus-summary-article-pseudo-p (article)
7425 "Say whether this article is a pseudo article or not."
7426 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7428 (defun gnus-article-parent-p (number)
7429 "Say whether this article is a parent or not."
7430 (let ((data (gnus-data-find-list number)))
7431 (and (cdr data) ; There has to be an article after...
7432 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7433 (gnus-data-level (nth 1 data))))))
7435 (defun gnus-article-children (number)
7436 "Return a list of all children to NUMBER."
7437 (let* ((data (gnus-data-find-list number))
7438 (level (gnus-data-level (car data)))
7440 (setq data (cdr data))
7442 (= (gnus-data-level (car data)) (1+ level)))
7443 (push (gnus-data-number (car data)) children)
7444 (setq data (cdr data)))
7447 (defmacro gnus-summary-skip-intangible ()
7448 "If the current article is intangible, then jump to a different article."
7449 '(let ((to (get-text-property (point) 'gnus-intangible)))
7450 (and to (gnus-summary-goto-subject to))))
7452 (defmacro gnus-summary-article-intangible-p ()
7453 "Say whether this article is intangible or not."
7454 '(get-text-property (point) 'gnus-intangible))
7456 ;; Some summary mode macros.
7458 (defmacro gnus-summary-article-number ()
7459 "The article number of the article on the current line.
7460 If there isn's an article number here, then we return the current
7463 (gnus-summary-skip-intangible)
7464 (or (get-text-property (point) 'gnus-number)
7465 (gnus-summary-last-subject))))
7467 (defmacro gnus-summary-article-header (&optional number)
7468 `(gnus-data-header (gnus-data-find
7469 ,(or number '(gnus-summary-article-number)))))
7471 (defmacro gnus-summary-thread-level (&optional number)
7472 `(if (and (eq gnus-summary-make-false-root 'dummy)
7473 (get-text-property (point) 'gnus-intangible))
7475 (gnus-data-level (gnus-data-find
7476 ,(or number '(gnus-summary-article-number))))))
7478 (defmacro gnus-summary-article-mark (&optional number)
7479 `(gnus-data-mark (gnus-data-find
7480 ,(or number '(gnus-summary-article-number)))))
7482 (defmacro gnus-summary-article-pos (&optional number)
7483 `(gnus-data-pos (gnus-data-find
7484 ,(or number '(gnus-summary-article-number)))))
7486 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7487 (defmacro gnus-summary-article-subject (&optional number)
7488 "Return current subject string or nil if nothing."
7491 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7492 '(gnus-data-header (assq (gnus-summary-article-number)
7493 gnus-newsgroup-data)))))
7496 (mail-header-subject headers))))
7498 (defmacro gnus-summary-article-score (&optional number)
7499 "Return current article score."
7500 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7501 gnus-newsgroup-scored))
7502 gnus-summary-default-score 0))
7504 (defun gnus-summary-article-children (&optional number)
7505 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7506 (level (gnus-data-level (car data)))
7508 (while (and (setq data (cdr data))
7509 (> (setq l (gnus-data-level (car data))) level))
7510 (and (= (1+ level) l)
7511 (setq children (cons (gnus-data-number (car data))
7513 (nreverse children)))
7515 (defun gnus-summary-article-parent (&optional number)
7516 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7517 (gnus-data-list t)))
7518 (level (gnus-data-level (car data))))
7520 () ; This is a root.
7521 ;; We search until we find an article with a level less than
7522 ;; this one. That function has to be the parent.
7523 (while (and (setq data (cdr data))
7524 (not (< (gnus-data-level (car data)) level))))
7525 (and data (gnus-data-number (car data))))))
7527 (defun gnus-unread-mark-p (mark)
7528 "Say whether MARK is the unread mark."
7529 (= mark gnus-unread-mark))
7531 (defun gnus-read-mark-p (mark)
7532 "Say whether MARK is one of the marks that mark as read.
7533 This is all marks except unread, ticked, dormant, and expirable."
7534 (not (or (= mark gnus-unread-mark)
7535 (= mark gnus-ticked-mark)
7536 (= mark gnus-dormant-mark)
7537 (= mark gnus-expirable-mark))))
7539 ;; Saving hidden threads.
7541 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7542 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7543 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7545 (defmacro gnus-save-hidden-threads (&rest forms)
7546 "Save hidden threads, eval FORMS, and restore the hidden threads."
7547 (let ((config (make-symbol "config")))
7548 `(let ((,config (gnus-hidden-threads-configuration)))
7552 (gnus-restore-hidden-threads-configuration ,config)))))
7554 (defun gnus-hidden-threads-configuration ()
7555 "Return the current hidden threads configuration."
7558 (goto-char (point-min))
7559 (while (search-forward "\r" nil t)
7560 (push (1- (point)) config))
7563 (defun gnus-restore-hidden-threads-configuration (config)
7564 "Restore hidden threads configuration from CONFIG."
7565 (let (point buffer-read-only)
7566 (while (setq point (pop config))
7567 (when (and (< point (point-max))
7569 (= (following-char) ?\n))
7570 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7572 ;; Various summary mode internalish functions.
7574 (defun gnus-mouse-pick-article (e)
7577 (gnus-summary-next-page nil t))
7579 (defun gnus-summary-setup-buffer (group)
7580 "Initialize summary buffer."
7581 (let ((buffer (concat "*Summary " group "*")))
7582 (if (get-buffer buffer)
7585 (setq gnus-summary-buffer (current-buffer))
7586 (not gnus-newsgroup-prepared))
7587 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7588 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7589 (gnus-add-current-to-buffer-list)
7590 (gnus-summary-mode group)
7592 (gnus-carpal-setup-buffer 'summary))
7593 (unless gnus-single-article-buffer
7594 (make-local-variable 'gnus-article-buffer)
7595 (make-local-variable 'gnus-article-current)
7596 (make-local-variable 'gnus-original-article-buffer))
7597 (setq gnus-newsgroup-name group)
7600 (defun gnus-set-global-variables ()
7601 ;; Set the global equivalents of the summary buffer-local variables
7602 ;; to the latest values they had. These reflect the summary buffer
7603 ;; that was in action when the last article was fetched.
7604 (when (eq major-mode 'gnus-summary-mode)
7605 (setq gnus-summary-buffer (current-buffer))
7606 (let ((name gnus-newsgroup-name)
7607 (marked gnus-newsgroup-marked)
7608 (unread gnus-newsgroup-unreads)
7609 (headers gnus-current-headers)
7610 (data gnus-newsgroup-data)
7611 (summary gnus-summary-buffer)
7612 (article-buffer gnus-article-buffer)
7613 (original gnus-original-article-buffer)
7614 (gac gnus-article-current)
7615 (score-file gnus-current-score-file))
7617 (set-buffer gnus-group-buffer)
7618 (setq gnus-newsgroup-name name)
7619 (setq gnus-newsgroup-marked marked)
7620 (setq gnus-newsgroup-unreads unread)
7621 (setq gnus-current-headers headers)
7622 (setq gnus-newsgroup-data data)
7623 (setq gnus-article-current gac)
7624 (setq gnus-summary-buffer summary)
7625 (setq gnus-article-buffer article-buffer)
7626 (setq gnus-original-article-buffer original)
7627 (setq gnus-current-score-file score-file)))))
7629 (defun gnus-summary-last-article-p (&optional article)
7630 "Return whether ARTICLE is the last article in the buffer."
7631 (if (not (setq article (or article (gnus-summary-article-number))))
7632 t ; All non-existant numbers are the last article. :-)
7633 (not (cdr (gnus-data-find-list article)))))
7635 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7636 "Insert a dummy root in the summary buffer."
7638 (gnus-add-text-properties
7639 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7640 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7642 (defun gnus-make-thread-indent-array ()
7644 (unless (and gnus-thread-indent-array
7645 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7646 (setq gnus-thread-indent-array (make-vector 201 "")
7647 gnus-thread-indent-array-level gnus-thread-indent-level)
7649 (aset gnus-thread-indent-array n
7650 (make-string (* n gnus-thread-indent-level) ? ))
7653 (defun gnus-summary-insert-line
7654 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7655 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7656 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7657 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7658 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7659 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7660 (gnus-tmp-score-char
7661 (if (or (null gnus-summary-default-score)
7662 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7663 gnus-summary-zcore-fuzz)) ?
7664 (if (< gnus-tmp-score gnus-summary-default-score)
7665 gnus-score-below-mark gnus-score-over-mark)))
7666 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7667 ((memq gnus-tmp-current gnus-newsgroup-cached)
7669 (gnus-tmp-replied gnus-replied-mark)
7670 ((memq gnus-tmp-current gnus-newsgroup-saved)
7672 (t gnus-unread-mark)))
7673 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7676 ((string-match "(.+)" gnus-tmp-from)
7677 (substring gnus-tmp-from
7678 (1+ (match-beginning 0)) (1- (match-end 0))))
7679 ((string-match "<[^>]+> *$" gnus-tmp-from)
7680 (let ((beg (match-beginning 0)))
7681 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7682 (substring gnus-tmp-from (1+ (match-beginning 0))
7683 (1- (match-end 0))))
7684 (substring gnus-tmp-from 0 beg))))
7686 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7687 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7688 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7689 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7690 (buffer-read-only nil))
7691 (when (string= gnus-tmp-name "")
7692 (setq gnus-tmp-name gnus-tmp-from))
7693 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7694 (gnus-put-text-property
7696 (progn (eval gnus-summary-line-format-spec) (point))
7697 'gnus-number gnus-tmp-number)
7698 (when (gnus-visual-p 'summary-highlight 'highlight)
7700 (run-hooks 'gnus-summary-update-hook)
7703 (defun gnus-summary-update-line (&optional dont-update)
7704 ;; Update summary line after change.
7705 (when (and gnus-summary-default-score
7706 (not gnus-summary-inhibit-highlight))
7707 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7708 (article (gnus-summary-article-number))
7709 (score (gnus-summary-article-score article)))
7711 (if (and gnus-summary-mark-below
7712 (< (gnus-summary-article-score)
7713 gnus-summary-mark-below))
7714 ;; This article has a low score, so we mark it as read.
7715 (when (memq article gnus-newsgroup-unreads)
7716 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7717 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7718 ;; This article was previously marked as read on account
7719 ;; of a low score, but now it has risen, so we mark it as
7721 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7722 (gnus-summary-update-mark
7723 (if (or (null gnus-summary-default-score)
7724 (<= (abs (- score gnus-summary-default-score))
7725 gnus-summary-zcore-fuzz)) ?
7726 (if (< score gnus-summary-default-score)
7727 gnus-score-below-mark gnus-score-over-mark)) 'score))
7728 ;; Do visual highlighting.
7729 (when (gnus-visual-p 'summary-highlight 'highlight)
7730 (run-hooks 'gnus-summary-update-hook)))))
7732 (defvar gnus-tmp-new-adopts nil)
7734 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7735 ;; Sum up all elements (and sub-elements) in a list.
7737 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7739 ((and (consp thread) (cdr thread))
7742 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7745 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7748 (when (and level (zerop level) gnus-tmp-new-adopts)
7751 'gnus-summary-number-of-articles-in-thread
7752 gnus-tmp-new-adopts))))
7754 (if (> number 1) gnus-not-empty-thread-mark
7755 gnus-empty-thread-mark)
7758 (defun gnus-summary-set-local-parameters (group)
7759 "Go through the local params of GROUP and set all variable specs in that list."
7760 (let ((params (gnus-info-params (gnus-get-info group)))
7763 (setq elem (car params)
7764 params (cdr params))
7765 (and (consp elem) ; Has to be a cons.
7766 (consp (cdr elem)) ; The cdr has to be a list.
7767 (symbolp (car elem)) ; Has to be a symbol in there.
7768 (not (memq (car elem)
7769 '(quit-config to-address to-list to-group)))
7770 (progn ; So we set it.
7771 (make-local-variable (car elem))
7772 (set (car elem) (eval (nth 1 elem))))))))
7774 (defun gnus-summary-read-group (group &optional show-all no-article
7775 kill-buffer no-display)
7776 "Start reading news in newsgroup GROUP.
7777 If SHOW-ALL is non-nil, already read articles are also listed.
7778 If NO-ARTICLE is non-nil, no article is selected initially.
7779 If NO-DISPLAY, don't generate a summary buffer."
7780 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7781 (let* ((new-group (gnus-summary-setup-buffer group))
7782 (quit-config (gnus-group-quit-config group))
7783 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7785 ;; This summary buffer exists already, so we just select it.
7787 (gnus-set-global-variables)
7789 (gnus-kill-or-deaden-summary kill-buffer))
7790 (gnus-configure-windows 'summary 'force)
7791 (gnus-set-mode-line 'summary)
7792 (gnus-summary-position-point)
7795 ;; We couldn't select this group.
7797 (when (and (eq major-mode 'gnus-summary-mode)
7798 (not (equal (current-buffer) kill-buffer)))
7799 (kill-buffer (current-buffer))
7800 (if (not quit-config)
7802 (set-buffer gnus-group-buffer)
7803 (gnus-group-jump-to-group group)
7804 (gnus-group-next-unread-group 1))
7805 (if (not (buffer-name (car quit-config)))
7806 (gnus-configure-windows 'group 'force)
7807 (set-buffer (car quit-config))
7808 (and (eq major-mode 'gnus-summary-mode)
7809 (gnus-set-global-variables))
7810 (gnus-configure-windows (cdr quit-config)))))
7811 (gnus-message 3 "Can't select group")
7813 ;; The user did a `C-g' while prompting for number of articles,
7814 ;; so we exit this group.
7815 ((eq did-select 'quit)
7816 (and (eq major-mode 'gnus-summary-mode)
7817 (not (equal (current-buffer) kill-buffer))
7818 (kill-buffer (current-buffer)))
7820 (gnus-kill-or-deaden-summary kill-buffer))
7821 (if (not quit-config)
7823 (set-buffer gnus-group-buffer)
7824 (gnus-group-jump-to-group group)
7825 (gnus-group-next-unread-group 1)
7826 (gnus-configure-windows 'group 'force))
7827 (if (not (buffer-name (car quit-config)))
7828 (gnus-configure-windows 'group 'force)
7829 (set-buffer (car quit-config))
7830 (and (eq major-mode 'gnus-summary-mode)
7831 (gnus-set-global-variables))
7832 (gnus-configure-windows (cdr quit-config))))
7833 ;; Finally signal the quit.
7835 ;; The group was successfully selected.
7837 (gnus-set-global-variables)
7838 ;; Save the active value in effect when the group was entered.
7839 (setq gnus-newsgroup-active
7841 (gnus-active gnus-newsgroup-name)))
7842 ;; You can change the summary buffer in some way with this hook.
7843 (run-hooks 'gnus-select-group-hook)
7844 ;; Set any local variables in the group parameters.
7845 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7846 (gnus-update-format-specifications)
7847 ;; Do score processing.
7848 (when gnus-use-scoring
7849 (gnus-possibly-score-headers))
7850 ;; Check whether to fill in the gaps in the threads.
7851 (when gnus-build-sparse-threads
7852 (gnus-build-sparse-threads))
7853 ;; Find the initial limit.
7854 (if gnus-show-threads
7856 (let ((gnus-newsgroup-dormant nil))
7857 (gnus-summary-initial-limit show-all))
7858 (gnus-summary-initial-limit show-all))
7859 (setq gnus-newsgroup-limit
7861 (lambda (header) (mail-header-number header))
7862 gnus-newsgroup-headers)))
7863 ;; Generate the summary buffer.
7865 (gnus-summary-prepare))
7866 (when gnus-use-trees
7867 (gnus-tree-open group)
7868 (setq gnus-summary-highlight-line-function
7869 'gnus-tree-highlight-article))
7870 ;; If the summary buffer is empty, but there are some low-scored
7871 ;; articles or some excluded dormants, we include these in the
7873 (when (and (zerop (buffer-size))
7875 (cond (gnus-newsgroup-dormant
7876 (gnus-summary-limit-include-dormant))
7877 ((and gnus-newsgroup-scored show-all)
7878 (gnus-summary-limit-include-expunged t))))
7879 ;; Function `gnus-apply-kill-file' must be called in this hook.
7880 (run-hooks 'gnus-apply-kill-hook)
7881 (if (and (zerop (buffer-size))
7884 ;; This newsgroup is empty.
7885 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7886 (gnus-message 6 "No unread news")
7888 (gnus-kill-or-deaden-summary kill-buffer))
7889 ;; Return nil from this function.
7891 ;; Hide conversation thread subtrees. We cannot do this in
7892 ;; gnus-summary-prepare-hook since kill processing may not
7893 ;; work with hidden articles.
7894 (and gnus-show-threads
7895 gnus-thread-hide-subtree
7896 (gnus-summary-hide-all-threads))
7897 ;; Show first unread article if requested.
7898 (if (and (not no-article)
7900 gnus-newsgroup-unreads
7901 gnus-auto-select-first)
7902 (unless (if (eq gnus-auto-select-first 'best)
7903 (gnus-summary-best-unread-article)
7904 (gnus-summary-first-unread-article))
7905 (gnus-configure-windows 'summary))
7906 ;; Don't select any articles, just move point to the first
7907 ;; article in the group.
7908 (goto-char (point-min))
7909 (gnus-summary-position-point)
7910 (gnus-set-mode-line 'summary)
7911 (gnus-configure-windows 'summary 'force))
7912 ;; If we are in async mode, we send some info to the backend.
7913 (when gnus-newsgroup-async
7914 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7916 (gnus-kill-or-deaden-summary kill-buffer))
7917 (when (get-buffer-window gnus-group-buffer t)
7918 ;; Gotta use windows, because recenter does wierd stuff if
7919 ;; the current buffer ain't the displayed window.
7920 (let ((owin (selected-window)))
7921 (select-window (get-buffer-window gnus-group-buffer t))
7922 (when (gnus-group-goto-group group)
7924 (select-window owin))))
7925 ;; Mark this buffer as "prepared".
7926 (setq gnus-newsgroup-prepared t)
7929 (defun gnus-summary-prepare ()
7930 "Generate the summary buffer."
7931 (let ((buffer-read-only nil))
7933 (setq gnus-newsgroup-data nil
7934 gnus-newsgroup-data-reverse nil)
7935 (run-hooks 'gnus-summary-generate-hook)
7936 ;; Generate the buffer, either with threads or without.
7937 (when gnus-newsgroup-headers
7938 (gnus-summary-prepare-threads
7939 (if gnus-show-threads
7940 (gnus-sort-gathered-threads
7941 (funcall gnus-summary-thread-gathering-function
7943 (gnus-cut-threads (gnus-make-threads)))))
7944 ;; Unthreaded display.
7945 (gnus-sort-articles gnus-newsgroup-headers))))
7946 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7947 ;; Call hooks for modifying summary buffer.
7948 (goto-char (point-min))
7949 (run-hooks 'gnus-summary-prepare-hook)))
7951 (defun gnus-gather-threads-by-subject (threads)
7952 "Gather threads by looking at Subject headers."
7953 (if (not gnus-summary-make-false-root)
7955 (let ((hashtb (gnus-make-hashtable 1023))
7958 subject hthread whole-subject)
7960 (setq whole-subject (mail-header-subject (caar threads)))
7963 ;; Truncate the subject.
7964 ((numberp gnus-summary-gather-subject-limit)
7965 (setq subject (gnus-simplify-subject-re whole-subject))
7966 (if (> (length subject) gnus-summary-gather-subject-limit)
7967 (substring subject 0 gnus-summary-gather-subject-limit)
7969 ;; Fuzzily simplify it.
7970 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7971 (gnus-simplify-subject-fuzzy whole-subject))
7972 ;; Just remove the leading "Re:".
7974 (gnus-simplify-subject-re whole-subject))))
7976 (if (and gnus-summary-gather-exclude-subject
7977 (string-match gnus-summary-gather-exclude-subject
7979 () ; We don't want to do anything with this article.
7980 ;; We simplify the subject before looking it up in the
7983 (if (setq hthread (gnus-gethash subject hashtb))
7985 ;; We enter a dummy root into the thread, if we
7986 ;; haven't done that already.
7987 (unless (stringp (caar hthread))
7988 (setcar hthread (list whole-subject (car hthread))))
7989 ;; We add this new gathered thread to this gathered
7991 (setcdr (car hthread)
7992 (nconc (cdar hthread) (list (car threads))))
7993 ;; Remove it from the list of threads.
7994 (setcdr prev (cdr threads))
7995 (setq threads prev))
7996 ;; Enter this thread into the hash table.
7997 (gnus-sethash subject threads hashtb)))
7999 (setq threads (cdr threads)))
8002 (defun gnus-gather-threads-by-references (threads)
8003 "Gather threads by looking at References headers."
8004 (let ((idhashtb (gnus-make-hashtable 1023))
8005 (thhashtb (gnus-make-hashtable 1023))
8008 ids references id gthread gid entered)
8010 (when (setq references (mail-header-references (caar threads)))
8011 (setq id (mail-header-id (caar threads)))
8012 (setq ids (gnus-split-references references))
8015 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
8017 (gnus-sethash (car ids) id idhashtb)
8018 (gnus-sethash id threads thhashtb))
8019 (setq gthread (gnus-gethash gid thhashtb))
8021 ;; We enter a dummy root into the thread, if we
8022 ;; haven't done that already.
8023 (unless (stringp (caar gthread))
8024 (setcar gthread (list (mail-header-subject (caar gthread))
8026 ;; We add this new gathered thread to this gathered
8028 (setcdr (car gthread)
8029 (nconc (cdar gthread) (list (car threads)))))
8030 ;; Add it into the thread hash table.
8031 (gnus-sethash id gthread thhashtb)
8033 ;; Remove it from the list of threads.
8034 (setcdr prev (cdr threads))
8035 (setq threads prev))
8036 (setq ids (cdr ids))))
8038 (setq threads (cdr threads)))
8041 (defun gnus-sort-gathered-threads (threads)
8042 "Sort subtreads inside each gathered thread by article number."
8043 (let ((result threads))
8045 (when (stringp (caar threads))
8046 (setcdr (car threads)
8047 (sort (cdar threads) 'gnus-thread-sort-by-number)))
8048 (setq threads (cdr threads)))
8051 (defun gnus-make-threads ()
8052 "Go through the dependency hashtb and find the roots. Return all threads."
8056 (unless (car (symbol-value refs))
8057 ;; These threads do not refer back to any other articles,
8058 ;; so they're roots.
8059 (setq threads (append (cdr (symbol-value refs)) threads))))
8060 gnus-newsgroup-dependencies)
8063 (defun gnus-build-sparse-threads ()
8064 (let ((headers gnus-newsgroup-headers)
8065 (deps gnus-newsgroup-dependencies)
8066 header references generation relations
8067 cthread subject child end pthread relation)
8068 ;; First we create an alist of generations/relations, where
8069 ;; generations is how much we trust the ralation, and the relation
8071 (gnus-message 7 "Making sparse threads...")
8073 (nnheader-set-temp-buffer " *gnus sparse threads*")
8074 (while (setq header (pop headers))
8075 (when (and (setq references (mail-header-references header))
8076 (not (string= references "")))
8078 (setq child (mail-header-id header)
8079 subject (mail-header-subject header))
8081 (while (search-backward ">" nil t)
8082 (setq end (1+ (point)))
8083 (when (search-backward "<" nil t)
8084 (push (list (incf generation)
8085 child (setq child (buffer-substring (point) end))
8088 (push (list (1+ generation) child nil subject) relations)
8090 (kill-buffer (current-buffer)))
8091 ;; Sort over trustworthiness.
8092 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8093 (while (setq relation (pop relations))
8094 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8095 (unless (car (symbol-value cthread))
8096 ;; Make this article the parent of these threads.
8097 (setcar (symbol-value cthread)
8098 (vector gnus-reffed-article-number
8102 (or (caddr relation) "") 0 0 "")))
8103 (set cthread (list (vector gnus-reffed-article-number
8105 "" "" (cadr relation)
8106 (or (caddr relation) "") 0 0 ""))))
8107 (push gnus-reffed-article-number gnus-newsgroup-limit)
8108 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8109 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8110 gnus-newsgroup-reads)
8111 (decf gnus-reffed-article-number)
8112 ;; Make this new thread the child of its parent.
8113 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8114 (setcdr (symbol-value pthread)
8115 (nconc (cdr (symbol-value pthread))
8116 (list (symbol-value cthread))))
8117 (set pthread (list nil (symbol-value cthread))))))
8118 (gnus-message 7 "Making sparse threads...done")))
8120 (defun gnus-build-old-threads ()
8121 ;; Look at all the articles that refer back to old articles, and
8122 ;; fetch the headers for the articles that aren't there. This will
8123 ;; build complete threads - if the roots haven't been expired by the
8128 (when (not (car (symbol-value refs)))
8129 (setq heads (cdr (symbol-value refs)))
8131 (if (memq (mail-header-number (caar heads))
8132 gnus-newsgroup-dormant)
8133 (setq heads (cdr heads))
8134 (setq id (symbol-name refs))
8135 (while (and (setq id (gnus-build-get-header id))
8136 (not (car (gnus-gethash
8137 id gnus-newsgroup-dependencies)))))
8138 (setq heads nil)))))
8139 gnus-newsgroup-dependencies)))
8141 (defun gnus-build-get-header (id)
8142 ;; Look through the buffer of NOV lines and find the header to
8143 ;; ID. Enter this line into the dependencies hash table, and return
8144 ;; the id of the parent article (if any).
8145 (let ((deps gnus-newsgroup-dependencies)
8149 (set-buffer nntp-server-buffer)
8150 (goto-char (point-min))
8151 (while (and (not found) (search-forward id nil t))
8153 (setq found (looking-at
8154 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8155 (regexp-quote id))))
8156 (or found (beginning-of-line 2)))
8160 (setq header (gnus-nov-parse-line
8161 (read (current-buffer)) deps))
8162 (gnus-parent-id (mail-header-references header)))))
8164 (let ((number (mail-header-number header)))
8165 (push number gnus-newsgroup-limit)
8166 (push header gnus-newsgroup-headers)
8167 (if (memq number gnus-newsgroup-unselected)
8169 (push number gnus-newsgroup-unreads)
8170 (setq gnus-newsgroup-unselected
8171 (delq number gnus-newsgroup-unselected)))
8172 (push number gnus-newsgroup-ancient)))))))
8174 (defun gnus-summary-update-article (article &optional iheader)
8175 "Update ARTICLE in the summary buffer."
8176 (set-buffer gnus-summary-buffer)
8177 (let* ((header (or iheader (gnus-summary-article-header article)))
8178 (id (mail-header-id header))
8179 (data (gnus-data-find article))
8180 (thread (gnus-id-to-thread id))
8181 (references (mail-header-references header))
8186 (not (equal "" references)))
8189 (buffer-read-only nil)
8191 (number (mail-header-number header))
8194 ;; !!! Should this be in or not?
8196 (setcar thread nil))
8198 (delq thread parent))
8199 (if (gnus-summary-insert-subject id header iheader)
8200 ;; Set the (possibly) new article number in the data structure.
8201 (gnus-data-set-number data (gnus-id-to-article id))
8205 (defun gnus-rebuild-thread (id)
8206 "Rebuild the thread containing ID."
8207 (let ((buffer-read-only nil)
8208 current thread data)
8209 (if (not gnus-show-threads)
8210 (setq thread (list (car (gnus-id-to-thread id))))
8211 ;; Get the thread this article is part of.
8212 (setq thread (gnus-remove-thread id)))
8213 (setq current (save-excursion
8214 (and (zerop (forward-line -1))
8215 (gnus-summary-article-number))))
8216 ;; If this is a gathered thread, we have to go some re-gathering.
8217 (when (stringp (car thread))
8218 (let ((subject (car thread))
8220 (setq thread (cdr thread))
8222 (unless (memq (setq thr (gnus-id-to-thread
8224 (mail-header-id (caar thread)))))
8227 (setq thread (cdr thread)))
8228 ;; We now have all (unique) roots.
8229 (if (= (length roots) 1)
8230 ;; All the loose roots are now one solid root.
8231 (setq thread (car roots))
8232 (setq thread (cons subject (gnus-sort-threads roots))))))
8234 ;; We then insert this thread into the summary buffer.
8235 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8236 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8237 (setq data (nreverse gnus-newsgroup-data))
8238 (setq threads gnus-newsgroup-threads))
8239 ;; We splice the new data into the data structure.
8240 (gnus-data-enter-list current data)
8241 (gnus-data-compute-positions)
8242 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8244 (defun gnus-number-to-header (number)
8245 "Return the header for article NUMBER."
8246 (let ((headers gnus-newsgroup-headers))
8248 (not (= number (mail-header-number (car headers)))))
8253 (defun gnus-id-to-thread (id)
8254 "Return the (sub-)thread where ID appears."
8255 (gnus-gethash id gnus-newsgroup-dependencies))
8257 (defun gnus-id-to-article (id)
8258 "Return the article number of ID."
8259 (let ((thread (gnus-id-to-thread id)))
8262 (mail-header-number (car thread)))))
8264 (defun gnus-id-to-header (id)
8265 "Return the article headers of ID."
8266 (car (gnus-id-to-thread id)))
8268 (defun gnus-article-displayed-root-p (article)
8269 "Say whether ARTICLE is a root(ish) article."
8270 (let ((level (gnus-summary-thread-level article))
8271 (refs (mail-header-references (gnus-summary-article-header article)))
8277 ((null (gnus-parent-id refs)) t)
8279 (null (setq particle (gnus-id-to-article
8280 (gnus-parent-id refs))))
8281 (null (gnus-summary-thread-level particle)))))))
8283 (defun gnus-root-id (id)
8284 "Return the id of the root of the thread where ID appears."
8286 (while (and id (setq prev (car (gnus-gethash
8287 id gnus-newsgroup-dependencies))))
8289 id (gnus-parent-id (mail-header-references prev))))
8292 (defun gnus-remove-thread (id &optional dont-remove)
8293 "Remove the thread that has ID in it."
8294 (let ((dep gnus-newsgroup-dependencies)
8295 headers thread last-id)
8296 ;; First go up in this thread until we find the root.
8297 (setq last-id (gnus-root-id id))
8298 (setq headers (list (car (gnus-id-to-thread last-id))
8299 (caadr (gnus-id-to-thread last-id))))
8300 ;; We have now found the real root of this thread. It might have
8301 ;; been gathered into some loose thread, so we have to search
8302 ;; through the threads to find the thread we wanted.
8303 (let ((threads gnus-newsgroup-threads)
8306 (setq sub (car threads))
8307 (if (stringp (car sub))
8308 ;; This is a gathered threads, so we look at the roots
8309 ;; below it to find whether this article in in this
8312 (setq sub (cdr sub))
8314 (when (member (caar sub) headers)
8315 (setq thread (car threads)
8318 (setq sub (cdr sub))))
8319 ;; It's an ordinary thread, so we check it.
8320 (when (eq (car sub) (car headers))
8323 (setq threads (cdr threads)))
8324 ;; If this article is in no thread, then it's a root.
8327 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8328 (setq thread (gnus-gethash last-id dep)))
8331 thread ; We return this thread.
8333 (if (stringp (car thread))
8335 ;; If we use dummy roots, then we have to remove the
8336 ;; dummy root as well.
8337 (when (eq gnus-summary-make-false-root 'dummy)
8340 (setq thread (cdr thread))
8342 (gnus-remove-thread-1 (car thread))
8343 (setq thread (cdr thread))))
8344 (gnus-remove-thread-1 thread))))))))
8346 (defun gnus-remove-thread-1 (thread)
8347 "Remove the thread THREAD recursively."
8348 (let ((number (mail-header-number (car thread)))
8350 (when (setq pos (text-property-any
8351 (point-min) (point-max) 'gnus-number number))
8354 (gnus-data-remove number))
8355 (setq thread (cdr thread))
8357 (gnus-remove-thread-1 (pop thread)))))
8359 (defun gnus-sort-threads (threads)
8361 (if (not gnus-thread-sort-functions)
8363 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8364 (car gnus-thread-sort-functions)
8366 ,(gnus-make-sort-function
8367 (reverse gnus-thread-sort-functions))))))
8368 (gnus-message 7 "Sorting threads...")
8371 (gnus-message 7 "Sorting threads...done")))))
8373 (defun gnus-sort-articles (articles)
8375 (when gnus-article-sort-functions
8376 (let ((func (if (= 1 (length gnus-article-sort-functions))
8377 (car gnus-article-sort-functions)
8379 ,(gnus-make-sort-function
8380 (reverse gnus-article-sort-functions))))))
8381 (gnus-message 7 "Sorting articles...")
8383 (setq gnus-newsgroup-headers (sort articles func))
8384 (gnus-message 7 "Sorting articles...done")))))
8386 (defun gnus-make-sort-function (funs)
8387 "Return a composite sort condition based on the functions in FUNC."
8389 `(or (,(car funs) t1 t2)
8390 (and (not (,(car funs) t2 t1))
8391 ,(gnus-make-sort-function (cdr funs))))
8392 `(,(car funs) t1 t2)))
8394 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8395 (defmacro gnus-thread-header (thread)
8396 ;; Return header of first article in THREAD.
8397 ;; Note that THREAD must never, ever be anything else than a variable -
8398 ;; using some other form will lead to serious barfage.
8399 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8400 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8401 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8404 (defsubst gnus-article-sort-by-number (h1 h2)
8405 "Sort articles by article number."
8406 (< (mail-header-number h1)
8407 (mail-header-number h2)))
8409 (defun gnus-thread-sort-by-number (h1 h2)
8410 "Sort threads by root article number."
8411 (gnus-article-sort-by-number
8412 (gnus-thread-header h1) (gnus-thread-header h2)))
8414 (defsubst gnus-article-sort-by-author (h1 h2)
8415 "Sort articles by root author."
8417 (let ((extract (funcall
8418 gnus-extract-address-components
8419 (mail-header-from h1))))
8420 (or (car extract) (cdr extract)))
8421 (let ((extract (funcall
8422 gnus-extract-address-components
8423 (mail-header-from h2))))
8424 (or (car extract) (cdr extract)))))
8426 (defun gnus-thread-sort-by-author (h1 h2)
8427 "Sort threads by root author."
8428 (gnus-article-sort-by-author
8429 (gnus-thread-header h1) (gnus-thread-header h2)))
8431 (defsubst gnus-article-sort-by-subject (h1 h2)
8432 "Sort articles by root subject."
8434 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8435 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8437 (defun gnus-thread-sort-by-subject (h1 h2)
8438 "Sort threads by root subject."
8439 (gnus-article-sort-by-subject
8440 (gnus-thread-header h1) (gnus-thread-header h2)))
8442 (defsubst gnus-article-sort-by-date (h1 h2)
8443 "Sort articles by root article date."
8445 (inline (gnus-sortable-date (mail-header-date h1)))
8446 (inline (gnus-sortable-date (mail-header-date h2)))))
8448 (defun gnus-thread-sort-by-date (h1 h2)
8449 "Sort threads by root article date."
8450 (gnus-article-sort-by-date
8451 (gnus-thread-header h1) (gnus-thread-header h2)))
8453 (defsubst gnus-article-sort-by-score (h1 h2)
8454 "Sort articles by root article score.
8455 Unscored articles will be counted as having a score of zero."
8456 (> (or (cdr (assq (mail-header-number h1)
8457 gnus-newsgroup-scored))
8458 gnus-summary-default-score 0)
8459 (or (cdr (assq (mail-header-number h2)
8460 gnus-newsgroup-scored))
8461 gnus-summary-default-score 0)))
8463 (defun gnus-thread-sort-by-score (h1 h2)
8464 "Sort threads by root article score."
8465 (gnus-article-sort-by-score
8466 (gnus-thread-header h1) (gnus-thread-header h2)))
8468 (defun gnus-thread-sort-by-total-score (h1 h2)
8469 "Sort threads by the sum of all scores in the thread.
8470 Unscored articles will be counted as having a score of zero."
8471 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8473 (defun gnus-thread-total-score (thread)
8474 ;; This function find the total score of THREAD.
8475 (cond ((null thread)
8478 (if (stringp (car thread))
8479 (apply gnus-thread-score-function 0
8480 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8481 (gnus-thread-total-score-1 thread)))
8483 (gnus-thread-total-score-1 (list thread)))))
8485 (defun gnus-thread-total-score-1 (root)
8486 ;; This function find the total score of the thread below ROOT.
8487 (setq root (car root))
8488 (apply gnus-thread-score-function
8490 (mapcar 'gnus-thread-total-score
8491 (cdr (gnus-gethash (mail-header-id root)
8492 gnus-newsgroup-dependencies)))
8493 (if (> (mail-header-number root) 0)
8494 (list (or (cdr (assq (mail-header-number root)
8495 gnus-newsgroup-scored))
8496 gnus-summary-default-score 0))))
8497 (list gnus-summary-default-score)
8500 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8501 (defvar gnus-tmp-prev-subject nil)
8502 (defvar gnus-tmp-false-parent nil)
8503 (defvar gnus-tmp-root-expunged nil)
8504 (defvar gnus-tmp-dummy-line nil)
8506 (defun gnus-summary-prepare-threads (threads)
8507 "Prepare summary buffer from THREADS and indentation LEVEL.
8508 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8509 or a straight list of headers."
8510 (gnus-message 7 "Generating summary...")
8512 (setq gnus-newsgroup-threads threads)
8515 (let ((gnus-tmp-level 0)
8516 (default-score (or gnus-summary-default-score 0))
8517 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8518 thread number subject stack state gnus-tmp-gathered beg-match
8519 new-roots gnus-tmp-new-adopts thread-end
8520 gnus-tmp-header gnus-tmp-unread
8521 gnus-tmp-replied gnus-tmp-subject-or-nil
8522 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8523 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8524 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8526 (setq gnus-tmp-prev-subject nil)
8528 (if (vectorp (car threads))
8529 ;; If this is a straight (sic) list of headers, then a
8530 ;; threaded summary display isn't required, so we just create
8531 ;; an unthreaded one.
8532 (gnus-summary-prepare-unthreaded threads)
8534 ;; Do the threaded display.
8536 (while (or threads stack gnus-tmp-new-adopts new-roots)
8538 (if (and (= gnus-tmp-level 0)
8539 (not (setq gnus-tmp-dummy-line nil))
8542 (not gnus-tmp-false-parent)
8543 (or gnus-tmp-new-adopts new-roots))
8544 (if gnus-tmp-new-adopts
8545 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8546 thread (list (car gnus-tmp-new-adopts))
8547 gnus-tmp-header (caar thread)
8548 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8550 (setq thread (list (car new-roots))
8551 gnus-tmp-header (caar thread)
8552 new-roots (cdr new-roots))))
8555 ;; If there are some threads, we do them before the
8556 ;; threads on the stack.
8557 (setq thread threads
8558 gnus-tmp-header (caar thread))
8559 ;; There were no current threads, so we pop something off
8561 (setq state (car stack)
8562 gnus-tmp-level (car state)
8565 gnus-tmp-header (caar thread))))
8567 (setq gnus-tmp-false-parent nil)
8568 (setq gnus-tmp-root-expunged nil)
8569 (setq thread-end nil)
8571 (if (stringp gnus-tmp-header)
8572 ;; The header is a dummy root.
8574 ((eq gnus-summary-make-false-root 'adopt)
8575 ;; We let the first article adopt the rest.
8576 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8578 (setq gnus-tmp-gathered
8580 (lambda (h) (mail-header-number (car h)))
8583 (setq thread (cons (list (caar thread)
8586 (setq gnus-tmp-level -1
8587 gnus-tmp-false-parent t))
8588 ((eq gnus-summary-make-false-root 'empty)
8589 ;; We print adopted articles with empty subject fields.
8590 (setq gnus-tmp-gathered
8592 (lambda (h) (mail-header-number (car h)))
8595 (setq gnus-tmp-level -1))
8596 ((eq gnus-summary-make-false-root 'dummy)
8597 ;; We remember that we probably want to output a dummy
8599 (setq gnus-tmp-dummy-line gnus-tmp-header)
8600 (setq gnus-tmp-prev-subject gnus-tmp-header))
8602 ;; We do not make a root for the gathered
8603 ;; sub-threads at all.
8604 (setq gnus-tmp-level -1)))
8606 (setq number (mail-header-number gnus-tmp-header)
8607 subject (mail-header-subject gnus-tmp-header))
8610 ;; If the thread has changed subject, we might want to make
8611 ;; this subthread into a root.
8612 ((and (null gnus-thread-ignore-subject)
8613 (not (zerop gnus-tmp-level))
8614 gnus-tmp-prev-subject
8616 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8617 (setq new-roots (nconc new-roots (list (car thread)))
8619 gnus-tmp-header nil))
8620 ;; If the article lies outside the current limit,
8621 ;; then we do not display it.
8622 ((and (not (memq number gnus-newsgroup-limit))
8623 ;(not gnus-tmp-dummy-line)
8625 (setq gnus-tmp-gathered
8627 (lambda (h) (mail-header-number (car h)))
8630 (setq gnus-tmp-new-adopts (if (cdar thread)
8631 (append gnus-tmp-new-adopts
8633 gnus-tmp-new-adopts)
8635 gnus-tmp-header nil)
8636 (when (zerop gnus-tmp-level)
8637 (setq gnus-tmp-root-expunged t)))
8638 ;; Perhaps this article is to be marked as read?
8639 ((and gnus-summary-mark-below
8640 (< (or (cdr (assq number gnus-newsgroup-scored))
8642 gnus-summary-mark-below)
8643 ;; Don't touch sparse articles.
8644 (not (memq number gnus-newsgroup-sparse))
8645 (not (memq number gnus-newsgroup-ancient)))
8646 (setq gnus-newsgroup-unreads
8647 (delq number gnus-newsgroup-unreads))
8648 (if gnus-newsgroup-auto-expire
8649 (push number gnus-newsgroup-expirable)
8650 (push (cons number gnus-low-score-mark)
8651 gnus-newsgroup-reads))))
8653 (when gnus-tmp-header
8654 ;; We may have an old dummy line to output before this
8656 (when gnus-tmp-dummy-line
8657 (gnus-summary-insert-dummy-line
8658 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8659 (setq gnus-tmp-dummy-line nil))
8661 ;; Compute the mark.
8665 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8666 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8667 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8668 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8669 (t (or (cdr (assq number gnus-newsgroup-reads))
8670 gnus-ancient-mark))))
8672 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8673 gnus-tmp-header gnus-tmp-level)
8674 gnus-newsgroup-data)
8676 ;; Actually insert the line.
8678 gnus-tmp-subject-or-nil
8680 ((and gnus-thread-ignore-subject
8681 gnus-tmp-prev-subject
8682 (not (inline (gnus-subject-equal
8683 gnus-tmp-prev-subject subject))))
8685 ((zerop gnus-tmp-level)
8686 (if (and (eq gnus-summary-make-false-root 'empty)
8687 (memq number gnus-tmp-gathered)
8688 gnus-tmp-prev-subject
8689 (inline (gnus-subject-equal
8690 gnus-tmp-prev-subject subject)))
8691 gnus-summary-same-subject
8693 (t gnus-summary-same-subject)))
8694 (if (and (eq gnus-summary-make-false-root 'adopt)
8695 (= gnus-tmp-level 1)
8696 (memq number gnus-tmp-gathered))
8697 (setq gnus-tmp-opening-bracket ?\<
8698 gnus-tmp-closing-bracket ?\>)
8699 (setq gnus-tmp-opening-bracket ?\[
8700 gnus-tmp-closing-bracket ?\]))
8702 gnus-tmp-indentation
8703 (aref gnus-thread-indent-array gnus-tmp-level)
8704 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8705 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8706 gnus-summary-default-score 0)
8708 (if (or (null gnus-summary-default-score)
8709 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8710 gnus-summary-zcore-fuzz)) ?
8711 (if (< gnus-tmp-score gnus-summary-default-score)
8712 gnus-score-below-mark gnus-score-over-mark))
8714 (cond ((memq number gnus-newsgroup-processable)
8716 ((memq number gnus-newsgroup-cached)
8718 ((memq number gnus-newsgroup-replied)
8720 ((memq number gnus-newsgroup-saved)
8722 (t gnus-unread-mark))
8723 gnus-tmp-from (mail-header-from gnus-tmp-header)
8726 ((string-match "(.+)" gnus-tmp-from)
8727 (substring gnus-tmp-from
8728 (1+ (match-beginning 0)) (1- (match-end 0))))
8729 ((string-match "<[^>]+> *$" gnus-tmp-from)
8730 (setq beg-match (match-beginning 0))
8731 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8732 (substring gnus-tmp-from (1+ (match-beginning 0))
8733 (1- (match-end 0))))
8734 (substring gnus-tmp-from 0 beg-match)))
8736 (when (string= gnus-tmp-name "")
8737 (setq gnus-tmp-name gnus-tmp-from))
8738 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8739 (gnus-put-text-property
8741 (progn (eval gnus-summary-line-format-spec) (point))
8742 'gnus-number number)
8745 (run-hooks 'gnus-summary-update-hook)
8748 (setq gnus-tmp-prev-subject subject)))
8750 (when (nth 1 thread)
8751 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8752 (incf gnus-tmp-level)
8753 (setq threads (if thread-end nil (cdar thread)))
8755 (setq gnus-tmp-level 0)))))
8756 (gnus-message 7 "Generating summary...done"))
8758 (defun gnus-summary-prepare-unthreaded (headers)
8759 "Generate an unthreaded summary buffer based on HEADERS."
8760 (let (header number mark)
8763 ;; We may have to root out some bad articles...
8764 (when (memq (setq number (mail-header-number
8765 (setq header (pop headers))))
8766 gnus-newsgroup-limit)
8767 ;; Mark article as read when it has a low score.
8768 (when (and gnus-summary-mark-below
8769 (< (or (cdr (assq number gnus-newsgroup-scored))
8770 gnus-summary-default-score 0)
8771 gnus-summary-mark-below)
8772 (not (memq number gnus-newsgroup-ancient)))
8773 (setq gnus-newsgroup-unreads
8774 (delq number gnus-newsgroup-unreads))
8775 (if gnus-newsgroup-auto-expire
8776 (push number gnus-newsgroup-expirable)
8777 (push (cons number gnus-low-score-mark)
8778 gnus-newsgroup-reads)))
8782 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8783 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8784 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8785 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8786 (t (or (cdr (assq number gnus-newsgroup-reads))
8787 gnus-ancient-mark))))
8788 (setq gnus-newsgroup-data
8789 (cons (gnus-data-make number mark (1+ (point)) header 0)
8790 gnus-newsgroup-data))
8791 (gnus-summary-insert-line
8792 header 0 nil mark (memq number gnus-newsgroup-replied)
8793 (memq number gnus-newsgroup-expirable)
8794 (mail-header-subject header) nil
8795 (cdr (assq number gnus-newsgroup-scored))
8796 (memq number gnus-newsgroup-processable))))))
8798 (defun gnus-select-newsgroup (group &optional read-all)
8799 "Select newsgroup GROUP.
8800 If READ-ALL is non-nil, all articles in the group are selected."
8801 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8802 (info (nth 2 entry))
8803 articles fetched-articles cached)
8805 (or (gnus-check-server
8806 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8807 (error "Couldn't open server"))
8809 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8810 (gnus-activate-group group) ; Or we can activate it...
8811 (progn ; Or we bug out.
8812 (when (equal major-mode 'gnus-summary-mode)
8813 (kill-buffer (current-buffer)))
8814 (error "Couldn't request group %s: %s"
8815 group (gnus-status-message group))))
8817 (unless (gnus-request-group group t)
8818 (when (equal major-mode 'gnus-summary-mode)
8819 (kill-buffer (current-buffer)))
8820 (error "Couldn't request group %s: %s"
8821 group (gnus-status-message group)))
8823 (setq gnus-newsgroup-name group)
8824 (setq gnus-newsgroup-unselected nil)
8825 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8827 (and gnus-asynchronous
8828 (gnus-check-backend-function
8829 'request-asynchronous gnus-newsgroup-name)
8830 (setq gnus-newsgroup-async
8831 (gnus-request-asynchronous gnus-newsgroup-name)))
8833 ;; Adjust and set lists of article marks.
8835 (gnus-adjust-marked-articles info))
8837 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8838 (when (gnus-virtual-group-p group)
8839 (setq cached gnus-newsgroup-cached))
8841 (setq gnus-newsgroup-unreads
8842 (gnus-set-difference
8843 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8844 gnus-newsgroup-dormant))
8846 (setq gnus-newsgroup-processable nil)
8848 (setq articles (gnus-articles-to-read group read-all))
8852 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8854 ((eq articles 0) nil)
8856 ;; Init the dependencies hash table.
8857 (setq gnus-newsgroup-dependencies
8858 (gnus-make-hashtable (length articles)))
8859 ;; Retrieve the headers and read them in.
8860 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8861 (setq gnus-newsgroup-headers
8863 (setq gnus-headers-retrieved-by
8864 (gnus-retrieve-headers
8865 articles gnus-newsgroup-name
8866 ;; We might want to fetch old headers, but
8867 ;; not if there is only 1 article.
8868 (and gnus-fetch-old-headers
8870 (not (eq gnus-fetch-old-headers 'some))
8871 (not (numberp gnus-fetch-old-headers)))
8872 (> (length articles) 1))))))
8873 (gnus-get-newsgroup-headers-xover articles)
8874 (gnus-get-newsgroup-headers)))
8875 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8877 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8879 (setq gnus-newsgroup-cached cached))
8881 ;; Set the initial limit.
8882 (setq gnus-newsgroup-limit (copy-sequence articles))
8883 ;; Remove canceled articles from the list of unread articles.
8884 (setq gnus-newsgroup-unreads
8885 (gnus-set-sorted-intersection
8886 gnus-newsgroup-unreads
8887 (setq fetched-articles
8888 (mapcar (lambda (headers) (mail-header-number headers))
8889 gnus-newsgroup-headers))))
8890 ;; Removed marked articles that do not exist.
8891 (gnus-update-missing-marks
8892 (gnus-sorted-complement fetched-articles articles))
8893 ;; We might want to build some more threads first.
8894 (and gnus-fetch-old-headers
8895 (eq gnus-headers-retrieved-by 'nov)
8896 (gnus-build-old-threads))
8897 ;; Check whether auto-expire is to be done in this group.
8898 (setq gnus-newsgroup-auto-expire
8899 (gnus-group-auto-expirable-p group))
8900 ;; Set up the article buffer now, if necessary.
8901 (unless gnus-single-article-buffer
8902 (gnus-article-setup-buffer))
8903 ;; First and last article in this newsgroup.
8904 (when gnus-newsgroup-headers
8905 (setq gnus-newsgroup-begin
8906 (mail-header-number (car gnus-newsgroup-headers))
8909 (gnus-last-element gnus-newsgroup-headers))))
8910 (setq gnus-reffed-article-number -1)
8911 ;; GROUP is successfully selected.
8912 (or gnus-newsgroup-headers t)))))
8914 (defun gnus-articles-to-read (group read-all)
8915 ;; Find out what articles the user wants to read.
8917 ;; Select all articles if `read-all' is non-nil, or if there
8918 ;; are no unread articles.
8920 (and (zerop (length gnus-newsgroup-marked))
8921 (zerop (length gnus-newsgroup-unreads))))
8922 (gnus-uncompress-range (gnus-active group))
8923 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8924 (copy-sequence gnus-newsgroup-unreads))
8926 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8927 (scored (length scored-list))
8928 (number (length articles))
8929 (marked (+ (length gnus-newsgroup-marked)
8930 (length gnus-newsgroup-dormant)))
8938 ((and (or (<= scored marked) (= scored number))
8939 (numberp gnus-large-newsgroup)
8940 (> number gnus-large-newsgroup))
8944 "How many articles from %s (default %d): "
8945 gnus-newsgroup-name number))))
8946 (if (string-match "^[ \t]*$" input) number input)))
8947 ((and (> scored marked) (< scored number)
8948 (> (- scored number) 20))
8951 (format "%s %s (%d scored, %d total): "
8952 "How many articles from"
8953 group scored number))))
8954 (if (string-match "^[ \t]*$" input)
8958 (setq select (if (stringp select) (string-to-number select) select))
8959 (if (or (null select) (zerop select))
8961 (if (and (not (zerop scored)) (<= (abs select) scored))
8963 (setq articles (sort scored-list '<))
8964 (setq number (length articles)))
8965 (setq articles (copy-sequence articles)))
8967 (if (< (abs select) number)
8969 ;; Select the N oldest articles.
8970 (setcdr (nthcdr (1- (abs select)) articles) nil)
8971 ;; Select the N most recent articles.
8972 (setq articles (nthcdr (- number select) articles))))
8973 (setq gnus-newsgroup-unselected
8974 (gnus-sorted-intersection
8975 gnus-newsgroup-unreads
8976 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8979 (defun gnus-killed-articles (killed articles)
8982 (if (inline (gnus-member-of-range (car articles) killed))
8983 (setq out (cons (car articles) out)))
8984 (setq articles (cdr articles)))
8987 (defun gnus-uncompress-marks (marks)
8988 "Uncompress the mark ranges in MARKS."
8989 (let ((uncompressed '(score bookmark))
8992 (if (memq (caar marks) uncompressed)
8993 (push (car marks) out)
8994 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8995 (setq marks (cdr marks)))
8998 (defun gnus-adjust-marked-articles (info)
8999 "Set all article lists and remove all marks that are no longer legal."
9000 (let* ((marked-lists (gnus-info-marks info))
9001 (active (gnus-active (gnus-info-group info)))
9004 (types gnus-article-mark-lists)
9005 (uncompressed '(score bookmark killed))
9006 marks var articles article mark)
9009 (setq marks (pop marked-lists))
9010 (set (setq var (intern (format "gnus-newsgroup-%s"
9011 (car (rassq (setq mark (car marks))
9013 (if (memq (car marks) uncompressed) (cdr marks)
9014 (gnus-uncompress-range (cdr marks))))
9016 (setq articles (symbol-value var))
9018 ;; All articles have to be subsets of the active articles.
9020 ;; Adjust "simple" lists.
9021 ((memq mark '(tick dormant expirable reply save))
9023 (when (or (< (setq article (pop articles)) min) (> article max))
9024 (set var (delq article (symbol-value var))))))
9026 ((memq mark uncompressed)
9028 (when (or (not (consp (setq article (pop articles))))
9029 (< (car article) min)
9030 (> (car article) max))
9031 (set var (delq article (symbol-value var))))))))))
9033 (defun gnus-update-missing-marks (missing)
9034 "Go through the list of MISSING articles and remove them mark lists."
9036 (let ((types gnus-article-mark-lists)
9038 ;; Go through all types.
9040 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
9041 (when (symbol-value var)
9042 ;; This list has articles. So we delete all missing articles
9046 (set var (delq (pop m) (symbol-value var)))))))))
9048 (defun gnus-update-marks ()
9049 "Enter the various lists of marked articles into the newsgroup info list."
9050 (let ((types gnus-article-mark-lists)
9051 (info (gnus-get-info gnus-newsgroup-name))
9052 (uncompressed '(score bookmark killed))
9053 type list newmarked symbol)
9055 ;; Add all marks lists that are non-nil to the list of marks lists.
9057 (setq type (pop types))
9058 (when (setq list (symbol-value
9060 (intern (format "gnus-newsgroup-%s"
9062 (push (cons (cdr type)
9063 (if (memq (cdr type) uncompressed) list
9064 (gnus-compress-sequence
9065 (set symbol (sort list '<)) t)))
9068 ;; Enter these new marks into the info of the group.
9070 (setcar (nthcdr 3 info) newmarked)
9071 ;; Add the marks lists to the end of the info.
9073 (setcdr (nthcdr 2 info) (list newmarked))))
9075 ;; Cut off the end of the info if there's nothing else there.
9079 (when (nthcdr (decf i) info)
9080 (setcdr (nthcdr i info) nil)))))))
9082 (defun gnus-add-marked-articles (group type articles &optional info force)
9083 ;; Add ARTICLES of TYPE to the info of GROUP.
9084 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9085 ;; add, but replace marked articles of TYPE with ARTICLES.
9086 (let ((info (or info (gnus-get-info group)))
9087 (uncompressed '(score bookmark killed))
9090 (and (not (setq marked (nthcdr 3 info)))
9092 (setcdr (nthcdr 2 info)
9093 (list (list (cons type (gnus-compress-sequence
9095 (and (not (setq m (assq type (car marked))))
9098 (cons (cons type (gnus-compress-sequence articles t) )
9102 (setcar (nthcdr 3 info)
9103 (delq (assq type (car marked)) (car marked)))
9104 (setcdr m (gnus-compress-sequence articles t)))
9105 (setcdr m (gnus-compress-sequence
9106 (sort (nconc (gnus-uncompress-range (cdr m))
9107 (copy-sequence articles)) '<) t))))))
9109 (defun gnus-set-mode-line (where)
9110 "This function sets the mode line of the article or summary buffers.
9111 If WHERE is `summary', the summary mode line format will be used."
9112 ;; Is this mode line one we keep updated?
9113 (when (memq where gnus-updated-mode-lines)
9116 ;; We evaluate this in the summary buffer since these
9117 ;; variables are buffer-local to that buffer.
9118 (set-buffer gnus-summary-buffer)
9119 ;; We bind all these variables that are used in the `eval' form
9121 (let* ((mformat (symbol-value
9123 (format "gnus-%s-mode-line-format-spec" where))))
9124 (gnus-tmp-group-name gnus-newsgroup-name)
9125 (gnus-tmp-article-number (or gnus-current-article 0))
9126 (gnus-tmp-unread gnus-newsgroup-unreads)
9127 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9128 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9129 (gnus-tmp-unread-and-unselected
9130 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9131 (zerop gnus-tmp-unselected)) "")
9132 ((zerop gnus-tmp-unselected)
9133 (format "{%d more}" gnus-tmp-unread-and-unticked))
9134 (t (format "{%d(+%d) more}"
9135 gnus-tmp-unread-and-unticked
9136 gnus-tmp-unselected))))
9138 (if (and gnus-current-headers
9139 (vectorp gnus-current-headers))
9140 (gnus-mode-string-quote
9141 (mail-header-subject gnus-current-headers)) ""))
9143 gnus-tmp-header);; passed as argument to any user-format-funcs
9144 (setq mode-string (eval mformat))
9145 (setq max-len (max 4 (if gnus-mode-non-string-length
9147 gnus-mode-non-string-length)
9148 (length mode-string))))
9149 ;; We might have to chop a bit of the string off...
9150 (when (> (length mode-string) max-len)
9152 (concat (gnus-truncate-string mode-string (- max-len 3))
9154 ;; Pad the mode string a bit.
9155 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9156 ;; Update the mode line.
9157 (setq mode-line-buffer-identification
9158 (gnus-mode-line-buffer-identification
9159 (list mode-string)))
9160 (set-buffer-modified-p t))))
9162 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9163 "Go through the HEADERS list and add all Xrefs to a hash table.
9164 The resulting hash table is returned, or nil if no Xrefs were found."
9165 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9166 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9167 (xref-hashtb (make-vector 63 0))
9168 start group entry number xrefs header)
9170 (setq header (pop headers))
9171 (when (and (setq xrefs (mail-header-xref header))
9172 (not (memq (setq number (mail-header-number header))
9175 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9176 (setq start (match-end 0))
9177 (setq group (if prefix
9178 (concat prefix (substring xrefs (match-beginning 1)
9180 (substring xrefs (match-beginning 1) (match-end 1))))
9182 (string-to-int (substring xrefs (match-beginning 2)
9184 (if (setq entry (gnus-gethash group xref-hashtb))
9185 (setcdr entry (cons number (cdr entry)))
9186 (gnus-sethash group (cons number nil) xref-hashtb)))))
9187 (and start xref-hashtb)))
9189 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9190 "Look through all the headers and mark the Xrefs as read."
9191 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9192 name entry info xref-hashtb idlist method nth4)
9194 (set-buffer gnus-group-buffer)
9195 (when (setq xref-hashtb
9196 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9199 (unless (string= from-newsgroup (setq name (symbol-name group)))
9200 (setq idlist (symbol-value group))
9201 ;; Dead groups are not updated.
9203 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9205 (if (stringp (setq nth4 (gnus-info-method info)))
9206 (setq nth4 (gnus-server-to-method nth4))))
9207 ;; Only do the xrefs if the group has the same
9208 ;; select method as the group we have just read.
9209 (or (gnus-methods-equal-p
9210 nth4 (gnus-find-method-for-group from-newsgroup))
9212 (equal nth4 (setq method (gnus-find-method-for-group
9214 (and (equal (car nth4) (car method))
9215 (equal (nth 1 nth4) (nth 1 method))))
9216 gnus-use-cross-reference
9217 (or (not (eq gnus-use-cross-reference t))
9219 ;; Only do cross-references on subscribed
9220 ;; groups, if that is what is wanted.
9221 (<= (gnus-info-level info) gnus-level-subscribed))
9222 (gnus-group-make-articles-read name idlist))))
9225 (defun gnus-group-make-articles-read (group articles)
9227 (entry (gnus-gethash group gnus-newsrc-hashtb))
9228 (info (nth 2 entry))
9229 (active (gnus-active group))
9231 ;; First peel off all illegal article numbers.
9233 (let ((ids articles)
9237 (if (and first (> id (cdr active)))
9239 ;; We'll end up in this situation in one particular
9240 ;; obscure situation. If you re-scan a group and get
9241 ;; a new article that is cross-posted to a different
9242 ;; group that has not been re-scanned, you might get
9243 ;; crossposted article that has a higher number than
9244 ;; Gnus believes possible. So we re-activate this
9245 ;; group as well. This might mean doing the
9246 ;; crossposting thingy will *increase* the number
9247 ;; of articles in some groups. Tsk, tsk.
9248 (setq active (or (gnus-activate-group group) active))))
9249 (if (or (> id (cdr active))
9250 (< id (car active)))
9251 (setq articles (delq id articles)))
9252 (setq ids (cdr ids)))))
9253 ;; If the read list is nil, we init it.
9255 (null (gnus-info-read info))
9257 (gnus-info-set-read info (cons 1 (1- (car active)))))
9258 ;; Then we add the read articles to the range.
9263 (gnus-info-read info) (setq articles (sort articles '<)))))
9264 ;; Then we have to re-compute how many unread
9265 ;; articles there are in this group.
9270 (setq num (- (1+ (cdr active)) (car active))))
9271 ((not (listp (cdr range)))
9272 (setq num (- (cdr active) (- (1+ (cdr range))
9276 (if (numberp (car range))
9278 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9279 (setq range (cdr range)))
9280 (setq num (- (cdr active) num))))
9281 ;; Update the number of unread articles.
9283 ;; Update the group buffer.
9284 (gnus-group-update-group group t)))))
9286 (defun gnus-methods-equal-p (m1 m2)
9287 (let ((m1 (or m1 gnus-select-method))
9288 (m2 (or m2 gnus-select-method)))
9290 (and (eq (car m1) (car m2))
9291 (or (not (memq 'address (assoc (symbol-name (car m1))
9292 gnus-valid-select-methods)))
9293 (equal (nth 1 m1) (nth 1 m2)))))))
9295 (defsubst gnus-header-value ()
9296 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9298 (defvar gnus-newsgroup-none-id 0)
9300 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9301 (let ((cur nntp-server-buffer)
9304 (save-excursion (set-buffer gnus-summary-buffer)
9305 gnus-newsgroup-dependencies)))
9306 headers id id-dep ref-dep end ref)
9308 (set-buffer nntp-server-buffer)
9309 (run-hooks 'gnus-parse-headers-hook)
9310 (let ((case-fold-search t)
9311 in-reply-to header p lines)
9312 (goto-char (point-min))
9313 ;; Search to the beginning of the next header. Error messages
9314 ;; do not begin with 2 or 3.
9315 (while (re-search-forward "^[23][0-9]+ " nil t)
9318 ;; This implementation of this function, with nine
9319 ;; search-forwards instead of the one re-search-forward and
9320 ;; a case (which basically was the old function) is actually
9321 ;; about twice as fast, even though it looks messier. You
9322 ;; can't have everything, I guess. Speed and elegance
9323 ;; doesn't always go hand in hand.
9332 (narrow-to-region (point)
9333 (or (and (search-forward "\n.\n" nil t)
9339 (if (search-forward "\nsubject: " nil t)
9340 (gnus-header-value) "(none)"))
9344 (if (search-forward "\nfrom: " nil t)
9345 (gnus-header-value) "(nobody)"))
9349 (if (search-forward "\ndate: " nil t)
9350 (gnus-header-value) ""))
9354 (if (search-forward "\nmessage-id: " nil t)
9355 (setq id (gnus-header-value))
9356 ;; If there was no message-id, we just fake one to make
9357 ;; subsequent routines simpler.
9358 (setq id (concat "none+"
9360 (setq gnus-newsgroup-none-id
9361 (1+ gnus-newsgroup-none-id)))))))
9365 (if (search-forward "\nreferences: " nil t)
9374 (search-backward ">" end t)
9377 (search-backward "<" end t)
9379 ;; Get the references from the in-reply-to header if there
9380 ;; were no references and the in-reply-to header looks
9382 (if (and (search-forward "\nin-reply-to: " nil t)
9383 (setq in-reply-to (gnus-header-value))
9384 (string-match "<[^>]+>" in-reply-to))
9385 (setq ref (substring in-reply-to (match-beginning 0)
9393 (if (search-forward "\nlines: " nil t)
9394 (if (numberp (setq lines (read cur)))
9400 (and (search-forward "\nxref: " nil t)
9401 (gnus-header-value)))))
9402 ;; We do the threading while we read the headers. The
9403 ;; message-id and the last reference are both entered into
9404 ;; the same hash table. Some tippy-toeing around has to be
9405 ;; done in case an article has arrived before the article
9406 ;; which it refers to.
9407 (if (boundp (setq id-dep (intern id dependencies)))
9408 (if (and (car (symbol-value id-dep))
9410 ;; An article with this Message-ID has already
9411 ;; been seen, so we ignore this one, except we add
9412 ;; any additional Xrefs (in case the two articles
9413 ;; came from different servers).
9415 (mail-header-set-xref
9416 (car (symbol-value id-dep))
9417 (concat (or (mail-header-xref
9418 (car (symbol-value id-dep))) "")
9419 (or (mail-header-xref header) "")))
9421 (setcar (symbol-value id-dep) header))
9422 (set id-dep (list header)))
9424 (if (boundp (setq ref-dep (intern ref dependencies)))
9425 (setcdr (symbol-value ref-dep)
9426 (nconc (cdr (symbol-value ref-dep))
9427 (list (symbol-value id-dep))))
9428 (set ref-dep (list nil (symbol-value id-dep))))
9429 (setq headers (cons header headers)))
9430 (goto-char (point-max))
9432 (nreverse headers)))))
9434 ;; The following macros and functions were written by Felix Lee
9435 ;; <flee@cse.psu.edu>.
9437 (defmacro gnus-nov-read-integer ()
9439 (if (= (following-char) ?\t)
9441 (let ((num (condition-case nil (read buffer) (error nil))))
9442 (if (numberp num) num 0)))
9443 (or (eobp) (forward-char 1))))
9445 (defmacro gnus-nov-skip-field ()
9446 '(search-forward "\t" eol 'move))
9448 (defmacro gnus-nov-field ()
9449 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9451 ;; Goes through the xover lines and returns a list of vectors
9452 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9453 force-new dependencies)
9454 "Parse the news overview data in the server buffer, and return a
9455 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9456 ;; Get the Xref when the users reads the articles since most/some
9457 ;; NNTP servers do not include Xrefs when using XOVER.
9458 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9459 (let ((cur nntp-server-buffer)
9460 (dependencies (or dependencies gnus-newsgroup-dependencies))
9461 number headers header)
9463 (set-buffer nntp-server-buffer)
9464 ;; Allow the user to mangle the headers before parsing them.
9465 (run-hooks 'gnus-parse-headers-hook)
9466 (goto-char (point-min))
9467 (while (and sequence (not (eobp)))
9468 (setq number (read cur))
9469 (while (and sequence (< (car sequence) number))
9470 (setq sequence (cdr sequence)))
9472 (eq number (car sequence))
9474 (setq sequence (cdr sequence))
9476 (inline (gnus-nov-parse-line
9477 number dependencies force-new)))
9478 (setq headers (cons header headers)))))
9480 (setq headers (nreverse headers)))
9483 ;; This function has to be called with point after the article number
9484 ;; on the beginning of the line.
9485 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9487 (eol (gnus-point-at-eol))
9488 (buffer (current-buffer))
9489 header ref id id-dep ref-dep)
9491 ;; overview: [num subject from date id refs chars lines misc]
9492 (narrow-to-region (point) eol)
9493 (or (eobp) (forward-char))
9499 (gnus-nov-field) ; subject
9500 (gnus-nov-field) ; from
9501 (gnus-nov-field) ; date
9502 (setq id (or (gnus-nov-field)
9505 (setq none (1+ none)))))) ; id
9508 (let ((beg (point)))
9509 (search-forward "\t" eol)
9510 (if (search-backward ">" beg t)
9514 (search-backward "<" beg t)))
9516 (gnus-nov-field)) ; refs
9517 (gnus-nov-read-integer) ; chars
9518 (gnus-nov-read-integer) ; lines
9519 (if (= (following-char) ?\n)
9521 (gnus-nov-field)) ; misc
9524 (gnus-error 4 "Strange nov line")
9530 ;; We build the thread tree.
9532 (if (boundp (setq id-dep (intern id dependencies)))
9533 (if (and (car (symbol-value id-dep))
9535 ;; An article with this Message-ID has already been seen,
9536 ;; so we ignore this one, except we add any additional
9537 ;; Xrefs (in case the two articles came from different
9540 (mail-header-set-xref
9541 (car (symbol-value id-dep))
9542 (concat (or (mail-header-xref
9543 (car (symbol-value id-dep))) "")
9544 (or (mail-header-xref header) "")))
9546 (setcar (symbol-value id-dep) header))
9547 (set id-dep (list header))))
9549 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9550 (setcdr (symbol-value ref-dep)
9551 (nconc (cdr (symbol-value ref-dep))
9552 (list (symbol-value id-dep))))
9553 (set ref-dep (list nil (symbol-value id-dep)))))
9556 (defun gnus-article-get-xrefs ()
9557 "Fill in the Xref value in `gnus-current-headers', if necessary.
9558 This is meant to be called in `gnus-article-internal-prepare-hook'."
9559 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9560 gnus-current-headers)))
9561 (or (not gnus-use-cross-reference)
9563 (and (mail-header-xref headers)
9564 (not (string= (mail-header-xref headers) "")))
9565 (let ((case-fold-search t)
9568 (nnheader-narrow-to-headers)
9569 (goto-char (point-min))
9570 (if (or (and (eq (downcase (following-char)) ?x)
9571 (looking-at "Xref:"))
9572 (search-forward "\nXref:" nil t))
9574 (goto-char (1+ (match-end 0)))
9575 (setq xref (buffer-substring (point)
9576 (progn (end-of-line) (point))))
9577 (mail-header-set-xref headers xref))))))))
9579 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9580 "Find article ID and insert the summary line for that article."
9581 (let ((header (if (and old-header use-old-header)
9582 old-header (gnus-read-header id)))
9583 (number (and (numberp id) id))
9586 ;; Rebuild the thread that this article is part of and go to the
9587 ;; article we have fetched.
9588 (when (and (not gnus-show-threads)
9590 (when (setq pos (text-property-any
9591 (point-min) (point-max) 'gnus-number
9592 (mail-header-number old-header)))
9595 (gnus-data-remove (mail-header-number old-header))))
9597 (mail-header-set-number header (mail-header-number old-header)))
9598 (setq gnus-newsgroup-sparse
9599 (delq (setq number (mail-header-number header))
9600 gnus-newsgroup-sparse))
9601 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9602 (gnus-rebuild-thread (mail-header-id header))
9603 (gnus-summary-goto-subject number nil t))
9604 (when (and (numberp number)
9606 ;; We have to update the boundaries even if we can't fetch the
9607 ;; article if ID is a number -- so that the next `P' or `N'
9608 ;; command will fetch the previous (or next) article even
9609 ;; if the one we tried to fetch this time has been canceled.
9610 (and (> number gnus-newsgroup-end)
9611 (setq gnus-newsgroup-end number))
9612 (and (< number gnus-newsgroup-begin)
9613 (setq gnus-newsgroup-begin number))
9614 (setq gnus-newsgroup-unselected
9615 (delq number gnus-newsgroup-unselected)))
9616 ;; Report back a success?
9617 (and header (mail-header-number header))))
9619 (defun gnus-summary-work-articles (n)
9620 "Return a list of articles to be worked upon. The prefix argument,
9621 the list of process marked articles, and the current article will be
9622 taken into consideration."
9625 ;; A numerical prefix has been given.
9626 (let ((backward (< n 0))
9627 (n (abs (prefix-numeric-value n)))
9632 (push (setq article (gnus-summary-article-number))
9635 (gnus-summary-find-prev nil article)
9636 (gnus-summary-find-next nil article)))
9638 (nreverse articles)))
9639 ((and (boundp 'transient-mark-mode)
9642 ;; Work on the region between point and mark.
9643 (let ((max (max (point) (mark)))
9646 (goto-char (min (point) (mark)))
9649 (push (setq article (gnus-summary-article-number)) articles)
9650 (gnus-summary-find-next nil article)
9652 (nreverse articles))))
9653 (gnus-newsgroup-processable
9654 ;; There are process-marked articles present.
9655 (reverse gnus-newsgroup-processable))
9657 ;; Just return the current article.
9658 (list (gnus-summary-article-number)))))
9660 (defun gnus-summary-search-group (&optional backward use-level)
9661 "Search for next unread newsgroup.
9662 If optional argument BACKWARD is non-nil, search backward instead."
9664 (set-buffer gnus-group-buffer)
9665 (if (gnus-group-search-forward
9666 backward nil (if use-level (gnus-group-group-level) nil))
9667 (gnus-group-group-name))))
9669 (defun gnus-summary-best-group (&optional exclude-group)
9670 "Find the name of the best unread group.
9671 If EXCLUDE-GROUP, do not go to this group."
9673 (set-buffer gnus-group-buffer)
9675 (gnus-group-best-unread-group exclude-group))))
9677 (defun gnus-summary-find-next (&optional unread article backward)
9678 (if backward (gnus-summary-find-prev)
9679 (let* ((dummy (gnus-summary-article-intangible-p))
9680 (article (or article (gnus-summary-article-number)))
9681 (arts (gnus-data-find-list article))
9683 (when (and (not dummy)
9684 (or (not gnus-summary-check-current)
9686 (not (gnus-data-unread-p (car arts)))))
9687 (setq arts (cdr arts)))
9692 (when (gnus-data-unread-p (car arts))
9693 (setq result (car arts)
9695 (setq arts (cdr arts)))
9698 (goto-char (gnus-data-pos result))
9699 (gnus-data-number result)))))
9701 (defun gnus-summary-find-prev (&optional unread article)
9702 (let* ((eobp (eobp))
9703 (article (or article (gnus-summary-article-number)))
9704 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9706 (when (and (not eobp)
9707 (or (not gnus-summary-check-current)
9709 (not (gnus-data-unread-p (car arts)))))
9710 (setq arts (cdr arts)))
9715 (and (gnus-data-unread-p (car arts))
9716 (setq result (car arts)
9718 (setq arts (cdr arts)))
9722 (goto-char (gnus-data-pos result))
9723 (gnus-data-number result)))))
9725 (defun gnus-summary-find-subject (subject &optional unread backward article)
9726 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9727 (article (or article (gnus-summary-article-number)))
9728 (articles (gnus-data-list backward))
9729 (arts (gnus-data-find-list article articles))
9731 (when (or (not gnus-summary-check-current)
9733 (not (gnus-data-unread-p (car arts))))
9734 (setq arts (cdr arts)))
9736 (and (or (not unread)
9737 (gnus-data-unread-p (car arts)))
9738 (vectorp (gnus-data-header (car arts)))
9740 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9741 (setq result (car arts)
9743 (setq arts (cdr arts)))
9745 (goto-char (gnus-data-pos result))
9746 (gnus-data-number result))))
9748 (defun gnus-summary-search-forward (&optional unread subject backward)
9749 "Search forward for an article.
9750 If UNREAD, look for unread articles. If SUBJECT, look for
9751 articles with that subject. If BACKWARD, search backward instead."
9752 (cond (subject (gnus-summary-find-subject subject unread backward))
9753 (backward (gnus-summary-find-prev unread))
9754 (t (gnus-summary-find-next unread))))
9756 (defun gnus-recenter (&optional n)
9757 "Center point in window and redisplay frame.
9758 Also do horizontal recentering."
9760 (when (and gnus-auto-center-summary
9761 (not (eq gnus-auto-center-summary 'vertical)))
9762 (gnus-horizontal-recenter))
9765 (defun gnus-summary-recenter ()
9766 "Center point in the summary window.
9767 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9768 displayed, no centering will be performed."
9769 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9770 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9771 (let* ((top (cond ((< (window-height) 4) 0)
9772 ((< (window-height) 7) 1)
9774 (height (1- (window-height)))
9775 (bottom (save-excursion (goto-char (point-max))
9776 (forward-line (- height))
9778 (window (get-buffer-window (current-buffer))))
9779 ;; The user has to want it.
9780 (when gnus-auto-center-summary
9781 (when (get-buffer-window gnus-article-buffer)
9782 ;; Only do recentering when the article buffer is displayed,
9783 ;; Set the window start to either `bottom', which is the biggest
9784 ;; possible valid number, or the second line from the top,
9785 ;; whichever is the least.
9787 window (min bottom (save-excursion
9788 (forward-line (- top)) (point)))))
9789 ;; Do horizontal recentering while we're at it.
9790 (when (and (get-buffer-window (current-buffer) t)
9791 (not (eq gnus-auto-center-summary 'vertical)))
9792 (let ((selected (selected-window)))
9793 (select-window (get-buffer-window (current-buffer) t))
9794 (gnus-summary-position-point)
9795 (gnus-horizontal-recenter)
9796 (select-window selected))))))
9798 (defun gnus-horizontal-recenter ()
9799 "Recenter the current buffer horizontally."
9800 (if (< (current-column) (/ (window-width) 2))
9801 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9802 (let* ((orig (point))
9803 (end (window-end (get-buffer-window (current-buffer) t)))
9805 ;; Find the longest line currently displayed in the window.
9806 (goto-char (window-start))
9807 (while (and (not (eobp))
9810 (setq max (max max (current-column)))
9813 ;; Scroll horizontally to center (sort of) the point.
9814 (if (> max (window-width))
9816 (get-buffer-window (current-buffer) t)
9817 (min (- (current-column) (/ (window-width) 3))
9818 (+ 2 (- max (window-width)))))
9819 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9822 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9823 (defun gnus-short-group-name (group &optional levels)
9824 "Collapse GROUP name LEVELS."
9831 (while (string-match "\\." group skip)
9832 (setq skip (match-end 0)
9835 (if (string-match ":" group)
9836 (setq foreign (substring group 0 (match-end 0))
9837 group (substring group (match-end 0))))
9839 (if (and (string-match "\\." group)
9840 (> levels (- gnus-group-uncollapsed-levels 1)))
9841 (setq name (concat name (substring group 0 1))
9842 group (substring group (match-end 0))
9844 name (concat name "."))
9845 (setq name (concat foreign name group)
9849 (defun gnus-summary-jump-to-group (newsgroup)
9850 "Move point to NEWSGROUP in group mode buffer."
9851 ;; Keep update point of group mode buffer if visible.
9852 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9853 (save-window-excursion
9854 ;; Take care of tree window mode.
9855 (if (get-buffer-window gnus-group-buffer)
9856 (pop-to-buffer gnus-group-buffer))
9857 (gnus-group-jump-to-group newsgroup))
9859 ;; Take care of tree window mode.
9860 (if (get-buffer-window gnus-group-buffer)
9861 (pop-to-buffer gnus-group-buffer)
9862 (set-buffer gnus-group-buffer))
9863 (gnus-group-jump-to-group newsgroup))))
9865 ;; This function returns a list of article numbers based on the
9866 ;; difference between the ranges of read articles in this group and
9867 ;; the range of active articles.
9868 (defun gnus-list-of-unread-articles (group)
9869 (let* ((read (gnus-info-read (gnus-get-info group)))
9870 (active (gnus-active group))
9873 ;; If none are read, then all are unread.
9875 (setq first (car active))
9876 ;; If the range of read articles is a single range, then the
9877 ;; first unread article is the article after the last read
9878 ;; article. Sounds logical, doesn't it?
9879 (if (not (listp (cdr read)))
9880 (setq first (1+ (cdr read)))
9881 ;; `read' is a list of ranges.
9882 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9887 (while (< first nlast)
9888 (setq unread (cons first unread))
9889 (setq first (1+ first))))
9890 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9891 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9892 (setq read (cdr read)))))
9893 ;; And add the last unread articles.
9894 (while (<= first last)
9895 (setq unread (cons first unread))
9896 (setq first (1+ first)))
9897 ;; Return the list of unread articles.
9900 (defun gnus-list-of-read-articles (group)
9901 "Return a list of unread, unticked and non-dormant articles."
9902 (let* ((info (gnus-get-info group))
9903 (marked (gnus-info-marks info))
9904 (active (gnus-active group)))
9906 (gnus-set-difference
9907 (gnus-sorted-complement
9908 (gnus-uncompress-range active)
9909 (gnus-list-of-unread-articles group))
9911 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9912 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9914 ;; Various summary commands
9916 (defun gnus-summary-universal-argument (arg)
9917 "Perform any operation on all articles that are process/prefixed."
9919 (gnus-set-global-variables)
9920 (let ((articles (gnus-summary-work-articles arg))
9927 (substitute-command-keys
9928 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9931 (gnus-error 1 "Undefined key")
9934 (gnus-summary-goto-subject (setq article (pop articles)))
9935 (command-execute func)
9936 (gnus-summary-remove-process-mark article)))))
9937 (gnus-summary-position-point))
9939 (defun gnus-summary-toggle-truncation (&optional arg)
9940 "Toggle truncation of summary lines.
9941 With arg, turn line truncation on iff arg is positive."
9943 (setq truncate-lines
9944 (if (null arg) (not truncate-lines)
9945 (> (prefix-numeric-value arg) 0)))
9948 (defun gnus-summary-reselect-current-group (&optional all rescan)
9949 "Exit and then reselect the current newsgroup.
9950 The prefix argument ALL means to select all articles."
9952 (gnus-set-global-variables)
9953 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9954 (error "Ephemeral groups can't be reselected"))
9955 (let ((current-subject (gnus-summary-article-number))
9956 (group gnus-newsgroup-name))
9957 (setq gnus-newsgroup-begin nil)
9959 ;; We have to adjust the point of group mode buffer because the
9960 ;; current point was moved to the next unread newsgroup by
9962 (gnus-summary-jump-to-group group)
9965 (gnus-group-get-new-news-this-group 1)))
9966 (gnus-group-read-group all t)
9967 (gnus-summary-goto-subject current-subject nil t)))
9969 (defun gnus-summary-rescan-group (&optional all)
9970 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9972 (gnus-summary-reselect-current-group all t))
9974 (defun gnus-summary-update-info ()
9975 (let* ((group gnus-newsgroup-name))
9976 (when gnus-newsgroup-kill-headers
9977 (setq gnus-newsgroup-killed
9978 (gnus-compress-sequence
9980 (gnus-set-sorted-intersection
9981 (gnus-uncompress-range gnus-newsgroup-killed)
9982 (setq gnus-newsgroup-unselected
9983 (sort gnus-newsgroup-unselected '<)))
9984 (setq gnus-newsgroup-unreads
9985 (sort gnus-newsgroup-unreads '<))) t)))
9986 (unless (listp (cdr gnus-newsgroup-killed))
9987 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9988 (let ((headers gnus-newsgroup-headers))
9989 (run-hooks 'gnus-exit-group-hook)
9990 (unless gnus-save-score
9991 (setq gnus-newsgroup-scored nil))
9992 ;; Set the new ranges of read articles.
9993 (gnus-update-read-articles
9994 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9995 ;; Set the current article marks.
9997 ;; Do the cross-ref thing.
9998 (when gnus-use-cross-reference
9999 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
10000 ;; Do adaptive scoring, and possibly save score files.
10001 (when gnus-newsgroup-adaptive
10002 (gnus-score-adaptive))
10003 (when gnus-use-scoring
10005 ;; Do not switch windows but change the buffer to work.
10006 (set-buffer gnus-group-buffer)
10007 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10008 (gnus-group-update-group group)))))
10010 (defun gnus-summary-exit (&optional temporary)
10011 "Exit reading current newsgroup, and then return to group selection mode.
10012 gnus-exit-group-hook is called with no arguments if that value is non-nil."
10014 (gnus-set-global-variables)
10015 (gnus-kill-save-kill-buffer)
10016 (let* ((group gnus-newsgroup-name)
10017 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
10019 (buf (current-buffer)))
10020 (run-hooks 'gnus-summary-prepare-exit-hook)
10021 ;; If we have several article buffers, we kill them at exit.
10022 (unless gnus-single-article-buffer
10023 (gnus-kill-buffer gnus-original-article-buffer)
10024 (setq gnus-article-current nil))
10025 (when gnus-use-cache
10026 (gnus-cache-possibly-remove-articles)
10027 (gnus-cache-save-buffers))
10028 (when gnus-use-trees
10029 (gnus-tree-close group))
10030 ;; Make all changes in this group permanent.
10031 (unless quit-config
10032 (gnus-summary-update-info))
10033 (gnus-close-group group)
10034 ;; Make sure where I was, and go to next newsgroup.
10035 (set-buffer gnus-group-buffer)
10036 (unless quit-config
10037 (gnus-group-jump-to-group group))
10038 (run-hooks 'gnus-summary-exit-hook)
10039 (unless quit-config
10040 (gnus-group-next-unread-group 1))
10042 nil ;Nothing to do.
10043 ;; If we have several article buffers, we kill them at exit.
10044 (unless gnus-single-article-buffer
10045 (gnus-kill-buffer gnus-article-buffer)
10046 (gnus-kill-buffer gnus-original-article-buffer)
10047 (setq gnus-article-current nil))
10049 (if (not gnus-kill-summary-on-exit)
10050 (gnus-deaden-summary)
10051 ;; We set all buffer-local variables to nil. It is unclear why
10052 ;; this is needed, but if we don't, buffer-local variables are
10053 ;; not garbage-collected, it seems. This would the lead to en
10054 ;; ever-growing Emacs.
10055 (gnus-summary-clear-local-variables)
10056 (when (get-buffer gnus-article-buffer)
10057 (bury-buffer gnus-article-buffer))
10058 ;; We clear the global counterparts of the buffer-local
10059 ;; variables as well, just to be on the safe side.
10060 (gnus-configure-windows 'group 'force)
10061 (gnus-summary-clear-local-variables)
10062 ;; Return to group mode buffer.
10063 (if (eq mode 'gnus-summary-mode)
10064 (gnus-kill-buffer buf)))
10065 (setq gnus-current-select-method gnus-select-method)
10066 (pop-to-buffer gnus-group-buffer)
10067 ;; Clear the current group name.
10068 (if (not quit-config)
10070 (gnus-group-jump-to-group group)
10071 (gnus-group-next-unread-group 1)
10072 (gnus-configure-windows 'group 'force))
10073 (if (not (buffer-name (car quit-config)))
10074 (gnus-configure-windows 'group 'force)
10075 (set-buffer (car quit-config))
10076 (and (eq major-mode 'gnus-summary-mode)
10077 (gnus-set-global-variables))
10078 (gnus-configure-windows (cdr quit-config))))
10079 (unless quit-config
10080 (setq gnus-newsgroup-name nil)))))
10082 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10083 (defun gnus-summary-exit-no-update (&optional no-questions)
10084 "Quit reading current newsgroup without updating read article info."
10086 (gnus-set-global-variables)
10087 (let* ((group gnus-newsgroup-name)
10088 (quit-config (gnus-group-quit-config group)))
10089 (when (or no-questions
10091 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10092 ;; If we have several article buffers, we kill them at exit.
10093 (unless gnus-single-article-buffer
10094 (gnus-kill-buffer gnus-article-buffer)
10095 (gnus-kill-buffer gnus-original-article-buffer)
10096 (setq gnus-article-current nil))
10097 (if (not gnus-kill-summary-on-exit)
10098 (gnus-deaden-summary)
10099 (gnus-close-group group)
10100 (gnus-summary-clear-local-variables)
10101 (set-buffer gnus-group-buffer)
10102 (gnus-summary-clear-local-variables)
10103 (when (get-buffer gnus-summary-buffer)
10104 (kill-buffer gnus-summary-buffer)))
10105 (unless gnus-single-article-buffer
10106 (setq gnus-article-current nil))
10107 (when gnus-use-trees
10108 (gnus-tree-close group))
10109 (when (get-buffer gnus-article-buffer)
10110 (bury-buffer gnus-article-buffer))
10111 ;; Return to the group buffer.
10112 (gnus-configure-windows 'group 'force)
10113 ;; Clear the current group name.
10114 (setq gnus-newsgroup-name nil)
10115 (when (equal (gnus-group-group-name) group)
10116 (gnus-group-next-unread-group 1))
10118 (if (not (buffer-name (car quit-config)))
10119 (gnus-configure-windows 'group 'force)
10120 (set-buffer (car quit-config))
10121 (when (eq major-mode 'gnus-summary-mode)
10122 (gnus-set-global-variables))
10123 (gnus-configure-windows (cdr quit-config)))))))
10125 ;;; Dead summaries.
10127 (defvar gnus-dead-summary-mode-map nil)
10129 (if gnus-dead-summary-mode-map
10131 (setq gnus-dead-summary-mode-map (make-keymap))
10132 (suppress-keymap gnus-dead-summary-mode-map)
10133 (substitute-key-definition
10134 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10135 (let ((keys '("\C-d" "\r" "\177")))
10137 (define-key gnus-dead-summary-mode-map
10138 (pop keys) 'gnus-summary-wake-up-the-dead))))
10140 (defvar gnus-dead-summary-mode nil
10141 "Minor mode for Gnus summary buffers.")
10143 (defun gnus-dead-summary-mode (&optional arg)
10144 "Minor mode for Gnus summary buffers."
10146 (when (eq major-mode 'gnus-summary-mode)
10147 (make-local-variable 'gnus-dead-summary-mode)
10148 (setq gnus-dead-summary-mode
10149 (if (null arg) (not gnus-dead-summary-mode)
10150 (> (prefix-numeric-value arg) 0)))
10151 (when gnus-dead-summary-mode
10152 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10153 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10154 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10155 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10156 minor-mode-map-alist)))))
10158 (defun gnus-deaden-summary ()
10159 "Make the current summary buffer into a dead summary buffer."
10160 ;; Kill any previous dead summary buffer.
10161 (when (and gnus-dead-summary
10162 (buffer-name gnus-dead-summary))
10164 (set-buffer gnus-dead-summary)
10165 (when gnus-dead-summary-mode
10166 (kill-buffer (current-buffer)))))
10167 ;; Make this the current dead summary.
10168 (setq gnus-dead-summary (current-buffer))
10169 (gnus-dead-summary-mode 1)
10170 (let ((name (buffer-name)))
10171 (when (string-match "Summary" name)
10173 (concat (substring name 0 (match-beginning 0)) "Dead "
10174 (substring name (match-beginning 0))) t))))
10176 (defun gnus-kill-or-deaden-summary (buffer)
10177 "Kill or deaden the summary BUFFER."
10178 (when (and (buffer-name buffer)
10179 (not gnus-single-article-buffer))
10181 (set-buffer buffer)
10182 (gnus-kill-buffer gnus-article-buffer)
10183 (gnus-kill-buffer gnus-original-article-buffer)))
10184 (cond (gnus-kill-summary-on-exit
10185 (when (and gnus-use-trees
10186 (and (get-buffer buffer)
10187 (buffer-name (get-buffer buffer))))
10189 (set-buffer (get-buffer buffer))
10190 (gnus-tree-close gnus-newsgroup-name)))
10191 (gnus-kill-buffer buffer))
10192 ((and (get-buffer buffer)
10193 (buffer-name (get-buffer buffer)))
10195 (set-buffer buffer)
10196 (gnus-deaden-summary)))))
10198 (defun gnus-summary-wake-up-the-dead (&rest args)
10199 "Wake up the dead summary buffer."
10201 (gnus-dead-summary-mode -1)
10202 (let ((name (buffer-name)))
10203 (when (string-match "Dead " name)
10205 (concat (substring name 0 (match-beginning 0))
10206 (substring name (match-end 0))) t)))
10207 (gnus-message 3 "This dead summary is now alive again"))
10209 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10210 (defun gnus-summary-fetch-faq (&optional faq-dir)
10211 "Fetch the FAQ for the current group.
10212 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10216 (if current-prefix-arg
10218 "Faq dir: " (and (listp gnus-group-faq-directory)
10219 gnus-group-faq-directory)))))
10220 (let (gnus-faq-buffer)
10221 (and (setq gnus-faq-buffer
10222 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10223 (gnus-configure-windows 'summary-faq))))
10225 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10226 (defun gnus-summary-describe-group (&optional force)
10227 "Describe the current newsgroup."
10229 (gnus-group-describe-group force gnus-newsgroup-name))
10231 (defun gnus-summary-describe-briefly ()
10232 "Describe summary mode commands briefly."
10235 (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")))
10237 ;; Walking around group mode buffer from summary mode.
10239 (defun gnus-summary-next-group (&optional no-article target-group backward)
10240 "Exit current newsgroup and then select next unread newsgroup.
10241 If prefix argument NO-ARTICLE is non-nil, no article is selected
10242 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10243 previous group instead."
10245 (gnus-set-global-variables)
10246 (let ((current-group gnus-newsgroup-name)
10247 (current-buffer (current-buffer))
10249 ;; First we semi-exit this group to update Xrefs and all variables.
10250 ;; We can't do a real exit, because the window conf must remain
10251 ;; the same in case the user is prompted for info, and we don't
10252 ;; want the window conf to change before that...
10253 (gnus-summary-exit t)
10254 (while (not entered)
10255 ;; Then we find what group we are supposed to enter.
10256 (set-buffer gnus-group-buffer)
10257 (gnus-group-jump-to-group current-group)
10260 (if (eq gnus-keep-same-level 'best)
10261 (gnus-summary-best-group gnus-newsgroup-name)
10262 (gnus-summary-search-group backward gnus-keep-same-level))))
10263 (if (not target-group)
10264 ;; There are no further groups, so we return to the group
10267 (gnus-message 5 "Returning to the group buffer")
10269 (set-buffer current-buffer)
10270 (gnus-summary-exit))
10271 ;; We try to enter the target group.
10272 (gnus-group-jump-to-group target-group)
10273 (let ((unreads (gnus-group-group-unread)))
10274 (if (and (or (eq t unreads)
10275 (and unreads (not (zerop unreads))))
10276 (gnus-summary-read-group
10277 target-group nil no-article current-buffer))
10279 (setq current-group target-group
10280 target-group nil)))))))
10282 (defun gnus-summary-prev-group (&optional no-article)
10283 "Exit current newsgroup and then select previous unread newsgroup.
10284 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10286 (gnus-summary-next-group no-article nil t))
10288 ;; Walking around summary lines.
10290 (defun gnus-summary-first-subject (&optional unread)
10291 "Go to the first unread subject.
10292 If UNREAD is non-nil, go to the first unread article.
10293 Returns the article selected or nil if there are no unread articles."
10298 ((null gnus-newsgroup-data)
10299 (gnus-message 3 "No articles in the group")
10301 ;; Pick the first article.
10303 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10304 (gnus-data-number (car gnus-newsgroup-data)))
10305 ;; No unread articles.
10306 ((null gnus-newsgroup-unreads)
10307 (gnus-message 3 "No more unread articles")
10309 ;; Find the first unread article.
10311 (let ((data gnus-newsgroup-data))
10313 (not (gnus-data-unread-p (car data))))
10314 (setq data (cdr data)))
10317 (goto-char (gnus-data-pos (car data)))
10318 (gnus-data-number (car data)))))))
10319 (gnus-summary-position-point)))
10321 (defun gnus-summary-next-subject (n &optional unread dont-display)
10322 "Go to next N'th summary line.
10323 If N is negative, go to the previous N'th subject line.
10324 If UNREAD is non-nil, only unread articles are selected.
10325 The difference between N and the actual number of steps taken is
10328 (let ((backward (< n 0))
10330 (while (and (> n 0)
10332 (gnus-summary-find-prev unread)
10333 (gnus-summary-find-next unread)))
10335 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10336 (if unread " unread" "")))
10337 (unless dont-display
10338 (gnus-summary-recenter)
10339 (gnus-summary-position-point))
10342 (defun gnus-summary-next-unread-subject (n)
10343 "Go to next N'th unread summary line."
10345 (gnus-summary-next-subject n t))
10347 (defun gnus-summary-prev-subject (n &optional unread)
10348 "Go to previous N'th summary line.
10349 If optional argument UNREAD is non-nil, only unread article is selected."
10351 (gnus-summary-next-subject (- n) unread))
10353 (defun gnus-summary-prev-unread-subject (n)
10354 "Go to previous N'th unread summary line."
10356 (gnus-summary-next-subject (- n) t))
10358 (defun gnus-summary-goto-subject (article &optional force silent)
10359 "Go the subject line of ARTICLE.
10360 If FORCE, also allow jumping to articles not currently shown."
10362 (data (gnus-data-find article)))
10363 ;; We read in the article if we have to.
10366 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10367 (setq data (gnus-data-find article)))
10372 (gnus-message 3 "Can't find article %d" article))
10374 (goto-char (gnus-data-pos data))
10377 ;; Walking around summary lines with displaying articles.
10379 (defun gnus-summary-expand-window (&optional arg)
10380 "Make the summary buffer take up the entire Emacs frame.
10381 Given a prefix, will force an `article' buffer configuration."
10383 (gnus-set-global-variables)
10385 (gnus-configure-windows 'article 'force)
10386 (gnus-configure-windows 'summary 'force)))
10388 (defun gnus-summary-display-article (article &optional all-header)
10389 "Display ARTICLE in article buffer."
10390 (gnus-set-global-variables)
10394 (if gnus-summary-display-article-function
10395 (funcall gnus-summary-display-article-function article all-header)
10396 (gnus-article-prepare article all-header))
10397 (run-hooks 'gnus-select-article-hook)
10398 (unless (zerop gnus-current-article)
10399 (gnus-summary-goto-subject gnus-current-article))
10400 (gnus-summary-recenter)
10401 (when gnus-use-trees
10402 (gnus-possibly-generate-tree article)
10403 (gnus-highlight-selected-tree article))
10404 ;; Successfully display article.
10405 (gnus-article-set-window-start
10406 (cdr (assq article gnus-newsgroup-bookmarks))))))
10408 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10409 "Select the current article.
10410 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10411 non-nil, the article will be re-fetched even if it already present in
10412 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10414 ;; Make sure we are in the summary buffer to work around bbdb bug.
10415 (unless (eq major-mode 'gnus-summary-mode)
10416 (set-buffer gnus-summary-buffer))
10417 (let ((article (or article (gnus-summary-article-number)))
10418 (all-headers (not (not all-headers))) ;Must be T or NIL.
10419 gnus-summary-display-article-function
10422 (gnus-summary-article-pseudo-p article)
10423 (error "This is a pseudo-article."))
10426 (set-buffer gnus-summary-buffer)
10427 (if (or (and gnus-single-article-buffer
10428 (or (null gnus-current-article)
10429 (null gnus-article-current)
10430 (null (get-buffer gnus-article-buffer))
10431 (not (eq article (cdr gnus-article-current)))
10432 (not (equal (car gnus-article-current)
10433 gnus-newsgroup-name))))
10434 (and (not gnus-single-article-buffer)
10435 (or (null gnus-current-article)
10436 (not (eq gnus-current-article article))))
10438 ;; The requested article is different from the current article.
10440 (gnus-summary-display-article article all-headers)
10441 (setq did article))
10442 (if (or all-headers gnus-show-all-headers)
10443 (gnus-article-show-all-headers))
10446 (gnus-article-set-window-start
10447 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10449 (defun gnus-summary-set-current-mark (&optional current-mark)
10450 "Obsolete function."
10453 (defun gnus-summary-next-article (&optional unread subject backward push)
10454 "Select the next article.
10455 If UNREAD, only unread articles are selected.
10456 If SUBJECT, only articles with SUBJECT are selected.
10457 If BACKWARD, the previous article is selected instead of the next."
10459 (gnus-set-global-variables)
10461 ;; Is there such an article?
10462 ((and (gnus-summary-search-forward unread subject backward)
10463 (or (gnus-summary-display-article (gnus-summary-article-number))
10464 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10465 (gnus-summary-position-point))
10466 ;; If not, we try the first unread, if that is wanted.
10468 gnus-auto-select-same
10469 (gnus-summary-first-unread-article))
10470 (gnus-summary-position-point)
10471 (gnus-message 6 "Wrapped"))
10472 ;; Try to get next/previous article not displayed in this group.
10473 ((and gnus-auto-extend-newsgroup
10474 (not unread) (not subject))
10475 (gnus-summary-goto-article
10476 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10478 ;; Go to next/previous group.
10480 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10481 (gnus-summary-jump-to-group gnus-newsgroup-name))
10482 (let ((cmd last-command-char)
10484 (if (eq gnus-keep-same-level 'best)
10485 (gnus-summary-best-group gnus-newsgroup-name)
10486 (gnus-summary-search-group backward gnus-keep-same-level))))
10487 ;; For some reason, the group window gets selected. We change
10489 (select-window (get-buffer-window (current-buffer)))
10490 ;; Select next unread newsgroup automagically.
10492 ((or (not gnus-auto-select-next)
10494 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10495 ((or (eq gnus-auto-select-next 'quietly)
10496 (and (eq gnus-auto-select-next 'slightly-quietly)
10498 (and (eq gnus-auto-select-next 'almost-quietly)
10499 (gnus-summary-last-article-p)))
10501 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10502 (gnus-summary-exit)
10503 (gnus-message 7 "No more%s articles (%s)..."
10504 (if unread " unread" "")
10505 (if group (concat "selecting " group)
10507 (gnus-summary-next-group nil group backward)))
10509 (gnus-summary-walk-group-buffer
10510 gnus-newsgroup-name cmd unread backward)))))))
10512 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10513 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10514 (?\C-p (gnus-group-prev-unread-group 1))))
10515 keve key group ended)
10517 (set-buffer gnus-group-buffer)
10518 (gnus-summary-jump-to-group from-group)
10520 (if (eq gnus-keep-same-level 'best)
10521 (gnus-summary-best-group gnus-newsgroup-name)
10522 (gnus-summary-search-group backward gnus-keep-same-level))))
10525 5 "No more%s articles%s" (if unread " unread" "")
10527 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10528 (format " (Type %s for %s [%s])"
10529 (single-key-description cmd) group
10530 (car (gnus-gethash group gnus-newsrc-hashtb)))
10531 (format " (Type %s to exit %s)"
10532 (single-key-description cmd)
10533 gnus-newsgroup-name)))
10534 ;; Confirm auto selection.
10535 (setq key (car (setq keve (gnus-read-event-char))))
10538 ((assq key keystrokes)
10539 (let ((obuf (current-buffer)))
10540 (switch-to-buffer gnus-group-buffer)
10542 (gnus-group-jump-to-group group))
10543 (eval (cadr (assq key keystrokes)))
10544 (setq group (gnus-group-group-name))
10545 (switch-to-buffer obuf))
10548 (if (or (not group)
10549 (gnus-ephemeral-group-p gnus-newsgroup-name))
10550 (gnus-summary-exit)
10551 (gnus-summary-next-group nil group backward)))
10553 (push (cdr keve) unread-command-events))))))
10555 (defun gnus-read-event-char ()
10556 "Get the next event."
10557 (let ((event (read-event)))
10558 (cons (and (numberp event) event) event)))
10560 (defun gnus-summary-next-unread-article ()
10561 "Select unread article after current one."
10563 (gnus-summary-next-article t (and gnus-auto-select-same
10564 (gnus-summary-article-subject))))
10566 (defun gnus-summary-prev-article (&optional unread subject)
10567 "Select the article after the current one.
10568 If UNREAD is non-nil, only unread articles are selected."
10570 (gnus-summary-next-article unread subject t))
10572 (defun gnus-summary-prev-unread-article ()
10573 "Select unred article before current one."
10575 (gnus-summary-prev-article t (and gnus-auto-select-same
10576 (gnus-summary-article-subject))))
10578 (defun gnus-summary-next-page (&optional lines circular)
10579 "Show next page of the selected article.
10580 If at the end of the current article, select the next article.
10581 LINES says how many lines should be scrolled up.
10583 If CIRCULAR is non-nil, go to the start of the article instead of
10584 selecting the next article when reaching the end of the current
10587 (setq gnus-summary-buffer (current-buffer))
10588 (gnus-set-global-variables)
10589 (let ((article (gnus-summary-article-number))
10591 (gnus-configure-windows 'article)
10592 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10593 (if (and (eq gnus-summary-goto-unread 'never)
10594 (not (gnus-summary-last-article-p article)))
10595 (gnus-summary-next-article)
10596 (gnus-summary-next-unread-article))
10597 (if (or (null gnus-current-article)
10598 (null gnus-article-current)
10599 (/= article (cdr gnus-article-current))
10600 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10601 ;; Selected subject is different from current article's.
10602 (gnus-summary-display-article article)
10603 (gnus-eval-in-buffer-window gnus-article-buffer
10604 (setq endp (gnus-article-next-page lines)))
10607 (gnus-summary-beginning-of-article))
10609 (gnus-message 3 "End of message"))
10611 (if (and (eq gnus-summary-goto-unread 'never)
10612 (not (gnus-summary-last-article-p article)))
10613 (gnus-summary-next-article)
10614 (gnus-summary-next-unread-article)))))))
10615 (gnus-summary-recenter)
10616 (gnus-summary-position-point)))
10618 (defun gnus-summary-prev-page (&optional lines)
10619 "Show previous page of selected article.
10620 Argument LINES specifies lines to be scrolled down."
10622 (gnus-set-global-variables)
10623 (let ((article (gnus-summary-article-number)))
10624 (gnus-configure-windows 'article)
10625 (if (or (null gnus-current-article)
10626 (null gnus-article-current)
10627 (/= article (cdr gnus-article-current))
10628 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10629 ;; Selected subject is different from current article's.
10630 (gnus-summary-display-article article)
10631 (gnus-summary-recenter)
10632 (gnus-eval-in-buffer-window gnus-article-buffer
10633 (gnus-article-prev-page lines))))
10634 (gnus-summary-position-point))
10636 (defun gnus-summary-scroll-up (lines)
10637 "Scroll up (or down) one line current article.
10638 Argument LINES specifies lines to be scrolled up (or down if negative)."
10640 (gnus-set-global-variables)
10641 (gnus-configure-windows 'article)
10642 (gnus-summary-show-thread)
10643 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10644 (gnus-eval-in-buffer-window gnus-article-buffer
10646 (if (gnus-article-next-page lines)
10647 (gnus-message 3 "End of message")))
10649 (gnus-article-prev-page (- lines))))))
10650 (gnus-summary-recenter)
10651 (gnus-summary-position-point))
10653 (defun gnus-summary-next-same-subject ()
10654 "Select next article which has the same subject as current one."
10656 (gnus-set-global-variables)
10657 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10659 (defun gnus-summary-prev-same-subject ()
10660 "Select previous article which has the same subject as current one."
10662 (gnus-set-global-variables)
10663 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10665 (defun gnus-summary-next-unread-same-subject ()
10666 "Select next unread article which has the same subject as current one."
10668 (gnus-set-global-variables)
10669 (gnus-summary-next-article t (gnus-summary-article-subject)))
10671 (defun gnus-summary-prev-unread-same-subject ()
10672 "Select previous unread article which has the same subject as current one."
10674 (gnus-set-global-variables)
10675 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10677 (defun gnus-summary-first-unread-article ()
10678 "Select the first unread article.
10679 Return nil if there are no unread articles."
10681 (gnus-set-global-variables)
10683 (if (gnus-summary-first-subject t)
10685 (gnus-summary-show-thread)
10686 (gnus-summary-first-subject t)
10687 (gnus-summary-display-article (gnus-summary-article-number))))
10688 (gnus-summary-position-point)))
10690 (defun gnus-summary-best-unread-article ()
10691 "Select the unread article with the highest score."
10693 (gnus-set-global-variables)
10694 (let ((best -1000000)
10695 (data gnus-newsgroup-data)
10698 (and (gnus-data-unread-p (car data))
10700 (gnus-summary-article-score (gnus-data-number (car data))))
10703 article (gnus-data-number (car data))))
10704 (setq data (cdr data)))
10707 (gnus-summary-goto-article article)
10708 (error "No unread articles"))
10709 (gnus-summary-position-point))))
10711 (defun gnus-summary-last-subject ()
10712 "Go to the last displayed subject line in the group."
10713 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10715 (gnus-summary-goto-subject article))))
10717 (defun gnus-summary-goto-article (article &optional all-headers force)
10718 "Fetch ARTICLE and display it if it exists.
10719 If ALL-HEADERS is non-nil, no header lines are hidden."
10725 (mapcar (lambda (number) (list (int-to-string number)))
10726 gnus-newsgroup-limit)))
10730 (if (gnus-summary-goto-subject article force)
10731 (gnus-summary-display-article article all-headers)
10732 (gnus-message 4 "Couldn't go to article %s" article) nil)
10733 (gnus-summary-position-point)))
10735 (defun gnus-summary-goto-last-article ()
10736 "Go to the previously read article."
10739 (and gnus-last-article
10740 (gnus-summary-goto-article gnus-last-article))
10741 (gnus-summary-position-point)))
10743 (defun gnus-summary-pop-article (number)
10744 "Pop one article off the history and go to the previous.
10745 NUMBER articles will be popped off."
10748 (setq gnus-newsgroup-history
10749 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10751 (gnus-summary-goto-article (car to))
10752 (error "Article history empty")))
10753 (gnus-summary-position-point))
10755 ;; Summary commands and functions for limiting the summary buffer.
10757 (defun gnus-summary-limit-to-articles (n)
10758 "Limit the summary buffer to the next N articles.
10759 If not given a prefix, use the process marked articles instead."
10761 (gnus-set-global-variables)
10763 (let ((articles (gnus-summary-work-articles n)))
10764 (setq gnus-newsgroup-processable nil)
10765 (gnus-summary-limit articles))
10766 (gnus-summary-position-point)))
10768 (defun gnus-summary-pop-limit (&optional total)
10769 "Restore the previous limit.
10770 If given a prefix, remove all limits."
10772 (gnus-set-global-variables)
10774 (setq gnus-newsgroup-limits
10775 (list (mapcar (lambda (h) (mail-header-number h))
10776 gnus-newsgroup-headers))))
10777 (unless gnus-newsgroup-limits
10778 (error "No limit to pop"))
10780 (gnus-summary-limit nil 'pop)
10781 (gnus-summary-position-point)))
10783 (defun gnus-summary-limit-to-subject (subject &optional header)
10784 "Limit the summary buffer to articles that have subjects that match a regexp."
10785 (interactive "sRegexp: ")
10787 (setq header "subject"))
10788 (when (not (equal "" subject))
10790 (let ((articles (gnus-summary-find-matching
10791 (or header "subject") subject 'all)))
10792 (or articles (error "Found no matches for \"%s\"" subject))
10793 (gnus-summary-limit articles))
10794 (gnus-summary-position-point))))
10796 (defun gnus-summary-limit-to-author (from)
10797 "Limit the summary buffer to articles that have authors that match a regexp."
10798 (interactive "sRegexp: ")
10799 (gnus-summary-limit-to-subject from "from"))
10801 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10803 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10805 (defun gnus-summary-limit-to-unread (&optional all)
10806 "Limit the summary buffer to articles that are not marked as read.
10807 If ALL is non-nil, limit strictly to unread articles."
10810 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10811 (gnus-summary-limit-to-marks
10812 ;; Concat all the marks that say that an article is read and have
10814 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10815 gnus-killed-mark gnus-kill-file-mark
10816 gnus-low-score-mark gnus-expirable-mark
10817 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10820 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10821 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10823 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10824 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10825 If REVERSE, limit the summary buffer to articles that are not marked
10826 with MARKS. MARKS can either be a string of marks or a list of marks.
10827 Returns how many articles were removed."
10828 (interactive "sMarks: ")
10829 (gnus-set-global-variables)
10831 (let ((data gnus-newsgroup-data)
10832 (marks (if (listp marks) marks
10833 (append marks nil))) ; Transform to list.
10836 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10837 (memq (gnus-data-mark (car data)) marks))
10838 (setq articles (cons (gnus-data-number (car data)) articles)))
10839 (setq data (cdr data)))
10840 (gnus-summary-limit articles))
10841 (gnus-summary-position-point)))
10843 (defun gnus-summary-limit-to-score (&optional score)
10844 "Limit to articles with score at or above SCORE."
10846 (gnus-set-global-variables)
10847 (setq score (if score
10848 (prefix-numeric-value score)
10849 (or gnus-summary-default-score 0)))
10850 (let ((data gnus-newsgroup-data)
10853 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10855 (push (gnus-data-number (car data)) articles))
10856 (setq data (cdr data)))
10858 (gnus-summary-limit articles)
10859 (gnus-summary-position-point))))
10861 (defun gnus-summary-limit-include-dormant ()
10862 "Display all the hidden articles that are marked as dormant."
10864 (gnus-set-global-variables)
10865 (or gnus-newsgroup-dormant
10866 (error "There are no dormant articles in this group"))
10868 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10869 (gnus-summary-position-point)))
10871 (defun gnus-summary-limit-exclude-dormant ()
10872 "Hide all dormant articles."
10874 (gnus-set-global-variables)
10876 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10877 (gnus-summary-position-point)))
10879 (defun gnus-summary-limit-exclude-childless-dormant ()
10880 "Hide all dormant articles that have no children."
10882 (gnus-set-global-variables)
10883 (let ((data (gnus-data-list t))
10884 articles d children)
10885 ;; Find all articles that are either not dormant or have
10887 (while (setq d (pop data))
10888 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10889 (and (setq children
10890 (gnus-article-children (gnus-data-number d)))
10893 (when (memq (car children) articles)
10898 (push (gnus-data-number d) articles)))
10899 ;; Do the limiting.
10901 (gnus-summary-limit articles)
10902 (gnus-summary-position-point))))
10904 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10905 "Mark all unread excluded articles as read.
10906 If ALL, mark even excluded ticked and dormants as read."
10908 (let ((articles (gnus-sorted-complement
10910 (mapcar (lambda (h) (mail-header-number h))
10911 gnus-newsgroup-headers)
10913 (sort gnus-newsgroup-limit '<)))
10915 (setq gnus-newsgroup-unreads nil)
10917 (setq gnus-newsgroup-dormant nil
10918 gnus-newsgroup-marked nil
10919 gnus-newsgroup-reads
10921 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10922 gnus-newsgroup-reads))
10923 (while (setq article (pop articles))
10924 (unless (or (memq article gnus-newsgroup-dormant)
10925 (memq article gnus-newsgroup-marked))
10926 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10928 (defun gnus-summary-limit (articles &optional pop)
10930 ;; We pop the previous limit off the stack and use that.
10931 (setq articles (car gnus-newsgroup-limits)
10932 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10933 ;; We use the new limit, so we push the old limit on the stack.
10934 (setq gnus-newsgroup-limits
10935 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10937 (setq gnus-newsgroup-limit articles)
10938 (let ((total (length gnus-newsgroup-data))
10939 (data (gnus-data-find-list (gnus-summary-article-number)))
10940 (gnus-summary-mark-below nil) ; Inhibit this.
10942 ;; This will do all the work of generating the new summary buffer
10943 ;; according to the new limit.
10944 (gnus-summary-prepare)
10945 ;; Hide any threads, possibly.
10946 (and gnus-show-threads
10947 gnus-thread-hide-subtree
10948 (gnus-summary-hide-all-threads))
10949 ;; Try to return to the article you were at, or one in the
10952 ;; We try to find some article after the current one.
10954 (and (gnus-summary-goto-subject
10955 (gnus-data-number (car data)) nil t)
10958 (setq data (cdr data))))
10960 ;; If there is no data, that means that we were after the last
10961 ;; article. The same goes when we can't find any articles
10962 ;; after the current one.
10964 (goto-char (point-max))
10965 (gnus-summary-find-prev)))
10966 ;; We return how many articles were removed from the summary
10967 ;; buffer as a result of the new limit.
10968 (- total (length gnus-newsgroup-data))))
10970 (defsubst gnus-invisible-cut-children (threads)
10973 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10978 (defsubst gnus-cut-thread (thread)
10979 "Go forwards in the thread until we find an article that we want to display."
10980 (when (or (eq gnus-fetch-old-headers 'some)
10981 (eq gnus-build-sparse-threads 'some)
10982 (eq gnus-build-sparse-threads 'more))
10983 ;; Deal with old-fetched headers and sparse threads.
10987 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10988 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10989 (or (<= (length (cdr thread)) 1)
10990 (gnus-invisible-cut-children (cdr thread))))
10991 (setq thread (cadr thread))))
10994 (defun gnus-cut-threads (threads)
10995 "Cut off all uninteresting articles from the beginning of threads."
10996 (when (or (eq gnus-fetch-old-headers 'some)
10997 (eq gnus-build-sparse-threads 'some)
10998 (eq gnus-build-sparse-threads 'more))
10999 (let ((th threads))
11001 (setcar th (gnus-cut-thread (car th)))
11002 (setq th (cdr th)))))
11003 ;; Remove nixed out threads.
11004 (delq nil threads))
11006 (defun gnus-summary-initial-limit (&optional show-if-empty)
11007 "Figure out what the initial limit is supposed to be on group entry.
11008 This entails weeding out unwanted dormants, low-scored articles,
11009 fetch-old-headers verbiage, and so on."
11010 ;; Most groups have nothing to remove.
11011 (if (or gnus-inhibit-limiting
11012 (and (null gnus-newsgroup-dormant)
11013 (not (eq gnus-fetch-old-headers 'some))
11014 (null gnus-summary-expunge-below)
11015 (not (eq gnus-build-sparse-threads 'some))
11016 (not (eq gnus-build-sparse-threads 'more))
11017 (null gnus-thread-expunge-below)
11018 (not gnus-use-nocem)))
11020 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11021 (setq gnus-newsgroup-limit nil)
11024 (unless (car (symbol-value node))
11025 ;; These threads have no parents -- they are roots.
11026 (let ((nodes (cdr (symbol-value node)))
11029 (if (and gnus-thread-expunge-below
11030 (< (gnus-thread-total-score (car nodes))
11031 gnus-thread-expunge-below))
11032 (gnus-expunge-thread (pop nodes))
11033 (setq thread (pop nodes))
11034 (gnus-summary-limit-children thread))))))
11035 gnus-newsgroup-dependencies)
11036 ;; If this limitation resulted in an empty group, we might
11037 ;; pop the previous limit and use it instead.
11038 (when (and (not gnus-newsgroup-limit)
11040 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
11041 gnus-newsgroup-limit))
11043 (defun gnus-summary-limit-children (thread)
11044 "Return 1 if this subthread is visible and 0 if it is not."
11045 ;; First we get the number of visible children to this thread. This
11046 ;; is done by recursing down the thread using this function, so this
11047 ;; will really go down to a leaf article first, before slowly
11048 ;; working its way up towards the root.
11052 (apply '+ (mapcar 'gnus-summary-limit-children
11055 (number (mail-header-number (car thread)))
11058 ;; If this article is dormant and has absolutely no visible
11059 ;; children, then this article isn't visible.
11060 (and (memq number gnus-newsgroup-dormant)
11062 ;; If this is "fetch-old-headered" and there is only one
11063 ;; visible child (or less), then we don't want this article.
11064 (and (eq gnus-fetch-old-headers 'some)
11065 (memq number gnus-newsgroup-ancient)
11067 ;; If this is a sparsely inserted article with no children,
11068 ;; we don't want it.
11069 (and (eq gnus-build-sparse-threads 'some)
11070 (memq number gnus-newsgroup-sparse)
11072 ;; If we use expunging, and this article is really
11073 ;; low-scored, then we don't want this article.
11074 (when (and gnus-summary-expunge-below
11076 (or (cdr (assq number gnus-newsgroup-scored))
11077 gnus-summary-default-score))
11078 gnus-summary-expunge-below))
11079 ;; We increase the expunge-tally here, but that has
11080 ;; nothing to do with the limits, really.
11081 (incf gnus-newsgroup-expunged-tally)
11082 ;; We also mark as read here, if that's wanted.
11083 (when (and gnus-summary-mark-below
11084 (< score gnus-summary-mark-below))
11085 (setq gnus-newsgroup-unreads
11086 (delq number gnus-newsgroup-unreads))
11087 (if gnus-newsgroup-auto-expire
11088 (push number gnus-newsgroup-expirable)
11089 (push (cons number gnus-low-score-mark)
11090 gnus-newsgroup-reads)))
11092 (and gnus-use-nocem
11093 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11094 ;; Nope, invisible article.
11096 ;; Ok, this article is to be visible, so we add it to the limit
11098 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11101 (defun gnus-expunge-thread (thread)
11102 "Mark all articles in THREAD as read."
11103 (let* ((number (mail-header-number (car thread))))
11104 (incf gnus-newsgroup-expunged-tally)
11105 ;; We also mark as read here, if that's wanted.
11106 (setq gnus-newsgroup-unreads
11107 (delq number gnus-newsgroup-unreads))
11108 (if gnus-newsgroup-auto-expire
11109 (push number gnus-newsgroup-expirable)
11110 (push (cons number gnus-low-score-mark)
11111 gnus-newsgroup-reads)))
11112 ;; Go recursively through all subthreads.
11113 (mapcar 'gnus-expunge-thread (cdr thread)))
11115 ;; Summary article oriented commands
11117 (defun gnus-summary-refer-parent-article (n)
11118 "Refer parent article N times.
11119 The difference between N and the number of articles fetched is returned."
11121 (gnus-set-global-variables)
11125 (let* ((header (gnus-summary-article-header))
11127 ;; If we try to find the parent of the currently
11128 ;; displayed article, then we take a look at the actual
11129 ;; References header, since this is slightly more
11130 ;; reliable than the References field we got from the
11132 (if (and (eq (mail-header-number header)
11133 (cdr gnus-article-current))
11134 (equal gnus-newsgroup-name
11135 (car gnus-article-current)))
11137 (set-buffer gnus-original-article-buffer)
11138 (nnheader-narrow-to-headers)
11140 (message-fetch-field "references")
11142 ;; It's not the current article, so we take a bet on
11143 ;; the value we got from the server.
11144 (mail-header-references header))))
11145 (if (setq ref (or ref (mail-header-references header)))
11146 (or (gnus-summary-refer-article (gnus-parent-id ref))
11147 (gnus-message 1 "Couldn't find parent"))
11148 (gnus-message 1 "No references in article %d"
11149 (gnus-summary-article-number))
11152 (gnus-summary-position-point)
11155 (defun gnus-summary-refer-references ()
11156 "Fetch all articles mentioned in the References header.
11157 Return how many articles were fetched."
11159 (gnus-set-global-variables)
11160 (let ((ref (mail-header-references (gnus-summary-article-header)))
11161 (current (gnus-summary-article-number))
11163 ;; For each Message-ID in the References header...
11164 (while (string-match "<[^>]*>" ref)
11166 ;; ... fetch that article.
11167 (gnus-summary-refer-article
11168 (prog1 (match-string 0 ref)
11169 (setq ref (substring ref (match-end 0))))))
11170 (gnus-summary-goto-subject current)
11171 (gnus-summary-position-point)
11174 (defun gnus-summary-refer-article (message-id)
11175 "Fetch an article specified by MESSAGE-ID."
11176 (interactive "sMessage-ID: ")
11177 (when (and (stringp message-id)
11178 (not (zerop (length message-id))))
11179 ;; Construct the correct Message-ID if necessary.
11180 ;; Suggested by tale@pawl.rpi.edu.
11181 (unless (string-match "^<" message-id)
11182 (setq message-id (concat "<" message-id)))
11183 (unless (string-match ">$" message-id)
11184 (setq message-id (concat message-id ">")))
11185 (let* ((header (gnus-id-to-header message-id))
11186 (sparse (and header
11187 (memq (mail-header-number header)
11188 gnus-newsgroup-sparse))))
11191 ;; The article is present in the buffer, to we just go to it.
11192 (gnus-summary-goto-article
11193 (mail-header-number header) nil header)
11195 (gnus-summary-update-article (mail-header-number header))))
11196 ;; We fetch the article
11197 (let ((gnus-override-method
11198 (and (gnus-news-group-p gnus-newsgroup-name)
11199 gnus-refer-article-method))
11201 ;; Start the special refer-article method, if necessary.
11202 (when (and gnus-refer-article-method
11203 (gnus-news-group-p gnus-newsgroup-name))
11204 (gnus-check-server gnus-refer-article-method))
11205 ;; Fetch the header, and display the article.
11206 (if (setq number (gnus-summary-insert-subject message-id))
11207 (gnus-summary-select-article nil nil nil number)
11208 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11210 (defun gnus-summary-enter-digest-group (&optional force)
11211 "Enter a digest group based on the current article."
11213 (gnus-set-global-variables)
11214 (gnus-summary-select-article)
11215 (let ((name (format "%s-%d"
11216 (gnus-group-prefixed-name
11217 gnus-newsgroup-name (list 'nndoc ""))
11218 gnus-current-article))
11219 (ogroup gnus-newsgroup-name)
11220 (case-fold-search t)
11221 (buf (current-buffer))
11224 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11225 (insert-buffer-substring gnus-original-article-buffer)
11227 (goto-char (point-min))
11228 (or (search-forward "\n\n" nil t) (point)))
11229 (goto-char (point-min))
11230 (delete-matching-lines "^\\(Path\\):\\|^From ")
11233 (if (gnus-group-read-ephemeral-group
11234 name `(nndoc ,name (nndoc-address
11236 (nndoc-article-type ,(if force 'digest 'guess))) t)
11237 ;; Make all postings to this group go to the parent group.
11238 (nconc (gnus-info-params (gnus-get-info name))
11239 (list (cons 'to-group ogroup)))
11240 ;; Couldn't select this doc group.
11241 (switch-to-buffer buf)
11242 (gnus-set-global-variables)
11243 (gnus-configure-windows 'summary)
11244 (gnus-message 3 "Article couldn't be entered?"))
11245 (kill-buffer dig))))
11247 (defun gnus-summary-isearch-article (&optional regexp-p)
11248 "Do incremental search forward on the current article.
11249 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11251 (gnus-set-global-variables)
11252 (gnus-summary-select-article)
11253 (gnus-configure-windows 'article)
11254 (gnus-eval-in-buffer-window gnus-article-buffer
11255 (goto-char (point-min))
11256 (isearch-forward regexp-p)))
11258 (defun gnus-summary-search-article-forward (regexp &optional backward)
11259 "Search for an article containing REGEXP forward.
11260 If BACKWARD, search backward instead."
11263 (format "Search article %s (regexp%s): "
11264 (if current-prefix-arg "backward" "forward")
11265 (if gnus-last-search-regexp
11266 (concat ", default " gnus-last-search-regexp)
11268 current-prefix-arg))
11269 (gnus-set-global-variables)
11270 (if (string-equal regexp "")
11271 (setq regexp (or gnus-last-search-regexp ""))
11272 (setq gnus-last-search-regexp regexp))
11273 (unless (gnus-summary-search-article regexp backward)
11274 (error "Search failed: \"%s\"" regexp)))
11276 (defun gnus-summary-search-article-backward (regexp)
11277 "Search for an article containing REGEXP backward."
11280 (format "Search article backward (regexp%s): "
11281 (if gnus-last-search-regexp
11282 (concat ", default " gnus-last-search-regexp)
11284 (gnus-summary-search-article-forward regexp 'backward))
11286 (defun gnus-summary-search-article (regexp &optional backward)
11287 "Search for an article containing REGEXP.
11288 Optional argument BACKWARD means do search for backward.
11289 `gnus-select-article-hook' is not called during the search."
11290 (let ((gnus-select-article-hook nil) ;Disable hook.
11291 (gnus-article-display-hook nil)
11292 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11295 're-search-backward 're-search-forward))
11296 (sum (current-buffer))
11298 (gnus-save-hidden-threads
11299 (gnus-summary-select-article)
11300 (set-buffer gnus-article-buffer)
11304 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11306 (re-search-backward regexp nil t)
11307 (re-search-forward regexp nil t))
11308 ;; We found the regexp.
11310 (setq found 'found)
11311 (beginning-of-line)
11313 (get-buffer-window (current-buffer))
11317 ;; We didn't find it, so we go to the next article.
11319 (if (not (if backward (gnus-summary-find-prev)
11320 (gnus-summary-find-next)))
11321 ;; No more articles.
11323 ;; Select the next article and adjust point.
11324 (gnus-summary-select-article)
11325 (set-buffer gnus-article-buffer)
11327 (goto-char (if backward (point-max) (point-min))))))
11328 (gnus-message 7 ""))
11329 ;; Return whether we found the regexp.
11330 (when (eq found 'found)
11331 (gnus-summary-show-thread)
11332 (gnus-summary-goto-subject gnus-current-article)
11333 (gnus-summary-position-point)
11336 (defun gnus-summary-find-matching (header regexp &optional backward unread
11338 "Return a list of all articles that match REGEXP on HEADER.
11339 The search stars on the current article and goes forwards unless
11340 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11341 If UNREAD is non-nil, only unread articles will
11342 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11343 in the comparisons."
11344 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11345 (gnus-data-find-list
11346 (gnus-summary-article-number) (gnus-data-list backward))))
11347 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11348 (case-fold-search (not not-case-fold))
11350 (or (fboundp (intern (concat "mail-header-" header)))
11351 (error "%s is not a valid header" header))
11353 (setq d (car data))
11354 (and (or (not unread) ; We want all articles...
11355 (gnus-data-unread-p d)) ; Or just unreads.
11356 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11357 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11358 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11359 (setq data (cdr data)))
11360 (nreverse articles)))
11362 (defun gnus-summary-execute-command (header regexp command &optional backward)
11363 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11364 If HEADER is an empty string (or nil), the match is done on the entire
11365 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11367 (list (let ((completion-ignore-case t))
11370 (mapcar (lambda (string) (list string))
11371 '("Number" "Subject" "From" "Lines" "Date"
11372 "Message-ID" "Xref" "References" "Body"))
11373 nil 'require-match))
11374 (read-string "Regexp: ")
11375 (read-key-sequence "Command: ")
11376 current-prefix-arg))
11377 (when (equal header "Body")
11379 (gnus-set-global-variables)
11380 ;; Hidden thread subtrees must be searched as well.
11381 (gnus-summary-show-all-threads)
11382 ;; We don't want to change current point nor window configuration.
11384 (save-window-excursion
11385 (gnus-message 6 "Executing %s..." (key-description command))
11386 ;; We'd like to execute COMMAND interactively so as to give arguments.
11387 (gnus-execute header regexp
11388 `(lambda () (call-interactively ',(key-binding command)))
11390 (gnus-message 6 "Executing %s...done" (key-description command)))))
11392 (defun gnus-summary-beginning-of-article ()
11393 "Scroll the article back to the beginning."
11395 (gnus-set-global-variables)
11396 (gnus-summary-select-article)
11397 (gnus-configure-windows 'article)
11398 (gnus-eval-in-buffer-window gnus-article-buffer
11400 (goto-char (point-min))
11401 (and gnus-break-pages (gnus-narrow-to-page))))
11403 (defun gnus-summary-end-of-article ()
11404 "Scroll to the end of the article."
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-max))
11413 (and gnus-break-pages (gnus-narrow-to-page))))
11415 (defun gnus-summary-show-article (&optional arg)
11416 "Force re-fetching of the current article.
11417 If ARG (the prefix) is non-nil, show the raw article without any
11418 article massaging functions being run."
11420 (gnus-set-global-variables)
11422 ;; Select the article the normal way.
11423 (gnus-summary-select-article nil 'force)
11424 ;; Bind the article treatment functions to nil.
11425 (let ((gnus-have-all-headers t)
11426 gnus-article-display-hook
11427 gnus-article-prepare-hook
11430 (gnus-summary-select-article nil 'force)))
11431 (gnus-summary-goto-subject gnus-current-article)
11432 ; (gnus-configure-windows 'article)
11433 (gnus-summary-position-point))
11435 (defun gnus-summary-verbose-headers (&optional arg)
11436 "Toggle permanent full header display.
11437 If ARG is a positive number, turn header display on.
11438 If ARG is a negative number, turn header display off."
11440 (gnus-set-global-variables)
11441 (gnus-summary-toggle-header arg)
11442 (setq gnus-show-all-headers
11443 (cond ((or (not (numberp arg))
11445 (not gnus-show-all-headers))
11449 (defun gnus-summary-toggle-header (&optional arg)
11450 "Show the headers if they are hidden, or hide them if they are shown.
11451 If ARG is a positive number, show the entire header.
11452 If ARG is a negative number, hide the unwanted header lines."
11454 (gnus-set-global-variables)
11456 (set-buffer gnus-article-buffer)
11457 (let* ((buffer-read-only nil)
11458 (inhibit-point-motion-hooks t)
11459 (hidden (text-property-any
11460 (goto-char (point-min)) (search-forward "\n\n")
11463 (goto-char (point-min))
11464 (when (search-forward "\n\n" nil t)
11465 (delete-region (point-min) (1- (point))))
11466 (goto-char (point-min))
11468 (set-buffer gnus-original-article-buffer)
11469 (goto-char (point-min))
11470 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11471 (insert-buffer-substring gnus-original-article-buffer 1 e)
11472 (let ((gnus-inhibit-hiding t))
11473 (run-hooks 'gnus-article-display-hook))
11474 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11475 (gnus-article-hide-headers)))))
11477 (defun gnus-summary-show-all-headers ()
11478 "Make all header lines visible."
11480 (gnus-set-global-variables)
11481 (gnus-article-show-all-headers))
11483 (defun gnus-summary-toggle-mime (&optional arg)
11484 "Toggle MIME processing.
11485 If ARG is a positive number, turn MIME processing on."
11487 (gnus-set-global-variables)
11488 (setq gnus-show-mime
11489 (if (null arg) (not gnus-show-mime)
11490 (> (prefix-numeric-value arg) 0)))
11491 (gnus-summary-select-article t 'force))
11493 (defun gnus-summary-caesar-message (&optional arg)
11494 "Caesar rotate the current article by 13.
11495 The numerical prefix specifies how manu places to rotate each letter
11498 (gnus-set-global-variables)
11499 (gnus-summary-select-article)
11500 (let ((mail-header-separator ""))
11501 (gnus-eval-in-buffer-window gnus-article-buffer
11504 (let ((start (window-start))
11506 (message-caesar-buffer-body arg)
11507 (set-window-start (get-buffer-window (current-buffer)) start))))))
11509 (defun gnus-summary-stop-page-breaking ()
11510 "Stop page breaking in the current article."
11512 (gnus-set-global-variables)
11513 (gnus-summary-select-article)
11514 (gnus-eval-in-buffer-window gnus-article-buffer
11517 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11518 "Move the current article to a different newsgroup.
11519 If N is a positive number, move the N next articles.
11520 If N is a negative number, move the N previous articles.
11521 If N is nil and any articles have been marked with the process mark,
11522 move those articles instead.
11523 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11524 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11525 re-spool using this method.
11527 For this function to work, both the current newsgroup and the
11528 newsgroup that you want to move to have to support the `request-move'
11529 and `request-accept' functions."
11531 (unless action (setq action 'move))
11532 (gnus-set-global-variables)
11533 ;; Check whether the source group supports the required functions.
11534 (cond ((and (eq action 'move)
11535 (not (gnus-check-backend-function
11536 'request-move-article gnus-newsgroup-name)))
11537 (error "The current group does not support article moving"))
11538 ((and (eq action 'crosspost)
11539 (not (gnus-check-backend-function
11540 'request-replace-article gnus-newsgroup-name)))
11541 (error "The current group does not support article editing")))
11542 (let ((articles (gnus-summary-work-articles n))
11543 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11544 (names '((move "Move" "Moving")
11545 (copy "Copy" "Copying")
11546 (crosspost "Crosspost" "Crossposting")))
11547 (copy-buf (save-excursion
11548 (nnheader-set-temp-buffer " *copy article*")))
11549 art-group to-method new-xref article to-groups)
11550 (unless (assq action names)
11551 (error "Unknown action %s" action))
11552 ;; Read the newsgroup name.
11553 (when (and (not to-newsgroup)
11554 (not select-method))
11556 (gnus-read-move-group-name
11557 (cadr (assq action names))
11558 (symbol-value (intern (format "gnus-current-%s-group" action)))
11560 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11561 (setq to-method (or select-method
11562 (gnus-group-name-to-method to-newsgroup)))
11563 ;; Check the method we are to move this article to...
11564 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11565 (error "%s does not support article copying" (car to-method)))
11566 (or (gnus-check-server to-method)
11567 (error "Can't open server %s" (car to-method)))
11568 (gnus-message 6 "%s to %s: %s..."
11569 (caddr (assq action names))
11570 (or (car select-method) to-newsgroup) articles)
11572 (setq article (pop articles))
11576 ;; Move the article.
11578 (gnus-request-move-article
11579 article ; Article to move
11580 gnus-newsgroup-name ; From newsgrouo
11581 (nth 1 (gnus-find-method-for-group
11582 gnus-newsgroup-name)) ; Server
11583 (list 'gnus-request-accept-article
11584 to-newsgroup (list 'quote select-method)
11585 (not articles)) ; Accept form
11586 (not articles))) ; Only save nov last time
11587 ;; Copy the article.
11590 (set-buffer copy-buf)
11591 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11592 (gnus-request-accept-article
11593 to-newsgroup select-method (not articles))))
11594 ;; Crosspost the article.
11595 ((eq action 'crosspost)
11596 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11597 (setq new-xref (concat gnus-newsgroup-name ":" article))
11598 (if (and xref (not (string= xref "")))
11600 (when (string-match "^Xref: " xref)
11601 (setq xref (substring xref (match-end 0))))
11602 (setq new-xref (concat xref " " new-xref)))
11603 (setq new-xref (concat (system-name) " " new-xref)))
11605 (set-buffer copy-buf)
11606 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11607 (nnheader-replace-header "xref" new-xref)
11608 (gnus-request-accept-article
11609 to-newsgroup select-method (not articles)))))))
11610 (if (not art-group)
11611 (gnus-message 1 "Couldn't %s article %s"
11612 (cadr (assq action names)) article)
11615 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11617 (gnus-group-prefixed-name
11620 (gnus-find-method-for-group to-newsgroup)))
11621 gnus-newsrc-hashtb)))
11622 (info (nth 2 entry))
11623 (to-group (gnus-info-group info)))
11624 ;; Update the group that has been moved to.
11626 (memq action '(move copy)))
11627 (unless (member to-group to-groups)
11628 (push to-group to-groups))
11630 (unless (memq article gnus-newsgroup-unreads)
11631 (gnus-info-set-read
11632 info (gnus-add-to-range (gnus-info-read info)
11633 (list (cdr art-group)))))
11635 ;; Copy any marks over to the new group.
11636 (let ((marks gnus-article-mark-lists)
11637 (to-article (cdr art-group)))
11639 ;; See whether the article is to be put in the cache.
11640 (when gnus-use-cache
11641 (gnus-cache-possibly-enter-article
11642 to-group to-article
11643 (let ((header (copy-sequence
11644 (gnus-summary-article-header article))))
11645 (mail-header-set-number header to-article)
11647 (memq article gnus-newsgroup-marked)
11648 (memq article gnus-newsgroup-dormant)
11649 (memq article gnus-newsgroup-unreads)))
11652 (when (memq article (symbol-value
11653 (intern (format "gnus-newsgroup-%s"
11655 ;; If the other group is the same as this group,
11656 ;; then we have to add the mark to the list.
11657 (when (equal to-group gnus-newsgroup-name)
11658 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11661 (intern (format "gnus-newsgroup-%s"
11663 ;; Copy mark to other group.
11664 (gnus-add-marked-articles
11665 to-group (cdar marks) (list to-article) info))
11666 (setq marks (cdr marks)))))
11668 ;; Update the Xref header in this article to point to
11669 ;; the new crossposted article we have just created.
11670 (when (eq action 'crosspost)
11672 (set-buffer copy-buf)
11673 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11674 (nnheader-replace-header
11675 "xref" (concat new-xref " " (gnus-group-prefixed-name
11676 (car art-group) to-method)
11677 ":" (cdr art-group)))
11678 (gnus-request-replace-article
11679 article gnus-newsgroup-name (current-buffer)))))
11681 (gnus-summary-goto-subject article)
11682 (when (eq action 'move)
11683 (gnus-summary-mark-article article gnus-canceled-mark)))
11684 (gnus-summary-remove-process-mark article))
11685 ;; Re-activate all groups that have been moved to.
11687 (gnus-activate-group (pop to-groups)))
11689 (gnus-kill-buffer copy-buf)
11690 (gnus-summary-position-point)
11691 (gnus-set-mode-line 'summary)))
11693 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11694 "Move the current article to a different newsgroup.
11695 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11696 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11697 re-spool using this method."
11699 (gnus-summary-move-article n nil select-method 'copy))
11701 (defun gnus-summary-crosspost-article (&optional n)
11702 "Crosspost the current article to some other group."
11704 (gnus-summary-move-article n nil nil 'crosspost))
11706 (defvar gnus-summary-respool-default-method nil
11707 "Default method for respooling an article.
11708 If nil, use to the current newsgroup method.")
11710 (defun gnus-summary-respool-article (&optional n method)
11711 "Respool the current article.
11712 The article will be squeezed through the mail spooling process again,
11713 which means that it will be put in some mail newsgroup or other
11714 depending on `nnmail-split-methods'.
11715 If N is a positive number, respool the N next articles.
11716 If N is a negative number, respool the N previous articles.
11717 If N is nil and any articles have been marked with the process mark,
11718 respool those articles instead.
11720 Respooling can be done both from mail groups and \"real\" newsgroups.
11721 In the former case, the articles in question will be moved from the
11722 current group into whatever groups they are destined to. In the
11723 latter case, they will be copied into the relevant groups."
11725 (list current-prefix-arg
11726 (let* ((methods (gnus-methods-using 'respool))
11728 (symbol-name (or gnus-summary-respool-default-method
11729 (car (gnus-find-method-for-group
11730 gnus-newsgroup-name)))))
11732 (gnus-completing-read
11733 methname "What backend do you want to use when respooling?"
11734 methods nil t nil 'gnus-method-history))
11737 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11738 (list (intern method) ""))
11742 (cdr (completing-read
11744 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11745 (gnus-set-global-variables)
11747 (error "No method given for respooling"))
11748 (if (assoc (symbol-name
11749 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11750 (gnus-methods-using 'respool))
11751 (gnus-summary-move-article n nil method)
11752 (gnus-summary-copy-article n nil method)))
11754 (defun gnus-summary-import-article (file)
11755 "Import a random file into a mail newsgroup."
11756 (interactive "fImport file: ")
11757 (gnus-set-global-variables)
11758 (let ((group gnus-newsgroup-name)
11759 (now (current-time))
11761 (or (gnus-check-backend-function 'request-accept-article group)
11762 (error "%s does not support article importing" group))
11763 (or (file-readable-p file)
11764 (not (file-regular-p file))
11765 (error "Can't read %s" file))
11767 (set-buffer (get-buffer-create " *import file*"))
11768 (buffer-disable-undo (current-buffer))
11770 (insert-file-contents file)
11771 (goto-char (point-min))
11772 (unless (nnheader-article-p)
11773 ;; This doesn't look like an article, so we fudge some headers.
11774 (setq atts (file-attributes file)
11775 lines (count-lines (point-min) (point-max)))
11776 (insert "From: " (read-string "From: ") "\n"
11777 "Subject: " (read-string "Subject: ") "\n"
11778 "Date: " (timezone-make-date-arpa-standard
11779 (current-time-string (nth 5 atts))
11780 (current-time-zone now)
11781 (current-time-zone now)) "\n"
11782 "Message-ID: " (message-make-message-id) "\n"
11783 "Lines: " (int-to-string lines) "\n"
11784 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11785 (gnus-request-accept-article group nil t)
11786 (kill-buffer (current-buffer)))))
11788 (defun gnus-summary-expire-articles (&optional now)
11789 "Expire all articles that are marked as expirable in the current group."
11791 (gnus-set-global-variables)
11792 (when (gnus-check-backend-function
11793 'request-expire-articles gnus-newsgroup-name)
11794 ;; This backend supports expiry.
11795 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11796 (expirable (if total
11797 (gnus-list-of-read-articles gnus-newsgroup-name)
11798 (setq gnus-newsgroup-expirable
11799 (sort gnus-newsgroup-expirable '<))))
11800 (expiry-wait (if now 'immediate
11801 (gnus-group-get-parameter
11802 gnus-newsgroup-name 'expiry-wait)))
11805 ;; There are expirable articles in this group, so we run them
11806 ;; through the expiry process.
11807 (gnus-message 6 "Expiring articles...")
11808 ;; The list of articles that weren't expired is returned.
11810 (let ((nnmail-expiry-wait-function nil)
11811 (nnmail-expiry-wait expiry-wait))
11812 (setq es (gnus-request-expire-articles
11813 expirable gnus-newsgroup-name)))
11814 (setq es (gnus-request-expire-articles
11815 expirable gnus-newsgroup-name)))
11816 (or total (setq gnus-newsgroup-expirable es))
11817 ;; We go through the old list of expirable, and mark all
11818 ;; really expired articles as nonexistent.
11819 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11820 (let ((gnus-use-cache nil))
11822 (unless (memq (car expirable) es)
11823 (when (gnus-data-find (car expirable))
11824 (gnus-summary-mark-article
11825 (car expirable) gnus-canceled-mark)))
11826 (setq expirable (cdr expirable)))))
11827 (gnus-message 6 "Expiring articles...done")))))
11829 (defun gnus-summary-expire-articles-now ()
11830 "Expunge all expirable articles in the current group.
11831 This means that *all* articles that are marked as expirable will be
11832 deleted forever, right now."
11834 (gnus-set-global-variables)
11835 (or gnus-expert-user
11837 "Are you really, really, really sure you want to delete all these messages? ")
11839 (gnus-summary-expire-articles t))
11841 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11842 (defun gnus-summary-delete-article (&optional n)
11843 "Delete the N next (mail) articles.
11844 This command actually deletes articles. This is not a marking
11845 command. The article will disappear forever from your life, never to
11847 If N is negative, delete backwards.
11848 If N is nil and articles have been marked with the process mark,
11849 delete these instead."
11851 (gnus-set-global-variables)
11852 (or (gnus-check-backend-function 'request-expire-articles
11853 gnus-newsgroup-name)
11854 (error "The current newsgroup does not support article deletion."))
11855 ;; Compute the list of articles to delete.
11856 (let ((articles (gnus-summary-work-articles n))
11858 (if (and gnus-novice-user
11859 (not (gnus-y-or-n-p
11860 (format "Do you really want to delete %s forever? "
11861 (if (> (length articles) 1)
11862 (format "these %s articles" (length articles))
11863 "this article")))))
11865 ;; Delete the articles.
11866 (setq not-deleted (gnus-request-expire-articles
11867 articles gnus-newsgroup-name 'force))
11869 (gnus-summary-remove-process-mark (car articles))
11870 ;; The backend might not have been able to delete the article
11872 (or (memq (car articles) not-deleted)
11873 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11874 (setq articles (cdr articles))))
11875 (gnus-summary-position-point)
11876 (gnus-set-mode-line 'summary)
11879 (defun gnus-summary-edit-article (&optional force)
11880 "Enter into a buffer and edit the current article.
11881 This will have permanent effect only in mail groups.
11882 If FORCE is non-nil, allow editing of articles even in read-only
11886 (set-buffer gnus-summary-buffer)
11887 (gnus-set-global-variables)
11888 (when (and (not force)
11889 (gnus-group-read-only-p))
11890 (error "The current newsgroup does not support article editing."))
11891 (gnus-summary-select-article t nil t)
11892 (gnus-configure-windows 'article)
11893 (select-window (get-buffer-window gnus-article-buffer))
11894 (gnus-message 6 "C-c C-c to end edits")
11895 (setq buffer-read-only nil)
11897 (use-local-map (copy-keymap (current-local-map)))
11898 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11899 (buffer-enable-undo)
11901 (goto-char (point-min))
11902 (search-forward "\n\n" nil t)))
11904 (defun gnus-summary-edit-article-done ()
11905 "Make edits to the current article permanent."
11907 (if (gnus-group-read-only-p)
11909 (let ((beep (not (eq major-mode 'text-mode))))
11910 (gnus-summary-edit-article-postpone)
11913 3 "The current newsgroup does not support article editing."))))
11914 (let ((buf (format "%s" (buffer-string))))
11917 (if (not (gnus-request-replace-article
11918 (cdr gnus-article-current) (car gnus-article-current)
11920 (error "Couldn't replace article.")
11921 (gnus-article-mode)
11922 (use-local-map gnus-article-mode-map)
11923 (setq buffer-read-only t)
11924 (buffer-disable-undo (current-buffer))
11925 (gnus-configure-windows 'summary)
11926 (gnus-summary-update-article (cdr gnus-article-current))
11927 (when gnus-use-cache
11928 (gnus-cache-update-article
11929 (car gnus-article-current) (cdr gnus-article-current)))
11930 (when gnus-keep-backlog
11931 (gnus-backlog-remove-article
11932 (car gnus-article-current) (cdr gnus-article-current))))
11934 (when (get-buffer gnus-original-article-buffer)
11935 (set-buffer gnus-original-article-buffer)
11936 (setq gnus-original-article nil)))
11937 (setq gnus-article-current nil
11938 gnus-current-article nil)
11939 (run-hooks 'gnus-article-display-hook)
11940 (and (gnus-visual-p 'summary-highlight 'highlight)
11941 (run-hooks 'gnus-visual-mark-article-hook)))))
11943 (defun gnus-summary-edit-article-postpone ()
11944 "Postpone changes to the current article."
11946 (gnus-article-mode)
11947 (use-local-map gnus-article-mode-map)
11948 (setq buffer-read-only t)
11949 (buffer-disable-undo (current-buffer))
11950 (gnus-configure-windows 'summary)
11951 (and (gnus-visual-p 'summary-highlight 'highlight)
11952 (run-hooks 'gnus-visual-mark-article-hook)))
11954 (defun gnus-summary-respool-query ()
11955 "Query where the respool algorithm would put this article."
11957 (gnus-set-global-variables)
11958 (gnus-summary-select-article)
11960 (set-buffer gnus-article-buffer)
11962 (goto-char (point-min))
11963 (search-forward "\n\n")
11964 (narrow-to-region (point-min) (point))
11965 (pp-eval-expression
11966 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11968 ;; Summary marking commands.
11970 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11971 "Mark articles which has the same subject as read, and then select the next.
11972 If UNMARK is positive, remove any kind of mark.
11973 If UNMARK is negative, tick articles."
11975 (gnus-set-global-variables)
11977 (setq unmark (prefix-numeric-value unmark)))
11979 (gnus-summary-mark-same-subject
11980 (gnus-summary-article-subject) unmark)))
11981 ;; Select next unread article. If auto-select-same mode, should
11982 ;; select the first unread article.
11983 (gnus-summary-next-article t (and gnus-auto-select-same
11984 (gnus-summary-article-subject)))
11985 (gnus-message 7 "%d article%s marked as %s"
11986 count (if (= count 1) " is" "s are")
11987 (if unmark "unread" "read"))))
11989 (defun gnus-summary-kill-same-subject (&optional unmark)
11990 "Mark articles which has the same subject as read.
11991 If UNMARK is positive, remove any kind of mark.
11992 If UNMARK is negative, tick articles."
11994 (gnus-set-global-variables)
11996 (setq unmark (prefix-numeric-value unmark)))
11998 (gnus-summary-mark-same-subject
11999 (gnus-summary-article-subject) unmark)))
12000 ;; If marked as read, go to next unread subject.
12002 ;; Go to next unread subject.
12003 (gnus-summary-next-subject 1 t))
12004 (gnus-message 7 "%d articles are marked as %s"
12005 count (if unmark "unread" "read"))))
12007 (defun gnus-summary-mark-same-subject (subject &optional unmark)
12008 "Mark articles with same SUBJECT as read, and return marked number.
12009 If optional argument UNMARK is positive, remove any kinds of marks.
12010 If optional argument UNMARK is negative, mark articles as unread instead."
12014 ((null unmark) ; Mark as read.
12017 (gnus-summary-mark-article-as-read gnus-killed-mark)
12018 (gnus-summary-show-thread) t)
12019 (gnus-summary-find-subject subject))
12020 (setq count (1+ count))))
12021 ((> unmark 0) ; Tick.
12024 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
12025 (gnus-summary-show-thread) t)
12026 (gnus-summary-find-subject subject))
12027 (setq count (1+ count))))
12028 (t ; Mark as unread.
12031 (gnus-summary-mark-article-as-unread gnus-unread-mark)
12032 (gnus-summary-show-thread) t)
12033 (gnus-summary-find-subject subject))
12034 (setq count (1+ count)))))
12035 (gnus-set-mode-line 'summary)
12036 ;; Return the number of marked articles.
12039 (defun gnus-summary-mark-as-processable (n &optional unmark)
12040 "Set the process mark on the next N articles.
12041 If N is negative, mark backward instead. If UNMARK is non-nil, remove
12042 the process mark instead. The difference between N and the actual
12043 number of articles marked is returned."
12045 (gnus-set-global-variables)
12046 (let ((backward (< n 0))
12051 (gnus-summary-remove-process-mark
12052 (gnus-summary-article-number))
12053 (gnus-summary-set-process-mark (gnus-summary-article-number)))
12054 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
12056 (if (/= 0 n) (gnus-message 7 "No more articles"))
12057 (gnus-summary-recenter)
12058 (gnus-summary-position-point)
12061 (defun gnus-summary-unmark-as-processable (n)
12062 "Remove the process mark from the next N articles.
12063 If N is negative, mark backward instead. The difference between N and
12064 the actual number of articles marked is returned."
12066 (gnus-set-global-variables)
12067 (gnus-summary-mark-as-processable n t))
12069 (defun gnus-summary-unmark-all-processable ()
12070 "Remove the process mark from all articles."
12072 (gnus-set-global-variables)
12074 (while gnus-newsgroup-processable
12075 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12076 (gnus-summary-position-point))
12078 (defun gnus-summary-mark-as-expirable (n)
12079 "Mark N articles forward as expirable.
12080 If N is negative, mark backward instead. The difference between N and
12081 the actual number of articles marked is returned."
12083 (gnus-set-global-variables)
12084 (gnus-summary-mark-forward n gnus-expirable-mark))
12086 (defun gnus-summary-mark-article-as-replied (article)
12087 "Mark ARTICLE replied and update the summary line."
12088 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12089 (let ((buffer-read-only nil))
12090 (when (gnus-summary-goto-subject article)
12091 (gnus-summary-update-secondary-mark article))))
12093 (defun gnus-summary-set-bookmark (article)
12094 "Set a bookmark in current article."
12095 (interactive (list (gnus-summary-article-number)))
12096 (gnus-set-global-variables)
12097 (if (or (not (get-buffer gnus-article-buffer))
12098 (not gnus-current-article)
12099 (not gnus-article-current)
12100 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12101 (error "No current article selected"))
12102 ;; Remove old bookmark, if one exists.
12103 (let ((old (assq article gnus-newsgroup-bookmarks)))
12104 (if old (setq gnus-newsgroup-bookmarks
12105 (delq old gnus-newsgroup-bookmarks))))
12106 ;; Set the new bookmark, which is on the form
12107 ;; (article-number . line-number-in-body).
12108 (setq gnus-newsgroup-bookmarks
12112 (set-buffer gnus-article-buffer)
12116 (goto-char (point-min))
12117 (search-forward "\n\n" nil t)
12120 gnus-newsgroup-bookmarks))
12121 (gnus-message 6 "A bookmark has been added to the current article."))
12123 (defun gnus-summary-remove-bookmark (article)
12124 "Remove the bookmark from the current article."
12125 (interactive (list (gnus-summary-article-number)))
12126 (gnus-set-global-variables)
12127 ;; Remove old bookmark, if one exists.
12128 (let ((old (assq article gnus-newsgroup-bookmarks)))
12131 (setq gnus-newsgroup-bookmarks
12132 (delq old gnus-newsgroup-bookmarks))
12133 (gnus-message 6 "Removed bookmark."))
12134 (gnus-message 6 "No bookmark in current article."))))
12136 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12137 (defun gnus-summary-mark-as-dormant (n)
12138 "Mark N articles forward as dormant.
12139 If N is negative, mark backward instead. The difference between N and
12140 the actual number of articles marked is returned."
12142 (gnus-set-global-variables)
12143 (gnus-summary-mark-forward n gnus-dormant-mark))
12145 (defun gnus-summary-set-process-mark (article)
12146 "Set the process mark on ARTICLE and update the summary line."
12147 (setq gnus-newsgroup-processable
12149 (delq article gnus-newsgroup-processable)))
12150 (when (gnus-summary-goto-subject article)
12151 (gnus-summary-show-thread)
12152 (gnus-summary-update-secondary-mark article)))
12154 (defun gnus-summary-remove-process-mark (article)
12155 "Remove the process mark from ARTICLE and update the summary line."
12156 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12157 (when (gnus-summary-goto-subject article)
12158 (gnus-summary-show-thread)
12159 (gnus-summary-update-secondary-mark article)))
12161 (defun gnus-summary-set-saved-mark (article)
12162 "Set the process mark on ARTICLE and update the summary line."
12163 (push article gnus-newsgroup-saved)
12164 (when (gnus-summary-goto-subject article)
12165 (gnus-summary-update-secondary-mark article)))
12167 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12168 "Mark N articles as read forwards.
12169 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12170 The difference between N and the actual number of articles marked is
12173 (gnus-set-global-variables)
12174 (let ((backward (< n 0))
12175 (gnus-summary-goto-unread
12176 (and gnus-summary-goto-unread
12177 (not (eq gnus-summary-goto-unread 'never))
12178 (not (memq mark (list gnus-unread-mark
12179 gnus-ticked-mark gnus-dormant-mark)))))
12181 (mark (or mark gnus-del-mark)))
12182 (while (and (> n 0)
12183 (gnus-summary-mark-article nil mark no-expire)
12184 (zerop (gnus-summary-next-subject
12186 (and gnus-summary-goto-unread
12187 (not (eq gnus-summary-goto-unread 'never)))
12190 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12191 (gnus-summary-recenter)
12192 (gnus-summary-position-point)
12193 (gnus-set-mode-line 'summary)
12196 (defun gnus-summary-mark-article-as-read (mark)
12197 "Mark the current article quickly as read with MARK."
12198 (let ((article (gnus-summary-article-number)))
12199 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12200 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12201 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12202 (setq gnus-newsgroup-reads
12203 (cons (cons article mark) gnus-newsgroup-reads))
12204 ;; Possibly remove from cache, if that is used.
12205 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12206 ;; Allow the backend to change the mark.
12207 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12208 ;; Check for auto-expiry.
12209 (when (and gnus-newsgroup-auto-expire
12210 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12211 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12212 (= mark gnus-ancient-mark)
12213 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12214 (setq mark gnus-expirable-mark)
12215 (push article gnus-newsgroup-expirable))
12216 ;; Set the mark in the buffer.
12217 (gnus-summary-update-mark mark 'unread)
12220 (defun gnus-summary-mark-article-as-unread (mark)
12221 "Mark the current article quickly as unread with MARK."
12222 (let ((article (gnus-summary-article-number)))
12224 (gnus-error 1 "Unmarkable article")
12225 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12226 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12227 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12228 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12229 (cond ((= mark gnus-ticked-mark)
12230 (push article gnus-newsgroup-marked))
12231 ((= mark gnus-dormant-mark)
12232 (push article gnus-newsgroup-dormant))
12234 (push article gnus-newsgroup-unreads)))
12235 (setq gnus-newsgroup-reads
12236 (delq (assq article gnus-newsgroup-reads)
12237 gnus-newsgroup-reads))
12239 ;; See whether the article is to be put in the cache.
12240 (and gnus-use-cache
12241 (vectorp (gnus-summary-article-header article))
12243 (gnus-cache-possibly-enter-article
12244 gnus-newsgroup-name article
12245 (gnus-summary-article-header article)
12246 (= mark gnus-ticked-mark)
12247 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12250 (gnus-summary-update-mark mark 'unread))
12253 (defun gnus-summary-mark-article (&optional article mark no-expire)
12254 "Mark ARTICLE with MARK. MARK can be any character.
12255 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12256 `??' (dormant) and `?E' (expirable).
12257 If MARK is nil, then the default character `?D' is used.
12258 If ARTICLE is nil, then the article on the current line will be
12260 ;; The mark might be a string.
12261 (and (stringp mark)
12262 (setq mark (aref mark 0)))
12263 ;; If no mark is given, then we check auto-expiring.
12264 (and (not no-expire)
12265 gnus-newsgroup-auto-expire
12267 (and (numberp mark)
12268 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12269 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12270 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12271 (setq mark gnus-expirable-mark))
12272 (let* ((mark (or mark gnus-del-mark))
12273 (article (or article (gnus-summary-article-number))))
12274 (or article (error "No article on current line"))
12275 (if (or (= mark gnus-unread-mark)
12276 (= mark gnus-ticked-mark)
12277 (= mark gnus-dormant-mark))
12278 (gnus-mark-article-as-unread article mark)
12279 (gnus-mark-article-as-read article mark))
12281 ;; See whether the article is to be put in the cache.
12282 (and gnus-use-cache
12283 (not (= mark gnus-canceled-mark))
12284 (vectorp (gnus-summary-article-header article))
12286 (gnus-cache-possibly-enter-article
12287 gnus-newsgroup-name article
12288 (gnus-summary-article-header article)
12289 (= mark gnus-ticked-mark)
12290 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12292 (if (gnus-summary-goto-subject article nil t)
12293 (let ((buffer-read-only nil))
12294 (gnus-summary-show-thread)
12296 (gnus-summary-update-mark mark 'unread)
12299 (defun gnus-summary-update-secondary-mark (article)
12300 "Update the secondary (read, process, cache) mark."
12301 (gnus-summary-update-mark
12302 (cond ((memq article gnus-newsgroup-processable)
12304 ((memq article gnus-newsgroup-cached)
12306 ((memq article gnus-newsgroup-replied)
12308 ((memq article gnus-newsgroup-saved)
12310 (t gnus-unread-mark))
12312 (when (gnus-visual-p 'summary-highlight 'highlight)
12313 (run-hooks 'gnus-summary-update-hook))
12316 (defun gnus-summary-update-mark (mark type)
12317 (beginning-of-line)
12318 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12319 (buffer-read-only nil))
12321 (<= (+ forward (point)) (point-max)))
12322 ;; Go to the right position on the line.
12323 (goto-char (+ forward (point)))
12324 ;; Replace the old mark with the new mark.
12325 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12326 ;; Optionally update the marks by some user rule.
12327 (when (eq type 'unread)
12328 (gnus-data-set-mark
12329 (gnus-data-find (gnus-summary-article-number)) mark)
12330 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12332 (defun gnus-mark-article-as-read (article &optional mark)
12333 "Enter ARTICLE in the pertinent lists and remove it from others."
12334 ;; Make the article expirable.
12335 (let ((mark (or mark gnus-del-mark)))
12336 (if (= mark gnus-expirable-mark)
12337 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12338 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12339 ;; Remove from unread and marked lists.
12340 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12341 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12342 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12343 (push (cons article mark) gnus-newsgroup-reads)
12344 ;; Possibly remove from cache, if that is used.
12345 (when gnus-use-cache
12346 (gnus-cache-enter-remove-article article))))
12348 (defun gnus-mark-article-as-unread (article &optional mark)
12349 "Enter ARTICLE in the pertinent lists and remove it from others."
12350 (let ((mark (or mark gnus-ticked-mark)))
12351 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12352 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12353 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12354 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12355 (cond ((= mark gnus-ticked-mark)
12356 (push article gnus-newsgroup-marked))
12357 ((= mark gnus-dormant-mark)
12358 (push article gnus-newsgroup-dormant))
12360 (push article gnus-newsgroup-unreads)))
12361 (setq gnus-newsgroup-reads
12362 (delq (assq article gnus-newsgroup-reads)
12363 gnus-newsgroup-reads))))
12365 (defalias 'gnus-summary-mark-as-unread-forward
12366 'gnus-summary-tick-article-forward)
12367 (make-obsolete 'gnus-summary-mark-as-unread-forward
12368 'gnus-summary-tick-article-forward)
12369 (defun gnus-summary-tick-article-forward (n)
12370 "Tick N articles forwards.
12371 If N is negative, tick backwards instead.
12372 The difference between N and the number of articles ticked is returned."
12374 (gnus-summary-mark-forward n gnus-ticked-mark))
12376 (defalias 'gnus-summary-mark-as-unread-backward
12377 'gnus-summary-tick-article-backward)
12378 (make-obsolete 'gnus-summary-mark-as-unread-backward
12379 'gnus-summary-tick-article-backward)
12380 (defun gnus-summary-tick-article-backward (n)
12381 "Tick N articles backwards.
12382 The difference between N and the number of articles ticked is returned."
12384 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12386 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12387 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12388 (defun gnus-summary-tick-article (&optional article clear-mark)
12389 "Mark current article as unread.
12390 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12391 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12393 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12394 gnus-ticked-mark)))
12396 (defun gnus-summary-mark-as-read-forward (n)
12397 "Mark N articles as read forwards.
12398 If N is negative, mark backwards instead.
12399 The difference between N and the actual number of articles marked is
12402 (gnus-summary-mark-forward n gnus-del-mark t))
12404 (defun gnus-summary-mark-as-read-backward (n)
12405 "Mark the N articles as read backwards.
12406 The difference between N and the actual number of articles marked is
12409 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12411 (defun gnus-summary-mark-as-read (&optional article mark)
12412 "Mark current article as read.
12413 ARTICLE specifies the article to be marked as read.
12414 MARK specifies a string to be inserted at the beginning of the line."
12415 (gnus-summary-mark-article article mark))
12417 (defun gnus-summary-clear-mark-forward (n)
12418 "Clear marks from N articles forward.
12419 If N is negative, clear backward instead.
12420 The difference between N and the number of marks cleared is returned."
12422 (gnus-summary-mark-forward n gnus-unread-mark))
12424 (defun gnus-summary-clear-mark-backward (n)
12425 "Clear marks from N articles backward.
12426 The difference between N and the number of marks cleared is returned."
12428 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12430 (defun gnus-summary-mark-unread-as-read ()
12431 "Intended to be used by `gnus-summary-mark-article-hook'."
12432 (when (memq gnus-current-article gnus-newsgroup-unreads)
12433 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12435 (defun gnus-summary-mark-read-and-unread-as-read ()
12436 "Intended to be used by `gnus-summary-mark-article-hook'."
12437 (let ((mark (gnus-summary-article-mark)))
12438 (when (or (gnus-unread-mark-p mark)
12439 (gnus-read-mark-p mark))
12440 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12442 (defun gnus-summary-mark-region-as-read (point mark all)
12443 "Mark all unread articles between point and mark as read.
12444 If given a prefix, mark all articles between point and mark as read,
12445 even ticked and dormant ones."
12446 (interactive "r\nP")
12450 (beginning-of-line)
12455 (memq (setq article (gnus-summary-article-number))
12456 gnus-newsgroup-unreads))
12457 (gnus-summary-mark-article article gnus-del-mark))
12459 (gnus-summary-find-next))))))
12461 (defun gnus-summary-mark-below (score mark)
12462 "Mark articles with score less than SCORE with MARK."
12463 (interactive "P\ncMark: ")
12464 (gnus-set-global-variables)
12465 (setq score (if score
12466 (prefix-numeric-value score)
12467 (or gnus-summary-default-score 0)))
12469 (set-buffer gnus-summary-buffer)
12470 (goto-char (point-min))
12473 (and (< (gnus-summary-article-score) score)
12474 (gnus-summary-mark-article nil mark))
12475 (gnus-summary-find-next)))))
12477 (defun gnus-summary-kill-below (&optional score)
12478 "Mark articles with score below SCORE as read."
12480 (gnus-set-global-variables)
12481 (gnus-summary-mark-below score gnus-killed-mark))
12483 (defun gnus-summary-clear-above (&optional score)
12484 "Clear all marks from articles with score above SCORE."
12486 (gnus-set-global-variables)
12487 (gnus-summary-mark-above score gnus-unread-mark))
12489 (defun gnus-summary-tick-above (&optional score)
12490 "Tick all articles with score above SCORE."
12492 (gnus-set-global-variables)
12493 (gnus-summary-mark-above score gnus-ticked-mark))
12495 (defun gnus-summary-mark-above (score mark)
12496 "Mark articles with score over SCORE with MARK."
12497 (interactive "P\ncMark: ")
12498 (gnus-set-global-variables)
12499 (setq score (if score
12500 (prefix-numeric-value score)
12501 (or gnus-summary-default-score 0)))
12503 (set-buffer gnus-summary-buffer)
12504 (goto-char (point-min))
12506 (if (> (gnus-summary-article-score) score)
12507 (gnus-summary-mark-article nil mark))
12509 (gnus-summary-find-next)))))
12511 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12512 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12513 (defun gnus-summary-limit-include-expunged (&optional no-error)
12514 "Display all the hidden articles that were expunged for low scores."
12516 (gnus-set-global-variables)
12517 (let ((buffer-read-only nil))
12518 (let ((scored gnus-newsgroup-scored)
12521 (or (gnus-summary-goto-subject (caar scored))
12522 (and (setq h (gnus-summary-article-header (caar scored)))
12523 (< (cdar scored) gnus-summary-expunge-below)
12524 (setq headers (cons h headers))))
12525 (setq scored (cdr scored)))
12527 (when (not no-error)
12528 (error "No expunged articles hidden."))
12529 (goto-char (point-min))
12530 (gnus-summary-prepare-unthreaded (nreverse headers))
12531 (goto-char (point-min))
12532 (gnus-summary-position-point)
12535 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12536 "Mark all articles not marked as unread in this newsgroup as read.
12537 If prefix argument ALL is non-nil, all articles are marked as read.
12538 If QUIETLY is non-nil, no questions will be asked.
12539 If TO-HERE is non-nil, it should be a point in the buffer. All
12540 articles before this point will be marked as read.
12541 The number of articles marked as read is returned."
12543 (gnus-set-global-variables)
12546 (not gnus-interactive-catchup) ;Without confirmation?
12550 "Mark absolutely all articles as read? "
12551 "Mark all unread articles as read? ")))
12553 (not gnus-newsgroup-adaptive)
12554 (not gnus-newsgroup-auto-expire))
12557 (setq gnus-newsgroup-marked nil
12558 gnus-newsgroup-dormant nil))
12559 (setq gnus-newsgroup-unreads nil))
12560 ;; We actually mark all articles as canceled, which we
12561 ;; have to do when using auto-expiry or adaptive scoring.
12562 (gnus-summary-show-all-threads)
12563 (if (gnus-summary-first-subject (not all))
12565 (if to-here (< (point) to-here) t)
12566 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12567 (gnus-summary-find-next (not all)))))
12569 (setq gnus-newsgroup-unreads nil))
12570 (gnus-set-mode-line 'summary)))
12571 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12572 (if (and (not to-here) (eq 'nnvirtual (car method)))
12573 (nnvirtual-catchup-group
12574 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12575 (gnus-summary-position-point)))
12577 (defun gnus-summary-catchup-to-here (&optional all)
12578 "Mark all unticked articles before the current one as read.
12579 If ALL is non-nil, also mark ticked and dormant articles as read."
12581 (gnus-set-global-variables)
12583 (gnus-save-hidden-threads
12584 (let ((beg (point)))
12585 ;; We check that there are unread articles.
12586 (when (or all (gnus-summary-find-prev))
12587 (gnus-summary-catchup all t beg)))))
12588 (gnus-summary-position-point))
12590 (defun gnus-summary-catchup-all (&optional quietly)
12591 "Mark all articles in this newsgroup as read."
12593 (gnus-set-global-variables)
12594 (gnus-summary-catchup t quietly))
12596 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12597 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12598 If prefix argument ALL is non-nil, all articles are marked as read."
12600 (gnus-set-global-variables)
12601 (gnus-summary-catchup all quietly nil 'fast)
12602 ;; Select next newsgroup or exit.
12603 (if (eq gnus-auto-select-next 'quietly)
12604 (gnus-summary-next-group nil)
12605 (gnus-summary-exit)))
12607 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12608 "Mark all articles in this newsgroup as read, and then exit."
12610 (gnus-set-global-variables)
12611 (gnus-summary-catchup-and-exit t quietly))
12613 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12614 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12615 "Mark all articles in this group as read and select the next group.
12616 If given a prefix, mark all articles, unread as well as ticked, as
12619 (gnus-set-global-variables)
12621 (gnus-summary-catchup all))
12622 (gnus-summary-next-article t nil nil t))
12624 ;; Thread-based commands.
12626 (defun gnus-summary-articles-in-thread (&optional article)
12627 "Return a list of all articles in the current thread.
12628 If ARTICLE is non-nil, return all articles in the thread that starts
12629 with that article."
12630 (let* ((article (or article (gnus-summary-article-number)))
12631 (data (gnus-data-find-list article))
12632 (top-level (gnus-data-level (car data)))
12634 (cond ((null gnus-thread-operation-ignore-subject)
12635 (gnus-simplify-subject-re
12636 (mail-header-subject (gnus-data-header (car data)))))
12637 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12638 (gnus-simplify-subject-fuzzy
12639 (mail-header-subject (gnus-data-header (car data)))))
12641 (end-point (save-excursion
12642 (if (gnus-summary-go-to-next-thread)
12643 (point) (point-max))))
12646 (< (gnus-data-pos (car data)) end-point))
12647 (when (or (not top-subject)
12648 (string= top-subject
12649 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12650 (gnus-simplify-subject-fuzzy
12651 (mail-header-subject
12652 (gnus-data-header (car data))))
12653 (gnus-simplify-subject-re
12654 (mail-header-subject
12655 (gnus-data-header (car data)))))))
12656 (push (gnus-data-number (car data)) articles))
12657 (unless (and (setq data (cdr data))
12658 (> (gnus-data-level (car data)) top-level))
12660 ;; Return the list of articles.
12661 (nreverse articles)))
12663 (defun gnus-summary-rethread-current ()
12664 "Rethread the thread the current article is part of."
12666 (gnus-set-global-variables)
12667 (let* ((gnus-show-threads t)
12668 (article (gnus-summary-article-number))
12669 (id (mail-header-id (gnus-summary-article-header)))
12670 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12672 (error "No article on the current line"))
12673 (gnus-rebuild-thread id)
12674 (gnus-summary-goto-subject article)))
12676 (defun gnus-summary-reparent-thread ()
12677 "Make current article child of the marked (or previous) article.
12679 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12680 is non-nil or the Subject: of both articles are the same."
12682 (or (not (gnus-group-read-only-p))
12683 (error "The current newsgroup does not support article editing."))
12684 (or (<= (length gnus-newsgroup-processable) 1)
12685 (error "No more than one article may be marked."))
12686 (save-window-excursion
12687 (let ((gnus-article-buffer " *reparent*")
12688 (current-article (gnus-summary-article-number))
12689 ; first grab the marked article, otherwise one line up.
12690 (parent-article (if (not (null gnus-newsgroup-processable))
12691 (car gnus-newsgroup-processable)
12693 (if (eq (forward-line -1) 0)
12694 (gnus-summary-article-number)
12695 (error "Beginning of summary buffer."))))))
12696 (or (not (eq current-article parent-article))
12697 (error "An article may not be self-referential."))
12698 (let ((message-id (mail-header-id
12699 (gnus-summary-article-header parent-article))))
12700 (or (and message-id (not (equal message-id "")))
12701 (error "No message-id in desired parent."))
12702 (gnus-summary-select-article t t nil current-article)
12703 (set-buffer gnus-article-buffer)
12704 (setq buffer-read-only nil)
12705 (let ((buf (format "%s" (buffer-string))))
12708 (goto-char (point-min))
12709 (if (search-forward-regexp "^References: " nil t)
12710 (insert message-id " " )
12711 (insert "References: " message-id "\n"))
12712 (or (gnus-request-replace-article current-article
12713 (car gnus-article-current)
12714 gnus-article-buffer)
12715 (error "Couldn't replace article."))
12716 (set-buffer gnus-summary-buffer)
12717 (gnus-summary-unmark-all-processable)
12718 (gnus-summary-rethread-current)
12719 (gnus-message 3 "Article %d is now the child of article %d."
12720 current-article parent-article)))))
12722 (defun gnus-summary-toggle-threads (&optional arg)
12723 "Toggle showing conversation threads.
12724 If ARG is positive number, turn showing conversation threads on."
12726 (gnus-set-global-variables)
12727 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12728 (setq gnus-show-threads
12729 (if (null arg) (not gnus-show-threads)
12730 (> (prefix-numeric-value arg) 0)))
12731 (gnus-summary-prepare)
12732 (gnus-summary-goto-subject current)
12733 (gnus-summary-position-point)))
12735 (defun gnus-summary-show-all-threads ()
12736 "Show all threads."
12738 (gnus-set-global-variables)
12740 (let ((buffer-read-only nil))
12741 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12742 (gnus-summary-position-point))
12744 (defun gnus-summary-show-thread ()
12745 "Show thread subtrees.
12746 Returns nil if no thread was there to be shown."
12748 (gnus-set-global-variables)
12749 (let ((buffer-read-only nil)
12751 ;; first goto end then to beg, to have point at beg after let
12752 (end (progn (end-of-line) (point)))
12753 (beg (progn (beginning-of-line) (point))))
12755 ;; Any hidden lines here?
12756 (search-forward "\r" end t)
12757 (subst-char-in-region beg end ?\^M ?\n t)
12759 (gnus-summary-position-point))))
12761 (defun gnus-summary-hide-all-threads ()
12762 "Hide all thread subtrees."
12764 (gnus-set-global-variables)
12766 (goto-char (point-min))
12767 (gnus-summary-hide-thread)
12768 (while (zerop (gnus-summary-next-thread 1 t))
12769 (gnus-summary-hide-thread)))
12770 (gnus-summary-position-point))
12772 (defun gnus-summary-hide-thread ()
12773 "Hide thread subtrees.
12774 Returns nil if no threads were there to be hidden."
12776 (gnus-set-global-variables)
12777 (let ((buffer-read-only nil)
12779 (article (gnus-summary-article-number)))
12781 ;; Go forward until either the buffer ends or the subthread
12783 (when (and (not (eobp))
12784 (or (zerop (gnus-summary-next-thread 1 t))
12785 (goto-char (point-max))))
12787 (if (and (> (point) start)
12788 (search-backward "\n" start t))
12790 (subst-char-in-region start (point) ?\n ?\^M)
12791 (gnus-summary-goto-subject article))
12794 ;;(gnus-summary-position-point)
12797 (defun gnus-summary-go-to-next-thread (&optional previous)
12798 "Go to the same level (or less) next thread.
12799 If PREVIOUS is non-nil, go to previous thread instead.
12800 Return the article number moved to, or nil if moving was impossible."
12801 (let ((level (gnus-summary-thread-level))
12802 (way (if previous -1 1))
12805 (while (and (not (eobp))
12806 (< level (gnus-summary-thread-level)))
12807 (forward-line way))
12814 (gnus-summary-article-number)
12815 (goto-char beg)))))
12817 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12818 "Go to the same level (or less) next thread.
12819 If PREVIOUS is non-nil, go to previous thread instead.
12820 Return the article number moved to, or nil if moving was impossible."
12821 (if (and (eq gnus-summary-make-false-root 'dummy)
12822 (gnus-summary-article-intangible-p))
12823 (let ((beg (point)))
12824 (while (and (zerop (forward-line 1))
12825 (not (gnus-summary-article-intangible-p))
12826 (not (zerop (save-excursion
12827 (gnus-summary-thread-level))))))
12833 (let* ((level (gnus-summary-thread-level))
12834 (article (gnus-summary-article-number))
12835 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12838 (if (<= (gnus-data-level (car data)) level)
12839 (setq oart (gnus-data-number (car data))
12841 (setq data (cdr data))))
12843 (gnus-summary-goto-subject oart)))))
12845 (defun gnus-summary-next-thread (n &optional silent)
12846 "Go to the same level next N'th thread.
12847 If N is negative, search backward instead.
12848 Returns the difference between N and the number of skips actually
12851 If SILENT, don't output messages."
12853 (gnus-set-global-variables)
12854 (let ((backward (< n 0))
12857 (while (and (> n 0)
12858 (gnus-summary-go-to-next-thread backward))
12861 (gnus-summary-position-point))
12862 (when (and (not silent) (/= 0 n))
12863 (gnus-message 7 "No more threads"))
12866 (defun gnus-summary-prev-thread (n)
12867 "Go to the same level previous N'th thread.
12868 Returns the difference between N and the number of skips actually
12871 (gnus-set-global-variables)
12872 (gnus-summary-next-thread (- n)))
12874 (defun gnus-summary-go-down-thread ()
12875 "Go down one level in the current thread."
12876 (let ((children (gnus-summary-article-children)))
12878 (gnus-summary-goto-subject (car children)))))
12880 (defun gnus-summary-go-up-thread ()
12881 "Go up one level in the current thread."
12882 (let ((parent (gnus-summary-article-parent)))
12884 (gnus-summary-goto-subject parent))))
12886 (defun gnus-summary-down-thread (n)
12887 "Go down thread N steps.
12888 If N is negative, go up instead.
12889 Returns the difference between N and how many steps down that were
12892 (gnus-set-global-variables)
12895 (while (and (> n 0)
12896 (if up (gnus-summary-go-up-thread)
12897 (gnus-summary-go-down-thread)))
12899 (gnus-summary-position-point)
12900 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12903 (defun gnus-summary-up-thread (n)
12904 "Go up thread N steps.
12905 If N is negative, go up instead.
12906 Returns the difference between N and how many steps down that were
12909 (gnus-set-global-variables)
12910 (gnus-summary-down-thread (- n)))
12912 (defun gnus-summary-top-thread ()
12913 "Go to the top of the thread."
12915 (gnus-set-global-variables)
12916 (while (gnus-summary-go-up-thread))
12917 (gnus-summary-article-number))
12919 (defun gnus-summary-kill-thread (&optional unmark)
12920 "Mark articles under current thread as read.
12921 If the prefix argument is positive, remove any kinds of marks.
12922 If the prefix argument is negative, tick articles instead."
12924 (gnus-set-global-variables)
12926 (setq unmark (prefix-numeric-value unmark)))
12927 (let ((articles (gnus-summary-articles-in-thread)))
12929 ;; Expand the thread.
12930 (gnus-summary-show-thread)
12931 ;; Mark all the articles.
12933 (gnus-summary-goto-subject (car articles))
12934 (cond ((null unmark)
12935 (gnus-summary-mark-article-as-read gnus-killed-mark))
12937 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12939 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12940 (setq articles (cdr articles))))
12941 ;; Hide killed subtrees.
12943 gnus-thread-hide-killed
12944 (gnus-summary-hide-thread))
12945 ;; If marked as read, go to next unread subject.
12947 ;; Go to next unread subject.
12948 (gnus-summary-next-subject 1 t)))
12949 (gnus-set-mode-line 'summary))
12951 ;; Summary sorting commands
12953 (defun gnus-summary-sort-by-number (&optional reverse)
12954 "Sort summary buffer by article number.
12955 Argument REVERSE means reverse order."
12957 (gnus-summary-sort 'number reverse))
12959 (defun gnus-summary-sort-by-author (&optional reverse)
12960 "Sort summary buffer by author name alphabetically.
12961 If case-fold-search is non-nil, case of letters is ignored.
12962 Argument REVERSE means reverse order."
12964 (gnus-summary-sort 'author reverse))
12966 (defun gnus-summary-sort-by-subject (&optional reverse)
12967 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12968 If case-fold-search is non-nil, case of letters is ignored.
12969 Argument REVERSE means reverse order."
12971 (gnus-summary-sort 'subject reverse))
12973 (defun gnus-summary-sort-by-date (&optional reverse)
12974 "Sort summary buffer by date.
12975 Argument REVERSE means reverse order."
12977 (gnus-summary-sort 'date reverse))
12979 (defun gnus-summary-sort-by-score (&optional reverse)
12980 "Sort summary buffer by score.
12981 Argument REVERSE means reverse order."
12983 (gnus-summary-sort 'score reverse))
12985 (defun gnus-summary-sort (predicate reverse)
12986 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12987 (gnus-set-global-variables)
12988 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12989 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12990 (gnus-thread-sort-functions
12995 (,thread t2 t1)))))
12996 (gnus-article-sort-functions
13001 (,article t2 t1)))))
13003 (gnus-summary-prepare-hook nil))
13004 ;; We do the sorting by regenerating the threads.
13005 (gnus-summary-prepare)
13006 ;; Hide subthreads if needed.
13007 (when (and gnus-show-threads gnus-thread-hide-subtree)
13008 (gnus-summary-hide-all-threads)))
13009 ;; If in async mode, we send some info to the backend.
13010 (when gnus-newsgroup-async
13011 (gnus-request-asynchronous
13012 gnus-newsgroup-name gnus-newsgroup-data)))
13014 (defun gnus-sortable-date (date)
13015 "Make sortable string by string-lessp from DATE.
13016 Timezone package is used."
13019 (setq date (inline (timezone-fix-time
13021 (aref (inline (timezone-parse-date date)) 4))))
13023 (timezone-make-sortable-date
13024 (aref date 0) (aref date 1) (aref date 2)
13026 (timezone-make-time-string
13027 (aref date 3) (aref date 4) (aref date 5))))))
13030 ;; Summary saving commands.
13032 (defun gnus-summary-save-article (&optional n not-saved)
13033 "Save the current article using the default saver function.
13034 If N is a positive number, save the N next articles.
13035 If N is a negative number, save the N previous articles.
13036 If N is nil and any articles have been marked with the process mark,
13037 save those articles instead.
13038 The variable `gnus-default-article-saver' specifies the saver function."
13040 (gnus-set-global-variables)
13041 (let ((articles (gnus-summary-work-articles n))
13042 (save-buffer (save-excursion
13043 (nnheader-set-temp-buffer " *Gnus Save*")))
13044 file header article)
13046 (setq header (gnus-summary-article-header
13047 (setq article (pop articles))))
13048 (if (not (vectorp header))
13049 ;; This is a pseudo-article.
13050 (if (assq 'name header)
13051 (gnus-copy-file (cdr (assq 'name header)))
13052 (gnus-message 1 "Article %d is unsaveable" article))
13053 ;; This is a real article.
13054 (save-window-excursion
13055 (gnus-summary-select-article t nil nil article))
13057 (set-buffer save-buffer)
13059 (insert-buffer-substring gnus-original-article-buffer))
13060 (unless gnus-save-all-headers
13061 ;; Remove headers accoring to `gnus-saved-headers'.
13062 (let ((gnus-visible-headers
13063 (or gnus-saved-headers gnus-visible-headers))
13064 (gnus-article-buffer save-buffer))
13065 (gnus-article-hide-headers 1 t)))
13066 (save-window-excursion
13067 (if (not gnus-default-article-saver)
13068 (error "No default saver is defined.")
13069 ;; !!! Magic! The saving functions all save
13070 ;; `gnus-original-article-buffer' (or so they think),
13071 ;; but we bind that variable to our save-buffer.
13072 (set-buffer gnus-article-buffer)
13073 (let ((gnus-original-article-buffer save-buffer))
13074 (set-buffer gnus-summary-buffer)
13075 (setq file (funcall
13076 gnus-default-article-saver
13078 ((not gnus-prompt-before-saving)
13080 ((eq gnus-prompt-before-saving 'always)
13083 (gnus-summary-remove-process-mark article)
13085 (gnus-summary-set-saved-mark article))))
13086 (gnus-kill-buffer save-buffer)
13087 (gnus-summary-position-point)
13090 (defun gnus-summary-pipe-output (&optional arg)
13091 "Pipe the current article to a subprocess.
13092 If N is a positive number, pipe the N next articles.
13093 If N is a negative number, pipe the N previous articles.
13094 If N is nil and any articles have been marked with the process mark,
13095 pipe those articles instead."
13097 (gnus-set-global-variables)
13098 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13099 (gnus-summary-save-article arg t))
13100 (gnus-configure-windows 'pipe))
13102 (defun gnus-summary-save-article-mail (&optional arg)
13103 "Append the current article to an mail file.
13104 If N is a positive number, save the N next articles.
13105 If N is a negative number, save the N previous articles.
13106 If N is nil and any articles have been marked with the process mark,
13107 save those articles instead."
13109 (gnus-set-global-variables)
13110 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13111 (gnus-summary-save-article arg)))
13113 (defun gnus-summary-save-article-rmail (&optional arg)
13114 "Append the current article to an rmail file.
13115 If N is a positive number, save the N next articles.
13116 If N is a negative number, save the N previous articles.
13117 If N is nil and any articles have been marked with the process mark,
13118 save those articles instead."
13120 (gnus-set-global-variables)
13121 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13122 (gnus-summary-save-article arg)))
13124 (defun gnus-summary-save-article-file (&optional arg)
13125 "Append the current article to a file.
13126 If N is a positive number, save the N next articles.
13127 If N is a negative number, save the N previous articles.
13128 If N is nil and any articles have been marked with the process mark,
13129 save those articles instead."
13131 (gnus-set-global-variables)
13132 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13133 (gnus-summary-save-article arg)))
13135 (defun gnus-summary-save-article-body-file (&optional arg)
13136 "Append the current article body to a file.
13137 If N is a positive number, save the N next articles.
13138 If N is a negative number, save the N previous articles.
13139 If N is nil and any articles have been marked with the process mark,
13140 save those articles instead."
13142 (gnus-set-global-variables)
13143 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13144 (gnus-summary-save-article arg)))
13146 (defun gnus-get-split-value (methods)
13147 "Return a value based on the split METHODS."
13148 (let (split-name method result match)
13151 (set-buffer gnus-original-article-buffer)
13153 (nnheader-narrow-to-headers)
13155 (goto-char (point-min))
13156 (setq method (pop methods))
13157 (setq match (car method))
13160 ;; Regular expression.
13162 (re-search-forward match nil t)
13164 ((gnus-functionp match)
13168 (setq result (funcall match gnus-newsgroup-name))))
13173 (setq result (eval match)))))
13174 (setq split-name (append (cdr method) split-name))
13175 (cond ((stringp result)
13176 (push result split-name))
13178 (setq split-name (append result split-name)))))))))
13181 (defun gnus-read-move-group-name (prompt default articles prefix)
13182 "Read a group name."
13183 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13184 (minibuffer-confirm-incomplete nil) ; XEmacs
13191 (assoc (symbol-name
13192 (car (gnus-find-method-for-group
13194 gnus-valid-select-methods))
13195 (push (list (symbol-name g)) group-map)))
13196 gnus-active-hashtb))
13198 (format "%s %s to:"
13200 (if (> (length articles) 1)
13201 (format "these %d articles" (length articles))
13206 (gnus-completing-read default prom
13207 group-map nil nil prefix
13208 'gnus-group-history))
13209 ((= 1 (length split-name))
13210 (gnus-completing-read (car split-name) prom group-map
13212 'gnus-group-history))
13214 (gnus-completing-read nil prom
13215 (mapcar (lambda (el) (list el))
13216 (nreverse split-name))
13218 'gnus-group-history)))))
13220 (if (or (string= to-newsgroup "")
13221 (string= to-newsgroup prefix))
13222 (setq to-newsgroup (or default "")))
13223 (or (gnus-active to-newsgroup)
13224 (gnus-activate-group to-newsgroup)
13225 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13227 (or (and (gnus-request-create-group
13228 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13229 (gnus-activate-group to-newsgroup nil nil
13230 (gnus-group-name-to-method
13232 (error "Couldn't create group %s" to-newsgroup)))
13233 (error "No such group: %s" to-newsgroup)))
13236 (defun gnus-read-save-file-name (prompt default-name)
13237 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13239 ;; Let the split methods have their say.
13241 ;; No split name was found.
13244 (concat prompt " (default "
13245 (file-name-nondirectory default-name) ") ")
13246 (file-name-directory default-name)
13248 ;; A single split name was found
13249 ((= 1 (length split-name))
13250 (let* ((name (car split-name))
13251 (dir (cond ((file-directory-p name)
13252 (file-name-as-directory name))
13253 ((file-exists-p name) name)
13254 (t gnus-article-save-directory))))
13256 (concat prompt " (default " name ") ")
13258 ;; A list of splits was found.
13260 (setq split-name (nreverse split-name))
13262 (let ((file-name-history (nconc split-name file-name-history)))
13265 (concat prompt " (`M-p' for defaults) ")
13266 gnus-article-save-directory
13267 (car split-name))))
13268 (car (push result file-name-history)))))))
13269 ;; If we have read a directory, we append the default file name.
13270 (when (file-directory-p file)
13271 (setq file (concat (file-name-as-directory file)
13272 (file-name-nondirectory default-name))))
13273 ;; Possibly translate some charaters.
13274 (nnheader-translate-file-chars file)))
13276 (defun gnus-article-archive-name (group)
13277 "Return the first instance of an \"Archive-name\" in the current buffer."
13278 (let ((case-fold-search t))
13279 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13280 (match-string 1))))
13282 (defun gnus-summary-save-in-rmail (&optional filename)
13283 "Append this article to Rmail file.
13284 Optional argument FILENAME specifies file name.
13285 Directory to save to is default to `gnus-article-save-directory'."
13287 (gnus-set-global-variables)
13288 (let ((default-name
13289 (funcall gnus-rmail-save-name gnus-newsgroup-name
13290 gnus-current-headers gnus-newsgroup-last-rmail)))
13292 (cond ((eq filename 'default)
13294 (filename filename)
13295 (t (gnus-read-save-file-name
13296 "Save in rmail file:" default-name))))
13297 (gnus-make-directory (file-name-directory filename))
13298 (gnus-eval-in-buffer-window gnus-original-article-buffer
13302 (gnus-output-to-rmail filename))))
13303 ;; Remember the directory name to save articles
13304 (setq gnus-newsgroup-last-rmail filename)))
13306 (defun gnus-summary-save-in-mail (&optional filename)
13307 "Append this article to Unix mail file.
13308 Optional argument FILENAME specifies file name.
13309 Directory to save to is default to `gnus-article-save-directory'."
13311 (gnus-set-global-variables)
13312 (let ((default-name
13313 (funcall gnus-mail-save-name gnus-newsgroup-name
13314 gnus-current-headers gnus-newsgroup-last-mail)))
13316 (cond ((eq filename 'default)
13318 (filename filename)
13319 (t (gnus-read-save-file-name
13320 "Save in Unix mail file:" default-name))))
13322 (expand-file-name filename
13324 (file-name-directory default-name))))
13325 (gnus-make-directory (file-name-directory filename))
13326 (gnus-eval-in-buffer-window gnus-original-article-buffer
13330 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13331 (gnus-output-to-rmail filename)
13332 (let ((mail-use-rfc822 t))
13333 (rmail-output filename 1 t t))))))
13334 ;; Remember the directory name to save articles.
13335 (setq gnus-newsgroup-last-mail filename)))
13337 (defun gnus-summary-save-in-file (&optional filename)
13338 "Append this article to file.
13339 Optional argument FILENAME specifies file name.
13340 Directory to save to is default to `gnus-article-save-directory'."
13342 (gnus-set-global-variables)
13343 (let ((default-name
13344 (funcall gnus-file-save-name gnus-newsgroup-name
13345 gnus-current-headers gnus-newsgroup-last-file)))
13347 (cond ((eq filename 'default)
13349 (filename filename)
13350 (t (gnus-read-save-file-name
13351 "Save in file:" default-name))))
13352 (gnus-make-directory (file-name-directory filename))
13353 (gnus-eval-in-buffer-window gnus-original-article-buffer
13357 (gnus-output-to-file filename))))
13358 ;; Remember the directory name to save articles.
13359 (setq gnus-newsgroup-last-file filename)))
13361 (defun gnus-summary-save-body-in-file (&optional filename)
13362 "Append this article body to a file.
13363 Optional argument FILENAME specifies file name.
13364 The directory to save in defaults to `gnus-article-save-directory'."
13366 (gnus-set-global-variables)
13367 (let ((default-name
13368 (funcall gnus-file-save-name gnus-newsgroup-name
13369 gnus-current-headers gnus-newsgroup-last-file)))
13371 (cond ((eq filename 'default)
13373 (filename filename)
13374 (t (gnus-read-save-file-name
13375 "Save body in file:" default-name))))
13376 (gnus-make-directory (file-name-directory filename))
13377 (gnus-eval-in-buffer-window gnus-original-article-buffer
13381 (goto-char (point-min))
13382 (and (search-forward "\n\n" nil t)
13383 (narrow-to-region (point) (point-max)))
13384 (gnus-output-to-file filename))))
13385 ;; Remember the directory name to save articles.
13386 (setq gnus-newsgroup-last-file filename)))
13388 (defun gnus-summary-save-in-pipe (&optional command)
13389 "Pipe this article to subprocess."
13391 (gnus-set-global-variables)
13393 (cond ((eq command 'default)
13394 gnus-last-shell-command)
13396 (t (read-string "Shell command on article: "
13397 gnus-last-shell-command))))
13398 (if (string-equal command "")
13399 (setq command gnus-last-shell-command))
13400 (gnus-eval-in-buffer-window gnus-article-buffer
13403 (shell-command-on-region (point-min) (point-max) command nil)))
13404 (setq gnus-last-shell-command command))
13406 ;; Summary extract commands
13408 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13409 (let ((buffer-read-only nil)
13410 (article (gnus-summary-article-number))
13412 (or (gnus-summary-goto-subject article)
13413 (error (format "No such article: %d" article)))
13414 (gnus-summary-position-point)
13415 ;; If all commands are to be bunched up on one line, we collect
13417 (if gnus-view-pseudos-separately
13419 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13422 (setq action (cdr (assq 'action (car ps))))
13423 (setq files (list (cdr (assq 'name (car ps)))))
13424 (while (and ps (cdr ps)
13425 (string= (or action "1")
13426 (or (cdr (assq 'action (cadr ps))) "2")))
13427 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13428 (setcdr ps (cddr ps)))
13431 (if (not (string-match "%s" action))
13432 (setq files (cons " " files)))
13433 (setq files (cons " " files))
13434 (and (assq 'execute (car ps))
13435 (setcdr (assq 'execute (car ps))
13436 (funcall (if (string-match "%s" action)
13439 (mapconcat (lambda (f) f) files " ")))))
13440 (setq ps (cdr ps)))))
13441 (if (and gnus-view-pseudos (not not-view))
13443 (and (assq 'execute (car pslist))
13444 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13445 (eq gnus-view-pseudos 'not-confirm)))
13446 (setq pslist (cdr pslist)))
13449 (setq after-article (or (cdr (assq 'article (car pslist)))
13450 (gnus-summary-article-number)))
13451 (gnus-summary-goto-subject after-article)
13454 (insert " " (file-name-nondirectory
13455 (cdr (assq 'name (car pslist))))
13456 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13458 (forward-line -1) ; back to `b'
13459 (gnus-add-text-properties
13460 b (1- e) (list 'gnus-number gnus-reffed-article-number
13461 gnus-mouse-face-prop gnus-mouse-face))
13463 after-article gnus-reffed-article-number
13464 gnus-unread-mark b (car pslist) 0 (- e b))
13465 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13466 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13467 (setq pslist (cdr pslist)))))))
13469 (defun gnus-pseudos< (p1 p2)
13470 (let ((c1 (cdr (assq 'action p1)))
13471 (c2 (cdr (assq 'action p2))))
13472 (and c1 c2 (string< c1 c2))))
13474 (defun gnus-request-pseudo-article (props)
13475 (cond ((assq 'execute props)
13476 (gnus-execute-command (cdr (assq 'execute props)))))
13477 (let ((gnus-current-article (gnus-summary-article-number)))
13478 (run-hooks 'gnus-mark-article-hook)))
13480 (defun gnus-execute-command (command &optional automatic)
13482 (gnus-article-setup-buffer)
13483 (set-buffer gnus-article-buffer)
13484 (setq buffer-read-only nil)
13485 (let ((command (if automatic command (read-string "Command: " command)))
13486 ;; Just binding this here doesn't help, because there might
13487 ;; be output from the process after exiting the scope of
13489 ;; (buffer-read-only nil)
13492 (insert "$ " command "\n\n")
13493 (if gnus-view-pseudo-asynchronously
13494 (start-process "gnus-execute" nil shell-file-name
13495 shell-command-switch command)
13496 (call-process shell-file-name nil t nil
13497 shell-command-switch command)))))
13499 (defun gnus-copy-file (file &optional to)
13502 (list (read-file-name "Copy file: " default-directory)
13503 (read-file-name "Copy file to: " default-directory)))
13504 (gnus-set-global-variables)
13505 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13506 (and (file-directory-p to)
13507 (setq to (concat (file-name-as-directory to)
13508 (file-name-nondirectory file))))
13509 (copy-file file to))
13511 ;; Summary kill commands.
13513 (defun gnus-summary-edit-global-kill (article)
13514 "Edit the \"global\" kill file."
13515 (interactive (list (gnus-summary-article-number)))
13516 (gnus-set-global-variables)
13517 (gnus-group-edit-global-kill article))
13519 (defun gnus-summary-edit-local-kill ()
13520 "Edit a local kill file applied to the current newsgroup."
13522 (gnus-set-global-variables)
13523 (setq gnus-current-headers (gnus-summary-article-header))
13524 (gnus-set-global-variables)
13525 (gnus-group-edit-local-kill
13526 (gnus-summary-article-number) gnus-newsgroup-name))
13530 ;;; Gnus article mode
13533 (put 'gnus-article-mode 'mode-class 'special)
13535 (if gnus-article-mode-map
13537 (setq gnus-article-mode-map (make-keymap))
13538 (suppress-keymap gnus-article-mode-map)
13540 (gnus-define-keys gnus-article-mode-map
13541 " " gnus-article-goto-next-page
13542 "\177" gnus-article-goto-prev-page
13543 [delete] gnus-article-goto-prev-page
13544 "\C-c^" gnus-article-refer-article
13545 "h" gnus-article-show-summary
13546 "s" gnus-article-show-summary
13547 "\C-c\C-m" gnus-article-mail
13548 "?" gnus-article-describe-briefly
13549 gnus-mouse-2 gnus-article-push-button
13550 "\r" gnus-article-press-button
13551 "\t" gnus-article-next-button
13552 "\M-\t" gnus-article-prev-button
13553 "<" beginning-of-buffer
13555 "\C-c\C-i" gnus-info-find-node
13556 "\C-c\C-b" gnus-bug)
13558 (substitute-key-definition
13559 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13561 (defun gnus-article-mode ()
13562 "Major mode for displaying an article.
13564 All normal editing commands are switched off.
13566 The following commands are available:
13568 \\<gnus-article-mode-map>
13569 \\[gnus-article-next-page]\t Scroll the article one page forwards
13570 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13571 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13572 \\[gnus-article-show-summary]\t Display the summary buffer
13573 \\[gnus-article-mail]\t Send a reply to the address near point
13574 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13575 \\[gnus-info-find-node]\t Go to the Gnus info node"
13577 (when (and menu-bar-mode
13578 (gnus-visual-p 'article-menu 'menu))
13579 (gnus-article-make-menu-bar))
13580 (kill-all-local-variables)
13581 (gnus-simplify-mode-line)
13582 (setq mode-name "Article")
13583 (setq major-mode 'gnus-article-mode)
13584 (make-local-variable 'minor-mode-alist)
13585 (or (assq 'gnus-show-mime minor-mode-alist)
13586 (setq minor-mode-alist
13587 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13588 (use-local-map gnus-article-mode-map)
13589 (make-local-variable 'page-delimiter)
13590 (setq page-delimiter gnus-page-delimiter)
13591 (buffer-disable-undo (current-buffer))
13592 (setq buffer-read-only t) ;Disable modification
13593 (run-hooks 'gnus-article-mode-hook))
13595 (defun gnus-article-setup-buffer ()
13596 "Initialize the article buffer."
13597 (let* ((name (if gnus-single-article-buffer "*Article*"
13598 (concat "*Article " gnus-newsgroup-name "*")))
13600 (progn (string-match "\\*Article" name)
13601 (concat " *Original Article"
13602 (substring name (match-end 0))))))
13603 (setq gnus-article-buffer name)
13604 (setq gnus-original-article-buffer original)
13605 ;; This might be a variable local to the summary buffer.
13606 (unless gnus-single-article-buffer
13608 (set-buffer gnus-summary-buffer)
13609 (setq gnus-article-buffer name)
13610 (setq gnus-original-article-buffer original)
13611 (gnus-set-global-variables))
13612 (make-local-variable 'gnus-summary-buffer))
13613 ;; Init original article buffer.
13615 (set-buffer (get-buffer-create gnus-original-article-buffer))
13616 (buffer-disable-undo (current-buffer))
13617 (setq major-mode 'gnus-original-article-mode)
13618 (make-local-variable 'gnus-original-article))
13619 (if (get-buffer name)
13622 (buffer-disable-undo (current-buffer))
13623 (setq buffer-read-only t)
13624 (gnus-add-current-to-buffer-list)
13625 (or (eq major-mode 'gnus-article-mode)
13626 (gnus-article-mode))
13629 (set-buffer (get-buffer-create name))
13630 (gnus-add-current-to-buffer-list)
13631 (gnus-article-mode)
13632 (current-buffer)))))
13634 ;; Set article window start at LINE, where LINE is the number of lines
13635 ;; from the head of the article.
13636 (defun gnus-article-set-window-start (&optional line)
13638 (get-buffer-window gnus-article-buffer t)
13640 (set-buffer gnus-article-buffer)
13641 (goto-char (point-min))
13644 (gnus-message 6 "Moved to bookmark")
13645 (search-forward "\n\n" nil t)
13646 (forward-line line)
13649 (defun gnus-kill-all-overlays ()
13650 "Delete all overlays in the current buffer."
13651 (when (fboundp 'overlay-lists)
13652 (let* ((overlayss (overlay-lists))
13653 (buffer-read-only nil)
13654 (overlays (nconc (car overlayss) (cdr overlayss))))
13656 (delete-overlay (pop overlays))))))
13658 (defun gnus-request-article-this-buffer (article group)
13659 "Get an article and insert it into this buffer."
13660 (let (do-update-line)
13664 (gnus-kill-all-overlays)
13665 (setq group (or group gnus-newsgroup-name))
13667 ;; Open server if it has closed.
13668 (gnus-check-server (gnus-find-method-for-group group))
13670 ;; Using `gnus-request-article' directly will insert the article into
13671 ;; `nntp-server-buffer' - so we'll save some time by not having to
13672 ;; copy it from the server buffer into the article buffer.
13674 ;; We only request an article by message-id when we do not have the
13675 ;; headers for it, so we'll have to get those.
13676 (when (stringp article)
13677 (let ((gnus-override-method gnus-refer-article-method))
13678 (gnus-read-header article)))
13680 ;; If the article number is negative, that means that this article
13681 ;; doesn't belong in this newsgroup (possibly), so we find its
13682 ;; message-id and request it by id instead of number.
13683 (when (and (numberp article)
13684 gnus-summary-buffer
13685 (get-buffer gnus-summary-buffer)
13686 (buffer-name (get-buffer gnus-summary-buffer)))
13688 (set-buffer gnus-summary-buffer)
13689 (let ((header (gnus-summary-article-header article)))
13692 ((memq article gnus-newsgroup-sparse)
13693 ;; This is a sparse gap article.
13694 (setq do-update-line article)
13695 (setq article (mail-header-id header))
13696 (let ((gnus-override-method gnus-refer-article-method))
13697 (gnus-read-header article))
13698 (setq gnus-newsgroup-sparse
13699 (delq article gnus-newsgroup-sparse)))
13701 ;; It's a real article.
13702 (setq article (mail-header-id header)))
13704 ;; It is an extracted pseudo-article.
13705 (setq article 'pseudo)
13706 (gnus-request-pseudo-article header))))
13708 (let ((method (gnus-find-method-for-group
13709 gnus-newsgroup-name)))
13710 (if (not (eq (car method) 'nneething))
13712 (let ((dir (concat (file-name-as-directory (nth 1 method))
13713 (mail-header-subject header))))
13714 (if (file-directory-p dir)
13716 (setq article 'nneething)
13717 (gnus-group-enter-directory dir)))))))))
13720 ;; Refuse to select canceled articles.
13721 ((and (numberp article)
13722 gnus-summary-buffer
13723 (get-buffer gnus-summary-buffer)
13724 (buffer-name (get-buffer gnus-summary-buffer))
13725 (eq (cdr (save-excursion
13726 (set-buffer gnus-summary-buffer)
13727 (assq article gnus-newsgroup-reads)))
13728 gnus-canceled-mark))
13730 ;; We first check `gnus-original-article-buffer'.
13731 ((and (get-buffer gnus-original-article-buffer)
13734 (set-buffer gnus-original-article-buffer)
13735 (and (equal (car gnus-original-article) group)
13736 (eq (cdr gnus-original-article) article))))
13737 (insert-buffer-substring gnus-original-article-buffer)
13739 ;; Check the backlog.
13740 ((and gnus-keep-backlog
13741 (gnus-backlog-request-article group article (current-buffer)))
13743 ;; Check the cache.
13744 ((and gnus-use-cache
13746 (gnus-cache-request-article article group))
13748 ;; Get the article and put into the article buffer.
13749 ((or (stringp article) (numberp article))
13750 (let ((gnus-override-method
13751 (and (stringp article) gnus-refer-article-method))
13752 (buffer-read-only nil))
13754 (gnus-kill-all-overlays)
13755 (if (gnus-request-article article group (current-buffer))
13757 (and gnus-keep-backlog
13759 (gnus-backlog-enter-article
13760 group article (current-buffer)))
13762 ;; It was a pseudo.
13765 ;; Take the article from the original article buffer
13766 ;; and place it in the buffer it's supposed to be in.
13767 (when (and (get-buffer gnus-article-buffer)
13768 ;;(numberp article)
13769 (equal (buffer-name (current-buffer))
13770 (buffer-name (get-buffer gnus-article-buffer))))
13772 (if (get-buffer gnus-original-article-buffer)
13773 (set-buffer (get-buffer gnus-original-article-buffer))
13774 (set-buffer (get-buffer-create gnus-original-article-buffer))
13775 (buffer-disable-undo (current-buffer))
13776 (setq major-mode 'gnus-original-article-mode)
13777 (setq buffer-read-only t)
13778 (gnus-add-current-to-buffer-list))
13779 (let (buffer-read-only)
13781 (insert-buffer-substring gnus-article-buffer))
13782 (setq gnus-original-article (cons group article))))
13784 ;; Update sparse articles.
13785 (when (and do-update-line
13786 (or (numberp article)
13787 (stringp article)))
13788 (let ((buf (current-buffer)))
13789 (set-buffer gnus-summary-buffer)
13790 (gnus-summary-update-article do-update-line)
13791 (gnus-summary-goto-subject do-update-line nil t)
13792 (set-window-point (get-buffer-window (current-buffer) t)
13794 (set-buffer buf))))))
13796 (defun gnus-read-header (id &optional header)
13797 "Read the headers of article ID and enter them into the Gnus system."
13798 (let ((group gnus-newsgroup-name)
13799 (gnus-override-method
13800 (and (gnus-news-group-p gnus-newsgroup-name)
13801 gnus-refer-article-method))
13803 ;; First we check to see whether the header in question is already
13806 ;; This is a Message-ID.
13807 (setq header (or header (gnus-id-to-header id)))
13808 ;; This is an article number.
13809 (setq header (or header (gnus-summary-article-header id))))
13811 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13812 ;; We have found the header.
13814 ;; We have to really fetch the header to this article.
13815 (when (setq where (gnus-request-head id group))
13817 (set-buffer nntp-server-buffer)
13818 (goto-char (point-max))
13820 (goto-char (point-min))
13824 ((cdr where) (cdr where))
13825 (header (mail-header-number header))
13826 (t gnus-reffed-article-number))
13828 (insert " Article retrieved.\n"))
13830 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13831 ; (setcar (gnus-id-to-thread id) nil))
13832 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13833 () ; Malformed head.
13834 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13835 (if (and (stringp id)
13836 (not (string= (gnus-group-real-name group)
13838 ;; If we fetched by Message-ID and the article came
13839 ;; from a different group, we fudge some bogus article
13840 ;; numbers for this article.
13841 (mail-header-set-number header gnus-reffed-article-number))
13842 (decf gnus-reffed-article-number)
13843 (gnus-remove-header (mail-header-number header))
13844 (push header gnus-newsgroup-headers)
13845 (setq gnus-current-headers header)
13846 (push (mail-header-number header) gnus-newsgroup-limit))
13849 (defun gnus-remove-header (number)
13850 "Remove header NUMBER from `gnus-newsgroup-headers'."
13851 (if (and gnus-newsgroup-headers
13852 (= number (mail-header-number (car gnus-newsgroup-headers))))
13853 (pop gnus-newsgroup-headers)
13854 (let ((headers gnus-newsgroup-headers))
13855 (while (and (cdr headers)
13856 (not (= number (mail-header-number (cadr headers)))))
13858 (when (cdr headers)
13859 (setcdr headers (cddr headers))))))
13861 (defun gnus-article-prepare (article &optional all-headers header)
13862 "Prepare ARTICLE in article mode buffer.
13863 ARTICLE should either be an article number or a Message-ID.
13864 If ARTICLE is an id, HEADER should be the article headers.
13865 If ALL-HEADERS is non-nil, no headers are hidden."
13867 ;; Make sure we start in a summary buffer.
13868 (unless (eq major-mode 'gnus-summary-mode)
13869 (set-buffer gnus-summary-buffer))
13870 (setq gnus-summary-buffer (current-buffer))
13871 ;; Make sure the connection to the server is alive.
13872 (unless (gnus-server-opened
13873 (gnus-find-method-for-group gnus-newsgroup-name))
13874 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13875 (gnus-request-group gnus-newsgroup-name t))
13876 (let* ((article (if header (mail-header-number header) article))
13877 (summary-buffer (current-buffer))
13878 (internal-hook gnus-article-internal-prepare-hook)
13879 (group gnus-newsgroup-name)
13882 (gnus-article-setup-buffer)
13883 (set-buffer gnus-article-buffer)
13884 ;; Deactivate active regions.
13885 (when (and (boundp 'transient-mark-mode)
13886 transient-mark-mode)
13887 (setq mark-active nil))
13888 (if (not (setq result (let ((buffer-read-only nil))
13889 (gnus-request-article-this-buffer
13891 ;; There is no such article.
13893 (when (and (numberp article)
13894 (not (memq article gnus-newsgroup-sparse)))
13895 (setq gnus-article-current
13896 (cons gnus-newsgroup-name article))
13897 (set-buffer gnus-summary-buffer)
13898 (setq gnus-current-article article)
13899 (gnus-summary-mark-article article gnus-canceled-mark))
13900 (unless (memq article gnus-newsgroup-sparse)
13902 1 "No such article (may have expired or been canceled)")))
13903 (if (or (eq result 'pseudo) (eq result 'nneething))
13906 (set-buffer summary-buffer)
13907 (setq gnus-last-article gnus-current-article
13908 gnus-newsgroup-history (cons gnus-current-article
13909 gnus-newsgroup-history)
13910 gnus-current-article 0
13911 gnus-current-headers nil
13912 gnus-article-current nil)
13913 (if (eq result 'nneething)
13914 (gnus-configure-windows 'summary)
13915 (gnus-configure-windows 'article))
13916 (gnus-set-global-variables))
13917 (gnus-set-mode-line 'article))
13918 ;; The result from the `request' was an actual article -
13919 ;; or at least some text that is now displayed in the
13921 (if (and (numberp article)
13922 (not (eq article gnus-current-article)))
13923 ;; Seems like a new article has been selected.
13924 ;; `gnus-current-article' must be an article number.
13926 (set-buffer summary-buffer)
13927 (setq gnus-last-article gnus-current-article
13928 gnus-newsgroup-history (cons gnus-current-article
13929 gnus-newsgroup-history)
13930 gnus-current-article article
13931 gnus-current-headers
13932 (gnus-summary-article-header gnus-current-article)
13933 gnus-article-current
13934 (cons gnus-newsgroup-name gnus-current-article))
13935 (unless (vectorp gnus-current-headers)
13936 (setq gnus-current-headers nil))
13937 (gnus-summary-show-thread)
13938 (run-hooks 'gnus-mark-article-hook)
13939 (gnus-set-mode-line 'summary)
13940 (and (gnus-visual-p 'article-highlight 'highlight)
13941 (run-hooks 'gnus-visual-mark-article-hook))
13942 ;; Set the global newsgroup variables here.
13943 ;; Suggested by Jim Sisolak
13944 ;; <sisolak@trans4.neep.wisc.edu>.
13945 (gnus-set-global-variables)
13946 (setq gnus-have-all-headers
13947 (or all-headers gnus-show-all-headers))
13948 (and gnus-use-cache
13949 (vectorp (gnus-summary-article-header article))
13950 (gnus-cache-possibly-enter-article
13952 (gnus-summary-article-header article)
13953 (memq article gnus-newsgroup-marked)
13954 (memq article gnus-newsgroup-dormant)
13955 (memq article gnus-newsgroup-unreads)))))
13956 (when (or (numberp article)
13958 ;; Hooks for getting information from the article.
13959 ;; This hook must be called before being narrowed.
13960 (let (buffer-read-only)
13961 (run-hooks 'internal-hook)
13962 (run-hooks 'gnus-article-prepare-hook)
13963 ;; Decode MIME message.
13965 (if (or (not gnus-strict-mime)
13966 (gnus-fetch-field "Mime-Version"))
13967 (funcall gnus-show-mime-method)
13968 (funcall gnus-decode-encoded-word-method)))
13969 ;; Perform the article display hooks.
13970 (run-hooks 'gnus-article-display-hook))
13972 (goto-char (point-min))
13973 (and gnus-break-pages (gnus-narrow-to-page)))
13974 (gnus-set-mode-line 'article)
13975 (gnus-configure-windows 'article)
13976 (goto-char (point-min))
13979 (defun gnus-article-show-all-headers ()
13980 "Show all article headers in article mode buffer."
13982 (gnus-article-setup-buffer)
13983 (set-buffer gnus-article-buffer)
13984 (let ((buffer-read-only nil))
13985 (gnus-unhide-text (point-min) (point-max)))))
13987 (defun gnus-article-hide-headers-if-wanted ()
13988 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13989 Provided for backwards compatibility."
13990 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13991 gnus-inhibit-hiding
13992 (gnus-article-hide-headers)))
13994 (defsubst gnus-article-header-rank ()
13995 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13996 (let ((list gnus-sorted-header-list)
13999 (when (looking-at (car list))
14001 (setq list (cdr list))
14005 (defun gnus-article-hide-headers (&optional arg delete)
14006 "Toggle whether to hide unwanted headers and possibly sort them as well.
14007 If given a negative prefix, always show; if given a positive prefix,
14009 (interactive (gnus-hidden-arg))
14010 (if (gnus-article-check-hidden-text 'headers arg)
14011 ;; Show boring headers as well.
14012 (gnus-article-show-hidden-text 'boring-headers)
14013 ;; This function might be inhibited.
14014 (unless gnus-inhibit-hiding
14016 (set-buffer gnus-article-buffer)
14018 (let ((buffer-read-only nil)
14019 (props (nconc (list 'gnus-type 'headers)
14020 gnus-hidden-properties))
14021 (max (1+ (length gnus-sorted-header-list)))
14022 (ignored (when (not (stringp gnus-visible-headers))
14023 (cond ((stringp gnus-ignored-headers)
14024 gnus-ignored-headers)
14025 ((listp gnus-ignored-headers)
14026 (mapconcat 'identity gnus-ignored-headers
14029 (cond ((stringp gnus-visible-headers)
14030 gnus-visible-headers)
14031 ((and gnus-visible-headers
14032 (listp gnus-visible-headers))
14033 (mapconcat 'identity gnus-visible-headers "\\|"))))
14034 (inhibit-point-motion-hooks t)
14036 ;; First we narrow to just the headers.
14038 (goto-char (point-min))
14039 ;; Hide any "From " lines at the beginning of (mail) articles.
14040 (while (looking-at "From ")
14044 (delete-region (point-min) (point))
14045 (gnus-hide-text (point-min) (point) props)))
14046 ;; Then treat the rest of the header lines.
14049 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
14050 ;; Then we use the two regular expressions
14051 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
14052 ;; select which header lines is to remain visible in the
14054 (goto-char (point-min))
14055 (while (re-search-forward "^[^ \t]*:" nil t)
14056 (beginning-of-line)
14057 ;; We add the headers we want to keep to a list and delete
14058 ;; them from the buffer.
14059 (gnus-put-text-property
14060 (point) (1+ (point)) 'message-rank
14061 (if (or (and visible (looking-at visible))
14063 (not (looking-at ignored))))
14064 (gnus-article-header-rank)
14067 (message-sort-headers-1)
14068 (when (setq beg (text-property-any
14069 (point-min) (point-max) 'message-rank (+ 2 max)))
14070 ;; We make the unwanted headers invisible.
14072 (delete-region beg (point-max))
14073 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
14074 (gnus-hide-text-type beg (point-max) 'headers))
14075 ;; Work around XEmacs lossage.
14076 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
14078 (defun gnus-article-hide-boring-headers (&optional arg)
14079 "Toggle hiding of headers that aren't very interesting.
14080 If given a negative prefix, always show; if given a positive prefix,
14082 (interactive (gnus-hidden-arg))
14083 (unless (gnus-article-check-hidden-text 'boring-headers arg)
14085 (set-buffer gnus-article-buffer)
14087 (let ((buffer-read-only nil)
14088 (list gnus-boring-article-headers)
14089 (inhibit-point-motion-hooks t)
14091 (nnheader-narrow-to-headers)
14093 (setq elem (pop list))
14094 (goto-char (point-min))
14096 ;; Hide empty headers.
14098 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14100 (gnus-hide-text-type
14101 (progn (beginning-of-line) (point))
14104 (if (re-search-forward "^[^ \t]" nil t)
14105 (match-beginning 0)
14108 ;; Hide boring Newsgroups header.
14109 ((eq elem 'newsgroups)
14110 (when (equal (message-fetch-field "newsgroups")
14111 (gnus-group-real-name gnus-newsgroup-name))
14112 (gnus-article-hide-header "newsgroups")))
14113 ((eq elem 'followup-to)
14114 (when (equal (message-fetch-field "followup-to")
14115 (message-fetch-field "newsgroups"))
14116 (gnus-article-hide-header "followup-to")))
14117 ((eq elem 'reply-to)
14118 (let ((from (message-fetch-field "from"))
14119 (reply-to (message-fetch-field "reply-to")))
14123 (nth 1 (funcall gnus-extract-address-components from))
14124 (nth 1 (funcall gnus-extract-address-components
14126 (gnus-article-hide-header "reply-to"))))
14128 (let ((date (message-fetch-field "date")))
14130 (< (gnus-days-between date (current-time-string))
14132 (gnus-article-hide-header "date")))))))))))
14134 (defun gnus-article-hide-header (header)
14136 (goto-char (point-min))
14137 (when (re-search-forward (concat "^" header ":") nil t)
14138 (gnus-hide-text-type
14139 (progn (beginning-of-line) (point))
14142 (if (re-search-forward "^[^ \t]" nil t)
14143 (match-beginning 0)
14145 'boring-headers))))
14147 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14148 (defun gnus-article-treat-overstrike ()
14149 "Translate overstrikes into bold text."
14152 (set-buffer gnus-article-buffer)
14153 (let ((buffer-read-only nil))
14154 (while (search-forward "\b" nil t)
14155 (let ((next (following-char))
14156 (previous (char-after (- (point) 2))))
14158 ((eq next previous)
14159 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14160 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14162 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14163 (gnus-put-text-property
14164 (- (point) 2) (1- (point)) 'face 'underline))
14166 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14167 (gnus-put-text-property
14168 (point) (1+ (point)) 'face 'underline))))))))
14170 (defun gnus-article-word-wrap ()
14171 "Format too long lines."
14174 (set-buffer gnus-article-buffer)
14175 (let ((buffer-read-only nil))
14177 (goto-char (point-min))
14178 (search-forward "\n\n" nil t)
14180 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14181 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14182 (adaptive-fill-mode t))
14183 (while (not (eobp))
14184 (and (>= (current-column) (min fill-column (window-width)))
14185 (/= (preceding-char) ?:)
14186 (fill-paragraph nil))
14187 (end-of-line 2))))))
14189 (defun gnus-article-remove-cr ()
14190 "Remove carriage returns from an article."
14193 (set-buffer gnus-article-buffer)
14194 (let ((buffer-read-only nil))
14195 (goto-char (point-min))
14196 (while (search-forward "\r" nil t)
14197 (replace-match "" t t)))))
14199 (defun gnus-article-remove-trailing-blank-lines ()
14200 "Remove all trailing blank lines from the article."
14203 (set-buffer gnus-article-buffer)
14204 (let ((buffer-read-only nil))
14205 (goto-char (point-max))
14209 (while (looking-at "^[ \t]*$")
14214 (defun gnus-article-display-x-face (&optional force)
14215 "Look for an X-Face header and display it if present."
14216 (interactive (list 'force))
14218 (set-buffer gnus-article-buffer)
14219 ;; Delete the old process, if any.
14220 (when (process-status "gnus-x-face")
14221 (delete-process "gnus-x-face"))
14222 (let ((inhibit-point-motion-hooks t)
14223 (case-fold-search nil)
14226 (nnheader-narrow-to-headers)
14227 (setq from (message-fetch-field "from"))
14228 (goto-char (point-min))
14229 (when (and gnus-article-x-face-command
14231 ;; Check whether this face is censored.
14232 (not gnus-article-x-face-too-ugly)
14233 (and gnus-article-x-face-too-ugly from
14234 (not (string-match gnus-article-x-face-too-ugly
14236 ;; Has to be present.
14237 (re-search-forward "^X-Face: " nil t))
14238 ;; We now have the area of the buffer where the X-Face is stored.
14239 (let ((beg (point))
14240 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14241 ;; We display the face.
14242 (if (symbolp gnus-article-x-face-command)
14243 ;; The command is a lisp function, so we call it.
14244 (if (gnus-functionp gnus-article-x-face-command)
14245 (funcall gnus-article-x-face-command beg end)
14246 (error "%s is not a function" gnus-article-x-face-command))
14247 ;; The command is a string, so we interpret the command
14248 ;; as a, well, command, and fork it off.
14249 (let ((process-connection-type nil))
14250 (process-kill-without-query
14252 "gnus-x-face" nil shell-file-name shell-command-switch
14253 gnus-article-x-face-command))
14254 (process-send-region "gnus-x-face" beg end)
14255 (process-send-eof "gnus-x-face")))))))))
14257 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14258 (defun gnus-decode-rfc1522 ()
14259 "Hack to remove QP encoding from headers."
14260 (let ((case-fold-search t)
14261 (inhibit-point-motion-hooks t)
14262 (buffer-read-only nil)
14266 (goto-char (point-min))
14267 (or (search-forward "\n\n" nil t) (point-max)))
14269 (while (re-search-forward
14270 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14271 (setq string (match-string 1))
14272 (narrow-to-region (match-beginning 0) (match-end 0))
14273 (delete-region (point-min) (point-max))
14275 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14276 (subst-char-in-region (point-min) (point-max) ?_ ? )
14278 (goto-char (point-min))))))
14280 (defun gnus-article-de-quoted-unreadable (&optional force)
14281 "Do a naive translation of a quoted-printable-encoded article.
14282 This is in no way, shape or form meant as a replacement for real MIME
14283 processing, but is simply a stop-gap measure until MIME support is
14285 If FORCE, decode the article whether it is marked as quoted-printable
14287 (interactive (list 'force))
14289 (set-buffer gnus-article-buffer)
14290 (let ((case-fold-search t)
14291 (buffer-read-only nil)
14292 (type (gnus-fetch-field "content-transfer-encoding")))
14293 (gnus-decode-rfc1522)
14295 (and type (string-match "quoted-printable" (downcase type))))
14296 (goto-char (point-min))
14297 (search-forward "\n\n" nil 'move)
14298 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14300 (defun gnus-mime-decode-quoted-printable (from to)
14301 "Decode Quoted-Printable in the region between FROM and TO."
14304 (while (search-forward "=" to t)
14305 (cond ((eq (following-char) ?\n)
14308 ((looking-at "[0-9A-F][0-9A-F]")
14309 (subst-char-in-region
14310 (1- (point)) (point) ?=
14311 (hexl-hex-string-to-integer
14312 (buffer-substring (point) (+ 2 (point)))))
14316 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14318 (defun gnus-article-hide-pgp (&optional arg)
14319 "Toggle hiding of any PGP headers and signatures in the current article.
14320 If given a negative prefix, always show; if given a positive prefix,
14322 (interactive (gnus-hidden-arg))
14323 (unless (gnus-article-check-hidden-text 'pgp arg)
14325 (set-buffer gnus-article-buffer)
14326 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14327 buffer-read-only beg end)
14329 (goto-char (point-min))
14330 ;; Hide the "header".
14331 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14332 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14334 ;; Hide the actual signature.
14335 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14336 (setq end (1+ (match-beginning 0)))
14339 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14341 ;; Perhaps we shouldn't hide to the end of the buffer
14342 ;; if there is no end to the signature?
14345 ;; Hide "- " PGP quotation markers.
14346 (when (and beg end)
14347 (narrow-to-region beg end)
14348 (goto-char (point-min))
14349 (while (re-search-forward "^- " nil t)
14350 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14353 (defun gnus-article-hide-signature (&optional arg)
14354 "Hide the signature in the current article.
14355 If given a negative prefix, always show; if given a positive prefix,
14357 (interactive (gnus-hidden-arg))
14358 (unless (gnus-article-check-hidden-text 'signature arg)
14360 (set-buffer gnus-article-buffer)
14362 (let ((buffer-read-only nil))
14363 (when (gnus-narrow-to-signature)
14364 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14366 (defun gnus-article-strip-leading-blank-lines ()
14367 "Remove all blank lines from the beginning of the article."
14370 (set-buffer gnus-article-buffer)
14371 (let (buffer-read-only)
14372 (goto-char (point-min))
14373 (when (search-forward "\n\n" nil t)
14374 (while (looking-at "[ \t]$")
14375 (gnus-delete-line))))))
14377 (defvar mime::preview/content-list)
14378 (defvar mime::preview-content-info/point-min)
14379 (defun gnus-narrow-to-signature ()
14380 "Narrow to the signature."
14382 (if (and (boundp 'mime::preview/content-list)
14383 mime::preview/content-list)
14384 (let ((pcinfo (car (last mime::preview/content-list))))
14387 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14390 (goto-char (point-max))
14391 (when (re-search-backward gnus-signature-separator nil t)
14393 (when (or (null gnus-signature-limit)
14394 (and (numberp gnus-signature-limit)
14395 (< (- (point-max) (point)) gnus-signature-limit))
14396 (and (gnus-functionp gnus-signature-limit)
14397 (funcall gnus-signature-limit))
14398 (and (stringp gnus-signature-limit)
14399 (not (re-search-forward gnus-signature-limit nil t))))
14400 (narrow-to-region (point) (point-max))
14403 (defun gnus-hidden-arg ()
14404 "Return the current prefix arg as a number, or 0 if no prefix."
14405 (list (if current-prefix-arg
14406 (prefix-numeric-value current-prefix-arg)
14409 (defun gnus-article-check-hidden-text (type arg)
14410 "Return nil if hiding is necessary.
14411 Arg can be nil or a number. Nil and positive means hide, negative
14412 means show, 0 means toggle."
14414 (set-buffer gnus-article-buffer)
14415 (let ((hide (gnus-article-hidden-text-p type)))
14421 (gnus-article-show-hidden-text type))
14423 (if (eq hide 'hidden)
14424 (gnus-article-show-hidden-text type)
14427 (defun gnus-article-hidden-text-p (type)
14428 "Say whether the current buffer contains hidden text of type TYPE."
14429 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14431 (if (get-text-property pos 'invisible)
14435 (defun gnus-article-hide (&optional arg force)
14436 "Hide all the gruft in the current article.
14437 This means that PGP stuff, signatures, cited text and (some)
14438 headers will be hidden.
14439 If given a prefix, show the hidden text instead."
14440 (interactive (list current-prefix-arg 'force))
14441 (gnus-article-hide-headers arg)
14442 (gnus-article-hide-pgp arg)
14443 (gnus-article-hide-citation-maybe arg force)
14444 (gnus-article-hide-signature arg))
14446 (defun gnus-article-show-hidden-text (type &optional hide)
14447 "Show all hidden text of type TYPE.
14448 If HIDE, hide the text instead."
14450 (set-buffer gnus-article-buffer)
14451 (let ((buffer-read-only nil)
14452 (inhibit-point-motion-hooks t)
14454 (while (gnus-goto-char (text-property-any
14455 beg (point-max) 'gnus-type type))
14459 (gnus-hide-text beg (point) gnus-hidden-properties)
14460 (gnus-unhide-text beg (point)))
14461 (setq beg (point)))
14464 (defvar gnus-article-time-units
14465 `((year . ,(* 365.25 24 60 60))
14466 (week . ,(* 7 24 60 60))
14467 (day . ,(* 24 60 60))
14468 (hour . ,(* 60 60))
14471 "Mapping from time units to seconds.")
14473 (defun gnus-article-date-ut (&optional type highlight)
14474 "Convert DATE date to universal time in the current article.
14475 If TYPE is `local', convert to local time; if it is `lapsed', output
14476 how much time has lapsed since DATE."
14477 (interactive (list 'ut t))
14478 (let* ((header (or gnus-current-headers
14479 (gnus-summary-article-header) ""))
14480 (date (and (vectorp header) (mail-header-date header)))
14481 (date-regexp "^Date: \\|^X-Sent: ")
14482 (now (current-time))
14483 (inhibit-point-motion-hooks t)
14485 (when (and date (not (string= date "")))
14487 (set-buffer gnus-article-buffer)
14489 (nnheader-narrow-to-headers)
14490 (let ((buffer-read-only nil))
14491 ;; Delete any old Date headers.
14492 (if (re-search-forward date-regexp nil t)
14494 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14495 eface (get-text-property (1- (gnus-point-at-eol))
14497 (message-remove-header date-regexp t)
14498 (beginning-of-line))
14499 (goto-char (point-max)))
14500 (insert (gnus-make-date-line date type))
14501 ;; Do highlighting.
14503 (when (and (gnus-visual-p 'article-highlight 'highlight)
14504 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14505 (gnus-put-text-property (match-beginning 1) (match-end 1)
14507 (gnus-put-text-property (match-beginning 2) (match-end 2)
14508 'face eface))))))))
14510 (defun gnus-make-date-line (date type)
14511 "Return a DATE line of TYPE."
14513 ;; Convert to the local timezone. We have to slap a
14514 ;; `condition-case' round the calls to the timezone
14515 ;; functions since they aren't particularly resistant to
14518 (concat "Date: " (condition-case ()
14519 (timezone-make-date-arpa-standard date)
14522 ;; Convert to Universal Time.
14526 (timezone-make-date-arpa-standard date nil "UT")
14529 ;; Get the original date from the article.
14530 ((eq type 'original)
14531 (concat "Date: " date "\n"))
14532 ;; Do an X-Sent lapsed format.
14534 ;; If the date is seriously mangled, the timezone
14535 ;; functions are liable to bug out, so we condition-case
14536 ;; the entire thing.
14537 (let* ((now (current-time))
14542 (timezone-make-date-arpa-standard
14543 (current-time-string now)
14544 (current-time-zone now) "UT"))
14546 (timezone-make-date-arpa-standard
14549 (real-sec (+ (* (float (car real-time)) 65536)
14551 (sec (abs real-sec))
14554 ((equal real-time '(0 0))
14555 "X-Sent: Unknown\n")
14561 ;; This is a bit convoluted, but basically we go
14562 ;; through the time units for years, weeks, etc,
14563 ;; and divide things to see whether that results
14564 ;; in positive answers.
14567 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14568 ;; The (remaining) seconds are too few to
14569 ;; be divided into this time unit.
14571 ;; It's big enough, so we output it.
14572 (setq sec (- sec (* num (cdr unit))))
14574 (concat (if prev ", " "") (int-to-string
14576 " " (symbol-name (car unit))
14577 (if (> num 1) "s" ""))
14579 gnus-article-time-units "")
14580 ;; If dates are odd, then it might appear like the
14581 ;; article was sent in the future.
14584 " in the future\n"))))))
14586 (error "Unknown conversion type: %s" type))))
14588 (defun gnus-article-date-local (&optional highlight)
14589 "Convert the current article date to the local timezone."
14590 (interactive (list t))
14591 (gnus-article-date-ut 'local highlight))
14593 (defun gnus-article-date-original (&optional highlight)
14594 "Convert the current article date to what it was originally.
14595 This is only useful if you have used some other date conversion
14596 function and want to see what the date was before converting."
14597 (interactive (list t))
14598 (gnus-article-date-ut 'original highlight))
14600 (defun gnus-article-date-lapsed (&optional highlight)
14601 "Convert the current article date to time lapsed since it was sent."
14602 (interactive (list t))
14603 (gnus-article-date-ut 'lapsed highlight))
14605 (defun gnus-article-maybe-highlight ()
14606 "Do some article highlighting if `gnus-visual' is non-nil."
14607 (if (gnus-visual-p 'article-highlight 'highlight)
14608 (gnus-article-highlight-some)))
14610 ;;; Article savers.
14612 (defun gnus-output-to-rmail (file-name)
14613 "Append the current article to an Rmail file named FILE-NAME."
14615 ;; Most of these codes are borrowed from rmailout.el.
14616 (setq file-name (expand-file-name file-name))
14617 (setq rmail-default-rmail-file file-name)
14618 (let ((artbuf (current-buffer))
14619 (tmpbuf (get-buffer-create " *Gnus-output*")))
14621 (or (get-file-buffer file-name)
14622 (file-exists-p file-name)
14623 (if (gnus-yes-or-no-p
14624 (concat "\"" file-name "\" does not exist, create it? "))
14625 (let ((file-buffer (create-file-buffer file-name)))
14627 (set-buffer file-buffer)
14628 (rmail-insert-rmail-file-header)
14629 (let ((require-final-newline nil))
14630 (write-region (point-min) (point-max) file-name t 1)))
14631 (kill-buffer file-buffer))
14632 (error "Output file does not exist")))
14633 (set-buffer tmpbuf)
14634 (buffer-disable-undo (current-buffer))
14636 (insert-buffer-substring artbuf)
14637 (gnus-convert-article-to-rmail)
14638 ;; Decide whether to append to a file or to an Emacs buffer.
14639 (let ((outbuf (get-file-buffer file-name)))
14641 (append-to-file (point-min) (point-max) file-name)
14642 ;; File has been visited, in buffer OUTBUF.
14643 (set-buffer outbuf)
14644 (let ((buffer-read-only nil)
14645 (msg (and (boundp 'rmail-current-message)
14646 (symbol-value 'rmail-current-message))))
14647 ;; If MSG is non-nil, buffer is in RMAIL mode.
14650 (narrow-to-region (point-max) (point-max))))
14651 (insert-buffer-substring tmpbuf)
14654 (goto-char (point-min))
14656 (search-backward "\^_")
14657 (narrow-to-region (point) (point-max))
14658 (goto-char (1+ (point-min)))
14659 (rmail-count-new-messages t)
14660 (rmail-show-message msg)))))))
14661 (kill-buffer tmpbuf)))
14663 (defun gnus-output-to-file (file-name)
14664 "Append the current article to a file named FILE-NAME."
14665 (let ((artbuf (current-buffer)))
14666 (nnheader-temp-write nil
14667 (insert-buffer-substring artbuf)
14668 ;; Append newline at end of the buffer as separator, and then
14669 ;; save it to file.
14670 (goto-char (point-max))
14672 (append-to-file (point-min) (point-max) file-name))))
14674 (defun gnus-convert-article-to-rmail ()
14675 "Convert article in current buffer to Rmail message format."
14676 (let ((buffer-read-only nil))
14677 ;; Convert article directly into Babyl format.
14678 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14679 (goto-char (point-min))
14680 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14681 (while (search-forward "\n\^_" nil t) ;single char
14682 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14683 (goto-char (point-max))
14686 (defun gnus-narrow-to-page (&optional arg)
14687 "Narrow the article buffer to a page.
14688 If given a numerical ARG, move forward ARG pages."
14690 (setq arg (if arg (prefix-numeric-value arg) 0))
14692 (set-buffer gnus-article-buffer)
14693 (goto-char (point-min))
14695 (when (gnus-visual-p 'page-marker)
14696 (let ((buffer-read-only nil))
14697 (gnus-remove-text-with-property 'gnus-prev)
14698 (gnus-remove-text-with-property 'gnus-next)))
14701 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14703 (re-search-forward page-delimiter nil 'move arg)))
14704 (goto-char (match-end 0)))
14707 (if (re-search-forward page-delimiter nil 'move)
14708 (match-beginning 0)
14710 (when (and (gnus-visual-p 'page-marker)
14711 (not (= (point-min) 1)))
14713 (goto-char (point-min))
14714 (gnus-insert-prev-page-button)))
14715 (when (and (gnus-visual-p 'page-marker)
14716 (not (= (1- (point-max)) (buffer-size))))
14718 (goto-char (point-max))
14719 (gnus-insert-next-page-button)))))
14721 ;; Article mode commands
14723 (defun gnus-article-goto-next-page ()
14724 "Show the next page of the article."
14726 (when (gnus-article-next-page)
14727 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14729 (defun gnus-article-goto-prev-page ()
14730 "Show the next page of the article."
14732 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14733 (gnus-article-prev-page nil)))
14735 (defun gnus-article-next-page (&optional lines)
14736 "Show the next page of the current article.
14737 If end of article, return non-nil. Otherwise return nil.
14738 Argument LINES specifies lines to be scrolled up."
14740 (move-to-window-line -1)
14741 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14742 (if (save-excursion
14744 (and (pos-visible-in-window-p) ;Not continuation line.
14746 ;; Nothing in this page.
14747 (if (or (not gnus-break-pages)
14750 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14752 (gnus-narrow-to-page 1) ;Go to next page.
14754 ;; More in this page.
14758 ;; Long lines may cause an end-of-buffer error.
14759 (goto-char (point-max))))
14760 (move-to-window-line 0)
14763 (defun gnus-article-prev-page (&optional lines)
14764 "Show previous page of current article.
14765 Argument LINES specifies lines to be scrolled down."
14767 (move-to-window-line 0)
14768 (if (and gnus-break-pages
14770 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14772 (gnus-narrow-to-page -1) ;Go to previous page.
14773 (goto-char (point-max))
14777 (scroll-down lines)
14779 (move-to-window-line 0))))
14781 (defun gnus-article-refer-article ()
14782 "Read article specified by message-id around point."
14784 (let ((point (point)))
14785 (search-forward ">" nil t) ;Move point to end of "<....>".
14786 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14787 (let ((message-id (match-string 1)))
14789 (set-buffer gnus-summary-buffer)
14790 (gnus-summary-refer-article message-id))
14791 (goto-char (point))
14792 (error "No references around point"))))
14794 (defun gnus-article-show-summary ()
14795 "Reconfigure windows to show summary buffer."
14797 (gnus-configure-windows 'article)
14798 (gnus-summary-goto-subject gnus-current-article))
14800 (defun gnus-article-describe-briefly ()
14801 "Describe article mode commands briefly."
14804 (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")))
14806 (defun gnus-article-summary-command ()
14807 "Execute the last keystroke in the summary buffer."
14809 (let ((obuf (current-buffer))
14810 (owin (current-window-configuration))
14812 (switch-to-buffer gnus-summary-buffer 'norecord)
14813 (setq func (lookup-key (current-local-map) (this-command-keys)))
14814 (call-interactively func)
14816 (set-window-configuration owin)
14817 (set-window-point (get-buffer-window (current-buffer)) (point))))
14819 (defun gnus-article-summary-command-nosave ()
14820 "Execute the last keystroke in the summary buffer."
14823 (pop-to-buffer gnus-summary-buffer 'norecord)
14824 (setq func (lookup-key (current-local-map) (this-command-keys)))
14825 (call-interactively func)))
14827 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14828 "Read a summary buffer key sequence and execute it from the article buffer."
14831 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14832 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14833 "=" "^" "\M-^" "|"))
14834 (nosave-but-article
14838 (set-buffer gnus-summary-buffer)
14839 (push (or key last-command-event) unread-command-events)
14840 (setq keys (read-key-sequence nil)))
14843 (if (or (member keys nosaves)
14844 (member keys nosave-but-article))
14846 (save-window-excursion
14847 (pop-to-buffer gnus-summary-buffer 'norecord)
14848 (setq func (lookup-key (current-local-map) keys)))
14851 (set-buffer gnus-summary-buffer)
14852 (call-interactively func))
14853 (when (member keys nosave-but-article)
14854 (pop-to-buffer gnus-article-buffer 'norecord)))
14855 (let ((obuf (current-buffer))
14856 (owin (current-window-configuration))
14859 (if not-restore-window
14860 (pop-to-buffer gnus-summary-buffer 'norecord)
14861 (switch-to-buffer gnus-summary-buffer 'norecord))
14862 (setq in-buffer (current-buffer))
14863 (if (setq func (lookup-key (current-local-map) keys))
14864 (call-interactively func)
14866 (when (eq in-buffer (current-buffer))
14868 (unless not-restore-window
14869 (set-window-configuration owin))
14870 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14874 ;;; Kill file handling.
14878 (defalias 'gnus-batch-kill 'gnus-batch-score)
14880 (defun gnus-batch-score ()
14881 "Run batched scoring.
14882 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14883 Newsgroups is a list of strings in Bnews format. If you want to score
14884 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14885 score the alt hierarchy, you'd say \"!alt.all\"."
14888 (gnus-newsrc-parse-options
14889 (apply (function concat)
14890 (mapcar (lambda (g) (concat g " "))
14891 command-line-args-left))))
14892 (gnus-expert-user t)
14893 (nnmail-spool-file nil)
14894 (gnus-use-dribble-file nil)
14895 (yes (car yes-and-no))
14896 (no (cdr yes-and-no))
14898 ;; Disable verbose message.
14899 gnus-novice-user gnus-large-newsgroup)
14900 ;; Eat all arguments.
14901 (setq command-line-args-left nil)
14904 ;; Apply kills to specified newsgroups in command line arguments.
14905 (setq newsrc (cdr gnus-newsrc-alist))
14907 (setq group (caar newsrc))
14908 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14909 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14911 (or (eq (car entry) t)
14912 (not (zerop (car entry)))))
14913 (if yes (string-match yes group) t)
14914 (or (null no) (not (string-match no group))))
14916 (gnus-summary-read-group group nil t nil t)
14917 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14918 (gnus-summary-exit))))
14919 (setq newsrc (cdr newsrc)))
14921 (switch-to-buffer gnus-group-buffer)
14922 (gnus-group-save-newsrc)))
14924 (defun gnus-apply-kill-file ()
14925 "Apply a kill file to the current newsgroup.
14926 Returns the number of articles marked as read."
14927 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14928 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14929 (gnus-apply-kill-file-internal)
14932 (defun gnus-kill-save-kill-buffer ()
14933 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14934 (when (get-file-buffer file)
14936 (set-buffer (get-file-buffer file))
14937 (and (buffer-modified-p) (save-buffer))
14938 (kill-buffer (current-buffer))))))
14940 (defvar gnus-kill-file-name "KILL"
14941 "Suffix of the kill files.")
14943 (defun gnus-newsgroup-kill-file (newsgroup)
14944 "Return the name of a kill file name for NEWSGROUP.
14945 If NEWSGROUP is nil, return the global kill file name instead."
14947 ;; The global KILL file is placed at top of the directory.
14948 ((or (null newsgroup)
14949 (string-equal newsgroup ""))
14950 (expand-file-name gnus-kill-file-name
14951 gnus-kill-files-directory))
14952 ;; Append ".KILL" to newsgroup name.
14953 ((gnus-use-long-file-name 'not-kill)
14954 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14955 "." gnus-kill-file-name)
14956 gnus-kill-files-directory))
14957 ;; Place "KILL" under the hierarchical directory.
14959 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14960 "/" gnus-kill-file-name)
14961 gnus-kill-files-directory))))
14968 (defvar gnus-dribble-ignore nil)
14969 (defvar gnus-dribble-eval-file nil)
14971 (defun gnus-dribble-file-name ()
14972 "Return the dribble file for the current .newsrc."
14974 (if gnus-dribble-directory
14975 (concat (file-name-as-directory gnus-dribble-directory)
14976 (file-name-nondirectory gnus-current-startup-file))
14977 gnus-current-startup-file)
14980 (defun gnus-dribble-enter (string)
14981 "Enter STRING into the dribble buffer."
14982 (if (and (not gnus-dribble-ignore)
14983 gnus-dribble-buffer
14984 (buffer-name gnus-dribble-buffer))
14985 (let ((obuf (current-buffer)))
14986 (set-buffer gnus-dribble-buffer)
14987 (insert string "\n")
14988 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14989 (bury-buffer gnus-dribble-buffer)
14990 (set-buffer obuf))))
14992 (defun gnus-dribble-read-file ()
14993 "Read the dribble file from disk."
14994 (let ((dribble-file (gnus-dribble-file-name)))
14996 (set-buffer (setq gnus-dribble-buffer
14998 (file-name-nondirectory dribble-file))))
14999 (gnus-add-current-to-buffer-list)
15001 (setq buffer-file-name dribble-file)
15003 (buffer-disable-undo (current-buffer))
15004 (bury-buffer (current-buffer))
15005 (set-buffer-modified-p nil)
15006 (let ((auto (make-auto-save-file-name))
15007 (gnus-dribble-ignore t)
15009 (when (or (file-exists-p auto) (file-exists-p dribble-file))
15010 ;; Load whichever file is newest -- the auto save file
15011 ;; or the "real" file.
15012 (if (file-newer-than-file-p auto dribble-file)
15013 (insert-file-contents auto)
15014 (insert-file-contents dribble-file))
15015 (unless (zerop (buffer-size))
15016 (set-buffer-modified-p t))
15017 ;; Set the file modes to reflect the .newsrc file modes.
15019 (when (and (file-exists-p gnus-current-startup-file)
15020 (setq modes (file-modes gnus-current-startup-file)))
15021 (set-file-modes dribble-file modes))
15022 ;; Possibly eval the file later.
15023 (when (gnus-y-or-n-p
15024 "Auto-save file exists. Do you want to read it? ")
15025 (setq gnus-dribble-eval-file t)))))))
15027 (defun gnus-dribble-eval-file ()
15028 (when gnus-dribble-eval-file
15029 (setq gnus-dribble-eval-file nil)
15031 (let ((gnus-dribble-ignore t))
15032 (set-buffer gnus-dribble-buffer)
15033 (eval-buffer (current-buffer))))))
15035 (defun gnus-dribble-delete-file ()
15036 (when (file-exists-p (gnus-dribble-file-name))
15037 (delete-file (gnus-dribble-file-name)))
15038 (when gnus-dribble-buffer
15040 (set-buffer gnus-dribble-buffer)
15041 (let ((auto (make-auto-save-file-name)))
15042 (if (file-exists-p auto)
15043 (delete-file auto))
15045 (set-buffer-modified-p nil)))))
15047 (defun gnus-dribble-save ()
15048 (when (and gnus-dribble-buffer
15049 (buffer-name gnus-dribble-buffer))
15051 (set-buffer gnus-dribble-buffer)
15054 (defun gnus-dribble-clear ()
15055 (when (gnus-buffer-exists-p gnus-dribble-buffer)
15057 (set-buffer gnus-dribble-buffer)
15059 (set-buffer-modified-p nil)
15060 (setq buffer-saved-size (buffer-size)))))
15064 ;;; Server Communication
15067 (defun gnus-start-news-server (&optional confirm)
15068 "Open a method for getting news.
15069 If CONFIRM is non-nil, the user will be asked for an NNTP server."
15071 (if gnus-current-select-method
15072 ;; Stream is already opened.
15074 ;; Open NNTP server.
15075 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
15078 ;; Read server name with completion.
15079 (setq gnus-nntp-server
15080 (completing-read "NNTP server: "
15081 (mapcar (lambda (server) (list server))
15082 (cons (list gnus-nntp-server)
15083 gnus-secondary-servers))
15084 nil nil gnus-nntp-server))))
15086 (if (and gnus-nntp-server
15087 (stringp gnus-nntp-server)
15088 (not (string= gnus-nntp-server "")))
15089 (setq gnus-select-method
15090 (cond ((or (string= gnus-nntp-server "")
15091 (string= gnus-nntp-server "::"))
15092 (list 'nnspool (system-name)))
15093 ((string-match "^:" gnus-nntp-server)
15094 (list 'nnmh gnus-nntp-server
15095 (list 'nnmh-directory
15096 (file-name-as-directory
15098 (concat "~/" (substring
15099 gnus-nntp-server 1)))))
15100 (list 'nnmh-get-new-mail nil)))
15102 (list 'nntp gnus-nntp-server)))))
15104 (setq how (car gnus-select-method))
15105 (cond ((eq how 'nnspool)
15107 (gnus-message 5 "Looking up local news spool..."))
15110 (gnus-message 5 "Looking up mh spool..."))
15113 (setq gnus-current-select-method gnus-select-method)
15114 (run-hooks 'gnus-open-server-hook)
15116 ;; gnus-open-server-hook might have opened it
15117 (gnus-server-opened gnus-select-method)
15118 (gnus-open-server gnus-select-method)
15121 "%s (%s) open error: '%s'. Continue? "
15122 (car gnus-select-method) (cadr gnus-select-method)
15123 (gnus-status-message gnus-select-method)))
15124 (gnus-error 1 "Couldn't open server on %s"
15125 (nth 1 gnus-select-method))))))
15127 (defun gnus-check-group (group)
15128 "Try to make sure that the server where GROUP exists is alive."
15129 (let ((method (gnus-find-method-for-group group)))
15130 (or (gnus-server-opened method)
15131 (gnus-open-server method))))
15133 (defun gnus-check-server (&optional method silent)
15134 "Check whether the connection to METHOD is down.
15135 If METHOD is nil, use `gnus-select-method'.
15136 If it is down, start it up (again)."
15137 (let ((method (or method gnus-select-method)))
15138 ;; Transform virtual server names into select methods.
15139 (when (stringp method)
15140 (setq method (gnus-server-to-method method)))
15141 (if (gnus-server-opened method)
15142 ;; The stream is already opened.
15144 ;; Open the server.
15146 (gnus-message 5 "Opening %s server%s..." (car method)
15147 (if (equal (nth 1 method) "") ""
15148 (format " on %s" (nth 1 method)))))
15149 (run-hooks 'gnus-open-server-hook)
15151 (gnus-open-server method)
15155 (defun gnus-get-function (method function &optional noerror)
15156 "Return a function symbol based on METHOD and FUNCTION."
15157 ;; Translate server names into methods.
15159 (error "Attempted use of a nil select method"))
15160 (when (stringp method)
15161 (setq method (gnus-server-to-method method)))
15162 (let ((func (intern (format "%s-%s" (car method) function))))
15163 ;; If the functions isn't bound, we require the backend in
15165 (unless (fboundp func)
15166 (require (car method))
15167 (when (and (not (fboundp func))
15169 ;; This backend doesn't implement this function.
15170 (error "No such function: %s" func)))
15175 ;;; Interface functions to the backends.
15178 (defun gnus-open-server (method)
15179 "Open a connection to METHOD."
15180 (when (stringp method)
15181 (setq method (gnus-server-to-method method)))
15182 (let ((elem (assoc method gnus-opened-servers)))
15183 ;; If this method was previously denied, we just return nil.
15184 (if (eq (nth 1 elem) 'denied)
15186 (gnus-message 1 "Denied server")
15188 ;; Open the server.
15190 (funcall (gnus-get-function method 'open-server)
15191 (nth 1 method) (nthcdr 2 method))))
15192 ;; If this hasn't been opened before, we add it to the list.
15194 (setq elem (list method nil)
15195 gnus-opened-servers (cons elem gnus-opened-servers)))
15196 ;; Set the status of this server.
15197 (setcar (cdr elem) (if result 'ok 'denied))
15198 ;; Return the result from the "open" call.
15201 (defun gnus-close-server (method)
15202 "Close the connection to METHOD."
15203 (when (stringp method)
15204 (setq method (gnus-server-to-method method)))
15205 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15207 (defun gnus-request-list (method)
15208 "Request the active file from METHOD."
15209 (when (stringp method)
15210 (setq method (gnus-server-to-method method)))
15211 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15213 (defun gnus-request-list-newsgroups (method)
15214 "Request the newsgroups file from METHOD."
15215 (when (stringp method)
15216 (setq method (gnus-server-to-method method)))
15217 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15219 (defun gnus-request-newgroups (date method)
15220 "Request all new groups since DATE from METHOD."
15221 (when (stringp method)
15222 (setq method (gnus-server-to-method method)))
15223 (funcall (gnus-get-function method 'request-newgroups)
15224 date (nth 1 method)))
15226 (defun gnus-server-opened (method)
15227 "Check whether a connection to METHOD has been opened."
15228 (when (stringp method)
15229 (setq method (gnus-server-to-method method)))
15230 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15232 (defun gnus-status-message (method)
15233 "Return the status message from METHOD.
15234 If METHOD is a string, it is interpreted as a group name. The method
15235 this group uses will be queried."
15236 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15238 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15240 (defun gnus-request-group (group &optional dont-check method)
15241 "Request GROUP. If DONT-CHECK, no information is required."
15242 (let ((method (or method (gnus-find-method-for-group group))))
15243 (when (stringp method)
15244 (setq method (gnus-server-to-method method)))
15245 (funcall (gnus-get-function method 'request-group)
15246 (gnus-group-real-name group) (nth 1 method) dont-check)))
15248 (defun gnus-request-asynchronous (group &optional articles)
15249 "Request that GROUP behave asynchronously.
15250 ARTICLES is the `data' of the group."
15251 (let ((method (gnus-find-method-for-group group)))
15252 (funcall (gnus-get-function method 'request-asynchronous)
15253 (gnus-group-real-name group) (nth 1 method) articles)))
15255 (defun gnus-list-active-group (group)
15256 "Request active information on GROUP."
15257 (let ((method (gnus-find-method-for-group group))
15258 (func 'list-active-group))
15259 (when (gnus-check-backend-function func group)
15260 (funcall (gnus-get-function method func)
15261 (gnus-group-real-name group) (nth 1 method)))))
15263 (defun gnus-request-group-description (group)
15264 "Request a description of GROUP."
15265 (let ((method (gnus-find-method-for-group group))
15266 (func 'request-group-description))
15267 (when (gnus-check-backend-function func group)
15268 (funcall (gnus-get-function method func)
15269 (gnus-group-real-name group) (nth 1 method)))))
15271 (defun gnus-close-group (group)
15272 "Request the GROUP be closed."
15273 (let ((method (gnus-find-method-for-group group)))
15274 (funcall (gnus-get-function method 'close-group)
15275 (gnus-group-real-name group) (nth 1 method))))
15277 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15278 "Request headers for ARTICLES in GROUP.
15279 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15280 (let ((method (gnus-find-method-for-group group)))
15281 (if (and gnus-use-cache (numberp (car articles)))
15282 (gnus-cache-retrieve-headers articles group fetch-old)
15283 (funcall (gnus-get-function method 'retrieve-headers)
15284 articles (gnus-group-real-name group) (nth 1 method)
15287 (defun gnus-retrieve-groups (groups method)
15288 "Request active information on GROUPS from METHOD."
15289 (when (stringp method)
15290 (setq method (gnus-server-to-method method)))
15291 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15293 (defun gnus-request-type (group &optional article)
15294 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15295 (let ((method (gnus-find-method-for-group group)))
15296 (if (not (gnus-check-backend-function 'request-type (car method)))
15298 (funcall (gnus-get-function method 'request-type)
15299 (gnus-group-real-name group) article))))
15301 (defun gnus-request-update-mark (group article mark)
15302 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15303 (let ((method (gnus-find-method-for-group group)))
15304 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15306 (funcall (gnus-get-function method 'request-update-mark)
15307 (gnus-group-real-name group) article mark))))
15309 (defun gnus-request-article (article group &optional buffer)
15310 "Request the ARTICLE in GROUP.
15311 ARTICLE can either be an article number or an article Message-ID.
15312 If BUFFER, insert the article in that group."
15313 (let ((method (gnus-find-method-for-group group)))
15314 (funcall (gnus-get-function method 'request-article)
15315 article (gnus-group-real-name group) (nth 1 method) buffer)))
15317 (defun gnus-request-head (article group)
15318 "Request the head of ARTICLE in GROUP."
15319 (let* ((method (gnus-find-method-for-group group))
15320 (head (gnus-get-function method 'request-head t)))
15322 (funcall head article (gnus-group-real-name group) (nth 1 method))
15323 (let ((res (gnus-request-article article group)))
15326 (set-buffer nntp-server-buffer)
15327 (goto-char (point-min))
15328 (when (search-forward "\n\n" nil t)
15329 (delete-region (1- (point)) (point-max)))
15330 (nnheader-fold-continuation-lines)))
15333 (defun gnus-request-body (article group)
15334 "Request the body of ARTICLE in GROUP."
15335 (let ((method (gnus-find-method-for-group group)))
15336 (funcall (gnus-get-function method 'request-body)
15337 article (gnus-group-real-name group) (nth 1 method))))
15339 (defun gnus-request-post (method)
15340 "Post the current buffer using METHOD."
15341 (when (stringp method)
15342 (setq method (gnus-server-to-method method)))
15343 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15345 (defun gnus-request-scan (group method)
15346 "Request a SCAN being performed in GROUP from METHOD.
15347 If GROUP is nil, all groups on METHOD are scanned."
15348 (let ((method (if group (gnus-find-method-for-group group) method)))
15349 (funcall (gnus-get-function method 'request-scan)
15350 (and group (gnus-group-real-name group)) (nth 1 method))))
15352 (defsubst gnus-request-update-info (info method)
15353 "Request that METHOD update INFO."
15354 (when (stringp method)
15355 (setq method (gnus-server-to-method method)))
15356 (when (gnus-check-backend-function 'request-update-info (car method))
15357 (funcall (gnus-get-function method 'request-update-info)
15358 (gnus-group-real-name (gnus-info-group info))
15359 info (nth 1 method))))
15361 (defun gnus-request-expire-articles (articles group &optional force)
15362 (let ((method (gnus-find-method-for-group group)))
15363 (funcall (gnus-get-function method 'request-expire-articles)
15364 articles (gnus-group-real-name group) (nth 1 method)
15367 (defun gnus-request-move-article
15368 (article group server accept-function &optional last)
15369 (let ((method (gnus-find-method-for-group group)))
15370 (funcall (gnus-get-function method 'request-move-article)
15371 article (gnus-group-real-name group)
15372 (nth 1 method) accept-function last)))
15374 (defun gnus-request-accept-article (group method &optional last)
15375 ;; Make sure there's a newline at the end of the article.
15376 (when (stringp method)
15377 (setq method (gnus-server-to-method method)))
15378 (when (and (not method)
15380 (setq method (gnus-group-name-to-method group)))
15381 (goto-char (point-max))
15384 (let ((func (car (or method (gnus-find-method-for-group group)))))
15385 (funcall (intern (format "%s-request-accept-article" func))
15386 (if (stringp group) (gnus-group-real-name group) group)
15390 (defun gnus-request-replace-article (article group buffer)
15391 (let ((func (car (gnus-find-method-for-group group))))
15392 (funcall (intern (format "%s-request-replace-article" func))
15393 article (gnus-group-real-name group) buffer)))
15395 (defun gnus-request-associate-buffer (group)
15396 (let ((method (gnus-find-method-for-group group)))
15397 (funcall (gnus-get-function method 'request-associate-buffer)
15398 (gnus-group-real-name group))))
15400 (defun gnus-request-restore-buffer (article group)
15401 "Request a new buffer restored to the state of ARTICLE."
15402 (let ((method (gnus-find-method-for-group group)))
15403 (funcall (gnus-get-function method 'request-restore-buffer)
15404 article (gnus-group-real-name group) (nth 1 method))))
15406 (defun gnus-request-create-group (group &optional method)
15407 (when (stringp method)
15408 (setq method (gnus-server-to-method method)))
15409 (let ((method (or method (gnus-find-method-for-group group))))
15410 (funcall (gnus-get-function method 'request-create-group)
15411 (gnus-group-real-name group) (nth 1 method))))
15413 (defun gnus-request-delete-group (group &optional force)
15414 (let ((method (gnus-find-method-for-group group)))
15415 (funcall (gnus-get-function method 'request-delete-group)
15416 (gnus-group-real-name group) force (nth 1 method))))
15418 (defun gnus-request-rename-group (group new-name)
15419 (let ((method (gnus-find-method-for-group group)))
15420 (funcall (gnus-get-function method 'request-rename-group)
15421 (gnus-group-real-name group)
15422 (gnus-group-real-name new-name) (nth 1 method))))
15424 (defun gnus-member-of-valid (symbol group)
15425 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15426 (memq symbol (assoc
15427 (symbol-name (car (gnus-find-method-for-group group)))
15428 gnus-valid-select-methods)))
15430 (defun gnus-method-option-p (method option)
15431 "Return non-nil if select METHOD has OPTION as a parameter."
15432 (when (stringp method)
15433 (setq method (gnus-server-to-method method)))
15434 (memq option (assoc (format "%s" (car method))
15435 gnus-valid-select-methods)))
15437 (defun gnus-server-extend-method (group method)
15438 ;; This function "extends" a virtual server. If the server is
15439 ;; "hello", and the select method is ("hello" (my-var "something"))
15440 ;; in the group "alt.alt", this will result in a new virtual server
15441 ;; called "hello+alt.alt".
15443 (gnus-copy-sequence
15444 (if (equal (car method) "native") gnus-select-method
15445 (cdr (assoc (car method) gnus-server-alist))))))
15446 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15447 (nconc entry (cdr method))))
15449 (defun gnus-server-status (method)
15450 "Return the status of METHOD."
15451 (nth 1 (assoc method gnus-opened-servers)))
15453 (defun gnus-group-name-to-method (group)
15454 "Return a select method suitable for GROUP."
15455 (if (string-match ":" group)
15456 (let ((server (substring group 0 (match-beginning 0))))
15457 (if (string-match "\\+" server)
15458 (list (intern (substring server 0 (match-beginning 0)))
15459 (substring server (match-end 0)))
15460 (list (intern server) "")))
15461 gnus-select-method))
15463 (defun gnus-find-method-for-group (group &optional info)
15464 "Find the select method that GROUP uses."
15465 (or gnus-override-method
15467 gnus-select-method)
15468 (let ((info (or info (gnus-get-info group)))
15471 (not (setq method (gnus-info-method info)))
15472 (equal method "native"))
15475 (cond ((stringp method)
15476 (gnus-server-to-method method))
15477 ((stringp (car method))
15478 (gnus-server-extend-method group method))
15481 (cond ((equal (cadr method) "")
15483 ((null (cadr method))
15484 (list (car method) ""))
15486 (gnus-server-add-address method)))))))
15488 (defun gnus-check-backend-function (func group)
15489 "Check whether GROUP supports function FUNC."
15490 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15492 (fboundp (intern (format "%s-%s" method func)))))
15494 (defun gnus-methods-using (feature)
15495 "Find all methods that have FEATURE."
15496 (let ((valids gnus-valid-select-methods)
15499 (if (memq feature (car valids))
15500 (setq outs (cons (car valids) outs)))
15501 (setq valids (cdr valids)))
15506 ;;; Active & Newsrc File Handling
15509 (defun gnus-setup-news (&optional rawfile level dont-connect)
15510 "Setup news information.
15511 If RAWFILE is non-nil, the .newsrc file will also be read.
15512 If LEVEL is non-nil, the news will be set up at level LEVEL."
15513 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15516 ;; Clear some variables to re-initialize news information.
15517 (setq gnus-newsrc-alist nil
15518 gnus-active-hashtb nil)
15519 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15520 (gnus-read-newsrc-file rawfile))
15522 (when (and (not (assoc "archive" gnus-server-alist))
15523 (gnus-archive-server-wanted-p))
15524 (push (cons "archive" gnus-message-archive-method)
15525 gnus-server-alist))
15527 ;; If we don't read the complete active file, we fill in the
15529 (if (or (null gnus-read-active-file)
15530 (eq gnus-read-active-file 'some))
15531 (gnus-update-active-hashtb-from-killed))
15533 ;; Read the active file and create `gnus-active-hashtb'.
15534 ;; If `gnus-read-active-file' is nil, then we just create an empty
15535 ;; hash table. The partial filling out of the hash table will be
15536 ;; done in `gnus-get-unread-articles'.
15537 (and gnus-read-active-file
15539 (gnus-read-active-file))
15541 (or gnus-active-hashtb
15542 (setq gnus-active-hashtb (make-vector 4095 0)))
15544 ;; Initialize the cache.
15545 (when gnus-use-cache
15548 ;; Possibly eval the dribble file.
15549 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15551 ;; Slave Gnusii should then clear the dribble buffer.
15552 (when (and init gnus-slave)
15553 (gnus-dribble-clear))
15555 (gnus-update-format-specifications)
15557 ;; See whether we need to read the description file.
15558 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15559 (not gnus-description-hashtb)
15561 gnus-read-active-file)
15562 (gnus-read-all-descriptions-files))
15564 ;; Find new newsgroups and treat them.
15565 (if (and init gnus-check-new-newsgroups (not level)
15566 (gnus-check-server gnus-select-method))
15567 (gnus-find-new-newsgroups))
15569 ;; We might read in new NoCeM messages here.
15570 (when (and gnus-use-nocem
15572 (not dont-connect))
15573 (gnus-nocem-scan-groups))
15575 ;; Find the number of unread articles in each non-dead group.
15576 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15577 (gnus-get-unread-articles level))
15579 (if (and init gnus-check-bogus-newsgroups
15580 gnus-read-active-file (not level)
15581 (gnus-server-opened gnus-select-method))
15582 (gnus-check-bogus-newsgroups))))
15584 (defun gnus-find-new-newsgroups (&optional arg)
15585 "Search for new newsgroups and add them.
15586 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15587 The `-n' option line from .newsrc is respected.
15588 If ARG (the prefix), use the `ask-server' method to query
15589 the server for new groups."
15591 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15592 (null gnus-read-active-file)
15593 (eq gnus-read-active-file 'some))
15594 'ask-server gnus-check-new-newsgroups)))
15595 (unless (gnus-check-first-time-used)
15596 (if (or (consp check)
15597 (eq check 'ask-server))
15598 ;; Ask the server for new groups.
15599 (gnus-ask-server-for-new-groups)
15600 ;; Go through the active hashtb and look for new groups.
15602 group new-newsgroups)
15603 (gnus-message 5 "Looking for new newsgroups...")
15604 (unless gnus-have-read-active-file
15605 (gnus-read-active-file))
15606 (setq gnus-newsrc-last-checked-date (current-time-string))
15607 (unless gnus-killed-hashtb
15608 (gnus-make-hashtable-from-killed))
15609 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15610 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15613 (if (or (null (setq group (symbol-name sym)))
15615 (null (symbol-value sym))
15616 (gnus-gethash group gnus-killed-hashtb)
15617 (gnus-gethash group gnus-newsrc-hashtb))
15619 (let ((do-sub (gnus-matches-options-n group)))
15621 ((eq do-sub 'subscribe)
15622 (setq groups (1+ groups))
15623 (gnus-sethash group group gnus-killed-hashtb)
15624 (funcall gnus-subscribe-options-newsgroup-method group))
15625 ((eq do-sub 'ignore)
15628 (setq groups (1+ groups))
15629 (gnus-sethash group group gnus-killed-hashtb)
15630 (if gnus-subscribe-hierarchical-interactive
15631 (setq new-newsgroups (cons group new-newsgroups))
15632 (funcall gnus-subscribe-newsgroup-method group)))))))
15633 gnus-active-hashtb)
15634 (when new-newsgroups
15635 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15636 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15638 (gnus-message 6 "%d new newsgroup%s arrived."
15639 groups (if (> groups 1) "s have" " has"))
15640 (gnus-message 6 "No new newsgroups.")))))))
15642 (defun gnus-matches-options-n (group)
15643 ;; Returns `subscribe' if the group is to be unconditionally
15644 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15645 ;; no match for the group.
15647 ;; First we check the two user variables.
15649 ((and gnus-options-subscribe
15650 (string-match gnus-options-subscribe group))
15652 ((and gnus-auto-subscribed-groups
15653 (string-match gnus-auto-subscribed-groups group))
15655 ((and gnus-options-not-subscribe
15656 (string-match gnus-options-not-subscribe group))
15658 ;; Then we go through the list that was retrieved from the .newsrc
15659 ;; file. This list has elements on the form
15660 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15661 ;; is in the reverse order of the options line) is returned.
15663 (let ((regs gnus-newsrc-options-n))
15665 (not (string-match (caar regs) group)))
15666 (setq regs (cdr regs)))
15667 (and regs (cdar regs))))))
15669 (defun gnus-ask-server-for-new-groups ()
15670 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15671 (methods (cons gnus-select-method
15673 (when (gnus-archive-server-wanted-p)
15676 (and (consp gnus-check-new-newsgroups)
15677 gnus-check-new-newsgroups)
15678 gnus-secondary-select-methods))))
15680 (new-date (current-time-string))
15681 group new-newsgroups got-new method hashtb
15682 gnus-override-subscribe-method)
15683 ;; Go through both primary and secondary select methods and
15684 ;; request new newsgroups.
15685 (while (setq method (gnus-server-get-method nil (pop methods)))
15686 (setq new-newsgroups nil)
15687 (setq gnus-override-subscribe-method method)
15688 (when (and (gnus-check-server method)
15689 (gnus-request-newgroups date method))
15692 (setq hashtb (gnus-make-hashtable 100))
15693 (set-buffer nntp-server-buffer)
15694 ;; Enter all the new groups into a hashtable.
15695 (gnus-active-to-gnus-format method hashtb 'ignore))
15696 ;; Now all new groups from `method' are in `hashtb'.
15698 (lambda (group-sym)
15699 (if (or (null (setq group (symbol-name group-sym)))
15700 (not (boundp group-sym))
15701 (null (symbol-value group-sym))
15702 (gnus-gethash group gnus-newsrc-hashtb)
15703 (member group gnus-zombie-list)
15704 (member group gnus-killed-list))
15705 ;; The group is already known.
15707 ;; Make this group active.
15708 (when (symbol-value group-sym)
15709 (gnus-set-active group (symbol-value group-sym)))
15710 ;; Check whether we want it or not.
15711 (let ((do-sub (gnus-matches-options-n group)))
15713 ((eq do-sub 'subscribe)
15715 (gnus-sethash group group gnus-killed-hashtb)
15716 (funcall gnus-subscribe-options-newsgroup-method group))
15717 ((eq do-sub 'ignore)
15721 (gnus-sethash group group gnus-killed-hashtb)
15722 (if gnus-subscribe-hierarchical-interactive
15723 (push group new-newsgroups)
15724 (funcall gnus-subscribe-newsgroup-method group)))))))
15726 (when new-newsgroups
15727 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15728 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15730 (gnus-message 6 "%d new newsgroup%s arrived."
15731 groups (if (> groups 1) "s have" " has")))
15732 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15735 (defun gnus-check-first-time-used ()
15736 (if (or (> (length gnus-newsrc-alist) 1)
15737 (file-exists-p gnus-startup-file)
15738 (file-exists-p (concat gnus-startup-file ".el"))
15739 (file-exists-p (concat gnus-startup-file ".eld")))
15741 (gnus-message 6 "First time user; subscribing you to default groups")
15742 (unless (gnus-read-active-file-p)
15743 (gnus-read-active-file))
15744 (setq gnus-newsrc-last-checked-date (current-time-string))
15745 (let ((groups gnus-default-subscribed-newsgroups)
15749 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15752 (if (null (setq group (symbol-name sym)))
15754 (let ((do-sub (gnus-matches-options-n group)))
15756 ((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)
15762 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15763 gnus-active-hashtb)
15765 (if (gnus-active (car groups))
15766 (gnus-group-change-level
15767 (car groups) gnus-level-default-subscribed gnus-level-killed))
15768 (setq groups (cdr groups)))
15769 (gnus-group-make-help-group)
15770 (and gnus-novice-user
15771 (gnus-message 7 "`A k' to list killed groups"))))))
15773 (defun gnus-subscribe-group (group previous &optional method)
15774 (gnus-group-change-level
15776 (list t group gnus-level-default-subscribed nil nil method)
15778 gnus-level-default-subscribed gnus-level-killed previous t))
15780 ;; `gnus-group-change-level' is the fundamental function for changing
15781 ;; subscription levels of newsgroups. This might mean just changing
15782 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15783 ;; again, which subscribes/unsubscribes a group, which is equally
15784 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15785 ;; from 8-9 to 1-7 means that you remove the group from the list of
15786 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15787 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15788 ;; which is trivial.
15789 ;; ENTRY can either be a string (newsgroup name) or a list (if
15790 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15791 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15793 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15794 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15796 (defun gnus-group-change-level (entry level &optional oldlevel
15797 previous fromkilled)
15798 (let (group info active num)
15799 ;; Glean what info we can from the arguments
15801 (if fromkilled (setq group (nth 1 entry))
15802 (setq group (car (nth 2 entry))))
15803 (setq group entry))
15804 (if (and (stringp entry)
15806 (< oldlevel gnus-level-zombie))
15807 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15808 (if (and (not oldlevel)
15810 (setq oldlevel (gnus-info-level (nth 2 entry)))
15811 (setq oldlevel (or oldlevel 9)))
15812 (if (stringp previous)
15813 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15815 (if (and (>= oldlevel gnus-level-zombie)
15816 (gnus-gethash group gnus-newsrc-hashtb))
15817 ;; We are trying to subscribe a group that is already
15821 (or (gnus-ephemeral-group-p group)
15822 (gnus-dribble-enter
15823 (format "(gnus-group-change-level %S %S %S %S %S)"
15824 group level oldlevel (car (nth 2 previous)) fromkilled)))
15826 ;; Then we remove the newgroup from any old structures, if needed.
15827 ;; If the group was killed, we remove it from the killed or zombie
15828 ;; list. If not, and it is in fact going to be killed, we remove
15829 ;; it from the newsrc hash table and assoc.
15831 ((>= oldlevel gnus-level-zombie)
15832 (if (= oldlevel gnus-level-zombie)
15833 (setq gnus-zombie-list (delete group gnus-zombie-list))
15834 (setq gnus-killed-list (delete group gnus-killed-list))))
15836 (if (and (>= level gnus-level-zombie)
15839 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15841 (setcdr (gnus-gethash (car (nth 3 entry))
15842 gnus-newsrc-hashtb)
15844 (setcdr (cdr entry) (cdddr entry))))))
15846 ;; Finally we enter (if needed) the list where it is supposed to
15847 ;; go, and change the subscription level. If it is to be killed,
15848 ;; we enter it into the killed or zombie list.
15850 ((>= level gnus-level-zombie)
15851 ;; Remove from the hash table.
15852 (gnus-sethash group nil gnus-newsrc-hashtb)
15853 ;; We do not enter foreign groups into the list of dead
15855 (unless (gnus-group-foreign-p group)
15856 (if (= level gnus-level-zombie)
15857 (setq gnus-zombie-list (cons group gnus-zombie-list))
15858 (setq gnus-killed-list (cons group gnus-killed-list)))))
15860 ;; If the list is to be entered into the newsrc assoc, and
15861 ;; it was killed, we have to create an entry in the newsrc
15862 ;; hashtb format and fix the pointers in the newsrc assoc.
15863 (if (< oldlevel gnus-level-zombie)
15864 ;; It was alive, and it is going to stay alive, so we
15865 ;; just change the level and don't change any pointers or
15866 ;; hash table entries.
15867 (setcar (cdaddr entry) level)
15869 (setq info (cdr entry)
15871 (setq active (gnus-active group))
15873 (if active (- (1+ (cdr active)) (car active)) t))
15874 ;; Check whether the group is foreign. If so, the
15875 ;; foreign select method has to be entered into the
15877 (let ((method (or gnus-override-subscribe-method
15878 (gnus-group-method group))))
15879 (if (eq method gnus-select-method)
15880 (setq info (list group level nil))
15881 (setq info (list group level nil nil method)))))
15884 (let ((p gnus-newsrc-alist))
15888 (setq entry (cons info (cddr previous)))
15891 (setcdr (cdr previous) entry)
15892 (gnus-sethash group (cons num (cdr previous))
15893 gnus-newsrc-hashtb))
15894 (setcdr previous entry)
15895 (gnus-sethash group (cons num previous)
15896 gnus-newsrc-hashtb))
15898 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15899 (when gnus-group-change-level-function
15900 (funcall gnus-group-change-level-function group level oldlevel)))))
15902 (defun gnus-kill-newsgroup (newsgroup)
15903 "Obsolete function. Kills a newsgroup."
15904 (gnus-group-change-level
15905 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15907 (defun gnus-check-bogus-newsgroups (&optional confirm)
15908 "Remove bogus newsgroups.
15909 If CONFIRM is non-nil, the user has to confirm the deletion of every
15911 (let ((newsrc (cdr gnus-newsrc-alist))
15912 bogus group entry info)
15913 (gnus-message 5 "Checking bogus newsgroups...")
15914 (unless (gnus-read-active-file-p)
15915 (gnus-read-active-file))
15916 (when (gnus-read-active-file-p)
15917 ;; Find all bogus newsgroup that are subscribed.
15919 (setq info (pop newsrc)
15920 group (gnus-info-group info))
15921 (unless (or (gnus-active group) ; Active
15922 (gnus-info-method info) ; Foreign
15924 (not (gnus-y-or-n-p
15925 (format "Remove bogus newsgroup: %s " group)))))
15926 ;; Found a bogus newsgroup.
15927 (push group bogus)))
15928 ;; Remove all bogus subscribed groups by first killing them, and
15929 ;; then removing them from the list of killed groups.
15931 (when (setq entry (gnus-gethash (setq group (pop bogus))
15932 gnus-newsrc-hashtb))
15933 (gnus-group-change-level entry gnus-level-killed)
15934 (setq gnus-killed-list (delete group gnus-killed-list))))
15935 ;; Then we remove all bogus groups from the list of killed and
15936 ;; zombie groups. They are are removed without confirmation.
15937 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15940 (setq killed (symbol-value (car dead-lists)))
15942 (unless (gnus-active (setq group (pop killed)))
15943 ;; The group is bogus.
15944 ;; !!!Slow as hell.
15945 (set (car dead-lists)
15946 (delete group (symbol-value (car dead-lists))))))
15947 (setq dead-lists (cdr dead-lists))))
15948 (run-hooks 'gnus-check-bogus-groups-hook)
15949 (gnus-message 5 "Checking bogus newsgroups...done"))))
15951 (defun gnus-check-duplicate-killed-groups ()
15952 "Remove duplicates from the list of killed groups."
15954 (let ((killed gnus-killed-list))
15956 (gnus-message 9 "%d" (length killed))
15957 (setcdr killed (delete (car killed) (cdr killed)))
15958 (setq killed (cdr killed)))))
15960 ;; We want to inline a function from gnus-cache, so we cheat here:
15963 (require 'gnus-cache))
15965 (defun gnus-get-unread-articles-in-group (info active &optional update)
15967 ;; Allow the backend to update the info in the group.
15969 (gnus-request-update-info
15970 info (gnus-find-method-for-group (gnus-info-group info))))
15971 (gnus-activate-group (gnus-info-group info) nil t))
15972 (let* ((range (gnus-info-read info))
15974 ;; If a cache is present, we may have to alter the active info.
15975 (when (and gnus-use-cache info)
15976 (inline (gnus-cache-possibly-alter-active
15977 (gnus-info-group info) active)))
15978 ;; Modify the list of read articles according to what articles
15979 ;; are available; then tally the unread articles and add the
15980 ;; number to the group hash table entry.
15982 ((zerop (cdr active))
15985 (setq num (- (1+ (cdr active)) (car active))))
15986 ((not (listp (cdr range)))
15987 ;; Fix a single (num . num) range according to the
15988 ;; active hash table.
15989 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15990 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15991 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15992 ;; Compute number of unread articles.
15993 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15995 ;; The read list is a list of ranges. Fix them according to
15996 ;; the active hash table.
15997 ;; First peel off any elements that are below the lower
15999 (while (and (cdr range)
16001 (or (and (atom (cadr range)) (cadr range))
16003 (if (numberp (car range))
16006 (or (and (numberp (cadr range))
16009 (setcdr (car range)
16010 (or (and (numberp (nth 1 range)) (nth 1 range))
16012 (setcdr range (cddr range)))
16013 ;; Adjust the first element to be the same as the lower limit.
16014 (if (and (not (atom (car range)))
16015 (< (cdar range) (car active)))
16016 (setcdr (car range) (1- (car active))))
16017 ;; Then we want to peel off any elements that are higher
16018 ;; than the upper active limit.
16019 (let ((srange range))
16020 ;; Go past all legal elements.
16021 (while (and (cdr srange)
16022 (<= (or (and (atom (cadr srange))
16024 (caadr srange)) (cdr active)))
16025 (setq srange (cdr srange)))
16027 ;; Nuke all remaining illegal elements.
16028 (setcdr srange nil))
16030 ;; Adjust the final element.
16031 (if (and (not (atom (car srange)))
16032 (> (cdar srange) (cdr active)))
16033 (setcdr (car srange) (cdr active))))
16034 ;; Compute the number of unread articles.
16036 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
16038 (or (and (atom (car range)) (car range))
16040 (setq range (cdr range)))
16041 (setq num (max 0 (- (cdr active) num)))))
16042 ;; Set the number of unread articles.
16044 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
16047 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
16048 ;; and compute how many unread articles there are in each group.
16049 (defun gnus-get-unread-articles (&optional level)
16050 (let* ((newsrc (cdr gnus-newsrc-alist))
16051 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
16054 (cond ((and gnus-activate-foreign-newsgroups
16055 (not (numberp gnus-activate-foreign-newsgroups)))
16056 (1+ gnus-level-subscribed))
16057 ((numberp gnus-activate-foreign-newsgroups)
16058 gnus-activate-foreign-newsgroups)
16061 info group active method)
16062 (gnus-message 5 "Checking new news...")
16065 (setq active (gnus-active (setq group (gnus-info-group
16066 (setq info (pop newsrc))))))
16068 ;; Check newsgroups. If the user doesn't want to check them, or
16069 ;; they can't be checked (for instance, if the news server can't
16070 ;; be reached) we just set the number of unread articles in this
16071 ;; newsgroup to t. This means that Gnus thinks that there are
16072 ;; unread articles, but it has no idea how many.
16073 (if (and (setq method (gnus-info-method info))
16074 (not (gnus-server-equal
16076 (setq method (gnus-server-get-method nil method))))
16077 (not (gnus-secondary-method-p method)))
16078 ;; These groups are foreign. Check the level.
16079 (when (<= (gnus-info-level info) foreign-level)
16080 (setq active (gnus-activate-group group 'scan))
16081 (unless (inline (gnus-virtual-group-p group))
16082 (inline (gnus-close-group group)))
16083 (when (fboundp (intern (concat (symbol-name (car method))
16084 "-request-update-info")))
16085 (inline (gnus-request-update-info info method))))
16086 ;; These groups are native or secondary.
16087 (when (and (<= (gnus-info-level info) level)
16088 (not gnus-read-active-file))
16089 (setq active (gnus-activate-group group 'scan))
16090 (inline (gnus-close-group group))))
16092 ;; Get the number of unread articles in the group.
16094 (inline (gnus-get-unread-articles-in-group info active))
16095 ;; The group couldn't be reached, so we nix out the number of
16096 ;; unread articles and stuff.
16097 (gnus-set-active group nil)
16098 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
16100 (gnus-message 5 "Checking new news...done")))
16102 ;; Create a hash table out of the newsrc alist. The `car's of the
16103 ;; alist elements are used as keys.
16104 (defun gnus-make-hashtable-from-newsrc-alist ()
16105 (let ((alist gnus-newsrc-alist)
16106 (ohashtb gnus-newsrc-hashtb)
16108 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
16110 (setq prev (setq gnus-newsrc-alist
16111 (if (equal (caar gnus-newsrc-alist)
16114 (cons (list "dummy.group" 0 nil) alist)))))
16118 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
16120 gnus-newsrc-hashtb)
16122 alist (cdr alist)))))
16124 (defun gnus-make-hashtable-from-killed ()
16125 "Create a hash table from the killed and zombie lists."
16126 (let ((lists '(gnus-killed-list gnus-zombie-list))
16128 (setq gnus-killed-hashtb
16129 (gnus-make-hashtable
16130 (+ (length gnus-killed-list) (length gnus-zombie-list))))
16131 (while (setq list (pop lists))
16132 (setq list (symbol-value list))
16134 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16136 (defun gnus-activate-group (group &optional scan dont-check method)
16137 ;; Check whether a group has been activated or not.
16138 ;; If SCAN, request a scan of that group as well.
16139 (let ((method (or method (gnus-find-method-for-group group)))
16141 (and (gnus-check-server method)
16142 ;; We escape all bugs and quit here to make it possible to
16143 ;; continue if a group is so out-there that it reports bugs
16147 (gnus-check-backend-function 'request-scan (car method))
16148 (gnus-request-scan group method))
16151 (gnus-request-group group dont-check method)
16155 (set-buffer nntp-server-buffer)
16156 (goto-char (point-min))
16157 ;; Parse the result we got from `gnus-request-group'.
16158 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16160 (goto-char (match-beginning 1))
16162 group (setq active (cons (read (current-buffer))
16163 (read (current-buffer)))))
16164 ;; Return the new active info.
16167 (defun gnus-update-read-articles (group unread)
16168 "Update the list of read and ticked articles in GROUP using the
16169 UNREAD and TICKED lists.
16170 Note: UNSELECTED has to be sorted over `<'.
16171 Returns whether the updating was successful."
16172 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16173 (entry (gnus-gethash group gnus-newsrc-hashtb))
16174 (info (nth 2 entry))
16176 (unread (sort (copy-sequence unread) '<))
16178 (if (or (not info) (not active))
16179 ;; There is no info on this group if it was, in fact,
16180 ;; killed. Gnus stores no information on killed groups, so
16181 ;; there's nothing to be done.
16182 ;; One could store the information somewhere temporarily,
16183 ;; perhaps... Hmmm...
16185 ;; Remove any negative articles numbers.
16186 (while (and unread (< (car unread) 0))
16187 (setq unread (cdr unread)))
16188 ;; Remove any expired article numbers
16189 (while (and unread (< (car unread) (car active)))
16190 (setq unread (cdr unread)))
16191 ;; Compute the ranges of read articles by looking at the list of
16192 ;; unread articles.
16194 (if (/= (car unread) prev)
16195 (setq read (cons (if (= prev (1- (car unread))) prev
16196 (cons prev (1- (car unread)))) read)))
16197 (setq prev (1+ (car unread)))
16198 (setq unread (cdr unread)))
16199 (when (<= prev (cdr active))
16200 (setq read (cons (cons prev (cdr active)) read)))
16201 ;; Enter this list into the group info.
16202 (gnus-info-set-read
16203 info (if (> (length read) 1) (nreverse read) read))
16204 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16205 (gnus-get-unread-articles-in-group info (gnus-active group))
16208 (defun gnus-make-articles-unread (group articles)
16209 "Mark ARTICLES in GROUP as unread."
16210 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16211 (gnus-gethash (gnus-group-real-name group)
16212 gnus-newsrc-hashtb))))
16213 (ranges (gnus-info-read info))
16216 (when (gnus-member-of-range
16217 (setq article (pop articles)) ranges)
16218 (setq news (cons article news))))
16220 (gnus-info-set-read
16221 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16222 (gnus-group-update-group group t))))
16224 ;; Enter all dead groups into the hashtb.
16225 (defun gnus-update-active-hashtb-from-killed ()
16226 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16227 (lists (list gnus-killed-list gnus-zombie-list))
16230 (setq killed (car lists))
16232 (gnus-sethash (car killed) nil hashtb)
16233 (setq killed (cdr killed)))
16234 (setq lists (cdr lists)))))
16236 (defun gnus-get-killed-groups ()
16237 "Go through the active hashtb and all all unknown groups as killed."
16238 ;; First make sure active file has been read.
16239 (unless (gnus-read-active-file-p)
16240 (let ((gnus-read-active-file t))
16241 (gnus-read-active-file)))
16242 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16243 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16247 (group (symbol-name sym)))
16248 (if (or (null group)
16249 (gnus-gethash group gnus-killed-hashtb)
16250 (gnus-gethash group gnus-newsrc-hashtb))
16252 (let ((do-sub (gnus-matches-options-n group)))
16253 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16255 (setq groups (1+ groups))
16256 (setq gnus-killed-list
16257 (cons group gnus-killed-list))
16258 (gnus-sethash group group gnus-killed-hashtb))))))
16259 gnus-active-hashtb))
16261 ;; Get the active file(s) from the backend(s).
16262 (defun gnus-read-active-file ()
16263 (gnus-group-set-mode-line)
16266 (if (gnus-check-server gnus-select-method)
16267 ;; The native server is available.
16268 (cons gnus-select-method gnus-secondary-select-methods)
16269 ;; The native server is down, so we just do the
16271 gnus-secondary-select-methods)
16272 ;; Also read from the archive server.
16273 (when (gnus-archive-server-wanted-p)
16274 (list "archive"))))
16276 (setq gnus-have-read-active-file nil)
16278 (set-buffer nntp-server-buffer)
16280 (let* ((method (if (stringp (car methods))
16281 (gnus-server-get-method nil (car methods))
16283 (where (nth 1 method))
16284 (mesg (format "Reading active file%s via %s..."
16285 (if (and where (not (zerop (length where))))
16286 (concat " from " where) "")
16288 (gnus-message 5 mesg)
16289 (when (gnus-check-server method)
16290 ;; Request that the backend scan its incoming messages.
16291 (and (gnus-check-backend-function 'request-scan (car method))
16292 (gnus-request-scan nil method))
16294 ((and (eq gnus-read-active-file 'some)
16295 (gnus-check-backend-function 'retrieve-groups (car method)))
16296 (let ((newsrc (cdr gnus-newsrc-alist))
16297 (gmethod (gnus-server-get-method nil method))
16299 (while (setq info (pop newsrc))
16300 (when (gnus-server-equal
16301 (gnus-find-method-for-group
16302 (gnus-info-group info) info)
16304 (push (gnus-group-real-name (gnus-info-group info))
16307 (gnus-check-server method)
16308 (setq list-type (gnus-retrieve-groups groups method))
16312 1.2 "Cannot read partial active file from %s server."
16314 ((eq list-type 'active)
16315 (gnus-active-to-gnus-format method gnus-active-hashtb))
16317 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16319 (if (not (gnus-request-list method))
16320 (unless (equal method gnus-message-archive-method)
16321 (gnus-error 1 "Cannot read active file from %s server."
16323 (gnus-message 5 mesg)
16324 (gnus-active-to-gnus-format method gnus-active-hashtb)
16325 ;; We mark this active file as read.
16326 (push method gnus-have-read-active-file)
16327 (gnus-message 5 "%sdone" mesg))))))
16328 (setq methods (cdr methods))))))
16330 ;; Read an active file and place the results in `gnus-active-hashtb'.
16331 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16333 (setq method gnus-select-method))
16334 (let ((cur (current-buffer))
16336 (if (and gnus-active-hashtb
16337 (not (equal method gnus-select-method)))
16339 (setq gnus-active-hashtb
16340 (if (equal method gnus-select-method)
16341 (gnus-make-hashtable
16342 (count-lines (point-min) (point-max)))
16343 (gnus-make-hashtable 4096)))))))
16344 ;; Delete unnecessary lines.
16345 (goto-char (point-min))
16346 (while (search-forward "\nto." nil t)
16347 (delete-region (1+ (match-beginning 0))
16348 (progn (forward-line 1) (point))))
16349 (or (string= gnus-ignored-newsgroups "")
16351 (goto-char (point-min))
16352 (delete-matching-lines gnus-ignored-newsgroups)))
16353 ;; Make the group names readable as a lisp expression even if they
16354 ;; contain special characters.
16355 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16356 (goto-char (point-max))
16357 (while (re-search-backward "[][';?()#]" nil t)
16359 ;; If these are groups from a foreign select method, we insert the
16360 ;; group prefix in front of the group names.
16361 (and method (not (gnus-server-equal
16362 (gnus-server-get-method nil method)
16363 (gnus-server-get-method nil gnus-select-method)))
16364 (let ((prefix (gnus-group-prefixed-name "" method)))
16365 (goto-char (point-min))
16366 (while (and (not (eobp))
16367 (progn (insert prefix)
16368 (zerop (forward-line 1)))))))
16369 ;; Store the active file in a hash table.
16370 (goto-char (point-min))
16371 (if (string-match "%[oO]" gnus-group-line-format)
16372 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16373 ;; If we want information on moderated groups, we use this
16375 (let* ((mod-hashtb (make-vector 7 0))
16376 (m (intern "m" mod-hashtb))
16378 (while (not (eobp))
16379 (condition-case nil
16381 (narrow-to-region (point) (gnus-point-at-eol))
16382 (setq group (let ((obarray hashtb)) (read cur)))
16383 (if (and (numberp (setq max (read cur)))
16384 (numberp (setq min (read cur)))
16386 (skip-chars-forward " \t")
16388 (or (= (following-char) ?=)
16389 (= (following-char) ?x)
16390 (= (following-char) ?j)))))
16391 (set group (cons min max))
16393 ;; Enter moderated groups into a list.
16394 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16395 (setq gnus-moderated-list
16396 (cons (symbol-name group) gnus-moderated-list))))
16403 ;; And if we do not care about moderation, we use this loop,
16404 ;; which is faster.
16405 (let (group max min)
16406 (while (not (eobp))
16409 (narrow-to-region (point) (gnus-point-at-eol))
16410 ;; group gets set to a symbol interned in the hash table
16411 ;; (what a hack!!) - jwz
16412 (setq group (let ((obarray hashtb)) (read cur)))
16413 (if (and (numberp (setq max (read cur)))
16414 (numberp (setq min (read cur)))
16416 (skip-chars-forward " \t")
16418 (or (= (following-char) ?=)
16419 (= (following-char) ?x)
16420 (= (following-char) ?j)))))
16421 (set group (cons min max))
16429 (gnus-message 3 "Warning - illegal active: %s"
16431 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16433 (forward-line 1))))))
16435 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16436 ;; Parse a "groups" active file.
16437 (let ((cur (current-buffer))
16439 (if (and method gnus-active-hashtb)
16441 (setq gnus-active-hashtb
16442 (gnus-make-hashtable
16443 (count-lines (point-min) (point-max)))))))
16444 (prefix (and method
16445 (not (gnus-server-equal
16446 (gnus-server-get-method nil method)
16447 (gnus-server-get-method nil gnus-select-method)))
16448 (gnus-group-prefixed-name "" method))))
16450 (goto-char (point-min))
16451 ;; We split this into to separate loops, one with the prefix
16452 ;; and one without to speed the reading up somewhat.
16454 (let (min max opoint group)
16455 (while (not (eobp))
16458 (read cur) (read cur)
16459 (setq min (read cur)
16462 (skip-chars-forward " \t")
16465 (set (let ((obarray hashtb)) (read cur))
16467 (error (and group (symbolp group) (set group nil))))
16469 (let (min max group)
16470 (while (not (eobp))
16472 (if (= (following-char) ?2)
16474 (read cur) (read cur)
16475 (setq min (read cur)
16477 (set (setq group (let ((obarray hashtb)) (read cur)))
16479 (error (and group (symbolp group) (set group nil))))
16480 (forward-line 1))))))
16482 (defun gnus-read-newsrc-file (&optional force)
16483 "Read startup file.
16484 If FORCE is non-nil, the .newsrc file is read."
16485 ;; Reset variables that might be defined in the .newsrc.eld file.
16486 (let ((variables gnus-variable-list))
16488 (set (car variables) nil)
16489 (setq variables (cdr variables))))
16490 (let* ((newsrc-file gnus-current-startup-file)
16491 (quick-file (concat newsrc-file ".el")))
16493 ;; We always load the .newsrc.eld file. If always contains
16494 ;; much information that can not be gotten from the .newsrc
16495 ;; file (ticked articles, killed groups, foreign methods, etc.)
16496 (gnus-read-newsrc-el-file quick-file)
16498 (if (and (file-exists-p gnus-current-startup-file)
16500 (and (file-newer-than-file-p newsrc-file quick-file)
16501 (file-newer-than-file-p newsrc-file
16502 (concat quick-file "d")))
16503 (not gnus-newsrc-alist)))
16504 ;; We read the .newsrc file. Note that if there if a
16505 ;; .newsrc.eld file exists, it has already been read, and
16506 ;; the `gnus-newsrc-hashtb' has been created. While reading
16507 ;; the .newsrc file, Gnus will only use the information it
16508 ;; can find there for changing the data already read -
16509 ;; ie. reading the .newsrc file will not trash the data
16510 ;; already read (except for read articles).
16512 (gnus-message 5 "Reading %s..." newsrc-file)
16513 (set-buffer (find-file-noselect newsrc-file))
16514 (buffer-disable-undo (current-buffer))
16515 (gnus-newsrc-to-gnus-format)
16516 (kill-buffer (current-buffer))
16517 (gnus-message 5 "Reading %s...done" newsrc-file)))
16519 ;; Read any slave files.
16521 (gnus-master-read-slave-newsrc))
16523 ;; Convert old to new.
16524 (gnus-convert-old-newsrc))))
16526 (defun gnus-continuum-version (version)
16527 "Return VERSION as a floating point number."
16528 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16529 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16530 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16531 (number (match-string 2 version))
16533 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16534 (setq major (string-to-number (match-string 1 number)))
16535 (setq minor (string-to-number (match-string 2 number)))
16536 (setq least (if (match-beginning 3)
16537 (string-to-number (match-string 3 number))
16541 (format "%s00%02d%02d"
16543 ((member alpha '("(ding)" "d")) "4.99")
16544 ((member alpha '("September" "s")) "5.01")
16545 ((member alpha '("Red" "r")) "5.03"))
16547 (format "%d.%02d%02d" major minor least))))))
16549 (defun gnus-convert-old-newsrc ()
16550 "Convert old newsrc into the new format, if needed."
16551 (let ((fcv (and gnus-newsrc-file-version
16552 (gnus-continuum-version gnus-newsrc-file-version))))
16554 ;; No .newsrc.eld file was loaded.
16556 ;; Gnus 5 .newsrc.eld was loaded.
16557 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16558 (gnus-convert-old-ticks)))))
16560 (defun gnus-convert-old-ticks ()
16561 (let ((newsrc (cdr gnus-newsrc-alist))
16562 marks info dormant ticked)
16563 (while (setq info (pop newsrc))
16564 (when (setq marks (gnus-info-marks info))
16565 (setq dormant (cdr (assq 'dormant marks))
16566 ticked (cdr (assq 'tick marks)))
16567 (when (or dormant ticked)
16568 (gnus-info-set-read
16571 (gnus-info-read info)
16572 (nconc (gnus-uncompress-range dormant)
16573 (gnus-uncompress-range ticked)))))))))
16575 (defun gnus-read-newsrc-el-file (file)
16576 (let ((ding-file (concat file "d")))
16577 ;; We always, always read the .eld file.
16578 (gnus-message 5 "Reading %s..." ding-file)
16579 (let (gnus-newsrc-assoc)
16580 (condition-case nil
16581 (load ding-file t t t)
16583 (gnus-error 1 "Error in %s" ding-file)))
16584 (when gnus-newsrc-assoc
16585 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16586 (gnus-make-hashtable-from-newsrc-alist)
16587 (when (file-newer-than-file-p file ding-file)
16588 ;; Old format quick file
16589 (gnus-message 5 "Reading %s..." file)
16590 ;; The .el file is newer than the .eld file, so we read that one
16592 (gnus-read-old-newsrc-el-file file))))
16594 ;; Parse the old-style quick startup file
16595 (defun gnus-read-old-newsrc-el-file (file)
16596 (let (newsrc killed marked group m info)
16598 (let ((gnus-killed-assoc nil)
16599 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16601 (condition-case nil
16604 (setq newsrc gnus-newsrc-assoc
16605 killed gnus-killed-assoc
16606 marked gnus-marked-assoc)))
16607 (setq gnus-newsrc-alist nil)
16608 (while (setq group (pop newsrc))
16609 (if (setq info (gnus-get-info (car group)))
16611 (gnus-info-set-read info (cddr group))
16612 (gnus-info-set-level
16613 info (if (nth 1 group) gnus-level-default-subscribed
16614 gnus-level-default-unsubscribed))
16615 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16618 (if (nth 1 group) gnus-level-default-subscribed
16619 gnus-level-default-unsubscribed)
16621 gnus-newsrc-alist))
16622 ;; Copy marks into info.
16623 (when (setq m (assoc (car group) marked))
16624 (unless (nthcdr 3 info)
16625 (nconc info (list nil)))
16626 (gnus-info-set-marks
16627 info (list (cons 'tick (gnus-compress-sequence
16628 (sort (cdr m) '<) t))))))
16629 (setq newsrc killed)
16631 (setcar newsrc (caar newsrc))
16632 (setq newsrc (cdr newsrc)))
16633 (setq gnus-killed-list killed))
16634 ;; The .el file version of this variable does not begin with
16635 ;; "options", while the .eld version does, so we just add it if it
16638 gnus-newsrc-options
16640 (and (not (string-match "^ *options" gnus-newsrc-options))
16641 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16642 (and (not (string-match "\n$" gnus-newsrc-options))
16643 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16644 ;; Finally, if we read some options lines, we parse them.
16645 (or (string= gnus-newsrc-options "")
16646 (gnus-newsrc-parse-options gnus-newsrc-options))))
16648 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16649 (gnus-make-hashtable-from-newsrc-alist)))
16651 (defun gnus-make-newsrc-file (file)
16652 "Make server dependent file name by catenating FILE and server host name."
16653 (let* ((file (expand-file-name file nil))
16654 (real-file (concat file "-" (nth 1 gnus-select-method))))
16655 (if (or (file-exists-p real-file)
16656 (file-exists-p (concat real-file ".el"))
16657 (file-exists-p (concat real-file ".eld")))
16660 (defun gnus-newsrc-to-gnus-format ()
16661 (setq gnus-newsrc-options "")
16662 (setq gnus-newsrc-options-n nil)
16664 (or gnus-active-hashtb
16665 (setq gnus-active-hashtb (make-vector 4095 0)))
16666 (let ((buf (current-buffer))
16667 (already-read (> (length gnus-newsrc-alist) 1))
16668 group subscribed options-symbol newsrc Options-symbol
16670 (goto-char (point-min))
16671 ;; We intern the symbol `options' in the active hashtb so that we
16672 ;; can `eq' against it later.
16673 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16674 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16676 (while (not (eobp))
16677 ;; We first read the first word on the line by narrowing and
16678 ;; then reading into `gnus-active-hashtb'. Most groups will
16679 ;; already exist in that hashtb, so this will save some string
16683 (progn (skip-chars-forward "^ \t!:\n") (point)))
16684 (goto-char (point-min))
16686 (and (/= (point-min) (point-max))
16687 (let ((obarray gnus-active-hashtb)) (read buf))))
16689 ;; Now, the symbol we have read is either `options' or a group
16690 ;; name. If it is an options line, we just add it to a string.
16692 ((or (eq symbol options-symbol)
16693 (eq symbol Options-symbol))
16694 (setq gnus-newsrc-options
16695 ;; This concating is quite inefficient, but since our
16696 ;; thorough studies show that approx 99.37% of all
16697 ;; .newsrc files only contain a single options line, we
16698 ;; don't give a damn, frankly, my dear.
16699 (concat gnus-newsrc-options
16701 (gnus-point-at-bol)
16702 ;; Options may continue on the next line.
16703 (or (and (re-search-forward "^[^ \t]" nil 'move)
16704 (progn (beginning-of-line) (point)))
16708 ;; Group names can be just numbers.
16709 (when (numberp symbol)
16710 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16711 (or (boundp symbol) (set symbol nil))
16712 ;; It was a group name.
16713 (setq subscribed (= (following-char) ?:)
16714 group (symbol-name symbol)
16717 ;; If the line ends here, this is clearly a buggy line, so
16718 ;; we put point a the beginning of line and let the cond
16719 ;; below do the error handling.
16720 (beginning-of-line)
16721 ;; We skip to the beginning of the ranges.
16722 (skip-chars-forward "!: \t"))
16723 ;; We are now at the beginning of the list of read articles.
16724 ;; We read them range by range.
16727 ((looking-at "[0-9]+")
16728 ;; We narrow and read a number instead of buffer-substring/
16729 ;; string-to-int because it's faster. narrow/widen is
16730 ;; faster than save-restriction/narrow, and save-restriction
16731 ;; produces a garbage object.
16733 (narrow-to-region (match-beginning 0) (match-end 0))
16736 ;; If the next character is a dash, then this is a range.
16737 (if (= (following-char) ?-)
16739 ;; We read the upper bound of the range.
16741 (if (not (looking-at "[0-9]+"))
16742 ;; This is a buggy line, by we pretend that
16743 ;; it's kinda OK. Perhaps the user should be
16745 (setq reads (cons num1 reads))
16750 (narrow-to-region (match-beginning 0)
16755 ;; It was just a simple number, so we add it to the
16757 (setq reads (cons num1 reads)))
16758 ;; If the next char in ?\n, then we have reached the end
16759 ;; of the line and return nil.
16760 (/= (following-char) ?\n))
16761 ((= (following-char) ?\n)
16762 ;; End of line, so we end.
16765 ;; Not numbers and not eol, so this might be a buggy
16768 ;; If it was eob instead of ?\n, we allow it.
16770 ;; The line was buggy.
16772 (gnus-error 3.1 "Mangled line: %s"
16773 (buffer-substring (gnus-point-at-bol)
16774 (gnus-point-at-eol)))))
16776 ;; Skip past ", ". Spaces are illegal in these ranges, but
16777 ;; we allow them, because it's a common mistake to put a
16778 ;; space after the comma.
16779 (skip-chars-forward ", "))
16781 ;; We have already read .newsrc.eld, so we gently update the
16782 ;; data in the hash table with the information we have just
16785 (let ((info (gnus-get-info group))
16788 ;; There is an entry for this file in the alist.
16790 (gnus-info-set-read info (nreverse reads))
16791 ;; We update the level very gently. In fact, we
16792 ;; only change it if there's been a status change
16793 ;; from subscribed to unsubscribed, or vice versa.
16794 (setq level (gnus-info-level info))
16795 (cond ((and (<= level gnus-level-subscribed)
16797 (setq level (if reads
16798 gnus-level-default-unsubscribed
16799 (1+ gnus-level-default-unsubscribed))))
16800 ((and (> level gnus-level-subscribed) subscribed)
16801 (setq level gnus-level-default-subscribed)))
16802 (gnus-info-set-level info level))
16803 ;; This is a new group.
16804 (setq info (list group
16806 gnus-level-default-subscribed
16808 (1+ gnus-level-subscribed)
16809 gnus-level-default-unsubscribed))
16810 (nreverse reads))))
16811 (setq newsrc (cons info newsrc))))))
16814 (setq newsrc (nreverse newsrc))
16816 (if (not already-read)
16818 ;; We now have two newsrc lists - `newsrc', which is what we
16819 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16820 ;; what we've read from .newsrc.eld. We have to merge these
16821 ;; lists. We do this by "attaching" any (foreign) groups in the
16822 ;; gnus-newsrc-alist to the (native) group that precedes them.
16823 (let ((rc (cdr gnus-newsrc-alist))
16824 (prev gnus-newsrc-alist)
16827 (or (null (nth 4 (car rc))) ; It's a native group.
16828 (assoc (caar rc) newsrc) ; It's already in the alist.
16829 (if (setq entry (assoc (caar prev) newsrc))
16830 (setcdr (setq mentry (memq entry newsrc))
16831 (cons (car rc) (cdr mentry)))
16832 (setq newsrc (cons (car rc) newsrc))))
16836 (setq gnus-newsrc-alist newsrc)
16837 ;; We make the newsrc hashtb.
16838 (gnus-make-hashtable-from-newsrc-alist)
16840 ;; Finally, if we read some options lines, we parse them.
16841 (or (string= gnus-newsrc-options "")
16842 (gnus-newsrc-parse-options gnus-newsrc-options))))
16844 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16845 ;; The return value will be a list on the form
16846 ;; ((regexp1 . ignore)
16847 ;; (regexp2 . subscribe)...)
16848 ;; When handling new newsgroups, groups that match a `ignore' regexp
16849 ;; will be ignored, and groups that match a `subscribe' regexp will be
16850 ;; subscribed. A line like
16851 ;; options -n !all rec.all
16852 ;; will lead to a list that looks like
16853 ;; (("^rec\\..+" . subscribe)
16854 ;; ("^.+" . ignore))
16855 ;; So all "rec.*" groups will be subscribed, while all the other
16856 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16857 ;; different from "options -n rec.all !all".
16858 (defun gnus-newsrc-parse-options (options)
16861 (gnus-set-work-buffer)
16862 (insert (regexp-quote options))
16863 ;; First we treat all continuation lines.
16864 (goto-char (point-min))
16865 (while (re-search-forward "\n[ \t]+" nil t)
16866 (replace-match " " t t))
16867 ;; Then we transform all "all"s into ".+"s.
16868 (goto-char (point-min))
16869 (while (re-search-forward "\\ball\\b" nil t)
16870 (replace-match ".+" t t))
16871 (goto-char (point-min))
16872 ;; We remove all other options than the "-n" ones.
16873 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16874 (replace-match " ")
16876 (goto-char (point-min))
16878 ;; We are only interested in "options -n" lines - we
16879 ;; ignore the other option lines.
16880 (while (re-search-forward "[ \t]-n" nil t)
16882 (or (save-excursion
16883 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16885 (gnus-point-at-eol)))
16886 ;; Search for all "words"...
16887 (while (re-search-forward "[^ \t,\n]+" eol t)
16888 (if (= (char-after (match-beginning 0)) ?!)
16889 ;; If the word begins with a bang (!), this is a "not"
16890 ;; spec. We put this spec (minus the bang) and the
16891 ;; symbol `ignore' into the list.
16892 (setq out (cons (cons (concat
16893 "^" (buffer-substring
16894 (1+ (match-beginning 0))
16897 ;; There was no bang, so this is a "yes" spec.
16898 (setq out (cons (cons (concat "^" (match-string 0))
16899 'subscribe) out)))))
16901 (setq gnus-newsrc-options-n out))))
16903 (defun gnus-save-newsrc-file (&optional force)
16904 "Save .newsrc file."
16905 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16906 ;; from the variable gnus-newsrc-alist.
16907 (when (and (or gnus-newsrc-alist gnus-killed-list)
16908 gnus-current-startup-file)
16910 (if (and (or gnus-use-dribble-file gnus-slave)
16912 (or (not gnus-dribble-buffer)
16913 (not (buffer-name gnus-dribble-buffer))
16914 (zerop (save-excursion
16915 (set-buffer gnus-dribble-buffer)
16917 (gnus-message 4 "(No changes need to be saved)")
16918 (run-hooks 'gnus-save-newsrc-hook)
16920 (gnus-slave-save-newsrc)
16922 (when gnus-save-newsrc-file
16923 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16924 (gnus-gnus-to-newsrc-format)
16925 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16926 ;; Save .newsrc.eld.
16927 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16928 (make-local-variable 'version-control)
16929 (setq version-control 'never)
16930 (setq buffer-file-name
16931 (concat gnus-current-startup-file ".eld"))
16932 (setq default-directory (file-name-directory buffer-file-name))
16933 (gnus-add-current-to-buffer-list)
16934 (buffer-disable-undo (current-buffer))
16936 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16937 (gnus-gnus-to-quick-newsrc-format)
16938 (run-hooks 'gnus-save-quick-newsrc-hook)
16940 (kill-buffer (current-buffer))
16942 5 "Saving %s.eld...done" gnus-current-startup-file))
16943 (gnus-dribble-delete-file)
16944 (gnus-group-set-mode-line)))))
16946 (defun gnus-gnus-to-quick-newsrc-format ()
16947 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16948 (insert ";; Gnus startup file.\n")
16949 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16950 (insert ";; to read .newsrc.\n")
16951 (insert "(setq gnus-newsrc-file-version "
16952 (prin1-to-string gnus-version) ")\n")
16954 (if gnus-save-killed-list gnus-variable-list
16955 ;; Remove the `gnus-killed-list' from the list of variables
16956 ;; to be saved, if required.
16957 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16958 ;; Peel off the "dummy" group.
16959 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16961 ;; Insert the variables into the file.
16963 (when (and (boundp (setq variable (pop variables)))
16964 (symbol-value variable))
16965 (insert "(setq " (symbol-name variable) " '")
16966 (prin1 (symbol-value variable) (current-buffer))
16969 (defun gnus-gnus-to-newsrc-format ()
16970 ;; Generate and save the .newsrc file.
16972 (set-buffer (create-file-buffer gnus-current-startup-file))
16973 (let ((newsrc (cdr gnus-newsrc-alist))
16974 (standard-output (current-buffer))
16975 info ranges range method)
16976 (setq buffer-file-name gnus-current-startup-file)
16977 (setq default-directory (file-name-directory buffer-file-name))
16978 (buffer-disable-undo (current-buffer))
16981 (if gnus-newsrc-options (insert gnus-newsrc-options))
16982 ;; Write subscribed and unsubscribed.
16983 (while (setq info (pop newsrc))
16984 ;; Don't write foreign groups to .newsrc.
16985 (when (or (null (setq method (gnus-info-method info)))
16986 (equal method "native")
16987 (gnus-server-equal method gnus-select-method))
16988 (insert (gnus-info-group info)
16989 (if (> (gnus-info-level info) gnus-level-subscribed)
16991 (when (setq ranges (gnus-info-read info))
16993 (if (not (listp (cdr ranges)))
16994 (if (= (car ranges) (cdr ranges))
16995 (princ (car ranges))
16996 (princ (car ranges))
16998 (princ (cdr ranges)))
16999 (while (setq range (pop ranges))
17000 (if (or (atom range) (= (car range) (cdr range)))
17001 (princ (or (and (atom range) range) (car range)))
17002 (princ (car range))
17004 (princ (cdr range)))
17005 (if ranges (insert ",")))))
17007 (make-local-variable 'version-control)
17008 (setq version-control 'never)
17009 ;; It has been reported that sometime the modtime on the .newsrc
17010 ;; file seems to be off. We really do want to overwrite it, so
17011 ;; we clear the modtime here before saving. It's a bit odd,
17013 ;; sometimes the modtime clear isn't sufficient. most brute force:
17014 ;; delete the silly thing entirely first. but this fails to provide
17015 ;; such niceties as .newsrc~ creation.
17016 (if gnus-modtime-botch
17017 (delete-file gnus-startup-file)
17018 (clear-visited-file-modtime))
17019 (run-hooks 'gnus-save-standard-newsrc-hook)
17021 (kill-buffer (current-buffer)))))
17025 ;;; Slave functions.
17028 (defun gnus-slave-save-newsrc ()
17030 (set-buffer gnus-dribble-buffer)
17032 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
17033 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
17035 (defun gnus-master-read-slave-newsrc ()
17038 (file-name-directory gnus-current-startup-file)
17042 (file-name-nondirectory gnus-current-startup-file)
17046 (if (not slave-files)
17047 () ; There are no slave files to read.
17048 (gnus-message 7 "Reading slave newsrcs...")
17050 (set-buffer (get-buffer-create " *gnus slave*"))
17051 (buffer-disable-undo (current-buffer))
17053 (sort (mapcar (lambda (file)
17054 (list (nth 5 (file-attributes file)) file))
17057 (or (< (caar f1) (caar f2))
17058 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
17061 (setq file (nth 1 (car slave-files)))
17062 (insert-file-contents file)
17063 (if (condition-case ()
17065 (eval-buffer (current-buffer))
17068 (gnus-error 3.2 "Possible error in %s" file)
17070 (or gnus-slave ; Slaves shouldn't delete these files.
17074 (setq slave-files (cdr slave-files))))
17075 (gnus-message 7 "Reading slave newsrcs...done"))))
17079 ;;; Group description.
17082 (defun gnus-read-all-descriptions-files ()
17083 (let ((methods (cons gnus-select-method
17085 (when (gnus-archive-server-wanted-p)
17087 gnus-secondary-select-methods))))
17089 (gnus-read-descriptions-file (car methods))
17090 (setq methods (cdr methods)))
17093 (defun gnus-read-descriptions-file (&optional method)
17094 (let ((method (or method gnus-select-method))
17096 (when (stringp method)
17097 (setq method (gnus-server-to-method method)))
17098 ;; We create the hashtable whether we manage to read the desc file
17099 ;; to avoid trying to re-read after a failed read.
17100 (or gnus-description-hashtb
17101 (setq gnus-description-hashtb
17102 (gnus-make-hashtable (length gnus-active-hashtb))))
17103 ;; Mark this method's desc file as read.
17104 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
17105 gnus-description-hashtb)
17107 (gnus-message 5 "Reading descriptions file via %s..." (car method))
17109 ((not (gnus-check-server method))
17110 (gnus-message 1 "Couldn't open server")
17112 ((not (gnus-request-list-newsgroups method))
17113 (gnus-message 1 "Couldn't read newsgroups descriptions")
17118 (set-buffer nntp-server-buffer)
17119 (goto-char (point-min))
17120 (when (or (search-forward "\n.\n" nil t)
17121 (goto-char (point-max)))
17122 (beginning-of-line)
17123 (narrow-to-region (point-min) (point)))
17124 ;; If these are groups from a foreign select method, we insert the
17125 ;; group prefix in front of the group names.
17126 (and method (not (gnus-server-equal
17127 (gnus-server-get-method nil method)
17128 (gnus-server-get-method nil gnus-select-method)))
17129 (let ((prefix (gnus-group-prefixed-name "" method)))
17130 (goto-char (point-min))
17131 (while (and (not (eobp))
17132 (progn (insert prefix)
17133 (zerop (forward-line 1)))))))
17134 (goto-char (point-min))
17135 (while (not (eobp))
17136 ;; If we get an error, we set group to 0, which is not a
17140 (let ((obarray gnus-description-hashtb))
17141 ;; Group is set to a symbol interned in this
17143 (read nntp-server-buffer))
17145 (skip-chars-forward " \t")
17146 ;; ... which leads to this line being effectively ignored.
17147 (and (symbolp group)
17148 (set group (buffer-substring
17149 (point) (progn (end-of-line) (point)))))
17150 (forward-line 1))))
17151 (gnus-message 5 "Reading descriptions file...done")
17154 (defun gnus-group-get-description (group)
17155 "Get the description of a group by sending XGTITLE to the server."
17156 (when (gnus-request-group-description group)
17158 (set-buffer nntp-server-buffer)
17159 (goto-char (point-min))
17160 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17161 (match-string 1)))))
17165 ;;; Buffering of read articles.
17168 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17169 (defvar gnus-backlog-articles nil)
17170 (defvar gnus-backlog-hashtb nil)
17172 (defun gnus-backlog-buffer ()
17173 "Return the backlog buffer."
17174 (or (get-buffer gnus-backlog-buffer)
17176 (set-buffer (get-buffer-create gnus-backlog-buffer))
17177 (buffer-disable-undo (current-buffer))
17178 (setq buffer-read-only t)
17179 (gnus-add-current-to-buffer-list)
17180 (get-buffer gnus-backlog-buffer))))
17182 (defun gnus-backlog-setup ()
17183 "Initialize backlog variables."
17184 (unless gnus-backlog-hashtb
17185 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17187 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17189 (defun gnus-backlog-shutdown ()
17190 "Clear all backlog variables and buffers."
17191 (when (get-buffer gnus-backlog-buffer)
17192 (kill-buffer gnus-backlog-buffer))
17193 (setq gnus-backlog-hashtb nil
17194 gnus-backlog-articles nil))
17196 (defun gnus-backlog-enter-article (group number buffer)
17197 (gnus-backlog-setup)
17198 (let ((ident (intern (concat group ":" (int-to-string number))
17199 gnus-backlog-hashtb))
17201 (if (memq ident gnus-backlog-articles)
17202 () ; It's already kept.
17203 ;; Remove the oldest article, if necessary.
17204 (and (numberp gnus-keep-backlog)
17205 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17206 (gnus-backlog-remove-oldest-article))
17207 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17208 ;; Insert the new article.
17210 (set-buffer (gnus-backlog-buffer))
17211 (let (buffer-read-only)
17212 (goto-char (point-max))
17213 (or (bolp) (insert "\n"))
17215 (insert-buffer-substring buffer)
17216 ;; Tag the beginning of the article with the ident.
17217 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17219 (defun gnus-backlog-remove-oldest-article ()
17221 (set-buffer (gnus-backlog-buffer))
17222 (goto-char (point-min))
17223 (if (zerop (buffer-size))
17224 () ; The buffer is empty.
17225 (let ((ident (get-text-property (point) 'gnus-backlog))
17227 ;; Remove the ident from the list of articles.
17229 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17230 ;; Delete the article itself.
17232 (point) (next-single-property-change
17233 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17235 (defun gnus-backlog-remove-article (group number)
17236 "Remove article NUMBER in GROUP from the backlog."
17237 (when (numberp number)
17238 (gnus-backlog-setup)
17239 (let ((ident (intern (concat group ":" (int-to-string number))
17240 gnus-backlog-hashtb))
17242 (when (memq ident gnus-backlog-articles)
17243 ;; It was in the backlog.
17245 (set-buffer (gnus-backlog-buffer))
17246 (let (buffer-read-only)
17247 (when (setq beg (text-property-any
17248 (point-min) (point-max) 'gnus-backlog
17250 ;; Find the end (i. e., the beginning of the next article).
17252 (next-single-property-change
17253 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17254 (delete-region beg end)
17258 (defun gnus-backlog-request-article (group number buffer)
17259 (when (numberp number)
17260 (gnus-backlog-setup)
17261 (let ((ident (intern (concat group ":" (int-to-string number))
17262 gnus-backlog-hashtb))
17264 (when (memq ident gnus-backlog-articles)
17265 ;; It was in the backlog.
17267 (set-buffer (gnus-backlog-buffer))
17268 (if (not (setq beg (text-property-any
17269 (point-min) (point-max) 'gnus-backlog
17271 ;; It wasn't in the backlog after all.
17273 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17274 ;; Find the end (i. e., the beginning of the next article).
17276 (next-single-property-change
17277 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17278 (let ((buffer-read-only nil))
17280 (insert-buffer-substring gnus-backlog-buffer beg end)
17283 ;; Allow redefinition of Gnus functions.
17285 (gnus-ems-redefine)
17289 ;;; gnus.el ends here