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-organization nil
59 "String with a description of what organization (if any) the user belongs to.
60 The ORGANIZATION environment variable is used instead if it is defined.
61 If this variable contains a function, this function will be called
62 with the current newsgroup name as the argument. The function should
65 In any case, if the string (either in the variable, in the environment
66 variable, or returned by the function) is a file name, the contents of
67 this file will be used as the organization.")
69 ;; Customization variables
71 ;; Don't touch this variable.
72 (defvar gnus-nntp-service "nntp"
73 "*NNTP service name (\"nntp\" or 119).
74 This is an obsolete variable, which is scarcely used. If you use an
75 nntp server for your newsgroup and want to change the port number
76 used to 899, you would say something along these lines:
78 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
80 (defvar gnus-nntpserver-file "/etc/nntpserver"
81 "*A file with only the name of the nntp server in it.")
83 ;; This function is used to check both the environment variable
84 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
85 ;; an nntp server name default.
86 (defun gnus-getenv-nntpserver ()
87 (or (getenv "NNTPSERVER")
88 (and (file-readable-p gnus-nntpserver-file)
90 (set-buffer (get-buffer-create " *gnus nntp*"))
91 (buffer-disable-undo (current-buffer))
92 (insert-file-contents gnus-nntpserver-file)
93 (let ((name (buffer-string)))
95 (if (string-match "^[ \t\n]*$" name)
98 (kill-buffer (current-buffer))))))))
100 (defvar gnus-select-method
102 (list 'nntp (or (condition-case ()
103 (gnus-getenv-nntpserver)
105 (if (and gnus-default-nntp-server
106 (not (string= gnus-default-nntp-server "")))
107 gnus-default-nntp-server)
109 (if (or (null gnus-nntp-service)
110 (equal gnus-nntp-service "nntp"))
112 (list gnus-nntp-service)))
113 "*Default method for selecting a newsgroup.
114 This variable should be a list, where the first element is how the
115 news is to be fetched, the second is the address.
117 For instance, if you want to get your news via NNTP from
118 \"flab.flab.edu\", you could say:
120 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
122 If you want to use your local spool, say:
124 (setq gnus-select-method (list 'nnspool (system-name)))
126 If you use this variable, you must set `gnus-nntp-server' to nil.
128 There is a lot more to know about select methods and virtual servers -
129 see the manual for details.")
131 (defvar gnus-message-archive-method
134 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
135 (nnfolder-active-file
136 ,(nnheader-concat message-directory "archive/active"))
137 (nnfolder-get-new-mail nil)
138 (nnfolder-inhibit-expiry t))
139 "*Method used for archiving messages you've sent.
140 This should be a mail method.
142 It's probably not a very effective to change this variable once you've
143 run Gnus once. After doing that, you must edit this server from the
146 (defvar gnus-message-archive-group nil
147 "*Name of the group in which to save the messages you've written.
148 This can either be a string, a list of strings; or an alist
149 of regexps/functions/forms to be evaluated to return a string (or a list
150 of strings). The functions are called with the name of the current
151 group (or nil) as a parameter.
153 Normally the group names returned by this variable should be
154 unprefixed -- which implictly means \"store on the archive server\".
155 However, you may wish to store the message on some other server. In
156 that case, just return a fully prefixed name of the group --
157 \"nnml+private:mail.misc\", for instance.")
159 (defvar gnus-refer-article-method nil
160 "*Preferred method for fetching an article by Message-ID.
161 If you are reading news from the local spool (with nnspool), fetching
162 articles by Message-ID is painfully slow. By setting this method to an
163 nntp method, you might get acceptable results.
165 The value of this variable must be a valid select method as discussed
166 in the documentation of `gnus-select-method'.")
168 (defvar gnus-secondary-select-methods nil
169 "*A list of secondary methods that will be used for reading news.
170 This is a list where each element is a complete select method (see
171 `gnus-select-method').
173 If, for instance, you want to read your mail with the nnml backend,
174 you could set this variable:
176 (setq gnus-secondary-select-methods '((nnml \"\")))")
178 (defvar gnus-secondary-servers nil
179 "*List of NNTP servers that the user can choose between interactively.
180 To make Gnus query you for a server, you have to give `gnus' a
181 non-numeric prefix - `C-u M-x gnus', in short.")
183 (defvar gnus-nntp-server nil
184 "*The name of the host running the NNTP server.
185 This variable is semi-obsolete. Use the `gnus-select-method'
188 (defvar gnus-startup-file "~/.newsrc"
189 "*Your `.newsrc' file.
190 `.newsrc-SERVER' will be used instead if that exists.")
192 (defvar gnus-init-file "~/.gnus"
193 "*Your Gnus elisp startup file.
194 If a file with the .el or .elc suffixes exist, it will be read
197 (defvar gnus-group-faq-directory
198 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
199 "/ftp@sunsite.auc.dk:/pub/usenet/"
200 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
201 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
202 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
203 "/ftp@rtfm.mit.edu:/pub/usenet/"
204 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
205 "/ftp@ftp.sunet.se:/pub/usenet/"
206 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
207 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
208 "/ftp@ftp.hk.super.net:/mirror/faqs/")
209 "*Directory where the group FAQs are stored.
210 This will most commonly be on a remote machine, and the file will be
213 This variable can also be a list of directories. In that case, the
214 first element in the list will be used by default. The others can
215 be used when being prompted for a site.
217 Note that Gnus uses an aol machine as the default directory. If this
218 feels fundamentally unclean, just think of it as a way to finally get
219 something of value back from them.
221 If the default site is too slow, try one of these:
223 North America: mirrors.aol.com /pub/rtfm/usenet
224 ftp.seas.gwu.edu /pub/rtfm
225 rtfm.mit.edu /pub/usenet
226 Europe: ftp.uni-paderborn.de /pub/FAQ
227 src.doc.ic.ac.uk /usenet/news-FAQS
228 ftp.sunet.se /pub/usenet
229 sunsite.auc.dk /pub/usenet
230 Asia: nctuccca.edu.tw /USENET/FAQ
231 hwarang.postech.ac.kr /pub/usenet
232 ftp.hk.super.net /mirror/faqs")
234 (defvar gnus-group-archive-directory
235 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
236 "*The address of the (ding) archives.")
238 (defvar gnus-group-recent-archive-directory
239 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
240 "*The address of the most recent (ding) articles.")
242 (defvar gnus-default-subscribed-newsgroups nil
243 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
244 It should be a list of strings.
245 If it is `t', Gnus will not do anything special the first time it is
246 started; it'll just use the normal newsgroups subscription methods.")
248 (defvar gnus-use-cross-reference t
249 "*Non-nil means that cross referenced articles will be marked as read.
250 If nil, ignore cross references. If t, mark articles as read in
251 subscribed newsgroups. If neither t nor nil, mark as read in all
254 (defvar gnus-single-article-buffer t
255 "*If non-nil, display all articles in the same buffer.
256 If nil, each group will get its own article buffer.")
258 (defvar gnus-use-dribble-file t
259 "*Non-nil means that Gnus will use a dribble file to store user updates.
260 If Emacs should crash without saving the .newsrc files, complete
261 information can be restored from the dribble file.")
263 (defvar gnus-dribble-directory nil
264 "*The directory where dribble files will be saved.
265 If this variable is nil, the directory where the .newsrc files are
266 saved will be used.")
268 (defvar gnus-asynchronous nil
269 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
271 (defvar gnus-kill-summary-on-exit t
272 "*If non-nil, kill the summary buffer when you exit from it.
273 If nil, the summary will become a \"*Dead Summary*\" buffer, and
274 it will be killed sometime later.")
276 (defvar gnus-large-newsgroup 200
277 "*The number of articles which indicates a large newsgroup.
278 If the number of articles in a newsgroup is greater than this value,
279 confirmation is required for selecting the newsgroup.")
281 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
282 (defvar gnus-no-groups-message "No news is horrible news"
283 "*Message displayed by Gnus when no groups are available.")
285 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
286 "*Non-nil means that the default name of a file to save articles in is the group name.
287 If it's nil, the directory form of the group name is used instead.
289 If this variable is a list, and the list contains the element
290 `not-score', long file names will not be used for score files; if it
291 contains the element `not-save', long file names will not be used for
292 saving; and if it contains the element `not-kill', long file names
293 will not be used for kill files.
295 Note that the default for this variable varies according to what system
296 type you're using. On `usg-unix-v' and `xenix' this variable defaults
297 to nil while on all other systems it defaults to t.")
299 (defvar gnus-article-save-directory gnus-directory
300 "*Name of the directory articles will be saved in (default \"~/News\").")
302 (defvar gnus-kill-files-directory gnus-directory
303 "*Name of the directory where kill files will be stored (default \"~/News\").")
305 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
306 "*A function to save articles in your favorite format.
307 The function must be interactively callable (in other words, it must
308 be an Emacs command).
310 Gnus provides the following functions:
312 * gnus-summary-save-in-rmail (Rmail format)
313 * gnus-summary-save-in-mail (Unix mail format)
314 * gnus-summary-save-in-folder (MH folder)
315 * gnus-summary-save-in-file (article format).
316 * gnus-summary-save-in-vm (use VM's folder format).")
318 (defvar gnus-prompt-before-saving 'always
319 "*This variable says how much prompting is to be done when saving articles.
320 If it is nil, no prompting will be done, and the articles will be
321 saved to the default files. If this variable is `always', each and
322 every article that is saved will be preceded by a prompt, even when
323 saving large batches of articles. If this variable is neither nil not
324 `always', there the user will be prompted once for a file name for
325 each invocation of the saving commands.")
327 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
328 "*A function generating a file name to save articles in Rmail format.
329 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
331 (defvar gnus-mail-save-name (function gnus-plain-save-name)
332 "*A function generating a file name to save articles in Unix mail format.
333 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
335 (defvar gnus-folder-save-name (function gnus-folder-save-name)
336 "*A function generating a file name to save articles in MH folder.
337 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
339 (defvar gnus-file-save-name (function gnus-numeric-save-name)
340 "*A function generating a file name to save articles in article format.
341 The function is called with NEWSGROUP, HEADERS, and optional
344 (defvar gnus-split-methods
345 '((gnus-article-archive-name))
346 "*Variable used to suggest where articles are to be saved.
347 For instance, if you would like to save articles related to Gnus in
348 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
349 you could set this variable to something like:
351 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
352 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
354 This variable is an alist where the where the key is the match and the
355 value is a list of possible files to save in if the match is non-nil.
357 If the match is a string, it is used as a regexp match on the
358 article. If the match is a symbol, that symbol will be funcalled
359 from the buffer of the article to be saved with the newsgroup as the
360 parameter. If it is a list, it will be evaled in the same buffer.
362 If this form or function returns a string, this string will be used as
363 a possible file name; and if it returns a non-nil list, that list will
364 be used as possible file names.")
366 (defvar gnus-move-split-methods nil
367 "*Variable used to suggest where articles are to be moved to.
368 It uses the same syntax as the `gnus-split-methods' variable.")
370 (defvar gnus-save-score nil
371 "*If non-nil, save group scoring info.")
373 (defvar gnus-use-adaptive-scoring nil
374 "*If non-nil, use some adaptive scoring scheme.")
376 (defvar gnus-use-cache 'passive
377 "*If nil, Gnus will ignore the article cache.
378 If `passive', it will allow entering (and reading) articles
379 explicitly entered into the cache. If anything else, use the
380 cache to the full extent of the law.")
382 (defvar gnus-use-trees nil
383 "*If non-nil, display a thread tree buffer.")
385 (defvar gnus-use-grouplens nil
386 "*If non-nil, use GroupLens ratings.")
388 (defvar gnus-keep-backlog nil
389 "*If non-nil, Gnus will keep read articles for later re-retrieval.
390 If it is a number N, then Gnus will only keep the last N articles
391 read. If it is neither nil nor a number, Gnus will keep all read
392 articles. This is not a good idea.")
394 (defvar gnus-use-nocem nil
395 "*If non-nil, Gnus will read NoCeM cancel messages.")
397 (defvar gnus-use-demon nil
398 "If non-nil, Gnus might use some demons.")
400 (defvar gnus-use-scoring t
401 "*If non-nil, enable scoring.")
403 (defvar gnus-use-picons nil
404 "*If non-nil, display picons.")
406 (defvar gnus-fetch-old-headers nil
407 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
408 If an unread article in the group refers to an older, already read (or
409 just marked as read) article, the old article will not normally be
410 displayed in the Summary buffer. If this variable is non-nil, Gnus
411 will attempt to grab the headers to the old articles, and thereby
412 build complete threads. If it has the value `some', only enough
413 headers to connect otherwise loose threads will be displayed.
414 This variable can also be a number. In that case, no more than that
415 number of old headers will be fetched.
417 The server has to support NOV for any of this to work.")
420 ;(defvar gnus-visual t
421 ; "*If non-nil, will do various highlighting.
422 ;If nil, no mouse highlights (or any other highlights) will be
423 ;performed. This might speed up Gnus some when generating large group
424 ;and summary buffers.")
426 (defvar gnus-novice-user t
427 "*Non-nil means that you are a usenet novice.
428 If non-nil, verbose messages may be displayed and confirmations may be
431 (defvar gnus-expert-user nil
432 "*Non-nil means that you will never be asked for confirmation about anything.
433 And that means *anything*.")
435 (defvar gnus-verbose 7
436 "*Integer that says how verbose Gnus should be.
437 The higher the number, the more messages Gnus will flash to say what
438 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
439 display most important messages; and at ten, Gnus will keep on
440 jabbering all the time.")
442 (defvar gnus-keep-same-level nil
443 "*Non-nil means that the next newsgroup after the current will be on the same level.
444 When you type, for instance, `n' after reading the last article in the
445 current newsgroup, you will go to the next newsgroup. If this variable
446 is nil, the next newsgroup will be the next from the group
448 If this variable is non-nil, Gnus will either put you in the
449 next newsgroup with the same level, or, if no such newsgroup is
450 available, the next newsgroup with the lowest possible level higher
451 than the current level.
452 If this variable is `best', Gnus will make the next newsgroup the one
453 with the best level.")
455 (defvar gnus-summary-make-false-root 'adopt
456 "*nil means that Gnus won't gather loose threads.
457 If the root of a thread has expired or been read in a previous
458 session, the information necessary to build a complete thread has been
459 lost. Instead of having many small sub-threads from this original thread
460 scattered all over the summary buffer, Gnus can gather them.
462 If non-nil, Gnus will try to gather all loose sub-threads from an
463 original thread into one large thread.
465 If this variable is non-nil, it should be one of `none', `adopt',
468 If this variable is `none', Gnus will not make a false root, but just
469 present the sub-threads after another.
470 If this variable is `dummy', Gnus will create a dummy root that will
471 have all the sub-threads as children.
472 If this variable is `adopt', Gnus will make one of the \"children\"
473 the parent and mark all the step-children as such.
474 If this variable is `empty', the \"children\" are printed with empty
475 subject fields. (Or rather, they will be printed with a string
476 given by the `gnus-summary-same-subject' variable.)")
478 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
479 "*A regexp to match subjects to be excluded from loose thread gathering.
480 As loose thread gathering is done on subjects only, that means that
481 there can be many false gatherings performed. By rooting out certain
482 common subjects, gathering might become saner.")
484 (defvar gnus-summary-gather-subject-limit nil
485 "*Maximum length of subject comparisons when gathering loose threads.
486 Use nil to compare full subjects. Setting this variable to a low
487 number will help gather threads that have been corrupted by
488 newsreaders chopping off subject lines, but it might also mean that
489 unrelated articles that have subject that happen to begin with the
490 same few characters will be incorrectly gathered.
492 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
493 comparing subjects.")
495 (defvar gnus-simplify-ignored-prefixes nil
496 "*Regexp, matches for which are removed from subject lines when simplifying.")
498 (defvar gnus-build-sparse-threads nil
499 "*If non-nil, fill in the gaps in threads.
500 If `some', only fill in the gaps that are needed to tie loose threads
501 together. If `more', fill in all leaf nodes that Gnus can find. If
502 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
504 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
505 "Function used for gathering loose threads.
506 There are two pre-defined functions: `gnus-gather-threads-by-subject',
507 which only takes Subjects into consideration; and
508 `gnus-gather-threads-by-references', which compared the References
509 headers of the articles to find matches.")
511 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
512 (defvar gnus-summary-same-subject ""
513 "*String indicating that the current article has the same subject as the previous.
514 This variable will only be used if the value of
515 `gnus-summary-make-false-root' is `empty'.")
517 (defvar gnus-summary-goto-unread t
518 "*If non-nil, marking commands will go to the next unread article.
519 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
520 whether it is read or not.")
522 (defvar gnus-group-goto-unread t
523 "*If non-nil, movement commands will go to the next unread and subscribed group.")
525 (defvar gnus-goto-next-group-when-activating t
526 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
528 (defvar gnus-check-new-newsgroups t
529 "*Non-nil means that Gnus will add new newsgroups at startup.
530 If this variable is `ask-server', Gnus will ask the server for new
531 groups since the last time it checked. This means that the killed list
532 is no longer necessary, so you could set `gnus-save-killed-list' to
535 A variant is to have this variable be a list of select methods. Gnus
536 will then use the `ask-server' method on all these select methods to
537 query for new groups from all those servers.
540 (setq gnus-check-new-newsgroups
541 '((nntp \"some.server\") (nntp \"other.server\")))
543 If this variable is nil, then you have to tell Gnus explicitly to
544 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
546 (defvar gnus-check-bogus-newsgroups nil
547 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
548 If this variable is nil, then you have to tell Gnus explicitly to
549 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
551 (defvar gnus-read-active-file t
552 "*Non-nil means that Gnus will read the entire active file at startup.
553 If this variable is nil, Gnus will only know about the groups in your
556 If this variable is `some', Gnus will try to only read the relevant
557 parts of the active file from the server. Not all servers support
558 this, and it might be quite slow with other servers, but this should
559 generally be faster than both the t and nil value.
561 If you set this variable to nil or `some', you probably still want to
562 be told about new newsgroups that arrive. To do that, set
563 `gnus-check-new-newsgroups' to `ask-server'. This may not work
564 properly with all servers.")
566 (defvar gnus-level-subscribed 5
567 "*Groups with levels less than or equal to this variable are subscribed.")
569 (defvar gnus-level-unsubscribed 7
570 "*Groups with levels less than or equal to this variable are unsubscribed.
571 Groups with levels less than `gnus-level-subscribed', which should be
572 less than this variable, are subscribed.")
574 (defvar gnus-level-zombie 8
575 "*Groups with this level are zombie groups.")
577 (defvar gnus-level-killed 9
578 "*Groups with this level are killed.")
580 (defvar gnus-level-default-subscribed 3
581 "*New subscribed groups will be subscribed at this level.")
583 (defvar gnus-level-default-unsubscribed 6
584 "*New unsubscribed groups will be unsubscribed at this level.")
586 (defvar gnus-activate-level (1+ gnus-level-subscribed)
587 "*Groups higher than this level won't be activated on startup.
588 Setting this variable to something log might save lots of time when
589 you have many groups that you aren't interested in.")
591 (defvar gnus-activate-foreign-newsgroups 4
592 "*If nil, Gnus will not check foreign newsgroups at startup.
593 If it is non-nil, it should be a number between one and nine. Foreign
594 newsgroups that have a level lower or equal to this number will be
595 activated on startup. For instance, if you want to active all
596 subscribed newsgroups, but not the rest, you'd set this variable to
597 `gnus-level-subscribed'.
599 If you subscribe to lots of newsgroups from different servers, startup
600 might take a while. By setting this variable to nil, you'll save time,
601 but you won't be told how many unread articles there are in the
604 (defvar gnus-save-newsrc-file t
605 "*Non-nil means that Gnus will save the `.newsrc' file.
606 Gnus always saves its own startup file, which is called
607 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
608 be readily understood by other newsreaders. If you don't plan on
609 using other newsreaders, set this variable to nil to save some time on
612 (defvar gnus-save-killed-list t
613 "*If non-nil, save the list of killed groups to the startup file.
614 If you set this variable to nil, you'll save both time (when starting
615 and quitting) and space (both memory and disk), but it will also mean
616 that Gnus has no record of which groups are new and which are old, so
617 the automatic new newsgroups subscription methods become meaningless.
619 You should always set `gnus-check-new-newsgroups' to `ask-server' or
620 nil if you set this variable to nil.")
622 (defvar gnus-interactive-catchup t
623 "*If non-nil, require your confirmation when catching up a group.")
625 (defvar gnus-interactive-exit t
626 "*If non-nil, require your confirmation when exiting Gnus.")
628 (defvar gnus-kill-killed t
629 "*If non-nil, Gnus will apply kill files to already killed articles.
630 If it is nil, Gnus will never apply kill files to articles that have
631 already been through the scoring process, which might very well save lots
634 (defvar gnus-extract-address-components 'gnus-extract-address-components
635 "*Function for extracting address components from a From header.
636 Two pre-defined function exist: `gnus-extract-address-components',
637 which is the default, quite fast, and too simplistic solution, and
638 `mail-extract-address-components', which works much better, but is
641 (defvar gnus-summary-default-score 0
642 "*Default article score level.
643 If this variable is nil, scoring will be disabled.")
645 (defvar gnus-summary-zcore-fuzz 0
646 "*Fuzziness factor for the zcore in the summary buffer.
647 Articles with scores closer than this to `gnus-summary-default-score'
648 will not be marked.")
650 (defvar gnus-simplify-subject-fuzzy-regexp nil
651 "*Strings to be removed when doing fuzzy matches.
652 This can either be a regular expression or list of regular expressions
653 that will be removed from subject strings if fuzzy subject
654 simplification is selected.")
656 (defvar gnus-permanently-visible-groups nil
657 "*Regexp to match groups that should always be listed in the group buffer.
658 This means that they will still be listed when there are no unread
659 articles in the groups.")
661 (defvar gnus-list-groups-with-ticked-articles t
662 "*If non-nil, list groups that have only ticked articles.
663 If nil, only list groups that have unread articles.")
665 (defvar gnus-group-default-list-level gnus-level-subscribed
666 "*Default listing level.
667 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
669 (defvar gnus-group-use-permanent-levels nil
670 "*If non-nil, once you set a level, Gnus will use this level.")
672 (defvar gnus-group-list-inactive-groups t
673 "*If non-nil, inactive groups will be listed.")
675 (defvar gnus-show-mime nil
676 "*If non-nil, do mime processing of articles.
677 The articles will simply be fed to the function given by
678 `gnus-show-mime-method'.")
680 (defvar gnus-strict-mime t
681 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
683 (defvar gnus-show-mime-method 'metamail-buffer
684 "*Function to process a MIME message.
685 The function is called from the article buffer.")
687 (defvar gnus-decode-encoded-word-method (lambda ())
688 "*Function to decode a MIME encoded-words.
689 The function is called from the article buffer.")
691 (defvar gnus-show-threads t
692 "*If non-nil, display threads in summary mode.")
694 (defvar gnus-thread-hide-subtree nil
695 "*If non-nil, hide all threads initially.
696 If threads are hidden, you have to run the command
697 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
698 to expose hidden threads.")
700 (defvar gnus-thread-hide-killed t
701 "*If non-nil, hide killed threads automatically.")
703 (defvar gnus-thread-ignore-subject nil
704 "*If non-nil, ignore subjects and do all threading based on the Reference header.
705 If nil, which is the default, articles that have different subjects
706 from their parents will start separate threads.")
708 (defvar gnus-thread-operation-ignore-subject t
709 "*If non-nil, subjects will be ignored when doing thread commands.
710 This affects commands like `gnus-summary-kill-thread' and
711 `gnus-summary-lower-thread'.
713 If this variable is nil, articles in the same thread with different
714 subjects will not be included in the operation in question. If this
715 variable is `fuzzy', only articles that have subjects that are fuzzily
716 equal will be included.")
718 (defvar gnus-thread-indent-level 4
719 "*Number that says how much each sub-thread should be indented.")
721 (defvar gnus-ignored-newsgroups
722 (purecopy (mapconcat 'identity
723 '("^to\\." ; not "real" groups
724 "^[0-9. \t]+ " ; all digits in name
725 "[][\"#'()]" ; bogus characters
728 "*A regexp to match uninteresting newsgroups in the active file.
729 Any lines in the active file matching this regular expression are
730 removed from the newsgroup list before anything else is done to it,
731 thus making them effectively non-existent.")
733 (defvar gnus-ignored-headers
734 "^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:"
735 "*All headers that match this regexp will be hidden.
736 This variable can also be a list of regexps of headers to be ignored.
737 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
739 (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-"
740 "*All headers that do not match this regexp will be hidden.
741 This variable can also be a list of regexp of headers to remain visible.
742 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
744 (defvar gnus-sorted-header-list
745 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
746 "^Cc:" "^Date:" "^Organization:")
747 "*This variable is a list of regular expressions.
748 If it is non-nil, headers that match the regular expressions will
749 be placed first in the article buffer in the sequence specified by
752 (defvar gnus-boring-article-headers
753 '(empty followup-to reply-to)
754 "*Headers that are only to be displayed if they have interesting data.
755 Possible values in this list are `empty', `newsgroups', `followup-to',
756 `reply-to', and `date'.")
758 (defvar gnus-show-all-headers nil
759 "*If non-nil, don't hide any headers.")
761 (defvar gnus-save-all-headers t
762 "*If non-nil, don't remove any headers before saving.")
764 (defvar gnus-saved-headers gnus-visible-headers
765 "*Headers to keep if `gnus-save-all-headers' is nil.
766 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
767 If that variable is nil, however, all headers that match this regexp
768 will be kept while the rest will be deleted before saving.")
770 (defvar gnus-inhibit-startup-message nil
771 "*If non-nil, the startup message will not be displayed.")
773 (defvar gnus-signature-separator "^-- *$"
774 "Regexp matching signature separator.")
776 (defvar gnus-signature-limit nil
777 "Provide a limit to what is considered a signature.
778 If it is a number, no signature may not be longer (in characters) than
779 that number. If it is a function, the function will be called without
780 any parameters, and if it returns nil, there is no signature in the
781 buffer. If it is a string, it will be used as a regexp. If it
782 matches, the text in question is not a signature.")
784 (defvar gnus-auto-extend-newsgroup t
785 "*If non-nil, extend newsgroup forward and backward when requested.")
787 (defvar gnus-auto-select-first t
788 "*If nil, don't select the first unread article when entering a group.
789 If this variable is `best', select the highest-scored unread article
790 in the group. If neither nil nor `best', select the first unread
793 If you want to prevent automatic selection of the first unread article
794 in some newsgroups, set the variable to nil in
795 `gnus-select-group-hook'.")
797 (defvar gnus-auto-select-next t
798 "*If non-nil, offer to go to the next group from the end of the previous.
799 If the value is t and the next newsgroup is empty, Gnus will exit
800 summary mode and go back to group mode. If the value is neither nil
801 nor t, Gnus will select the following unread newsgroup. In
802 particular, if the value is the symbol `quietly', the next unread
803 newsgroup will be selected without any confirmation, and if it is
804 `almost-quietly', the next group will be selected without any
805 confirmation if you are located on the last article in the group.
806 Finally, if this variable is `slightly-quietly', the `Z n' command
807 will go to the next group without confirmation.")
809 (defvar gnus-auto-select-same nil
810 "*If non-nil, select the next article with the same subject.")
812 (defvar gnus-summary-check-current nil
813 "*If non-nil, consider the current article when moving.
814 The \"unread\" movement commands will stay on the same line if the
815 current article is unread.")
817 (defvar gnus-auto-center-summary t
818 "*If non-nil, always center the current summary buffer.
819 In particular, if `vertical' do only vertical recentering. If non-nil
820 and non-`vertical', do both horizontal and vertical recentering.")
822 (defvar gnus-break-pages t
823 "*If non-nil, do page breaking on articles.
824 The page delimiter is specified by the `gnus-page-delimiter'
827 (defvar gnus-page-delimiter "^\^L"
828 "*Regexp describing what to use as article page delimiters.
829 The default value is \"^\^L\", which is a form linefeed at the
830 beginning of a line.")
832 (defvar gnus-use-full-window t
833 "*If non-nil, use the entire Emacs screen.")
835 (defvar gnus-window-configuration nil
836 "Obsolete variable. See `gnus-buffer-configuration'.")
838 (defvar gnus-window-min-width 2
839 "*Minimum width of Gnus buffers.")
841 (defvar gnus-window-min-height 1
842 "*Minimum height of Gnus buffers.")
844 (defvar gnus-buffer-configuration
848 (if gnus-carpal '(group-carpal 4))))
852 (if gnus-carpal '(summary-carpal 4))))
859 (if gnus-carpal '(summary-carpal 4))
861 (vertical ((height . 5) (width . 15)
863 (left . -1) (top . 1))
873 (if gnus-carpal '(summary-carpal 4))
878 (if gnus-carpal '(server-carpal 2))))
882 (if gnus-carpal '(browse-carpal 2))))
885 (message 1.0 point)))
888 (article 1.0 point)))
899 (edit-group 1.0 point)))
903 (edit-server 1.0 point)))
907 (edit-score 1.0 point)))
914 (message 1.0 point)))
917 (message 1.0 point)))
920 (message 1.0 point)))
924 (message 1.0 point)))
931 (if gnus-carpal '(summary-carpal 4))
932 ("*Shell Command Output*" 1.0)))
935 ("*Gnus Help Bug*" 0.5)
936 ("*Gnus Bug*" 1.0 point)))
940 (message 1.0 point))))
941 "Window configuration for all possible Gnus buffers.
942 This variable is a list of lists. Each of these lists has a NAME and
943 a RULE. The NAMEs are commonsense names like `group', which names a
944 rule used when displaying the group buffer; `summary', which names a
945 rule for what happens when you enter a group and do not display an
946 article buffer; and so on. See the value of this variable for a
947 complete list of NAMEs.
949 Each RULE is a list of vectors. The first element in this vector is
950 the name of the buffer to be displayed; the second element is the
951 percentage of the screen this buffer is to occupy (a number in the
952 0.0-0.99 range); the optional third element is `point', which should
953 be present to denote which buffer point is to go to after making this
954 buffer configuration.")
956 (defvar gnus-window-to-buffer
957 '((group . gnus-group-buffer)
958 (summary . gnus-summary-buffer)
959 (article . gnus-article-buffer)
960 (server . gnus-server-buffer)
961 (browse . "*Gnus Browse Server*")
962 (edit-group . gnus-group-edit-buffer)
963 (edit-server . gnus-server-edit-buffer)
964 (group-carpal . gnus-carpal-group-buffer)
965 (summary-carpal . gnus-carpal-summary-buffer)
966 (server-carpal . gnus-carpal-server-buffer)
967 (browse-carpal . gnus-carpal-browse-buffer)
968 (edit-score . gnus-score-edit-buffer)
969 (message . gnus-message-buffer)
970 (mail . gnus-message-buffer)
971 (post-news . gnus-message-buffer)
972 (faq . gnus-faq-buffer)
973 (picons . "*Picons*")
974 (tree . gnus-tree-buffer)
975 (info . gnus-info-buffer)
976 (article-copy . gnus-article-copy)
977 (draft . gnus-draft-buffer))
978 "Mapping from short symbols to buffer names or buffer variables.")
980 (defvar gnus-carpal nil
981 "*If non-nil, display clickable icons.")
983 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
984 "*Function called with a group name when new group is detected.
985 A few pre-made functions are supplied: `gnus-subscribe-randomly'
986 inserts new groups at the beginning of the list of groups;
987 `gnus-subscribe-alphabetically' inserts new groups in strict
988 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
989 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
990 for your decision; `gnus-subscribe-killed' kills all new groups;
991 `gnus-subscribe-zombies' will make all new groups into zombies.")
993 ;; Suggested by a bug report by Hallvard B Furuseth.
994 ;; <h.b.furuseth@usit.uio.no>.
995 (defvar gnus-subscribe-options-newsgroup-method
996 (function gnus-subscribe-alphabetically)
997 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
998 If, for instance, you want to subscribe to all newsgroups in the
999 \"no\" and \"alt\" hierarchies, you'd put the following in your
1002 options -n no.all alt.all
1004 Gnus will the subscribe all new newsgroups in these hierarchies with
1005 the subscription method in this variable.")
1007 (defvar gnus-subscribe-hierarchical-interactive nil
1008 "*If non-nil, Gnus will offer to subscribe hierarchically.
1009 When a new hierarchy appears, Gnus will ask the user:
1011 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1013 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1014 subscribe to all newsgroups in the hierarchy and `s' will skip this
1015 hierarchy in its entirety.")
1017 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1018 "*Function used for sorting the group buffer.
1019 This function will be called with group info entries as the arguments
1020 for the groups to be sorted. Pre-made functions include
1021 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1022 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1023 `gnus-group-sort-by-rank'.
1025 This variable can also be a list of sorting functions. In that case,
1026 the most significant sort function should be the last function in the
1029 ;; Mark variables suggested by Thomas Michanek
1030 ;; <Thomas.Michanek@telelogic.se>.
1031 (defvar gnus-unread-mark ?
1032 "*Mark used for unread articles.")
1033 (defvar gnus-ticked-mark ?!
1034 "*Mark used for ticked articles.")
1035 (defvar gnus-dormant-mark ??
1036 "*Mark used for dormant articles.")
1037 (defvar gnus-del-mark ?r
1038 "*Mark used for del'd articles.")
1039 (defvar gnus-read-mark ?R
1040 "*Mark used for read articles.")
1041 (defvar gnus-expirable-mark ?E
1042 "*Mark used for expirable articles.")
1043 (defvar gnus-killed-mark ?K
1044 "*Mark used for killed articles.")
1045 (defvar gnus-souped-mark ?F
1046 "*Mark used for killed articles.")
1047 (defvar gnus-kill-file-mark ?X
1048 "*Mark used for articles killed by kill files.")
1049 (defvar gnus-low-score-mark ?Y
1050 "*Mark used for articles with a low score.")
1051 (defvar gnus-catchup-mark ?C
1052 "*Mark used for articles that are caught up.")
1053 (defvar gnus-replied-mark ?A
1054 "*Mark used for articles that have been replied to.")
1055 (defvar gnus-cached-mark ?*
1056 "*Mark used for articles that are in the cache.")
1057 (defvar gnus-saved-mark ?S
1058 "*Mark used for articles that have been saved to.")
1059 (defvar gnus-process-mark ?#
1061 (defvar gnus-ancient-mark ?O
1062 "*Mark used for ancient articles.")
1063 (defvar gnus-sparse-mark ?Q
1064 "*Mark used for sparsely reffed articles.")
1065 (defvar gnus-canceled-mark ?G
1066 "*Mark used for canceled articles.")
1067 (defvar gnus-score-over-mark ?+
1068 "*Score mark used for articles with high scores.")
1069 (defvar gnus-score-below-mark ?-
1070 "*Score mark used for articles with low scores.")
1071 (defvar gnus-empty-thread-mark ?
1072 "*There is no thread under the article.")
1073 (defvar gnus-not-empty-thread-mark ?=
1074 "*There is a thread under the article.")
1076 (defvar gnus-view-pseudo-asynchronously nil
1077 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1079 (defvar gnus-view-pseudos nil
1080 "*If `automatic', pseudo-articles will be viewed automatically.
1081 If `not-confirm', pseudos will be viewed automatically, and the user
1082 will not be asked to confirm the command.")
1084 (defvar gnus-view-pseudos-separately t
1085 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1086 If nil, all files that use the same viewing command will be given as a
1087 list of parameters to that command.")
1089 (defvar gnus-insert-pseudo-articles t
1090 "*If non-nil, insert pseudo-articles when decoding articles.")
1092 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1093 "*Format of group lines.
1094 It works along the same lines as a normal formatting string,
1095 with some simple extensions.
1097 %M Only marked articles (character, \"*\" or \" \")
1098 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1099 %L Level of subscribedness (integer)
1100 %N Number of unread articles (integer)
1101 %I Number of dormant articles (integer)
1102 %i Number of ticked and dormant (integer)
1103 %T Number of ticked articles (integer)
1104 %R Number of read articles (integer)
1105 %t Total number of articles (integer)
1106 %y Number of unread, unticked articles (integer)
1107 %G Group name (string)
1108 %g Qualified group name (string)
1109 %D Group description (string)
1110 %s Select method (string)
1111 %o Moderated group (char, \"m\")
1112 %p Process mark (char)
1113 %O Moderated group (string, \"(m)\" or \"\")
1114 %P Topic indentation (string)
1115 %l Whether there are GroupLens predictions for this group (string)
1116 %n Select from where (string)
1117 %z A string that look like `<%s:%n>' if a foreign select method is used
1118 %u User defined specifier. The next character in the format string should
1119 be a letter. Gnus will call the function gnus-user-format-function-X,
1120 where X is the letter following %u. The function will be passed the
1121 current header as argument. The function should return a string, which
1122 will be inserted into the buffer just like information from any other
1125 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1126 the mouse point move inside the area. There can only be one such area.
1128 Note that this format specification is not always respected. For
1129 reasons of efficiency, when listing killed groups, this specification
1130 is ignored altogether. If the spec is changed considerably, your
1131 output may end up looking strange when listing both alive and killed
1134 If you use %o or %O, reading the active file will be slower and quite
1135 a bit of extra memory will be used. %D will also worsen performance.
1136 Also note that if you change the format specification to include any
1137 of these specs, you must probably re-start Gnus to see them go into
1140 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1141 "*The format specification of the lines in the summary buffer.
1143 It works along the same lines as a normal formatting string,
1144 with some simple extensions.
1146 %N Article number, left padded with spaces (string)
1148 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1149 %n Name of the poster (string)
1150 %a Extracted name of the poster (string)
1151 %A Extracted address of the poster (string)
1152 %F Contents of the From: header (string)
1153 %x Contents of the Xref: header (string)
1154 %D Date of the article (string)
1155 %d Date of the article (string) in DD-MMM format
1156 %M Message-id of the article (string)
1157 %r References of the article (string)
1158 %c Number of characters in the article (integer)
1159 %L Number of lines in the article (integer)
1160 %I Indentation based on thread level (a string of spaces)
1161 %T A string with two possible values: 80 spaces if the article
1162 is on thread level two or larger and 0 spaces on level one
1163 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1164 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1165 %[ Opening bracket (character, \"[\" or \"<\")
1166 %] Closing bracket (character, \"]\" or \">\")
1167 %> Spaces of length thread-level (string)
1168 %< Spaces of length (- 20 thread-level) (string)
1169 %i Article score (number)
1170 %z Article zcore (character)
1171 %t Number of articles under the current thread (number).
1172 %e Whether the thread is empty or not (character).
1173 %l GroupLens score (string).
1174 %u User defined specifier. The next character in the format string should
1175 be a letter. Gnus will call the function gnus-user-format-function-X,
1176 where X is the letter following %u. The function will be passed the
1177 current header as argument. The function should return a string, which
1178 will be inserted into the summary just like information from any other
1181 Text between %( and %) will be highlighted with `gnus-mouse-face'
1182 when the mouse point is placed inside the area. There can only be one
1185 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1186 with care. For reasons of efficiency, Gnus will compute what column
1187 these characters will end up in, and \"hard-code\" that. This means that
1188 it is illegal to have these specs after a variable-length spec. Well,
1189 you might not be arrested, but your summary buffer will look strange,
1190 which is bad enough.
1192 The smart choice is to have these specs as for to the left as
1195 This restriction may disappear in later versions of Gnus.")
1197 (defvar gnus-summary-dummy-line-format
1199 "*The format specification for the dummy roots in the summary buffer.
1200 It works along the same lines as a normal formatting string,
1201 with some simple extensions.
1205 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1206 "*The format specification for the summary mode line.
1207 It works along the same lines as a normal formatting string,
1208 with some simple extensions:
1211 %p Unprefixed group name
1212 %A Current article number
1214 %U Number of unread articles in the group
1215 %e Number of unselected articles in the group
1216 %Z A string with unread/unselected article counts
1217 %g Shortish group name
1218 %S Subject of the current article
1219 %u User-defined spec
1220 %s Current score file name
1221 %d Number of dormant articles
1222 %r Number of articles that have been marked as read in this session
1223 %E Number of articles expunged by the score files")
1225 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1226 "*The format specification for the article mode line.
1227 See `gnus-summary-mode-line-format' for a closer description.")
1229 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1230 "*The format specification for the group mode line.
1231 It works along the same lines as a normal formatting string,
1232 with some simple extensions:
1234 %S The native news server.
1235 %M The native select method.
1236 %: \":\" if %S isn't \"\".")
1238 (defvar gnus-valid-select-methods
1239 '(("nntp" post address prompt-address)
1240 ("nnspool" post address)
1241 ("nnvirtual" post-mail virtual prompt-address)
1242 ("nnmbox" mail respool address)
1243 ("nnml" mail respool address)
1244 ("nnmh" mail respool address)
1245 ("nndir" post-mail prompt-address address)
1246 ("nneething" none address prompt-address)
1247 ("nndoc" none address prompt-address)
1248 ("nnbabyl" mail address respool)
1249 ("nnkiboze" post virtual)
1250 ("nnsoup" post-mail address)
1251 ("nndraft" post-mail)
1252 ("nnfolder" mail respool address))
1253 "An alist of valid select methods.
1254 The first element of each list lists should be a string with the name
1255 of the select method. The other elements may be be the category of
1256 this method (ie. `post', `mail', `none' or whatever) or other
1257 properties that this method has (like being respoolable).
1258 If you implement a new select method, all you should have to change is
1259 this variable. I think.")
1261 (defvar gnus-updated-mode-lines '(group article summary tree)
1262 "*List of buffers that should update their mode lines.
1263 The list may contain the symbols `group', `article' and `summary'. If
1264 the corresponding symbol is present, Gnus will keep that mode line
1265 updated with information that may be pertinent.
1266 If this variable is nil, screen refresh may be quicker.")
1268 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1269 (defvar gnus-mode-non-string-length nil
1270 "*Max length of mode-line non-string contents.
1271 If this is nil, Gnus will take space as is needed, leaving the rest
1272 of the modeline intact.")
1275 ;(defvar gnus-mouse-face 'highlight
1276 ; "*Face used for mouse highlighting in Gnus.
1277 ;No mouse highlights will be done if `gnus-visual' is nil.")
1279 (defvar gnus-summary-mark-below 0
1280 "*Mark all articles with a score below this variable as read.
1281 This variable is local to each summary buffer and usually set by the
1284 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1285 "*List of functions used for sorting articles in the summary buffer.
1286 This variable is only used when not using a threaded display.")
1288 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1289 "*List of functions used for sorting threads in the summary buffer.
1290 By default, threads are sorted by article number.
1292 Each function takes two threads and return non-nil if the first thread
1293 should be sorted before the other. If you use more than one function,
1294 the primary sort function should be the last. You should probably
1295 always include `gnus-thread-sort-by-number' in the list of sorting
1296 functions -- preferably first.
1298 Ready-mady functions include `gnus-thread-sort-by-number',
1299 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1300 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1301 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1303 (defvar gnus-thread-score-function '+
1304 "*Function used for calculating the total score of a thread.
1306 The function is called with the scores of the article and each
1307 subthread and should then return the score of the thread.
1309 Some functions you can use are `+', `max', or `min'.")
1311 (defvar gnus-summary-expunge-below nil
1312 "All articles that have a score less than this variable will be expunged.")
1314 (defvar gnus-thread-expunge-below nil
1315 "All threads that have a total score less than this variable will be expunged.
1316 See `gnus-thread-score-function' for en explanation of what a
1317 \"thread score\" is.")
1319 (defvar gnus-auto-subscribed-groups
1320 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1321 "*All new groups that match this regexp will be subscribed automatically.
1322 Note that this variable only deals with new groups. It has no effect
1323 whatsoever on old groups.
1325 New groups that match this regexp will not be handled by
1326 `gnus-subscribe-newsgroup-method'. Instead, they will
1327 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1329 (defvar gnus-options-subscribe nil
1330 "*All new groups matching this regexp will be subscribed unconditionally.
1331 Note that this variable deals only with new newsgroups. This variable
1332 does not affect old newsgroups.
1334 New groups that match this regexp will not be handled by
1335 `gnus-subscribe-newsgroup-method'. Instead, they will
1336 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1338 (defvar gnus-options-not-subscribe nil
1339 "*All new groups matching this regexp will be ignored.
1340 Note that this variable deals only with new newsgroups. This variable
1341 does not affect old (already subscribed) newsgroups.")
1343 (defvar gnus-auto-expirable-newsgroups nil
1344 "*Groups in which to automatically mark read articles as expirable.
1345 If non-nil, this should be a regexp that should match all groups in
1346 which to perform auto-expiry. This only makes sense for mail groups.")
1348 (defvar gnus-total-expirable-newsgroups nil
1349 "*Groups in which to perform expiry of all read articles.
1350 Use with extreme caution. All groups that match this regexp will be
1351 expiring - which means that all read articles will be deleted after
1352 (say) one week. (This only goes for mail groups and the like, of
1355 (defvar gnus-group-uncollapsed-levels 1
1356 "Number of group name elements to leave alone when making a short group name.")
1358 (defvar gnus-hidden-properties '(invisible t intangible t)
1359 "Property list to use for hiding text.")
1361 (defvar gnus-modtime-botch nil
1362 "*Non-nil means .newsrc should be deleted prior to save.
1363 Its use is due to the bogus appearance that .newsrc was modified on
1368 (defvar gnus-group-mode-hook nil
1369 "*A hook for Gnus group mode.")
1371 (defvar gnus-summary-mode-hook nil
1372 "*A hook for Gnus summary mode.
1373 This hook is run before any variables are set in the summary buffer.")
1375 (defvar gnus-article-mode-hook nil
1376 "*A hook for Gnus article mode.")
1378 (defvar gnus-summary-prepare-exit-hook nil
1379 "*A hook called when preparing to exit from the summary buffer.
1380 It calls `gnus-summary-expire-articles' by default.")
1381 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1383 (defvar gnus-summary-exit-hook nil
1384 "*A hook called on exit from the summary buffer.")
1386 (defvar gnus-group-catchup-group-hook nil
1387 "*A hook run when catching up a group from the group buffer.")
1389 (defvar gnus-group-update-group-hook nil
1390 "*A hook called when updating group lines.")
1392 (defvar gnus-open-server-hook nil
1393 "*A hook called just before opening connection to the news server.")
1395 (defvar gnus-load-hook nil
1396 "*A hook run while Gnus is loaded.")
1398 (defvar gnus-startup-hook nil
1399 "*A hook called at startup.
1400 This hook is called after Gnus is connected to the NNTP server.")
1402 (defvar gnus-get-new-news-hook nil
1403 "*A hook run just before Gnus checks for new news.")
1405 (defvar gnus-after-getting-new-news-hook nil
1406 "*A hook run after Gnus checks for new news.")
1408 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1409 "*A function that is called to generate the group buffer.
1410 The function is called with three arguments: The first is a number;
1411 all group with a level less or equal to that number should be listed,
1412 if the second is non-nil, empty groups should also be displayed. If
1413 the third is non-nil, it is a number. No groups with a level lower
1414 than this number should be displayed.
1416 The only current function implemented is `gnus-group-prepare-flat'.")
1418 (defvar gnus-group-prepare-hook nil
1419 "*A hook called after the group buffer has been generated.
1420 If you want to modify the group buffer, you can use this hook.")
1422 (defvar gnus-summary-prepare-hook nil
1423 "*A hook called after the summary buffer has been generated.
1424 If you want to modify the summary buffer, you can use this hook.")
1426 (defvar gnus-summary-generate-hook nil
1427 "*A hook run just before generating the summary buffer.
1428 This hook is commonly used to customize threading variables and the
1431 (defvar gnus-article-prepare-hook nil
1432 "*A hook called after an article has been prepared in the article buffer.
1433 If you want to run a special decoding program like nkf, use this hook.")
1435 ;(defvar gnus-article-display-hook nil
1436 ; "*A hook called after the article is displayed in the article buffer.
1437 ;The hook is designed to change the contents of the article
1438 ;buffer. Typical functions that this hook may contain are
1439 ;`gnus-article-hide-headers' (hide selected headers),
1440 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1441 ;`gnus-article-hide-signature' (hide signature) and
1442 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1443 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1444 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1445 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1447 (defvar gnus-article-x-face-too-ugly nil
1448 "Regexp matching posters whose face shouldn't be shown automatically.")
1450 (defvar gnus-select-group-hook nil
1451 "*A hook called when a newsgroup is selected.
1453 If you'd like to simplify subjects like the
1454 `gnus-summary-next-same-subject' command does, you can use the
1457 (setq gnus-select-group-hook
1460 (mapcar (lambda (header)
1461 (mail-header-set-subject
1463 (gnus-simplify-subject
1464 (mail-header-subject header) 're-only)))
1465 gnus-newsgroup-headers))))")
1467 (defvar gnus-select-article-hook nil
1468 "*A hook called when an article is selected.")
1470 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1471 "*A hook called to apply kill files to a group.
1472 This hook is intended to apply a kill file to the selected newsgroup.
1473 The function `gnus-apply-kill-file' is called by default.
1475 Since a general kill file is too heavy to use only for a few
1476 newsgroups, I recommend you to use a lighter hook function. For
1477 example, if you'd like to apply a kill file to articles which contains
1478 a string `rmgroup' in subject in newsgroup `control', you can use the
1481 (setq gnus-apply-kill-hook
1484 (cond ((string-match \"control\" gnus-newsgroup-name)
1485 (gnus-kill \"Subject\" \"rmgroup\")
1486 (gnus-expunge \"X\"))))))")
1488 (defvar gnus-visual-mark-article-hook
1489 (list 'gnus-highlight-selected-summary)
1490 "*Hook run after selecting an article in the summary buffer.
1491 It is meant to be used for highlighting the article in some way. It
1492 is not run if `gnus-visual' is nil.")
1494 (defvar gnus-parse-headers-hook nil
1495 "*A hook called before parsing the headers.")
1496 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1498 (defvar gnus-exit-group-hook nil
1499 "*A hook called when exiting (not quitting) summary mode.")
1501 (defvar gnus-suspend-gnus-hook nil
1502 "*A hook called when suspending (not exiting) Gnus.")
1504 (defvar gnus-exit-gnus-hook nil
1505 "*A hook called when exiting Gnus.")
1507 (defvar gnus-after-exiting-gnus-hook nil
1508 "*A hook called after exiting Gnus.")
1510 (defvar gnus-save-newsrc-hook nil
1511 "*A hook called before saving any of the newsrc files.")
1513 (defvar gnus-save-quick-newsrc-hook nil
1514 "*A hook called just before saving the quick newsrc file.
1515 Can be used to turn version control on or off.")
1517 (defvar gnus-save-standard-newsrc-hook nil
1518 "*A hook called just before saving the standard newsrc file.
1519 Can be used to turn version control on or off.")
1521 (defvar gnus-summary-update-hook
1522 (list 'gnus-summary-highlight-line)
1523 "*A hook called when a summary line is changed.
1524 The hook will not be called if `gnus-visual' is nil.
1526 The default function `gnus-summary-highlight-line' will
1527 highlight the line according to the `gnus-summary-highlight'
1530 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1531 "*A hook called when a group line is changed.
1532 The hook will not be called if `gnus-visual' is nil.
1534 The default function `gnus-group-highlight-line' will
1535 highlight the line according to the `gnus-group-highlight'
1538 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1539 "*A hook called when an article is selected for the first time.
1540 The hook is intended to mark an article as read (or unread)
1541 automatically when it is selected.")
1543 (defvar gnus-group-change-level-function nil
1544 "Function run when a group level is changed.
1545 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1547 ;; Remove any hilit infestation.
1548 (add-hook 'gnus-startup-hook
1550 (remove-hook 'gnus-summary-prepare-hook
1551 'hilit-rehighlight-buffer-quietly)
1552 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1553 (setq gnus-mark-article-hook
1554 '(gnus-summary-mark-read-and-unread-as-read))
1555 (remove-hook 'gnus-article-prepare-hook
1556 'hilit-rehighlight-buffer-quietly)))
1559 ;; Internal variables
1561 (defvar gnus-tree-buffer "*Tree*"
1562 "Buffer where Gnus thread trees are displayed.")
1565 (defvar gnus-use-generic-from nil)
1567 (defvar gnus-thread-indent-array nil)
1568 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1570 (defvar gnus-newsrc-file-version nil)
1572 (defvar gnus-method-history nil)
1573 ;; Variable holding the user answers to all method prompts.
1575 (defvar gnus-group-history nil)
1576 ;; Variable holding the user answers to all group prompts.
1578 (defvar gnus-server-alist nil
1579 "List of available servers.")
1581 (defvar gnus-group-indentation-function nil)
1583 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1585 (defvar gnus-goto-missing-group-function nil)
1587 (defvar gnus-override-subscribe-method nil)
1589 (defvar gnus-group-goto-next-group-function nil
1590 "Function to override finding the next group after listing groups.")
1592 (defconst gnus-article-mark-lists
1593 '((marked . tick) (replied . reply)
1594 (expirable . expire) (killed . killed)
1595 (bookmarks . bookmark) (dormant . dormant)
1596 (scored . score) (saved . save)
1600 ;; Avoid highlighting in kill files.
1601 (defvar gnus-summary-inhibit-highlight nil)
1602 (defvar gnus-newsgroup-selected-overlay nil)
1604 (defvar gnus-inhibit-hiding nil)
1605 (defvar gnus-group-indentation "")
1606 (defvar gnus-inhibit-limiting nil)
1607 (defvar gnus-created-frames nil)
1609 (defvar gnus-article-mode-map nil)
1610 (defvar gnus-dribble-buffer nil)
1611 (defvar gnus-headers-retrieved-by nil)
1612 (defvar gnus-article-reply nil)
1613 (defvar gnus-override-method nil)
1614 (defvar gnus-article-check-size nil)
1616 (defvar gnus-current-score-file nil)
1617 (defvar gnus-newsgroup-adaptive-score-file nil)
1618 (defvar gnus-scores-exclude-files nil)
1620 (defvar gnus-opened-servers nil)
1622 (defvar gnus-current-move-group nil)
1623 (defvar gnus-current-copy-group nil)
1624 (defvar gnus-current-crosspost-group nil)
1626 (defvar gnus-newsgroup-dependencies nil)
1627 (defvar gnus-newsgroup-async nil)
1628 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1630 (defvar gnus-newsgroup-adaptive nil)
1632 (defvar gnus-summary-display-table nil)
1633 (defvar gnus-summary-display-article-function nil)
1635 (defvar gnus-summary-highlight-line-function nil
1636 "Function called after highlighting a summary line.")
1638 (defvar gnus-group-line-format-alist
1639 `((?M gnus-tmp-marked-mark ?c)
1640 (?S gnus-tmp-subscribed ?c)
1641 (?L gnus-tmp-level ?d)
1642 (?N (cond ((eq number t) "*" )
1646 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1647 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1649 (?R gnus-tmp-number-of-read ?s)
1650 (?t gnus-tmp-number-total ?d)
1651 (?y gnus-tmp-number-of-unread ?s)
1652 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1653 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1654 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1655 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1656 (?g gnus-tmp-group ?s)
1657 (?G gnus-tmp-qualified-group ?s)
1658 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1659 (?D gnus-tmp-newsgroup-description ?s)
1660 (?o gnus-tmp-moderated ?c)
1661 (?O gnus-tmp-moderated-string ?s)
1662 (?p gnus-tmp-process-marked ?c)
1663 (?s gnus-tmp-news-server ?s)
1664 (?n gnus-tmp-news-method ?s)
1665 (?P gnus-group-indentation ?s)
1666 (?l gnus-tmp-grouplens ?s)
1667 (?z gnus-tmp-news-method-string ?s)
1668 (?u gnus-tmp-user-defined ?s)))
1670 (defvar gnus-summary-line-format-alist
1671 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1672 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1673 (?s gnus-tmp-subject-or-nil ?s)
1674 (?n gnus-tmp-name ?s)
1675 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1677 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1679 (?F gnus-tmp-from ?s)
1680 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1681 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1682 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1683 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1684 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1685 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1686 (?L gnus-tmp-lines ?d)
1687 (?I gnus-tmp-indentation ?s)
1688 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1689 (?R gnus-tmp-replied ?c)
1690 (?\[ gnus-tmp-opening-bracket ?c)
1691 (?\] gnus-tmp-closing-bracket ?c)
1692 (?\> (make-string gnus-tmp-level ? ) ?s)
1693 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1694 (?i gnus-tmp-score ?d)
1695 (?z gnus-tmp-score-char ?c)
1696 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1697 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1698 (?U gnus-tmp-unread ?c)
1699 (?t (gnus-summary-number-of-articles-in-thread
1700 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1702 (?e (gnus-summary-number-of-articles-in-thread
1703 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1705 (?u gnus-tmp-user-defined ?s))
1706 "An alist of format specifications that can appear in summary lines,
1707 and what variables they correspond with, along with the type of the
1708 variable (string, integer, character, etc).")
1710 (defvar gnus-summary-dummy-line-format-alist
1711 `((?S gnus-tmp-subject ?s)
1712 (?N gnus-tmp-number ?d)
1713 (?u gnus-tmp-user-defined ?s)))
1715 (defvar gnus-summary-mode-line-format-alist
1716 `((?G gnus-tmp-group-name ?s)
1717 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1718 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1719 (?A gnus-tmp-article-number ?d)
1720 (?Z gnus-tmp-unread-and-unselected ?s)
1721 (?V gnus-version ?s)
1722 (?U gnus-tmp-unread-and-unticked ?d)
1723 (?S gnus-tmp-subject ?s)
1724 (?e gnus-tmp-unselected ?d)
1725 (?u gnus-tmp-user-defined ?s)
1726 (?d (length gnus-newsgroup-dormant) ?d)
1727 (?t (length gnus-newsgroup-marked) ?d)
1728 (?r (length gnus-newsgroup-reads) ?d)
1729 (?E gnus-newsgroup-expunged-tally ?d)
1730 (?s (gnus-current-score-file-nondirectory) ?s)))
1732 (defvar gnus-article-mode-line-format-alist
1733 gnus-summary-mode-line-format-alist)
1735 (defvar gnus-group-mode-line-format-alist
1736 `((?S gnus-tmp-news-server ?s)
1737 (?M gnus-tmp-news-method ?s)
1738 (?u gnus-tmp-user-defined ?s)
1739 (?: gnus-tmp-colon ?s)))
1741 (defvar gnus-have-read-active-file nil)
1743 (defconst gnus-maintainer
1744 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1745 "The mail address of the Gnus maintainers.")
1747 (defconst gnus-version-number "5.3"
1748 "Version number for this version of Gnus.")
1750 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1751 "Version string for this version of Gnus.")
1753 (defvar gnus-info-nodes
1754 '((gnus-group-mode "(gnus)The Group Buffer")
1755 (gnus-summary-mode "(gnus)The Summary Buffer")
1756 (gnus-article-mode "(gnus)The Article Buffer")
1757 (gnus-server-mode "(gnus)The Server Buffer")
1758 (gnus-browse-mode "(gnus)Browse Foreign Server")
1759 (gnus-tree-mode "(gnus)Tree Display")
1761 "Alist of major modes and related Info nodes.")
1763 (defvar gnus-group-buffer "*Group*")
1764 (defvar gnus-summary-buffer "*Summary*")
1765 (defvar gnus-article-buffer "*Article*")
1766 (defvar gnus-server-buffer "*Server*")
1768 (defvar gnus-work-buffer " *gnus work*")
1770 (defvar gnus-original-article-buffer " *Original Article*")
1771 (defvar gnus-original-article nil)
1773 (defvar gnus-buffer-list nil
1774 "Gnus buffers that should be killed on exit.")
1776 (defvar gnus-slave nil
1777 "Whether this Gnus is a slave or not.")
1779 (defvar gnus-variable-list
1780 '(gnus-newsrc-options gnus-newsrc-options-n
1781 gnus-newsrc-last-checked-date
1782 gnus-newsrc-alist gnus-server-alist
1783 gnus-killed-list gnus-zombie-list
1784 gnus-topic-topology gnus-topic-alist
1786 "Gnus variables saved in the quick startup file.")
1788 (defvar gnus-newsrc-options nil
1789 "Options line in the .newsrc file.")
1791 (defvar gnus-newsrc-options-n nil
1792 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1794 (defvar gnus-newsrc-last-checked-date nil
1795 "Date Gnus last asked server for new newsgroups.")
1797 (defvar gnus-topic-topology nil
1798 "The complete topic hierarchy.")
1800 (defvar gnus-topic-alist nil
1801 "The complete topic-group alist.")
1803 (defvar gnus-newsrc-alist nil
1804 "Assoc list of read articles.
1805 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1807 (defvar gnus-newsrc-hashtb nil
1808 "Hashtable of gnus-newsrc-alist.")
1810 (defvar gnus-killed-list nil
1811 "List of killed newsgroups.")
1813 (defvar gnus-killed-hashtb nil
1814 "Hash table equivalent of gnus-killed-list.")
1816 (defvar gnus-zombie-list nil
1817 "List of almost dead newsgroups.")
1819 (defvar gnus-description-hashtb nil
1820 "Descriptions of newsgroups.")
1822 (defvar gnus-list-of-killed-groups nil
1823 "List of newsgroups that have recently been killed by the user.")
1825 (defvar gnus-active-hashtb nil
1826 "Hashtable of active articles.")
1828 (defvar gnus-moderated-list nil
1829 "List of moderated newsgroups.")
1831 (defvar gnus-group-marked nil)
1833 (defvar gnus-current-startup-file nil
1834 "Startup file for the current host.")
1836 (defvar gnus-last-search-regexp nil
1837 "Default regexp for article search command.")
1839 (defvar gnus-last-shell-command nil
1840 "Default shell command on article.")
1842 (defvar gnus-current-select-method nil
1843 "The current method for selecting a newsgroup.")
1845 (defvar gnus-group-list-mode nil)
1847 (defvar gnus-article-internal-prepare-hook nil)
1849 (defvar gnus-newsgroup-name nil)
1850 (defvar gnus-newsgroup-begin nil)
1851 (defvar gnus-newsgroup-end nil)
1852 (defvar gnus-newsgroup-last-rmail nil)
1853 (defvar gnus-newsgroup-last-mail nil)
1854 (defvar gnus-newsgroup-last-folder nil)
1855 (defvar gnus-newsgroup-last-file nil)
1856 (defvar gnus-newsgroup-auto-expire nil)
1857 (defvar gnus-newsgroup-active nil)
1859 (defvar gnus-newsgroup-data nil)
1860 (defvar gnus-newsgroup-data-reverse nil)
1861 (defvar gnus-newsgroup-limit nil)
1862 (defvar gnus-newsgroup-limits nil)
1864 (defvar gnus-newsgroup-unreads nil
1865 "List of unread articles in the current newsgroup.")
1867 (defvar gnus-newsgroup-unselected nil
1868 "List of unselected unread articles in the current newsgroup.")
1870 (defvar gnus-newsgroup-reads nil
1871 "Alist of read articles and article marks in the current newsgroup.")
1873 (defvar gnus-newsgroup-expunged-tally nil)
1875 (defvar gnus-newsgroup-marked nil
1876 "List of ticked articles in the current newsgroup (a subset of unread art).")
1878 (defvar gnus-newsgroup-killed nil
1879 "List of ranges of articles that have been through the scoring process.")
1881 (defvar gnus-newsgroup-cached nil
1882 "List of articles that come from the article cache.")
1884 (defvar gnus-newsgroup-saved nil
1885 "List of articles that have been saved.")
1887 (defvar gnus-newsgroup-kill-headers nil)
1889 (defvar gnus-newsgroup-replied nil
1890 "List of articles that have been replied to in the current newsgroup.")
1892 (defvar gnus-newsgroup-expirable nil
1893 "List of articles in the current newsgroup that can be expired.")
1895 (defvar gnus-newsgroup-processable nil
1896 "List of articles in the current newsgroup that can be processed.")
1898 (defvar gnus-newsgroup-bookmarks nil
1899 "List of articles in the current newsgroup that have bookmarks.")
1901 (defvar gnus-newsgroup-dormant nil
1902 "List of dormant articles in the current newsgroup.")
1904 (defvar gnus-newsgroup-scored nil
1905 "List of scored articles in the current newsgroup.")
1907 (defvar gnus-newsgroup-headers nil
1908 "List of article headers in the current newsgroup.")
1910 (defvar gnus-newsgroup-threads nil)
1912 (defvar gnus-newsgroup-prepared nil
1913 "Whether the current group has been prepared properly.")
1915 (defvar gnus-newsgroup-ancient nil
1916 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1918 (defvar gnus-newsgroup-sparse nil)
1920 (defvar gnus-current-article nil)
1921 (defvar gnus-article-current nil)
1922 (defvar gnus-current-headers nil)
1923 (defvar gnus-have-all-headers nil)
1924 (defvar gnus-last-article nil)
1925 (defvar gnus-newsgroup-history nil)
1926 (defvar gnus-current-kill-article nil)
1928 ;; Save window configuration.
1929 (defvar gnus-prev-winconf nil)
1931 (defvar gnus-summary-mark-positions nil)
1932 (defvar gnus-group-mark-positions nil)
1934 (defvar gnus-reffed-article-number nil)
1936 ;;; Let the byte-compiler know that we know about this variable.
1937 (defvar rmail-default-rmail-file)
1939 (defvar gnus-cache-removable-articles nil)
1941 (defvar gnus-dead-summary nil)
1943 (defconst gnus-summary-local-variables
1944 '(gnus-newsgroup-name
1945 gnus-newsgroup-begin gnus-newsgroup-end
1946 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1947 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1948 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1949 gnus-newsgroup-unselected gnus-newsgroup-marked
1950 gnus-newsgroup-reads gnus-newsgroup-saved
1951 gnus-newsgroup-replied gnus-newsgroup-expirable
1952 gnus-newsgroup-processable gnus-newsgroup-killed
1953 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1954 gnus-newsgroup-headers gnus-newsgroup-threads
1955 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1956 gnus-current-article gnus-current-headers gnus-have-all-headers
1957 gnus-last-article gnus-article-internal-prepare-hook
1958 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1959 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1960 gnus-newsgroup-async gnus-thread-expunge-below
1961 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1962 (gnus-summary-mark-below . global)
1963 gnus-newsgroup-active gnus-scores-exclude-files
1964 gnus-newsgroup-history gnus-newsgroup-ancient
1965 gnus-newsgroup-sparse
1966 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1967 gnus-newsgroup-adaptive-score-file
1968 (gnus-newsgroup-expunged-tally . 0)
1969 gnus-cache-removable-articles gnus-newsgroup-cached
1970 gnus-newsgroup-data gnus-newsgroup-data-reverse
1971 gnus-newsgroup-limit gnus-newsgroup-limits)
1972 "Variables that are buffer-local to the summary buffers.")
1974 (defconst gnus-bug-message
1975 "Sending a bug report to the Gnus Towers.
1976 ========================================
1978 The buffer below is a mail buffer. When you press `C-c C-c', it will
1979 be sent to the Gnus Bug Exterminators.
1981 At the bottom of the buffer you'll see lots of variable settings.
1982 Please do not delete those. They will tell the Bug People what your
1983 environment is, so that it will be easier to locate the bugs.
1985 If you have found a bug that makes Emacs go \"beep\", set
1986 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1987 and include the backtrace in your bug report.
1989 Please describe the bug in annoying, painstaking detail.
1991 Thank you for your help in stamping out bugs.
1994 ;;; End of variables.
1996 ;; Define some autoload functions Gnus might use.
1999 ;; This little mapcar goes through the list below and marks the
2000 ;; symbols in question as autoloaded functions.
2003 (let ((interactive (nth 1 (memq ':interactive package))))
2007 (when (consp function)
2008 (setq keymap (car (memq 'keymap function)))
2009 (setq function (car function)))
2010 (autoload function (car package) nil interactive keymap)))
2011 (if (eq (nth 1 package) ':interactive)
2014 '(("metamail" metamail-buffer)
2015 ("info" Info-goto-node)
2016 ("hexl" hexl-hex-string-to-integer)
2017 ("pp" pp pp-to-string pp-eval-expression)
2018 ("mail-extr" mail-extract-address-components)
2019 ("nnmail" nnmail-split-fancy nnmail-article-group)
2020 ("nnvirtual" nnvirtual-catchup-group)
2021 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2022 timezone-make-sortable-date timezone-make-time-string)
2023 ("rmailout" rmail-output)
2024 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2026 ("gnus-soup" :interactive t
2027 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2028 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2029 ("nnsoup" nnsoup-pack-replies)
2030 ("score-mode" :interactive t gnus-score-mode)
2031 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2032 gnus-Folder-save-name gnus-folder-save-name)
2033 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2034 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2035 gnus-server-make-menu-bar gnus-article-make-menu-bar
2036 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2037 gnus-summary-highlight-line gnus-carpal-setup-buffer
2038 gnus-group-highlight-line
2039 gnus-article-add-button gnus-insert-next-page-button
2040 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2041 ("gnus-vis" :interactive t
2042 gnus-article-push-button gnus-article-press-button
2043 gnus-article-highlight gnus-article-highlight-some
2044 gnus-article-highlight-headers gnus-article-highlight-signature
2045 gnus-article-add-buttons gnus-article-add-buttons-to-head
2046 gnus-article-next-button gnus-article-prev-button)
2047 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2048 gnus-demon-add-disconnection gnus-demon-add-handler
2049 gnus-demon-remove-handler)
2050 ("gnus-demon" :interactive t
2051 gnus-demon-init gnus-demon-cancel)
2052 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2053 gnus-tree-open gnus-tree-close)
2054 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2055 gnus-nocem-unwanted-article-p)
2056 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2057 ("gnus-srvr" gnus-browse-foreign-server)
2058 ("gnus-cite" :interactive t
2059 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2060 gnus-article-hide-citation gnus-article-fill-cited-article
2061 gnus-article-hide-citation-in-followups)
2062 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2063 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2064 gnus-execute gnus-expunge)
2065 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2066 gnus-cache-possibly-remove-articles gnus-cache-request-article
2067 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2068 gnus-cache-enter-remove-article gnus-cached-article-p
2069 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2070 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2071 gnus-cache-remove-article)
2072 ("gnus-score" :interactive t
2073 gnus-summary-increase-score gnus-summary-lower-score
2074 gnus-score-flush-cache gnus-score-close
2075 gnus-score-raise-same-subject-and-select
2076 gnus-score-raise-same-subject gnus-score-default
2077 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2078 gnus-score-lower-same-subject gnus-score-lower-thread
2079 gnus-possibly-score-headers gnus-summary-raise-score
2080 gnus-summary-set-score gnus-summary-current-score)
2082 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2083 gnus-current-score-file-nondirectory gnus-score-adaptive
2084 gnus-score-find-trace gnus-score-file-name)
2085 ("gnus-edit" :interactive t gnus-score-customize)
2086 ("gnus-topic" :interactive t gnus-topic-mode)
2087 ("gnus-topic" gnus-topic-remove-group)
2088 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2089 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2090 ("gnus-uu" :interactive t
2091 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2092 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2093 gnus-uu-mark-by-regexp gnus-uu-mark-all
2094 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2095 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2096 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2097 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2098 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2099 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2100 gnus-uu-decode-binhex-view)
2101 ("gnus-msg" (gnus-summary-send-map keymap)
2102 gnus-mail-yank-original gnus-mail-send-and-exit
2103 gnus-article-mail gnus-new-mail gnus-mail-reply)
2104 ("gnus-msg" :interactive t
2105 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2106 gnus-summary-followup gnus-summary-followup-with-original
2107 gnus-summary-cancel-article gnus-summary-supersede-article
2108 gnus-post-news gnus-inews-news
2109 gnus-summary-reply gnus-summary-reply-with-original
2110 gnus-summary-mail-forward gnus-summary-mail-other-window
2112 ("gnus-picon" :interactive t gnus-article-display-picons
2113 gnus-group-display-picons gnus-picons-article-display-x-face
2114 gnus-picons-display-x-face)
2115 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2116 gnus-grouplens-mode)
2117 ("smiley" :interactive t gnus-smiley-display)
2118 ("gnus-vm" gnus-vm-mail-setup)
2119 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2120 gnus-summary-save-article-vm))))
2124 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2125 ;; If you want the cursor to go somewhere else, set these two
2126 ;; functions in some startup hook to whatever you want.
2127 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2128 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2130 ;;; Various macros and substs.
2132 (defun gnus-header-from (header)
2133 (mail-header-from header))
2135 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2136 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2137 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2138 (w (make-symbol "w"))
2139 (buf (make-symbol "buf")))
2140 `(let* ((,tempvar (selected-window))
2142 (,w (get-buffer-window ,buf 'visible)))
2147 (pop-to-buffer ,buf))
2149 (select-window ,tempvar)))))
2151 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2152 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2153 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2155 (defmacro gnus-gethash (string hashtable)
2156 "Get hash value of STRING in HASHTABLE."
2157 `(symbol-value (intern-soft ,string ,hashtable)))
2159 (defmacro gnus-sethash (string value hashtable)
2160 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2161 `(set (intern ,string ,hashtable) ,value))
2163 (defmacro gnus-intern-safe (string hashtable)
2164 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2165 `(let ((symbol (intern ,string ,hashtable)))
2170 (defmacro gnus-group-unread (group)
2171 "Get the currently computed number of unread articles in GROUP."
2172 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2174 (defmacro gnus-group-entry (group)
2175 "Get the newsrc entry for GROUP."
2176 `(gnus-gethash ,group gnus-newsrc-hashtb))
2178 (defmacro gnus-active (group)
2179 "Get active info on GROUP."
2180 `(gnus-gethash ,group gnus-active-hashtb))
2182 (defmacro gnus-set-active (group active)
2183 "Set GROUP's active info."
2184 `(gnus-sethash ,group ,active gnus-active-hashtb))
2186 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2187 ;; function `substring' might cut on a middle of multi-octet
2189 (defun gnus-truncate-string (str width)
2190 (substring str 0 width))
2192 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2193 ;; to limit the length of a string. This function is necessary since
2194 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2195 (defsubst gnus-limit-string (str width)
2196 (if (> (length str) width)
2197 (substring str 0 width)
2200 (defsubst gnus-simplify-subject-re (subject)
2201 "Remove \"Re:\" from subject lines."
2202 (if (string-match "^[Rr][Ee]: *" subject)
2203 (substring subject (match-end 0))
2206 (defsubst gnus-functionp (form)
2207 "Return non-nil if FORM is funcallable."
2208 (or (and (symbolp form) (fboundp form))
2209 (and (listp form) (eq (car form) 'lambda))))
2211 (defsubst gnus-goto-char (point)
2212 (and point (goto-char point)))
2214 (defmacro gnus-buffer-exists-p (buffer)
2215 `(let ((buffer ,buffer))
2217 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2220 (defmacro gnus-kill-buffer (buffer)
2221 `(let ((buf ,buffer))
2222 (if (gnus-buffer-exists-p buf)
2223 (kill-buffer buf))))
2225 (defsubst gnus-point-at-bol ()
2226 "Return point at the beginning of the line."
2233 (defsubst gnus-point-at-eol ()
2234 "Return point at the end of the line."
2241 (defun gnus-alive-p ()
2242 "Say whether Gnus is running or not."
2243 (and gnus-group-buffer
2244 (get-buffer gnus-group-buffer)))
2246 (defun gnus-delete-first (elt list)
2247 "Delete by side effect the first occurrence of ELT as a member of LIST."
2248 (if (equal (car list) elt)
2251 (while (and (cdr list)
2252 (not (equal (cadr list) elt)))
2253 (setq list (cdr list)))
2255 (setcdr list (cddr list)))
2258 ;; Delete the current line (and the next N lines.);
2259 (defmacro gnus-delete-line (&optional n)
2260 `(delete-region (progn (beginning-of-line) (point))
2261 (progn (forward-line ,(or n 1)) (point))))
2263 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2264 (defvar gnus-init-inhibit nil)
2265 (defun gnus-read-init-file (&optional inhibit-next)
2266 (if gnus-init-inhibit
2267 (setq gnus-init-inhibit nil)
2268 (setq gnus-init-inhibit inhibit-next)
2270 (or (and (file-exists-p gnus-init-file)
2271 ;; Don't try to load a directory.
2272 (not (file-directory-p gnus-init-file)))
2273 (file-exists-p (concat gnus-init-file ".el"))
2274 (file-exists-p (concat gnus-init-file ".elc")))
2276 (load gnus-init-file nil t)
2278 (error "Error in %s: %s" gnus-init-file var))))))
2280 ;; Info access macros.
2282 (defmacro gnus-info-group (info)
2284 (defmacro gnus-info-rank (info)
2286 (defmacro gnus-info-read (info)
2288 (defmacro gnus-info-marks (info)
2290 (defmacro gnus-info-method (info)
2292 (defmacro gnus-info-params (info)
2295 (defmacro gnus-info-level (info)
2296 `(let ((rank (gnus-info-rank ,info)))
2300 (defmacro gnus-info-score (info)
2301 `(let ((rank (gnus-info-rank ,info)))
2302 (or (and (consp rank) (cdr rank)) 0)))
2304 (defmacro gnus-info-set-group (info group)
2305 `(setcar ,info ,group))
2306 (defmacro gnus-info-set-rank (info rank)
2307 `(setcar (nthcdr 1 ,info) ,rank))
2308 (defmacro gnus-info-set-read (info read)
2309 `(setcar (nthcdr 2 ,info) ,read))
2310 (defmacro gnus-info-set-marks (info marks)
2311 `(setcar (nthcdr 3 ,info) ,marks))
2312 (defmacro gnus-info-set-method (info method)
2313 `(setcar (nthcdr 4 ,info) ,method))
2314 (defmacro gnus-info-set-params (info params)
2315 `(setcar (nthcdr 5 ,info) ,params))
2317 (defmacro gnus-info-set-level (info level)
2318 `(let ((rank (cdr ,info)))
2319 (if (consp (car rank))
2320 (setcar (car rank) ,level)
2321 (setcar rank ,level))))
2322 (defmacro gnus-info-set-score (info score)
2323 `(let ((rank (cdr ,info)))
2324 (if (consp (car rank))
2325 (setcdr (car rank) ,score)
2326 (setcar rank (cons (car rank) ,score)))))
2328 (defmacro gnus-get-info (group)
2329 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2331 (defun gnus-byte-code (func)
2332 "Return a form that can be `eval'ed based on FUNC."
2333 (let ((fval (symbol-function func)))
2334 (if (byte-code-function-p fval)
2335 (let ((flist (append fval nil)))
2336 (setcar flist 'byte-code)
2338 (cons 'progn (cddr fval)))))
2340 ;; Find out whether the gnus-visual TYPE is wanted.
2341 (defun gnus-visual-p (&optional type class)
2342 (and gnus-visual ; Has to be non-nil, at least.
2343 (if (not type) ; We don't care about type.
2345 (if (listp gnus-visual) ; It's a list, so we check it.
2346 (or (memq type gnus-visual)
2347 (memq class gnus-visual))
2350 ;;; Load the compatability functions.
2360 (defvar gnus-shutdown-alist nil)
2362 (defun gnus-add-shutdown (function &rest symbols)
2363 "Run FUNCTION whenever one of SYMBOLS is shut down."
2364 (push (cons function symbols) gnus-shutdown-alist))
2366 (defun gnus-shutdown (symbol)
2367 "Shut down everything that waits for SYMBOL."
2368 (let ((alist gnus-shutdown-alist)
2370 (while (setq entry (pop alist))
2371 (when (memq symbol (cdr entry))
2372 (funcall (car entry))))))
2376 ;; Format specs. The chunks below are the machine-generated forms
2377 ;; that are to be evaled as the result of the default format strings.
2378 ;; We write them in here to get them byte-compiled. That way the
2379 ;; default actions will be quite fast, while still retaining the full
2380 ;; flexibility of the user-defined format specs.
2382 ;; First we have lots of dummy defvars to let the compiler know these
2383 ;; are really dynamic variables.
2385 (defvar gnus-tmp-unread)
2386 (defvar gnus-tmp-replied)
2387 (defvar gnus-tmp-score-char)
2388 (defvar gnus-tmp-indentation)
2389 (defvar gnus-tmp-opening-bracket)
2390 (defvar gnus-tmp-lines)
2391 (defvar gnus-tmp-name)
2392 (defvar gnus-tmp-closing-bracket)
2393 (defvar gnus-tmp-subject-or-nil)
2394 (defvar gnus-tmp-subject)
2395 (defvar gnus-tmp-marked)
2396 (defvar gnus-tmp-marked-mark)
2397 (defvar gnus-tmp-subscribed)
2398 (defvar gnus-tmp-process-marked)
2399 (defvar gnus-tmp-number-of-unread)
2400 (defvar gnus-tmp-group-name)
2401 (defvar gnus-tmp-group)
2402 (defvar gnus-tmp-article-number)
2403 (defvar gnus-tmp-unread-and-unselected)
2404 (defvar gnus-tmp-news-method)
2405 (defvar gnus-tmp-news-server)
2406 (defvar gnus-tmp-article-number)
2407 (defvar gnus-mouse-face)
2408 (defvar gnus-mouse-face-prop)
2410 (defun gnus-summary-line-format-spec ()
2411 (insert gnus-tmp-unread gnus-tmp-replied
2412 gnus-tmp-score-char gnus-tmp-indentation)
2413 (gnus-put-text-property
2417 gnus-tmp-opening-bracket
2418 (format "%4d: %-20s"
2420 (if (> (length gnus-tmp-name) 20)
2421 (substring gnus-tmp-name 0 20)
2423 gnus-tmp-closing-bracket)
2425 gnus-mouse-face-prop gnus-mouse-face)
2426 (insert " " gnus-tmp-subject-or-nil "\n"))
2428 (defvar gnus-summary-line-format-spec
2429 (gnus-byte-code 'gnus-summary-line-format-spec))
2431 (defun gnus-summary-dummy-line-format-spec ()
2433 (gnus-put-text-property
2438 gnus-mouse-face-prop gnus-mouse-face)
2439 (insert " " gnus-tmp-subject "\n"))
2441 (defvar gnus-summary-dummy-line-format-spec
2442 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2444 (defun gnus-group-line-format-spec ()
2445 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2446 gnus-tmp-process-marked
2447 gnus-group-indentation
2448 (format "%5s: " gnus-tmp-number-of-unread))
2449 (gnus-put-text-property
2452 (insert gnus-tmp-group "\n")
2454 gnus-mouse-face-prop gnus-mouse-face))
2455 (defvar gnus-group-line-format-spec
2456 (gnus-byte-code 'gnus-group-line-format-spec))
2458 (defvar gnus-format-specs
2459 `((version . ,emacs-version)
2460 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2461 (summary-dummy ,gnus-summary-dummy-line-format
2462 ,gnus-summary-dummy-line-format-spec)
2463 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2465 (defvar gnus-article-mode-line-format-spec nil)
2466 (defvar gnus-summary-mode-line-format-spec nil)
2467 (defvar gnus-group-mode-line-format-spec nil)
2469 ;;; Phew. All that gruft is over, fortunately.
2473 ;;; Gnus Utility Functions
2476 (defun gnus-extract-address-components (from)
2478 ;; First find the address - the thing with the @ in it. This may
2479 ;; not be accurate in mail addresses, but does the trick most of
2480 ;; the time in news messages.
2481 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2482 (setq address (substring from (match-beginning 0) (match-end 0))))
2483 ;; Then we check whether the "name <address>" format is used.
2485 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2486 ;; Linear white space is not required.
2487 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2488 (and (setq name (substring from 0 (match-beginning 0)))
2489 ;; Strip any quotes from the name.
2490 (string-match "\".*\"" name)
2491 (setq name (substring name 1 (1- (match-end 0))))))
2492 ;; If not, then "address (name)" is used.
2494 (and (string-match "(.+)" from)
2495 (setq name (substring from (1+ (match-beginning 0))
2496 (1- (match-end 0)))))
2497 (and (string-match "()" from)
2498 (setq name address))
2499 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2500 ;; XOVER might not support folded From headers.
2501 (and (string-match "(.*" from)
2502 (setq name (substring from (1+ (match-beginning 0))
2504 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2505 (list (or name from) (or address from))))
2507 (defun gnus-fetch-field (field)
2508 "Return the value of the header FIELD of current article."
2511 (let ((case-fold-search t)
2512 (inhibit-point-motion-hooks t))
2513 (nnheader-narrow-to-headers)
2514 (message-fetch-field field)))))
2516 (defun gnus-goto-colon ()
2518 (search-forward ":" (gnus-point-at-eol) t))
2521 (defun gnus-update-format (var)
2522 "Update the format specification near point."
2527 ;; Find the end of the current word.
2528 (re-search-forward "[ \t\n]" nil t)
2530 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2531 (match-string 1)))))
2532 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2533 (match-string 1 var))))
2534 (entry (assq type gnus-format-specs))
2537 (setq gnus-format-specs (delq entry gnus-format-specs)))
2539 (intern (format "%s-spec" var))
2540 (gnus-parse-format (setq value (symbol-value (intern var)))
2541 (symbol-value (intern (format "%s-alist" var)))
2542 (not (string-match "mode" var))))
2543 (setq spec (symbol-value (intern (format "%s-spec" var))))
2544 (push (list type value spec) gnus-format-specs)
2546 (pop-to-buffer "*Gnus Format*")
2548 (lisp-interaction-mode)
2549 (insert (pp-to-string spec))))
2551 (defun gnus-update-format-specifications (&optional force)
2552 "Update all (necessary) format specifications."
2553 ;; Make the indentation array.
2554 (gnus-make-thread-indent-array)
2556 ;; See whether all the stored info needs to be flushed.
2558 (not (equal emacs-version
2559 (cdr (assq 'version gnus-format-specs)))))
2560 (setq gnus-format-specs nil))
2562 ;; Go through all the formats and see whether they need updating.
2563 (let ((types '(summary summary-dummy group
2564 summary-mode group-mode article-mode))
2565 new-format entry type val)
2566 (while (setq type (pop types))
2567 ;; Jump to the proper buffer to find out the value of
2568 ;; the variable, if possible. (It may be buffer-local.)
2570 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2572 (when (and (boundp buffer)
2573 (setq val (symbol-value buffer))
2575 (buffer-name (get-buffer val)))
2576 (set-buffer (get-buffer val)))
2577 (setq new-format (symbol-value
2578 (intern (format "gnus-%s-line-format" type))))))
2579 (setq entry (cdr (assq type gnus-format-specs)))
2581 (equal (car entry) new-format))
2582 ;; Use the old format.
2583 (set (intern (format "gnus-%s-line-format-spec" type))
2585 ;; This is a new format.
2587 (if (not (stringp new-format))
2588 ;; This is a function call or something.
2590 ;; This is a "real" format.
2594 (intern (format "gnus-%s-line-format-alist"
2595 (if (eq type 'article-mode)
2596 'summary-mode type))))
2597 (not (string-match "mode$" (symbol-name type))))))
2598 ;; Enter the new format spec into the list.
2601 (setcar (cdr entry) val)
2602 (setcar entry new-format))
2603 (push (list type new-format val) gnus-format-specs))
2604 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2606 (unless (assq 'version gnus-format-specs)
2607 (push (cons 'version emacs-version) gnus-format-specs))
2609 (gnus-update-group-mark-positions)
2610 (gnus-update-summary-mark-positions))
2612 (defun gnus-update-summary-mark-positions ()
2613 "Compute where the summary marks are to go."
2615 (when (and gnus-summary-buffer
2616 (get-buffer gnus-summary-buffer)
2617 (buffer-name (get-buffer gnus-summary-buffer)))
2618 (set-buffer gnus-summary-buffer))
2619 (let ((gnus-replied-mark 129)
2620 (gnus-score-below-mark 130)
2621 (gnus-score-over-mark 130)
2624 (spec gnus-summary-line-format-spec)
2627 (gnus-set-work-buffer)
2628 (let ((gnus-summary-line-format-spec spec))
2629 (gnus-summary-insert-line
2630 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2631 (goto-char (point-min))
2632 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2634 (goto-char (point-min))
2635 (push (cons 'replied (and (search-forward "\201" nil t)
2638 (goto-char (point-min))
2639 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2641 (setq gnus-summary-mark-positions pos))))
2643 (defun gnus-update-group-mark-positions ()
2645 (let ((gnus-process-mark 128)
2646 (gnus-group-marked '("dummy.group"))
2647 (gnus-active-hashtb (make-vector 10 0)))
2648 (gnus-set-active "dummy.group" '(0 . 0))
2649 (gnus-set-work-buffer)
2650 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2651 (goto-char (point-min))
2652 (setq gnus-group-mark-positions
2653 (list (cons 'process (and (search-forward "\200" nil t)
2654 (- (point) 2))))))))
2656 (defvar gnus-mouse-face-0 'highlight)
2657 (defvar gnus-mouse-face-1 'highlight)
2658 (defvar gnus-mouse-face-2 'highlight)
2659 (defvar gnus-mouse-face-3 'highlight)
2660 (defvar gnus-mouse-face-4 'highlight)
2662 (defun gnus-mouse-face-function (form type)
2663 `(gnus-put-text-property
2664 (point) (progn ,@form (point))
2665 gnus-mouse-face-prop
2668 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2670 (defvar gnus-face-0 'bold)
2671 (defvar gnus-face-1 'italic)
2672 (defvar gnus-face-2 'bold-italic)
2673 (defvar gnus-face-3 'bold)
2674 (defvar gnus-face-4 'bold)
2676 (defun gnus-face-face-function (form type)
2677 `(gnus-put-text-property
2678 (point) (progn ,@form (point))
2679 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2681 (defun gnus-max-width-function (el max-width)
2682 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2684 `(if (> (length ,el) ,max-width)
2685 (substring ,el 0 ,max-width)
2687 `(let ((val (eval ,el)))
2689 (setq val (int-to-string val)))
2690 (if (> (length val) ,max-width)
2691 (substring val 0 ,max-width)
2694 (defun gnus-parse-format (format spec-alist &optional insert)
2695 ;; This function parses the FORMAT string with the help of the
2696 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2697 ;; string. If the FORMAT string contains the specifiers %( and %)
2698 ;; the text between them will have the mouse-face text property.
2700 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2702 (gnus-parse-complex-format format spec-alist)
2703 ;; This is a simple format.
2704 (gnus-parse-simple-format format spec-alist insert)))
2706 (defun gnus-parse-complex-format (format spec-alist)
2708 (gnus-set-work-buffer)
2710 (goto-char (point-min))
2711 (while (re-search-forward "\"" nil t)
2712 (replace-match "\\\"" nil t))
2713 (goto-char (point-min))
2715 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2716 (let ((number (if (match-beginning 1)
2717 (match-string 1) "0"))
2718 (delim (aref (match-string 2) 0)))
2719 (if (or (= delim ?\() (= delim ?\{))
2720 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2722 (replace-match "\")\""))))
2723 (goto-char (point-max))
2725 (goto-char (point-min))
2726 (let ((form (read (current-buffer))))
2727 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2729 (defun gnus-complex-form-to-spec (form spec-alist)
2734 (gnus-parse-simple-format sform spec-alist t)
2735 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2736 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2740 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2741 ;; This function parses the FORMAT string with the help of the
2742 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2745 spec flist fstring newspec elem beg result dontinsert)
2747 (gnus-set-work-buffer)
2749 (goto-char (point-min))
2750 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2752 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2754 beg (1+ (match-beginning 0)))
2755 ;; First check if there are any specs that look anything like
2756 ;; "%12,12A", ie. with a "max width specification". These have
2757 ;; to be treated specially.
2758 (if (setq beg (match-beginning 1))
2762 (1+ (match-beginning 1)) (match-end 1))))
2764 (setq beg (match-beginning 2)))
2765 ;; Find the specification from `spec-alist'.
2766 (unless (setq elem (cdr (assq spec spec-alist)))
2767 (setq elem '("*" ?s)))
2768 ;; Treat user defined format specifiers specially.
2769 (when (eq (car elem) 'gnus-tmp-user-defined)
2772 (list (intern (concat "gnus-user-format-function-"
2774 'gnus-tmp-header) ?s))
2775 (delete-region (match-beginning 3) (match-end 3)))
2776 (if (not (zerop max-width))
2777 (let ((el (car elem)))
2778 (cond ((= (cadr elem) ?c)
2779 (setq el (list 'char-to-string el)))
2781 (setq el (list 'int-to-string el))))
2782 (setq flist (cons (gnus-max-width-function el max-width)
2786 (setq flist (cons (car elem) flist))
2787 (setq newspec (cadr elem)))))
2788 ;; Remove the old specification (and possibly a ",12" string).
2789 (delete-region beg (match-end 2))
2790 ;; Insert the new specification.
2793 (setq fstring (buffer-substring 1 (point-max))))
2794 ;; Do some postprocessing to increase efficiency.
2799 ((string= fstring "")
2801 ;; Not a format string.
2802 ((not (string-match "%" fstring))
2804 ;; A format string with just a single string spec.
2805 ((string= fstring "%s")
2807 ;; A single character.
2808 ((string= fstring "%c")
2811 ((string= fstring "%d")
2814 (list `(princ ,(car flist)))
2815 (list `(int-to-string ,(car flist)))))
2816 ;; Just lots of chars and strings.
2817 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2819 ;; A single string spec at the beginning of the spec.
2820 ((string-match "\\`%[sc][^%]+\\'" fstring)
2821 (list (car flist) (substring fstring 2)))
2822 ;; A single string spec in the middle of the spec.
2823 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2824 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2825 ;; A single string spec in the end of the spec.
2826 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2827 (list (match-string 1 fstring) (car flist)))
2828 ;; A more complex spec.
2830 (list (cons 'format (cons fstring (nreverse flist)))))))
2836 (cons 'insert result)))
2837 (cond ((stringp result)
2840 (cons 'concat result))
2843 (defun gnus-eval-format (format &optional alist props)
2844 "Eval the format variable FORMAT, using ALIST.
2845 If PROPS, insert the result."
2846 (let ((form (gnus-parse-format format alist props)))
2848 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2851 (defun gnus-remove-text-with-property (prop)
2852 "Delete all text in the current buffer with text property PROP."
2854 (goto-char (point-min))
2856 (while (get-text-property (point) prop)
2858 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2860 (defun gnus-set-work-buffer ()
2861 (if (get-buffer gnus-work-buffer)
2863 (set-buffer gnus-work-buffer)
2865 (set-buffer (get-buffer-create gnus-work-buffer))
2866 (kill-all-local-variables)
2867 (buffer-disable-undo (current-buffer))
2868 (gnus-add-current-to-buffer-list)))
2870 ;; Article file names when saving.
2872 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2873 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2874 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2875 Otherwise, it is like ~/News/news/group/num."
2878 (concat (if (gnus-use-long-file-name 'not-save)
2879 (gnus-capitalize-newsgroup newsgroup)
2880 (gnus-newsgroup-directory-form newsgroup))
2881 "/" (int-to-string (mail-header-number headers)))
2882 gnus-article-save-directory)))
2884 (string-equal (file-name-directory default)
2885 (file-name-directory last-file))
2886 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2888 (or last-file default))))
2890 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2891 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2892 If variable `gnus-use-long-file-name' is non-nil, it is
2893 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2896 (concat (if (gnus-use-long-file-name 'not-save)
2898 (gnus-newsgroup-directory-form newsgroup))
2899 "/" (int-to-string (mail-header-number headers)))
2900 gnus-article-save-directory)))
2902 (string-equal (file-name-directory default)
2903 (file-name-directory last-file))
2904 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2906 (or last-file default))))
2908 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2909 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2910 If variable `gnus-use-long-file-name' is non-nil, it is
2911 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2914 (if (gnus-use-long-file-name 'not-save)
2915 (gnus-capitalize-newsgroup newsgroup)
2916 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2917 gnus-article-save-directory)))
2919 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2920 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2921 If variable `gnus-use-long-file-name' is non-nil, it is
2922 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2925 (if (gnus-use-long-file-name 'not-save)
2927 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2928 gnus-article-save-directory)))
2930 ;; For subscribing new newsgroup
2932 (defun gnus-subscribe-hierarchical-interactive (groups)
2933 (let ((groups (sort groups 'string<))
2934 prefixes prefix start ans group starts)
2936 (setq prefixes (list "^"))
2937 (while (and groups prefixes)
2938 (while (not (string-match (car prefixes) (car groups)))
2939 (setq prefixes (cdr prefixes)))
2940 (setq prefix (car prefixes))
2941 (setq start (1- (length prefix)))
2942 (if (and (string-match "[^\\.]\\." (car groups) start)
2945 (concat "^" (substring (car groups) 0 (match-end 0))))
2946 (string-match prefix (cadr groups)))
2948 (setq prefixes (cons prefix prefixes))
2949 (message "Descend hierarchy %s? ([y]nsq): "
2950 (substring prefix 1 (1- (length prefix))))
2951 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2953 (message "Descend hierarchy %s? ([y]nsq): "
2954 (substring prefix 1 (1- (length prefix)))))
2957 (string-match prefix
2958 (setq group (car groups))))
2959 (setq gnus-killed-list
2960 (cons group gnus-killed-list))
2961 (gnus-sethash group group gnus-killed-hashtb)
2962 (setq groups (cdr groups)))
2963 (setq starts (cdr starts)))
2966 (string-match prefix
2967 (setq group (car groups))))
2968 (gnus-sethash group group gnus-killed-hashtb)
2969 (gnus-subscribe-alphabetically (car groups))
2970 (setq groups (cdr groups)))
2971 (setq starts (cdr starts)))
2974 (setq group (car groups))
2975 (setq gnus-killed-list (cons group gnus-killed-list))
2976 (gnus-sethash group group gnus-killed-hashtb)
2977 (setq groups (cdr groups))))
2979 (message "Subscribe %s? ([n]yq)" (car groups))
2980 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2982 (message "Subscribe %s? ([n]yq)" (car groups)))
2983 (setq group (car groups))
2985 (gnus-subscribe-alphabetically (car groups))
2986 (gnus-sethash group group gnus-killed-hashtb))
2989 (setq group (car groups))
2990 (setq gnus-killed-list (cons group gnus-killed-list))
2991 (gnus-sethash group group gnus-killed-hashtb)
2992 (setq groups (cdr groups))))
2994 (setq gnus-killed-list (cons group gnus-killed-list))
2995 (gnus-sethash group group gnus-killed-hashtb)))
2996 (setq groups (cdr groups)))))))
2998 (defun gnus-subscribe-randomly (newsgroup)
2999 "Subscribe new NEWSGROUP by making it the first newsgroup."
3000 (gnus-subscribe-newsgroup newsgroup))
3002 (defun gnus-subscribe-alphabetically (newgroup)
3003 "Subscribe new NEWSGROUP and insert it in alphabetical order."
3004 (let ((groups (cdr gnus-newsrc-alist))
3006 (while (and (not before) groups)
3007 (if (string< newgroup (caar groups))
3008 (setq before (caar groups))
3009 (setq groups (cdr groups))))
3010 (gnus-subscribe-newsgroup newgroup before)))
3012 (defun gnus-subscribe-hierarchically (newgroup)
3013 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
3014 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3016 (set-buffer (find-file-noselect gnus-current-startup-file))
3017 (let ((groupkey newgroup)
3019 (while (and (not before) groupkey)
3020 (goto-char (point-min))
3022 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3023 (while (and (re-search-forward groupkey-re nil t)
3025 (setq before (match-string 1))
3026 (string< before newgroup)))))
3027 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3029 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3030 (substring groupkey (match-beginning 1) (match-end 1)))))
3031 (gnus-subscribe-newsgroup newgroup before))
3032 (kill-buffer (current-buffer))))
3034 (defun gnus-subscribe-interactively (group)
3035 "Subscribe the new GROUP interactively.
3036 It is inserted in hierarchical newsgroup order if subscribed. If not,
3038 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3039 (gnus-subscribe-hierarchically group)
3040 (push group gnus-killed-list)))
3042 (defun gnus-subscribe-zombies (group)
3043 "Make the new GROUP into a zombie group."
3044 (push group gnus-zombie-list))
3046 (defun gnus-subscribe-killed (group)
3047 "Make the new GROUP a killed group."
3048 (push group gnus-killed-list))
3050 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3051 "Subscribe new NEWSGROUP.
3052 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3053 the first newsgroup."
3054 ;; We subscribe the group by changing its level to `subscribed'.
3055 (gnus-group-change-level
3056 newsgroup gnus-level-default-subscribed
3057 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3058 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3062 (defun gnus-newsgroup-directory-form (newsgroup)
3063 "Make hierarchical directory name from NEWSGROUP name."
3064 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3065 (len (length newsgroup))
3067 ;; If this is a foreign group, we don't want to translate the
3069 (if (setq idx (string-match ":" newsgroup))
3070 (aset newsgroup idx ?/)
3072 ;; Replace all occurrences of `.' with `/'.
3074 (if (= (aref newsgroup idx) ?.)
3075 (aset newsgroup idx ?/))
3076 (setq idx (1+ idx)))
3079 (defun gnus-newsgroup-savable-name (group)
3080 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3082 (nnheader-replace-chars-in-string group ?/ ?.))
3084 (defun gnus-make-directory (dir)
3085 "Make DIRECTORY recursively."
3086 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3087 ;; of the many mysteries of the universe.
3088 (let* ((dir (expand-file-name dir default-directory))
3090 (if (string-match "/$" dir)
3091 (setq dir (substring dir 0 (match-beginning 0))))
3092 ;; First go down the path until we find a directory that exists.
3093 (while (not (file-exists-p dir))
3094 (setq dirs (cons dir dirs))
3095 (string-match "/[^/]+$" dir)
3096 (setq dir (substring dir 0 (match-beginning 0))))
3097 ;; Then create all the subdirs.
3098 (while (and dirs (not err))
3100 (make-directory (car dirs))
3101 (error (setq err t)))
3102 (setq dirs (cdr dirs)))
3103 ;; We return whether we were successful or not.
3106 (defun gnus-capitalize-newsgroup (newsgroup)
3107 "Capitalize NEWSGROUP name."
3108 (and (not (zerop (length newsgroup)))
3109 (concat (char-to-string (upcase (aref newsgroup 0)))
3110 (substring newsgroup 1))))
3112 ;; Various... things.
3114 (defun gnus-simplify-subject (subject &optional re-only)
3115 "Remove `Re:' and words in parentheses.
3116 If RE-ONLY is non-nil, strip leading `Re:'s only."
3117 (let ((case-fold-search t)) ;Ignore case.
3118 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3119 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3120 (setq subject (substring subject (match-end 0))))
3121 ;; Remove uninteresting prefixes.
3122 (if (and (not re-only)
3123 gnus-simplify-ignored-prefixes
3124 (string-match gnus-simplify-ignored-prefixes subject))
3125 (setq subject (substring subject (match-end 0))))
3126 ;; Remove words in parentheses from end.
3128 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3129 (setq subject (substring subject 0 (match-beginning 0)))))
3130 ;; Return subject string.
3133 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3135 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3136 (defun gnus-simplify-buffer-fuzzy ()
3137 (let ((case-fold-search t))
3138 (goto-char (point-min))
3139 (while (search-forward "\t" nil t)
3140 (replace-match " " t t))
3141 (goto-char (point-min))
3142 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3143 (goto-char (match-beginning 0))
3145 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3146 (looking-at "^[[].*: .*[]]$"))
3147 (goto-char (point-min))
3148 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3150 (replace-match "" t t))
3151 (goto-char (point-min))
3152 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3153 (goto-char (match-end 0))
3156 (progn (goto-char (match-beginning 0)))
3157 (re-search-forward ":"))))
3158 (goto-char (point-min))
3159 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3160 (replace-match "" t t))
3161 (goto-char (point-min))
3162 (while (re-search-forward " +" nil t)
3163 (replace-match " " t t))
3164 (goto-char (point-min))
3165 (while (re-search-forward " $" nil t)
3166 (replace-match "" t t))
3167 (goto-char (point-min))
3168 (while (re-search-forward "^ +" nil t)
3169 (replace-match "" t t))
3170 (goto-char (point-min))
3171 (when gnus-simplify-subject-fuzzy-regexp
3172 (if (listp gnus-simplify-subject-fuzzy-regexp)
3173 (let ((list gnus-simplify-subject-fuzzy-regexp))
3175 (goto-char (point-min))
3176 (while (re-search-forward (car list) nil t)
3177 (replace-match "" t t))
3178 (setq list (cdr list))))
3179 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3180 (replace-match "" t t))))))
3182 (defun gnus-simplify-subject-fuzzy (subject)
3183 "Siplify a subject string fuzzily."
3185 (gnus-set-work-buffer)
3186 (let ((case-fold-search t))
3188 (inline (gnus-simplify-buffer-fuzzy))
3191 ;; Add the current buffer to the list of buffers to be killed on exit.
3192 (defun gnus-add-current-to-buffer-list ()
3193 (or (memq (current-buffer) gnus-buffer-list)
3194 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3196 (defun gnus-string> (s1 s2)
3197 (not (or (string< s1 s2)
3200 (defun gnus-read-active-file-p ()
3201 "Say whether the active file has been read from `gnus-select-method'."
3202 (memq gnus-select-method gnus-have-read-active-file))
3204 ;;; General various misc type functions.
3206 (defun gnus-clear-system ()
3207 "Clear all variables and buffers."
3208 ;; Clear Gnus variables.
3209 (let ((variables gnus-variable-list))
3211 (set (car variables) nil)
3212 (setq variables (cdr variables))))
3213 ;; Clear other internal variables.
3214 (setq gnus-list-of-killed-groups nil
3215 gnus-have-read-active-file nil
3216 gnus-newsrc-alist nil
3217 gnus-newsrc-hashtb nil
3218 gnus-killed-list nil
3219 gnus-zombie-list nil
3220 gnus-killed-hashtb nil
3221 gnus-active-hashtb nil
3222 gnus-moderated-list nil
3223 gnus-description-hashtb nil
3224 gnus-current-headers nil
3225 gnus-thread-indent-array nil
3226 gnus-newsgroup-headers nil
3227 gnus-newsgroup-name nil
3228 gnus-server-alist nil
3229 gnus-group-list-mode nil
3230 gnus-opened-servers nil
3231 gnus-group-mark-positions nil
3232 gnus-newsgroup-data nil
3233 gnus-newsgroup-unreads nil
3234 nnoo-state-alist nil
3235 gnus-current-select-method nil)
3236 (gnus-shutdown 'gnus)
3237 ;; Kill the startup file.
3238 (and gnus-current-startup-file
3239 (get-file-buffer gnus-current-startup-file)
3240 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3241 ;; Clear the dribble buffer.
3242 (gnus-dribble-clear)
3243 ;; Kill global KILL file buffer.
3244 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3245 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3246 (gnus-kill-buffer nntp-server-buffer)
3247 ;; Kill Gnus buffers.
3248 (while gnus-buffer-list
3249 (gnus-kill-buffer (pop gnus-buffer-list)))
3250 ;; Remove Gnus frames.
3251 (gnus-kill-gnus-frames))
3253 (defun gnus-kill-gnus-frames ()
3254 "Kill all frames Gnus has created."
3255 (while gnus-created-frames
3256 (when (frame-live-p (car gnus-created-frames))
3257 ;; We slap a condition-case around this `delete-frame' to ensure
3258 ;; against errors if we try do delete the single frame that's left.
3260 (delete-frame (car gnus-created-frames))
3262 (pop gnus-created-frames)))
3264 (defun gnus-windows-old-to-new (setting)
3265 ;; First we take care of the really, really old Gnus 3 actions.
3266 (when (symbolp setting)
3268 ;; Take care of ooold GNUS 3.x values.
3269 (cond ((eq setting 'SelectArticle) 'article)
3270 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3271 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3273 (if (or (listp setting)
3274 (not (and gnus-window-configuration
3275 (memq setting '(group summary article)))))
3277 (let* ((setting (if (eq setting 'group)
3278 (if (assq 'newsgroup gnus-window-configuration)
3280 'newsgroups) setting))
3281 (elem (cadr (assq setting gnus-window-configuration)))
3282 (total (apply '+ elem))
3283 (types '(group summary article))
3284 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3289 (or (not (numberp (nth i elem)))
3290 (zerop (nth i elem))
3292 (setq perc (if (= i 2)
3294 (/ (float (nth 0 elem)) total)))
3295 (setq out (cons (if (eq pbuf (nth i types))
3296 (list (nth i types) perc 'point)
3297 (list (nth i types) perc))
3300 `(vertical 1.0 ,@(nreverse out)))))
3303 (defun gnus-add-configuration (conf)
3304 "Add the window configuration CONF to `gnus-buffer-configuration'."
3305 (setq gnus-buffer-configuration
3306 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3307 gnus-buffer-configuration))))
3309 (defvar gnus-frame-list nil)
3311 (defun gnus-configure-frame (split &optional window)
3312 "Split WINDOW according to SPLIT."
3314 (setq window (get-buffer-window (current-buffer))))
3315 (select-window window)
3316 ;; This might be an old-stylee buffer config.
3317 (when (vectorp split)
3318 (setq split (append split nil)))
3319 (when (or (consp (car split))
3320 (vectorp (car split)))
3322 (push 'vertical split))
3323 ;; The SPLIT might be something that is to be evaled to
3324 ;; return a new SPLIT.
3325 (while (and (not (assq (car split) gnus-window-to-buffer))
3326 (gnus-functionp (car split)))
3327 (setq split (eval split)))
3328 (let* ((type (car split))
3330 (len (if (eq type 'horizontal) (window-width) (window-height)))
3332 (window-min-width (or gnus-window-min-width window-min-width))
3333 (window-min-height (or gnus-window-min-height window-min-height))
3334 s result new-win rest comp-subs size sub)
3336 ;; Nothing to do here.
3338 ;; Don't switch buffers.
3340 (and (memq 'point split) window))
3341 ;; This is a buffer to be selected.
3342 ((not (memq type '(frame horizontal vertical)))
3343 (let ((buffer (cond ((stringp type) type)
3344 (t (cdr (assq type gnus-window-to-buffer)))))
3347 (error "Illegal buffer type: %s" type))
3348 (unless (setq buf (get-buffer (if (symbolp buffer)
3349 (symbol-value buffer) buffer)))
3350 (setq buf (get-buffer-create (if (symbolp buffer)
3351 (symbol-value buffer) buffer))))
3352 (switch-to-buffer buf)
3353 ;; We return the window if it has the `point' spec.
3354 (and (memq 'point split) window)))
3355 ;; This is a frame split.
3357 (unless gnus-frame-list
3358 (setq gnus-frame-list (list (window-frame
3359 (get-buffer-window (current-buffer))))))
3361 params frame fresult)
3362 (while (< i (length subs))
3363 ;; Frame parameter is gotten from the sub-split.
3364 (setq params (cadr (elt subs i)))
3365 ;; It should be a list.
3366 (unless (listp params)
3368 ;; Create a new frame?
3369 (unless (setq frame (elt gnus-frame-list i))
3370 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3371 (push frame gnus-created-frames))
3372 ;; Is the old frame still alive?
3373 (unless (frame-live-p frame)
3374 (setcar (nthcdr i gnus-frame-list)
3375 (setq frame (make-frame params))))
3376 ;; Select the frame in question and do more splits there.
3377 (select-frame frame)
3378 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3380 ;; Select the frame that has the selected buffer.
3382 (select-frame (window-frame fresult)))))
3383 ;; This is a normal split.
3385 (when (> (length subs) 0)
3386 ;; First we have to compute the sizes of all new windows.
3388 (setq sub (append (pop subs) nil))
3389 (while (and (not (assq (car sub) gnus-window-to-buffer))
3390 (gnus-functionp (car sub)))
3391 (setq sub (eval sub)))
3393 (push sub comp-subs)
3394 (setq size (cadar comp-subs))
3395 (cond ((equal size 1.0)
3396 (setq rest (car comp-subs))
3399 (setq s (floor (* size len))))
3403 (error "Illegal size: %s" size)))
3404 ;; Try to make sure that we are inside the safe limits.
3406 ((eq type 'horizontal)
3407 (setq s (max s window-min-width)))
3408 ((eq type 'vertical)
3409 (setq s (max s window-min-height))))
3410 (setcar (cdar comp-subs) s)
3412 ;; Take care of the "1.0" spec.
3414 (setcar (cdr rest) (- len total))
3415 (error "No 1.0 specs in %s" split))
3416 ;; The we do the actual splitting in a nice recursive
3418 (setq comp-subs (nreverse comp-subs))
3420 (if (null (cdr comp-subs))
3421 (setq new-win window)
3423 (split-window window (cadar comp-subs)
3424 (eq type 'horizontal))))
3425 (setq result (or (gnus-configure-frame
3426 (car comp-subs) window) result))
3427 (select-window new-win)
3428 (setq window new-win)
3429 (setq comp-subs (cdr comp-subs))))
3430 ;; Return the proper window, if any.
3432 (select-window result))))))
3434 (defvar gnus-frame-split-p nil)
3436 (defun gnus-configure-windows (setting &optional force)
3437 (setq setting (gnus-windows-old-to-new setting))
3438 (let ((split (if (symbolp setting)
3439 (cadr (assq setting gnus-buffer-configuration))
3443 (setq gnus-frame-split-p nil)
3446 (error "No such setting: %s" setting))
3448 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3450 ;; All the windows mentioned are already visible, so we just
3451 ;; put point in the assigned buffer, and do not touch the
3453 (select-window all-visible)
3455 ;; Either remove all windows or just remove all Gnus windows.
3456 (let ((frame (selected-frame)))
3458 (if gnus-use-full-window
3459 ;; We want to remove all other windows.
3460 (if (not gnus-frame-split-p)
3461 ;; This is not a `frame' split, so we ignore the
3463 (delete-other-windows)
3464 ;; This is a `frame' split, so we delete all windows
3468 (unless (eq (cdr (assq 'minibuffer
3469 (frame-parameters frame)))
3471 (select-frame frame)
3472 (delete-other-windows)))
3474 ;; Just remove some windows.
3475 (gnus-remove-some-windows)
3476 (switch-to-buffer nntp-server-buffer))
3477 (select-frame frame)))
3479 (switch-to-buffer nntp-server-buffer)
3480 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3482 (defun gnus-all-windows-visible-p (split)
3483 "Say whether all buffers in SPLIT are currently visible.
3484 In particular, the value returned will be the window that
3486 (let ((stack (list split))
3488 type buffer win buf)
3489 (while (and (setq split (pop stack))
3491 ;; Be backwards compatible.
3492 (when (vectorp split)
3493 (setq split (append split nil)))
3494 (when (or (consp (car split))
3495 (vectorp (car split)))
3497 (push 'vertical split))
3498 ;; The SPLIT might be something that is to be evaled to
3499 ;; return a new SPLIT.
3500 (while (and (not (assq (car split) gnus-window-to-buffer))
3501 (gnus-functionp (car split)))
3502 (setq split (eval split)))
3504 (setq type (elt split 0))
3509 ((not (memq type '(horizontal vertical frame)))
3510 (setq buffer (cond ((stringp type) type)
3511 (t (cdr (assq type gnus-window-to-buffer)))))
3513 (error "Illegal buffer type: %s" type))
3514 (when (setq buf (get-buffer (if (symbolp buffer)
3515 (symbol-value buffer)
3517 (setq win (get-buffer-window buf t)))
3519 (when (memq 'point split)
3520 (setq all-visible win))
3521 (setq all-visible nil)))
3523 (when (eq type 'frame)
3524 (setq gnus-frame-split-p t))
3525 (setq stack (append (cddr split) stack)))))
3526 (unless (eq all-visible t)
3529 (defun gnus-window-top-edge (&optional window)
3530 (nth 1 (window-edges window)))
3532 (defun gnus-remove-some-windows ()
3533 (let ((buffers gnus-window-to-buffer)
3534 buf bufs lowest-buf lowest)
3536 ;; Remove windows on all known Gnus buffers.
3538 (setq buf (cdar buffers))
3540 (setq buf (and (boundp buf) (symbol-value buf))))
3542 (get-buffer-window buf)
3544 (setq bufs (cons buf bufs))
3546 (if (or (not lowest)
3547 (< (gnus-window-top-edge) lowest))
3549 (setq lowest (gnus-window-top-edge))
3550 (setq lowest-buf buf)))))
3551 (setq buffers (cdr buffers)))
3552 ;; Remove windows on *all* summary buffers.
3555 (let ((buf (window-buffer win)))
3556 (if (string-match "^\\*Summary" (buffer-name buf))
3558 (setq bufs (cons buf bufs))
3560 (if (or (not lowest)
3561 (< (gnus-window-top-edge) lowest))
3563 (setq lowest-buf buf)
3564 (setq lowest (gnus-window-top-edge)))))))))
3567 (pop-to-buffer lowest-buf)
3568 (switch-to-buffer nntp-server-buffer)))
3570 (and (not (eq (car bufs) lowest-buf))
3571 (delete-windows-on (car bufs)))
3572 (setq bufs (cdr bufs))))))
3574 (defun gnus-version (&optional arg)
3575 "Version number of this version of Gnus.
3576 If ARG, insert string at point."
3578 (let ((methods gnus-valid-select-methods)
3581 ;; Go through all the legal select methods and add their version
3582 ;; numbers to the total version string. Only the backends that are
3583 ;; currently in use will have their message numbers taken into
3586 (setq meth (intern (concat (caar methods) "-version")))
3588 (stringp (symbol-value meth))
3589 (setq mess (concat mess "; " (symbol-value meth))))
3590 (setq methods (cdr methods)))
3592 (insert (message mess))
3595 (defun gnus-info-find-node ()
3596 "Find Info documentation of Gnus."
3598 ;; Enlarge info window if needed.
3599 (let ((mode major-mode)
3601 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3602 (setq gnus-info-buffer (current-buffer))
3603 (gnus-configure-windows 'info)))
3605 (defun gnus-days-between (date1 date2)
3606 ;; Return the number of days between date1 and date2.
3607 (- (gnus-day-number date1) (gnus-day-number date2)))
3609 (defun gnus-day-number (date)
3610 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3611 (timezone-parse-date date))))
3612 (timezone-absolute-from-gregorian
3613 (nth 1 dat) (nth 2 dat) (car dat))))
3615 (defun gnus-encode-date (date)
3616 "Convert DATE to internal time."
3617 (let* ((parse (timezone-parse-date date))
3618 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3619 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3620 (encode-time (caddr time) (cadr time) (car time)
3621 (caddr date) (cadr date) (car date) (nth 4 date))))
3623 (defun gnus-time-minus (t1 t2)
3624 "Subtract two internal times."
3625 (let ((borrow (< (cadr t1) (cadr t2))))
3626 (list (- (car t1) (car t2) (if borrow 1 0))
3627 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3629 (defun gnus-file-newer-than (file date)
3630 (let ((fdate (nth 5 (file-attributes file))))
3631 (or (> (car fdate) (car date))
3632 (and (= (car fdate) (car date))
3633 (> (nth 1 fdate) (nth 1 date))))))
3635 (defmacro gnus-local-set-keys (&rest plist)
3636 "Set the keys in PLIST in the current keymap."
3637 `(gnus-define-keys-1 (current-local-map) ',plist))
3639 (defmacro gnus-define-keys (keymap &rest plist)
3640 "Define all keys in PLIST in KEYMAP."
3641 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3643 (put 'gnus-define-keys 'lisp-indent-function 1)
3644 (put 'gnus-define-keys 'lisp-indent-hook 1)
3645 (put 'gnus-define-keymap 'lisp-indent-function 1)
3646 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3648 (defmacro gnus-define-keymap (keymap &rest plist)
3649 "Define all keys in PLIST in KEYMAP."
3650 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3652 (defun gnus-define-keys-1 (keymap plist)
3654 (error "Can't set keys in a null keymap"))
3655 (cond ((symbolp keymap)
3656 (setq keymap (symbol-value keymap)))
3659 (set (car keymap) nil)
3660 (define-prefix-command (car keymap))
3661 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3662 (setq keymap (symbol-value (car keymap)))))
3665 (when (symbolp (setq key (pop plist)))
3666 (setq key (symbol-value key)))
3667 (define-key keymap key (pop plist)))))
3669 (defun gnus-group-read-only-p (&optional group)
3670 "Check whether GROUP supports editing or not.
3671 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3672 that that variable is buffer-local to the summary buffers."
3673 (let ((group (or group gnus-newsgroup-name)))
3674 (not (gnus-check-backend-function 'request-replace-article group))))
3676 (defun gnus-group-total-expirable-p (group)
3677 "Check whether GROUP is total-expirable or not."
3678 (let ((params (gnus-info-params (gnus-get-info group))))
3679 (or (memq 'total-expire params)
3680 (cdr (assq 'total-expire params)) ; (total-expire . t)
3681 (and gnus-total-expirable-newsgroups ; Check var.
3682 (string-match gnus-total-expirable-newsgroups group)))))
3684 (defun gnus-group-auto-expirable-p (group)
3685 "Check whether GROUP is total-expirable or not."
3686 (let ((params (gnus-info-params (gnus-get-info group))))
3687 (or (memq 'auto-expire params)
3688 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3689 (and gnus-auto-expirable-newsgroups ; Check var.
3690 (string-match gnus-auto-expirable-newsgroups group)))))
3692 (defun gnus-virtual-group-p (group)
3693 "Say whether GROUP is virtual or not."
3694 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3695 gnus-valid-select-methods)))
3697 (defun gnus-news-group-p (group &optional article)
3698 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3699 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3700 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3701 (eq (gnus-request-type group article) 'news))))
3703 (defsubst gnus-simplify-subject-fully (subject)
3704 "Simplify a subject string according to the user's wishes."
3706 ((null gnus-summary-gather-subject-limit)
3707 (gnus-simplify-subject-re subject))
3708 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3709 (gnus-simplify-subject-fuzzy subject))
3710 ((numberp gnus-summary-gather-subject-limit)
3711 (gnus-limit-string (gnus-simplify-subject-re subject)
3712 gnus-summary-gather-subject-limit))
3716 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3717 "Check whether two subjects are equal. If optional argument
3718 simple-first is t, first argument is already simplified."
3720 ((null simple-first)
3721 (equal (gnus-simplify-subject-fully s1)
3722 (gnus-simplify-subject-fully s2)))
3725 (gnus-simplify-subject-fully s2)))))
3727 ;; Returns a list of writable groups.
3728 (defun gnus-writable-groups ()
3729 (let ((alist gnus-newsrc-alist)
3731 (while (setq group (car (pop alist)))
3732 (unless (gnus-group-read-only-p group)
3733 (push group groups)))
3736 (defun gnus-completing-read (default prompt &rest args)
3737 ;; Like `completing-read', except that DEFAULT is the default argument.
3738 (let* ((prompt (if default
3739 (concat prompt " (default " default ") ")
3740 (concat prompt " ")))
3741 (answer (apply 'completing-read prompt args)))
3742 (if (or (null answer) (zerop (length answer)))
3746 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3748 (defun gnus-y-or-n-p (prompt)
3753 (defun gnus-yes-or-no-p (prompt)
3755 (yes-or-no-p prompt)
3758 ;; Check whether to use long file names.
3759 (defun gnus-use-long-file-name (symbol)
3760 ;; The variable has to be set...
3761 (and gnus-use-long-file-name
3762 ;; If it isn't a list, then we return t.
3763 (or (not (listp gnus-use-long-file-name))
3764 ;; If it is a list, and the list contains `symbol', we
3766 (not (memq symbol gnus-use-long-file-name)))))
3768 ;; I suspect there's a better way, but I haven't taken the time to do
3769 ;; it yet. -erik selberg@cs.washington.edu
3770 (defun gnus-dd-mmm (messy-date)
3771 "Return a string like DD-MMM from a big messy string"
3772 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3778 ;; Make sure leading zeroes are stripped.
3779 (number-to-string (string-to-number (aref datevec 2)))
3783 (nth (1- (string-to-number (aref datevec 1)))
3784 timezone-months-assoc))
3787 (defun gnus-mode-string-quote (string)
3788 "Quote all \"%\" in STRING."
3790 (gnus-set-work-buffer)
3792 (goto-char (point-min))
3793 (while (search-forward "%" nil t)
3797 ;; Make a hash table (default and minimum size is 255).
3798 ;; Optional argument HASHSIZE specifies the table size.
3799 (defun gnus-make-hashtable (&optional hashsize)
3800 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3802 ;; Make a number that is suitable for hashing; bigger than MIN and one
3804 (defun gnus-create-hash-size (min)
3810 ;; Show message if message has a lower level than `gnus-verbose'.
3811 ;; Guideline for numbers:
3812 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3813 ;; for things that take a long time, 7 - not very important messages
3814 ;; on stuff, 9 - messages inside loops.
3815 (defun gnus-message (level &rest args)
3816 (if (<= level gnus-verbose)
3817 (apply 'message args)
3818 ;; We have to do this format thingy here even if the result isn't
3819 ;; shown - the return value has to be the same as the return value
3821 (apply 'format args)))
3823 (defun gnus-error (level &rest args)
3824 "Beep an error if LEVEL is equal to or less than `gnus-verbose'."
3825 (when (<= (floor level) gnus-verbose)
3826 (apply 'message args)
3829 (when (and (floatp level)
3830 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3831 (sit-for duration))))
3834 ;; Generate a unique new group name.
3835 (defun gnus-generate-new-group-name (leaf)
3838 (while (gnus-gethash name gnus-newsrc-hashtb)
3839 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3842 (defsubst gnus-hide-text (b e props)
3843 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3844 (gnus-add-text-properties b e props)
3845 (when (memq 'intangible props)
3846 (gnus-put-text-property (max (1- b) (point-min))
3847 b 'intangible (cddr (memq 'intangible props)))))
3849 (defsubst gnus-unhide-text (b e)
3850 "Remove hidden text properties from region between B and E."
3851 (remove-text-properties b e gnus-hidden-properties)
3852 (when (memq 'intangible gnus-hidden-properties)
3853 (gnus-put-text-property (max (1- b) (point-min))
3854 b 'intangible nil)))
3856 (defun gnus-hide-text-type (b e type)
3857 "Hide text of TYPE between B and E."
3858 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3860 (defun gnus-parent-headers (headers &optional generation)
3861 "Return the headers of the GENERATIONeth parent of HEADERS."
3863 (setq generation 1))
3864 (let (references parent)
3865 (while (and headers (not (zerop generation)))
3866 (setq references (mail-header-references headers))
3867 (when (and references
3868 (setq parent (gnus-parent-id references))
3869 (setq headers (car (gnus-id-to-thread parent))))
3873 (defun gnus-parent-id (references)
3874 "Return the last Message-ID in REFERENCES."
3875 (when (and references
3876 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3877 (substring references (match-beginning 1) (match-end 1))))
3879 (defun gnus-split-references (references)
3880 "Return a list of Message-IDs in REFERENCES."
3883 (while (string-match "<[^>]+>" references beg)
3884 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3888 (defun gnus-buffer-live-p (buffer)
3889 "Say whether BUFFER is alive or not."
3892 (buffer-name (get-buffer buffer))))
3894 (defun gnus-ephemeral-group-p (group)
3895 "Say whether GROUP is ephemeral or not."
3896 (gnus-group-get-parameter group 'quit-config))
3898 (defun gnus-group-quit-config (group)
3899 "Return the quit-config of GROUP."
3900 (gnus-group-get-parameter group 'quit-config))
3902 (defun gnus-simplify-mode-line ()
3903 "Make mode lines a bit simpler."
3904 (setq mode-line-modified "-- ")
3905 (when (listp mode-line-format)
3906 (make-local-variable 'mode-line-format)
3907 (setq mode-line-format (copy-sequence mode-line-format))
3908 (when (equal (nth 3 mode-line-format) " ")
3909 (setcar (nthcdr 3 mode-line-format) " "))))
3911 ;;; List and range functions
3913 (defun gnus-last-element (list)
3914 "Return last element of LIST."
3916 (setq list (cdr list)))
3919 (defun gnus-copy-sequence (list)
3920 "Do a complete, total copy of a list."
3921 (if (and (consp list) (not (consp (cdr list))))
3922 (cons (car list) (cdr list))
3923 (mapcar (lambda (elem) (if (consp elem)
3924 (if (consp (cdr elem))
3925 (gnus-copy-sequence elem)
3926 (cons (car elem) (cdr elem)))
3930 (defun gnus-set-difference (list1 list2)
3931 "Return a list of elements of LIST1 that do not appear in LIST2."
3932 (let ((list1 (copy-sequence list1)))
3934 (setq list1 (delq (car list2) list1))
3935 (setq list2 (cdr list2)))
3938 (defun gnus-sorted-complement (list1 list2)
3939 "Return a list of elements of LIST1 that do not appear in LIST2.
3940 Both lists have to be sorted over <."
3942 (if (or (null list1) (null list2))
3944 (while (and list1 list2)
3945 (cond ((= (car list1) (car list2))
3946 (setq list1 (cdr list1)
3948 ((< (car list1) (car list2))
3949 (setq out (cons (car list1) out))
3950 (setq list1 (cdr list1)))
3952 (setq out (cons (car list2) out))
3953 (setq list2 (cdr list2)))))
3954 (nconc (nreverse out) (or list1 list2)))))
3956 (defun gnus-intersection (list1 list2)
3959 (if (memq (car list2) list1)
3960 (setq result (cons (car list2) result)))
3961 (setq list2 (cdr list2)))
3964 (defun gnus-sorted-intersection (list1 list2)
3965 ;; LIST1 and LIST2 have to be sorted over <.
3967 (while (and list1 list2)
3968 (cond ((= (car list1) (car list2))
3969 (setq out (cons (car list1) out)
3972 ((< (car list1) (car list2))
3973 (setq list1 (cdr list1)))
3975 (setq list2 (cdr list2)))))
3978 (defun gnus-set-sorted-intersection (list1 list2)
3979 ;; LIST1 and LIST2 have to be sorted over <.
3980 ;; This function modifies LIST1.
3981 (let* ((top (cons nil list1))
3983 (while (and list1 list2)
3984 (cond ((= (car list1) (car list2))
3988 ((< (car list1) (car list2))
3989 (setcdr prev (cdr list1))
3990 (setq list1 (cdr list1)))
3992 (setq list2 (cdr list2)))))
3996 (defun gnus-compress-sequence (numbers &optional always-list)
3997 "Convert list of numbers to a list of ranges or a single range.
3998 If ALWAYS-LIST is non-nil, this function will always release a list of
4000 (let* ((first (car numbers))
4001 (last (car numbers))
4005 (if (not (listp (cdr numbers)))
4008 (cond ((= last (car numbers)) nil) ;Omit duplicated number
4009 ((= (1+ last) (car numbers)) ;Still in sequence
4010 (setq last (car numbers)))
4011 (t ;End of one sequence
4013 (cons (if (= first last) first
4014 (cons first last)) result))
4015 (setq first (car numbers))
4016 (setq last (car numbers))))
4017 (setq numbers (cdr numbers)))
4018 (if (and (not always-list) (null result))
4019 (if (= first last) (list first) (cons first last))
4020 (nreverse (cons (if (= first last) first (cons first last))
4023 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
4024 (defun gnus-uncompress-range (ranges)
4025 "Expand a list of ranges into a list of numbers.
4026 RANGES is either a single range on the form `(num . num)' or a list of
4028 (let (first last result)
4032 ((not (listp (cdr ranges)))
4033 (setq first (car ranges))
4034 (setq last (cdr ranges))
4035 (while (<= first last)
4036 (setq result (cons first result))
4037 (setq first (1+ first)))
4041 (if (atom (car ranges))
4042 (if (numberp (car ranges))
4043 (setq result (cons (car ranges) result)))
4044 (setq first (caar ranges))
4045 (setq last (cdar ranges))
4046 (while (<= first last)
4047 (setq result (cons first result))
4048 (setq first (1+ first))))
4049 (setq ranges (cdr ranges)))
4050 (nreverse result)))))
4052 (defun gnus-add-to-range (ranges list)
4053 "Return a list of ranges that has all articles from both RANGES and LIST.
4054 Note: LIST has to be sorted over `<'."
4056 (gnus-compress-sequence list t)
4057 (setq list (copy-sequence list))
4058 (or (listp (cdr ranges))
4059 (setq ranges (list ranges)))
4061 ilist lowest highest temp)
4062 (while (and ranges list)
4064 (setq lowest (or (and (atom (car ranges)) (car ranges))
4066 (while (and list (cdr list) (< (cadr list) lowest))
4067 (setq list (cdr list)))
4068 (if (< (car ilist) lowest)
4071 (setq list (cdr list))
4073 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4074 (setq highest (or (and (atom (car ranges)) (car ranges))
4076 (while (and list (<= (car list) highest))
4077 (setq list (cdr list)))
4078 (setq ranges (cdr ranges)))
4080 (setq out (nconc (gnus-compress-sequence list t) out)))
4081 (setq out (sort out (lambda (r1 r2)
4082 (< (or (and (atom r1) r1) (car r1))
4083 (or (and (atom r2) r2) (car r2))))))
4086 (if (atom (car ranges))
4088 (if (atom (cadr ranges))
4089 (if (= (1+ (car ranges)) (cadr ranges))
4091 (setcar ranges (cons (car ranges)
4093 (setcdr ranges (cddr ranges))))
4094 (if (= (1+ (car ranges)) (caadr ranges))
4096 (setcar (cadr ranges) (car ranges))
4097 (setcar ranges (cadr ranges))
4098 (setcdr ranges (cddr ranges))))))
4100 (if (atom (cadr ranges))
4101 (if (= (1+ (cdar ranges)) (cadr ranges))
4103 (setcdr (car ranges) (cadr ranges))
4104 (setcdr ranges (cddr ranges))))
4105 (if (= (1+ (cdar ranges)) (caadr ranges))
4107 (setcdr (car ranges) (cdadr ranges))
4108 (setcdr ranges (cddr ranges)))))))
4109 (setq ranges (cdr ranges)))
4112 (defun gnus-remove-from-range (ranges list)
4113 "Return a list of ranges that has all articles from LIST removed from RANGES.
4114 Note: LIST has to be sorted over `<'."
4115 ;; !!! This function shouldn't look like this, but I've got a headache.
4116 (gnus-compress-sequence
4117 (gnus-sorted-complement
4118 (gnus-uncompress-range ranges) list)))
4120 (defun gnus-member-of-range (number ranges)
4121 (if (not (listp (cdr ranges)))
4122 (and (>= number (car ranges))
4123 (<= number (cdr ranges)))
4126 (if (numberp (car ranges))
4127 (>= number (car ranges))
4128 (>= number (caar ranges)))
4130 (if (if (numberp (car ranges))
4131 (= number (car ranges))
4132 (and (>= number (caar ranges))
4133 (<= number (cdar ranges))))
4134 (setq not-stop nil))
4135 (setq ranges (cdr ranges)))
4138 (defun gnus-range-length (range)
4139 "Return the length RANGE would have if uncompressed."
4140 (length (gnus-uncompress-range range)))
4142 (defun gnus-sublist-p (list sublist)
4143 "Test whether all elements in SUBLIST are members of LIST."
4146 (unless (memq (pop sublist) list)
4156 (defvar gnus-group-mode-map nil)
4157 (put 'gnus-group-mode 'mode-class 'special)
4159 (unless gnus-group-mode-map
4160 (setq gnus-group-mode-map (make-keymap))
4161 (suppress-keymap gnus-group-mode-map)
4163 (gnus-define-keys gnus-group-mode-map
4164 " " gnus-group-read-group
4165 "=" gnus-group-select-group
4166 "\r" gnus-group-select-group
4167 "\M-\r" gnus-group-quick-select-group
4168 "j" gnus-group-jump-to-group
4169 "n" gnus-group-next-unread-group
4170 "p" gnus-group-prev-unread-group
4171 "\177" gnus-group-prev-unread-group
4172 [delete] gnus-group-prev-unread-group
4173 "N" gnus-group-next-group
4174 "P" gnus-group-prev-group
4175 "\M-n" gnus-group-next-unread-group-same-level
4176 "\M-p" gnus-group-prev-unread-group-same-level
4177 "," gnus-group-best-unread-group
4178 "." gnus-group-first-unread-group
4179 "u" gnus-group-unsubscribe-current-group
4180 "U" gnus-group-unsubscribe-group
4181 "c" gnus-group-catchup-current
4182 "C" gnus-group-catchup-current-all
4183 "l" gnus-group-list-groups
4184 "L" gnus-group-list-all-groups
4186 "g" gnus-group-get-new-news
4187 "\M-g" gnus-group-get-new-news-this-group
4188 "R" gnus-group-restart
4189 "r" gnus-group-read-init-file
4190 "B" gnus-group-browse-foreign-server
4191 "b" gnus-group-check-bogus-groups
4192 "F" gnus-find-new-newsgroups
4193 "\C-c\C-d" gnus-group-describe-group
4194 "\M-d" gnus-group-describe-all-groups
4195 "\C-c\C-a" gnus-group-apropos
4196 "\C-c\M-\C-a" gnus-group-description-apropos
4197 "a" gnus-group-post-news
4198 "\ek" gnus-group-edit-local-kill
4199 "\eK" gnus-group-edit-global-kill
4200 "\C-k" gnus-group-kill-group
4201 "\C-y" gnus-group-yank-group
4202 "\C-w" gnus-group-kill-region
4203 "\C-x\C-t" gnus-group-transpose-groups
4204 "\C-c\C-l" gnus-group-list-killed
4205 "\C-c\C-x" gnus-group-expire-articles
4206 "\C-c\M-\C-x" gnus-group-expire-all-groups
4208 "s" gnus-group-save-newsrc
4209 "z" gnus-group-suspend
4210 ; "Z" gnus-group-clear-dribble
4213 "?" gnus-group-describe-briefly
4214 "\C-c\C-i" gnus-info-find-node
4215 "\M-e" gnus-group-edit-group-method
4216 "^" gnus-group-enter-server-mode
4217 gnus-mouse-2 gnus-mouse-pick-group
4218 "<" beginning-of-buffer
4221 "\C-c\C-s" gnus-group-sort-groups
4223 "\C-c\M-g" gnus-activate-all-groups
4224 "\M-&" gnus-group-universal-argument
4225 "#" gnus-group-mark-group
4226 "\M-#" gnus-group-unmark-group)
4228 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4229 "m" gnus-group-mark-group
4230 "u" gnus-group-unmark-group
4231 "w" gnus-group-mark-region
4232 "m" gnus-group-mark-buffer
4233 "r" gnus-group-mark-regexp
4234 "U" gnus-group-unmark-all-groups)
4236 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4237 "d" gnus-group-make-directory-group
4238 "h" gnus-group-make-help-group
4239 "a" gnus-group-make-archive-group
4240 "k" gnus-group-make-kiboze-group
4241 "m" gnus-group-make-group
4242 "E" gnus-group-edit-group
4243 "e" gnus-group-edit-group-method
4244 "p" gnus-group-edit-group-parameters
4245 "v" gnus-group-add-to-virtual
4246 "V" gnus-group-make-empty-virtual
4247 "D" gnus-group-enter-directory
4248 "f" gnus-group-make-doc-group
4249 "r" gnus-group-rename-group
4250 "\177" gnus-group-delete-group
4251 [delete] gnus-group-delete-group)
4253 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4254 "b" gnus-group-brew-soup
4255 "w" gnus-soup-save-areas
4256 "s" gnus-soup-send-replies
4257 "p" gnus-soup-pack-packet
4258 "r" nnsoup-pack-replies)
4260 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4261 "s" gnus-group-sort-groups
4262 "a" gnus-group-sort-groups-by-alphabet
4263 "u" gnus-group-sort-groups-by-unread
4264 "l" gnus-group-sort-groups-by-level
4265 "v" gnus-group-sort-groups-by-score
4266 "r" gnus-group-sort-groups-by-rank
4267 "m" gnus-group-sort-groups-by-method)
4269 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4270 "k" gnus-group-list-killed
4271 "z" gnus-group-list-zombies
4272 "s" gnus-group-list-groups
4273 "u" gnus-group-list-all-groups
4274 "A" gnus-group-list-active
4275 "a" gnus-group-apropos
4276 "d" gnus-group-description-apropos
4277 "m" gnus-group-list-matching
4278 "M" gnus-group-list-all-matching
4279 "l" gnus-group-list-level)
4281 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4282 "f" gnus-score-flush-cache)
4284 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4285 "f" gnus-group-fetch-faq)
4287 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4288 "l" gnus-group-set-current-level
4289 "t" gnus-group-unsubscribe-current-group
4290 "s" gnus-group-unsubscribe-group
4291 "k" gnus-group-kill-group
4292 "y" gnus-group-yank-group
4293 "w" gnus-group-kill-region
4294 "\C-k" gnus-group-kill-level
4295 "z" gnus-group-kill-all-zombies))
4297 (defun gnus-group-mode ()
4298 "Major mode for reading news.
4300 All normal editing commands are switched off.
4301 \\<gnus-group-mode-map>
4302 The group buffer lists (some of) the groups available. For instance,
4303 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4304 lists all zombie groups.
4306 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4307 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4309 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4311 The following commands are available:
4313 \\{gnus-group-mode-map}"
4315 (when (and menu-bar-mode
4316 (gnus-visual-p 'group-menu 'menu))
4317 (gnus-group-make-menu-bar))
4318 (kill-all-local-variables)
4319 (gnus-simplify-mode-line)
4320 (setq major-mode 'gnus-group-mode)
4321 (setq mode-name "Group")
4322 (gnus-group-set-mode-line)
4323 (setq mode-line-process nil)
4324 (use-local-map gnus-group-mode-map)
4325 (buffer-disable-undo (current-buffer))
4326 (setq truncate-lines t)
4327 (setq buffer-read-only t)
4328 (gnus-make-local-hook 'post-command-hook)
4329 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4330 (run-hooks 'gnus-group-mode-hook))
4332 (defun gnus-clear-inboxes-moved ()
4333 (setq nnmail-moved-inboxes nil))
4335 (defun gnus-mouse-pick-group (e)
4336 "Enter the group under the mouse pointer."
4339 (gnus-group-read-group nil))
4341 ;; Look at LEVEL and find out what the level is really supposed to be.
4342 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4343 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4344 (defun gnus-group-default-level (&optional level number-or-nil)
4346 (gnus-group-use-permanent-levels
4347 (or (setq gnus-group-use-permanent-levels
4348 (or level (if (numberp gnus-group-use-permanent-levels)
4349 gnus-group-use-permanent-levels
4350 (or gnus-group-default-list-level
4351 gnus-level-subscribed))))
4352 gnus-group-default-list-level gnus-level-subscribed))
4356 (or level gnus-group-default-list-level gnus-level-subscribed))))
4359 (defun gnus-slave-no-server (&optional arg)
4360 "Read network news as a slave, without connecting to local server"
4362 (gnus-no-server arg t))
4365 (defun gnus-no-server (&optional arg slave)
4367 If ARG is a positive number, Gnus will use that as the
4368 startup level. If ARG is nil, Gnus will be started at level 2.
4369 If ARG is non-nil and not a positive number, Gnus will
4370 prompt the user for the name of an NNTP server to use.
4371 As opposed to `gnus', this command will not connect to the local server."
4373 (let ((val (or arg (1- gnus-level-default-subscribed))))
4375 (make-local-variable 'gnus-group-use-permanent-levels)
4376 (setq gnus-group-use-permanent-levels val)))
4379 (defun gnus-slave (&optional arg)
4380 "Read news as a slave."
4382 (gnus arg nil 'slave))
4385 (defun gnus-other-frame (&optional arg)
4386 "Pop up a frame to read news."
4388 (if (get-buffer gnus-group-buffer)
4389 (let ((pop-up-frames t))
4391 (select-frame (make-frame))
4395 (defun gnus (&optional arg dont-connect slave)
4397 If ARG is non-nil and a positive number, Gnus will use that as the
4398 startup level. If ARG is non-nil and not a positive number, Gnus will
4399 prompt the user for the name of an NNTP server to use."
4402 (if (get-buffer gnus-group-buffer)
4404 (switch-to-buffer gnus-group-buffer)
4405 (gnus-group-get-new-news))
4408 (nnheader-init-server-buffer)
4409 (gnus-read-init-file)
4410 (setq gnus-slave slave)
4412 (gnus-group-setup-buffer)
4413 (let ((buffer-read-only nil))
4415 (if (not gnus-inhibit-startup-message)
4417 (gnus-group-startup-message)
4420 (let ((level (and (numberp arg) (> arg 0) arg))
4426 (gnus-start-news-server (and arg (not level))))))
4427 (if (and (not dont-connect)
4430 (run-hooks 'gnus-startup-hook)
4431 ;; NNTP server is successfully open.
4433 ;; Find the current startup file name.
4434 (setq gnus-current-startup-file
4435 (gnus-make-newsrc-file gnus-startup-file))
4437 ;; Read the dribble file.
4438 (when (or gnus-slave gnus-use-dribble-file)
4439 (gnus-dribble-read-file))
4441 ;; Allow using GroupLens predictions.
4442 (when gnus-use-grouplens
4444 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4446 (gnus-summary-make-display-table)
4447 ;; Do the actual startup.
4448 (gnus-setup-news nil level dont-connect)
4449 ;; Generate the group buffer.
4450 (gnus-group-list-groups level)
4451 (gnus-group-first-unread-group)
4452 (gnus-configure-windows 'group)
4453 (gnus-group-set-mode-line))))))
4455 (defun gnus-unload ()
4456 "Unload all Gnus features."
4458 (or (boundp 'load-history)
4459 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4460 (let ((history load-history)
4463 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4464 (setq feature (cdr (assq 'provide (car history))))
4465 (unload-feature feature 'force))
4466 (setq history (cdr history)))))
4468 (defun gnus-compile ()
4469 "Byte-compile the user-defined format specs."
4471 (let ((entries gnus-format-specs)
4472 entry gnus-tmp-func)
4474 (gnus-message 7 "Compiling format specs...")
4477 (setq entry (pop entries))
4478 (if (eq (car entry) 'version)
4479 (setq gnus-format-specs (delq entry gnus-format-specs))
4480 (when (and (listp (caddr entry))
4481 (not (eq 'byte-code (caaddr entry))))
4482 (fset 'gnus-tmp-func
4483 `(lambda () ,(caddr entry)))
4484 (byte-compile 'gnus-tmp-func)
4485 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4487 (push (cons 'version emacs-version) gnus-format-specs)
4489 (gnus-message 7 "Compiling user specs...done"))))
4491 (defun gnus-indent-rigidly (start end arg)
4492 "Indent rigidly using only spaces and no tabs."
4495 (narrow-to-region start end)
4496 (indent-rigidly start end arg)
4497 (goto-char (point-min))
4498 (while (search-forward "\t" nil t)
4499 (replace-match " " t t)))))
4501 (defun gnus-group-startup-message (&optional x y)
4502 "Insert startup message in current buffer."
4503 ;; Insert the message.
4508 _ ___ __ ___ __ _ ___
4527 ;; And then hack it.
4528 (gnus-indent-rigidly (point-min) (point-max)
4529 (/ (max (- (window-width) (or x 46)) 0) 2))
4530 (goto-char (point-min))
4532 (let* ((pheight (count-lines (point-min) (point-max)))
4533 (wheight (window-height))
4534 (rest (- wheight pheight)))
4535 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4537 (goto-char (point-min))
4538 (and (search-forward "Praxis" nil t)
4539 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4540 (goto-char (point-min))
4541 (let* ((mode-string (gnus-group-set-mode-line)))
4542 (setq mode-line-buffer-identification
4543 (list (concat gnus-version (substring (car mode-string) 4))))
4544 (set-buffer-modified-p t)))
4546 (defun gnus-group-setup-buffer ()
4547 (or (get-buffer gnus-group-buffer)
4549 (switch-to-buffer gnus-group-buffer)
4550 (gnus-add-current-to-buffer-list)
4552 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4554 (defun gnus-group-list-groups (&optional level unread lowest)
4555 "List newsgroups with level LEVEL or lower that have unread articles.
4556 Default is all subscribed groups.
4557 If argument UNREAD is non-nil, groups with no unread articles are also
4559 (interactive (list (if current-prefix-arg
4560 (prefix-numeric-value current-prefix-arg)
4562 (gnus-group-default-level nil t)
4563 gnus-group-default-list-level
4564 gnus-level-subscribed))))
4566 (setq level (car gnus-group-list-mode)
4567 unread (cdr gnus-group-list-mode)))
4568 (setq level (gnus-group-default-level level))
4569 (gnus-group-setup-buffer) ;May call from out of group buffer
4570 (gnus-update-format-specifications)
4571 (let ((case-fold-search nil)
4572 (props (text-properties-at (gnus-point-at-bol)))
4573 (group (gnus-group-group-name)))
4574 (set-buffer gnus-group-buffer)
4575 (funcall gnus-group-prepare-function level unread lowest)
4576 (if (zerop (buffer-size))
4577 (gnus-message 5 gnus-no-groups-message)
4578 (goto-char (point-max))
4579 (when (or (not gnus-group-goto-next-group-function)
4580 (not (funcall gnus-group-goto-next-group-function
4583 ;; Go to the first group with unread articles.
4584 (gnus-group-search-forward t)
4585 ;; Find the right group to put point on. If the current group
4586 ;; has disappeared in the new listing, try to find the next
4587 ;; one. If no next one can be found, just leave point at the
4588 ;; first newsgroup in the buffer.
4589 (if (not (gnus-goto-char
4591 (point-min) (point-max)
4592 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4593 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4595 (not (gnus-goto-char
4597 (point-min) (point-max) 'gnus-group
4599 (caar newsrc) gnus-active-hashtb)))))
4600 (setq newsrc (cdr newsrc)))
4601 (or newsrc (progn (goto-char (point-max))
4602 (forward-line -1)))))))
4603 ;; Adjust cursor point.
4604 (gnus-group-position-point))))
4606 (defun gnus-group-list-level (level &optional all)
4607 "List groups on LEVEL.
4608 If ALL (the prefix), also list groups that have no unread articles."
4609 (interactive "nList groups on level: \nP")
4610 (gnus-group-list-groups level all level))
4612 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4613 "List all newsgroups with unread articles of level LEVEL or lower.
4614 If ALL is non-nil, list groups that have no unread articles.
4615 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4616 If REGEXP, only list groups matching REGEXP."
4617 (set-buffer gnus-group-buffer)
4618 (let ((buffer-read-only nil)
4619 (newsrc (cdr gnus-newsrc-alist))
4620 (lowest (or lowest 1))
4621 info clevel unread group params)
4623 (if (< lowest gnus-level-zombie)
4624 ;; List living groups.
4626 (setq info (car newsrc)
4627 group (gnus-info-group info)
4628 params (gnus-info-params info)
4630 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4631 (and unread ; This group might be bogus
4633 (string-match regexp group))
4634 (<= (setq clevel (gnus-info-level info)) level)
4636 (or all ; We list all groups?
4637 (if (eq unread t) ; Unactivated?
4638 gnus-group-list-inactive-groups ; We list unactivated
4639 (> unread 0)) ; We list groups with unread articles
4640 (and gnus-list-groups-with-ticked-articles
4641 (cdr (assq 'tick (gnus-info-marks info))))
4642 ; And groups with tickeds
4643 ;; Check for permanent visibility.
4644 (and gnus-permanently-visible-groups
4645 (string-match gnus-permanently-visible-groups
4647 (memq 'visible params)
4648 (cdr (assq 'visible params)))
4649 (gnus-group-insert-group-line
4650 group (gnus-info-level info)
4651 (gnus-info-marks info) unread (gnus-info-method info)))))
4653 ;; List dead groups.
4654 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4655 (gnus-group-prepare-flat-list-dead
4656 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4657 gnus-level-zombie ?Z
4659 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4660 (gnus-group-prepare-flat-list-dead
4661 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4662 gnus-level-killed ?K regexp))
4664 (gnus-group-set-mode-line)
4665 (setq gnus-group-list-mode (cons level all))
4666 (run-hooks 'gnus-group-prepare-hook)))
4668 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4669 ;; List zombies and killed lists somewhat faster, which was
4670 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4671 ;; this by ignoring the group format specification altogether.
4674 ;; This loop is used when listing groups that match some
4677 (setq group (pop groups))
4678 (when (string-match regexp group)
4679 (gnus-add-text-properties
4680 (point) (prog1 (1+ (point))
4681 (insert " " mark " *: " group "\n"))
4682 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4684 'gnus-level level))))
4685 ;; This loop is used when listing all groups.
4687 (gnus-add-text-properties
4688 (point) (prog1 (1+ (point))
4689 (insert " " mark " *: "
4690 (setq group (pop groups)) "\n"))
4691 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4693 'gnus-level level))))))
4695 (defmacro gnus-group-real-name (group)
4696 "Find the real name of a foreign newsgroup."
4697 `(let ((gname ,group))
4698 (if (string-match ":[^:]+$" gname)
4699 (substring gname (1+ (match-beginning 0)))
4702 (defsubst gnus-server-add-address (method)
4703 (let ((method-name (symbol-name (car method))))
4704 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4705 (not (assq (intern (concat method-name "-address")) method)))
4706 (append method (list (list (intern (concat method-name "-address"))
4710 (defsubst gnus-server-get-method (group method)
4711 ;; Input either a server name, and extended server name, or a
4712 ;; select method, and return a select method.
4713 (cond ((stringp method)
4714 (gnus-server-to-method method))
4715 ((equal method gnus-select-method)
4717 ((and (stringp (car method)) group)
4718 (gnus-server-extend-method group method))
4719 ((and method (not group)
4720 (equal (cadr method) ""))
4723 (gnus-server-add-address method))))
4725 (defun gnus-server-to-method (server)
4726 "Map virtual server names to select methods."
4728 ;; Is this a method, perhaps?
4729 (and server (listp server) server)
4730 ;; Perhaps this is the native server?
4731 (and (equal server "native") gnus-select-method)
4732 ;; It should be in the server alist.
4733 (cdr (assoc server gnus-server-alist))
4734 ;; If not, we look through all the opened server
4735 ;; to see whether we can find it there.
4736 (let ((opened gnus-opened-servers))
4738 (not (equal server (format "%s:%s" (caaar opened)
4743 (defmacro gnus-method-equal (ss1 ss2)
4744 "Say whether two servers are equal."
4748 (and (= (length s1) (length s2))
4750 (while (and s1 (member (car s1) s2))
4754 (defun gnus-server-equal (m1 m2)
4755 "Say whether two methods are equal."
4756 (let ((m1 (cond ((null m1) gnus-select-method)
4757 ((stringp m1) (gnus-server-to-method m1))
4759 (m2 (cond ((null m2) gnus-select-method)
4760 ((stringp m2) (gnus-server-to-method m2))
4762 (gnus-method-equal m1 m2)))
4764 (defun gnus-servers-using-backend (backend)
4765 "Return a list of known servers using BACKEND."
4766 (let ((opened gnus-opened-servers)
4769 (when (eq backend (caaar opened))
4770 (push (caar opened) out))
4774 (defun gnus-archive-server-wanted-p ()
4775 "Say whether the user wants to use the archive server."
4777 ((or (not gnus-message-archive-method)
4778 (not gnus-message-archive-group))
4780 ((and gnus-message-archive-method gnus-message-archive-group)
4783 (let ((active (cadr (assq 'nnfolder-active-file
4784 gnus-message-archive-method))))
4786 (file-exists-p active))))))
4788 (defun gnus-group-prefixed-name (group method)
4789 "Return the whole name from GROUP and METHOD."
4790 (and (stringp method) (setq method (gnus-server-to-method method)))
4791 (concat (format "%s" (car method))
4793 (or (assoc (format "%s" (car method))
4794 (gnus-methods-using 'address))
4795 (gnus-server-equal method gnus-message-archive-method))
4797 (not (string= (nth 1 method) "")))
4798 (concat "+" (nth 1 method)))
4801 (defun gnus-group-real-prefix (group)
4802 "Return the prefix of the current group name."
4803 (if (string-match "^[^:]+:" group)
4804 (substring group 0 (match-end 0))
4807 (defun gnus-group-method (group)
4808 "Return the server or method used for selecting GROUP."
4809 (let ((prefix (gnus-group-real-prefix group)))
4810 (if (equal prefix "")
4812 (let ((servers gnus-opened-servers)
4814 backend possible found)
4815 (if (string-match "^[^\\+]+\\+" prefix)
4816 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4817 server (substring prefix (match-end 0) (1- (length prefix))))
4818 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4820 (when (eq (caaar servers) backend)
4821 (setq possible (caar servers))
4822 (when (equal (cadaar servers) server)
4823 (setq found (caar servers))))
4825 (or (car (rassoc found gnus-server-alist))
4827 (car (rassoc possible gnus-server-alist))
4829 (list backend server))))))
4831 (defsubst gnus-secondary-method-p (method)
4832 "Return whether METHOD is a secondary select method."
4833 (let ((methods gnus-secondary-select-methods)
4834 (gmethod (gnus-server-get-method nil method)))
4836 (not (equal (gnus-server-get-method nil (car methods))
4838 (setq methods (cdr methods)))
4841 (defun gnus-group-foreign-p (group)
4842 "Say whether a group is foreign or not."
4843 (and (not (gnus-group-native-p group))
4844 (not (gnus-group-secondary-p group))))
4846 (defun gnus-group-native-p (group)
4847 "Say whether the group is native or not."
4848 (not (string-match ":" group)))
4850 (defun gnus-group-secondary-p (group)
4851 "Say whether the group is secondary or not."
4852 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4854 (defun gnus-group-get-parameter (group &optional symbol)
4855 "Returns the group parameters for GROUP.
4856 If SYMBOL, return the value of that symbol in the group parameters."
4857 (let ((params (gnus-info-params (gnus-get-info group))))
4859 (gnus-group-parameter-value params symbol)
4862 (defun gnus-group-parameter-value (params symbol)
4863 "Return the value of SYMBOL in group PARAMS."
4864 (or (car (memq symbol params)) ; It's either a simple symbol
4865 (cdr (assq symbol params)))) ; or a cons.
4867 (defun gnus-group-add-parameter (group param)
4868 "Add parameter PARAM to GROUP."
4869 (let ((info (gnus-get-info group)))
4871 () ; This is a dead group. We just ignore it.
4872 ;; Cons the new param to the old one and update.
4873 (gnus-group-set-info (cons param (gnus-info-params info))
4876 (defun gnus-group-set-parameter (group name value)
4877 "Set parameter NAME to VALUE in GROUP."
4878 (let ((info (gnus-get-info group)))
4880 () ; This is a dead group. We just ignore it.
4881 (let ((old-params (gnus-info-params info))
4882 (new-params (list (cons name value))))
4884 (if (or (not (listp (car old-params)))
4885 (not (eq (caar old-params) name)))
4886 (setq new-params (append new-params (list (car old-params)))))
4887 (setq old-params (cdr old-params)))
4888 (gnus-group-set-info new-params group 'params)))))
4890 (defun gnus-group-add-score (group &optional score)
4891 "Add SCORE to the GROUP score.
4892 If SCORE is nil, add 1 to the score of GROUP."
4893 (let ((info (gnus-get-info group)))
4895 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4897 (defun gnus-summary-bubble-group ()
4898 "Increase the score of the current group.
4899 This is a handy function to add to `gnus-summary-exit-hook' to
4900 increase the score of each group you read."
4901 (gnus-group-add-score gnus-newsgroup-name))
4903 (defun gnus-group-set-info (info &optional method-only-group part)
4904 (let* ((entry (gnus-gethash
4905 (or method-only-group (gnus-info-group info))
4906 gnus-newsrc-hashtb))
4908 (info (if method-only-group (nth 2 entry) info))
4910 (when method-only-group
4912 (error "Trying to change non-existent group %s" method-only-group))
4913 ;; We have received parts of the actual group info - either the
4914 ;; select method or the group parameters. We first check
4915 ;; whether we have to extend the info, and if so, do that.
4916 (let ((len (length info))
4917 (total (if (eq part 'method) 5 6)))
4919 (setcdr (nthcdr (1- len) info)
4920 (make-list (- total len) nil)))
4921 ;; Then we enter the new info.
4922 (setcar (nthcdr (1- total) info) part-info)))
4924 ;; This is a new group, so we just create it.
4926 (set-buffer gnus-group-buffer)
4927 (setq method (gnus-info-method info))
4928 (when (gnus-server-equal method "native")
4931 (set-buffer gnus-group-buffer)
4933 ;; It's a foreign group...
4934 (gnus-group-make-group
4935 (gnus-group-real-name (gnus-info-group info))
4936 (if (stringp method) method
4937 (prin1-to-string (car method)))
4939 (nth 1 (gnus-info-method info))))
4940 ;; It's a native group.
4941 (gnus-group-make-group (gnus-info-group info))))
4942 (gnus-message 6 "Note: New group created")
4944 (gnus-gethash (gnus-group-prefixed-name
4945 (gnus-group-real-name (gnus-info-group info))
4946 (or (gnus-info-method info) gnus-select-method))
4947 gnus-newsrc-hashtb))))
4948 ;; Whether it was a new group or not, we now have the entry, so we
4949 ;; can do the update.
4952 (setcar (nthcdr 2 entry) info)
4953 (when (and (not (eq (car entry) t))
4954 (gnus-active (gnus-info-group info)))
4955 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4956 (error "No such group: %s" (gnus-info-group info)))))
4958 (defun gnus-group-set-method-info (group select-method)
4959 (gnus-group-set-info select-method group 'method))
4961 (defun gnus-group-set-params-info (group params)
4962 (gnus-group-set-info params group 'params))
4964 (defun gnus-group-update-group-line ()
4965 "Update the current line in the group buffer."
4966 (let* ((buffer-read-only nil)
4967 (group (gnus-group-group-name))
4968 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4969 gnus-group-indentation)
4972 (not (gnus-ephemeral-group-p group))
4974 (concat "(gnus-group-set-info '"
4975 (prin1-to-string (nth 2 entry)) ")")))
4976 (setq gnus-group-indentation (gnus-group-group-indentation))
4978 (gnus-group-insert-group-line-info group)
4980 (gnus-group-position-point))))
4982 (defun gnus-group-insert-group-line-info (group)
4983 "Insert GROUP on the current line."
4984 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4988 ;; (Un)subscribed group.
4989 (setq info (nth 2 entry))
4990 (gnus-group-insert-group-line
4991 group (gnus-info-level info) (gnus-info-marks info)
4992 (or (car entry) t) (gnus-info-method info)))
4993 ;; This group is dead.
4994 (gnus-group-insert-group-line
4996 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4998 (if (setq active (gnus-active group))
4999 (- (1+ (cdr active)) (car active)) 0)
5002 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
5003 gnus-tmp-marked number
5005 "Insert a group line in the group buffer."
5006 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
5007 (gnus-tmp-number-total
5009 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
5011 (gnus-tmp-number-of-unread
5012 (if (numberp number) (int-to-string (max 0 number))
5014 (gnus-tmp-number-of-read
5015 (if (numberp number)
5016 (int-to-string (max 0 (- gnus-tmp-number-total number)))
5018 (gnus-tmp-subscribed
5019 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
5020 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
5021 ((= gnus-tmp-level gnus-level-zombie) ?Z)
5023 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
5024 (gnus-tmp-newsgroup-description
5025 (if gnus-description-hashtb
5026 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
5029 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
5030 (gnus-tmp-moderated-string
5031 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
5033 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
5034 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
5035 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
5036 (gnus-tmp-news-method-string
5038 (format "(%s:%s)" (car gnus-tmp-method)
5039 (cadr gnus-tmp-method)) ""))
5040 (gnus-tmp-marked-mark
5041 (if (and (numberp number)
5043 (cdr (assq 'tick gnus-tmp-marked)))
5045 (gnus-tmp-process-marked
5046 (if (member gnus-tmp-group gnus-group-marked)
5047 gnus-process-mark ? ))
5049 (or (and gnus-use-grouplens
5050 (bbb-grouplens-group-p gnus-tmp-group))
5052 (buffer-read-only nil)
5053 header gnus-tmp-header) ; passed as parameter to user-funcs.
5055 (gnus-add-text-properties
5059 (eval gnus-group-line-format-spec))
5060 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5061 gnus-unread ,(if (numberp number)
5062 (string-to-int gnus-tmp-number-of-unread)
5064 gnus-marked ,gnus-tmp-marked-mark
5065 gnus-indentation ,gnus-group-indentation
5066 gnus-level ,gnus-tmp-level))
5067 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5069 (run-hooks 'gnus-group-update-hook)
5071 ;; Allow XEmacs to remove front-sticky text properties.
5072 (gnus-group-remove-excess-properties)))
5074 (defun gnus-group-update-group (group &optional visible-only)
5075 "Update all lines where GROUP appear.
5076 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5079 (set-buffer gnus-group-buffer)
5080 ;; The buffer may be narrowed.
5083 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5085 found buffer-read-only)
5086 ;; Enter the current status into the dribble buffer.
5087 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5088 (if (and entry (not (gnus-ephemeral-group-p group)))
5090 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5092 ;; Find all group instances. If topics are in use, each group
5093 ;; may be listed in more than once.
5094 (while (setq loc (text-property-any
5095 loc (point-max) 'gnus-group ident))
5098 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5100 (gnus-group-insert-group-line-info group)
5103 (run-hooks 'gnus-group-update-group-hook)))
5104 (setq loc (1+ loc)))
5105 (unless (or found visible-only)
5106 ;; No such line in the buffer, find out where it's supposed to
5107 ;; go, and insert it there (or at the end of the buffer).
5108 (if gnus-goto-missing-group-function
5109 (funcall gnus-goto-missing-group-function group)
5110 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5111 (while (and entry (car entry)
5115 (point-min) (point-max)
5116 'gnus-group (gnus-intern-safe
5117 (caar entry) gnus-active-hashtb)))))
5118 (setq entry (cdr entry)))
5119 (or entry (goto-char (point-max)))))
5120 ;; Finally insert the line.
5121 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5122 (gnus-group-insert-group-line-info group)
5125 (run-hooks 'gnus-group-update-group-hook))))
5126 (gnus-group-set-mode-line)))))
5128 (defun gnus-group-set-mode-line ()
5129 "Update the mode line in the group buffer."
5130 (when (memq 'group gnus-updated-mode-lines)
5131 ;; Yes, we want to keep this mode line updated.
5133 (set-buffer gnus-group-buffer)
5134 (let* ((gformat (or gnus-group-mode-line-format-spec
5135 (setq gnus-group-mode-line-format-spec
5137 gnus-group-mode-line-format
5138 gnus-group-mode-line-format-alist))))
5139 (gnus-tmp-news-server (cadr gnus-select-method))
5140 (gnus-tmp-news-method (car gnus-select-method))
5141 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5143 gnus-tmp-header ;Dummy binding for user-defined formats
5144 ;; Get the resulting string.
5146 (and gnus-dribble-buffer
5147 (buffer-name gnus-dribble-buffer)
5148 (buffer-modified-p gnus-dribble-buffer)
5150 (set-buffer gnus-dribble-buffer)
5151 (not (zerop (buffer-size))))))
5152 (mode-string (eval gformat)))
5153 ;; Say whether the dribble buffer has been modified.
5154 (setq mode-line-modified
5155 (if modified "---*- " "----- "))
5156 ;; If the line is too long, we chop it off.
5157 (when (> (length mode-string) max-len)
5158 (setq mode-string (substring mode-string 0 (- max-len 4))))
5160 (setq mode-line-buffer-identification
5161 (gnus-mode-line-buffer-identification
5162 (list mode-string)))
5163 (set-buffer-modified-p modified))))))
5165 (defun gnus-group-group-name ()
5166 "Get the name of the newsgroup on the current line."
5167 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5168 (and group (symbol-name group))))
5170 (defun gnus-group-group-level ()
5171 "Get the level of the newsgroup on the current line."
5172 (get-text-property (gnus-point-at-bol) 'gnus-level))
5174 (defun gnus-group-group-indentation ()
5175 "Get the indentation of the newsgroup on the current line."
5176 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5177 (and gnus-group-indentation-function
5178 (funcall gnus-group-indentation-function))
5181 (defun gnus-group-group-unread ()
5182 "Get the number of unread articles of the newsgroup on the current line."
5183 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5185 (defun gnus-group-search-forward (&optional backward all level first-too)
5186 "Find the next newsgroup with unread articles.
5187 If BACKWARD is non-nil, find the previous newsgroup instead.
5188 If ALL is non-nil, just find any newsgroup.
5189 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5191 If FIRST-TOO, the current line is also eligible as a target."
5192 (let ((way (if backward -1 1))
5193 (low gnus-level-killed)
5196 (if (and backward (progn (beginning-of-line)) (bobp))
5198 (or first-too (forward-line way))
5206 (get-text-property (point) 'gnus-unread)))
5207 (and (numberp unread) (> unread 0)))
5208 (setq lev (get-text-property (point)
5210 (<= lev gnus-level-subscribed)))
5212 (and (setq lev (get-text-property (point)
5221 (zerop (forward-line way)))))
5223 (progn (gnus-group-position-point) t)
5224 (goto-char (or pos beg))
5227 ;;; Gnus group mode commands
5231 (defun gnus-group-mark-group (n &optional unmark no-advance)
5232 "Mark the current group."
5234 (let ((buffer-read-only nil)
5238 (when (setq group (gnus-group-group-name))
5242 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5247 (setq gnus-group-marked (delete group gnus-group-marked)))
5249 (setq gnus-group-marked
5250 (cons group (delete group gnus-group-marked)))))
5251 (or no-advance (gnus-group-next-group 1))
5253 (gnus-summary-position-point)
5256 (defun gnus-group-unmark-group (n)
5257 "Remove the mark from the current group."
5259 (gnus-group-mark-group n 'unmark)
5260 (gnus-group-position-point))
5262 (defun gnus-group-unmark-all-groups ()
5263 "Unmark all groups."
5265 (let ((groups gnus-group-marked))
5268 (gnus-group-remove-mark (pop groups)))))
5269 (gnus-group-position-point))
5271 (defun gnus-group-mark-region (unmark beg end)
5272 "Mark all groups between point and mark.
5273 If UNMARK, remove the mark instead."
5274 (interactive "P\nr")
5275 (let ((num (count-lines beg end)))
5278 (- num (gnus-group-mark-group num unmark)))))
5280 (defun gnus-group-mark-buffer (&optional unmark)
5281 "Mark all groups in the buffer.
5282 If UNMARK, remove the mark instead."
5284 (gnus-group-mark-region unmark (point-min) (point-max)))
5286 (defun gnus-group-mark-regexp (regexp)
5287 "Mark all groups that match some regexp."
5288 (interactive "sMark (regexp): ")
5289 (let ((alist (cdr gnus-newsrc-alist))
5292 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5293 (gnus-group-set-mark group))))
5294 (gnus-group-position-point))
5296 (defun gnus-group-remove-mark (group)
5297 "Remove the process mark from GROUP and move point there.
5298 Return nil if the group isn't displayed."
5299 (if (gnus-group-goto-group group)
5301 (gnus-group-mark-group 1 'unmark t)
5303 (setq gnus-group-marked
5304 (delete group gnus-group-marked))
5307 (defun gnus-group-set-mark (group)
5308 "Set the process mark on GROUP."
5309 (if (gnus-group-goto-group group)
5311 (gnus-group-mark-group 1 nil t))
5312 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5314 (defun gnus-group-universal-argument (arg &optional groups func)
5315 "Perform any command on all groups accoring to the process/prefix convention."
5317 (let ((groups (or groups (gnus-group-process-prefix arg)))
5319 (if (eq (setq func (or func
5322 (substitute-command-keys
5323 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5325 (gnus-error 1 "Undefined key")
5327 (gnus-group-remove-mark (setq group (pop groups)))
5328 (command-execute func))))
5329 (gnus-group-position-point))
5331 (defun gnus-group-process-prefix (n)
5332 "Return a list of groups to work on.
5333 Take into consideration N (the prefix) and the list of marked groups."
5336 (setq n (prefix-numeric-value n))
5337 ;; There is a prefix, so we return a list of the N next
5339 (let ((way (if (< n 0) -1 1))
5344 (setq group (gnus-group-group-name)))
5345 (setq groups (cons group groups))
5347 (gnus-group-next-group way)))
5349 ((and (boundp 'transient-mark-mode)
5351 (boundp 'mark-active)
5353 ;; Work on the region between point and mark.
5354 (let ((max (max (point) (mark)))
5357 (goto-char (min (point) (mark)))
5360 (push (gnus-group-group-name) groups)
5361 (zerop (gnus-group-next-group 1))
5363 (nreverse groups))))
5365 ;; No prefix, but a list of marked articles.
5366 (reverse gnus-group-marked))
5368 ;; Neither marked articles or a prefix, so we return the
5370 (let ((group (gnus-group-group-name)))
5371 (and group (list group))))))
5373 ;; Selecting groups.
5375 (defun gnus-group-read-group (&optional all no-article group)
5376 "Read news in this newsgroup.
5377 If the prefix argument ALL is non-nil, already read articles become
5378 readable. IF ALL is a number, fetch this number of articles. If the
5379 optional argument NO-ARTICLE is non-nil, no article will be
5380 auto-selected upon group entry. If GROUP is non-nil, fetch that
5383 (let ((group (or group (gnus-group-group-name)))
5384 number active marked entry)
5385 (or group (error "No group on current line"))
5386 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5387 group gnus-newsrc-hashtb)))))
5388 ;; This group might be a dead group. In that case we have to get
5389 ;; the number of unread articles from `gnus-active-hashtb'.
5391 (cond ((numberp all) all)
5393 ((setq active (gnus-active group))
5394 (- (1+ (cdr active)) (car active)))))
5395 (gnus-summary-read-group
5396 group (or all (and (numberp number)
5397 (zerop (+ number (gnus-range-length
5398 (cdr (assq 'tick marked)))
5400 (cdr (assq 'dormant marked)))))))
5403 (defun gnus-group-select-group (&optional all)
5404 "Select this newsgroup.
5405 No article is selected automatically.
5406 If ALL is non-nil, already read articles become readable.
5407 If ALL is a number, fetch this number of articles."
5409 (gnus-group-read-group all t))
5411 (defun gnus-group-quick-select-group (&optional all)
5412 "Select the current group \"quickly\".
5413 This means that no highlighting or scoring will be performed."
5416 gnus-score-find-score-files-function
5417 gnus-apply-kill-hook
5418 gnus-summary-expunge-below)
5419 (gnus-group-read-group all t)))
5421 (defun gnus-group-visible-select-group (&optional all)
5422 "Select the current group without hiding any articles."
5424 (let ((gnus-inhibit-limiting t))
5425 (gnus-group-read-group all t)))
5428 (defun gnus-fetch-group (group)
5429 "Start Gnus if necessary and enter GROUP.
5430 Returns whether the fetching was successful or not."
5431 (interactive "sGroup name: ")
5432 (or (get-buffer gnus-group-buffer)
5434 (gnus-group-read-group nil nil group))
5436 ;; Enter a group that is not in the group buffer. Non-nil is returned
5437 ;; if selection was successful.
5438 (defun gnus-group-read-ephemeral-group
5439 (group method &optional activate quit-config)
5440 (let ((group (if (gnus-group-foreign-p group) group
5441 (gnus-group-prefixed-name group method))))
5444 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5445 ((quit-config . ,(if quit-config quit-config
5446 (cons (current-buffer) 'summary))))))
5448 (set-buffer gnus-group-buffer)
5449 (or (gnus-check-server method)
5450 (error "Unable to contact server: %s" (gnus-status-message method)))
5451 (if activate (or (gnus-request-group group)
5452 (error "Couldn't request group")))
5454 (gnus-group-read-group t t group)
5458 (defun gnus-group-jump-to-group (group)
5459 "Jump to newsgroup GROUP."
5461 (list (completing-read
5462 "Group: " gnus-active-hashtb nil
5463 (gnus-read-active-file-p)
5465 'gnus-group-history)))
5467 (when (equal group "")
5468 (error "Empty group name"))
5470 (when (string-match "[\000-\032]" group)
5471 (error "Control characters in group: %s" group))
5473 (let ((b (text-property-any
5474 (point-min) (point-max)
5475 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5476 (unless (gnus-ephemeral-group-p group)
5478 ;; Either go to the line in the group buffer...
5480 ;; ... or insert the line.
5483 (gnus-activate-group group)
5484 (error "%s error: %s" group (gnus-status-message group)))
5486 (gnus-group-update-group group)
5487 (goto-char (text-property-any
5488 (point-min) (point-max)
5489 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5490 ;; Adjust cursor point.
5491 (gnus-group-position-point)))
5493 (defun gnus-group-goto-group (group)
5494 "Goto to newsgroup GROUP."
5496 (let ((b (text-property-any (point-min) (point-max)
5497 'gnus-group (gnus-intern-safe
5498 group gnus-active-hashtb))))
5499 (and b (goto-char b)))))
5501 (defun gnus-group-next-group (n)
5502 "Go to next N'th newsgroup.
5503 If N is negative, search backward instead.
5504 Returns the difference between N and the number of skips actually
5507 (gnus-group-next-unread-group n t))
5509 (defun gnus-group-next-unread-group (n &optional all level)
5510 "Go to next N'th unread newsgroup.
5511 If N is negative, search backward instead.
5512 If ALL is non-nil, choose any newsgroup, unread or not.
5513 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5514 such group can be found, the next group with a level higher than
5516 Returns the difference between N and the number of skips actually
5519 (let ((backward (< n 0))
5522 (gnus-group-search-forward
5523 backward (or (not gnus-group-goto-unread) all) level))
5525 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5526 (if level " on this level or higher" "")))
5529 (defun gnus-group-prev-group (n)
5530 "Go to previous N'th newsgroup.
5531 Returns the difference between N and the number of skips actually
5534 (gnus-group-next-unread-group (- n) t))
5536 (defun gnus-group-prev-unread-group (n)
5537 "Go to previous N'th unread newsgroup.
5538 Returns the difference between N and the number of skips actually
5541 (gnus-group-next-unread-group (- n)))
5543 (defun gnus-group-next-unread-group-same-level (n)
5544 "Go to next N'th unread newsgroup on the same level.
5545 If N is negative, search backward instead.
5546 Returns the difference between N and the number of skips actually
5549 (gnus-group-next-unread-group n t (gnus-group-group-level))
5550 (gnus-group-position-point))
5552 (defun gnus-group-prev-unread-group-same-level (n)
5553 "Go to next N'th unread newsgroup on the same level.
5554 Returns the difference between N and the number of skips actually
5557 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5558 (gnus-group-position-point))
5560 (defun gnus-group-best-unread-group (&optional exclude-group)
5561 "Go to the group with the highest level.
5562 If EXCLUDE-GROUP, do not go to that group."
5564 (goto-char (point-min))
5568 (setq unread (get-text-property (point) 'gnus-unread))
5569 (if (and (numberp unread) (> unread 0))
5571 (if (and (get-text-property (point) 'gnus-level)
5572 (< (get-text-property (point) 'gnus-level) best)
5573 (or (not exclude-group)
5574 (not (equal exclude-group (gnus-group-group-name)))))
5576 (setq best (get-text-property (point) 'gnus-level))
5577 (setq best-point (point))))))
5579 (if best-point (goto-char best-point))
5580 (gnus-summary-position-point)
5581 (and best-point (gnus-group-group-name))))
5583 (defun gnus-group-first-unread-group ()
5584 "Go to the first group with unread articles."
5587 (let ((opoint (point))
5589 (goto-char (point-min))
5590 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5591 (and (numberp unread) ; Not a topic.
5592 (not (zerop unread))) ; Has unread articles.
5593 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5596 nil)) ; Not success.
5597 (gnus-group-position-point)))
5599 (defun gnus-group-enter-server-mode ()
5600 "Jump to the server buffer."
5602 (gnus-enter-server-buffer))
5604 (defun gnus-group-make-group (name &optional method address)
5605 "Add a new newsgroup.
5606 The user will be prompted for a NAME, for a select METHOD, and an
5610 (read-string "Group name: ")
5613 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5614 nil t nil 'gnus-method-history)))
5615 (cond ((assoc method gnus-valid-select-methods)
5617 (if (memq 'prompt-address
5618 (assoc method gnus-valid-select-methods))
5619 (read-string "Address: ")
5621 ((assoc method gnus-server-alist)
5624 (list method ""))))))
5626 (let* ((meth (and method (if address (list (intern method) address)
5628 (nname (if method (gnus-group-prefixed-name name meth) name))
5630 (when (gnus-gethash nname gnus-newsrc-hashtb)
5631 (error "Group %s already exists" nname))
5632 ;; Subscribe to the new group.
5633 (gnus-group-change-level
5634 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5635 gnus-level-default-subscribed gnus-level-killed
5636 (and (gnus-group-group-name)
5637 (gnus-gethash (gnus-group-group-name)
5638 gnus-newsrc-hashtb))
5641 (gnus-set-active nname (cons 1 0))
5642 (or (gnus-ephemeral-group-p name)
5644 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5646 (gnus-group-insert-group-line-info nname)
5648 (gnus-group-position-point)
5650 ;; Load the backend and try to make the backend create
5651 ;; the group as well.
5652 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5654 gnus-valid-select-methods)
5656 (gnus-check-server meth)
5657 (and (gnus-check-backend-function 'request-create-group nname)
5658 (gnus-request-create-group nname))
5661 (defun gnus-group-delete-group (group &optional force)
5662 "Delete the current group. Only meaningful with mail groups.
5663 If FORCE (the prefix) is non-nil, all the articles in the group will
5664 be deleted. This is \"deleted\" as in \"removed forever from the face
5665 of the Earth\". There is no undo. The user will be prompted before
5666 doing the deletion."
5668 (list (gnus-group-group-name)
5669 current-prefix-arg))
5670 (or group (error "No group to rename"))
5671 (or (gnus-check-backend-function 'request-delete-group group)
5672 (error "This backend does not support group deletion"))
5674 (if (not (gnus-yes-or-no-p
5676 "Do you really want to delete %s%s? "
5677 group (if force " and all its contents" ""))))
5679 (gnus-message 6 "Deleting group %s..." group)
5680 (if (not (gnus-request-delete-group group force))
5681 (gnus-error 3 "Couldn't delete group %s" group)
5682 (gnus-message 6 "Deleting group %s...done" group)
5683 (gnus-group-goto-group group)
5684 (gnus-group-kill-group 1 t)
5685 (gnus-sethash group nil gnus-active-hashtb)
5687 (gnus-group-position-point)))
5689 (defun gnus-group-rename-group (group new-name)
5692 (gnus-group-group-name)
5694 (or (gnus-check-backend-function
5695 'request-rename-group (gnus-group-group-name))
5696 (error "This backend does not support renaming groups"))
5697 (read-string "New group name: "))))
5699 (or (gnus-check-backend-function 'request-rename-group group)
5700 (error "This backend does not support renaming groups"))
5702 (or group (error "No group to rename"))
5703 (and (string-match "^[ \t]*$" new-name)
5704 (error "Not a valid group name"))
5706 ;; We find the proper prefixed name.
5708 (gnus-group-prefixed-name
5709 (gnus-group-real-name new-name)
5710 (gnus-info-method (gnus-get-info group))))
5712 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5714 (if (not (gnus-request-rename-group group new-name))
5715 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5716 ;; We rename the group internally by killing it...
5717 (gnus-group-goto-group group)
5718 (gnus-group-kill-group)
5719 ;; ... changing its name ...
5720 (setcar (cdar gnus-list-of-killed-groups) new-name)
5721 ;; ... and then yanking it. Magic!
5722 (gnus-group-yank-group)
5723 (gnus-set-active new-name (gnus-active group))
5724 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5726 (gnus-group-position-point)))
5728 (defun gnus-group-edit-group (group &optional part)
5729 "Edit the group on the current line."
5730 (interactive (list (gnus-group-group-name)))
5731 (let* ((part (or part 'info))
5732 (done-func `(lambda ()
5733 "Exit editing mode and update the information."
5735 (gnus-group-edit-group-done ',part ,group)))
5736 (winconf (current-window-configuration))
5738 (or group (error "No group on current line"))
5739 (or (setq info (gnus-get-info group))
5740 (error "Killed group; can't be edited"))
5741 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5742 (gnus-configure-windows 'edit-group)
5743 (gnus-add-current-to-buffer-list)
5745 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5746 (use-local-map (copy-keymap emacs-lisp-mode-map))
5747 (local-set-key "\C-c\C-c" done-func)
5748 (make-local-variable 'gnus-prev-winconf)
5749 (setq gnus-prev-winconf winconf)
5754 ";; Type `C-c C-c' after editing the select method.\n\n")
5756 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5758 ";; Type `C-c C-c' after editing the group info.\n\n")))
5761 (cond ((eq part 'method)
5762 (or (gnus-info-method info) "native"))
5764 (gnus-info-params info))
5768 (defun gnus-group-edit-group-method (group)
5769 "Edit the select method of GROUP."
5770 (interactive (list (gnus-group-group-name)))
5771 (gnus-group-edit-group group 'method))
5773 (defun gnus-group-edit-group-parameters (group)
5774 "Edit the group parameters of GROUP."
5775 (interactive (list (gnus-group-group-name)))
5776 (gnus-group-edit-group group 'params))
5778 (defun gnus-group-edit-group-done (part group)
5779 "Get info from buffer, update variables and jump to the group buffer."
5780 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5781 (goto-char (point-min))
5782 (let* ((form (read (current-buffer)))
5783 (winconf gnus-prev-winconf)
5784 (method (cond ((eq part 'info) (nth 4 form))
5785 ((eq part 'method) form)
5787 (info (cond ((eq part 'info) form)
5788 ((eq part 'method) (gnus-get-info group))
5791 (if (or (not method)
5793 gnus-select-method method))
5794 (gnus-group-real-name (car info))
5795 (gnus-group-prefixed-name
5796 (gnus-group-real-name (car info)) method))
5798 (when (and new-group
5799 (not (equal new-group group)))
5800 (when (gnus-group-goto-group group)
5801 (gnus-group-kill-group 1))
5802 (gnus-activate-group new-group))
5804 (if (and info new-group)
5806 (setq info (gnus-copy-sequence info))
5807 (setcar info new-group)
5808 (unless (gnus-server-equal method "native")
5809 (unless (nthcdr 3 info)
5810 (nconc info (list nil nil)))
5811 (unless (nthcdr 4 info)
5812 (nconc info (list nil)))
5813 (gnus-info-set-method info method))
5814 (gnus-group-set-info info))
5815 (gnus-group-set-info form (or new-group group) part))
5816 (kill-buffer (current-buffer))
5817 (and winconf (set-window-configuration winconf))
5818 (set-buffer gnus-group-buffer)
5819 (gnus-group-update-group (or new-group group))
5820 (gnus-group-position-point)))
5822 (defun gnus-group-make-help-group ()
5823 "Create the Gnus documentation group."
5825 (let ((path load-path)
5826 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5828 (and (gnus-gethash name gnus-newsrc-hashtb)
5829 (error "Documentation group already exists"))
5831 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5833 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5835 (setq file (concat (file-name-directory
5836 (directory-file-name dir))
5837 "etc/gnus-tut.txt"))))
5840 (gnus-message 1 "Couldn't find doc group")
5841 (gnus-group-make-group
5842 (gnus-group-real-name name)
5843 (list 'nndoc "gnus-help"
5844 (list 'nndoc-address file)
5845 (list 'nndoc-article-type 'mbox)))))
5846 (gnus-group-position-point))
5848 (defun gnus-group-make-doc-group (file type)
5849 "Create a group that uses a single file as the source."
5851 (list (read-file-name "File name: ")
5852 (and current-prefix-arg 'ask)))
5853 (when (eq type 'ask)
5858 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5860 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5861 ((= char ?b) 'babyl)
5862 ((= char ?d) 'digest)
5863 ((= char ?f) 'forward)
5865 (t (setq err (format "%c unknown. " char))
5868 (let* ((file (expand-file-name file))
5869 (name (gnus-generate-new-group-name
5870 (gnus-group-prefixed-name
5871 (file-name-nondirectory file) '(nndoc "")))))
5872 (gnus-group-make-group
5873 (gnus-group-real-name name)
5874 (list 'nndoc (file-name-nondirectory file)
5875 (list 'nndoc-address file)
5876 (list 'nndoc-article-type (or type 'guess))))))
5878 (defun gnus-group-make-archive-group (&optional all)
5879 "Create the (ding) Gnus archive group of the most recent articles.
5880 Given a prefix, create a full group."
5882 (let ((group (gnus-group-prefixed-name
5883 (if all "ding.archives" "ding.recent") '(nndir ""))))
5884 (and (gnus-gethash group gnus-newsrc-hashtb)
5885 (error "Archive group already exists"))
5886 (gnus-group-make-group
5887 (gnus-group-real-name group)
5888 (list 'nndir (if all "hpc" "edu")
5889 (list 'nndir-directory
5890 (if all gnus-group-archive-directory
5891 gnus-group-recent-archive-directory))))))
5893 (defun gnus-group-make-directory-group (dir)
5894 "Create an nndir group.
5895 The user will be prompted for a directory. The contents of this
5896 directory will be used as a newsgroup. The directory should contain
5897 mail messages or news articles in files that have numeric names."
5899 (list (read-file-name "Create group from directory: ")))
5900 (or (file-exists-p dir) (error "No such directory"))
5901 (or (file-directory-p dir) (error "Not a directory"))
5905 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5907 (gnus-group-prefixed-name
5908 (concat (file-name-as-directory (directory-file-name dir))
5911 (setq ext (format "<%d>" (setq i (1+ i)))))
5912 (gnus-group-make-group
5913 (gnus-group-real-name group)
5914 (list 'nndir group (list 'nndir-directory dir)))))
5916 (defun gnus-group-make-kiboze-group (group address scores)
5917 "Create an nnkiboze group.
5918 The user will be prompted for a name, a regexp to match groups, and
5919 score file entries for articles to include in the group."
5922 (read-string "nnkiboze group name: ")
5923 (read-string "Source groups (regexp): ")
5924 (let ((headers (mapcar (lambda (group) (list group))
5925 '("subject" "from" "number" "date" "message-id"
5926 "references" "chars" "lines" "xref"
5927 "followup" "all" "body" "head")))
5928 scores header regexp regexps)
5929 (while (not (equal "" (setq header (completing-read
5930 "Match on header: " headers nil t))))
5932 (while (not (equal "" (setq regexp (read-string
5933 (format "Match on %s (string): "
5935 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5936 (setq scores (cons (cons header regexps) scores)))
5938 (gnus-group-make-group group "nnkiboze" address)
5939 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5940 (let (emacs-lisp-mode-hook)
5941 (pp scores (current-buffer)))))
5943 (defun gnus-group-add-to-virtual (n vgroup)
5944 "Add the current group to a virtual group."
5946 (list current-prefix-arg
5947 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5949 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5950 (error "%s is not an nnvirtual group" vgroup))
5951 (let* ((groups (gnus-group-process-prefix n))
5952 (method (gnus-info-method (gnus-get-info vgroup))))
5953 (setcar (cdr method)
5955 (nth 1 method) "\\|"
5958 (gnus-group-remove-mark s)
5959 (concat "\\(^" (regexp-quote s) "$\\)"))
5961 (gnus-group-position-point))
5963 (defun gnus-group-make-empty-virtual (group)
5964 "Create a new, fresh, empty virtual group."
5965 (interactive "sCreate new, empty virtual group: ")
5966 (let* ((method (list 'nnvirtual "^$"))
5967 (pgroup (gnus-group-prefixed-name group method)))
5968 ;; Check whether it exists already.
5969 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5970 (error "Group %s already exists." pgroup))
5971 ;; Subscribe the new group after the group on the current line.
5972 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5973 (gnus-group-update-group pgroup)
5975 (gnus-group-position-point)))
5977 (defun gnus-group-enter-directory (dir)
5978 "Enter an ephemeral nneething group."
5979 (interactive "DDirectory to read: ")
5980 (let* ((method (list 'nneething dir '(nneething-read-only t)))
5981 (leaf (gnus-group-prefixed-name
5982 (file-name-nondirectory (directory-file-name dir))
5984 (name (gnus-generate-new-group-name leaf)))
5985 (unless (gnus-group-read-ephemeral-group
5987 (cons (current-buffer)
5988 (if (eq major-mode 'gnus-summary-mode)
5990 (error "Couldn't enter %s" dir))))
5992 ;; Group sorting commands
5993 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5995 (defun gnus-group-sort-groups (func &optional reverse)
5996 "Sort the group buffer according to FUNC.
5997 If REVERSE, reverse the sorting order."
5998 (interactive (list gnus-group-sort-function
5999 current-prefix-arg))
6001 ((not (listp func)) func)
6003 ((= 1 (length func)) (car func))
6005 ,(gnus-make-sort-function
6006 (reverse func)))))))
6007 ;; We peel off the dummy group from the alist.
6009 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
6010 (pop gnus-newsrc-alist))
6012 (setq gnus-newsrc-alist
6013 (sort gnus-newsrc-alist func))
6015 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
6016 ;; Regenerate the hash table.
6017 (gnus-make-hashtable-from-newsrc-alist)
6018 (gnus-group-list-groups))))
6020 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
6021 "Sort the group buffer alphabetically by group name.
6022 If REVERSE, sort in reverse order."
6024 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
6026 (defun gnus-group-sort-groups-by-unread (&optional reverse)
6027 "Sort the group buffer by number of unread articles.
6028 If REVERSE, sort in reverse order."
6030 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
6032 (defun gnus-group-sort-groups-by-level (&optional reverse)
6033 "Sort the group buffer by group level.
6034 If REVERSE, sort in reverse order."
6036 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
6038 (defun gnus-group-sort-groups-by-score (&optional reverse)
6039 "Sort the group buffer by group score.
6040 If REVERSE, sort in reverse order."
6042 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
6044 (defun gnus-group-sort-groups-by-rank (&optional reverse)
6045 "Sort the group buffer by group rank.
6046 If REVERSE, sort in reverse order."
6048 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6050 (defun gnus-group-sort-groups-by-method (&optional reverse)
6051 "Sort the group buffer alphabetically by backend name.
6052 If REVERSE, sort in reverse order."
6054 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6056 (defun gnus-group-sort-by-alphabet (info1 info2)
6057 "Sort alphabetically."
6058 (string< (gnus-info-group info1) (gnus-info-group info2)))
6060 (defun gnus-group-sort-by-unread (info1 info2)
6061 "Sort by number of unread articles."
6062 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6063 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6064 (< (or (and (numberp n1) n1) 0)
6065 (or (and (numberp n2) n2) 0))))
6067 (defun gnus-group-sort-by-level (info1 info2)
6069 (< (gnus-info-level info1) (gnus-info-level info2)))
6071 (defun gnus-group-sort-by-method (info1 info2)
6072 "Sort alphabetically by backend name."
6073 (string< (symbol-name (car (gnus-find-method-for-group
6074 (gnus-info-group info1) info1)))
6075 (symbol-name (car (gnus-find-method-for-group
6076 (gnus-info-group info2) info2)))))
6078 (defun gnus-group-sort-by-score (info1 info2)
6079 "Sort by group score."
6080 (< (gnus-info-score info1) (gnus-info-score info2)))
6082 (defun gnus-group-sort-by-rank (info1 info2)
6083 "Sort by level and score."
6084 (let ((level1 (gnus-info-level info1))
6085 (level2 (gnus-info-level info2)))
6086 (or (< level1 level2)
6087 (and (= level1 level2)
6088 (> (gnus-info-score info1) (gnus-info-score info2))))))
6090 ;; Group catching up.
6092 (defun gnus-group-clear-data (n)
6093 "Clear all marks and read ranges from the current group."
6095 (let ((groups (gnus-group-process-prefix n))
6097 (while (setq group (pop groups))
6098 (setq info (gnus-get-info group))
6099 (gnus-info-set-read info nil)
6100 (when (gnus-info-marks info)
6101 (gnus-info-set-marks info nil))
6102 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6103 (when (gnus-group-goto-group group)
6104 (gnus-group-remove-mark group)
6105 (gnus-group-update-group-line)))))
6107 (defun gnus-group-catchup-current (&optional n all)
6108 "Mark all articles not marked as unread in current newsgroup as read.
6109 If prefix argument N is numeric, the ARG next newsgroups will be
6110 caught up. If ALL is non-nil, marked articles will also be marked as
6111 read. Cross references (Xref: header) of articles are ignored.
6112 The difference between N and actual number of newsgroups that were
6113 caught up is returned."
6115 (unless (gnus-group-group-name)
6116 (error "No group on the current line"))
6117 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6121 "Do you really want to mark all articles as read? "
6122 "Mark all unread articles as read? "))))
6124 (let ((groups (gnus-group-process-prefix n))
6127 ;; Virtual groups have to be given special treatment.
6128 (let ((method (gnus-find-method-for-group (car groups))))
6129 (if (eq 'nnvirtual (car method))
6130 (nnvirtual-catchup-group
6131 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6132 (gnus-group-remove-mark (car groups))
6133 (if (>= (gnus-group-group-level) gnus-level-zombie)
6134 (gnus-message 2 "Dead groups can't be caught up")
6136 (gnus-group-goto-group (car groups))
6137 (gnus-group-catchup (car groups) all))
6138 (gnus-group-update-group-line)
6139 (setq ret (1+ ret))))
6140 (setq groups (cdr groups)))
6141 (gnus-group-next-unread-group 1)
6144 (defun gnus-group-catchup-current-all (&optional n)
6145 "Mark all articles in current newsgroup as read.
6146 Cross references (Xref: header) of articles are ignored."
6148 (gnus-group-catchup-current n 'all))
6150 (defun gnus-group-catchup (group &optional all)
6151 "Mark all articles in GROUP as read.
6152 If ALL is non-nil, all articles are marked as read.
6153 The return value is the number of articles that were marked as read,
6154 or nil if no action could be taken."
6155 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6157 ;; Do the updating only if the newsgroup isn't killed.
6158 (if (not (numberp (car entry)))
6159 (gnus-message 1 "Can't catch up; non-active group")
6160 ;; Do auto-expirable marks if that's required.
6161 (when (gnus-group-auto-expirable-p group)
6162 (gnus-add-marked-articles
6163 group 'expire (gnus-list-of-unread-articles group))
6165 (let ((marks (nth 3 (nth 2 entry))))
6166 (gnus-add-marked-articles
6167 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6168 (gnus-add-marked-articles
6169 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6171 (gnus-update-read-articles group nil)
6172 ;; Also nix out the lists of marks and dormants.
6174 (gnus-add-marked-articles group 'tick nil nil 'force)
6175 (gnus-add-marked-articles group 'dormant nil nil 'force))
6176 (run-hooks 'gnus-group-catchup-group-hook)
6179 (defun gnus-group-expire-articles (&optional n)
6180 "Expire all expirable articles in the current newsgroup."
6182 (let ((groups (gnus-group-process-prefix n))
6185 (error "No groups to expire"))
6186 (while (setq group (pop groups))
6187 (gnus-group-remove-mark group)
6188 (when (gnus-check-backend-function 'request-expire-articles group)
6189 (gnus-message 6 "Expiring articles in %s..." group)
6190 (let* ((info (gnus-get-info group))
6191 (expirable (if (gnus-group-total-expirable-p group)
6192 (cons nil (gnus-list-of-read-articles group))
6193 (assq 'expire (gnus-info-marks info))))
6194 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6198 (gnus-compress-sequence
6200 ;; We set the expiry variables to the groupp
6202 (let ((nnmail-expiry-wait-function nil)
6203 (nnmail-expiry-wait expiry-wait))
6204 (gnus-request-expire-articles
6205 (gnus-uncompress-sequence (cdr expirable)) group))
6206 ;; Just expire using the normal expiry values.
6207 (gnus-request-expire-articles
6208 (gnus-uncompress-sequence (cdr expirable)) group))))
6209 (gnus-close-group group))
6210 (gnus-message 6 "Expiring articles in %s...done" group)))
6211 (gnus-group-position-point))))
6213 (defun gnus-group-expire-all-groups ()
6214 "Expire all expirable articles in all newsgroups."
6217 (gnus-message 5 "Expiring...")
6218 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6219 (cdr gnus-newsrc-alist))))
6220 (gnus-group-expire-articles nil)))
6221 (gnus-group-position-point)
6222 (gnus-message 5 "Expiring...done"))
6224 (defun gnus-group-set-current-level (n level)
6225 "Set the level of the next N groups to LEVEL."
6230 (let ((s (read-string
6231 (format "Level (default %s): "
6232 (or (gnus-group-group-level)
6233 gnus-level-default-subscribed)))))
6234 (if (string-match "^\\s-*$" s)
6235 (int-to-string (or (gnus-group-group-level)
6236 gnus-level-default-subscribed))
6238 (or (and (>= level 1) (<= level gnus-level-killed))
6239 (error "Illegal level: %d" level))
6240 (let ((groups (gnus-group-process-prefix n))
6242 (while (setq group (pop groups))
6243 (gnus-group-remove-mark group)
6244 (gnus-message 6 "Changed level of %s from %d to %d"
6245 group (or (gnus-group-group-level) gnus-level-killed)
6247 (gnus-group-change-level
6248 group level (or (gnus-group-group-level) gnus-level-killed))
6249 (gnus-group-update-group-line)))
6250 (gnus-group-position-point))
6252 (defun gnus-group-unsubscribe-current-group (&optional n)
6253 "Toggle subscription of the current group.
6254 If given numerical prefix, toggle the N next groups."
6256 (let ((groups (gnus-group-process-prefix n))
6259 (setq group (car groups)
6260 groups (cdr groups))
6261 (gnus-group-remove-mark group)
6262 (gnus-group-unsubscribe-group
6263 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6264 gnus-level-default-unsubscribed
6265 gnus-level-default-subscribed) t)
6266 (gnus-group-update-group-line))
6267 (gnus-group-next-group 1)))
6269 (defun gnus-group-unsubscribe-group (group &optional level silent)
6270 "Toggle subscription to GROUP.
6271 Killed newsgroups are subscribed. If SILENT, don't try to update the
6274 (list (completing-read
6275 "Group: " gnus-active-hashtb nil
6276 (gnus-read-active-file-p)
6278 'gnus-group-history)))
6279 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6281 ((string-match "^[ \t]$" group)
6282 (error "Empty group name"))
6284 ;; Toggle subscription flag.
6285 (gnus-group-change-level
6286 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6287 gnus-level-subscribed)
6288 (1+ gnus-level-subscribed)
6289 gnus-level-default-subscribed)))
6291 (gnus-group-update-group group)))
6292 ((and (stringp group)
6293 (or (not (gnus-read-active-file-p))
6294 (gnus-active group)))
6295 ;; Add new newsgroup.
6296 (gnus-group-change-level
6298 (if level level gnus-level-default-subscribed)
6299 (or (and (member group gnus-zombie-list)
6302 (and (gnus-group-group-name)
6303 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6305 (gnus-group-update-group group)))
6306 (t (error "No such newsgroup: %s" group)))
6307 (gnus-group-position-point)))
6309 (defun gnus-group-transpose-groups (n)
6310 "Move the current newsgroup up N places.
6311 If given a negative prefix, move down instead. The difference between
6312 N and the number of steps taken is returned."
6314 (or (gnus-group-group-name)
6315 (error "No group on current line"))
6316 (gnus-group-kill-group 1)
6318 (forward-line (- n))
6319 (gnus-group-yank-group)
6320 (gnus-group-position-point)))
6322 (defun gnus-group-kill-all-zombies ()
6323 "Kill all zombie newsgroups."
6325 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6326 (setq gnus-zombie-list nil)
6327 (gnus-group-list-groups))
6329 (defun gnus-group-kill-region (begin end)
6330 "Kill newsgroups in current region (excluding current point).
6331 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6346 (beginning-of-line) ;Important when LINES < 1
6347 (gnus-group-kill-group lines)))
6349 (defun gnus-group-kill-group (&optional n discard)
6350 "Kill the next N groups.
6351 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6352 However, only groups that were alive can be yanked; already killed
6353 groups or zombie groups can't be yanked.
6354 The return value is the name of the group that was killed, or a list
6357 (let ((buffer-read-only nil)
6358 (groups (gnus-group-process-prefix n))
6359 group entry level out)
6360 (if (< (length groups) 10)
6361 ;; This is faster when there are few groups.
6363 (push (setq group (pop groups)) out)
6364 (gnus-group-remove-mark group)
6365 (setq level (gnus-group-group-level))
6367 (when (and (not discard)
6368 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6369 (push (cons (car entry) (nth 2 entry))
6370 gnus-list-of-killed-groups))
6371 (gnus-group-change-level
6372 (if entry entry group) gnus-level-killed (if entry nil level)))
6373 ;; If there are lots and lots of groups to be killed, we use
6374 ;; this thing instead.
6376 (setq groups (nreverse groups))
6378 (gnus-group-remove-mark (setq group (pop groups)))
6380 (push group gnus-killed-list)
6381 (setq gnus-newsrc-alist
6382 (delq (assoc group gnus-newsrc-alist)
6384 (when gnus-group-change-level-function
6385 (funcall gnus-group-change-level-function group 9 3))
6387 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6388 (push (cons (car entry) (nth 2 entry))
6389 gnus-list-of-killed-groups)
6390 (setcdr (cdr entry) (cdddr entry)))
6391 ((member group gnus-zombie-list)
6392 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6393 (gnus-make-hashtable-from-newsrc-alist)))
6395 (gnus-group-position-point)
6396 (if (< (length out) 2) (car out) (nreverse out))))
6398 (defun gnus-group-yank-group (&optional arg)
6399 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6400 inserting it before the current newsgroup. The numeric ARG specifies
6401 how many newsgroups are to be yanked. The name of the newsgroup yanked
6402 is returned, or (if several groups are yanked) a list of yanked groups
6405 (setq arg (or arg 1))
6406 (let (info group prev out)
6407 (while (>= (decf arg) 0)
6408 (if (not (setq info (pop gnus-list-of-killed-groups)))
6409 (error "No more newsgroups to yank"))
6410 (push (setq group (nth 1 info)) out)
6411 ;; Find which newsgroup to insert this one before - search
6412 ;; backward until something suitable is found. If there are no
6413 ;; other newsgroups in this buffer, just make this newsgroup the
6415 (setq prev (gnus-group-group-name))
6416 (gnus-group-change-level
6417 info (gnus-info-level (cdr info)) gnus-level-killed
6418 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6420 (gnus-group-insert-group-line-info group))
6422 (gnus-group-position-point)
6423 (if (< (length out) 2) (car out) (nreverse out))))
6425 (defun gnus-group-kill-level (level)
6426 "Kill all groups that is on a certain LEVEL."
6427 (interactive "nKill all groups on level: ")
6429 ((= level gnus-level-zombie)
6430 (setq gnus-killed-list
6431 (nconc gnus-zombie-list gnus-killed-list))
6432 (setq gnus-zombie-list nil))
6433 ((and (< level gnus-level-zombie)
6435 (or gnus-expert-user
6438 "Do you really want to kill all groups on level %d? "
6440 (let* ((prev gnus-newsrc-alist)
6443 (if (= (gnus-info-level (car alist)) level)
6445 (push (gnus-info-group (car alist)) gnus-killed-list)
6446 (setcdr prev (cdr alist)))
6448 (setq alist (cdr alist)))
6449 (gnus-make-hashtable-from-newsrc-alist)
6450 (gnus-group-list-groups)))
6452 (error "Can't kill; illegal level: %d" level))))
6454 (defun gnus-group-list-all-groups (&optional arg)
6455 "List all newsgroups with level ARG or lower.
6456 Default is gnus-level-unsubscribed, which lists all subscribed and most
6457 unsubscribed groups."
6459 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6461 ;; Redefine this to list ALL killed groups if prefix arg used.
6462 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6463 (defun gnus-group-list-killed (&optional arg)
6464 "List all killed newsgroups in the group buffer.
6465 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6466 entail asking the server for the groups."
6468 ;; Find all possible killed newsgroups if arg.
6470 (gnus-get-killed-groups))
6471 (if (not gnus-killed-list)
6472 (gnus-message 6 "No killed groups")
6473 (let (gnus-group-list-mode)
6474 (funcall gnus-group-prepare-function
6475 gnus-level-killed t gnus-level-killed))
6476 (goto-char (point-min)))
6477 (gnus-group-position-point))
6479 (defun gnus-group-list-zombies ()
6480 "List all zombie newsgroups in the group buffer."
6482 (if (not gnus-zombie-list)
6483 (gnus-message 6 "No zombie groups")
6484 (let (gnus-group-list-mode)
6485 (funcall gnus-group-prepare-function
6486 gnus-level-zombie t gnus-level-zombie))
6487 (goto-char (point-min)))
6488 (gnus-group-position-point))
6490 (defun gnus-group-list-active ()
6491 "List all groups that are available from the server(s)."
6493 ;; First we make sure that we have really read the active file.
6494 (unless (gnus-read-active-file-p)
6495 (let ((gnus-read-active-file t))
6496 (gnus-read-active-file)))
6497 ;; Find all groups and sort them.
6505 (setq list (cons (symbol-name sym) list))))
6509 (buffer-read-only nil))
6512 (gnus-group-insert-group-line-info (pop groups)))
6513 (goto-char (point-min))))
6515 (defun gnus-activate-all-groups (level)
6516 "Activate absolutely all groups."
6517 (interactive (list 7))
6518 (let ((gnus-activate-level level)
6519 (gnus-activate-foreign-newsgroups level))
6520 (gnus-group-get-new-news)))
6522 (defun gnus-group-get-new-news (&optional arg)
6523 "Get newly arrived articles.
6524 If ARG is a number, it specifies which levels you are interested in
6525 re-scanning. If ARG is non-nil and not a number, this will force
6526 \"hard\" re-reading of the active files from all servers."
6528 (run-hooks 'gnus-get-new-news-hook)
6529 ;; We might read in new NoCeM messages here.
6530 (when (and gnus-use-nocem
6532 (gnus-nocem-scan-groups))
6533 ;; If ARG is not a number, then we read the active file.
6534 (when (and arg (not (numberp arg)))
6535 (let ((gnus-read-active-file t))
6536 (gnus-read-active-file))
6539 (setq arg (gnus-group-default-level arg t))
6540 (if (and gnus-read-active-file (not arg))
6542 (gnus-read-active-file)
6543 (gnus-get-unread-articles arg))
6544 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6545 (gnus-get-unread-articles arg)))
6546 (run-hooks 'gnus-after-getting-new-news-hook)
6547 (gnus-group-list-groups))
6549 (defun gnus-group-get-new-news-this-group (&optional n)
6550 "Check for newly arrived news in the current group (and the N-1 next groups).
6551 The difference between N and the number of newsgroup checked is returned.
6552 If N is negative, this group and the N-1 previous groups will be checked."
6554 (let* ((groups (gnus-group-process-prefix n))
6555 (ret (if (numberp n) (- n (length groups)) 0))
6556 (beg (unless n (point)))
6558 (while (setq group (pop groups))
6559 (gnus-group-remove-mark group)
6560 (if (gnus-activate-group group 'scan)
6562 (gnus-get-unread-articles-in-group
6563 (gnus-get-info group) (gnus-active group) t)
6564 (unless (gnus-virtual-group-p group)
6565 (gnus-close-group group))
6566 (gnus-group-update-group group))
6567 (if (eq (gnus-server-status (gnus-find-method-for-group group))
6569 (gnus-error "Server denied access")
6570 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
6571 (when beg (goto-char beg))
6572 (when gnus-goto-next-group-when-activating
6573 (gnus-group-next-unread-group 1 t))
6574 (gnus-summary-position-point)
6577 (defun gnus-group-fetch-faq (group &optional faq-dir)
6578 "Fetch the FAQ for the current group."
6581 (and (gnus-group-group-name)
6582 (gnus-group-real-name (gnus-group-group-name)))
6583 (cond (current-prefix-arg
6585 "Faq dir: " (and (listp gnus-group-faq-directory)
6586 (mapcar (lambda (file) (list file))
6587 gnus-group-faq-directory)))))))
6589 (setq faq-dir (if (listp gnus-group-faq-directory)
6590 (car gnus-group-faq-directory)
6591 gnus-group-faq-directory)))
6592 (or group (error "No group name given"))
6593 (let ((file (concat (file-name-as-directory faq-dir)
6594 (gnus-group-real-name group))))
6595 (if (not (file-exists-p file))
6596 (error "No such file: %s" file)
6599 (defun gnus-group-describe-group (force &optional group)
6600 "Display a description of the current newsgroup."
6601 (interactive (list current-prefix-arg (gnus-group-group-name)))
6602 (let* ((method (gnus-find-method-for-group group))
6603 (mname (gnus-group-prefixed-name "" method))
6606 gnus-description-hashtb)
6607 (gnus-sethash mname nil gnus-description-hashtb))
6608 (or group (error "No group name given"))
6609 (and (or (and gnus-description-hashtb
6610 ;; We check whether this group's method has been
6611 ;; queried for a description file.
6612 (gnus-gethash mname gnus-description-hashtb))
6613 (setq desc (gnus-group-get-description group))
6614 (gnus-read-descriptions-file method))
6616 (or desc (gnus-gethash group gnus-description-hashtb)
6617 "No description available")))))
6619 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6620 (defun gnus-group-describe-all-groups (&optional force)
6621 "Pop up a buffer with descriptions of all newsgroups."
6623 (and force (setq gnus-description-hashtb nil))
6624 (if (not (or gnus-description-hashtb
6625 (gnus-read-all-descriptions-files)))
6626 (error "Couldn't request descriptions file"))
6627 (let ((buffer-read-only nil)
6633 (insert (format " *: %-20s %s\n" (symbol-name group)
6634 (symbol-value group)))
6635 (gnus-add-text-properties
6636 b (1+ b) (list 'gnus-group group
6637 'gnus-unread t 'gnus-marked nil
6638 'gnus-level (1+ gnus-level-subscribed))))
6639 gnus-description-hashtb)
6640 (goto-char (point-min))
6641 (gnus-group-position-point)))
6643 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6644 (defun gnus-group-apropos (regexp &optional search-description)
6645 "List all newsgroups that have names that match a regexp."
6646 (interactive "sGnus apropos (regexp): ")
6648 (obuf (current-buffer))
6650 ;; Go through all newsgroups that are known to Gnus.
6653 (and (symbol-name group)
6654 (string-match regexp (symbol-name group))
6655 (setq groups (cons (symbol-name group) groups))))
6657 ;; Also go through all descriptions that are known to Gnus.
6658 (when search-description
6661 (and (string-match regexp (symbol-value group))
6662 (gnus-active (symbol-name group))
6663 (setq groups (cons (symbol-name group) groups))))
6664 gnus-description-hashtb))
6666 (gnus-message 3 "No groups matched \"%s\"." regexp)
6667 ;; Print out all the groups.
6669 (pop-to-buffer "*Gnus Help*")
6670 (buffer-disable-undo (current-buffer))
6672 (setq groups (sort groups 'string<))
6674 ;; Groups may be entered twice into the list of groups.
6675 (if (not (string= (car groups) prev))
6677 (insert (setq prev (car groups)) "\n")
6678 (if (and gnus-description-hashtb
6679 (setq des (gnus-gethash (car groups)
6680 gnus-description-hashtb)))
6681 (insert " " des "\n"))))
6682 (setq groups (cdr groups)))
6683 (goto-char (point-min))))
6684 (pop-to-buffer obuf)))
6686 (defun gnus-group-description-apropos (regexp)
6687 "List all newsgroups that have names or descriptions that match a regexp."
6688 (interactive "sGnus description apropos (regexp): ")
6689 (if (not (or gnus-description-hashtb
6690 (gnus-read-all-descriptions-files)))
6691 (error "Couldn't request descriptions file"))
6692 (gnus-group-apropos regexp t))
6694 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6695 (defun gnus-group-list-matching (level regexp &optional all lowest)
6696 "List all groups with unread articles that match REGEXP.
6697 If the prefix LEVEL is non-nil, it should be a number that says which
6698 level to cut off listing groups.
6699 If ALL, also list groups with no unread articles.
6700 If LOWEST, don't list groups with level lower than LOWEST.
6702 This command may read the active file."
6703 (interactive "P\nsList newsgroups matching: ")
6704 ;; First make sure active file has been read.
6706 (> (prefix-numeric-value level) gnus-level-killed))
6707 (gnus-get-killed-groups))
6708 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6709 all (or lowest 1) regexp)
6710 (goto-char (point-min))
6711 (gnus-group-position-point))
6713 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6714 "List all groups 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 LOWEST, don't list groups with level lower than LOWEST."
6718 (interactive "P\nsList newsgroups matching: ")
6719 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6721 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6722 (defun gnus-group-save-newsrc (&optional force)
6723 "Save the Gnus startup files.
6724 If FORCE, force saving whether it is necessary or not."
6726 (gnus-save-newsrc-file force))
6728 (defun gnus-group-restart (&optional arg)
6729 "Force Gnus to read the .newsrc file."
6731 (when (gnus-yes-or-no-p
6732 (format "Are you sure you want to read %s? "
6733 gnus-current-startup-file))
6734 (gnus-save-newsrc-file)
6735 (gnus-setup-news 'force)
6736 (gnus-group-list-groups arg)))
6738 (defun gnus-group-read-init-file ()
6739 "Read the Gnus elisp init file."
6741 (gnus-read-init-file))
6743 (defun gnus-group-check-bogus-groups (&optional silent)
6744 "Check bogus newsgroups.
6745 If given a prefix, don't ask for confirmation before removing a bogus
6748 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6749 (gnus-group-list-groups))
6751 (defun gnus-group-edit-global-kill (&optional article group)
6752 "Edit the global kill file.
6753 If GROUP, edit that local kill file instead."
6755 (setq gnus-current-kill-article article)
6756 (gnus-kill-file-edit-file group)
6759 (substitute-command-keys
6760 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6761 (if group "local" "global")))))
6763 (defun gnus-group-edit-local-kill (article group)
6764 "Edit a local kill file."
6765 (interactive (list nil (gnus-group-group-name)))
6766 (gnus-group-edit-global-kill article group))
6768 (defun gnus-group-force-update ()
6769 "Update `.newsrc' file."
6771 (gnus-save-newsrc-file))
6773 (defun gnus-group-suspend ()
6774 "Suspend the current Gnus session.
6775 In fact, cleanup buffers except for group mode buffer.
6776 The hook gnus-suspend-gnus-hook is called before actually suspending."
6778 (run-hooks 'gnus-suspend-gnus-hook)
6779 ;; Kill Gnus buffers except for group mode buffer.
6780 (let* ((group-buf (get-buffer gnus-group-buffer))
6781 ;; Do this on a separate list in case the user does a ^G before we finish
6783 (delete group-buf (delete gnus-dribble-buffer
6784 (append gnus-buffer-list nil)))))
6785 (while gnus-buffer-list
6786 (gnus-kill-buffer (pop gnus-buffer-list)))
6787 (gnus-kill-gnus-frames)
6789 (setq gnus-buffer-list (list group-buf))
6790 (bury-buffer group-buf)
6791 (delete-windows-on group-buf t))))
6793 (defun gnus-group-clear-dribble ()
6794 "Clear all information from the dribble buffer."
6796 (gnus-dribble-clear)
6797 (gnus-message 7 "Cleared dribble buffer"))
6799 (defun gnus-group-exit ()
6800 "Quit reading news after updating .newsrc.eld and .newsrc.
6801 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6804 (or noninteractive ;For gnus-batch-kill
6805 (not gnus-interactive-exit) ;Without confirmation
6807 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6808 (run-hooks 'gnus-exit-gnus-hook)
6809 ;; Offer to save data from non-quitted summary buffers.
6810 (gnus-offer-save-summaries)
6811 ;; Save the newsrc file(s).
6812 (gnus-save-newsrc-file)
6814 (gnus-close-backends)
6815 ;; Reset everything.
6817 ;; Allow the user to do things after cleaning up.
6818 (run-hooks 'gnus-after-exiting-gnus-hook)))
6820 (defun gnus-close-backends ()
6821 ;; Send a close request to all backends that support such a request.
6822 (let ((methods gnus-valid-select-methods)
6825 (if (fboundp (setq func (intern (concat (caar methods)
6826 "-request-close"))))
6828 (setq methods (cdr methods)))))
6830 (defun gnus-group-quit ()
6831 "Quit reading news without updating .newsrc.eld or .newsrc.
6832 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6834 (when (or noninteractive ;For gnus-batch-kill
6835 (zerop (buffer-size))
6836 (not (gnus-server-opened gnus-select-method))
6838 (not gnus-current-startup-file)
6840 (format "Quit reading news without saving %s? "
6841 (file-name-nondirectory gnus-current-startup-file))))
6842 (run-hooks 'gnus-exit-gnus-hook)
6843 (if gnus-use-full-window
6844 (delete-other-windows)
6845 (gnus-remove-some-windows))
6847 (gnus-close-backends)
6849 ;; Allow the user to do things after cleaning up.
6850 (run-hooks 'gnus-after-exiting-gnus-hook)))
6852 (defun gnus-offer-save-summaries ()
6853 "Offer to save all active summary buffers."
6855 (let ((buflist (buffer-list))
6857 ;; Go through all buffers and find all summaries.
6859 (and (setq bufname (buffer-name (car buflist)))
6860 (string-match "Summary" bufname)
6862 (set-buffer bufname)
6863 ;; We check that this is, indeed, a summary buffer.
6864 (and (eq major-mode 'gnus-summary-mode)
6865 ;; Also make sure this isn't bogus.
6866 gnus-newsgroup-prepared))
6867 (push bufname buffers))
6868 (setq buflist (cdr buflist)))
6869 ;; Go through all these summary buffers and offer to save them.
6872 "Update summary buffer %s? "
6873 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6876 (defun gnus-group-describe-briefly ()
6877 "Give a one line description of the group mode commands."
6879 (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")))
6881 (defun gnus-group-browse-foreign-server (method)
6882 "Browse a foreign news server.
6883 If called interactively, this function will ask for a select method
6884 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6885 If not, METHOD should be a list where the first element is the method
6886 and the second element is the address."
6888 (list (let ((how (completing-read
6890 (append gnus-valid-select-methods gnus-server-alist)
6891 nil t (cons "nntp" 0) 'gnus-method-history)))
6892 ;; We either got a backend name or a virtual server name.
6893 ;; If the first, we also need an address.
6894 (if (assoc how gnus-valid-select-methods)
6896 ;; Suggested by mapjph@bath.ac.uk.
6899 (mapcar (lambda (server) (list server))
6900 gnus-secondary-servers)))
6901 ;; We got a server name, so we find the method.
6902 (gnus-server-to-method how)))))
6903 (gnus-browse-foreign-server method))
6907 ;;; Gnus summary mode
6910 (defvar gnus-summary-mode-map nil)
6912 (put 'gnus-summary-mode 'mode-class 'special)
6914 (unless gnus-summary-mode-map
6915 (setq gnus-summary-mode-map (make-keymap))
6916 (suppress-keymap gnus-summary-mode-map)
6918 ;; Non-orthogonal keys
6920 (gnus-define-keys gnus-summary-mode-map
6921 " " gnus-summary-next-page
6922 "\177" gnus-summary-prev-page
6923 [delete] gnus-summary-prev-page
6924 "\r" gnus-summary-scroll-up
6925 "n" gnus-summary-next-unread-article
6926 "p" gnus-summary-prev-unread-article
6927 "N" gnus-summary-next-article
6928 "P" gnus-summary-prev-article
6929 "\M-\C-n" gnus-summary-next-same-subject
6930 "\M-\C-p" gnus-summary-prev-same-subject
6931 "\M-n" gnus-summary-next-unread-subject
6932 "\M-p" gnus-summary-prev-unread-subject
6933 "." gnus-summary-first-unread-article
6934 "," gnus-summary-best-unread-article
6935 "\M-s" gnus-summary-search-article-forward
6936 "\M-r" gnus-summary-search-article-backward
6937 "<" gnus-summary-beginning-of-article
6938 ">" gnus-summary-end-of-article
6939 "j" gnus-summary-goto-article
6940 "^" gnus-summary-refer-parent-article
6941 "\M-^" gnus-summary-refer-article
6942 "u" gnus-summary-tick-article-forward
6943 "!" gnus-summary-tick-article-forward
6944 "U" gnus-summary-tick-article-backward
6945 "d" gnus-summary-mark-as-read-forward
6946 "D" gnus-summary-mark-as-read-backward
6947 "E" gnus-summary-mark-as-expirable
6948 "\M-u" gnus-summary-clear-mark-forward
6949 "\M-U" gnus-summary-clear-mark-backward
6950 "k" gnus-summary-kill-same-subject-and-select
6951 "\C-k" gnus-summary-kill-same-subject
6952 "\M-\C-k" gnus-summary-kill-thread
6953 "\M-\C-l" gnus-summary-lower-thread
6954 "e" gnus-summary-edit-article
6955 "#" gnus-summary-mark-as-processable
6956 "\M-#" gnus-summary-unmark-as-processable
6957 "\M-\C-t" gnus-summary-toggle-threads
6958 "\M-\C-s" gnus-summary-show-thread
6959 "\M-\C-h" gnus-summary-hide-thread
6960 "\M-\C-f" gnus-summary-next-thread
6961 "\M-\C-b" gnus-summary-prev-thread
6962 "\M-\C-u" gnus-summary-up-thread
6963 "\M-\C-d" gnus-summary-down-thread
6964 "&" gnus-summary-execute-command
6965 "c" gnus-summary-catchup-and-exit
6966 "\C-w" gnus-summary-mark-region-as-read
6967 "\C-t" gnus-summary-toggle-truncation
6968 "?" gnus-summary-mark-as-dormant
6969 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6970 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6971 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6972 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6973 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6974 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6975 "=" gnus-summary-expand-window
6976 "\C-x\C-s" gnus-summary-reselect-current-group
6977 "\M-g" gnus-summary-rescan-group
6978 "w" gnus-summary-stop-page-breaking
6979 "\C-c\C-r" gnus-summary-caesar-message
6980 "\M-t" gnus-summary-toggle-mime
6981 "f" gnus-summary-followup
6982 "F" gnus-summary-followup-with-original
6983 "C" gnus-summary-cancel-article
6984 "r" gnus-summary-reply
6985 "R" gnus-summary-reply-with-original
6986 "\C-c\C-f" gnus-summary-mail-forward
6987 "o" gnus-summary-save-article
6988 "\C-o" gnus-summary-save-article-mail
6989 "|" gnus-summary-pipe-output
6990 "\M-k" gnus-summary-edit-local-kill
6991 "\M-K" gnus-summary-edit-global-kill
6993 "\C-c\C-d" gnus-summary-describe-group
6994 "q" gnus-summary-exit
6995 "Q" gnus-summary-exit-no-update
6996 "\C-c\C-i" gnus-info-find-node
6997 gnus-mouse-2 gnus-mouse-pick-article
6998 "m" gnus-summary-mail-other-window
6999 "a" gnus-summary-post-news
7000 "x" gnus-summary-limit-to-unread
7001 "s" gnus-summary-isearch-article
7002 "t" gnus-article-hide-headers
7003 "g" gnus-summary-show-article
7004 "l" gnus-summary-goto-last-article
7005 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
7006 "\C-d" gnus-summary-enter-digest-group
7008 "*" gnus-cache-enter-article
7009 "\M-*" gnus-cache-remove-article
7010 "\M-&" gnus-summary-universal-argument
7011 "\C-l" gnus-recenter
7012 "I" gnus-summary-increase-score
7013 "L" gnus-summary-lower-score
7015 "V" gnus-summary-score-map
7016 "X" gnus-uu-extract-map
7017 "S" gnus-summary-send-map)
7019 ;; Sort of orthogonal keymap
7020 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
7021 "t" gnus-summary-tick-article-forward
7022 "!" gnus-summary-tick-article-forward
7023 "d" gnus-summary-mark-as-read-forward
7024 "r" gnus-summary-mark-as-read-forward
7025 "c" gnus-summary-clear-mark-forward
7026 " " gnus-summary-clear-mark-forward
7027 "e" gnus-summary-mark-as-expirable
7028 "x" gnus-summary-mark-as-expirable
7029 "?" gnus-summary-mark-as-dormant
7030 "b" gnus-summary-set-bookmark
7031 "B" gnus-summary-remove-bookmark
7032 "#" gnus-summary-mark-as-processable
7033 "\M-#" gnus-summary-unmark-as-processable
7034 "S" gnus-summary-limit-include-expunged
7035 "C" gnus-summary-catchup
7036 "H" gnus-summary-catchup-to-here
7037 "\C-c" gnus-summary-catchup-all
7038 "k" gnus-summary-kill-same-subject-and-select
7039 "K" gnus-summary-kill-same-subject
7040 "P" gnus-uu-mark-map)
7042 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7043 "c" gnus-summary-clear-above
7044 "u" gnus-summary-tick-above
7045 "m" gnus-summary-mark-above
7046 "k" gnus-summary-kill-below)
7048 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7049 "/" gnus-summary-limit-to-subject
7050 "n" gnus-summary-limit-to-articles
7051 "w" gnus-summary-pop-limit
7052 "s" gnus-summary-limit-to-subject
7053 "a" gnus-summary-limit-to-author
7054 "u" gnus-summary-limit-to-unread
7055 "m" gnus-summary-limit-to-marks
7056 "v" gnus-summary-limit-to-score
7057 "D" gnus-summary-limit-include-dormant
7058 "d" gnus-summary-limit-exclude-dormant
7059 ;; "t" gnus-summary-limit-exclude-thread
7060 "E" gnus-summary-limit-include-expunged
7061 "c" gnus-summary-limit-exclude-childless-dormant
7062 "C" gnus-summary-limit-mark-excluded-as-read)
7064 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7065 "n" gnus-summary-next-unread-article
7066 "p" gnus-summary-prev-unread-article
7067 "N" gnus-summary-next-article
7068 "P" gnus-summary-prev-article
7069 "\C-n" gnus-summary-next-same-subject
7070 "\C-p" gnus-summary-prev-same-subject
7071 "\M-n" gnus-summary-next-unread-subject
7072 "\M-p" gnus-summary-prev-unread-subject
7073 "f" gnus-summary-first-unread-article
7074 "b" gnus-summary-best-unread-article
7075 "j" gnus-summary-goto-article
7076 "g" gnus-summary-goto-subject
7077 "l" gnus-summary-goto-last-article
7078 "p" gnus-summary-pop-article)
7080 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7081 "k" gnus-summary-kill-thread
7082 "l" gnus-summary-lower-thread
7083 "i" gnus-summary-raise-thread
7084 "T" gnus-summary-toggle-threads
7085 "t" gnus-summary-rethread-current
7086 "^" gnus-summary-reparent-thread
7087 "s" gnus-summary-show-thread
7088 "S" gnus-summary-show-all-threads
7089 "h" gnus-summary-hide-thread
7090 "H" gnus-summary-hide-all-threads
7091 "n" gnus-summary-next-thread
7092 "p" gnus-summary-prev-thread
7093 "u" gnus-summary-up-thread
7094 "o" gnus-summary-top-thread
7095 "d" gnus-summary-down-thread
7096 "#" gnus-uu-mark-thread
7097 "\M-#" gnus-uu-unmark-thread)
7099 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7100 "c" gnus-summary-catchup-and-exit
7101 "C" gnus-summary-catchup-all-and-exit
7102 "E" gnus-summary-exit-no-update
7103 "Q" gnus-summary-exit
7104 "Z" gnus-summary-exit
7105 "n" gnus-summary-catchup-and-goto-next-group
7106 "R" gnus-summary-reselect-current-group
7107 "G" gnus-summary-rescan-group
7108 "N" gnus-summary-next-group
7109 "P" gnus-summary-prev-group)
7111 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7112 " " gnus-summary-next-page
7113 "n" gnus-summary-next-page
7114 "\177" gnus-summary-prev-page
7115 [delete] gnus-summary-prev-page
7116 "p" gnus-summary-prev-page
7117 "\r" gnus-summary-scroll-up
7118 "<" gnus-summary-beginning-of-article
7119 ">" gnus-summary-end-of-article
7120 "b" gnus-summary-beginning-of-article
7121 "e" gnus-summary-end-of-article
7122 "^" gnus-summary-refer-parent-article
7123 "r" gnus-summary-refer-parent-article
7124 "R" gnus-summary-refer-references
7125 "g" gnus-summary-show-article
7126 "s" gnus-summary-isearch-article)
7128 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7129 "b" gnus-article-add-buttons
7130 "B" gnus-article-add-buttons-to-head
7131 "o" gnus-article-treat-overstrike
7132 ;; "w" gnus-article-word-wrap
7133 "w" gnus-article-fill-cited-article
7134 "c" gnus-article-remove-cr
7135 "L" gnus-article-remove-trailing-blank-lines
7136 "q" gnus-article-de-quoted-unreadable
7137 "f" gnus-article-display-x-face
7138 "l" gnus-summary-stop-page-breaking
7139 "r" gnus-summary-caesar-message
7140 "t" gnus-article-hide-headers
7141 "v" gnus-summary-verbose-headers
7142 "m" gnus-summary-toggle-mime)
7144 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7145 "a" gnus-article-hide
7146 "h" gnus-article-hide-headers
7147 "b" gnus-article-hide-boring-headers
7148 "s" gnus-article-hide-signature
7149 "c" gnus-article-hide-citation
7150 "p" gnus-article-hide-pgp
7151 "\C-c" gnus-article-hide-citation-maybe)
7153 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7154 "a" gnus-article-highlight
7155 "h" gnus-article-highlight-headers
7156 "c" gnus-article-highlight-citation
7157 "s" gnus-article-highlight-signature)
7159 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7160 "z" gnus-article-date-ut
7161 "u" gnus-article-date-ut
7162 "l" gnus-article-date-local
7163 "e" gnus-article-date-lapsed
7164 "o" gnus-article-date-original)
7166 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7168 "f" gnus-summary-fetch-faq
7169 "d" gnus-summary-describe-group
7170 "h" gnus-summary-describe-briefly
7171 "i" gnus-info-find-node)
7173 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7174 "e" gnus-summary-expire-articles
7175 "\M-\C-e" gnus-summary-expire-articles-now
7176 "\177" gnus-summary-delete-article
7177 [delete] gnus-summary-delete-article
7178 "m" gnus-summary-move-article
7179 "r" gnus-summary-respool-article
7180 "w" gnus-summary-edit-article
7181 "c" gnus-summary-copy-article
7182 "B" gnus-summary-crosspost-article
7183 "q" gnus-summary-respool-query
7184 "i" gnus-summary-import-article)
7186 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7187 "o" gnus-summary-save-article
7188 "m" gnus-summary-save-article-mail
7189 "r" gnus-summary-save-article-rmail
7190 "f" gnus-summary-save-article-file
7191 "b" gnus-summary-save-article-body-file
7192 "h" gnus-summary-save-article-folder
7193 "v" gnus-summary-save-article-vm
7194 "p" gnus-summary-pipe-output
7195 "s" gnus-soup-add-article)
7200 (defun gnus-summary-mode (&optional group)
7201 "Major mode for reading articles.
7203 All normal editing commands are switched off.
7204 \\<gnus-summary-mode-map>
7205 Each line in this buffer represents one article. To read an
7206 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7207 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7210 You can also post articles and send mail from this buffer. To
7211 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7212 of an article, type `\\[gnus-summary-reply]'.
7214 There are approx. one gazillion commands you can execute in this
7215 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7217 The following commands are available:
7219 \\{gnus-summary-mode-map}"
7221 (when (and menu-bar-mode
7222 (gnus-visual-p 'summary-menu 'menu))
7223 (gnus-summary-make-menu-bar))
7224 (kill-all-local-variables)
7225 (gnus-summary-make-local-variables)
7226 (gnus-make-thread-indent-array)
7227 (gnus-simplify-mode-line)
7228 (setq major-mode 'gnus-summary-mode)
7229 (setq mode-name "Summary")
7230 (make-local-variable 'minor-mode-alist)
7231 (use-local-map gnus-summary-mode-map)
7232 (buffer-disable-undo (current-buffer))
7233 (setq buffer-read-only t) ;Disable modification
7234 (setq truncate-lines t)
7235 (setq selective-display t)
7236 (setq selective-display-ellipses t) ;Display `...'
7237 (setq buffer-display-table gnus-summary-display-table)
7238 (setq gnus-newsgroup-name group)
7239 (make-local-variable 'gnus-summary-line-format)
7240 (make-local-variable 'gnus-summary-line-format-spec)
7241 (make-local-variable 'gnus-summary-mark-positions)
7242 (gnus-make-local-hook 'post-command-hook)
7243 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
7244 (run-hooks 'gnus-summary-mode-hook))
7246 (defun gnus-summary-make-local-variables ()
7247 "Make all the local summary buffer variables."
7248 (let ((locals gnus-summary-local-variables)
7250 (while (setq local (pop locals))
7253 (if (eq (cdr local) 'global)
7254 ;; Copy the global value of the variable.
7255 (setq global (symbol-value (car local)))
7256 ;; Use the value from the list.
7257 (setq global (eval (cdr local))))
7258 (make-local-variable (car local))
7259 (set (car local) global))
7260 ;; Simple nil-valued local variable.
7261 (make-local-variable local)
7264 (defun gnus-summary-make-display-table ()
7265 ;; Change the display table. Odd characters have a tendency to mess
7266 ;; up nicely formatted displays - we make all possible glyphs
7267 ;; display only a single character.
7269 ;; We start from the standard display table, if any.
7270 (setq gnus-summary-display-table
7271 (or (copy-sequence standard-display-table)
7272 (make-display-table)))
7273 ;; Nix out all the control chars...
7275 (while (>= (setq i (1- i)) 0)
7276 (aset gnus-summary-display-table i [??])))
7277 ;; ... but not newline and cr, of course. (cr is necessary for the
7278 ;; selective display).
7279 (aset gnus-summary-display-table ?\n nil)
7280 (aset gnus-summary-display-table ?\r nil)
7281 ;; We nix out any glyphs over 126 that are not set already.
7283 (while (>= (setq i (1- i)) 127)
7284 ;; Only modify if the entry is nil.
7285 (or (aref gnus-summary-display-table i)
7286 (aset gnus-summary-display-table i [??])))))
7288 (defun gnus-summary-clear-local-variables ()
7289 (let ((locals gnus-summary-local-variables))
7291 (if (consp (car locals))
7292 (and (vectorp (caar locals))
7293 (set (caar locals) nil))
7294 (and (vectorp (car locals))
7295 (set (car locals) nil)))
7296 (setq locals (cdr locals)))))
7298 ;; Summary data functions.
7300 (defmacro gnus-data-number (data)
7303 (defmacro gnus-data-set-number (data number)
7304 `(setcar ,data ,number))
7306 (defmacro gnus-data-mark (data)
7309 (defmacro gnus-data-set-mark (data mark)
7310 `(setcar (nthcdr 1 ,data) ,mark))
7312 (defmacro gnus-data-pos (data)
7315 (defmacro gnus-data-set-pos (data pos)
7316 `(setcar (nthcdr 2 ,data) ,pos))
7318 (defmacro gnus-data-header (data)
7321 (defmacro gnus-data-level (data)
7324 (defmacro gnus-data-unread-p (data)
7325 `(= (nth 1 ,data) gnus-unread-mark))
7327 (defmacro gnus-data-pseudo-p (data)
7328 `(consp (nth 3 ,data)))
7330 (defmacro gnus-data-find (number)
7331 `(assq ,number gnus-newsgroup-data))
7333 (defmacro gnus-data-find-list (number &optional data)
7334 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7335 (memq (assq ,number bdata)
7338 (defmacro gnus-data-make (number mark pos header level)
7339 `(list ,number ,mark ,pos ,header ,level))
7341 (defun gnus-data-enter (after-article number mark pos header level offset)
7342 (let ((data (gnus-data-find-list after-article)))
7343 (or data (error "No such article: %d" after-article))
7344 (setcdr data (cons (gnus-data-make number mark pos header level)
7346 (setq gnus-newsgroup-data-reverse nil)
7347 (gnus-data-update-list (cddr data) offset)))
7349 (defun gnus-data-enter-list (after-article list &optional offset)
7351 (let ((data (and after-article (gnus-data-find-list after-article)))
7353 (or data (not after-article) (error "No such article: %d" after-article))
7354 ;; Find the last element in the list to be spliced into the main
7357 (setq list (cdr list)))
7360 (setcdr list gnus-newsgroup-data)
7361 (setq gnus-newsgroup-data ilist)
7362 (and offset (gnus-data-update-list (cdr list) offset)))
7363 (setcdr list (cdr data))
7365 (and offset (gnus-data-update-list (cdr data) offset)))
7366 (setq gnus-newsgroup-data-reverse nil))))
7368 (defun gnus-data-remove (article &optional offset)
7369 (let ((data gnus-newsgroup-data))
7370 (if (= (gnus-data-number (car data)) article)
7371 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7372 gnus-newsgroup-data-reverse nil)
7374 (and (= (gnus-data-number (cadr data)) article)
7376 (setcdr data (cddr data))
7377 (and offset (gnus-data-update-list (cdr data) offset))
7379 gnus-newsgroup-data-reverse nil)))
7380 (setq data (cdr data))))))
7382 (defmacro gnus-data-list (backward)
7384 (or gnus-newsgroup-data-reverse
7385 (setq gnus-newsgroup-data-reverse
7386 (reverse gnus-newsgroup-data)))
7387 gnus-newsgroup-data))
7389 (defun gnus-data-update-list (data offset)
7390 "Add OFFSET to the POS of all data entries in DATA."
7392 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7393 (setq data (cdr data))))
7395 (defun gnus-data-compute-positions ()
7396 "Compute the positions of all articles."
7397 (let ((data gnus-newsgroup-data)
7400 (when (setq pos (text-property-any
7401 (point-min) (point-max)
7402 'gnus-number (gnus-data-number (car data))))
7403 (gnus-data-set-pos (car data) (+ pos 3)))
7404 (setq data (cdr data)))))
7406 (defun gnus-summary-article-pseudo-p (article)
7407 "Say whether this article is a pseudo article or not."
7408 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7410 (defun gnus-article-parent-p (number)
7411 "Say whether this article is a parent or not."
7412 (let ((data (gnus-data-find-list number)))
7413 (and (cdr data) ; There has to be an article after...
7414 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7415 (gnus-data-level (nth 1 data))))))
7417 (defun gnus-article-children (number)
7418 "Return a list of all children to NUMBER."
7419 (let* ((data (gnus-data-find-list number))
7420 (level (gnus-data-level (car data)))
7422 (setq data (cdr data))
7424 (= (gnus-data-level (car data)) (1+ level)))
7425 (push (gnus-data-number (car data)) children)
7426 (setq data (cdr data)))
7429 (defmacro gnus-summary-skip-intangible ()
7430 "If the current article is intangible, then jump to a different article."
7431 '(let ((to (get-text-property (point) 'gnus-intangible)))
7432 (and to (gnus-summary-goto-subject to))))
7434 (defmacro gnus-summary-article-intangible-p ()
7435 "Say whether this article is intangible or not."
7436 '(get-text-property (point) 'gnus-intangible))
7438 ;; Some summary mode macros.
7440 (defmacro gnus-summary-article-number ()
7441 "The article number of the article on the current line.
7442 If there isn's an article number here, then we return the current
7445 (gnus-summary-skip-intangible)
7446 (or (get-text-property (point) 'gnus-number)
7447 (gnus-summary-last-subject))))
7449 (defmacro gnus-summary-article-header (&optional number)
7450 `(gnus-data-header (gnus-data-find
7451 ,(or number '(gnus-summary-article-number)))))
7453 (defmacro gnus-summary-thread-level (&optional number)
7454 `(if (and (eq gnus-summary-make-false-root 'dummy)
7455 (get-text-property (point) 'gnus-intangible))
7457 (gnus-data-level (gnus-data-find
7458 ,(or number '(gnus-summary-article-number))))))
7460 (defmacro gnus-summary-article-mark (&optional number)
7461 `(gnus-data-mark (gnus-data-find
7462 ,(or number '(gnus-summary-article-number)))))
7464 (defmacro gnus-summary-article-pos (&optional number)
7465 `(gnus-data-pos (gnus-data-find
7466 ,(or number '(gnus-summary-article-number)))))
7468 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7469 (defmacro gnus-summary-article-subject (&optional number)
7470 "Return current subject string or nil if nothing."
7473 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7474 '(gnus-data-header (assq (gnus-summary-article-number)
7475 gnus-newsgroup-data)))))
7478 (mail-header-subject headers))))
7480 (defmacro gnus-summary-article-score (&optional number)
7481 "Return current article score."
7482 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7483 gnus-newsgroup-scored))
7484 gnus-summary-default-score 0))
7486 (defun gnus-summary-article-children (&optional number)
7487 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7488 (level (gnus-data-level (car data)))
7490 (while (and (setq data (cdr data))
7491 (> (setq l (gnus-data-level (car data))) level))
7492 (and (= (1+ level) l)
7493 (setq children (cons (gnus-data-number (car data))
7495 (nreverse children)))
7497 (defun gnus-summary-article-parent (&optional number)
7498 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7499 (gnus-data-list t)))
7500 (level (gnus-data-level (car data))))
7502 () ; This is a root.
7503 ;; We search until we find an article with a level less than
7504 ;; this one. That function has to be the parent.
7505 (while (and (setq data (cdr data))
7506 (not (< (gnus-data-level (car data)) level))))
7507 (and data (gnus-data-number (car data))))))
7509 (defun gnus-unread-mark-p (mark)
7510 "Say whether MARK is the unread mark."
7511 (= mark gnus-unread-mark))
7513 (defun gnus-read-mark-p (mark)
7514 "Say whether MARK is one of the marks that mark as read.
7515 This is all marks except unread, ticked, dormant, and expirable."
7516 (not (or (= mark gnus-unread-mark)
7517 (= mark gnus-ticked-mark)
7518 (= mark gnus-dormant-mark)
7519 (= mark gnus-expirable-mark))))
7521 ;; Saving hidden threads.
7523 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7524 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7525 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7527 (defmacro gnus-save-hidden-threads (&rest forms)
7528 "Save hidden threads, eval FORMS, and restore the hidden threads."
7529 (let ((config (make-symbol "config")))
7530 `(let ((,config (gnus-hidden-threads-configuration)))
7534 (gnus-restore-hidden-threads-configuration ,config)))))
7536 (defun gnus-hidden-threads-configuration ()
7537 "Return the current hidden threads configuration."
7540 (goto-char (point-min))
7541 (while (search-forward "\r" nil t)
7542 (push (1- (point)) config))
7545 (defun gnus-restore-hidden-threads-configuration (config)
7546 "Restore hidden threads configuration from CONFIG."
7547 (let (point buffer-read-only)
7548 (while (setq point (pop config))
7549 (when (and (< point (point-max))
7551 (= (following-char) ?\n))
7552 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7554 ;; Various summary mode internalish functions.
7556 (defun gnus-mouse-pick-article (e)
7559 (gnus-summary-next-page nil t))
7561 (defun gnus-summary-setup-buffer (group)
7562 "Initialize summary buffer."
7563 (let ((buffer (concat "*Summary " group "*")))
7564 (if (get-buffer buffer)
7567 (setq gnus-summary-buffer (current-buffer))
7568 (not gnus-newsgroup-prepared))
7569 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7570 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7571 (gnus-add-current-to-buffer-list)
7572 (gnus-summary-mode group)
7574 (gnus-carpal-setup-buffer 'summary))
7575 (unless gnus-single-article-buffer
7576 (make-local-variable 'gnus-article-buffer)
7577 (make-local-variable 'gnus-article-current)
7578 (make-local-variable 'gnus-original-article-buffer))
7579 (setq gnus-newsgroup-name group)
7582 (defun gnus-set-global-variables ()
7583 ;; Set the global equivalents of the summary buffer-local variables
7584 ;; to the latest values they had. These reflect the summary buffer
7585 ;; that was in action when the last article was fetched.
7586 (when (eq major-mode 'gnus-summary-mode)
7587 (setq gnus-summary-buffer (current-buffer))
7588 (let ((name gnus-newsgroup-name)
7589 (marked gnus-newsgroup-marked)
7590 (unread gnus-newsgroup-unreads)
7591 (headers gnus-current-headers)
7592 (data gnus-newsgroup-data)
7593 (summary gnus-summary-buffer)
7594 (article-buffer gnus-article-buffer)
7595 (original gnus-original-article-buffer)
7596 (gac gnus-article-current)
7597 (score-file gnus-current-score-file))
7599 (set-buffer gnus-group-buffer)
7600 (setq gnus-newsgroup-name name)
7601 (setq gnus-newsgroup-marked marked)
7602 (setq gnus-newsgroup-unreads unread)
7603 (setq gnus-current-headers headers)
7604 (setq gnus-newsgroup-data data)
7605 (setq gnus-article-current gac)
7606 (setq gnus-summary-buffer summary)
7607 (setq gnus-article-buffer article-buffer)
7608 (setq gnus-original-article-buffer original)
7609 (setq gnus-current-score-file score-file)))))
7611 (defun gnus-summary-last-article-p (&optional article)
7612 "Return whether ARTICLE is the last article in the buffer."
7613 (if (not (setq article (or article (gnus-summary-article-number))))
7614 t ; All non-existant numbers are the last article. :-)
7615 (not (cdr (gnus-data-find-list article)))))
7617 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7618 "Insert a dummy root in the summary buffer."
7620 (gnus-add-text-properties
7621 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7622 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7624 (defun gnus-make-thread-indent-array ()
7626 (unless (and gnus-thread-indent-array
7627 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7628 (setq gnus-thread-indent-array (make-vector 201 "")
7629 gnus-thread-indent-array-level gnus-thread-indent-level)
7631 (aset gnus-thread-indent-array n
7632 (make-string (* n gnus-thread-indent-level) ? ))
7635 (defun gnus-summary-insert-line
7636 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7637 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7638 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7639 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7640 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7641 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7642 (gnus-tmp-score-char
7643 (if (or (null gnus-summary-default-score)
7644 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7645 gnus-summary-zcore-fuzz)) ?
7646 (if (< gnus-tmp-score gnus-summary-default-score)
7647 gnus-score-below-mark gnus-score-over-mark)))
7648 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7649 ((memq gnus-tmp-current gnus-newsgroup-cached)
7651 (gnus-tmp-replied gnus-replied-mark)
7652 ((memq gnus-tmp-current gnus-newsgroup-saved)
7654 (t gnus-unread-mark)))
7655 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7658 ((string-match "(.+)" gnus-tmp-from)
7659 (substring gnus-tmp-from
7660 (1+ (match-beginning 0)) (1- (match-end 0))))
7661 ((string-match "<[^>]+> *$" gnus-tmp-from)
7662 (let ((beg (match-beginning 0)))
7663 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7664 (substring gnus-tmp-from (1+ (match-beginning 0))
7665 (1- (match-end 0))))
7666 (substring gnus-tmp-from 0 beg))))
7668 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7669 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7670 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7671 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7672 (buffer-read-only nil))
7673 (when (string= gnus-tmp-name "")
7674 (setq gnus-tmp-name gnus-tmp-from))
7675 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7676 (gnus-put-text-property
7678 (progn (eval gnus-summary-line-format-spec) (point))
7679 'gnus-number gnus-tmp-number)
7680 (when (gnus-visual-p 'summary-highlight 'highlight)
7682 (run-hooks 'gnus-summary-update-hook)
7685 (defun gnus-summary-update-line (&optional dont-update)
7686 ;; Update summary line after change.
7687 (when (and gnus-summary-default-score
7688 (not gnus-summary-inhibit-highlight))
7689 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7690 (article (gnus-summary-article-number))
7691 (score (gnus-summary-article-score article)))
7693 (if (and gnus-summary-mark-below
7694 (< (gnus-summary-article-score)
7695 gnus-summary-mark-below))
7696 ;; This article has a low score, so we mark it as read.
7697 (when (memq article gnus-newsgroup-unreads)
7698 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7699 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7700 ;; This article was previously marked as read on account
7701 ;; of a low score, but now it has risen, so we mark it as
7703 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7704 (gnus-summary-update-mark
7705 (if (or (null gnus-summary-default-score)
7706 (<= (abs (- score gnus-summary-default-score))
7707 gnus-summary-zcore-fuzz)) ?
7708 (if (< score gnus-summary-default-score)
7709 gnus-score-below-mark gnus-score-over-mark)) 'score))
7710 ;; Do visual highlighting.
7711 (when (gnus-visual-p 'summary-highlight 'highlight)
7712 (run-hooks 'gnus-summary-update-hook)))))
7714 (defvar gnus-tmp-new-adopts nil)
7716 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7717 ;; Sum up all elements (and sub-elements) in a list.
7719 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7721 ((and (consp thread) (cdr thread))
7724 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7727 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7730 (when (and level (zerop level) gnus-tmp-new-adopts)
7733 'gnus-summary-number-of-articles-in-thread
7734 gnus-tmp-new-adopts))))
7736 (if (> number 1) gnus-not-empty-thread-mark
7737 gnus-empty-thread-mark)
7740 (defun gnus-summary-set-local-parameters (group)
7741 "Go through the local params of GROUP and set all variable specs in that list."
7742 (let ((params (gnus-info-params (gnus-get-info group)))
7745 (setq elem (car params)
7746 params (cdr params))
7747 (and (consp elem) ; Has to be a cons.
7748 (consp (cdr elem)) ; The cdr has to be a list.
7749 (symbolp (car elem)) ; Has to be a symbol in there.
7750 (not (memq (car elem)
7751 '(quit-config to-address to-list to-group)))
7752 (progn ; So we set it.
7753 (make-local-variable (car elem))
7754 (set (car elem) (eval (nth 1 elem))))))))
7756 (defun gnus-summary-read-group (group &optional show-all no-article
7757 kill-buffer no-display)
7758 "Start reading news in newsgroup GROUP.
7759 If SHOW-ALL is non-nil, already read articles are also listed.
7760 If NO-ARTICLE is non-nil, no article is selected initially.
7761 If NO-DISPLAY, don't generate a summary buffer."
7762 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7763 (let* ((new-group (gnus-summary-setup-buffer group))
7764 (quit-config (gnus-group-quit-config group))
7765 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7767 ;; This summary buffer exists already, so we just select it.
7769 (gnus-set-global-variables)
7771 (gnus-kill-or-deaden-summary kill-buffer))
7772 (gnus-configure-windows 'summary 'force)
7773 (gnus-set-mode-line 'summary)
7774 (gnus-summary-position-point)
7777 ;; We couldn't select this group.
7779 (when (and (eq major-mode 'gnus-summary-mode)
7780 (not (equal (current-buffer) kill-buffer)))
7781 (kill-buffer (current-buffer))
7782 (if (not quit-config)
7784 (set-buffer gnus-group-buffer)
7785 (gnus-group-jump-to-group group)
7786 (gnus-group-next-unread-group 1))
7787 (if (not (buffer-name (car quit-config)))
7788 (gnus-configure-windows 'group 'force)
7789 (set-buffer (car quit-config))
7790 (and (eq major-mode 'gnus-summary-mode)
7791 (gnus-set-global-variables))
7792 (gnus-configure-windows (cdr quit-config)))))
7793 (gnus-message 3 "Can't select group")
7795 ;; The user did a `C-g' while prompting for number of articles,
7796 ;; so we exit this group.
7797 ((eq did-select 'quit)
7798 (and (eq major-mode 'gnus-summary-mode)
7799 (not (equal (current-buffer) kill-buffer))
7800 (kill-buffer (current-buffer)))
7802 (gnus-kill-or-deaden-summary kill-buffer))
7803 (if (not quit-config)
7805 (set-buffer gnus-group-buffer)
7806 (gnus-group-jump-to-group group)
7807 (gnus-group-next-unread-group 1)
7808 (gnus-configure-windows 'group 'force))
7809 (if (not (buffer-name (car quit-config)))
7810 (gnus-configure-windows 'group 'force)
7811 (set-buffer (car quit-config))
7812 (and (eq major-mode 'gnus-summary-mode)
7813 (gnus-set-global-variables))
7814 (gnus-configure-windows (cdr quit-config))))
7815 ;; Finally signal the quit.
7817 ;; The group was successfully selected.
7819 (gnus-set-global-variables)
7820 ;; Save the active value in effect when the group was entered.
7821 (setq gnus-newsgroup-active
7823 (gnus-active gnus-newsgroup-name)))
7824 ;; You can change the summary buffer in some way with this hook.
7825 (run-hooks 'gnus-select-group-hook)
7826 ;; Set any local variables in the group parameters.
7827 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7828 (gnus-update-format-specifications)
7829 ;; Do score processing.
7830 (when gnus-use-scoring
7831 (gnus-possibly-score-headers))
7832 ;; Check whether to fill in the gaps in the threads.
7833 (when gnus-build-sparse-threads
7834 (gnus-build-sparse-threads))
7835 ;; Find the initial limit.
7836 (if gnus-show-threads
7838 (let ((gnus-newsgroup-dormant nil))
7839 (gnus-summary-initial-limit show-all))
7840 (gnus-summary-initial-limit show-all))
7841 (setq gnus-newsgroup-limit
7843 (lambda (header) (mail-header-number header))
7844 gnus-newsgroup-headers)))
7845 ;; Generate the summary buffer.
7847 (gnus-summary-prepare))
7848 (when gnus-use-trees
7849 (gnus-tree-open group)
7850 (setq gnus-summary-highlight-line-function
7851 'gnus-tree-highlight-article))
7852 ;; If the summary buffer is empty, but there are some low-scored
7853 ;; articles or some excluded dormants, we include these in the
7855 (when (and (zerop (buffer-size))
7857 (cond (gnus-newsgroup-dormant
7858 (gnus-summary-limit-include-dormant))
7859 ((and gnus-newsgroup-scored show-all)
7860 (gnus-summary-limit-include-expunged))))
7861 ;; Function `gnus-apply-kill-file' must be called in this hook.
7862 (run-hooks 'gnus-apply-kill-hook)
7863 (if (and (zerop (buffer-size))
7866 ;; This newsgroup is empty.
7867 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7868 (gnus-message 6 "No unread news")
7870 (gnus-kill-or-deaden-summary kill-buffer))
7871 ;; Return nil from this function.
7873 ;; Hide conversation thread subtrees. We cannot do this in
7874 ;; gnus-summary-prepare-hook since kill processing may not
7875 ;; work with hidden articles.
7876 (and gnus-show-threads
7877 gnus-thread-hide-subtree
7878 (gnus-summary-hide-all-threads))
7879 ;; Show first unread article if requested.
7880 (if (and (not no-article)
7882 gnus-newsgroup-unreads
7883 gnus-auto-select-first)
7884 (unless (if (eq gnus-auto-select-first 'best)
7885 (gnus-summary-best-unread-article)
7886 (gnus-summary-first-unread-article))
7887 (gnus-configure-windows 'summary))
7888 ;; Don't select any articles, just move point to the first
7889 ;; article in the group.
7890 (goto-char (point-min))
7891 (gnus-summary-position-point)
7892 (gnus-set-mode-line 'summary)
7893 (gnus-configure-windows 'summary 'force))
7894 ;; If we are in async mode, we send some info to the backend.
7895 (when gnus-newsgroup-async
7896 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7898 (gnus-kill-or-deaden-summary kill-buffer))
7899 (when (get-buffer-window gnus-group-buffer t)
7900 ;; Gotta use windows, because recenter does wierd stuff if
7901 ;; the current buffer ain't the displayed window.
7902 (let ((owin (selected-window)))
7903 (select-window (get-buffer-window gnus-group-buffer t))
7904 (when (gnus-group-goto-group group)
7906 (select-window owin))))
7907 ;; Mark this buffer as "prepared".
7908 (setq gnus-newsgroup-prepared t)
7911 (defun gnus-summary-prepare ()
7912 "Generate the summary buffer."
7913 (let ((buffer-read-only nil))
7915 (setq gnus-newsgroup-data nil
7916 gnus-newsgroup-data-reverse nil)
7917 (run-hooks 'gnus-summary-generate-hook)
7918 ;; Generate the buffer, either with threads or without.
7919 (when gnus-newsgroup-headers
7920 (gnus-summary-prepare-threads
7921 (if gnus-show-threads
7922 (gnus-sort-gathered-threads
7923 (funcall gnus-summary-thread-gathering-function
7925 (gnus-cut-threads (gnus-make-threads)))))
7926 ;; Unthreaded display.
7927 (gnus-sort-articles gnus-newsgroup-headers))))
7928 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7929 ;; Call hooks for modifying summary buffer.
7930 (goto-char (point-min))
7931 (run-hooks 'gnus-summary-prepare-hook)))
7933 (defun gnus-gather-threads-by-subject (threads)
7934 "Gather threads by looking at Subject headers."
7935 (if (not gnus-summary-make-false-root)
7937 (let ((hashtb (gnus-make-hashtable 1023))
7940 subject hthread whole-subject)
7942 (setq whole-subject (mail-header-subject (caar threads)))
7945 ;; Truncate the subject.
7946 ((numberp gnus-summary-gather-subject-limit)
7947 (setq subject (gnus-simplify-subject-re whole-subject))
7948 (if (> (length subject) gnus-summary-gather-subject-limit)
7949 (substring subject 0 gnus-summary-gather-subject-limit)
7951 ;; Fuzzily simplify it.
7952 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7953 (gnus-simplify-subject-fuzzy whole-subject))
7954 ;; Just remove the leading "Re:".
7956 (gnus-simplify-subject-re whole-subject))))
7958 (if (and gnus-summary-gather-exclude-subject
7959 (string-match gnus-summary-gather-exclude-subject
7961 () ; We don't want to do anything with this article.
7962 ;; We simplify the subject before looking it up in the
7965 (if (setq hthread (gnus-gethash subject hashtb))
7967 ;; We enter a dummy root into the thread, if we
7968 ;; haven't done that already.
7969 (unless (stringp (caar hthread))
7970 (setcar hthread (list whole-subject (car hthread))))
7971 ;; We add this new gathered thread to this gathered
7973 (setcdr (car hthread)
7974 (nconc (cdar hthread) (list (car threads))))
7975 ;; Remove it from the list of threads.
7976 (setcdr prev (cdr threads))
7977 (setq threads prev))
7978 ;; Enter this thread into the hash table.
7979 (gnus-sethash subject threads hashtb)))
7981 (setq threads (cdr threads)))
7984 (defun gnus-gather-threads-by-references (threads)
7985 "Gather threads by looking at References headers."
7986 (let ((idhashtb (gnus-make-hashtable 1023))
7987 (thhashtb (gnus-make-hashtable 1023))
7990 ids references id gthread gid entered)
7992 (when (setq references (mail-header-references (caar threads)))
7993 (setq id (mail-header-id (caar threads)))
7994 (setq ids (gnus-split-references references))
7997 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7999 (gnus-sethash (car ids) id idhashtb)
8000 (gnus-sethash id threads thhashtb))
8001 (setq gthread (gnus-gethash gid thhashtb))
8003 ;; We enter a dummy root into the thread, if we
8004 ;; haven't done that already.
8005 (unless (stringp (caar gthread))
8006 (setcar gthread (list (mail-header-subject (caar gthread))
8008 ;; We add this new gathered thread to this gathered
8010 (setcdr (car gthread)
8011 (nconc (cdar gthread) (list (car threads)))))
8012 ;; Add it into the thread hash table.
8013 (gnus-sethash id gthread thhashtb)
8015 ;; Remove it from the list of threads.
8016 (setcdr prev (cdr threads))
8017 (setq threads prev))
8018 (setq ids (cdr ids))))
8020 (setq threads (cdr threads)))
8023 (defun gnus-sort-gathered-threads (threads)
8024 "Sort subtreads inside each gathered thread by article number."
8025 (let ((result threads))
8027 (when (stringp (caar threads))
8028 (setcdr (car threads)
8029 (sort (cdar threads) 'gnus-thread-sort-by-number)))
8030 (setq threads (cdr threads)))
8033 (defun gnus-make-threads ()
8034 "Go through the dependency hashtb and find the roots. Return all threads."
8038 (unless (car (symbol-value refs))
8039 ;; These threads do not refer back to any other articles,
8040 ;; so they're roots.
8041 (setq threads (append (cdr (symbol-value refs)) threads))))
8042 gnus-newsgroup-dependencies)
8045 (defun gnus-build-sparse-threads ()
8046 (let ((headers gnus-newsgroup-headers)
8047 (deps gnus-newsgroup-dependencies)
8048 header references generation relations
8049 cthread subject child end pthread relation)
8050 ;; First we create an alist of generations/relations, where
8051 ;; generations is how much we trust the ralation, and the relation
8053 (gnus-message 7 "Making sparse threads...")
8055 (nnheader-set-temp-buffer " *gnus sparse threads*")
8056 (while (setq header (pop headers))
8057 (when (and (setq references (mail-header-references header))
8058 (not (string= references "")))
8060 (setq child (mail-header-id header)
8061 subject (mail-header-subject header))
8063 (while (search-backward ">" nil t)
8064 (setq end (1+ (point)))
8065 (when (search-backward "<" nil t)
8066 (push (list (incf generation)
8067 child (setq child (buffer-substring (point) end))
8070 (push (list (1+ generation) child nil subject) relations)
8072 (kill-buffer (current-buffer)))
8073 ;; Sort over trustworthiness.
8074 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8075 (while (setq relation (pop relations))
8076 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8077 (unless (car (symbol-value cthread))
8078 ;; Make this article the parent of these threads.
8079 (setcar (symbol-value cthread)
8080 (vector gnus-reffed-article-number
8084 (or (caddr relation) "") 0 0 "")))
8085 (set cthread (list (vector gnus-reffed-article-number
8087 "" "" (cadr relation)
8088 (or (caddr relation) "") 0 0 ""))))
8089 (push gnus-reffed-article-number gnus-newsgroup-limit)
8090 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8091 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8092 gnus-newsgroup-reads)
8093 (decf gnus-reffed-article-number)
8094 ;; Make this new thread the child of its parent.
8095 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8096 (setcdr (symbol-value pthread)
8097 (nconc (cdr (symbol-value pthread))
8098 (list (symbol-value cthread))))
8099 (set pthread (list nil (symbol-value cthread))))))
8100 (gnus-message 7 "Making sparse threads...done")))
8102 (defun gnus-build-old-threads ()
8103 ;; Look at all the articles that refer back to old articles, and
8104 ;; fetch the headers for the articles that aren't there. This will
8105 ;; build complete threads - if the roots haven't been expired by the
8110 (when (not (car (symbol-value refs)))
8111 (setq heads (cdr (symbol-value refs)))
8113 (if (memq (mail-header-number (caar heads))
8114 gnus-newsgroup-dormant)
8115 (setq heads (cdr heads))
8116 (setq id (symbol-name refs))
8117 (while (and (setq id (gnus-build-get-header id))
8118 (not (car (gnus-gethash
8119 id gnus-newsgroup-dependencies)))))
8120 (setq heads nil)))))
8121 gnus-newsgroup-dependencies)))
8123 (defun gnus-build-get-header (id)
8124 ;; Look through the buffer of NOV lines and find the header to
8125 ;; ID. Enter this line into the dependencies hash table, and return
8126 ;; the id of the parent article (if any).
8127 (let ((deps gnus-newsgroup-dependencies)
8131 (set-buffer nntp-server-buffer)
8132 (goto-char (point-min))
8133 (while (and (not found) (search-forward id nil t))
8135 (setq found (looking-at
8136 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8137 (regexp-quote id))))
8138 (or found (beginning-of-line 2)))
8142 (setq header (gnus-nov-parse-line
8143 (read (current-buffer)) deps))
8144 (gnus-parent-id (mail-header-references header)))))
8146 (let ((number (mail-header-number header)))
8147 (push number gnus-newsgroup-limit)
8148 (push header gnus-newsgroup-headers)
8149 (if (memq number gnus-newsgroup-unselected)
8151 (push number gnus-newsgroup-unreads)
8152 (setq gnus-newsgroup-unselected
8153 (delq number gnus-newsgroup-unselected)))
8154 (push number gnus-newsgroup-ancient)))))))
8156 (defun gnus-summary-update-article (article &optional iheader)
8157 "Update ARTICLE in the summary buffer."
8158 (set-buffer gnus-summary-buffer)
8159 (let* ((header (or iheader (gnus-summary-article-header article)))
8160 (id (mail-header-id header))
8161 (data (gnus-data-find article))
8162 (thread (gnus-id-to-thread id))
8163 (references (mail-header-references header))
8168 (not (equal "" references)))
8171 (buffer-read-only nil)
8173 (number (mail-header-number header))
8176 ;; !!! Should this be in or not?
8178 (setcar thread nil))
8180 (delq thread parent))
8181 (if (gnus-summary-insert-subject id header iheader)
8182 ;; Set the (possibly) new article number in the data structure.
8183 (gnus-data-set-number data (gnus-id-to-article id))
8187 (defun gnus-rebuild-thread (id)
8188 "Rebuild the thread containing ID."
8189 (let ((buffer-read-only nil)
8190 current thread data)
8191 (if (not gnus-show-threads)
8192 (setq thread (list (car (gnus-id-to-thread id))))
8193 ;; Get the thread this article is part of.
8194 (setq thread (gnus-remove-thread id)))
8195 (setq current (save-excursion
8196 (and (zerop (forward-line -1))
8197 (gnus-summary-article-number))))
8198 ;; If this is a gathered thread, we have to go some re-gathering.
8199 (when (stringp (car thread))
8200 (let ((subject (car thread))
8202 (setq thread (cdr thread))
8204 (unless (memq (setq thr (gnus-id-to-thread
8206 (mail-header-id (caar thread)))))
8209 (setq thread (cdr thread)))
8210 ;; We now have all (unique) roots.
8211 (if (= (length roots) 1)
8212 ;; All the loose roots are now one solid root.
8213 (setq thread (car roots))
8214 (setq thread (cons subject (gnus-sort-threads roots))))))
8216 ;; We then insert this thread into the summary buffer.
8217 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8218 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8219 (setq data (nreverse gnus-newsgroup-data))
8220 (setq threads gnus-newsgroup-threads))
8221 ;; We splice the new data into the data structure.
8222 (gnus-data-enter-list current data)
8223 (gnus-data-compute-positions)
8224 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8226 (defun gnus-number-to-header (number)
8227 "Return the header for article NUMBER."
8228 (let ((headers gnus-newsgroup-headers))
8230 (not (= number (mail-header-number (car headers)))))
8235 (defun gnus-id-to-thread (id)
8236 "Return the (sub-)thread where ID appears."
8237 (gnus-gethash id gnus-newsgroup-dependencies))
8239 (defun gnus-id-to-article (id)
8240 "Return the article number of ID."
8241 (let ((thread (gnus-id-to-thread id)))
8244 (mail-header-number (car thread)))))
8246 (defun gnus-id-to-header (id)
8247 "Return the article headers of ID."
8248 (car (gnus-id-to-thread id)))
8250 (defun gnus-article-displayed-root-p (article)
8251 "Say whether ARTICLE is a root(ish) article."
8252 (let ((level (gnus-summary-thread-level article))
8253 (refs (mail-header-references (gnus-summary-article-header article)))
8259 ((null (gnus-parent-id refs)) t)
8261 (null (setq particle (gnus-id-to-article
8262 (gnus-parent-id refs))))
8263 (null (gnus-summary-thread-level particle)))))))
8265 (defun gnus-root-id (id)
8266 "Return the id of the root of the thread where ID appears."
8268 (while (and id (setq prev (car (gnus-gethash
8269 id gnus-newsgroup-dependencies))))
8271 id (gnus-parent-id (mail-header-references prev))))
8274 (defun gnus-remove-thread (id &optional dont-remove)
8275 "Remove the thread that has ID in it."
8276 (let ((dep gnus-newsgroup-dependencies)
8277 headers thread last-id)
8278 ;; First go up in this thread until we find the root.
8279 (setq last-id (gnus-root-id id))
8280 (setq headers (list (car (gnus-id-to-thread last-id))
8281 (caadr (gnus-id-to-thread last-id))))
8282 ;; We have now found the real root of this thread. It might have
8283 ;; been gathered into some loose thread, so we have to search
8284 ;; through the threads to find the thread we wanted.
8285 (let ((threads gnus-newsgroup-threads)
8288 (setq sub (car threads))
8289 (if (stringp (car sub))
8290 ;; This is a gathered threads, so we look at the roots
8291 ;; below it to find whether this article in in this
8294 (setq sub (cdr sub))
8296 (when (member (caar sub) headers)
8297 (setq thread (car threads)
8300 (setq sub (cdr sub))))
8301 ;; It's an ordinary thread, so we check it.
8302 (when (eq (car sub) (car headers))
8305 (setq threads (cdr threads)))
8306 ;; If this article is in no thread, then it's a root.
8309 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8310 (setq thread (gnus-gethash last-id dep)))
8313 thread ; We return this thread.
8315 (if (stringp (car thread))
8317 ;; If we use dummy roots, then we have to remove the
8318 ;; dummy root as well.
8319 (when (eq gnus-summary-make-false-root 'dummy)
8322 (setq thread (cdr thread))
8324 (gnus-remove-thread-1 (car thread))
8325 (setq thread (cdr thread))))
8326 (gnus-remove-thread-1 thread))))))))
8328 (defun gnus-remove-thread-1 (thread)
8329 "Remove the thread THREAD recursively."
8330 (let ((number (mail-header-number (car thread)))
8332 (when (setq pos (text-property-any
8333 (point-min) (point-max) 'gnus-number number))
8336 (gnus-data-remove number))
8337 (setq thread (cdr thread))
8339 (gnus-remove-thread-1 (pop thread)))))
8341 (defun gnus-sort-threads (threads)
8343 (if (not gnus-thread-sort-functions)
8345 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8346 (car gnus-thread-sort-functions)
8348 ,(gnus-make-sort-function
8349 (reverse gnus-thread-sort-functions))))))
8350 (gnus-message 7 "Sorting threads...")
8353 (gnus-message 7 "Sorting threads...done")))))
8355 (defun gnus-sort-articles (articles)
8357 (when gnus-article-sort-functions
8358 (let ((func (if (= 1 (length gnus-article-sort-functions))
8359 (car gnus-article-sort-functions)
8361 ,(gnus-make-sort-function
8362 (reverse gnus-article-sort-functions))))))
8363 (gnus-message 7 "Sorting articles...")
8365 (setq gnus-newsgroup-headers (sort articles func))
8366 (gnus-message 7 "Sorting articles...done")))))
8368 (defun gnus-make-sort-function (funs)
8369 "Return a composite sort condition based on the functions in FUNC."
8371 `(or (,(car funs) t1 t2)
8372 (and (not (,(car funs) t2 t1))
8373 ,(gnus-make-sort-function (cdr funs))))
8374 `(,(car funs) t1 t2)))
8376 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8377 (defmacro gnus-thread-header (thread)
8378 ;; Return header of first article in THREAD.
8379 ;; Note that THREAD must never, ever be anything else than a variable -
8380 ;; using some other form will lead to serious barfage.
8381 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8382 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8383 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8386 (defsubst gnus-article-sort-by-number (h1 h2)
8387 "Sort articles by article number."
8388 (< (mail-header-number h1)
8389 (mail-header-number h2)))
8391 (defun gnus-thread-sort-by-number (h1 h2)
8392 "Sort threads by root article number."
8393 (gnus-article-sort-by-number
8394 (gnus-thread-header h1) (gnus-thread-header h2)))
8396 (defsubst gnus-article-sort-by-author (h1 h2)
8397 "Sort articles by root author."
8399 (let ((extract (funcall
8400 gnus-extract-address-components
8401 (mail-header-from h1))))
8402 (or (car extract) (cdr extract)))
8403 (let ((extract (funcall
8404 gnus-extract-address-components
8405 (mail-header-from h2))))
8406 (or (car extract) (cdr extract)))))
8408 (defun gnus-thread-sort-by-author (h1 h2)
8409 "Sort threads by root author."
8410 (gnus-article-sort-by-author
8411 (gnus-thread-header h1) (gnus-thread-header h2)))
8413 (defsubst gnus-article-sort-by-subject (h1 h2)
8414 "Sort articles by root subject."
8416 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8417 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8419 (defun gnus-thread-sort-by-subject (h1 h2)
8420 "Sort threads by root subject."
8421 (gnus-article-sort-by-subject
8422 (gnus-thread-header h1) (gnus-thread-header h2)))
8424 (defsubst gnus-article-sort-by-date (h1 h2)
8425 "Sort articles by root article date."
8427 (inline (gnus-sortable-date (mail-header-date h1)))
8428 (inline (gnus-sortable-date (mail-header-date h2)))))
8430 (defun gnus-thread-sort-by-date (h1 h2)
8431 "Sort threads by root article date."
8432 (gnus-article-sort-by-date
8433 (gnus-thread-header h1) (gnus-thread-header h2)))
8435 (defsubst gnus-article-sort-by-score (h1 h2)
8436 "Sort articles by root article score.
8437 Unscored articles will be counted as having a score of zero."
8438 (> (or (cdr (assq (mail-header-number h1)
8439 gnus-newsgroup-scored))
8440 gnus-summary-default-score 0)
8441 (or (cdr (assq (mail-header-number h2)
8442 gnus-newsgroup-scored))
8443 gnus-summary-default-score 0)))
8445 (defun gnus-thread-sort-by-score (h1 h2)
8446 "Sort threads by root article score."
8447 (gnus-article-sort-by-score
8448 (gnus-thread-header h1) (gnus-thread-header h2)))
8450 (defun gnus-thread-sort-by-total-score (h1 h2)
8451 "Sort threads by the sum of all scores in the thread.
8452 Unscored articles will be counted as having a score of zero."
8453 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8455 (defun gnus-thread-total-score (thread)
8456 ;; This function find the total score of THREAD.
8457 (cond ((null thread)
8460 (if (stringp (car thread))
8461 (apply gnus-thread-score-function 0
8462 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8463 (gnus-thread-total-score-1 thread)))
8465 (gnus-thread-total-score-1 (list thread)))))
8467 (defun gnus-thread-total-score-1 (root)
8468 ;; This function find the total score of the thread below ROOT.
8469 (setq root (car root))
8470 (apply gnus-thread-score-function
8472 (mapcar 'gnus-thread-total-score
8473 (cdr (gnus-gethash (mail-header-id root)
8474 gnus-newsgroup-dependencies)))
8475 (if (> (mail-header-number root) 0)
8476 (list (or (cdr (assq (mail-header-number root)
8477 gnus-newsgroup-scored))
8478 gnus-summary-default-score 0))))
8479 (list gnus-summary-default-score)
8482 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8483 (defvar gnus-tmp-prev-subject nil)
8484 (defvar gnus-tmp-false-parent nil)
8485 (defvar gnus-tmp-root-expunged nil)
8486 (defvar gnus-tmp-dummy-line nil)
8488 (defun gnus-summary-prepare-threads (threads)
8489 "Prepare summary buffer from THREADS and indentation LEVEL.
8490 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8491 or a straight list of headers."
8492 (gnus-message 7 "Generating summary...")
8494 (setq gnus-newsgroup-threads threads)
8497 (let ((gnus-tmp-level 0)
8498 (default-score (or gnus-summary-default-score 0))
8499 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8500 thread number subject stack state gnus-tmp-gathered beg-match
8501 new-roots gnus-tmp-new-adopts thread-end
8502 gnus-tmp-header gnus-tmp-unread
8503 gnus-tmp-replied gnus-tmp-subject-or-nil
8504 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8505 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8506 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8508 (setq gnus-tmp-prev-subject nil)
8510 (if (vectorp (car threads))
8511 ;; If this is a straight (sic) list of headers, then a
8512 ;; threaded summary display isn't required, so we just create
8513 ;; an unthreaded one.
8514 (gnus-summary-prepare-unthreaded threads)
8516 ;; Do the threaded display.
8518 (while (or threads stack gnus-tmp-new-adopts new-roots)
8520 (if (and (= gnus-tmp-level 0)
8521 (not (setq gnus-tmp-dummy-line nil))
8524 (not gnus-tmp-false-parent)
8525 (or gnus-tmp-new-adopts new-roots))
8526 (if gnus-tmp-new-adopts
8527 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8528 thread (list (car gnus-tmp-new-adopts))
8529 gnus-tmp-header (caar thread)
8530 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8532 (setq thread (list (car new-roots))
8533 gnus-tmp-header (caar thread)
8534 new-roots (cdr new-roots))))
8537 ;; If there are some threads, we do them before the
8538 ;; threads on the stack.
8539 (setq thread threads
8540 gnus-tmp-header (caar thread))
8541 ;; There were no current threads, so we pop something off
8543 (setq state (car stack)
8544 gnus-tmp-level (car state)
8547 gnus-tmp-header (caar thread))))
8549 (setq gnus-tmp-false-parent nil)
8550 (setq gnus-tmp-root-expunged nil)
8551 (setq thread-end nil)
8553 (if (stringp gnus-tmp-header)
8554 ;; The header is a dummy root.
8556 ((eq gnus-summary-make-false-root 'adopt)
8557 ;; We let the first article adopt the rest.
8558 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8560 (setq gnus-tmp-gathered
8562 (lambda (h) (mail-header-number (car h)))
8565 (setq thread (cons (list (caar thread)
8568 (setq gnus-tmp-level -1
8569 gnus-tmp-false-parent t))
8570 ((eq gnus-summary-make-false-root 'empty)
8571 ;; We print adopted articles with empty subject fields.
8572 (setq gnus-tmp-gathered
8574 (lambda (h) (mail-header-number (car h)))
8577 (setq gnus-tmp-level -1))
8578 ((eq gnus-summary-make-false-root 'dummy)
8579 ;; We remember that we probably want to output a dummy
8581 (setq gnus-tmp-dummy-line gnus-tmp-header)
8582 (setq gnus-tmp-prev-subject gnus-tmp-header))
8584 ;; We do not make a root for the gathered
8585 ;; sub-threads at all.
8586 (setq gnus-tmp-level -1)))
8588 (setq number (mail-header-number gnus-tmp-header)
8589 subject (mail-header-subject gnus-tmp-header))
8592 ;; If the thread has changed subject, we might want to make
8593 ;; this subthread into a root.
8594 ((and (null gnus-thread-ignore-subject)
8595 (not (zerop gnus-tmp-level))
8596 gnus-tmp-prev-subject
8598 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8599 (setq new-roots (nconc new-roots (list (car thread)))
8601 gnus-tmp-header nil))
8602 ;; If the article lies outside the current limit,
8603 ;; then we do not display it.
8604 ((and (not (memq number gnus-newsgroup-limit))
8605 (not gnus-tmp-dummy-line))
8606 (setq gnus-tmp-gathered
8608 (lambda (h) (mail-header-number (car h)))
8611 (setq gnus-tmp-new-adopts (if (cdar thread)
8612 (append gnus-tmp-new-adopts
8614 gnus-tmp-new-adopts)
8616 gnus-tmp-header nil)
8617 (when (zerop gnus-tmp-level)
8618 (setq gnus-tmp-root-expunged t)))
8619 ;; Perhaps this article is to be marked as read?
8620 ((and gnus-summary-mark-below
8621 (< (or (cdr (assq number gnus-newsgroup-scored))
8623 gnus-summary-mark-below)
8624 ;; Don't touch sparse articles.
8625 (not (memq number gnus-newsgroup-sparse))
8626 (not (memq number gnus-newsgroup-ancient)))
8627 (setq gnus-newsgroup-unreads
8628 (delq number gnus-newsgroup-unreads))
8629 (if gnus-newsgroup-auto-expire
8630 (push number gnus-newsgroup-expirable)
8631 (push (cons number gnus-low-score-mark)
8632 gnus-newsgroup-reads))))
8634 (when gnus-tmp-header
8635 ;; We may have an old dummy line to output before this
8637 (when gnus-tmp-dummy-line
8638 (gnus-summary-insert-dummy-line
8639 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8640 (setq gnus-tmp-dummy-line nil))
8642 ;; Compute the mark.
8646 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8647 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8648 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8649 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8650 (t (or (cdr (assq number gnus-newsgroup-reads))
8651 gnus-ancient-mark))))
8653 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8654 gnus-tmp-header gnus-tmp-level)
8655 gnus-newsgroup-data)
8657 ;; Actually insert the line.
8659 gnus-tmp-subject-or-nil
8661 ((and gnus-thread-ignore-subject
8662 gnus-tmp-prev-subject
8663 (not (inline (gnus-subject-equal
8664 gnus-tmp-prev-subject subject))))
8666 ((zerop gnus-tmp-level)
8667 (if (and (eq gnus-summary-make-false-root 'empty)
8668 (memq number gnus-tmp-gathered)
8669 gnus-tmp-prev-subject
8670 (inline (gnus-subject-equal
8671 gnus-tmp-prev-subject subject)))
8672 gnus-summary-same-subject
8674 (t gnus-summary-same-subject)))
8675 (if (and (eq gnus-summary-make-false-root 'adopt)
8676 (= gnus-tmp-level 1)
8677 (memq number gnus-tmp-gathered))
8678 (setq gnus-tmp-opening-bracket ?\<
8679 gnus-tmp-closing-bracket ?\>)
8680 (setq gnus-tmp-opening-bracket ?\[
8681 gnus-tmp-closing-bracket ?\]))
8683 gnus-tmp-indentation
8684 (aref gnus-thread-indent-array gnus-tmp-level)
8685 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8686 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8687 gnus-summary-default-score 0)
8689 (if (or (null gnus-summary-default-score)
8690 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8691 gnus-summary-zcore-fuzz)) ?
8692 (if (< gnus-tmp-score gnus-summary-default-score)
8693 gnus-score-below-mark gnus-score-over-mark))
8695 (cond ((memq number gnus-newsgroup-processable)
8697 ((memq number gnus-newsgroup-cached)
8699 ((memq number gnus-newsgroup-replied)
8701 ((memq number gnus-newsgroup-saved)
8703 (t gnus-unread-mark))
8704 gnus-tmp-from (mail-header-from gnus-tmp-header)
8707 ((string-match "(.+)" gnus-tmp-from)
8708 (substring gnus-tmp-from
8709 (1+ (match-beginning 0)) (1- (match-end 0))))
8710 ((string-match "<[^>]+> *$" gnus-tmp-from)
8711 (setq beg-match (match-beginning 0))
8712 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8713 (substring gnus-tmp-from (1+ (match-beginning 0))
8714 (1- (match-end 0))))
8715 (substring gnus-tmp-from 0 beg-match)))
8717 (when (string= gnus-tmp-name "")
8718 (setq gnus-tmp-name gnus-tmp-from))
8719 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8720 (gnus-put-text-property
8722 (progn (eval gnus-summary-line-format-spec) (point))
8723 'gnus-number number)
8726 (run-hooks 'gnus-summary-update-hook)
8729 (setq gnus-tmp-prev-subject subject)))
8731 (when (nth 1 thread)
8732 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8733 (incf gnus-tmp-level)
8734 (setq threads (if thread-end nil (cdar thread)))
8736 (setq gnus-tmp-level 0)))))
8737 (gnus-message 7 "Generating summary...done"))
8739 (defun gnus-summary-prepare-unthreaded (headers)
8740 "Generate an unthreaded summary buffer based on HEADERS."
8741 (let (header number mark)
8744 ;; We may have to root out some bad articles...
8745 (when (memq (setq number (mail-header-number
8746 (setq header (pop headers))))
8747 gnus-newsgroup-limit)
8748 ;; Mark article as read when it has a low score.
8749 (when (and gnus-summary-mark-below
8750 (< (or (cdr (assq number gnus-newsgroup-scored))
8751 gnus-summary-default-score 0)
8752 gnus-summary-mark-below)
8753 (not (memq number gnus-newsgroup-ancient)))
8754 (setq gnus-newsgroup-unreads
8755 (delq number gnus-newsgroup-unreads))
8756 (if gnus-newsgroup-auto-expire
8757 (push number gnus-newsgroup-expirable)
8758 (push (cons number gnus-low-score-mark)
8759 gnus-newsgroup-reads)))
8763 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8764 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8765 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8766 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8767 (t (or (cdr (assq number gnus-newsgroup-reads))
8768 gnus-ancient-mark))))
8769 (setq gnus-newsgroup-data
8770 (cons (gnus-data-make number mark (1+ (point)) header 0)
8771 gnus-newsgroup-data))
8772 (gnus-summary-insert-line
8773 header 0 nil mark (memq number gnus-newsgroup-replied)
8774 (memq number gnus-newsgroup-expirable)
8775 (mail-header-subject header) nil
8776 (cdr (assq number gnus-newsgroup-scored))
8777 (memq number gnus-newsgroup-processable))))))
8779 (defun gnus-select-newsgroup (group &optional read-all)
8780 "Select newsgroup GROUP.
8781 If READ-ALL is non-nil, all articles in the group are selected."
8782 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8783 (info (nth 2 entry))
8784 articles fetched-articles cached)
8786 (or (gnus-check-server
8787 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8788 (error "Couldn't open server"))
8790 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8791 (gnus-activate-group group) ; Or we can activate it...
8792 (progn ; Or we bug out.
8793 (when (equal major-mode 'gnus-summary-mode)
8794 (kill-buffer (current-buffer)))
8795 (error "Couldn't request group %s: %s"
8796 group (gnus-status-message group))))
8798 (unless (gnus-request-group group t)
8799 (when (equal major-mode 'gnus-summary-mode)
8800 (kill-buffer (current-buffer)))
8801 (error "Couldn't request group %s: %s"
8802 group (gnus-status-message group)))
8804 (setq gnus-newsgroup-name group)
8805 (setq gnus-newsgroup-unselected nil)
8806 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8808 (and gnus-asynchronous
8809 (gnus-check-backend-function
8810 'request-asynchronous gnus-newsgroup-name)
8811 (setq gnus-newsgroup-async
8812 (gnus-request-asynchronous gnus-newsgroup-name)))
8814 ;; Adjust and set lists of article marks.
8816 (gnus-adjust-marked-articles info))
8818 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8819 (when (gnus-virtual-group-p group)
8820 (setq cached gnus-newsgroup-cached))
8822 (setq gnus-newsgroup-unreads
8823 (gnus-set-difference
8824 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8825 gnus-newsgroup-dormant))
8827 (setq gnus-newsgroup-processable nil)
8829 (setq articles (gnus-articles-to-read group read-all))
8833 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8835 ((eq articles 0) nil)
8837 ;; Init the dependencies hash table.
8838 (setq gnus-newsgroup-dependencies
8839 (gnus-make-hashtable (length articles)))
8840 ;; Retrieve the headers and read them in.
8841 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8842 (setq gnus-newsgroup-headers
8844 (setq gnus-headers-retrieved-by
8845 (gnus-retrieve-headers
8846 articles gnus-newsgroup-name
8847 ;; We might want to fetch old headers, but
8848 ;; not if there is only 1 article.
8849 (and gnus-fetch-old-headers
8851 (not (eq gnus-fetch-old-headers 'some))
8852 (not (numberp gnus-fetch-old-headers)))
8853 (> (length articles) 1))))))
8854 (gnus-get-newsgroup-headers-xover articles)
8855 (gnus-get-newsgroup-headers)))
8856 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8858 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8860 (setq gnus-newsgroup-cached cached))
8862 ;; Set the initial limit.
8863 (setq gnus-newsgroup-limit (copy-sequence articles))
8864 ;; Remove canceled articles from the list of unread articles.
8865 (setq gnus-newsgroup-unreads
8866 (gnus-set-sorted-intersection
8867 gnus-newsgroup-unreads
8868 (setq fetched-articles
8869 (mapcar (lambda (headers) (mail-header-number headers))
8870 gnus-newsgroup-headers))))
8871 ;; Removed marked articles that do not exist.
8872 (gnus-update-missing-marks
8873 (gnus-sorted-complement fetched-articles articles))
8874 ;; We might want to build some more threads first.
8875 (and gnus-fetch-old-headers
8876 (eq gnus-headers-retrieved-by 'nov)
8877 (gnus-build-old-threads))
8878 ;; Check whether auto-expire is to be done in this group.
8879 (setq gnus-newsgroup-auto-expire
8880 (gnus-group-auto-expirable-p group))
8881 ;; Set up the article buffer now, if necessary.
8882 (unless gnus-single-article-buffer
8883 (gnus-article-setup-buffer))
8884 ;; First and last article in this newsgroup.
8885 (when gnus-newsgroup-headers
8886 (setq gnus-newsgroup-begin
8887 (mail-header-number (car gnus-newsgroup-headers))
8890 (gnus-last-element gnus-newsgroup-headers))))
8891 (setq gnus-reffed-article-number -1)
8892 ;; GROUP is successfully selected.
8893 (or gnus-newsgroup-headers t)))))
8895 (defun gnus-articles-to-read (group read-all)
8896 ;; Find out what articles the user wants to read.
8898 ;; Select all articles if `read-all' is non-nil, or if there
8899 ;; are no unread articles.
8901 (and (zerop (length gnus-newsgroup-marked))
8902 (zerop (length gnus-newsgroup-unreads))))
8903 (gnus-uncompress-range (gnus-active group))
8904 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8905 (copy-sequence gnus-newsgroup-unreads))
8907 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8908 (scored (length scored-list))
8909 (number (length articles))
8910 (marked (+ (length gnus-newsgroup-marked)
8911 (length gnus-newsgroup-dormant)))
8919 ((and (or (<= scored marked) (= scored number))
8920 (numberp gnus-large-newsgroup)
8921 (> number gnus-large-newsgroup))
8925 "How many articles from %s (default %d): "
8926 gnus-newsgroup-name number))))
8927 (if (string-match "^[ \t]*$" input) number input)))
8928 ((and (> scored marked) (< scored number)
8929 (> (- scored number) 20))
8932 (format "%s %s (%d scored, %d total): "
8933 "How many articles from"
8934 group scored number))))
8935 (if (string-match "^[ \t]*$" input)
8939 (setq select (if (stringp select) (string-to-number select) select))
8940 (if (or (null select) (zerop select))
8942 (if (and (not (zerop scored)) (<= (abs select) scored))
8944 (setq articles (sort scored-list '<))
8945 (setq number (length articles)))
8946 (setq articles (copy-sequence articles)))
8948 (if (< (abs select) number)
8950 ;; Select the N oldest articles.
8951 (setcdr (nthcdr (1- (abs select)) articles) nil)
8952 ;; Select the N most recent articles.
8953 (setq articles (nthcdr (- number select) articles))))
8954 (setq gnus-newsgroup-unselected
8955 (gnus-sorted-intersection
8956 gnus-newsgroup-unreads
8957 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8960 (defun gnus-killed-articles (killed articles)
8963 (if (inline (gnus-member-of-range (car articles) killed))
8964 (setq out (cons (car articles) out)))
8965 (setq articles (cdr articles)))
8968 (defun gnus-uncompress-marks (marks)
8969 "Uncompress the mark ranges in MARKS."
8970 (let ((uncompressed '(score bookmark))
8973 (if (memq (caar marks) uncompressed)
8974 (push (car marks) out)
8975 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8976 (setq marks (cdr marks)))
8979 (defun gnus-adjust-marked-articles (info)
8980 "Set all article lists and remove all marks that are no longer legal."
8981 (let* ((marked-lists (gnus-info-marks info))
8982 (active (gnus-active (gnus-info-group info)))
8985 (types gnus-article-mark-lists)
8986 (uncompressed '(score bookmark killed))
8987 marks var articles article mark)
8990 (setq marks (pop marked-lists))
8991 (set (setq var (intern (format "gnus-newsgroup-%s"
8992 (car (rassq (setq mark (car marks))
8994 (if (memq (car marks) uncompressed) (cdr marks)
8995 (gnus-uncompress-range (cdr marks))))
8997 (setq articles (symbol-value var))
8999 ;; All articles have to be subsets of the active articles.
9001 ;; Adjust "simple" lists.
9002 ((memq mark '(tick dormant expirable reply save))
9004 (when (or (< (setq article (pop articles)) min) (> article max))
9005 (set var (delq article (symbol-value var))))))
9007 ((memq mark uncompressed)
9009 (when (or (not (consp (setq article (pop articles))))
9010 (< (car article) min)
9011 (> (car article) max))
9012 (set var (delq article (symbol-value var))))))))))
9014 (defun gnus-update-missing-marks (missing)
9015 "Go through the list of MISSING articles and remove them mark lists."
9017 (let ((types gnus-article-mark-lists)
9019 ;; Go through all types.
9021 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
9022 (when (symbol-value var)
9023 ;; This list has articles. So we delete all missing articles
9027 (set var (delq (pop m) (symbol-value var)))))))))
9029 (defun gnus-update-marks ()
9030 "Enter the various lists of marked articles into the newsgroup info list."
9031 (let ((types gnus-article-mark-lists)
9032 (info (gnus-get-info gnus-newsgroup-name))
9033 (uncompressed '(score bookmark killed))
9034 type list newmarked symbol)
9036 ;; Add all marks lists that are non-nil to the list of marks lists.
9038 (setq type (pop types))
9039 (when (setq list (symbol-value
9041 (intern (format "gnus-newsgroup-%s"
9043 (push (cons (cdr type)
9044 (if (memq (cdr type) uncompressed) list
9045 (gnus-compress-sequence
9046 (set symbol (sort list '<)) t)))
9049 ;; Enter these new marks into the info of the group.
9051 (setcar (nthcdr 3 info) newmarked)
9052 ;; Add the marks lists to the end of the info.
9054 (setcdr (nthcdr 2 info) (list newmarked))))
9056 ;; Cut off the end of the info if there's nothing else there.
9060 (when (nthcdr (decf i) info)
9061 (setcdr (nthcdr i info) nil)))))))
9063 (defun gnus-add-marked-articles (group type articles &optional info force)
9064 ;; Add ARTICLES of TYPE to the info of GROUP.
9065 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9066 ;; add, but replace marked articles of TYPE with ARTICLES.
9067 (let ((info (or info (gnus-get-info group)))
9068 (uncompressed '(score bookmark killed))
9071 (and (not (setq marked (nthcdr 3 info)))
9073 (setcdr (nthcdr 2 info)
9074 (list (list (cons type (gnus-compress-sequence
9076 (and (not (setq m (assq type (car marked))))
9079 (cons (cons type (gnus-compress-sequence articles t) )
9083 (setcar (nthcdr 3 info)
9084 (delq (assq type (car marked)) (car marked)))
9085 (setcdr m (gnus-compress-sequence articles t)))
9086 (setcdr m (gnus-compress-sequence
9087 (sort (nconc (gnus-uncompress-range (cdr m))
9088 (copy-sequence articles)) '<) t))))))
9090 (defun gnus-set-mode-line (where)
9091 "This function sets the mode line of the article or summary buffers.
9092 If WHERE is `summary', the summary mode line format will be used."
9093 ;; Is this mode line one we keep updated?
9094 (when (memq where gnus-updated-mode-lines)
9097 ;; We evaluate this in the summary buffer since these
9098 ;; variables are buffer-local to that buffer.
9099 (set-buffer gnus-summary-buffer)
9100 ;; We bind all these variables that are used in the `eval' form
9102 (let* ((mformat (symbol-value
9104 (format "gnus-%s-mode-line-format-spec" where))))
9105 (gnus-tmp-group-name gnus-newsgroup-name)
9106 (gnus-tmp-article-number (or gnus-current-article 0))
9107 (gnus-tmp-unread gnus-newsgroup-unreads)
9108 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9109 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9110 (gnus-tmp-unread-and-unselected
9111 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9112 (zerop gnus-tmp-unselected)) "")
9113 ((zerop gnus-tmp-unselected)
9114 (format "{%d more}" gnus-tmp-unread-and-unticked))
9115 (t (format "{%d(+%d) more}"
9116 gnus-tmp-unread-and-unticked
9117 gnus-tmp-unselected))))
9119 (if (and gnus-current-headers
9120 (vectorp gnus-current-headers))
9121 (gnus-mode-string-quote
9122 (mail-header-subject gnus-current-headers)) ""))
9124 gnus-tmp-header);; passed as argument to any user-format-funcs
9125 (setq mode-string (eval mformat))
9126 (setq max-len (max 4 (if gnus-mode-non-string-length
9128 gnus-mode-non-string-length)
9129 (length mode-string))))
9130 ;; We might have to chop a bit of the string off...
9131 (when (> (length mode-string) max-len)
9133 (concat (gnus-truncate-string mode-string (- max-len 3))
9135 ;; Pad the mode string a bit.
9136 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9137 ;; Update the mode line.
9138 (setq mode-line-buffer-identification
9139 (gnus-mode-line-buffer-identification
9140 (list mode-string)))
9141 (set-buffer-modified-p t))))
9143 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9144 "Go through the HEADERS list and add all Xrefs to a hash table.
9145 The resulting hash table is returned, or nil if no Xrefs were found."
9146 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9147 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9148 (xref-hashtb (make-vector 63 0))
9149 start group entry number xrefs header)
9151 (setq header (pop headers))
9152 (when (and (setq xrefs (mail-header-xref header))
9153 (not (memq (setq number (mail-header-number header))
9156 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9157 (setq start (match-end 0))
9158 (setq group (if prefix
9159 (concat prefix (substring xrefs (match-beginning 1)
9161 (substring xrefs (match-beginning 1) (match-end 1))))
9163 (string-to-int (substring xrefs (match-beginning 2)
9165 (if (setq entry (gnus-gethash group xref-hashtb))
9166 (setcdr entry (cons number (cdr entry)))
9167 (gnus-sethash group (cons number nil) xref-hashtb)))))
9168 (and start xref-hashtb)))
9170 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9171 "Look through all the headers and mark the Xrefs as read."
9172 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9173 name entry info xref-hashtb idlist method nth4)
9175 (set-buffer gnus-group-buffer)
9176 (when (setq xref-hashtb
9177 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9180 (unless (string= from-newsgroup (setq name (symbol-name group)))
9181 (setq idlist (symbol-value group))
9182 ;; Dead groups are not updated.
9184 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9186 (if (stringp (setq nth4 (gnus-info-method info)))
9187 (setq nth4 (gnus-server-to-method nth4))))
9188 ;; Only do the xrefs if the group has the same
9189 ;; select method as the group we have just read.
9190 (or (gnus-methods-equal-p
9191 nth4 (gnus-find-method-for-group from-newsgroup))
9193 (equal nth4 (setq method (gnus-find-method-for-group
9195 (and (equal (car nth4) (car method))
9196 (equal (nth 1 nth4) (nth 1 method))))
9197 gnus-use-cross-reference
9198 (or (not (eq gnus-use-cross-reference t))
9200 ;; Only do cross-references on subscribed
9201 ;; groups, if that is what is wanted.
9202 (<= (gnus-info-level info) gnus-level-subscribed))
9203 (gnus-group-make-articles-read name idlist))))
9206 (defun gnus-group-make-articles-read (group articles)
9208 (entry (gnus-gethash group gnus-newsrc-hashtb))
9209 (info (nth 2 entry))
9210 (active (gnus-active group))
9212 ;; First peel off all illegal article numbers.
9214 (let ((ids articles)
9218 (if (and first (> id (cdr active)))
9220 ;; We'll end up in this situation in one particular
9221 ;; obscure situation. If you re-scan a group and get
9222 ;; a new article that is cross-posted to a different
9223 ;; group that has not been re-scanned, you might get
9224 ;; crossposted article that has a higher number than
9225 ;; Gnus believes possible. So we re-activate this
9226 ;; group as well. This might mean doing the
9227 ;; crossposting thingy will *increase* the number
9228 ;; of articles in some groups. Tsk, tsk.
9229 (setq active (or (gnus-activate-group group) active))))
9230 (if (or (> id (cdr active))
9231 (< id (car active)))
9232 (setq articles (delq id articles)))
9233 (setq ids (cdr ids)))))
9234 ;; If the read list is nil, we init it.
9236 (null (gnus-info-read info))
9238 (gnus-info-set-read info (cons 1 (1- (car active)))))
9239 ;; Then we add the read articles to the range.
9244 (gnus-info-read info) (setq articles (sort articles '<)))))
9245 ;; Then we have to re-compute how many unread
9246 ;; articles there are in this group.
9251 (setq num (- (1+ (cdr active)) (car active))))
9252 ((not (listp (cdr range)))
9253 (setq num (- (cdr active) (- (1+ (cdr range))
9257 (if (numberp (car range))
9259 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9260 (setq range (cdr range)))
9261 (setq num (- (cdr active) num))))
9262 ;; Update the number of unread articles.
9264 ;; Update the group buffer.
9265 (gnus-group-update-group group t)))))
9267 (defun gnus-methods-equal-p (m1 m2)
9268 (let ((m1 (or m1 gnus-select-method))
9269 (m2 (or m2 gnus-select-method)))
9271 (and (eq (car m1) (car m2))
9272 (or (not (memq 'address (assoc (symbol-name (car m1))
9273 gnus-valid-select-methods)))
9274 (equal (nth 1 m1) (nth 1 m2)))))))
9276 (defsubst gnus-header-value ()
9277 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9279 (defvar gnus-newsgroup-none-id 0)
9281 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9282 (let ((cur nntp-server-buffer)
9285 (save-excursion (set-buffer gnus-summary-buffer)
9286 gnus-newsgroup-dependencies)))
9287 headers id id-dep ref-dep end ref)
9289 (set-buffer nntp-server-buffer)
9290 (run-hooks 'gnus-parse-headers-hook)
9291 (let ((case-fold-search t)
9292 in-reply-to header p lines)
9293 (goto-char (point-min))
9294 ;; Search to the beginning of the next header. Error messages
9295 ;; do not begin with 2 or 3.
9296 (while (re-search-forward "^[23][0-9]+ " nil t)
9299 ;; This implementation of this function, with nine
9300 ;; search-forwards instead of the one re-search-forward and
9301 ;; a case (which basically was the old function) is actually
9302 ;; about twice as fast, even though it looks messier. You
9303 ;; can't have everything, I guess. Speed and elegance
9304 ;; doesn't always go hand in hand.
9313 (narrow-to-region (point)
9314 (or (and (search-forward "\n.\n" nil t)
9320 (if (search-forward "\nsubject: " nil t)
9321 (gnus-header-value) "(none)"))
9325 (if (search-forward "\nfrom: " nil t)
9326 (gnus-header-value) "(nobody)"))
9330 (if (search-forward "\ndate: " nil t)
9331 (gnus-header-value) ""))
9335 (if (search-forward "\nmessage-id: " nil t)
9336 (setq id (gnus-header-value))
9337 ;; If there was no message-id, we just fake one to make
9338 ;; subsequent routines simpler.
9339 (setq id (concat "none+"
9341 (setq gnus-newsgroup-none-id
9342 (1+ gnus-newsgroup-none-id)))))))
9346 (if (search-forward "\nreferences: " nil t)
9355 (search-backward ">" end t)
9358 (search-backward "<" end t)
9360 ;; Get the references from the in-reply-to header if there
9361 ;; were no references and the in-reply-to header looks
9363 (if (and (search-forward "\nin-reply-to: " nil t)
9364 (setq in-reply-to (gnus-header-value))
9365 (string-match "<[^>]+>" in-reply-to))
9366 (setq ref (substring in-reply-to (match-beginning 0)
9374 (if (search-forward "\nlines: " nil t)
9375 (if (numberp (setq lines (read cur)))
9381 (and (search-forward "\nxref: " nil t)
9382 (gnus-header-value)))))
9383 ;; We do the threading while we read the headers. The
9384 ;; message-id and the last reference are both entered into
9385 ;; the same hash table. Some tippy-toeing around has to be
9386 ;; done in case an article has arrived before the article
9387 ;; which it refers to.
9388 (if (boundp (setq id-dep (intern id dependencies)))
9389 (if (and (car (symbol-value id-dep))
9391 ;; An article with this Message-ID has already
9392 ;; been seen, so we ignore this one, except we add
9393 ;; any additional Xrefs (in case the two articles
9394 ;; came from different servers).
9396 (mail-header-set-xref
9397 (car (symbol-value id-dep))
9398 (concat (or (mail-header-xref
9399 (car (symbol-value id-dep))) "")
9400 (or (mail-header-xref header) "")))
9402 (setcar (symbol-value id-dep) header))
9403 (set id-dep (list header)))
9405 (if (boundp (setq ref-dep (intern ref dependencies)))
9406 (setcdr (symbol-value ref-dep)
9407 (nconc (cdr (symbol-value ref-dep))
9408 (list (symbol-value id-dep))))
9409 (set ref-dep (list nil (symbol-value id-dep))))
9410 (setq headers (cons header headers)))
9411 (goto-char (point-max))
9413 (nreverse headers)))))
9415 ;; The following macros and functions were written by Felix Lee
9416 ;; <flee@cse.psu.edu>.
9418 (defmacro gnus-nov-read-integer ()
9420 (if (= (following-char) ?\t)
9422 (let ((num (condition-case nil (read buffer) (error nil))))
9423 (if (numberp num) num 0)))
9424 (or (eobp) (forward-char 1))))
9426 (defmacro gnus-nov-skip-field ()
9427 '(search-forward "\t" eol 'move))
9429 (defmacro gnus-nov-field ()
9430 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9432 ;; Goes through the xover lines and returns a list of vectors
9433 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9434 force-new dependencies)
9435 "Parse the news overview data in the server buffer, and return a
9436 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9437 ;; Get the Xref when the users reads the articles since most/some
9438 ;; NNTP servers do not include Xrefs when using XOVER.
9439 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9440 (let ((cur nntp-server-buffer)
9441 (dependencies (or dependencies gnus-newsgroup-dependencies))
9442 number headers header)
9444 (set-buffer nntp-server-buffer)
9445 ;; Allow the user to mangle the headers before parsing them.
9446 (run-hooks 'gnus-parse-headers-hook)
9447 (goto-char (point-min))
9448 (while (and sequence (not (eobp)))
9449 (setq number (read cur))
9450 (while (and sequence (< (car sequence) number))
9451 (setq sequence (cdr sequence)))
9453 (eq number (car sequence))
9455 (setq sequence (cdr sequence))
9457 (inline (gnus-nov-parse-line
9458 number dependencies force-new)))
9459 (setq headers (cons header headers)))))
9461 (setq headers (nreverse headers)))
9464 ;; This function has to be called with point after the article number
9465 ;; on the beginning of the line.
9466 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9468 (eol (gnus-point-at-eol))
9469 (buffer (current-buffer))
9470 header ref id id-dep ref-dep)
9472 ;; overview: [num subject from date id refs chars lines misc]
9473 (narrow-to-region (point) eol)
9474 (or (eobp) (forward-char))
9480 (gnus-nov-field) ; subject
9481 (gnus-nov-field) ; from
9482 (gnus-nov-field) ; date
9483 (setq id (or (gnus-nov-field)
9486 (setq none (1+ none)))))) ; id
9489 (let ((beg (point)))
9490 (search-forward "\t" eol)
9491 (if (search-backward ">" beg t)
9495 (search-backward "<" beg t)))
9497 (gnus-nov-field)) ; refs
9498 (gnus-nov-read-integer) ; chars
9499 (gnus-nov-read-integer) ; lines
9500 (if (= (following-char) ?\n)
9502 (gnus-nov-field)) ; misc
9505 (gnus-error 4 "Strange nov line")
9511 ;; We build the thread tree.
9513 (if (boundp (setq id-dep (intern id dependencies)))
9514 (if (and (car (symbol-value id-dep))
9516 ;; An article with this Message-ID has already been seen,
9517 ;; so we ignore this one, except we add any additional
9518 ;; Xrefs (in case the two articles came from different
9521 (mail-header-set-xref
9522 (car (symbol-value id-dep))
9523 (concat (or (mail-header-xref
9524 (car (symbol-value id-dep))) "")
9525 (or (mail-header-xref header) "")))
9527 (setcar (symbol-value id-dep) header))
9528 (set id-dep (list header))))
9530 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9531 (setcdr (symbol-value ref-dep)
9532 (nconc (cdr (symbol-value ref-dep))
9533 (list (symbol-value id-dep))))
9534 (set ref-dep (list nil (symbol-value id-dep)))))
9537 (defun gnus-article-get-xrefs ()
9538 "Fill in the Xref value in `gnus-current-headers', if necessary.
9539 This is meant to be called in `gnus-article-internal-prepare-hook'."
9540 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9541 gnus-current-headers)))
9542 (or (not gnus-use-cross-reference)
9544 (and (mail-header-xref headers)
9545 (not (string= (mail-header-xref headers) "")))
9546 (let ((case-fold-search t)
9549 (nnheader-narrow-to-headers)
9550 (goto-char (point-min))
9551 (if (or (and (eq (downcase (following-char)) ?x)
9552 (looking-at "Xref:"))
9553 (search-forward "\nXref:" nil t))
9555 (goto-char (1+ (match-end 0)))
9556 (setq xref (buffer-substring (point)
9557 (progn (end-of-line) (point))))
9558 (mail-header-set-xref headers xref))))))))
9560 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9561 "Find article ID and insert the summary line for that article."
9562 (let ((header (if (and old-header use-old-header)
9563 old-header (gnus-read-header id)))
9564 (number (and (numberp id) id))
9567 ;; Rebuild the thread that this article is part of and go to the
9568 ;; article we have fetched.
9569 (when (and (not gnus-show-threads)
9571 (when (setq pos (text-property-any
9572 (point-min) (point-max) 'gnus-number
9573 (mail-header-number old-header)))
9576 (gnus-data-remove (mail-header-number old-header))))
9578 (mail-header-set-number header (mail-header-number old-header)))
9579 (setq gnus-newsgroup-sparse
9580 (delq (setq number (mail-header-number header))
9581 gnus-newsgroup-sparse))
9582 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9583 (gnus-rebuild-thread (mail-header-id header))
9584 (gnus-summary-goto-subject number nil t))
9585 (when (and (numberp number)
9587 ;; We have to update the boundaries even if we can't fetch the
9588 ;; article if ID is a number -- so that the next `P' or `N'
9589 ;; command will fetch the previous (or next) article even
9590 ;; if the one we tried to fetch this time has been canceled.
9591 (and (> number gnus-newsgroup-end)
9592 (setq gnus-newsgroup-end number))
9593 (and (< number gnus-newsgroup-begin)
9594 (setq gnus-newsgroup-begin number))
9595 (setq gnus-newsgroup-unselected
9596 (delq number gnus-newsgroup-unselected)))
9597 ;; Report back a success?
9598 (and header (mail-header-number header))))
9600 (defun gnus-summary-work-articles (n)
9601 "Return a list of articles to be worked upon. The prefix argument,
9602 the list of process marked articles, and the current article will be
9603 taken into consideration."
9606 ;; A numerical prefix has been given.
9607 (let ((backward (< n 0))
9608 (n (abs (prefix-numeric-value n)))
9613 (push (setq article (gnus-summary-article-number))
9616 (gnus-summary-find-prev nil article)
9617 (gnus-summary-find-next nil article)))
9619 (nreverse articles)))
9620 ((and (boundp 'transient-mark-mode)
9623 ;; Work on the region between point and mark.
9624 (let ((max (max (point) (mark)))
9627 (goto-char (min (point) (mark)))
9630 (push (setq article (gnus-summary-article-number)) articles)
9631 (gnus-summary-find-next nil article)
9633 (nreverse articles))))
9634 (gnus-newsgroup-processable
9635 ;; There are process-marked articles present.
9636 (reverse gnus-newsgroup-processable))
9638 ;; Just return the current article.
9639 (list (gnus-summary-article-number)))))
9641 (defun gnus-summary-search-group (&optional backward use-level)
9642 "Search for next unread newsgroup.
9643 If optional argument BACKWARD is non-nil, search backward instead."
9645 (set-buffer gnus-group-buffer)
9646 (if (gnus-group-search-forward
9647 backward nil (if use-level (gnus-group-group-level) nil))
9648 (gnus-group-group-name))))
9650 (defun gnus-summary-best-group (&optional exclude-group)
9651 "Find the name of the best unread group.
9652 If EXCLUDE-GROUP, do not go to this group."
9654 (set-buffer gnus-group-buffer)
9656 (gnus-group-best-unread-group exclude-group))))
9658 (defun gnus-summary-find-next (&optional unread article backward)
9659 (if backward (gnus-summary-find-prev)
9660 (let* ((dummy (gnus-summary-article-intangible-p))
9661 (article (or article (gnus-summary-article-number)))
9662 (arts (gnus-data-find-list article))
9664 (when (and (not dummy)
9665 (or (not gnus-summary-check-current)
9667 (not (gnus-data-unread-p (car arts)))))
9668 (setq arts (cdr arts)))
9673 (when (gnus-data-unread-p (car arts))
9674 (setq result (car arts)
9676 (setq arts (cdr arts)))
9679 (goto-char (gnus-data-pos result))
9680 (gnus-data-number result)))))
9682 (defun gnus-summary-find-prev (&optional unread article)
9683 (let* ((eobp (eobp))
9684 (article (or article (gnus-summary-article-number)))
9685 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9687 (when (and (not eobp)
9688 (or (not gnus-summary-check-current)
9690 (not (gnus-data-unread-p (car arts)))))
9691 (setq arts (cdr arts)))
9696 (and (gnus-data-unread-p (car arts))
9697 (setq result (car arts)
9699 (setq arts (cdr arts)))
9703 (goto-char (gnus-data-pos result))
9704 (gnus-data-number result)))))
9706 (defun gnus-summary-find-subject (subject &optional unread backward article)
9707 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9708 (article (or article (gnus-summary-article-number)))
9709 (articles (gnus-data-list backward))
9710 (arts (gnus-data-find-list article articles))
9712 (when (or (not gnus-summary-check-current)
9714 (not (gnus-data-unread-p (car arts))))
9715 (setq arts (cdr arts)))
9717 (and (or (not unread)
9718 (gnus-data-unread-p (car arts)))
9719 (vectorp (gnus-data-header (car arts)))
9721 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9722 (setq result (car arts)
9724 (setq arts (cdr arts)))
9726 (goto-char (gnus-data-pos result))
9727 (gnus-data-number result))))
9729 (defun gnus-summary-search-forward (&optional unread subject backward)
9730 "Search forward for an article.
9731 If UNREAD, look for unread articles. If SUBJECT, look for
9732 articles with that subject. If BACKWARD, search backward instead."
9733 (cond (subject (gnus-summary-find-subject subject unread backward))
9734 (backward (gnus-summary-find-prev unread))
9735 (t (gnus-summary-find-next unread))))
9737 (defun gnus-recenter (&optional n)
9738 "Center point in window and redisplay frame.
9739 Also do horizontal recentering."
9741 (when (and gnus-auto-center-summary
9742 (not (eq gnus-auto-center-summary 'vertical)))
9743 (gnus-horizontal-recenter))
9746 (defun gnus-summary-recenter ()
9747 "Center point in the summary window.
9748 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9749 displayed, no centering will be performed."
9750 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9751 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9752 (let* ((top (cond ((< (window-height) 4) 0)
9753 ((< (window-height) 7) 1)
9755 (height (1- (window-height)))
9756 (bottom (save-excursion (goto-char (point-max))
9757 (forward-line (- height))
9759 (window (get-buffer-window (current-buffer))))
9760 ;; The user has to want it.
9761 (when gnus-auto-center-summary
9762 (when (get-buffer-window gnus-article-buffer)
9763 ;; Only do recentering when the article buffer is displayed,
9764 ;; Set the window start to either `bottom', which is the biggest
9765 ;; possible valid number, or the second line from the top,
9766 ;; whichever is the least.
9768 window (min bottom (save-excursion
9769 (forward-line (- top)) (point)))))
9770 ;; Do horizontal recentering while we're at it.
9771 (when (and (get-buffer-window (current-buffer) t)
9772 (not (eq gnus-auto-center-summary 'vertical)))
9773 (let ((selected (selected-window)))
9774 (select-window (get-buffer-window (current-buffer) t))
9775 (gnus-summary-position-point)
9776 (gnus-horizontal-recenter)
9777 (select-window selected))))))
9779 (defun gnus-horizontal-recenter ()
9780 "Recenter the current buffer horizontally."
9781 (if (< (current-column) (/ (window-width) 2))
9782 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9783 (let* ((orig (point))
9784 (end (window-end (get-buffer-window (current-buffer) t)))
9786 ;; Find the longest line currently displayed in the window.
9787 (goto-char (window-start))
9788 (while (and (not (eobp))
9791 (setq max (max max (current-column)))
9794 ;; Scroll horizontally to center (sort of) the point.
9795 (if (> max (window-width))
9797 (get-buffer-window (current-buffer) t)
9798 (min (- (current-column) (/ (window-width) 3))
9799 (+ 2 (- max (window-width)))))
9800 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9803 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9804 (defun gnus-short-group-name (group &optional levels)
9805 "Collapse GROUP name LEVELS."
9812 (while (string-match "\\." group skip)
9813 (setq skip (match-end 0)
9816 (if (string-match ":" group)
9817 (setq foreign (substring group 0 (match-end 0))
9818 group (substring group (match-end 0))))
9820 (if (and (string-match "\\." group)
9821 (> levels (- gnus-group-uncollapsed-levels 1)))
9822 (setq name (concat name (substring group 0 1))
9823 group (substring group (match-end 0))
9825 name (concat name "."))
9826 (setq name (concat foreign name group)
9830 (defun gnus-summary-jump-to-group (newsgroup)
9831 "Move point to NEWSGROUP in group mode buffer."
9832 ;; Keep update point of group mode buffer if visible.
9833 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9834 (save-window-excursion
9835 ;; Take care of tree window mode.
9836 (if (get-buffer-window gnus-group-buffer)
9837 (pop-to-buffer gnus-group-buffer))
9838 (gnus-group-jump-to-group newsgroup))
9840 ;; Take care of tree window mode.
9841 (if (get-buffer-window gnus-group-buffer)
9842 (pop-to-buffer gnus-group-buffer)
9843 (set-buffer gnus-group-buffer))
9844 (gnus-group-jump-to-group newsgroup))))
9846 ;; This function returns a list of article numbers based on the
9847 ;; difference between the ranges of read articles in this group and
9848 ;; the range of active articles.
9849 (defun gnus-list-of-unread-articles (group)
9850 (let* ((read (gnus-info-read (gnus-get-info group)))
9851 (active (gnus-active group))
9854 ;; If none are read, then all are unread.
9856 (setq first (car active))
9857 ;; If the range of read articles is a single range, then the
9858 ;; first unread article is the article after the last read
9859 ;; article. Sounds logical, doesn't it?
9860 (if (not (listp (cdr read)))
9861 (setq first (1+ (cdr read)))
9862 ;; `read' is a list of ranges.
9863 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9868 (while (< first nlast)
9869 (setq unread (cons first unread))
9870 (setq first (1+ first))))
9871 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9872 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9873 (setq read (cdr read)))))
9874 ;; And add the last unread articles.
9875 (while (<= first last)
9876 (setq unread (cons first unread))
9877 (setq first (1+ first)))
9878 ;; Return the list of unread articles.
9881 (defun gnus-list-of-read-articles (group)
9882 "Return a list of unread, unticked and non-dormant articles."
9883 (let* ((info (gnus-get-info group))
9884 (marked (gnus-info-marks info))
9885 (active (gnus-active group)))
9887 (gnus-set-difference
9888 (gnus-sorted-complement
9889 (gnus-uncompress-range active)
9890 (gnus-list-of-unread-articles group))
9892 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9893 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9895 ;; Various summary commands
9897 (defun gnus-summary-universal-argument (arg)
9898 "Perform any operation on all articles that are process/prefixed."
9900 (gnus-set-global-variables)
9901 (let ((articles (gnus-summary-work-articles arg))
9908 (substitute-command-keys
9909 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9912 (gnus-error 1 "Undefined key")
9915 (gnus-summary-goto-subject (setq article (pop articles)))
9916 (command-execute func)
9917 (gnus-summary-remove-process-mark article)))))
9918 (gnus-summary-position-point))
9920 (defun gnus-summary-toggle-truncation (&optional arg)
9921 "Toggle truncation of summary lines.
9922 With arg, turn line truncation on iff arg is positive."
9924 (setq truncate-lines
9925 (if (null arg) (not truncate-lines)
9926 (> (prefix-numeric-value arg) 0)))
9929 (defun gnus-summary-reselect-current-group (&optional all rescan)
9930 "Exit and then reselect the current newsgroup.
9931 The prefix argument ALL means to select all articles."
9933 (gnus-set-global-variables)
9934 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9935 (error "Ephemeral groups can't be reselected"))
9936 (let ((current-subject (gnus-summary-article-number))
9937 (group gnus-newsgroup-name))
9938 (setq gnus-newsgroup-begin nil)
9940 ;; We have to adjust the point of group mode buffer because the
9941 ;; current point was moved to the next unread newsgroup by
9943 (gnus-summary-jump-to-group group)
9946 (gnus-group-get-new-news-this-group 1)))
9947 (gnus-group-read-group all t)
9948 (gnus-summary-goto-subject current-subject nil t)))
9950 (defun gnus-summary-rescan-group (&optional all)
9951 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9953 (gnus-summary-reselect-current-group all t))
9955 (defun gnus-summary-update-info ()
9956 (let* ((group gnus-newsgroup-name))
9957 (when gnus-newsgroup-kill-headers
9958 (setq gnus-newsgroup-killed
9959 (gnus-compress-sequence
9961 (gnus-set-sorted-intersection
9962 (gnus-uncompress-range gnus-newsgroup-killed)
9963 (setq gnus-newsgroup-unselected
9964 (sort gnus-newsgroup-unselected '<)))
9965 (setq gnus-newsgroup-unreads
9966 (sort gnus-newsgroup-unreads '<))) t)))
9967 (unless (listp (cdr gnus-newsgroup-killed))
9968 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9969 (let ((headers gnus-newsgroup-headers))
9970 (run-hooks 'gnus-exit-group-hook)
9971 (unless gnus-save-score
9972 (setq gnus-newsgroup-scored nil))
9973 ;; Set the new ranges of read articles.
9974 (gnus-update-read-articles
9975 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9976 ;; Set the current article marks.
9978 ;; Do the cross-ref thing.
9979 (when gnus-use-cross-reference
9980 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9981 ;; Do adaptive scoring, and possibly save score files.
9982 (when gnus-newsgroup-adaptive
9983 (gnus-score-adaptive))
9984 (when gnus-use-scoring
9986 ;; Do not switch windows but change the buffer to work.
9987 (set-buffer gnus-group-buffer)
9988 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9989 (gnus-group-update-group group)))))
9991 (defun gnus-summary-exit (&optional temporary)
9992 "Exit reading current newsgroup, and then return to group selection mode.
9993 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9995 (gnus-set-global-variables)
9996 (gnus-kill-save-kill-buffer)
9997 (let* ((group gnus-newsgroup-name)
9998 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
10000 (buf (current-buffer)))
10001 (run-hooks 'gnus-summary-prepare-exit-hook)
10002 ;; If we have several article buffers, we kill them at exit.
10003 (unless gnus-single-article-buffer
10004 (gnus-kill-buffer gnus-original-article-buffer)
10005 (setq gnus-article-current nil))
10006 (when gnus-use-cache
10007 (gnus-cache-possibly-remove-articles)
10008 (gnus-cache-save-buffers))
10009 (when gnus-use-trees
10010 (gnus-tree-close group))
10011 ;; Make all changes in this group permanent.
10012 (unless quit-config
10013 (gnus-summary-update-info))
10014 (gnus-close-group group)
10015 ;; Make sure where I was, and go to next newsgroup.
10016 (set-buffer gnus-group-buffer)
10017 (unless quit-config
10018 (gnus-group-jump-to-group group))
10019 (run-hooks 'gnus-summary-exit-hook)
10020 (unless quit-config
10021 (gnus-group-next-unread-group 1))
10023 nil ;Nothing to do.
10024 ;; If we have several article buffers, we kill them at exit.
10025 (unless gnus-single-article-buffer
10026 (gnus-kill-buffer gnus-article-buffer)
10027 (gnus-kill-buffer gnus-original-article-buffer)
10028 (setq gnus-article-current nil))
10030 (if (not gnus-kill-summary-on-exit)
10031 (gnus-deaden-summary)
10032 ;; We set all buffer-local variables to nil. It is unclear why
10033 ;; this is needed, but if we don't, buffer-local variables are
10034 ;; not garbage-collected, it seems. This would the lead to en
10035 ;; ever-growing Emacs.
10036 (gnus-summary-clear-local-variables)
10037 (when (get-buffer gnus-article-buffer)
10038 (bury-buffer gnus-article-buffer))
10039 ;; We clear the global counterparts of the buffer-local
10040 ;; variables as well, just to be on the safe side.
10041 (gnus-configure-windows 'group 'force)
10042 (gnus-summary-clear-local-variables)
10043 ;; Return to group mode buffer.
10044 (if (eq mode 'gnus-summary-mode)
10045 (gnus-kill-buffer buf)))
10046 (setq gnus-current-select-method gnus-select-method)
10047 (pop-to-buffer gnus-group-buffer)
10048 ;; Clear the current group name.
10049 (if (not quit-config)
10051 (gnus-group-jump-to-group group)
10052 (gnus-group-next-unread-group 1)
10053 (gnus-configure-windows 'group 'force))
10054 (if (not (buffer-name (car quit-config)))
10055 (gnus-configure-windows 'group 'force)
10056 (set-buffer (car quit-config))
10057 (and (eq major-mode 'gnus-summary-mode)
10058 (gnus-set-global-variables))
10059 (gnus-configure-windows (cdr quit-config))))
10060 (unless quit-config
10061 (setq gnus-newsgroup-name nil)))))
10063 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10064 (defun gnus-summary-exit-no-update (&optional no-questions)
10065 "Quit reading current newsgroup without updating read article info."
10067 (gnus-set-global-variables)
10068 (let* ((group gnus-newsgroup-name)
10069 (quit-config (gnus-group-quit-config group)))
10070 (when (or no-questions
10072 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10073 ;; If we have several article buffers, we kill them at exit.
10074 (unless gnus-single-article-buffer
10075 (gnus-kill-buffer gnus-article-buffer)
10076 (gnus-kill-buffer gnus-original-article-buffer)
10077 (setq gnus-article-current nil))
10078 (if (not gnus-kill-summary-on-exit)
10079 (gnus-deaden-summary)
10080 (gnus-close-group group)
10081 (gnus-summary-clear-local-variables)
10082 (set-buffer gnus-group-buffer)
10083 (gnus-summary-clear-local-variables)
10084 (when (get-buffer gnus-summary-buffer)
10085 (kill-buffer gnus-summary-buffer)))
10086 (unless gnus-single-article-buffer
10087 (setq gnus-article-current nil))
10088 (when gnus-use-trees
10089 (gnus-tree-close group))
10090 (when (get-buffer gnus-article-buffer)
10091 (bury-buffer gnus-article-buffer))
10092 ;; Return to the group buffer.
10093 (gnus-configure-windows 'group 'force)
10094 ;; Clear the current group name.
10095 (setq gnus-newsgroup-name nil)
10096 (when (equal (gnus-group-group-name) group)
10097 (gnus-group-next-unread-group 1))
10099 (if (not (buffer-name (car quit-config)))
10100 (gnus-configure-windows 'group 'force)
10101 (set-buffer (car quit-config))
10102 (when (eq major-mode 'gnus-summary-mode)
10103 (gnus-set-global-variables))
10104 (gnus-configure-windows (cdr quit-config)))))))
10106 ;;; Dead summaries.
10108 (defvar gnus-dead-summary-mode-map nil)
10110 (if gnus-dead-summary-mode-map
10112 (setq gnus-dead-summary-mode-map (make-keymap))
10113 (suppress-keymap gnus-dead-summary-mode-map)
10114 (substitute-key-definition
10115 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10116 (let ((keys '("\C-d" "\r" "\177")))
10118 (define-key gnus-dead-summary-mode-map
10119 (pop keys) 'gnus-summary-wake-up-the-dead))))
10121 (defvar gnus-dead-summary-mode nil
10122 "Minor mode for Gnus summary buffers.")
10124 (defun gnus-dead-summary-mode (&optional arg)
10125 "Minor mode for Gnus summary buffers."
10127 (when (eq major-mode 'gnus-summary-mode)
10128 (make-local-variable 'gnus-dead-summary-mode)
10129 (setq gnus-dead-summary-mode
10130 (if (null arg) (not gnus-dead-summary-mode)
10131 (> (prefix-numeric-value arg) 0)))
10132 (when gnus-dead-summary-mode
10133 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10134 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10135 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10136 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10137 minor-mode-map-alist)))))
10139 (defun gnus-deaden-summary ()
10140 "Make the current summary buffer into a dead summary buffer."
10141 ;; Kill any previous dead summary buffer.
10142 (when (and gnus-dead-summary
10143 (buffer-name gnus-dead-summary))
10145 (set-buffer gnus-dead-summary)
10146 (when gnus-dead-summary-mode
10147 (kill-buffer (current-buffer)))))
10148 ;; Make this the current dead summary.
10149 (setq gnus-dead-summary (current-buffer))
10150 (gnus-dead-summary-mode 1)
10151 (let ((name (buffer-name)))
10152 (when (string-match "Summary" name)
10154 (concat (substring name 0 (match-beginning 0)) "Dead "
10155 (substring name (match-beginning 0))) t))))
10157 (defun gnus-kill-or-deaden-summary (buffer)
10158 "Kill or deaden the summary BUFFER."
10159 (when (and (buffer-name buffer)
10160 (not gnus-single-article-buffer))
10162 (set-buffer buffer)
10163 (gnus-kill-buffer gnus-article-buffer)
10164 (gnus-kill-buffer gnus-original-article-buffer)))
10165 (cond (gnus-kill-summary-on-exit
10166 (when (and gnus-use-trees
10167 (and (get-buffer buffer)
10168 (buffer-name (get-buffer buffer))))
10170 (set-buffer (get-buffer buffer))
10171 (gnus-tree-close gnus-newsgroup-name)))
10172 (gnus-kill-buffer buffer))
10173 ((and (get-buffer buffer)
10174 (buffer-name (get-buffer buffer)))
10176 (set-buffer buffer)
10177 (gnus-deaden-summary)))))
10179 (defun gnus-summary-wake-up-the-dead (&rest args)
10180 "Wake up the dead summary buffer."
10182 (gnus-dead-summary-mode -1)
10183 (let ((name (buffer-name)))
10184 (when (string-match "Dead " name)
10186 (concat (substring name 0 (match-beginning 0))
10187 (substring name (match-end 0))) t)))
10188 (gnus-message 3 "This dead summary is now alive again"))
10190 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10191 (defun gnus-summary-fetch-faq (&optional faq-dir)
10192 "Fetch the FAQ for the current group.
10193 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10197 (if current-prefix-arg
10199 "Faq dir: " (and (listp gnus-group-faq-directory)
10200 gnus-group-faq-directory)))))
10201 (let (gnus-faq-buffer)
10202 (and (setq gnus-faq-buffer
10203 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10204 (gnus-configure-windows 'summary-faq))))
10206 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10207 (defun gnus-summary-describe-group (&optional force)
10208 "Describe the current newsgroup."
10210 (gnus-group-describe-group force gnus-newsgroup-name))
10212 (defun gnus-summary-describe-briefly ()
10213 "Describe summary mode commands briefly."
10216 (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")))
10218 ;; Walking around group mode buffer from summary mode.
10220 (defun gnus-summary-next-group (&optional no-article target-group backward)
10221 "Exit current newsgroup and then select next unread newsgroup.
10222 If prefix argument NO-ARTICLE is non-nil, no article is selected
10223 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10224 previous group instead."
10226 (gnus-set-global-variables)
10227 (let ((current-group gnus-newsgroup-name)
10228 (current-buffer (current-buffer))
10230 ;; First we semi-exit this group to update Xrefs and all variables.
10231 ;; We can't do a real exit, because the window conf must remain
10232 ;; the same in case the user is prompted for info, and we don't
10233 ;; want the window conf to change before that...
10234 (gnus-summary-exit t)
10235 (while (not entered)
10236 ;; Then we find what group we are supposed to enter.
10237 (set-buffer gnus-group-buffer)
10238 (gnus-group-jump-to-group current-group)
10241 (if (eq gnus-keep-same-level 'best)
10242 (gnus-summary-best-group gnus-newsgroup-name)
10243 (gnus-summary-search-group backward gnus-keep-same-level))))
10244 (if (not target-group)
10245 ;; There are no further groups, so we return to the group
10248 (gnus-message 5 "Returning to the group buffer")
10250 (set-buffer current-buffer)
10251 (gnus-summary-exit))
10252 ;; We try to enter the target group.
10253 (gnus-group-jump-to-group target-group)
10254 (let ((unreads (gnus-group-group-unread)))
10255 (if (and (or (eq t unreads)
10256 (and unreads (not (zerop unreads))))
10257 (gnus-summary-read-group
10258 target-group nil no-article current-buffer))
10260 (setq current-group target-group
10261 target-group nil)))))))
10263 (defun gnus-summary-prev-group (&optional no-article)
10264 "Exit current newsgroup and then select previous unread newsgroup.
10265 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10267 (gnus-summary-next-group no-article nil t))
10269 ;; Walking around summary lines.
10271 (defun gnus-summary-first-subject (&optional unread)
10272 "Go to the first unread subject.
10273 If UNREAD is non-nil, go to the first unread article.
10274 Returns the article selected or nil if there are no unread articles."
10279 ((null gnus-newsgroup-data)
10280 (gnus-message 3 "No articles in the group")
10282 ;; Pick the first article.
10284 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10285 (gnus-data-number (car gnus-newsgroup-data)))
10286 ;; No unread articles.
10287 ((null gnus-newsgroup-unreads)
10288 (gnus-message 3 "No more unread articles")
10290 ;; Find the first unread article.
10292 (let ((data gnus-newsgroup-data))
10294 (not (gnus-data-unread-p (car data))))
10295 (setq data (cdr data)))
10298 (goto-char (gnus-data-pos (car data)))
10299 (gnus-data-number (car data)))))))
10300 (gnus-summary-position-point)))
10302 (defun gnus-summary-next-subject (n &optional unread dont-display)
10303 "Go to next N'th summary line.
10304 If N is negative, go to the previous N'th subject line.
10305 If UNREAD is non-nil, only unread articles are selected.
10306 The difference between N and the actual number of steps taken is
10309 (let ((backward (< n 0))
10311 (while (and (> n 0)
10313 (gnus-summary-find-prev unread)
10314 (gnus-summary-find-next unread)))
10316 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10317 (if unread " unread" "")))
10318 (unless dont-display
10319 (gnus-summary-recenter)
10320 (gnus-summary-position-point))
10323 (defun gnus-summary-next-unread-subject (n)
10324 "Go to next N'th unread summary line."
10326 (gnus-summary-next-subject n t))
10328 (defun gnus-summary-prev-subject (n &optional unread)
10329 "Go to previous N'th summary line.
10330 If optional argument UNREAD is non-nil, only unread article is selected."
10332 (gnus-summary-next-subject (- n) unread))
10334 (defun gnus-summary-prev-unread-subject (n)
10335 "Go to previous N'th unread summary line."
10337 (gnus-summary-next-subject (- n) t))
10339 (defun gnus-summary-goto-subject (article &optional force silent)
10340 "Go the subject line of ARTICLE.
10341 If FORCE, also allow jumping to articles not currently shown."
10343 (data (gnus-data-find article)))
10344 ;; We read in the article if we have to.
10347 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10348 (setq data (gnus-data-find article)))
10353 (gnus-message 3 "Can't find article %d" article))
10355 (goto-char (gnus-data-pos data))
10358 ;; Walking around summary lines with displaying articles.
10360 (defun gnus-summary-expand-window (&optional arg)
10361 "Make the summary buffer take up the entire Emacs frame.
10362 Given a prefix, will force an `article' buffer configuration."
10364 (gnus-set-global-variables)
10366 (gnus-configure-windows 'article 'force)
10367 (gnus-configure-windows 'summary 'force)))
10369 (defun gnus-summary-display-article (article &optional all-header)
10370 "Display ARTICLE in article buffer."
10371 (gnus-set-global-variables)
10375 (if gnus-summary-display-article-function
10376 (funcall gnus-summary-display-article-function article all-header)
10377 (gnus-article-prepare article all-header))
10378 (run-hooks 'gnus-select-article-hook)
10379 (unless (zerop gnus-current-article)
10380 (gnus-summary-goto-subject gnus-current-article))
10381 (gnus-summary-recenter)
10382 (when gnus-use-trees
10383 (gnus-possibly-generate-tree article)
10384 (gnus-highlight-selected-tree article))
10385 ;; Successfully display article.
10386 (gnus-article-set-window-start
10387 (cdr (assq article gnus-newsgroup-bookmarks))))))
10389 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10390 "Select the current article.
10391 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10392 non-nil, the article will be re-fetched even if it already present in
10393 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10395 ;; Make sure we are in the summary buffer to work around bbdb bug.
10396 (unless (eq major-mode 'gnus-summary-mode)
10397 (set-buffer gnus-summary-buffer))
10398 (let ((article (or article (gnus-summary-article-number)))
10399 (all-headers (not (not all-headers))) ;Must be T or NIL.
10400 gnus-summary-display-article-function
10403 (gnus-summary-article-pseudo-p article)
10404 (error "This is a pseudo-article."))
10407 (set-buffer gnus-summary-buffer)
10408 (if (or (and gnus-single-article-buffer
10409 (or (null gnus-current-article)
10410 (null gnus-article-current)
10411 (null (get-buffer gnus-article-buffer))
10412 (not (eq article (cdr gnus-article-current)))
10413 (not (equal (car gnus-article-current)
10414 gnus-newsgroup-name))))
10415 (and (not gnus-single-article-buffer)
10416 (or (null gnus-current-article)
10417 (not (eq gnus-current-article article))))
10419 ;; The requested article is different from the current article.
10421 (gnus-summary-display-article article all-headers)
10422 (setq did article))
10423 (if (or all-headers gnus-show-all-headers)
10424 (gnus-article-show-all-headers))
10427 (gnus-article-set-window-start
10428 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10430 (defun gnus-summary-set-current-mark (&optional current-mark)
10431 "Obsolete function."
10434 (defun gnus-summary-next-article (&optional unread subject backward push)
10435 "Select the next article.
10436 If UNREAD, only unread articles are selected.
10437 If SUBJECT, only articles with SUBJECT are selected.
10438 If BACKWARD, the previous article is selected instead of the next."
10440 (gnus-set-global-variables)
10442 ;; Is there such an article?
10443 ((and (gnus-summary-search-forward unread subject backward)
10444 (or (gnus-summary-display-article (gnus-summary-article-number))
10445 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10446 (gnus-summary-position-point))
10447 ;; If not, we try the first unread, if that is wanted.
10449 gnus-auto-select-same
10450 (gnus-summary-first-unread-article))
10451 (gnus-summary-position-point)
10452 (gnus-message 6 "Wrapped"))
10453 ;; Try to get next/previous article not displayed in this group.
10454 ((and gnus-auto-extend-newsgroup
10455 (not unread) (not subject))
10456 (gnus-summary-goto-article
10457 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10459 ;; Go to next/previous group.
10461 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10462 (gnus-summary-jump-to-group gnus-newsgroup-name))
10463 (let ((cmd last-command-char)
10465 (if (eq gnus-keep-same-level 'best)
10466 (gnus-summary-best-group gnus-newsgroup-name)
10467 (gnus-summary-search-group backward gnus-keep-same-level))))
10468 ;; For some reason, the group window gets selected. We change
10470 (select-window (get-buffer-window (current-buffer)))
10471 ;; Select next unread newsgroup automagically.
10473 ((or (not gnus-auto-select-next)
10475 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10476 ((or (eq gnus-auto-select-next 'quietly)
10477 (and (eq gnus-auto-select-next 'slightly-quietly)
10479 (and (eq gnus-auto-select-next 'almost-quietly)
10480 (gnus-summary-last-article-p)))
10482 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10483 (gnus-summary-exit)
10484 (gnus-message 7 "No more%s articles (%s)..."
10485 (if unread " unread" "")
10486 (if group (concat "selecting " group)
10488 (gnus-summary-next-group nil group backward)))
10490 (gnus-summary-walk-group-buffer
10491 gnus-newsgroup-name cmd unread backward)))))))
10493 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10494 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10495 (?\C-p (gnus-group-prev-unread-group 1))))
10496 keve key group ended)
10498 (set-buffer gnus-group-buffer)
10499 (gnus-summary-jump-to-group from-group)
10501 (if (eq gnus-keep-same-level 'best)
10502 (gnus-summary-best-group gnus-newsgroup-name)
10503 (gnus-summary-search-group backward gnus-keep-same-level))))
10506 5 "No more%s articles%s" (if unread " unread" "")
10508 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10509 (format " (Type %s for %s [%s])"
10510 (single-key-description cmd) group
10511 (car (gnus-gethash group gnus-newsrc-hashtb)))
10512 (format " (Type %s to exit %s)"
10513 (single-key-description cmd)
10514 gnus-newsgroup-name)))
10515 ;; Confirm auto selection.
10516 (setq key (car (setq keve (gnus-read-event-char))))
10519 ((assq key keystrokes)
10520 (let ((obuf (current-buffer)))
10521 (switch-to-buffer gnus-group-buffer)
10523 (gnus-group-jump-to-group group))
10524 (eval (cadr (assq key keystrokes)))
10525 (setq group (gnus-group-group-name))
10526 (switch-to-buffer obuf))
10529 (if (or (not group)
10530 (gnus-ephemeral-group-p gnus-newsgroup-name))
10531 (gnus-summary-exit)
10532 (gnus-summary-next-group nil group backward)))
10534 (push (cdr keve) unread-command-events))))))
10536 (defun gnus-read-event-char ()
10537 "Get the next event."
10538 (let ((event (read-event)))
10539 (cons (and (numberp event) event) event)))
10541 (defun gnus-summary-next-unread-article ()
10542 "Select unread article after current one."
10544 (gnus-summary-next-article t (and gnus-auto-select-same
10545 (gnus-summary-article-subject))))
10547 (defun gnus-summary-prev-article (&optional unread subject)
10548 "Select the article after the current one.
10549 If UNREAD is non-nil, only unread articles are selected."
10551 (gnus-summary-next-article unread subject t))
10553 (defun gnus-summary-prev-unread-article ()
10554 "Select unred article before current one."
10556 (gnus-summary-prev-article t (and gnus-auto-select-same
10557 (gnus-summary-article-subject))))
10559 (defun gnus-summary-next-page (&optional lines circular)
10560 "Show next page of the selected article.
10561 If at the end of the current article, select the next article.
10562 LINES says how many lines should be scrolled up.
10564 If CIRCULAR is non-nil, go to the start of the article instead of
10565 selecting the next article when reaching the end of the current
10568 (setq gnus-summary-buffer (current-buffer))
10569 (gnus-set-global-variables)
10570 (let ((article (gnus-summary-article-number))
10572 (gnus-configure-windows 'article)
10573 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10574 (if (and (eq gnus-summary-goto-unread 'never)
10575 (not (gnus-summary-last-article-p article)))
10576 (gnus-summary-next-article)
10577 (gnus-summary-next-unread-article))
10578 (if (or (null gnus-current-article)
10579 (null gnus-article-current)
10580 (/= article (cdr gnus-article-current))
10581 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10582 ;; Selected subject is different from current article's.
10583 (gnus-summary-display-article article)
10584 (gnus-eval-in-buffer-window gnus-article-buffer
10585 (setq endp (gnus-article-next-page lines)))
10588 (gnus-summary-beginning-of-article))
10590 (gnus-message 3 "End of message"))
10592 (if (and (eq gnus-summary-goto-unread 'never)
10593 (not (gnus-summary-last-article-p article)))
10594 (gnus-summary-next-article)
10595 (gnus-summary-next-unread-article)))))))
10596 (gnus-summary-recenter)
10597 (gnus-summary-position-point)))
10599 (defun gnus-summary-prev-page (&optional lines)
10600 "Show previous page of selected article.
10601 Argument LINES specifies lines to be scrolled down."
10603 (gnus-set-global-variables)
10604 (let ((article (gnus-summary-article-number)))
10605 (gnus-configure-windows 'article)
10606 (if (or (null gnus-current-article)
10607 (null gnus-article-current)
10608 (/= article (cdr gnus-article-current))
10609 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10610 ;; Selected subject is different from current article's.
10611 (gnus-summary-display-article article)
10612 (gnus-summary-recenter)
10613 (gnus-eval-in-buffer-window gnus-article-buffer
10614 (gnus-article-prev-page lines))))
10615 (gnus-summary-position-point))
10617 (defun gnus-summary-scroll-up (lines)
10618 "Scroll up (or down) one line current article.
10619 Argument LINES specifies lines to be scrolled up (or down if negative)."
10621 (gnus-set-global-variables)
10622 (gnus-configure-windows 'article)
10623 (gnus-summary-show-thread)
10624 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10625 (gnus-eval-in-buffer-window gnus-article-buffer
10627 (if (gnus-article-next-page lines)
10628 (gnus-message 3 "End of message")))
10630 (gnus-article-prev-page (- lines))))))
10631 (gnus-summary-recenter)
10632 (gnus-summary-position-point))
10634 (defun gnus-summary-next-same-subject ()
10635 "Select next article which has the same subject as current one."
10637 (gnus-set-global-variables)
10638 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10640 (defun gnus-summary-prev-same-subject ()
10641 "Select previous article which has the same subject as current one."
10643 (gnus-set-global-variables)
10644 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10646 (defun gnus-summary-next-unread-same-subject ()
10647 "Select next unread article which has the same subject as current one."
10649 (gnus-set-global-variables)
10650 (gnus-summary-next-article t (gnus-summary-article-subject)))
10652 (defun gnus-summary-prev-unread-same-subject ()
10653 "Select previous unread article which has the same subject as current one."
10655 (gnus-set-global-variables)
10656 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10658 (defun gnus-summary-first-unread-article ()
10659 "Select the first unread article.
10660 Return nil if there are no unread articles."
10662 (gnus-set-global-variables)
10664 (if (gnus-summary-first-subject t)
10666 (gnus-summary-show-thread)
10667 (gnus-summary-first-subject t)
10668 (gnus-summary-display-article (gnus-summary-article-number))))
10669 (gnus-summary-position-point)))
10671 (defun gnus-summary-best-unread-article ()
10672 "Select the unread article with the highest score."
10674 (gnus-set-global-variables)
10675 (let ((best -1000000)
10676 (data gnus-newsgroup-data)
10679 (and (gnus-data-unread-p (car data))
10681 (gnus-summary-article-score (gnus-data-number (car data))))
10684 article (gnus-data-number (car data))))
10685 (setq data (cdr data)))
10688 (gnus-summary-goto-article article)
10689 (error "No unread articles"))
10690 (gnus-summary-position-point))))
10692 (defun gnus-summary-last-subject ()
10693 "Go to the last displayed subject line in the group."
10694 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10696 (gnus-summary-goto-subject article))))
10698 (defun gnus-summary-goto-article (article &optional all-headers force)
10699 "Fetch ARTICLE and display it if it exists.
10700 If ALL-HEADERS is non-nil, no header lines are hidden."
10706 (mapcar (lambda (number) (list (int-to-string number)))
10707 gnus-newsgroup-limit)))
10711 (if (gnus-summary-goto-subject article force)
10712 (gnus-summary-display-article article all-headers)
10713 (gnus-message 4 "Couldn't go to article %s" article) nil)
10714 (gnus-summary-position-point)))
10716 (defun gnus-summary-goto-last-article ()
10717 "Go to the previously read article."
10720 (and gnus-last-article
10721 (gnus-summary-goto-article gnus-last-article))
10722 (gnus-summary-position-point)))
10724 (defun gnus-summary-pop-article (number)
10725 "Pop one article off the history and go to the previous.
10726 NUMBER articles will be popped off."
10729 (setq gnus-newsgroup-history
10730 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10732 (gnus-summary-goto-article (car to))
10733 (error "Article history empty")))
10734 (gnus-summary-position-point))
10736 ;; Summary commands and functions for limiting the summary buffer.
10738 (defun gnus-summary-limit-to-articles (n)
10739 "Limit the summary buffer to the next N articles.
10740 If not given a prefix, use the process marked articles instead."
10742 (gnus-set-global-variables)
10744 (let ((articles (gnus-summary-work-articles n)))
10745 (setq gnus-newsgroup-processable nil)
10746 (gnus-summary-limit articles))
10747 (gnus-summary-position-point)))
10749 (defun gnus-summary-pop-limit (&optional total)
10750 "Restore the previous limit.
10751 If given a prefix, remove all limits."
10753 (gnus-set-global-variables)
10755 (setq gnus-newsgroup-limits
10756 (list (mapcar (lambda (h) (mail-header-number h))
10757 gnus-newsgroup-headers))))
10758 (unless gnus-newsgroup-limits
10759 (error "No limit to pop"))
10761 (gnus-summary-limit nil 'pop)
10762 (gnus-summary-position-point)))
10764 (defun gnus-summary-limit-to-subject (subject &optional header)
10765 "Limit the summary buffer to articles that have subjects that match a regexp."
10766 (interactive "sRegexp: ")
10768 (setq header "subject"))
10769 (when (not (equal "" subject))
10771 (let ((articles (gnus-summary-find-matching
10772 (or header "subject") subject 'all)))
10773 (or articles (error "Found no matches for \"%s\"" subject))
10774 (gnus-summary-limit articles))
10775 (gnus-summary-position-point))))
10777 (defun gnus-summary-limit-to-author (from)
10778 "Limit the summary buffer to articles that have authors that match a regexp."
10779 (interactive "sRegexp: ")
10780 (gnus-summary-limit-to-subject from "from"))
10782 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10784 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10786 (defun gnus-summary-limit-to-unread (&optional all)
10787 "Limit the summary buffer to articles that are not marked as read.
10788 If ALL is non-nil, limit strictly to unread articles."
10791 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10792 (gnus-summary-limit-to-marks
10793 ;; Concat all the marks that say that an article is read and have
10795 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10796 gnus-killed-mark gnus-kill-file-mark
10797 gnus-low-score-mark gnus-expirable-mark
10798 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10801 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10802 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10804 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10805 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10806 If REVERSE, limit the summary buffer to articles that are not marked
10807 with MARKS. MARKS can either be a string of marks or a list of marks.
10808 Returns how many articles were removed."
10809 (interactive "sMarks: ")
10810 (gnus-set-global-variables)
10812 (let ((data gnus-newsgroup-data)
10813 (marks (if (listp marks) marks
10814 (append marks nil))) ; Transform to list.
10817 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10818 (memq (gnus-data-mark (car data)) marks))
10819 (setq articles (cons (gnus-data-number (car data)) articles)))
10820 (setq data (cdr data)))
10821 (gnus-summary-limit articles))
10822 (gnus-summary-position-point)))
10824 (defun gnus-summary-limit-to-score (&optional score)
10825 "Limit to articles with score at or above SCORE."
10827 (gnus-set-global-variables)
10828 (setq score (if score
10829 (prefix-numeric-value score)
10830 (or gnus-summary-default-score 0)))
10831 (let ((data gnus-newsgroup-data)
10834 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10836 (push (gnus-data-number (car data)) articles))
10837 (setq data (cdr data)))
10839 (gnus-summary-limit articles)
10840 (gnus-summary-position-point))))
10842 (defun gnus-summary-limit-include-dormant ()
10843 "Display all the hidden articles that are marked as dormant."
10845 (gnus-set-global-variables)
10846 (or gnus-newsgroup-dormant
10847 (error "There are no dormant articles in this group"))
10849 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10850 (gnus-summary-position-point)))
10852 (defun gnus-summary-limit-exclude-dormant ()
10853 "Hide all dormant articles."
10855 (gnus-set-global-variables)
10857 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10858 (gnus-summary-position-point)))
10860 (defun gnus-summary-limit-exclude-childless-dormant ()
10861 "Hide all dormant articles that have no children."
10863 (gnus-set-global-variables)
10864 (let ((data (gnus-data-list t))
10865 articles d children)
10866 ;; Find all articles that are either not dormant or have
10868 (while (setq d (pop data))
10869 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10870 (and (setq children
10871 (gnus-article-children (gnus-data-number d)))
10874 (when (memq (car children) articles)
10879 (push (gnus-data-number d) articles)))
10880 ;; Do the limiting.
10882 (gnus-summary-limit articles)
10883 (gnus-summary-position-point))))
10885 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10886 "Mark all unread excluded articles as read.
10887 If ALL, mark even excluded ticked and dormants as read."
10889 (let ((articles (gnus-sorted-complement
10891 (mapcar (lambda (h) (mail-header-number h))
10892 gnus-newsgroup-headers)
10894 (sort gnus-newsgroup-limit '<)))
10896 (setq gnus-newsgroup-unreads nil)
10898 (setq gnus-newsgroup-dormant nil
10899 gnus-newsgroup-marked nil
10900 gnus-newsgroup-reads
10902 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10903 gnus-newsgroup-reads))
10904 (while (setq article (pop articles))
10905 (unless (or (memq article gnus-newsgroup-dormant)
10906 (memq article gnus-newsgroup-marked))
10907 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10909 (defun gnus-summary-limit (articles &optional pop)
10911 ;; We pop the previous limit off the stack and use that.
10912 (setq articles (car gnus-newsgroup-limits)
10913 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10914 ;; We use the new limit, so we push the old limit on the stack.
10915 (setq gnus-newsgroup-limits
10916 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10918 (setq gnus-newsgroup-limit articles)
10919 (let ((total (length gnus-newsgroup-data))
10920 (data (gnus-data-find-list (gnus-summary-article-number)))
10921 (gnus-summary-mark-below nil) ; Inhibit this.
10923 ;; This will do all the work of generating the new summary buffer
10924 ;; according to the new limit.
10925 (gnus-summary-prepare)
10926 ;; Hide any threads, possibly.
10927 (and gnus-show-threads
10928 gnus-thread-hide-subtree
10929 (gnus-summary-hide-all-threads))
10930 ;; Try to return to the article you were at, or one in the
10933 ;; We try to find some article after the current one.
10935 (and (gnus-summary-goto-subject
10936 (gnus-data-number (car data)) nil t)
10939 (setq data (cdr data))))
10941 ;; If there is no data, that means that we were after the last
10942 ;; article. The same goes when we can't find any articles
10943 ;; after the current one.
10945 (goto-char (point-max))
10946 (gnus-summary-find-prev)))
10947 ;; We return how many articles were removed from the summary
10948 ;; buffer as a result of the new limit.
10949 (- total (length gnus-newsgroup-data))))
10951 (defsubst gnus-invisible-cut-children (threads)
10954 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10959 (defsubst gnus-cut-thread (thread)
10960 "Go forwards in the thread until we find an article that we want to display."
10961 (when (or (eq gnus-fetch-old-headers 'some)
10962 (eq gnus-build-sparse-threads 'some)
10963 (eq gnus-build-sparse-threads 'more))
10964 ;; Deal with old-fetched headers and sparse threads.
10968 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10969 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10970 (or (<= (length (cdr thread)) 1)
10971 (gnus-invisible-cut-children (cdr thread))))
10972 (setq thread (cadr thread))))
10975 (defun gnus-cut-threads (threads)
10976 "Cut off all uninteresting articles from the beginning of threads."
10977 (when (or (eq gnus-fetch-old-headers 'some)
10978 (eq gnus-build-sparse-threads 'some)
10979 (eq gnus-build-sparse-threads 'more))
10980 (let ((th threads))
10982 (setcar th (gnus-cut-thread (car th)))
10983 (setq th (cdr th)))))
10984 ;; Remove nixed out threads.
10985 (delq nil threads))
10987 (defun gnus-summary-initial-limit (&optional show-if-empty)
10988 "Figure out what the initial limit is supposed to be on group entry.
10989 This entails weeding out unwanted dormants, low-scored articles,
10990 fetch-old-headers verbiage, and so on."
10991 ;; Most groups have nothing to remove.
10992 (if (or gnus-inhibit-limiting
10993 (and (null gnus-newsgroup-dormant)
10994 (not (eq gnus-fetch-old-headers 'some))
10995 (null gnus-summary-expunge-below)
10996 (not (eq gnus-build-sparse-threads 'some))
10997 (not (eq gnus-build-sparse-threads 'more))
10998 (null gnus-thread-expunge-below)
10999 (not gnus-use-nocem)))
11001 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11002 (setq gnus-newsgroup-limit nil)
11005 (unless (car (symbol-value node))
11006 ;; These threads have no parents -- they are roots.
11007 (let ((nodes (cdr (symbol-value node)))
11010 (if (and gnus-thread-expunge-below
11011 (< (gnus-thread-total-score (car nodes))
11012 gnus-thread-expunge-below))
11013 (gnus-expunge-thread (pop nodes))
11014 (setq thread (pop nodes))
11015 (gnus-summary-limit-children thread))))))
11016 gnus-newsgroup-dependencies)
11017 ;; If this limitation resulted in an empty group, we might
11018 ;; pop the previous limit and use it instead.
11019 (when (and (not gnus-newsgroup-limit)
11021 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
11022 gnus-newsgroup-limit))
11024 (defun gnus-summary-limit-children (thread)
11025 "Return 1 if this subthread is visible and 0 if it is not."
11026 ;; First we get the number of visible children to this thread. This
11027 ;; is done by recursing down the thread using this function, so this
11028 ;; will really go down to a leaf article first, before slowly
11029 ;; working its way up towards the root.
11033 (apply '+ (mapcar 'gnus-summary-limit-children
11036 (number (mail-header-number (car thread)))
11039 ;; If this article is dormant and has absolutely no visible
11040 ;; children, then this article isn't visible.
11041 (and (memq number gnus-newsgroup-dormant)
11043 ;; If this is "fetch-old-headered" and there is only one
11044 ;; visible child (or less), then we don't want this article.
11045 (and (eq gnus-fetch-old-headers 'some)
11046 (memq number gnus-newsgroup-ancient)
11048 ;; If this is a sparsely inserted article with no children,
11049 ;; we don't want it.
11050 (and (eq gnus-build-sparse-threads 'some)
11051 (memq number gnus-newsgroup-sparse)
11053 ;; If we use expunging, and this article is really
11054 ;; low-scored, then we don't want this article.
11055 (when (and gnus-summary-expunge-below
11057 (or (cdr (assq number gnus-newsgroup-scored))
11058 gnus-summary-default-score))
11059 gnus-summary-expunge-below))
11060 ;; We increase the expunge-tally here, but that has
11061 ;; nothing to do with the limits, really.
11062 (incf gnus-newsgroup-expunged-tally)
11063 ;; We also mark as read here, if that's wanted.
11064 (when (and gnus-summary-mark-below
11065 (< score gnus-summary-mark-below))
11066 (setq gnus-newsgroup-unreads
11067 (delq number gnus-newsgroup-unreads))
11068 (if gnus-newsgroup-auto-expire
11069 (push number gnus-newsgroup-expirable)
11070 (push (cons number gnus-low-score-mark)
11071 gnus-newsgroup-reads)))
11073 (and gnus-use-nocem
11074 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11075 ;; Nope, invisible article.
11077 ;; Ok, this article is to be visible, so we add it to the limit
11079 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11082 (defun gnus-expunge-thread (thread)
11083 "Mark all articles in THREAD as read."
11084 (let* ((number (mail-header-number (car thread))))
11085 (incf gnus-newsgroup-expunged-tally)
11086 ;; We also mark as read here, if that's wanted.
11087 (setq gnus-newsgroup-unreads
11088 (delq number gnus-newsgroup-unreads))
11089 (if gnus-newsgroup-auto-expire
11090 (push number gnus-newsgroup-expirable)
11091 (push (cons number gnus-low-score-mark)
11092 gnus-newsgroup-reads)))
11093 ;; Go recursively through all subthreads.
11094 (mapcar 'gnus-expunge-thread (cdr thread)))
11096 ;; Summary article oriented commands
11098 (defun gnus-summary-refer-parent-article (n)
11099 "Refer parent article N times.
11100 The difference between N and the number of articles fetched is returned."
11102 (gnus-set-global-variables)
11106 (let* ((header (gnus-summary-article-header))
11108 ;; If we try to find the parent of the currently
11109 ;; displayed article, then we take a look at the actual
11110 ;; References header, since this is slightly more
11111 ;; reliable than the References field we got from the
11113 (if (and (eq (mail-header-number header)
11114 (cdr gnus-article-current))
11115 (equal gnus-newsgroup-name
11116 (car gnus-article-current)))
11118 (set-buffer gnus-original-article-buffer)
11119 (nnheader-narrow-to-headers)
11121 (message-fetch-field "references")
11123 ;; It's not the current article, so we take a bet on
11124 ;; the value we got from the server.
11125 (mail-header-references header))))
11126 (if (setq ref (or ref (mail-header-references header)))
11127 (or (gnus-summary-refer-article (gnus-parent-id ref))
11128 (gnus-message 1 "Couldn't find parent"))
11129 (gnus-message 1 "No references in article %d"
11130 (gnus-summary-article-number))
11133 (gnus-summary-position-point)
11136 (defun gnus-summary-refer-references ()
11137 "Fetch all articles mentioned in the References header.
11138 Return how many articles were fetched."
11140 (gnus-set-global-variables)
11141 (let ((ref (mail-header-references (gnus-summary-article-header)))
11142 (current (gnus-summary-article-number))
11144 ;; For each Message-ID in the References header...
11145 (while (string-match "<[^>]*>" ref)
11147 ;; ... fetch that article.
11148 (gnus-summary-refer-article
11149 (prog1 (match-string 0 ref)
11150 (setq ref (substring ref (match-end 0))))))
11151 (gnus-summary-goto-subject current)
11152 (gnus-summary-position-point)
11155 (defun gnus-summary-refer-article (message-id)
11156 "Fetch an article specified by MESSAGE-ID."
11157 (interactive "sMessage-ID: ")
11158 (when (and (stringp message-id)
11159 (not (zerop (length message-id))))
11160 ;; Construct the correct Message-ID if necessary.
11161 ;; Suggested by tale@pawl.rpi.edu.
11162 (unless (string-match "^<" message-id)
11163 (setq message-id (concat "<" message-id)))
11164 (unless (string-match ">$" message-id)
11165 (setq message-id (concat message-id ">")))
11166 (let* ((header (gnus-id-to-header message-id))
11167 (sparse (and header
11168 (memq (mail-header-number header)
11169 gnus-newsgroup-sparse))))
11172 ;; The article is present in the buffer, to we just go to it.
11173 (gnus-summary-goto-article
11174 (mail-header-number header) nil header)
11176 (gnus-summary-update-article (mail-header-number header))))
11177 ;; We fetch the article
11178 (let ((gnus-override-method
11179 (and (gnus-news-group-p gnus-newsgroup-name)
11180 gnus-refer-article-method))
11182 ;; Start the special refer-article method, if necessary.
11183 (when (and gnus-refer-article-method
11184 (gnus-news-group-p gnus-newsgroup-name))
11185 (gnus-check-server gnus-refer-article-method))
11186 ;; Fetch the header, and display the article.
11187 (if (setq number (gnus-summary-insert-subject message-id))
11188 (gnus-summary-select-article nil nil nil number)
11189 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11191 (defun gnus-summary-enter-digest-group (&optional force)
11192 "Enter a digest group based on the current article."
11194 (gnus-set-global-variables)
11195 (gnus-summary-select-article)
11196 (let ((name (format "%s-%d"
11197 (gnus-group-prefixed-name
11198 gnus-newsgroup-name (list 'nndoc ""))
11199 gnus-current-article))
11200 (ogroup gnus-newsgroup-name)
11201 (case-fold-search t)
11202 (buf (current-buffer))
11205 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11206 (insert-buffer-substring gnus-original-article-buffer)
11208 (goto-char (point-min))
11209 (or (search-forward "\n\n" nil t) (point)))
11210 (goto-char (point-min))
11211 (delete-matching-lines "^\\(Path\\):\\|^From ")
11214 (if (gnus-group-read-ephemeral-group
11215 name `(nndoc ,name (nndoc-address
11217 (nndoc-article-type ,(if force 'digest 'guess))) t)
11218 ;; Make all postings to this group go to the parent group.
11219 (nconc (gnus-info-params (gnus-get-info name))
11220 (list (cons 'to-group ogroup)))
11221 ;; Couldn't select this doc group.
11222 (switch-to-buffer buf)
11223 (gnus-set-global-variables)
11224 (gnus-configure-windows 'summary)
11225 (gnus-message 3 "Article couldn't be entered?"))
11226 (kill-buffer dig))))
11228 (defun gnus-summary-isearch-article (&optional regexp-p)
11229 "Do incremental search forward on the current article.
11230 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11232 (gnus-set-global-variables)
11233 (gnus-summary-select-article)
11234 (gnus-configure-windows 'article)
11235 (gnus-eval-in-buffer-window gnus-article-buffer
11236 (goto-char (point-min))
11237 (isearch-forward regexp-p)))
11239 (defun gnus-summary-search-article-forward (regexp &optional backward)
11240 "Search for an article containing REGEXP forward.
11241 If BACKWARD, search backward instead."
11244 (format "Search article %s (regexp%s): "
11245 (if current-prefix-arg "backward" "forward")
11246 (if gnus-last-search-regexp
11247 (concat ", default " gnus-last-search-regexp)
11249 current-prefix-arg))
11250 (gnus-set-global-variables)
11251 (if (string-equal regexp "")
11252 (setq regexp (or gnus-last-search-regexp ""))
11253 (setq gnus-last-search-regexp regexp))
11254 (unless (gnus-summary-search-article regexp backward)
11255 (error "Search failed: \"%s\"" regexp)))
11257 (defun gnus-summary-search-article-backward (regexp)
11258 "Search for an article containing REGEXP backward."
11261 (format "Search article backward (regexp%s): "
11262 (if gnus-last-search-regexp
11263 (concat ", default " gnus-last-search-regexp)
11265 (gnus-summary-search-article-forward regexp 'backward))
11267 (defun gnus-summary-search-article (regexp &optional backward)
11268 "Search for an article containing REGEXP.
11269 Optional argument BACKWARD means do search for backward.
11270 `gnus-select-article-hook' is not called during the search."
11271 (let ((gnus-select-article-hook nil) ;Disable hook.
11272 (gnus-article-display-hook nil)
11273 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11276 're-search-backward 're-search-forward))
11277 (sum (current-buffer))
11279 (gnus-save-hidden-threads
11280 (gnus-summary-select-article)
11281 (set-buffer gnus-article-buffer)
11285 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11287 (re-search-backward regexp nil t)
11288 (re-search-forward regexp nil t))
11289 ;; We found the regexp.
11291 (setq found 'found)
11292 (beginning-of-line)
11294 (get-buffer-window (current-buffer))
11298 ;; We didn't find it, so we go to the next article.
11300 (if (not (if backward (gnus-summary-find-prev)
11301 (gnus-summary-find-next)))
11302 ;; No more articles.
11304 ;; Select the next article and adjust point.
11305 (gnus-summary-select-article)
11306 (set-buffer gnus-article-buffer)
11308 (goto-char (if backward (point-max) (point-min))))))
11309 (gnus-message 7 ""))
11310 ;; Return whether we found the regexp.
11311 (when (eq found 'found)
11312 (gnus-summary-show-thread)
11313 (gnus-summary-goto-subject gnus-current-article)
11314 (gnus-summary-position-point)
11317 (defun gnus-summary-find-matching (header regexp &optional backward unread
11319 "Return a list of all articles that match REGEXP on HEADER.
11320 The search stars on the current article and goes forwards unless
11321 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11322 If UNREAD is non-nil, only unread articles will
11323 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11324 in the comparisons."
11325 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11326 (gnus-data-find-list
11327 (gnus-summary-article-number) (gnus-data-list backward))))
11328 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11329 (case-fold-search (not not-case-fold))
11331 (or (fboundp (intern (concat "mail-header-" header)))
11332 (error "%s is not a valid header" header))
11334 (setq d (car data))
11335 (and (or (not unread) ; We want all articles...
11336 (gnus-data-unread-p d)) ; Or just unreads.
11337 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11338 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11339 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11340 (setq data (cdr data)))
11341 (nreverse articles)))
11343 (defun gnus-summary-execute-command (header regexp command &optional backward)
11344 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11345 If HEADER is an empty string (or nil), the match is done on the entire
11346 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11348 (list (let ((completion-ignore-case t))
11351 (mapcar (lambda (string) (list string))
11352 '("Number" "Subject" "From" "Lines" "Date"
11353 "Message-ID" "Xref" "References" "Body"))
11354 nil 'require-match))
11355 (read-string "Regexp: ")
11356 (read-key-sequence "Command: ")
11357 current-prefix-arg))
11358 (when (equal header "Body")
11360 (gnus-set-global-variables)
11361 ;; Hidden thread subtrees must be searched as well.
11362 (gnus-summary-show-all-threads)
11363 ;; We don't want to change current point nor window configuration.
11365 (save-window-excursion
11366 (gnus-message 6 "Executing %s..." (key-description command))
11367 ;; We'd like to execute COMMAND interactively so as to give arguments.
11368 (gnus-execute header regexp
11369 `(lambda () (call-interactively ',(key-binding command)))
11371 (gnus-message 6 "Executing %s...done" (key-description command)))))
11373 (defun gnus-summary-beginning-of-article ()
11374 "Scroll the article back to the beginning."
11376 (gnus-set-global-variables)
11377 (gnus-summary-select-article)
11378 (gnus-configure-windows 'article)
11379 (gnus-eval-in-buffer-window gnus-article-buffer
11381 (goto-char (point-min))
11382 (and gnus-break-pages (gnus-narrow-to-page))))
11384 (defun gnus-summary-end-of-article ()
11385 "Scroll to the end of the article."
11387 (gnus-set-global-variables)
11388 (gnus-summary-select-article)
11389 (gnus-configure-windows 'article)
11390 (gnus-eval-in-buffer-window gnus-article-buffer
11392 (goto-char (point-max))
11394 (and gnus-break-pages (gnus-narrow-to-page))))
11396 (defun gnus-summary-show-article (&optional arg)
11397 "Force re-fetching of the current article.
11398 If ARG (the prefix) is non-nil, show the raw article without any
11399 article massaging functions being run."
11401 (gnus-set-global-variables)
11403 ;; Select the article the normal way.
11404 (gnus-summary-select-article nil 'force)
11405 ;; Bind the article treatment functions to nil.
11406 (let ((gnus-have-all-headers t)
11407 gnus-article-display-hook
11408 gnus-article-prepare-hook
11411 (gnus-summary-select-article nil 'force)))
11412 (gnus-summary-goto-subject gnus-current-article)
11413 ; (gnus-configure-windows 'article)
11414 (gnus-summary-position-point))
11416 (defun gnus-summary-verbose-headers (&optional arg)
11417 "Toggle permanent full header display.
11418 If ARG is a positive number, turn header display on.
11419 If ARG is a negative number, turn header display off."
11421 (gnus-set-global-variables)
11422 (gnus-summary-toggle-header arg)
11423 (setq gnus-show-all-headers
11424 (cond ((or (not (numberp arg))
11426 (not gnus-show-all-headers))
11430 (defun gnus-summary-toggle-header (&optional arg)
11431 "Show the headers if they are hidden, or hide them if they are shown.
11432 If ARG is a positive number, show the entire header.
11433 If ARG is a negative number, hide the unwanted header lines."
11435 (gnus-set-global-variables)
11437 (set-buffer gnus-article-buffer)
11438 (let* ((buffer-read-only nil)
11439 (inhibit-point-motion-hooks t)
11440 (hidden (text-property-any
11441 (goto-char (point-min)) (search-forward "\n\n")
11444 (goto-char (point-min))
11445 (when (search-forward "\n\n" nil t)
11446 (delete-region (point-min) (1- (point))))
11447 (goto-char (point-min))
11449 (set-buffer gnus-original-article-buffer)
11450 (goto-char (point-min))
11451 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11452 (insert-buffer-substring gnus-original-article-buffer 1 e)
11453 (let ((gnus-inhibit-hiding t))
11454 (run-hooks 'gnus-article-display-hook))
11455 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11456 (gnus-article-hide-headers)))))
11458 (defun gnus-summary-show-all-headers ()
11459 "Make all header lines visible."
11461 (gnus-set-global-variables)
11462 (gnus-article-show-all-headers))
11464 (defun gnus-summary-toggle-mime (&optional arg)
11465 "Toggle MIME processing.
11466 If ARG is a positive number, turn MIME processing on."
11468 (gnus-set-global-variables)
11469 (setq gnus-show-mime
11470 (if (null arg) (not gnus-show-mime)
11471 (> (prefix-numeric-value arg) 0)))
11472 (gnus-summary-select-article t 'force))
11474 (defun gnus-summary-caesar-message (&optional arg)
11475 "Caesar rotate the current article by 13.
11476 The numerical prefix specifies how manu places to rotate each letter
11479 (gnus-set-global-variables)
11480 (gnus-summary-select-article)
11481 (let ((mail-header-separator ""))
11482 (gnus-eval-in-buffer-window gnus-article-buffer
11485 (let ((start (window-start))
11487 (message-caesar-buffer-body arg)
11488 (set-window-start (get-buffer-window (current-buffer)) start))))))
11490 (defun gnus-summary-stop-page-breaking ()
11491 "Stop page breaking in the current article."
11493 (gnus-set-global-variables)
11494 (gnus-summary-select-article)
11495 (gnus-eval-in-buffer-window gnus-article-buffer
11498 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11499 "Move the current article to a different newsgroup.
11500 If N is a positive number, move the N next articles.
11501 If N is a negative number, move the N previous articles.
11502 If N is nil and any articles have been marked with the process mark,
11503 move those articles instead.
11504 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11505 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11506 re-spool using this method.
11508 For this function to work, both the current newsgroup and the
11509 newsgroup that you want to move to have to support the `request-move'
11510 and `request-accept' functions."
11512 (unless action (setq action 'move))
11513 (gnus-set-global-variables)
11514 ;; Check whether the source group supports the required functions.
11515 (cond ((and (eq action 'move)
11516 (not (gnus-check-backend-function
11517 'request-move-article gnus-newsgroup-name)))
11518 (error "The current group does not support article moving"))
11519 ((and (eq action 'crosspost)
11520 (not (gnus-check-backend-function
11521 'request-replace-article gnus-newsgroup-name)))
11522 (error "The current group does not support article editing")))
11523 (let ((articles (gnus-summary-work-articles n))
11524 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11525 (names '((move "Move" "Moving")
11526 (copy "Copy" "Copying")
11527 (crosspost "Crosspost" "Crossposting")))
11528 (copy-buf (save-excursion
11529 (nnheader-set-temp-buffer " *copy article*")))
11530 art-group to-method new-xref article to-groups)
11531 (unless (assq action names)
11532 (error "Unknown action %s" action))
11533 ;; Read the newsgroup name.
11534 (when (and (not to-newsgroup)
11535 (not select-method))
11537 (gnus-read-move-group-name
11538 (cadr (assq action names))
11539 (symbol-value (intern (format "gnus-current-%s-group" action)))
11541 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11542 (setq to-method (or select-method
11543 (gnus-group-name-to-method to-newsgroup)))
11544 ;; Check the method we are to move this article to...
11545 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11546 (error "%s does not support article copying" (car to-method)))
11547 (or (gnus-check-server to-method)
11548 (error "Can't open server %s" (car to-method)))
11549 (gnus-message 6 "%s to %s: %s..."
11550 (caddr (assq action names))
11551 (or (car select-method) to-newsgroup) articles)
11553 (setq article (pop articles))
11557 ;; Move the article.
11559 (gnus-request-move-article
11560 article ; Article to move
11561 gnus-newsgroup-name ; From newsgrouo
11562 (nth 1 (gnus-find-method-for-group
11563 gnus-newsgroup-name)) ; Server
11564 (list 'gnus-request-accept-article
11565 to-newsgroup (list 'quote select-method)
11566 (not articles)) ; Accept form
11567 (not articles))) ; Only save nov last time
11568 ;; Copy the article.
11571 (set-buffer copy-buf)
11572 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11573 (gnus-request-accept-article
11574 to-newsgroup select-method (not articles))))
11575 ;; Crosspost the article.
11576 ((eq action 'crosspost)
11577 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11578 (setq new-xref (concat gnus-newsgroup-name ":" article))
11579 (if (and xref (not (string= xref "")))
11581 (when (string-match "^Xref: " xref)
11582 (setq xref (substring xref (match-end 0))))
11583 (setq new-xref (concat xref " " new-xref)))
11584 (setq new-xref (concat (system-name) " " new-xref)))
11586 (set-buffer copy-buf)
11587 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11588 (nnheader-replace-header "xref" new-xref)
11589 (gnus-request-accept-article
11590 to-newsgroup select-method (not articles)))))))
11591 (if (not art-group)
11592 (gnus-message 1 "Couldn't %s article %s"
11593 (cadr (assq action names)) article)
11596 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11598 (gnus-group-prefixed-name
11601 (gnus-find-method-for-group to-newsgroup)))
11602 gnus-newsrc-hashtb)))
11603 (info (nth 2 entry))
11604 (to-group (gnus-info-group info)))
11605 ;; Update the group that has been moved to.
11607 (memq action '(move copy)))
11608 (unless (member to-group to-groups)
11609 (push to-group to-groups))
11611 (unless (memq article gnus-newsgroup-unreads)
11612 (gnus-info-set-read
11613 info (gnus-add-to-range (gnus-info-read info)
11614 (list (cdr art-group)))))
11616 ;; Copy any marks over to the new group.
11617 (let ((marks gnus-article-mark-lists)
11618 (to-article (cdr art-group)))
11620 ;; See whether the article is to be put in the cache.
11621 (when gnus-use-cache
11622 (gnus-cache-possibly-enter-article
11623 to-group to-article
11624 (let ((header (copy-sequence
11625 (gnus-summary-article-header article))))
11626 (mail-header-set-number header to-article)
11628 (memq article gnus-newsgroup-marked)
11629 (memq article gnus-newsgroup-dormant)
11630 (memq article gnus-newsgroup-unreads)))
11633 (when (memq article (symbol-value
11634 (intern (format "gnus-newsgroup-%s"
11636 ;; If the other group is the same as this group,
11637 ;; then we have to add the mark to the list.
11638 (when (equal to-group gnus-newsgroup-name)
11639 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11642 (intern (format "gnus-newsgroup-%s"
11644 ;; Copy mark to other group.
11645 (gnus-add-marked-articles
11646 to-group (cdar marks) (list to-article) info))
11647 (setq marks (cdr marks)))))
11649 ;; Update the Xref header in this article to point to
11650 ;; the new crossposted article we have just created.
11651 (when (eq action 'crosspost)
11653 (set-buffer copy-buf)
11654 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11655 (nnheader-replace-header
11656 "xref" (concat new-xref " " (gnus-group-prefixed-name
11657 (car art-group) to-method)
11658 ":" (cdr art-group)))
11659 (gnus-request-replace-article
11660 article gnus-newsgroup-name (current-buffer)))))
11662 (gnus-summary-goto-subject article)
11663 (when (eq action 'move)
11664 (gnus-summary-mark-article article gnus-canceled-mark)))
11665 (gnus-summary-remove-process-mark article))
11666 ;; Re-activate all groups that have been moved to.
11668 (gnus-activate-group (pop to-groups)))
11670 (gnus-kill-buffer copy-buf)
11671 (gnus-summary-position-point)
11672 (gnus-set-mode-line 'summary)))
11674 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11675 "Move the current article to a different newsgroup.
11676 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11677 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11678 re-spool using this method."
11680 (gnus-summary-move-article n nil select-method 'copy))
11682 (defun gnus-summary-crosspost-article (&optional n)
11683 "Crosspost the current article to some other group."
11685 (gnus-summary-move-article n nil nil 'crosspost))
11687 (defvar gnus-summary-respool-default-method nil
11688 "Default method for respooling an article.
11689 If nil, use to the current newsgroup method.")
11691 (defun gnus-summary-respool-article (&optional n method)
11692 "Respool the current article.
11693 The article will be squeezed through the mail spooling process again,
11694 which means that it will be put in some mail newsgroup or other
11695 depending on `nnmail-split-methods'.
11696 If N is a positive number, respool the N next articles.
11697 If N is a negative number, respool the N previous articles.
11698 If N is nil and any articles have been marked with the process mark,
11699 respool those articles instead.
11701 Respooling can be done both from mail groups and \"real\" newsgroups.
11702 In the former case, the articles in question will be moved from the
11703 current group into whatever groups they are destined to. In the
11704 latter case, they will be copied into the relevant groups."
11706 (list current-prefix-arg
11707 (let* ((methods (gnus-methods-using 'respool))
11709 (symbol-name (or gnus-summary-respool-default-method
11710 (car (gnus-find-method-for-group
11711 gnus-newsgroup-name)))))
11713 (gnus-completing-read
11714 methname "What backend do you want to use when respooling?"
11715 methods nil t nil 'gnus-method-history))
11718 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11719 (list (intern method) ""))
11723 (cdr (completing-read
11725 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11726 (gnus-set-global-variables)
11728 (error "No method given for respooling"))
11729 (if (assoc (symbol-name
11730 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11731 (gnus-methods-using 'respool))
11732 (gnus-summary-move-article n nil method)
11733 (gnus-summary-copy-article n nil method)))
11735 (defun gnus-summary-import-article (file)
11736 "Import a random file into a mail newsgroup."
11737 (interactive "fImport file: ")
11738 (gnus-set-global-variables)
11739 (let ((group gnus-newsgroup-name)
11740 (now (current-time))
11742 (or (gnus-check-backend-function 'request-accept-article group)
11743 (error "%s does not support article importing" group))
11744 (or (file-readable-p file)
11745 (not (file-regular-p file))
11746 (error "Can't read %s" file))
11748 (set-buffer (get-buffer-create " *import file*"))
11749 (buffer-disable-undo (current-buffer))
11751 (insert-file-contents file)
11752 (goto-char (point-min))
11753 (unless (nnheader-article-p)
11754 ;; This doesn't look like an article, so we fudge some headers.
11755 (setq atts (file-attributes file)
11756 lines (count-lines (point-min) (point-max)))
11757 (insert "From: " (read-string "From: ") "\n"
11758 "Subject: " (read-string "Subject: ") "\n"
11759 "Date: " (timezone-make-date-arpa-standard
11760 (current-time-string (nth 5 atts))
11761 (current-time-zone now)
11762 (current-time-zone now)) "\n"
11763 "Message-ID: " (message-make-message-id) "\n"
11764 "Lines: " (int-to-string lines) "\n"
11765 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11766 (gnus-request-accept-article group nil t)
11767 (kill-buffer (current-buffer)))))
11769 (defun gnus-summary-expire-articles (&optional now)
11770 "Expire all articles that are marked as expirable in the current group."
11772 (gnus-set-global-variables)
11773 (when (gnus-check-backend-function
11774 'request-expire-articles gnus-newsgroup-name)
11775 ;; This backend supports expiry.
11776 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11777 (expirable (if total
11778 (gnus-list-of-read-articles gnus-newsgroup-name)
11779 (setq gnus-newsgroup-expirable
11780 (sort gnus-newsgroup-expirable '<))))
11781 (expiry-wait (if now 'immediate
11782 (gnus-group-get-parameter
11783 gnus-newsgroup-name 'expiry-wait)))
11786 ;; There are expirable articles in this group, so we run them
11787 ;; through the expiry process.
11788 (gnus-message 6 "Expiring articles...")
11789 ;; The list of articles that weren't expired is returned.
11791 (let ((nnmail-expiry-wait-function nil)
11792 (nnmail-expiry-wait expiry-wait))
11793 (setq es (gnus-request-expire-articles
11794 expirable gnus-newsgroup-name)))
11795 (setq es (gnus-request-expire-articles
11796 expirable gnus-newsgroup-name)))
11797 (or total (setq gnus-newsgroup-expirable es))
11798 ;; We go through the old list of expirable, and mark all
11799 ;; really expired articles as nonexistent.
11800 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11801 (let ((gnus-use-cache nil))
11803 (unless (memq (car expirable) es)
11804 (when (gnus-data-find (car expirable))
11805 (gnus-summary-mark-article
11806 (car expirable) gnus-canceled-mark)))
11807 (setq expirable (cdr expirable)))))
11808 (gnus-message 6 "Expiring articles...done")))))
11810 (defun gnus-summary-expire-articles-now ()
11811 "Expunge all expirable articles in the current group.
11812 This means that *all* articles that are marked as expirable will be
11813 deleted forever, right now."
11815 (gnus-set-global-variables)
11816 (or gnus-expert-user
11818 "Are you really, really, really sure you want to delete all these messages? ")
11820 (gnus-summary-expire-articles t))
11822 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11823 (defun gnus-summary-delete-article (&optional n)
11824 "Delete the N next (mail) articles.
11825 This command actually deletes articles. This is not a marking
11826 command. The article will disappear forever from your life, never to
11828 If N is negative, delete backwards.
11829 If N is nil and articles have been marked with the process mark,
11830 delete these instead."
11832 (gnus-set-global-variables)
11833 (or (gnus-check-backend-function 'request-expire-articles
11834 gnus-newsgroup-name)
11835 (error "The current newsgroup does not support article deletion."))
11836 ;; Compute the list of articles to delete.
11837 (let ((articles (gnus-summary-work-articles n))
11839 (if (and gnus-novice-user
11840 (not (gnus-y-or-n-p
11841 (format "Do you really want to delete %s forever? "
11842 (if (> (length articles) 1)
11843 (format "these %s articles" (length articles))
11844 "this article")))))
11846 ;; Delete the articles.
11847 (setq not-deleted (gnus-request-expire-articles
11848 articles gnus-newsgroup-name 'force))
11850 (gnus-summary-remove-process-mark (car articles))
11851 ;; The backend might not have been able to delete the article
11853 (or (memq (car articles) not-deleted)
11854 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11855 (setq articles (cdr articles))))
11856 (gnus-summary-position-point)
11857 (gnus-set-mode-line 'summary)
11860 (defun gnus-summary-edit-article (&optional force)
11861 "Enter into a buffer and edit the current article.
11862 This will have permanent effect only in mail groups.
11863 If FORCE is non-nil, allow editing of articles even in read-only
11867 (set-buffer gnus-summary-buffer)
11868 (gnus-set-global-variables)
11869 (when (and (not force)
11870 (gnus-group-read-only-p))
11871 (error "The current newsgroup does not support article editing."))
11872 (gnus-summary-select-article t nil t)
11873 (gnus-configure-windows 'article)
11874 (select-window (get-buffer-window gnus-article-buffer))
11875 (gnus-message 6 "C-c C-c to end edits")
11876 (setq buffer-read-only nil)
11878 (use-local-map (copy-keymap (current-local-map)))
11879 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11880 (buffer-enable-undo)
11882 (goto-char (point-min))
11883 (search-forward "\n\n" nil t)))
11885 (defun gnus-summary-edit-article-done ()
11886 "Make edits to the current article permanent."
11888 (if (gnus-group-read-only-p)
11890 (let ((beep (not (eq major-mode 'text-mode))))
11891 (gnus-summary-edit-article-postpone)
11894 3 "The current newsgroup does not support article editing."))))
11895 (let ((buf (format "%s" (buffer-string))))
11898 (if (not (gnus-request-replace-article
11899 (cdr gnus-article-current) (car gnus-article-current)
11901 (error "Couldn't replace article.")
11902 (gnus-article-mode)
11903 (use-local-map gnus-article-mode-map)
11904 (setq buffer-read-only t)
11905 (buffer-disable-undo (current-buffer))
11906 (gnus-configure-windows 'summary)
11907 (gnus-summary-update-article (cdr gnus-article-current))
11908 (when gnus-use-cache
11909 (gnus-cache-update-article
11910 (car gnus-article-current) (cdr gnus-article-current)))
11911 (when gnus-keep-backlog
11912 (gnus-backlog-remove-article
11913 (car gnus-article-current) (cdr gnus-article-current))))
11915 (when (get-buffer gnus-original-article-buffer)
11916 (set-buffer gnus-original-article-buffer)
11917 (setq gnus-original-article nil)))
11918 (setq gnus-article-current nil
11919 gnus-current-article nil)
11920 (run-hooks 'gnus-article-display-hook)
11921 (and (gnus-visual-p 'summary-highlight 'highlight)
11922 (run-hooks 'gnus-visual-mark-article-hook)))))
11924 (defun gnus-summary-edit-article-postpone ()
11925 "Postpone changes to the current article."
11927 (gnus-article-mode)
11928 (use-local-map gnus-article-mode-map)
11929 (setq buffer-read-only t)
11930 (buffer-disable-undo (current-buffer))
11931 (gnus-configure-windows 'summary)
11932 (and (gnus-visual-p 'summary-highlight 'highlight)
11933 (run-hooks 'gnus-visual-mark-article-hook)))
11935 (defun gnus-summary-respool-query ()
11936 "Query where the respool algorithm would put this article."
11938 (gnus-set-global-variables)
11939 (gnus-summary-select-article)
11941 (set-buffer gnus-article-buffer)
11943 (goto-char (point-min))
11944 (search-forward "\n\n")
11945 (narrow-to-region (point-min) (point))
11946 (pp-eval-expression
11947 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11949 ;; Summary marking commands.
11951 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11952 "Mark articles which has the same subject as read, and then select the next.
11953 If UNMARK is positive, remove any kind of mark.
11954 If UNMARK is negative, tick articles."
11956 (gnus-set-global-variables)
11958 (setq unmark (prefix-numeric-value unmark)))
11960 (gnus-summary-mark-same-subject
11961 (gnus-summary-article-subject) unmark)))
11962 ;; Select next unread article. If auto-select-same mode, should
11963 ;; select the first unread article.
11964 (gnus-summary-next-article t (and gnus-auto-select-same
11965 (gnus-summary-article-subject)))
11966 (gnus-message 7 "%d article%s marked as %s"
11967 count (if (= count 1) " is" "s are")
11968 (if unmark "unread" "read"))))
11970 (defun gnus-summary-kill-same-subject (&optional unmark)
11971 "Mark articles which has the same subject as read.
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 ;; If marked as read, go to next unread subject.
11983 ;; Go to next unread subject.
11984 (gnus-summary-next-subject 1 t))
11985 (gnus-message 7 "%d articles are marked as %s"
11986 count (if unmark "unread" "read"))))
11988 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11989 "Mark articles with same SUBJECT as read, and return marked number.
11990 If optional argument UNMARK is positive, remove any kinds of marks.
11991 If optional argument UNMARK is negative, mark articles as unread instead."
11995 ((null unmark) ; Mark as read.
11998 (gnus-summary-mark-article-as-read gnus-killed-mark)
11999 (gnus-summary-show-thread) t)
12000 (gnus-summary-find-subject subject))
12001 (setq count (1+ count))))
12002 ((> unmark 0) ; Tick.
12005 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
12006 (gnus-summary-show-thread) t)
12007 (gnus-summary-find-subject subject))
12008 (setq count (1+ count))))
12009 (t ; Mark as unread.
12012 (gnus-summary-mark-article-as-unread gnus-unread-mark)
12013 (gnus-summary-show-thread) t)
12014 (gnus-summary-find-subject subject))
12015 (setq count (1+ count)))))
12016 (gnus-set-mode-line 'summary)
12017 ;; Return the number of marked articles.
12020 (defun gnus-summary-mark-as-processable (n &optional unmark)
12021 "Set the process mark on the next N articles.
12022 If N is negative, mark backward instead. If UNMARK is non-nil, remove
12023 the process mark instead. The difference between N and the actual
12024 number of articles marked is returned."
12026 (gnus-set-global-variables)
12027 (let ((backward (< n 0))
12032 (gnus-summary-remove-process-mark
12033 (gnus-summary-article-number))
12034 (gnus-summary-set-process-mark (gnus-summary-article-number)))
12035 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
12037 (if (/= 0 n) (gnus-message 7 "No more articles"))
12038 (gnus-summary-recenter)
12039 (gnus-summary-position-point)
12042 (defun gnus-summary-unmark-as-processable (n)
12043 "Remove the process mark from the next N articles.
12044 If N is negative, mark backward instead. The difference between N and
12045 the actual number of articles marked is returned."
12047 (gnus-set-global-variables)
12048 (gnus-summary-mark-as-processable n t))
12050 (defun gnus-summary-unmark-all-processable ()
12051 "Remove the process mark from all articles."
12053 (gnus-set-global-variables)
12055 (while gnus-newsgroup-processable
12056 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12057 (gnus-summary-position-point))
12059 (defun gnus-summary-mark-as-expirable (n)
12060 "Mark N articles forward as expirable.
12061 If N is negative, mark backward instead. The difference between N and
12062 the actual number of articles marked is returned."
12064 (gnus-set-global-variables)
12065 (gnus-summary-mark-forward n gnus-expirable-mark))
12067 (defun gnus-summary-mark-article-as-replied (article)
12068 "Mark ARTICLE replied and update the summary line."
12069 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12070 (let ((buffer-read-only nil))
12071 (when (gnus-summary-goto-subject article)
12072 (gnus-summary-update-secondary-mark article))))
12074 (defun gnus-summary-set-bookmark (article)
12075 "Set a bookmark in current article."
12076 (interactive (list (gnus-summary-article-number)))
12077 (gnus-set-global-variables)
12078 (if (or (not (get-buffer gnus-article-buffer))
12079 (not gnus-current-article)
12080 (not gnus-article-current)
12081 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12082 (error "No current article selected"))
12083 ;; Remove old bookmark, if one exists.
12084 (let ((old (assq article gnus-newsgroup-bookmarks)))
12085 (if old (setq gnus-newsgroup-bookmarks
12086 (delq old gnus-newsgroup-bookmarks))))
12087 ;; Set the new bookmark, which is on the form
12088 ;; (article-number . line-number-in-body).
12089 (setq gnus-newsgroup-bookmarks
12093 (set-buffer gnus-article-buffer)
12097 (goto-char (point-min))
12098 (search-forward "\n\n" nil t)
12101 gnus-newsgroup-bookmarks))
12102 (gnus-message 6 "A bookmark has been added to the current article."))
12104 (defun gnus-summary-remove-bookmark (article)
12105 "Remove the bookmark from the current article."
12106 (interactive (list (gnus-summary-article-number)))
12107 (gnus-set-global-variables)
12108 ;; Remove old bookmark, if one exists.
12109 (let ((old (assq article gnus-newsgroup-bookmarks)))
12112 (setq gnus-newsgroup-bookmarks
12113 (delq old gnus-newsgroup-bookmarks))
12114 (gnus-message 6 "Removed bookmark."))
12115 (gnus-message 6 "No bookmark in current article."))))
12117 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12118 (defun gnus-summary-mark-as-dormant (n)
12119 "Mark N articles forward as dormant.
12120 If N is negative, mark backward instead. The difference between N and
12121 the actual number of articles marked is returned."
12123 (gnus-set-global-variables)
12124 (gnus-summary-mark-forward n gnus-dormant-mark))
12126 (defun gnus-summary-set-process-mark (article)
12127 "Set the process mark on ARTICLE and update the summary line."
12128 (setq gnus-newsgroup-processable
12130 (delq article gnus-newsgroup-processable)))
12131 (when (gnus-summary-goto-subject article)
12132 (gnus-summary-show-thread)
12133 (gnus-summary-update-secondary-mark article)))
12135 (defun gnus-summary-remove-process-mark (article)
12136 "Remove the process mark from ARTICLE and update the summary line."
12137 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12138 (when (gnus-summary-goto-subject article)
12139 (gnus-summary-show-thread)
12140 (gnus-summary-update-secondary-mark article)))
12142 (defun gnus-summary-set-saved-mark (article)
12143 "Set the process mark on ARTICLE and update the summary line."
12144 (push article gnus-newsgroup-saved)
12145 (when (gnus-summary-goto-subject article)
12146 (gnus-summary-update-secondary-mark article)))
12148 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12149 "Mark N articles as read forwards.
12150 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12151 The difference between N and the actual number of articles marked is
12154 (gnus-set-global-variables)
12155 (let ((backward (< n 0))
12156 (gnus-summary-goto-unread
12157 (and gnus-summary-goto-unread
12158 (not (eq gnus-summary-goto-unread 'never))
12159 (not (memq mark (list gnus-unread-mark
12160 gnus-ticked-mark gnus-dormant-mark)))))
12162 (mark (or mark gnus-del-mark)))
12163 (while (and (> n 0)
12164 (gnus-summary-mark-article nil mark no-expire)
12165 (zerop (gnus-summary-next-subject
12167 (and gnus-summary-goto-unread
12168 (not (eq gnus-summary-goto-unread 'never)))
12171 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12172 (gnus-summary-recenter)
12173 (gnus-summary-position-point)
12174 (gnus-set-mode-line 'summary)
12177 (defun gnus-summary-mark-article-as-read (mark)
12178 "Mark the current article quickly as read with MARK."
12179 (let ((article (gnus-summary-article-number)))
12180 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12181 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12182 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12183 (setq gnus-newsgroup-reads
12184 (cons (cons article mark) gnus-newsgroup-reads))
12185 ;; Possibly remove from cache, if that is used.
12186 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12187 ;; Allow the backend to change the mark.
12188 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12189 ;; Check for auto-expiry.
12190 (when (and gnus-newsgroup-auto-expire
12191 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12192 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12193 (= mark gnus-ancient-mark)
12194 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12195 (setq mark gnus-expirable-mark)
12196 (push article gnus-newsgroup-expirable))
12197 ;; Set the mark in the buffer.
12198 (gnus-summary-update-mark mark 'unread)
12201 (defun gnus-summary-mark-article-as-unread (mark)
12202 "Mark the current article quickly as unread with MARK."
12203 (let ((article (gnus-summary-article-number)))
12205 (gnus-error 1 "Unmarkable article")
12206 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12207 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12208 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12209 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12210 (cond ((= mark gnus-ticked-mark)
12211 (push article gnus-newsgroup-marked))
12212 ((= mark gnus-dormant-mark)
12213 (push article gnus-newsgroup-dormant))
12215 (push article gnus-newsgroup-unreads)))
12216 (setq gnus-newsgroup-reads
12217 (delq (assq article gnus-newsgroup-reads)
12218 gnus-newsgroup-reads))
12220 ;; See whether the article is to be put in the cache.
12221 (and gnus-use-cache
12222 (vectorp (gnus-summary-article-header article))
12224 (gnus-cache-possibly-enter-article
12225 gnus-newsgroup-name article
12226 (gnus-summary-article-header article)
12227 (= mark gnus-ticked-mark)
12228 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12231 (gnus-summary-update-mark mark 'unread))
12234 (defun gnus-summary-mark-article (&optional article mark no-expire)
12235 "Mark ARTICLE with MARK. MARK can be any character.
12236 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12237 `??' (dormant) and `?E' (expirable).
12238 If MARK is nil, then the default character `?D' is used.
12239 If ARTICLE is nil, then the article on the current line will be
12241 ;; The mark might be a string.
12242 (and (stringp mark)
12243 (setq mark (aref mark 0)))
12244 ;; If no mark is given, then we check auto-expiring.
12245 (and (not no-expire)
12246 gnus-newsgroup-auto-expire
12248 (and (numberp mark)
12249 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12250 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12251 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12252 (setq mark gnus-expirable-mark))
12253 (let* ((mark (or mark gnus-del-mark))
12254 (article (or article (gnus-summary-article-number))))
12255 (or article (error "No article on current line"))
12256 (if (or (= mark gnus-unread-mark)
12257 (= mark gnus-ticked-mark)
12258 (= mark gnus-dormant-mark))
12259 (gnus-mark-article-as-unread article mark)
12260 (gnus-mark-article-as-read article mark))
12262 ;; See whether the article is to be put in the cache.
12263 (and gnus-use-cache
12264 (not (= mark gnus-canceled-mark))
12265 (vectorp (gnus-summary-article-header article))
12267 (gnus-cache-possibly-enter-article
12268 gnus-newsgroup-name article
12269 (gnus-summary-article-header article)
12270 (= mark gnus-ticked-mark)
12271 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12273 (if (gnus-summary-goto-subject article nil t)
12274 (let ((buffer-read-only nil))
12275 (gnus-summary-show-thread)
12277 (gnus-summary-update-mark mark 'unread)
12280 (defun gnus-summary-update-secondary-mark (article)
12281 "Update the secondary (read, process, cache) mark."
12282 (gnus-summary-update-mark
12283 (cond ((memq article gnus-newsgroup-processable)
12285 ((memq article gnus-newsgroup-cached)
12287 ((memq article gnus-newsgroup-replied)
12289 ((memq article gnus-newsgroup-saved)
12291 (t gnus-unread-mark))
12293 (when (gnus-visual-p 'summary-highlight 'highlight)
12294 (run-hooks 'gnus-summary-update-hook))
12297 (defun gnus-summary-update-mark (mark type)
12298 (beginning-of-line)
12299 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12300 (buffer-read-only nil))
12302 (<= (+ forward (point)) (point-max)))
12303 ;; Go to the right position on the line.
12304 (goto-char (+ forward (point)))
12305 ;; Replace the old mark with the new mark.
12306 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12307 ;; Optionally update the marks by some user rule.
12308 (when (eq type 'unread)
12309 (gnus-data-set-mark
12310 (gnus-data-find (gnus-summary-article-number)) mark)
12311 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12313 (defun gnus-mark-article-as-read (article &optional mark)
12314 "Enter ARTICLE in the pertinent lists and remove it from others."
12315 ;; Make the article expirable.
12316 (let ((mark (or mark gnus-del-mark)))
12317 (if (= mark gnus-expirable-mark)
12318 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12319 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12320 ;; Remove from unread and marked lists.
12321 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12322 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12323 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12324 (push (cons article mark) gnus-newsgroup-reads)
12325 ;; Possibly remove from cache, if that is used.
12326 (when gnus-use-cache
12327 (gnus-cache-enter-remove-article article))))
12329 (defun gnus-mark-article-as-unread (article &optional mark)
12330 "Enter ARTICLE in the pertinent lists and remove it from others."
12331 (let ((mark (or mark gnus-ticked-mark)))
12332 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12333 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12334 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12335 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12336 (cond ((= mark gnus-ticked-mark)
12337 (push article gnus-newsgroup-marked))
12338 ((= mark gnus-dormant-mark)
12339 (push article gnus-newsgroup-dormant))
12341 (push article gnus-newsgroup-unreads)))
12342 (setq gnus-newsgroup-reads
12343 (delq (assq article gnus-newsgroup-reads)
12344 gnus-newsgroup-reads))))
12346 (defalias 'gnus-summary-mark-as-unread-forward
12347 'gnus-summary-tick-article-forward)
12348 (make-obsolete 'gnus-summary-mark-as-unread-forward
12349 'gnus-summary-tick-article-forward)
12350 (defun gnus-summary-tick-article-forward (n)
12351 "Tick N articles forwards.
12352 If N is negative, tick backwards instead.
12353 The difference between N and the number of articles ticked is returned."
12355 (gnus-summary-mark-forward n gnus-ticked-mark))
12357 (defalias 'gnus-summary-mark-as-unread-backward
12358 'gnus-summary-tick-article-backward)
12359 (make-obsolete 'gnus-summary-mark-as-unread-backward
12360 'gnus-summary-tick-article-backward)
12361 (defun gnus-summary-tick-article-backward (n)
12362 "Tick N articles backwards.
12363 The difference between N and the number of articles ticked is returned."
12365 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12367 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12368 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12369 (defun gnus-summary-tick-article (&optional article clear-mark)
12370 "Mark current article as unread.
12371 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12372 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12374 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12375 gnus-ticked-mark)))
12377 (defun gnus-summary-mark-as-read-forward (n)
12378 "Mark N articles as read forwards.
12379 If N is negative, mark backwards instead.
12380 The difference between N and the actual number of articles marked is
12383 (gnus-summary-mark-forward n gnus-del-mark t))
12385 (defun gnus-summary-mark-as-read-backward (n)
12386 "Mark the N articles as read backwards.
12387 The difference between N and the actual number of articles marked is
12390 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12392 (defun gnus-summary-mark-as-read (&optional article mark)
12393 "Mark current article as read.
12394 ARTICLE specifies the article to be marked as read.
12395 MARK specifies a string to be inserted at the beginning of the line."
12396 (gnus-summary-mark-article article mark))
12398 (defun gnus-summary-clear-mark-forward (n)
12399 "Clear marks from N articles forward.
12400 If N is negative, clear backward instead.
12401 The difference between N and the number of marks cleared is returned."
12403 (gnus-summary-mark-forward n gnus-unread-mark))
12405 (defun gnus-summary-clear-mark-backward (n)
12406 "Clear marks from N articles backward.
12407 The difference between N and the number of marks cleared is returned."
12409 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12411 (defun gnus-summary-mark-unread-as-read ()
12412 "Intended to be used by `gnus-summary-mark-article-hook'."
12413 (when (memq gnus-current-article gnus-newsgroup-unreads)
12414 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12416 (defun gnus-summary-mark-read-and-unread-as-read ()
12417 "Intended to be used by `gnus-summary-mark-article-hook'."
12418 (let ((mark (gnus-summary-article-mark)))
12419 (when (or (gnus-unread-mark-p mark)
12420 (gnus-read-mark-p mark))
12421 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12423 (defun gnus-summary-mark-region-as-read (point mark all)
12424 "Mark all unread articles between point and mark as read.
12425 If given a prefix, mark all articles between point and mark as read,
12426 even ticked and dormant ones."
12427 (interactive "r\nP")
12431 (beginning-of-line)
12436 (memq (setq article (gnus-summary-article-number))
12437 gnus-newsgroup-unreads))
12438 (gnus-summary-mark-article article gnus-del-mark))
12440 (gnus-summary-find-next))))))
12442 (defun gnus-summary-mark-below (score mark)
12443 "Mark articles with score less than SCORE with MARK."
12444 (interactive "P\ncMark: ")
12445 (gnus-set-global-variables)
12446 (setq score (if score
12447 (prefix-numeric-value score)
12448 (or gnus-summary-default-score 0)))
12450 (set-buffer gnus-summary-buffer)
12451 (goto-char (point-min))
12454 (and (< (gnus-summary-article-score) score)
12455 (gnus-summary-mark-article nil mark))
12456 (gnus-summary-find-next)))))
12458 (defun gnus-summary-kill-below (&optional score)
12459 "Mark articles with score below SCORE as read."
12461 (gnus-set-global-variables)
12462 (gnus-summary-mark-below score gnus-killed-mark))
12464 (defun gnus-summary-clear-above (&optional score)
12465 "Clear all marks from articles with score above SCORE."
12467 (gnus-set-global-variables)
12468 (gnus-summary-mark-above score gnus-unread-mark))
12470 (defun gnus-summary-tick-above (&optional score)
12471 "Tick all articles with score above SCORE."
12473 (gnus-set-global-variables)
12474 (gnus-summary-mark-above score gnus-ticked-mark))
12476 (defun gnus-summary-mark-above (score mark)
12477 "Mark articles with score over SCORE with MARK."
12478 (interactive "P\ncMark: ")
12479 (gnus-set-global-variables)
12480 (setq score (if score
12481 (prefix-numeric-value score)
12482 (or gnus-summary-default-score 0)))
12484 (set-buffer gnus-summary-buffer)
12485 (goto-char (point-min))
12487 (if (> (gnus-summary-article-score) score)
12488 (gnus-summary-mark-article nil mark))
12490 (gnus-summary-find-next)))))
12492 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12493 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12494 (defun gnus-summary-limit-include-expunged ()
12495 "Display all the hidden articles that were expunged for low scores."
12497 (gnus-set-global-variables)
12498 (let ((buffer-read-only nil))
12499 (let ((scored gnus-newsgroup-scored)
12502 (or (gnus-summary-goto-subject (caar scored))
12503 (and (setq h (gnus-summary-article-header (caar scored)))
12504 (< (cdar scored) gnus-summary-expunge-below)
12505 (setq headers (cons h headers))))
12506 (setq scored (cdr scored)))
12507 (or headers (error "No expunged articles hidden."))
12508 (goto-char (point-min))
12509 (gnus-summary-prepare-unthreaded (nreverse headers)))
12510 (goto-char (point-min))
12511 (gnus-summary-position-point)))
12513 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12514 "Mark all articles not marked as unread in this newsgroup as read.
12515 If prefix argument ALL is non-nil, all articles are marked as read.
12516 If QUIETLY is non-nil, no questions will be asked.
12517 If TO-HERE is non-nil, it should be a point in the buffer. All
12518 articles before this point will be marked as read.
12519 The number of articles marked as read is returned."
12521 (gnus-set-global-variables)
12524 (not gnus-interactive-catchup) ;Without confirmation?
12528 "Mark absolutely all articles as read? "
12529 "Mark all unread articles as read? ")))
12531 (not gnus-newsgroup-adaptive)
12532 (not gnus-newsgroup-auto-expire))
12535 (setq gnus-newsgroup-marked nil
12536 gnus-newsgroup-dormant nil))
12537 (setq gnus-newsgroup-unreads nil))
12538 ;; We actually mark all articles as canceled, which we
12539 ;; have to do when using auto-expiry or adaptive scoring.
12540 (gnus-summary-show-all-threads)
12541 (if (gnus-summary-first-subject (not all))
12543 (if to-here (< (point) to-here) t)
12544 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12545 (gnus-summary-find-next (not all)))))
12547 (setq gnus-newsgroup-unreads nil))
12548 (gnus-set-mode-line 'summary)))
12549 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12550 (if (and (not to-here) (eq 'nnvirtual (car method)))
12551 (nnvirtual-catchup-group
12552 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12553 (gnus-summary-position-point)))
12555 (defun gnus-summary-catchup-to-here (&optional all)
12556 "Mark all unticked articles before the current one as read.
12557 If ALL is non-nil, also mark ticked and dormant articles as read."
12559 (gnus-set-global-variables)
12561 (gnus-save-hidden-threads
12562 (let ((beg (point)))
12563 ;; We check that there are unread articles.
12564 (when (or all (gnus-summary-find-prev))
12565 (gnus-summary-catchup all t beg)))))
12566 (gnus-summary-position-point))
12568 (defun gnus-summary-catchup-all (&optional quietly)
12569 "Mark all articles in this newsgroup as read."
12571 (gnus-set-global-variables)
12572 (gnus-summary-catchup t quietly))
12574 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12575 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12576 If prefix argument ALL is non-nil, all articles are marked as read."
12578 (gnus-set-global-variables)
12579 (gnus-summary-catchup all quietly nil 'fast)
12580 ;; Select next newsgroup or exit.
12581 (if (eq gnus-auto-select-next 'quietly)
12582 (gnus-summary-next-group nil)
12583 (gnus-summary-exit)))
12585 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12586 "Mark all articles in this newsgroup as read, and then exit."
12588 (gnus-set-global-variables)
12589 (gnus-summary-catchup-and-exit t quietly))
12591 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12592 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12593 "Mark all articles in this group as read and select the next group.
12594 If given a prefix, mark all articles, unread as well as ticked, as
12597 (gnus-set-global-variables)
12599 (gnus-summary-catchup all))
12600 (gnus-summary-next-article t nil nil t))
12602 ;; Thread-based commands.
12604 (defun gnus-summary-articles-in-thread (&optional article)
12605 "Return a list of all articles in the current thread.
12606 If ARTICLE is non-nil, return all articles in the thread that starts
12607 with that article."
12608 (let* ((article (or article (gnus-summary-article-number)))
12609 (data (gnus-data-find-list article))
12610 (top-level (gnus-data-level (car data)))
12612 (cond ((null gnus-thread-operation-ignore-subject)
12613 (gnus-simplify-subject-re
12614 (mail-header-subject (gnus-data-header (car data)))))
12615 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12616 (gnus-simplify-subject-fuzzy
12617 (mail-header-subject (gnus-data-header (car data)))))
12619 (end-point (save-excursion
12620 (if (gnus-summary-go-to-next-thread)
12621 (point) (point-max))))
12624 (< (gnus-data-pos (car data)) end-point))
12625 (when (or (not top-subject)
12626 (string= top-subject
12627 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12628 (gnus-simplify-subject-fuzzy
12629 (mail-header-subject
12630 (gnus-data-header (car data))))
12631 (gnus-simplify-subject-re
12632 (mail-header-subject
12633 (gnus-data-header (car data)))))))
12634 (push (gnus-data-number (car data)) articles))
12635 (unless (and (setq data (cdr data))
12636 (> (gnus-data-level (car data)) top-level))
12638 ;; Return the list of articles.
12639 (nreverse articles)))
12641 (defun gnus-summary-rethread-current ()
12642 "Rethread the thread the current article is part of."
12644 (gnus-set-global-variables)
12645 (let* ((gnus-show-threads t)
12646 (article (gnus-summary-article-number))
12647 (id (mail-header-id (gnus-summary-article-header)))
12648 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12650 (error "No article on the current line"))
12651 (gnus-rebuild-thread id)
12652 (gnus-summary-goto-subject article)))
12654 (defun gnus-summary-reparent-thread ()
12655 "Make current article child of the marked (or previous) article.
12657 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12658 is non-nil or the Subject: of both articles are the same."
12660 (or (not (gnus-group-read-only-p))
12661 (error "The current newsgroup does not support article editing."))
12662 (or (<= (length gnus-newsgroup-processable) 1)
12663 (error "No more than one article may be marked."))
12664 (save-window-excursion
12665 (let ((gnus-article-buffer " *reparent*")
12666 (current-article (gnus-summary-article-number))
12667 ; first grab the marked article, otherwise one line up.
12668 (parent-article (if (not (null gnus-newsgroup-processable))
12669 (car gnus-newsgroup-processable)
12671 (if (eq (forward-line -1) 0)
12672 (gnus-summary-article-number)
12673 (error "Beginning of summary buffer."))))))
12674 (or (not (eq current-article parent-article))
12675 (error "An article may not be self-referential."))
12676 (let ((message-id (mail-header-id
12677 (gnus-summary-article-header parent-article))))
12678 (or (and message-id (not (equal message-id "")))
12679 (error "No message-id in desired parent."))
12680 (gnus-summary-select-article t t nil current-article)
12681 (set-buffer gnus-article-buffer)
12682 (setq buffer-read-only nil)
12683 (let ((buf (format "%s" (buffer-string))))
12686 (goto-char (point-min))
12687 (if (search-forward-regexp "^References: " nil t)
12688 (insert message-id " " )
12689 (insert "References: " message-id "\n"))
12690 (or (gnus-request-replace-article current-article
12691 (car gnus-article-current)
12692 gnus-article-buffer)
12693 (error "Couldn't replace article."))
12694 (set-buffer gnus-summary-buffer)
12695 (gnus-summary-unmark-all-processable)
12696 (gnus-summary-rethread-current)
12697 (gnus-message 3 "Article %d is now the child of article %d."
12698 current-article parent-article)))))
12700 (defun gnus-summary-toggle-threads (&optional arg)
12701 "Toggle showing conversation threads.
12702 If ARG is positive number, turn showing conversation threads on."
12704 (gnus-set-global-variables)
12705 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12706 (setq gnus-show-threads
12707 (if (null arg) (not gnus-show-threads)
12708 (> (prefix-numeric-value arg) 0)))
12709 (gnus-summary-prepare)
12710 (gnus-summary-goto-subject current)
12711 (gnus-summary-position-point)))
12713 (defun gnus-summary-show-all-threads ()
12714 "Show all threads."
12716 (gnus-set-global-variables)
12718 (let ((buffer-read-only nil))
12719 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12720 (gnus-summary-position-point))
12722 (defun gnus-summary-show-thread ()
12723 "Show thread subtrees.
12724 Returns nil if no thread was there to be shown."
12726 (gnus-set-global-variables)
12727 (let ((buffer-read-only nil)
12729 ;; first goto end then to beg, to have point at beg after let
12730 (end (progn (end-of-line) (point)))
12731 (beg (progn (beginning-of-line) (point))))
12733 ;; Any hidden lines here?
12734 (search-forward "\r" end t)
12735 (subst-char-in-region beg end ?\^M ?\n t)
12737 (gnus-summary-position-point))))
12739 (defun gnus-summary-hide-all-threads ()
12740 "Hide all thread subtrees."
12742 (gnus-set-global-variables)
12744 (goto-char (point-min))
12745 (gnus-summary-hide-thread)
12746 (while (zerop (gnus-summary-next-thread 1 t))
12747 (gnus-summary-hide-thread)))
12748 (gnus-summary-position-point))
12750 (defun gnus-summary-hide-thread ()
12751 "Hide thread subtrees.
12752 Returns nil if no threads were there to be hidden."
12754 (gnus-set-global-variables)
12755 (let ((buffer-read-only nil)
12757 (article (gnus-summary-article-number)))
12759 ;; Go forward until either the buffer ends or the subthread
12761 (when (and (not (eobp))
12762 (or (zerop (gnus-summary-next-thread 1 t))
12763 (goto-char (point-max))))
12765 (if (and (> (point) start)
12766 (search-backward "\n" start t))
12768 (subst-char-in-region start (point) ?\n ?\^M)
12769 (gnus-summary-goto-subject article))
12772 ;;(gnus-summary-position-point)
12775 (defun gnus-summary-go-to-next-thread (&optional previous)
12776 "Go to the same level (or less) next thread.
12777 If PREVIOUS is non-nil, go to previous thread instead.
12778 Return the article number moved to, or nil if moving was impossible."
12779 (let ((level (gnus-summary-thread-level))
12780 (way (if previous -1 1))
12783 (while (and (not (eobp))
12784 (< level (gnus-summary-thread-level)))
12785 (forward-line way))
12792 (gnus-summary-article-number)
12793 (goto-char beg)))))
12795 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12796 "Go to the same level (or less) next thread.
12797 If PREVIOUS is non-nil, go to previous thread instead.
12798 Return the article number moved to, or nil if moving was impossible."
12799 (if (and (eq gnus-summary-make-false-root 'dummy)
12800 (gnus-summary-article-intangible-p))
12801 (let ((beg (point)))
12802 (while (and (zerop (forward-line 1))
12803 (not (gnus-summary-article-intangible-p))
12804 (not (zerop (save-excursion
12805 (gnus-summary-thread-level))))))
12811 (let* ((level (gnus-summary-thread-level))
12812 (article (gnus-summary-article-number))
12813 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12816 (if (<= (gnus-data-level (car data)) level)
12817 (setq oart (gnus-data-number (car data))
12819 (setq data (cdr data))))
12821 (gnus-summary-goto-subject oart)))))
12823 (defun gnus-summary-next-thread (n &optional silent)
12824 "Go to the same level next N'th thread.
12825 If N is negative, search backward instead.
12826 Returns the difference between N and the number of skips actually
12829 If SILENT, don't output messages."
12831 (gnus-set-global-variables)
12832 (let ((backward (< n 0))
12835 (while (and (> n 0)
12836 (gnus-summary-go-to-next-thread backward))
12839 (gnus-summary-position-point))
12840 (when (and (not silent) (/= 0 n))
12841 (gnus-message 7 "No more threads"))
12844 (defun gnus-summary-prev-thread (n)
12845 "Go to the same level previous N'th thread.
12846 Returns the difference between N and the number of skips actually
12849 (gnus-set-global-variables)
12850 (gnus-summary-next-thread (- n)))
12852 (defun gnus-summary-go-down-thread ()
12853 "Go down one level in the current thread."
12854 (let ((children (gnus-summary-article-children)))
12856 (gnus-summary-goto-subject (car children)))))
12858 (defun gnus-summary-go-up-thread ()
12859 "Go up one level in the current thread."
12860 (let ((parent (gnus-summary-article-parent)))
12862 (gnus-summary-goto-subject parent))))
12864 (defun gnus-summary-down-thread (n)
12865 "Go down thread N steps.
12866 If N is negative, go up instead.
12867 Returns the difference between N and how many steps down that were
12870 (gnus-set-global-variables)
12873 (while (and (> n 0)
12874 (if up (gnus-summary-go-up-thread)
12875 (gnus-summary-go-down-thread)))
12877 (gnus-summary-position-point)
12878 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12881 (defun gnus-summary-up-thread (n)
12882 "Go up thread N steps.
12883 If N is negative, go up instead.
12884 Returns the difference between N and how many steps down that were
12887 (gnus-set-global-variables)
12888 (gnus-summary-down-thread (- n)))
12890 (defun gnus-summary-top-thread ()
12891 "Go to the top of the thread."
12893 (gnus-set-global-variables)
12894 (while (gnus-summary-go-up-thread))
12895 (gnus-summary-article-number))
12897 (defun gnus-summary-kill-thread (&optional unmark)
12898 "Mark articles under current thread as read.
12899 If the prefix argument is positive, remove any kinds of marks.
12900 If the prefix argument is negative, tick articles instead."
12902 (gnus-set-global-variables)
12904 (setq unmark (prefix-numeric-value unmark)))
12905 (let ((articles (gnus-summary-articles-in-thread)))
12907 ;; Expand the thread.
12908 (gnus-summary-show-thread)
12909 ;; Mark all the articles.
12911 (gnus-summary-goto-subject (car articles))
12912 (cond ((null unmark)
12913 (gnus-summary-mark-article-as-read gnus-killed-mark))
12915 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12917 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12918 (setq articles (cdr articles))))
12919 ;; Hide killed subtrees.
12921 gnus-thread-hide-killed
12922 (gnus-summary-hide-thread))
12923 ;; If marked as read, go to next unread subject.
12925 ;; Go to next unread subject.
12926 (gnus-summary-next-subject 1 t)))
12927 (gnus-set-mode-line 'summary))
12929 ;; Summary sorting commands
12931 (defun gnus-summary-sort-by-number (&optional reverse)
12932 "Sort summary buffer by article number.
12933 Argument REVERSE means reverse order."
12935 (gnus-summary-sort 'number reverse))
12937 (defun gnus-summary-sort-by-author (&optional reverse)
12938 "Sort summary buffer by author name alphabetically.
12939 If case-fold-search is non-nil, case of letters is ignored.
12940 Argument REVERSE means reverse order."
12942 (gnus-summary-sort 'author reverse))
12944 (defun gnus-summary-sort-by-subject (&optional reverse)
12945 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12946 If case-fold-search is non-nil, case of letters is ignored.
12947 Argument REVERSE means reverse order."
12949 (gnus-summary-sort 'subject reverse))
12951 (defun gnus-summary-sort-by-date (&optional reverse)
12952 "Sort summary buffer by date.
12953 Argument REVERSE means reverse order."
12955 (gnus-summary-sort 'date reverse))
12957 (defun gnus-summary-sort-by-score (&optional reverse)
12958 "Sort summary buffer by score.
12959 Argument REVERSE means reverse order."
12961 (gnus-summary-sort 'score reverse))
12963 (defun gnus-summary-sort (predicate reverse)
12964 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12965 (gnus-set-global-variables)
12966 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12967 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12968 (gnus-thread-sort-functions
12973 (,thread t2 t1)))))
12974 (gnus-article-sort-functions
12979 (,article t2 t1)))))
12981 (gnus-summary-prepare-hook nil))
12982 ;; We do the sorting by regenerating the threads.
12983 (gnus-summary-prepare)
12984 ;; Hide subthreads if needed.
12985 (when (and gnus-show-threads gnus-thread-hide-subtree)
12986 (gnus-summary-hide-all-threads)))
12987 ;; If in async mode, we send some info to the backend.
12988 (when gnus-newsgroup-async
12989 (gnus-request-asynchronous
12990 gnus-newsgroup-name gnus-newsgroup-data)))
12992 (defun gnus-sortable-date (date)
12993 "Make sortable string by string-lessp from DATE.
12994 Timezone package is used."
12997 (setq date (inline (timezone-fix-time
12999 (aref (inline (timezone-parse-date date)) 4))))
13001 (timezone-make-sortable-date
13002 (aref date 0) (aref date 1) (aref date 2)
13004 (timezone-make-time-string
13005 (aref date 3) (aref date 4) (aref date 5))))))
13008 ;; Summary saving commands.
13010 (defun gnus-summary-save-article (&optional n not-saved)
13011 "Save the current article using the default saver function.
13012 If N is a positive number, save the N next articles.
13013 If N is a negative number, save the N previous articles.
13014 If N is nil and any articles have been marked with the process mark,
13015 save those articles instead.
13016 The variable `gnus-default-article-saver' specifies the saver function."
13018 (gnus-set-global-variables)
13019 (let ((articles (gnus-summary-work-articles n))
13020 (save-buffer (save-excursion
13021 (nnheader-set-temp-buffer " *Gnus Save*")))
13022 file header article)
13024 (setq header (gnus-summary-article-header
13025 (setq article (pop articles))))
13026 (if (not (vectorp header))
13027 ;; This is a pseudo-article.
13028 (if (assq 'name header)
13029 (gnus-copy-file (cdr (assq 'name header)))
13030 (gnus-message 1 "Article %d is unsaveable" article))
13031 ;; This is a real article.
13032 (save-window-excursion
13033 (gnus-summary-select-article t nil nil article))
13035 (set-buffer save-buffer)
13037 (insert-buffer-substring gnus-original-article-buffer))
13038 (unless gnus-save-all-headers
13039 ;; Remove headers accoring to `gnus-saved-headers'.
13040 (let ((gnus-visible-headers
13041 (or gnus-saved-headers gnus-visible-headers))
13042 (gnus-article-buffer save-buffer))
13043 (gnus-article-hide-headers 1 t)))
13044 (save-window-excursion
13045 (if (not gnus-default-article-saver)
13046 (error "No default saver is defined.")
13047 ;; !!! Magic! The saving functions all save
13048 ;; `gnus-original-article-buffer' (or so they think),
13049 ;; but we bind that variable to our save-buffer.
13050 (set-buffer gnus-article-buffer)
13051 (let ((gnus-original-article-buffer save-buffer))
13052 (set-buffer gnus-summary-buffer)
13053 (setq file (funcall
13054 gnus-default-article-saver
13056 ((not gnus-prompt-before-saving)
13058 ((eq gnus-prompt-before-saving 'always)
13061 (gnus-summary-remove-process-mark article)
13063 (gnus-summary-set-saved-mark article))))
13064 (gnus-kill-buffer save-buffer)
13065 (gnus-summary-position-point)
13068 (defun gnus-summary-pipe-output (&optional arg)
13069 "Pipe the current article to a subprocess.
13070 If N is a positive number, pipe the N next articles.
13071 If N is a negative number, pipe the N previous articles.
13072 If N is nil and any articles have been marked with the process mark,
13073 pipe those articles instead."
13075 (gnus-set-global-variables)
13076 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13077 (gnus-summary-save-article arg t))
13078 (gnus-configure-windows 'pipe))
13080 (defun gnus-summary-save-article-mail (&optional arg)
13081 "Append the current article to an mail file.
13082 If N is a positive number, save the N next articles.
13083 If N is a negative number, save the N previous articles.
13084 If N is nil and any articles have been marked with the process mark,
13085 save those articles instead."
13087 (gnus-set-global-variables)
13088 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13089 (gnus-summary-save-article arg)))
13091 (defun gnus-summary-save-article-rmail (&optional arg)
13092 "Append the current article to an rmail file.
13093 If N is a positive number, save the N next articles.
13094 If N is a negative number, save the N previous articles.
13095 If N is nil and any articles have been marked with the process mark,
13096 save those articles instead."
13098 (gnus-set-global-variables)
13099 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13100 (gnus-summary-save-article arg)))
13102 (defun gnus-summary-save-article-file (&optional arg)
13103 "Append the current article to a 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-file))
13111 (gnus-summary-save-article arg)))
13113 (defun gnus-summary-save-article-body-file (&optional arg)
13114 "Append the current article body to a 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-body-in-file))
13122 (gnus-summary-save-article arg)))
13124 (defun gnus-get-split-value (methods)
13125 "Return a value based on the split METHODS."
13126 (let (split-name method result match)
13129 (set-buffer gnus-original-article-buffer)
13131 (nnheader-narrow-to-headers)
13133 (goto-char (point-min))
13134 (setq method (pop methods))
13135 (setq match (car method))
13138 ;; Regular expression.
13140 (re-search-forward match nil t)
13142 ((gnus-functionp match)
13146 (setq result (funcall match gnus-newsgroup-name))))
13151 (setq result (eval match)))))
13152 (setq split-name (append (cdr method) split-name))
13153 (cond ((stringp result)
13154 (push result split-name))
13156 (setq split-name (append result split-name)))))))))
13159 (defun gnus-read-move-group-name (prompt default articles prefix)
13160 "Read a group name."
13161 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13162 (minibuffer-confirm-incomplete nil) ; XEmacs
13169 (assoc (symbol-name
13170 (car (gnus-find-method-for-group
13172 gnus-valid-select-methods))
13173 (push (list (symbol-name g)) group-map)))
13174 gnus-active-hashtb))
13176 (format "%s %s to:"
13178 (if (> (length articles) 1)
13179 (format "these %d articles" (length articles))
13184 (gnus-completing-read default prom
13185 group-map nil nil prefix
13186 'gnus-group-history))
13187 ((= 1 (length split-name))
13188 (gnus-completing-read (car split-name) prom group-map
13190 'gnus-group-history))
13192 (gnus-completing-read nil prom
13193 (mapcar (lambda (el) (list el))
13194 (nreverse split-name))
13196 'gnus-group-history)))))
13198 (if (or (string= to-newsgroup "")
13199 (string= to-newsgroup prefix))
13200 (setq to-newsgroup (or default "")))
13201 (or (gnus-active to-newsgroup)
13202 (gnus-activate-group to-newsgroup)
13203 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13205 (or (and (gnus-request-create-group
13206 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13207 (gnus-activate-group to-newsgroup nil nil
13208 (gnus-group-name-to-method
13210 (error "Couldn't create group %s" to-newsgroup)))
13211 (error "No such group: %s" to-newsgroup)))
13214 (defun gnus-read-save-file-name (prompt default-name)
13215 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13217 ;; Let the split methods have their say.
13219 ;; No split name was found.
13222 (concat prompt " (default "
13223 (file-name-nondirectory default-name) ") ")
13224 (file-name-directory default-name)
13226 ;; A single split name was found
13227 ((= 1 (length split-name))
13228 (let* ((name (car split-name))
13229 (dir (cond ((file-directory-p name)
13230 (file-name-as-directory name))
13231 ((file-exists-p name) name)
13232 (t gnus-article-save-directory))))
13234 (concat prompt " (default " name ") ")
13236 ;; A list of splits was found.
13238 (setq split-name (nreverse split-name))
13240 (let ((file-name-history (nconc split-name file-name-history)))
13243 (concat prompt " (`M-p' for defaults) ")
13244 gnus-article-save-directory
13245 (car split-name))))
13246 (car (push result file-name-history)))))))
13247 ;; If we have read a directory, we append the default file name.
13248 (when (file-directory-p file)
13249 (setq file (concat (file-name-as-directory file)
13250 (file-name-nondirectory default-name))))
13251 ;; Possibly translate some charaters.
13252 (nnheader-translate-file-chars file)))
13254 (defun gnus-article-archive-name (group)
13255 "Return the first instance of an \"Archive-name\" in the current buffer."
13256 (let ((case-fold-search t))
13257 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13258 (match-string 1))))
13260 (defun gnus-summary-save-in-rmail (&optional filename)
13261 "Append this article to Rmail file.
13262 Optional argument FILENAME specifies file name.
13263 Directory to save to is default to `gnus-article-save-directory'."
13265 (gnus-set-global-variables)
13266 (let ((default-name
13267 (funcall gnus-rmail-save-name gnus-newsgroup-name
13268 gnus-current-headers gnus-newsgroup-last-rmail)))
13270 (cond ((eq filename 'default)
13272 (filename filename)
13273 (t (gnus-read-save-file-name
13274 "Save in rmail file:" default-name))))
13275 (gnus-make-directory (file-name-directory filename))
13276 (gnus-eval-in-buffer-window gnus-original-article-buffer
13280 (gnus-output-to-rmail filename))))
13281 ;; Remember the directory name to save articles
13282 (setq gnus-newsgroup-last-rmail filename)))
13284 (defun gnus-summary-save-in-mail (&optional filename)
13285 "Append this article to Unix mail file.
13286 Optional argument FILENAME specifies file name.
13287 Directory to save to is default to `gnus-article-save-directory'."
13289 (gnus-set-global-variables)
13290 (let ((default-name
13291 (funcall gnus-mail-save-name gnus-newsgroup-name
13292 gnus-current-headers gnus-newsgroup-last-mail)))
13294 (cond ((eq filename 'default)
13296 (filename filename)
13297 (t (gnus-read-save-file-name
13298 "Save in Unix mail file:" default-name))))
13300 (expand-file-name filename
13302 (file-name-directory default-name))))
13303 (gnus-make-directory (file-name-directory filename))
13304 (gnus-eval-in-buffer-window gnus-original-article-buffer
13308 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13309 (gnus-output-to-rmail filename)
13310 (let ((mail-use-rfc822 t))
13311 (rmail-output filename 1 t t))))))
13312 ;; Remember the directory name to save articles.
13313 (setq gnus-newsgroup-last-mail filename)))
13315 (defun gnus-summary-save-in-file (&optional filename)
13316 "Append this article to file.
13317 Optional argument FILENAME specifies file name.
13318 Directory to save to is default to `gnus-article-save-directory'."
13320 (gnus-set-global-variables)
13321 (let ((default-name
13322 (funcall gnus-file-save-name gnus-newsgroup-name
13323 gnus-current-headers gnus-newsgroup-last-file)))
13325 (cond ((eq filename 'default)
13327 (filename filename)
13328 (t (gnus-read-save-file-name
13329 "Save in file:" default-name))))
13330 (gnus-make-directory (file-name-directory filename))
13331 (gnus-eval-in-buffer-window gnus-original-article-buffer
13335 (gnus-output-to-file filename))))
13336 ;; Remember the directory name to save articles.
13337 (setq gnus-newsgroup-last-file filename)))
13339 (defun gnus-summary-save-body-in-file (&optional filename)
13340 "Append this article body to a file.
13341 Optional argument FILENAME specifies file name.
13342 The directory to save in defaults to `gnus-article-save-directory'."
13344 (gnus-set-global-variables)
13345 (let ((default-name
13346 (funcall gnus-file-save-name gnus-newsgroup-name
13347 gnus-current-headers gnus-newsgroup-last-file)))
13349 (cond ((eq filename 'default)
13351 (filename filename)
13352 (t (gnus-read-save-file-name
13353 "Save body in file:" default-name))))
13354 (gnus-make-directory (file-name-directory filename))
13355 (gnus-eval-in-buffer-window gnus-original-article-buffer
13359 (goto-char (point-min))
13360 (and (search-forward "\n\n" nil t)
13361 (narrow-to-region (point) (point-max)))
13362 (gnus-output-to-file filename))))
13363 ;; Remember the directory name to save articles.
13364 (setq gnus-newsgroup-last-file filename)))
13366 (defun gnus-summary-save-in-pipe (&optional command)
13367 "Pipe this article to subprocess."
13369 (gnus-set-global-variables)
13371 (cond ((eq command 'default)
13372 gnus-last-shell-command)
13374 (t (read-string "Shell command on article: "
13375 gnus-last-shell-command))))
13376 (if (string-equal command "")
13377 (setq command gnus-last-shell-command))
13378 (gnus-eval-in-buffer-window gnus-article-buffer
13381 (shell-command-on-region (point-min) (point-max) command nil)))
13382 (setq gnus-last-shell-command command))
13384 ;; Summary extract commands
13386 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13387 (let ((buffer-read-only nil)
13388 (article (gnus-summary-article-number))
13390 (or (gnus-summary-goto-subject article)
13391 (error (format "No such article: %d" article)))
13392 (gnus-summary-position-point)
13393 ;; If all commands are to be bunched up on one line, we collect
13395 (if gnus-view-pseudos-separately
13397 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13400 (setq action (cdr (assq 'action (car ps))))
13401 (setq files (list (cdr (assq 'name (car ps)))))
13402 (while (and ps (cdr ps)
13403 (string= (or action "1")
13404 (or (cdr (assq 'action (cadr ps))) "2")))
13405 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13406 (setcdr ps (cddr ps)))
13409 (if (not (string-match "%s" action))
13410 (setq files (cons " " files)))
13411 (setq files (cons " " files))
13412 (and (assq 'execute (car ps))
13413 (setcdr (assq 'execute (car ps))
13414 (funcall (if (string-match "%s" action)
13417 (mapconcat (lambda (f) f) files " ")))))
13418 (setq ps (cdr ps)))))
13419 (if (and gnus-view-pseudos (not not-view))
13421 (and (assq 'execute (car pslist))
13422 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13423 (eq gnus-view-pseudos 'not-confirm)))
13424 (setq pslist (cdr pslist)))
13427 (setq after-article (or (cdr (assq 'article (car pslist)))
13428 (gnus-summary-article-number)))
13429 (gnus-summary-goto-subject after-article)
13432 (insert " " (file-name-nondirectory
13433 (cdr (assq 'name (car pslist))))
13434 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13436 (forward-line -1) ; back to `b'
13437 (gnus-add-text-properties
13438 b (1- e) (list 'gnus-number gnus-reffed-article-number
13439 gnus-mouse-face-prop gnus-mouse-face))
13441 after-article gnus-reffed-article-number
13442 gnus-unread-mark b (car pslist) 0 (- e b))
13443 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13444 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13445 (setq pslist (cdr pslist)))))))
13447 (defun gnus-pseudos< (p1 p2)
13448 (let ((c1 (cdr (assq 'action p1)))
13449 (c2 (cdr (assq 'action p2))))
13450 (and c1 c2 (string< c1 c2))))
13452 (defun gnus-request-pseudo-article (props)
13453 (cond ((assq 'execute props)
13454 (gnus-execute-command (cdr (assq 'execute props)))))
13455 (let ((gnus-current-article (gnus-summary-article-number)))
13456 (run-hooks 'gnus-mark-article-hook)))
13458 (defun gnus-execute-command (command &optional automatic)
13460 (gnus-article-setup-buffer)
13461 (set-buffer gnus-article-buffer)
13462 (setq buffer-read-only nil)
13463 (let ((command (if automatic command (read-string "Command: " command)))
13464 ;; Just binding this here doesn't help, because there might
13465 ;; be output from the process after exiting the scope of
13467 ;; (buffer-read-only nil)
13470 (insert "$ " command "\n\n")
13471 (if gnus-view-pseudo-asynchronously
13472 (start-process "gnus-execute" nil shell-file-name
13473 shell-command-switch command)
13474 (call-process shell-file-name nil t nil
13475 shell-command-switch command)))))
13477 (defun gnus-copy-file (file &optional to)
13480 (list (read-file-name "Copy file: " default-directory)
13481 (read-file-name "Copy file to: " default-directory)))
13482 (gnus-set-global-variables)
13483 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13484 (and (file-directory-p to)
13485 (setq to (concat (file-name-as-directory to)
13486 (file-name-nondirectory file))))
13487 (copy-file file to))
13489 ;; Summary kill commands.
13491 (defun gnus-summary-edit-global-kill (article)
13492 "Edit the \"global\" kill file."
13493 (interactive (list (gnus-summary-article-number)))
13494 (gnus-set-global-variables)
13495 (gnus-group-edit-global-kill article))
13497 (defun gnus-summary-edit-local-kill ()
13498 "Edit a local kill file applied to the current newsgroup."
13500 (gnus-set-global-variables)
13501 (setq gnus-current-headers (gnus-summary-article-header))
13502 (gnus-set-global-variables)
13503 (gnus-group-edit-local-kill
13504 (gnus-summary-article-number) gnus-newsgroup-name))
13508 ;;; Gnus article mode
13511 (put 'gnus-article-mode 'mode-class 'special)
13513 (if gnus-article-mode-map
13515 (setq gnus-article-mode-map (make-keymap))
13516 (suppress-keymap gnus-article-mode-map)
13518 (gnus-define-keys gnus-article-mode-map
13519 " " gnus-article-goto-next-page
13520 "\177" gnus-article-goto-prev-page
13521 [delete] gnus-article-goto-prev-page
13522 "\C-c^" gnus-article-refer-article
13523 "h" gnus-article-show-summary
13524 "s" gnus-article-show-summary
13525 "\C-c\C-m" gnus-article-mail
13526 "?" gnus-article-describe-briefly
13527 gnus-mouse-2 gnus-article-push-button
13528 "\r" gnus-article-press-button
13529 "\t" gnus-article-next-button
13530 "\M-\t" gnus-article-prev-button
13531 "<" beginning-of-buffer
13533 "\C-c\C-i" gnus-info-find-node
13534 "\C-c\C-b" gnus-bug)
13536 (substitute-key-definition
13537 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13539 (defun gnus-article-mode ()
13540 "Major mode for displaying an article.
13542 All normal editing commands are switched off.
13544 The following commands are available:
13546 \\<gnus-article-mode-map>
13547 \\[gnus-article-next-page]\t Scroll the article one page forwards
13548 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13549 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13550 \\[gnus-article-show-summary]\t Display the summary buffer
13551 \\[gnus-article-mail]\t Send a reply to the address near point
13552 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13553 \\[gnus-info-find-node]\t Go to the Gnus info node"
13555 (when (and menu-bar-mode
13556 (gnus-visual-p 'article-menu 'menu))
13557 (gnus-article-make-menu-bar))
13558 (kill-all-local-variables)
13559 (gnus-simplify-mode-line)
13560 (setq mode-name "Article")
13561 (setq major-mode 'gnus-article-mode)
13562 (make-local-variable 'minor-mode-alist)
13563 (or (assq 'gnus-show-mime minor-mode-alist)
13564 (setq minor-mode-alist
13565 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13566 (use-local-map gnus-article-mode-map)
13567 (make-local-variable 'page-delimiter)
13568 (setq page-delimiter gnus-page-delimiter)
13569 (buffer-disable-undo (current-buffer))
13570 (setq buffer-read-only t) ;Disable modification
13571 (run-hooks 'gnus-article-mode-hook))
13573 (defun gnus-article-setup-buffer ()
13574 "Initialize the article buffer."
13575 (let* ((name (if gnus-single-article-buffer "*Article*"
13576 (concat "*Article " gnus-newsgroup-name "*")))
13578 (progn (string-match "\\*Article" name)
13579 (concat " *Original Article"
13580 (substring name (match-end 0))))))
13581 (setq gnus-article-buffer name)
13582 (setq gnus-original-article-buffer original)
13583 ;; This might be a variable local to the summary buffer.
13584 (unless gnus-single-article-buffer
13586 (set-buffer gnus-summary-buffer)
13587 (setq gnus-article-buffer name)
13588 (setq gnus-original-article-buffer original)
13589 (gnus-set-global-variables))
13590 (make-local-variable 'gnus-summary-buffer))
13591 ;; Init original article buffer.
13593 (set-buffer (get-buffer-create gnus-original-article-buffer))
13594 (buffer-disable-undo (current-buffer))
13595 (setq major-mode 'gnus-original-article-mode)
13596 (make-local-variable 'gnus-original-article))
13597 (if (get-buffer name)
13600 (buffer-disable-undo (current-buffer))
13601 (setq buffer-read-only t)
13602 (gnus-add-current-to-buffer-list)
13603 (or (eq major-mode 'gnus-article-mode)
13604 (gnus-article-mode))
13607 (set-buffer (get-buffer-create name))
13608 (gnus-add-current-to-buffer-list)
13609 (gnus-article-mode)
13610 (current-buffer)))))
13612 ;; Set article window start at LINE, where LINE is the number of lines
13613 ;; from the head of the article.
13614 (defun gnus-article-set-window-start (&optional line)
13616 (get-buffer-window gnus-article-buffer t)
13618 (set-buffer gnus-article-buffer)
13619 (goto-char (point-min))
13622 (gnus-message 6 "Moved to bookmark")
13623 (search-forward "\n\n" nil t)
13624 (forward-line line)
13627 (defun gnus-kill-all-overlays ()
13628 "Delete all overlays in the current buffer."
13629 (when (fboundp 'overlay-lists)
13630 (let* ((overlayss (overlay-lists))
13631 (buffer-read-only nil)
13632 (overlays (nconc (car overlayss) (cdr overlayss))))
13634 (delete-overlay (pop overlays))))))
13636 (defun gnus-request-article-this-buffer (article group)
13637 "Get an article and insert it into this buffer."
13638 (let (do-update-line)
13642 (gnus-kill-all-overlays)
13643 (setq group (or group gnus-newsgroup-name))
13645 ;; Open server if it has closed.
13646 (gnus-check-server (gnus-find-method-for-group group))
13648 ;; Using `gnus-request-article' directly will insert the article into
13649 ;; `nntp-server-buffer' - so we'll save some time by not having to
13650 ;; copy it from the server buffer into the article buffer.
13652 ;; We only request an article by message-id when we do not have the
13653 ;; headers for it, so we'll have to get those.
13654 (when (stringp article)
13655 (let ((gnus-override-method gnus-refer-article-method))
13656 (gnus-read-header article)))
13658 ;; If the article number is negative, that means that this article
13659 ;; doesn't belong in this newsgroup (possibly), so we find its
13660 ;; message-id and request it by id instead of number.
13661 (when (and (numberp article)
13662 gnus-summary-buffer
13663 (get-buffer gnus-summary-buffer)
13664 (buffer-name (get-buffer gnus-summary-buffer)))
13666 (set-buffer gnus-summary-buffer)
13667 (let ((header (gnus-summary-article-header article)))
13670 ((memq article gnus-newsgroup-sparse)
13671 ;; This is a sparse gap article.
13672 (setq do-update-line article)
13673 (setq article (mail-header-id header))
13674 (let ((gnus-override-method gnus-refer-article-method))
13675 (gnus-read-header article))
13676 (setq gnus-newsgroup-sparse
13677 (delq article gnus-newsgroup-sparse)))
13679 ;; It's a real article.
13680 (setq article (mail-header-id header)))
13682 ;; It is an extracted pseudo-article.
13683 (setq article 'pseudo)
13684 (gnus-request-pseudo-article header))))
13686 (let ((method (gnus-find-method-for-group
13687 gnus-newsgroup-name)))
13688 (if (not (eq (car method) 'nneething))
13690 (let ((dir (concat (file-name-as-directory (nth 1 method))
13691 (mail-header-subject header))))
13692 (if (file-directory-p dir)
13694 (setq article 'nneething)
13695 (gnus-group-enter-directory dir)))))))))
13698 ;; Refuse to select canceled articles.
13699 ((and (numberp article)
13700 gnus-summary-buffer
13701 (get-buffer gnus-summary-buffer)
13702 (buffer-name (get-buffer gnus-summary-buffer))
13703 (eq (cdr (save-excursion
13704 (set-buffer gnus-summary-buffer)
13705 (assq article gnus-newsgroup-reads)))
13706 gnus-canceled-mark))
13708 ;; We first check `gnus-original-article-buffer'.
13709 ((and (get-buffer gnus-original-article-buffer)
13712 (set-buffer gnus-original-article-buffer)
13713 (and (equal (car gnus-original-article) group)
13714 (eq (cdr gnus-original-article) article))))
13715 (insert-buffer-substring gnus-original-article-buffer)
13717 ;; Check the backlog.
13718 ((and gnus-keep-backlog
13719 (gnus-backlog-request-article group article (current-buffer)))
13721 ;; Check the cache.
13722 ((and gnus-use-cache
13724 (gnus-cache-request-article article group))
13726 ;; Get the article and put into the article buffer.
13727 ((or (stringp article) (numberp article))
13728 (let ((gnus-override-method
13729 (and (stringp article) gnus-refer-article-method))
13730 (buffer-read-only nil))
13732 (gnus-kill-all-overlays)
13733 (if (gnus-request-article article group (current-buffer))
13735 (and gnus-keep-backlog
13737 (gnus-backlog-enter-article
13738 group article (current-buffer)))
13740 ;; It was a pseudo.
13743 ;; Take the article from the original article buffer
13744 ;; and place it in the buffer it's supposed to be in.
13745 (when (and (get-buffer gnus-article-buffer)
13746 ;;(numberp article)
13747 (equal (buffer-name (current-buffer))
13748 (buffer-name (get-buffer gnus-article-buffer))))
13750 (if (get-buffer gnus-original-article-buffer)
13751 (set-buffer (get-buffer gnus-original-article-buffer))
13752 (set-buffer (get-buffer-create gnus-original-article-buffer))
13753 (buffer-disable-undo (current-buffer))
13754 (setq major-mode 'gnus-original-article-mode)
13755 (setq buffer-read-only t)
13756 (gnus-add-current-to-buffer-list))
13757 (let (buffer-read-only)
13759 (insert-buffer-substring gnus-article-buffer))
13760 (setq gnus-original-article (cons group article))))
13762 ;; Update sparse articles.
13763 (when (and do-update-line
13764 (or (numberp article)
13765 (stringp article)))
13766 (let ((buf (current-buffer)))
13767 (set-buffer gnus-summary-buffer)
13768 (gnus-summary-update-article do-update-line)
13769 (gnus-summary-goto-subject do-update-line nil t)
13770 (set-window-point (get-buffer-window (current-buffer) t)
13772 (set-buffer buf))))))
13774 (defun gnus-read-header (id &optional header)
13775 "Read the headers of article ID and enter them into the Gnus system."
13776 (let ((group gnus-newsgroup-name)
13777 (gnus-override-method
13778 (and (gnus-news-group-p gnus-newsgroup-name)
13779 gnus-refer-article-method))
13781 ;; First we check to see whether the header in question is already
13784 ;; This is a Message-ID.
13785 (setq header (or header (gnus-id-to-header id)))
13786 ;; This is an article number.
13787 (setq header (or header (gnus-summary-article-header id))))
13789 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13790 ;; We have found the header.
13792 ;; We have to really fetch the header to this article.
13793 (when (setq where (gnus-request-head id group))
13795 (set-buffer nntp-server-buffer)
13796 (goto-char (point-max))
13798 (goto-char (point-min))
13802 ((cdr where) (cdr where))
13803 (header (mail-header-number header))
13804 (t gnus-reffed-article-number))
13806 (insert " Article retrieved.\n"))
13808 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13809 ; (setcar (gnus-id-to-thread id) nil))
13810 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13811 () ; Malformed head.
13812 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13813 (if (and (stringp id)
13814 (not (string= (gnus-group-real-name group)
13816 ;; If we fetched by Message-ID and the article came
13817 ;; from a different group, we fudge some bogus article
13818 ;; numbers for this article.
13819 (mail-header-set-number header gnus-reffed-article-number))
13820 (decf gnus-reffed-article-number)
13821 (gnus-remove-header (mail-header-number header))
13822 (push header gnus-newsgroup-headers)
13823 (setq gnus-current-headers header)
13824 (push (mail-header-number header) gnus-newsgroup-limit))
13827 (defun gnus-remove-header (number)
13828 "Remove header NUMBER from `gnus-newsgroup-headers'."
13829 (if (and gnus-newsgroup-headers
13830 (= number (mail-header-number (car gnus-newsgroup-headers))))
13831 (pop gnus-newsgroup-headers)
13832 (let ((headers gnus-newsgroup-headers))
13833 (while (and (cdr headers)
13834 (not (= number (mail-header-number (cadr headers)))))
13836 (when (cdr headers)
13837 (setcdr headers (cddr headers))))))
13839 (defun gnus-article-prepare (article &optional all-headers header)
13840 "Prepare ARTICLE in article mode buffer.
13841 ARTICLE should either be an article number or a Message-ID.
13842 If ARTICLE is an id, HEADER should be the article headers.
13843 If ALL-HEADERS is non-nil, no headers are hidden."
13845 ;; Make sure we start in a summary buffer.
13846 (unless (eq major-mode 'gnus-summary-mode)
13847 (set-buffer gnus-summary-buffer))
13848 (setq gnus-summary-buffer (current-buffer))
13849 ;; Make sure the connection to the server is alive.
13850 (unless (gnus-server-opened
13851 (gnus-find-method-for-group gnus-newsgroup-name))
13852 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13853 (gnus-request-group gnus-newsgroup-name t))
13854 (let* ((article (if header (mail-header-number header) article))
13855 (summary-buffer (current-buffer))
13856 (internal-hook gnus-article-internal-prepare-hook)
13857 (group gnus-newsgroup-name)
13860 (gnus-article-setup-buffer)
13861 (set-buffer gnus-article-buffer)
13862 ;; Deactivate active regions.
13863 (when (and (boundp 'transient-mark-mode)
13864 transient-mark-mode)
13865 (setq mark-active nil))
13866 (if (not (setq result (let ((buffer-read-only nil))
13867 (gnus-request-article-this-buffer
13869 ;; There is no such article.
13871 (when (and (numberp article)
13872 (not (memq article gnus-newsgroup-sparse)))
13873 (setq gnus-article-current
13874 (cons gnus-newsgroup-name article))
13875 (set-buffer gnus-summary-buffer)
13876 (setq gnus-current-article article)
13877 (gnus-summary-mark-article article gnus-canceled-mark))
13878 (unless (memq article gnus-newsgroup-sparse)
13880 1 "No such article (may have expired or been canceled)")))
13881 (if (or (eq result 'pseudo) (eq result 'nneething))
13884 (set-buffer summary-buffer)
13885 (setq gnus-last-article gnus-current-article
13886 gnus-newsgroup-history (cons gnus-current-article
13887 gnus-newsgroup-history)
13888 gnus-current-article 0
13889 gnus-current-headers nil
13890 gnus-article-current nil)
13891 (if (eq result 'nneething)
13892 (gnus-configure-windows 'summary)
13893 (gnus-configure-windows 'article))
13894 (gnus-set-global-variables))
13895 (gnus-set-mode-line 'article))
13896 ;; The result from the `request' was an actual article -
13897 ;; or at least some text that is now displayed in the
13899 (if (and (numberp article)
13900 (not (eq article gnus-current-article)))
13901 ;; Seems like a new article has been selected.
13902 ;; `gnus-current-article' must be an article number.
13904 (set-buffer summary-buffer)
13905 (setq gnus-last-article gnus-current-article
13906 gnus-newsgroup-history (cons gnus-current-article
13907 gnus-newsgroup-history)
13908 gnus-current-article article
13909 gnus-current-headers
13910 (gnus-summary-article-header gnus-current-article)
13911 gnus-article-current
13912 (cons gnus-newsgroup-name gnus-current-article))
13913 (unless (vectorp gnus-current-headers)
13914 (setq gnus-current-headers nil))
13915 (gnus-summary-show-thread)
13916 (run-hooks 'gnus-mark-article-hook)
13917 (gnus-set-mode-line 'summary)
13918 (and (gnus-visual-p 'article-highlight 'highlight)
13919 (run-hooks 'gnus-visual-mark-article-hook))
13920 ;; Set the global newsgroup variables here.
13921 ;; Suggested by Jim Sisolak
13922 ;; <sisolak@trans4.neep.wisc.edu>.
13923 (gnus-set-global-variables)
13924 (setq gnus-have-all-headers
13925 (or all-headers gnus-show-all-headers))
13926 (and gnus-use-cache
13927 (vectorp (gnus-summary-article-header article))
13928 (gnus-cache-possibly-enter-article
13930 (gnus-summary-article-header article)
13931 (memq article gnus-newsgroup-marked)
13932 (memq article gnus-newsgroup-dormant)
13933 (memq article gnus-newsgroup-unreads)))))
13934 (when (or (numberp article)
13936 ;; Hooks for getting information from the article.
13937 ;; This hook must be called before being narrowed.
13938 (let (buffer-read-only)
13939 (run-hooks 'internal-hook)
13940 (run-hooks 'gnus-article-prepare-hook)
13941 ;; Decode MIME message.
13943 (if (or (not gnus-strict-mime)
13944 (gnus-fetch-field "Mime-Version"))
13945 (funcall gnus-show-mime-method)
13946 (funcall gnus-decode-encoded-word-method)))
13947 ;; Perform the article display hooks.
13948 (run-hooks 'gnus-article-display-hook))
13950 (goto-char (point-min))
13951 (and gnus-break-pages (gnus-narrow-to-page)))
13952 (gnus-set-mode-line 'article)
13953 (gnus-configure-windows 'article)
13954 (goto-char (point-min))
13957 (defun gnus-article-show-all-headers ()
13958 "Show all article headers in article mode buffer."
13960 (gnus-article-setup-buffer)
13961 (set-buffer gnus-article-buffer)
13962 (let ((buffer-read-only nil))
13963 (gnus-unhide-text (point-min) (point-max)))))
13965 (defun gnus-article-hide-headers-if-wanted ()
13966 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13967 Provided for backwards compatibility."
13968 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13969 gnus-inhibit-hiding
13970 (gnus-article-hide-headers)))
13972 (defsubst gnus-article-header-rank ()
13973 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13974 (let ((list gnus-sorted-header-list)
13977 (when (looking-at (car list))
13979 (setq list (cdr list))
13983 (defun gnus-article-hide-headers (&optional arg delete)
13984 "Toggle whether to hide unwanted headers and possibly sort them as well.
13985 If given a negative prefix, always show; if given a positive prefix,
13987 (interactive (gnus-hidden-arg))
13988 (if (gnus-article-check-hidden-text 'headers arg)
13989 ;; Show boring headers as well.
13990 (gnus-article-show-hidden-text 'boring-headers)
13991 ;; This function might be inhibited.
13992 (unless gnus-inhibit-hiding
13994 (set-buffer gnus-article-buffer)
13996 (let ((buffer-read-only nil)
13997 (props (nconc (list 'gnus-type 'headers)
13998 gnus-hidden-properties))
13999 (max (1+ (length gnus-sorted-header-list)))
14000 (ignored (when (not (stringp gnus-visible-headers))
14001 (cond ((stringp gnus-ignored-headers)
14002 gnus-ignored-headers)
14003 ((listp gnus-ignored-headers)
14004 (mapconcat 'identity gnus-ignored-headers
14007 (cond ((stringp gnus-visible-headers)
14008 gnus-visible-headers)
14009 ((and gnus-visible-headers
14010 (listp gnus-visible-headers))
14011 (mapconcat 'identity gnus-visible-headers "\\|"))))
14012 (inhibit-point-motion-hooks t)
14014 ;; First we narrow to just the headers.
14016 (goto-char (point-min))
14017 ;; Hide any "From " lines at the beginning of (mail) articles.
14018 (while (looking-at "From ")
14022 (delete-region (point-min) (point))
14023 (gnus-hide-text (point-min) (point) props)))
14024 ;; Then treat the rest of the header lines.
14027 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
14028 ;; Then we use the two regular expressions
14029 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
14030 ;; select which header lines is to remain visible in the
14032 (goto-char (point-min))
14033 (while (re-search-forward "^[^ \t]*:" nil t)
14034 (beginning-of-line)
14035 ;; We add the headers we want to keep to a list and delete
14036 ;; them from the buffer.
14037 (gnus-put-text-property
14038 (point) (1+ (point)) 'message-rank
14039 (if (or (and visible (looking-at visible))
14041 (not (looking-at ignored))))
14042 (gnus-article-header-rank)
14045 (message-sort-headers-1)
14046 (when (setq beg (text-property-any
14047 (point-min) (point-max) 'message-rank (+ 2 max)))
14048 ;; We make the unwanted headers invisible.
14050 (delete-region beg (point-max))
14051 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
14052 (gnus-hide-text-type beg (point-max) 'headers))
14053 ;; Work around XEmacs lossage.
14054 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
14056 (defun gnus-article-hide-boring-headers (&optional arg)
14057 "Toggle hiding of headers that aren't very interesting.
14058 If given a negative prefix, always show; if given a positive prefix,
14060 (interactive (gnus-hidden-arg))
14061 (unless (gnus-article-check-hidden-text 'boring-headers arg)
14063 (set-buffer gnus-article-buffer)
14065 (let ((buffer-read-only nil)
14066 (list gnus-boring-article-headers)
14067 (inhibit-point-motion-hooks t)
14069 (nnheader-narrow-to-headers)
14071 (setq elem (pop list))
14072 (goto-char (point-min))
14074 ;; Hide empty headers.
14076 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14078 (gnus-hide-text-type
14079 (progn (beginning-of-line) (point))
14082 (if (re-search-forward "^[^ \t]" nil t)
14083 (match-beginning 0)
14086 ;; Hide boring Newsgroups header.
14087 ((eq elem 'newsgroups)
14088 (when (equal (message-fetch-field "newsgroups")
14089 (gnus-group-real-name gnus-newsgroup-name))
14090 (gnus-article-hide-header "newsgroups")))
14091 ((eq elem 'followup-to)
14092 (when (equal (message-fetch-field "followup-to")
14093 (message-fetch-field "newsgroups"))
14094 (gnus-article-hide-header "followup-to")))
14095 ((eq elem 'reply-to)
14096 (let ((from (message-fetch-field "from"))
14097 (reply-to (message-fetch-field "reply-to")))
14101 (nth 1 (funcall gnus-extract-address-components from))
14102 (nth 1 (funcall gnus-extract-address-components
14104 (gnus-article-hide-header "reply-to"))))
14106 (let ((date (message-fetch-field "date")))
14108 (< (gnus-days-between date (current-time-string))
14110 (gnus-article-hide-header "date")))))))))))
14112 (defun gnus-article-hide-header (header)
14114 (goto-char (point-min))
14115 (when (re-search-forward (concat "^" header ":") nil t)
14116 (gnus-hide-text-type
14117 (progn (beginning-of-line) (point))
14120 (if (re-search-forward "^[^ \t]" nil t)
14121 (match-beginning 0)
14123 'boring-headers))))
14125 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14126 (defun gnus-article-treat-overstrike ()
14127 "Translate overstrikes into bold text."
14130 (set-buffer gnus-article-buffer)
14131 (let ((buffer-read-only nil))
14132 (while (search-forward "\b" nil t)
14133 (let ((next (following-char))
14134 (previous (char-after (- (point) 2))))
14136 ((eq next previous)
14137 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14138 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14140 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14141 (gnus-put-text-property
14142 (- (point) 2) (1- (point)) 'face 'underline))
14144 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14145 (gnus-put-text-property
14146 (point) (1+ (point)) 'face 'underline))))))))
14148 (defun gnus-article-word-wrap ()
14149 "Format too long lines."
14152 (set-buffer gnus-article-buffer)
14153 (let ((buffer-read-only nil))
14155 (goto-char (point-min))
14156 (search-forward "\n\n" nil t)
14158 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14159 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14160 (adaptive-fill-mode t))
14161 (while (not (eobp))
14162 (and (>= (current-column) (min fill-column (window-width)))
14163 (/= (preceding-char) ?:)
14164 (fill-paragraph nil))
14165 (end-of-line 2))))))
14167 (defun gnus-article-remove-cr ()
14168 "Remove carriage returns from an article."
14171 (set-buffer gnus-article-buffer)
14172 (let ((buffer-read-only nil))
14173 (goto-char (point-min))
14174 (while (search-forward "\r" nil t)
14175 (replace-match "" t t)))))
14177 (defun gnus-article-remove-trailing-blank-lines ()
14178 "Remove all trailing blank lines from the article."
14181 (set-buffer gnus-article-buffer)
14182 (let ((buffer-read-only nil))
14183 (goto-char (point-max))
14187 (while (looking-at "^[ \t]*$")
14192 (defun gnus-article-display-x-face (&optional force)
14193 "Look for an X-Face header and display it if present."
14194 (interactive (list 'force))
14196 (set-buffer gnus-article-buffer)
14197 ;; Delete the old process, if any.
14198 (when (process-status "gnus-x-face")
14199 (delete-process "gnus-x-face"))
14200 (let ((inhibit-point-motion-hooks t)
14201 (case-fold-search nil)
14204 (nnheader-narrow-to-headers)
14205 (setq from (message-fetch-field "from"))
14206 (goto-char (point-min))
14207 (when (and gnus-article-x-face-command
14209 ;; Check whether this face is censored.
14210 (not gnus-article-x-face-too-ugly)
14211 (and gnus-article-x-face-too-ugly from
14212 (not (string-match gnus-article-x-face-too-ugly
14214 ;; Has to be present.
14215 (re-search-forward "^X-Face: " nil t))
14216 ;; We now have the area of the buffer where the X-Face is stored.
14217 (let ((beg (point))
14218 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14219 ;; We display the face.
14220 (if (symbolp gnus-article-x-face-command)
14221 ;; The command is a lisp function, so we call it.
14222 (if (gnus-functionp gnus-article-x-face-command)
14223 (funcall gnus-article-x-face-command beg end)
14224 (error "%s is not a function" gnus-article-x-face-command))
14225 ;; The command is a string, so we interpret the command
14226 ;; as a, well, command, and fork it off.
14227 (let ((process-connection-type nil))
14228 (process-kill-without-query
14230 "gnus-x-face" nil shell-file-name shell-command-switch
14231 gnus-article-x-face-command))
14232 (process-send-region "gnus-x-face" beg end)
14233 (process-send-eof "gnus-x-face")))))))))
14235 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14236 (defun gnus-decode-rfc1522 ()
14237 "Hack to remove QP encoding from headers."
14238 (let ((case-fold-search t)
14239 (inhibit-point-motion-hooks t)
14240 (buffer-read-only nil)
14244 (goto-char (point-min))
14245 (or (search-forward "\n\n" nil t) (point-max)))
14247 (goto-char (point-min))
14248 (while (re-search-forward
14249 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14250 (setq string (match-string 1))
14251 (narrow-to-region (match-beginning 0) (match-end 0))
14252 (delete-region (point-min) (point-max))
14254 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14255 (subst-char-in-region (point-min) (point-max) ?_ ? )
14257 (goto-char (point-min))))))
14259 (defun gnus-article-de-quoted-unreadable (&optional force)
14260 "Do a naive translation of a quoted-printable-encoded article.
14261 This is in no way, shape or form meant as a replacement for real MIME
14262 processing, but is simply a stop-gap measure until MIME support is
14264 If FORCE, decode the article whether it is marked as quoted-printable
14266 (interactive (list 'force))
14268 (set-buffer gnus-article-buffer)
14269 (let ((case-fold-search t)
14270 (buffer-read-only nil)
14271 (type (gnus-fetch-field "content-transfer-encoding")))
14272 (gnus-decode-rfc1522)
14274 (and type (string-match "quoted-printable" (downcase type))))
14275 (goto-char (point-min))
14276 (search-forward "\n\n" nil 'move)
14277 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14279 (defun gnus-mime-decode-quoted-printable (from to)
14280 "Decode Quoted-Printable in the region between FROM and TO."
14283 (while (search-forward "=" to t)
14284 (cond ((eq (following-char) ?\n)
14287 ((looking-at "[0-9A-F][0-9A-F]")
14288 (subst-char-in-region
14289 (1- (point)) (point) ?=
14290 (hexl-hex-string-to-integer
14291 (buffer-substring (point) (+ 2 (point)))))
14295 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14297 (defun gnus-article-hide-pgp (&optional arg)
14298 "Toggle hiding of any PGP headers and signatures in the current article.
14299 If given a negative prefix, always show; if given a positive prefix,
14301 (interactive (gnus-hidden-arg))
14302 (unless (gnus-article-check-hidden-text 'pgp arg)
14304 (set-buffer gnus-article-buffer)
14305 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14306 buffer-read-only beg end)
14308 (goto-char (point-min))
14309 ;; Hide the "header".
14310 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14311 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14313 ;; Hide the actual signature.
14314 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14315 (setq end (1+ (match-beginning 0)))
14318 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14320 ;; Perhaps we shouldn't hide to the end of the buffer
14321 ;; if there is no end to the signature?
14324 ;; Hide "- " PGP quotation markers.
14325 (when (and beg end)
14326 (narrow-to-region beg end)
14327 (goto-char (point-min))
14328 (while (re-search-forward "^- " nil t)
14329 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14332 (defun gnus-article-hide-signature (&optional arg)
14333 "Hide the signature in the current article.
14334 If given a negative prefix, always show; if given a positive prefix,
14336 (interactive (gnus-hidden-arg))
14337 (unless (gnus-article-check-hidden-text 'signature arg)
14339 (set-buffer gnus-article-buffer)
14341 (let ((buffer-read-only nil))
14342 (when (gnus-narrow-to-signature)
14343 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14345 (defun gnus-article-strip-leading-blank-lines ()
14346 "Remove all blank lines from the beginning of the article."
14349 (set-buffer gnus-article-buffer)
14350 (let (buffer-read-only)
14351 (goto-char (point-min))
14352 (when (search-forward "\n\n" nil t)
14353 (while (looking-at "[ \t]$")
14354 (gnus-delete-line))))))
14356 (defvar mime::preview/content-list)
14357 (defvar mime::preview-content-info/point-min)
14358 (defun gnus-narrow-to-signature ()
14359 "Narrow to the signature."
14361 (if (and (boundp 'mime::preview/content-list)
14362 mime::preview/content-list)
14363 (let ((pcinfo (car (last mime::preview/content-list))))
14366 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14369 (goto-char (point-max))
14370 (when (re-search-backward gnus-signature-separator nil t)
14372 (when (or (null gnus-signature-limit)
14373 (and (numberp gnus-signature-limit)
14374 (< (- (point-max) (point)) gnus-signature-limit))
14375 (and (gnus-functionp gnus-signature-limit)
14376 (funcall gnus-signature-limit))
14377 (and (stringp gnus-signature-limit)
14378 (not (re-search-forward gnus-signature-limit nil t))))
14379 (narrow-to-region (point) (point-max))
14382 (defun gnus-hidden-arg ()
14383 "Return the current prefix arg as a number, or 0 if no prefix."
14384 (list (if current-prefix-arg
14385 (prefix-numeric-value current-prefix-arg)
14388 (defun gnus-article-check-hidden-text (type arg)
14389 "Return nil if hiding is necessary.
14390 Arg can be nil or a number. Nil and positive means hide, negative
14391 means show, 0 means toggle."
14393 (set-buffer gnus-article-buffer)
14394 (let ((hide (gnus-article-hidden-text-p type)))
14400 (gnus-article-show-hidden-text type))
14402 (if (eq hide 'hidden)
14403 (gnus-article-show-hidden-text type)
14406 (defun gnus-article-hidden-text-p (type)
14407 "Say whether the current buffer contains hidden text of type TYPE."
14408 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14410 (if (get-text-property pos 'invisible)
14414 (defun gnus-article-hide (&optional arg force)
14415 "Hide all the gruft in the current article.
14416 This means that PGP stuff, signatures, cited text and (some)
14417 headers will be hidden.
14418 If given a prefix, show the hidden text instead."
14419 (interactive (list current-prefix-arg 'force))
14420 (gnus-article-hide-headers arg)
14421 (gnus-article-hide-pgp arg)
14422 (gnus-article-hide-citation-maybe arg force)
14423 (gnus-article-hide-signature arg))
14425 (defun gnus-article-show-hidden-text (type &optional hide)
14426 "Show all hidden text of type TYPE.
14427 If HIDE, hide the text instead."
14429 (set-buffer gnus-article-buffer)
14430 (let ((buffer-read-only nil)
14431 (inhibit-point-motion-hooks t)
14433 (while (gnus-goto-char (text-property-any
14434 beg (point-max) 'gnus-type type))
14438 (gnus-hide-text beg (point) gnus-hidden-properties)
14439 (gnus-unhide-text beg (point)))
14440 (setq beg (point)))
14443 (defvar gnus-article-time-units
14444 `((year . ,(* 365.25 24 60 60))
14445 (week . ,(* 7 24 60 60))
14446 (day . ,(* 24 60 60))
14447 (hour . ,(* 60 60))
14450 "Mapping from time units to seconds.")
14452 (defun gnus-article-date-ut (&optional type highlight)
14453 "Convert DATE date to universal time in the current article.
14454 If TYPE is `local', convert to local time; if it is `lapsed', output
14455 how much time has lapsed since DATE."
14456 (interactive (list 'ut t))
14457 (let* ((header (or gnus-current-headers
14458 (gnus-summary-article-header) ""))
14459 (date (and (vectorp header) (mail-header-date header)))
14460 (date-regexp "^Date: \\|^X-Sent: ")
14461 (now (current-time))
14462 (inhibit-point-motion-hooks t)
14464 (when (and date (not (string= date "")))
14466 (set-buffer gnus-article-buffer)
14468 (nnheader-narrow-to-headers)
14469 (let ((buffer-read-only nil))
14470 ;; Delete any old Date headers.
14471 (if (re-search-forward date-regexp nil t)
14473 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14474 eface (get-text-property (1- (gnus-point-at-eol))
14476 (message-remove-header date-regexp t)
14477 (beginning-of-line))
14478 (goto-char (point-max)))
14479 (insert (gnus-make-date-line date type))
14480 ;; Do highlighting.
14482 (when (and (gnus-visual-p 'article-highlight 'highlight)
14483 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14484 (gnus-put-text-property (match-beginning 1) (match-end 1)
14486 (gnus-put-text-property (match-beginning 2) (match-end 2)
14487 'face eface))))))))
14489 (defun gnus-make-date-line (date type)
14490 "Return a DATE line of TYPE."
14492 ;; Convert to the local timezone. We have to slap a
14493 ;; `condition-case' round the calls to the timezone
14494 ;; functions since they aren't particularly resistant to
14497 (concat "Date: " (condition-case ()
14498 (timezone-make-date-arpa-standard date)
14501 ;; Convert to Universal Time.
14505 (timezone-make-date-arpa-standard date nil "UT")
14508 ;; Get the original date from the article.
14509 ((eq type 'original)
14510 (concat "Date: " date "\n"))
14511 ;; Do an X-Sent lapsed format.
14513 ;; If the date is seriously mangled, the timezone
14514 ;; functions are liable to bug out, so we condition-case
14515 ;; the entire thing.
14516 (let* ((now (current-time))
14521 (timezone-make-date-arpa-standard
14522 (current-time-string now)
14523 (current-time-zone now) "UT"))
14525 (timezone-make-date-arpa-standard
14528 (real-sec (+ (* (float (car real-time)) 65536)
14530 (sec (abs real-sec))
14533 ((equal real-time '(0 0))
14534 "X-Sent: Unknown\n")
14540 ;; This is a bit convoluted, but basically we go
14541 ;; through the time units for years, weeks, etc,
14542 ;; and divide things to see whether that results
14543 ;; in positive answers.
14546 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14547 ;; The (remaining) seconds are too few to
14548 ;; be divided into this time unit.
14550 ;; It's big enough, so we output it.
14551 (setq sec (- sec (* num (cdr unit))))
14553 (concat (if prev ", " "") (int-to-string
14555 " " (symbol-name (car unit))
14556 (if (> num 1) "s" ""))
14558 gnus-article-time-units "")
14559 ;; If dates are odd, then it might appear like the
14560 ;; article was sent in the future.
14563 " in the future\n"))))))
14565 (error "Unknown conversion type: %s" type))))
14567 (defun gnus-article-date-local (&optional highlight)
14568 "Convert the current article date to the local timezone."
14569 (interactive (list t))
14570 (gnus-article-date-ut 'local highlight))
14572 (defun gnus-article-date-original (&optional highlight)
14573 "Convert the current article date to what it was originally.
14574 This is only useful if you have used some other date conversion
14575 function and want to see what the date was before converting."
14576 (interactive (list t))
14577 (gnus-article-date-ut 'original highlight))
14579 (defun gnus-article-date-lapsed (&optional highlight)
14580 "Convert the current article date to time lapsed since it was sent."
14581 (interactive (list t))
14582 (gnus-article-date-ut 'lapsed highlight))
14584 (defun gnus-article-maybe-highlight ()
14585 "Do some article highlighting if `gnus-visual' is non-nil."
14586 (if (gnus-visual-p 'article-highlight 'highlight)
14587 (gnus-article-highlight-some)))
14589 ;;; Article savers.
14591 (defun gnus-output-to-rmail (file-name)
14592 "Append the current article to an Rmail file named FILE-NAME."
14594 ;; Most of these codes are borrowed from rmailout.el.
14595 (setq file-name (expand-file-name file-name))
14596 (setq rmail-default-rmail-file file-name)
14597 (let ((artbuf (current-buffer))
14598 (tmpbuf (get-buffer-create " *Gnus-output*")))
14600 (or (get-file-buffer file-name)
14601 (file-exists-p file-name)
14602 (if (gnus-yes-or-no-p
14603 (concat "\"" file-name "\" does not exist, create it? "))
14604 (let ((file-buffer (create-file-buffer file-name)))
14606 (set-buffer file-buffer)
14607 (rmail-insert-rmail-file-header)
14608 (let ((require-final-newline nil))
14609 (write-region (point-min) (point-max) file-name t 1)))
14610 (kill-buffer file-buffer))
14611 (error "Output file does not exist")))
14612 (set-buffer tmpbuf)
14613 (buffer-disable-undo (current-buffer))
14615 (insert-buffer-substring artbuf)
14616 (gnus-convert-article-to-rmail)
14617 ;; Decide whether to append to a file or to an Emacs buffer.
14618 (let ((outbuf (get-file-buffer file-name)))
14620 (append-to-file (point-min) (point-max) file-name)
14621 ;; File has been visited, in buffer OUTBUF.
14622 (set-buffer outbuf)
14623 (let ((buffer-read-only nil)
14624 (msg (and (boundp 'rmail-current-message)
14625 (symbol-value 'rmail-current-message))))
14626 ;; If MSG is non-nil, buffer is in RMAIL mode.
14629 (narrow-to-region (point-max) (point-max))))
14630 (insert-buffer-substring tmpbuf)
14633 (goto-char (point-min))
14635 (search-backward "\^_")
14636 (narrow-to-region (point) (point-max))
14637 (goto-char (1+ (point-min)))
14638 (rmail-count-new-messages t)
14639 (rmail-show-message msg)))))))
14640 (kill-buffer tmpbuf)))
14642 (defun gnus-output-to-file (file-name)
14643 "Append the current article to a file named FILE-NAME."
14644 (let ((artbuf (current-buffer)))
14645 (nnheader-temp-write nil
14646 (insert-buffer-substring artbuf)
14647 ;; Append newline at end of the buffer as separator, and then
14648 ;; save it to file.
14649 (goto-char (point-max))
14651 (append-to-file (point-min) (point-max) file-name))))
14653 (defun gnus-convert-article-to-rmail ()
14654 "Convert article in current buffer to Rmail message format."
14655 (let ((buffer-read-only nil))
14656 ;; Convert article directly into Babyl format.
14657 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14658 (goto-char (point-min))
14659 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14660 (while (search-forward "\n\^_" nil t) ;single char
14661 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14662 (goto-char (point-max))
14665 (defun gnus-narrow-to-page (&optional arg)
14666 "Narrow the article buffer to a page.
14667 If given a numerical ARG, move forward ARG pages."
14669 (setq arg (if arg (prefix-numeric-value arg) 0))
14671 (set-buffer gnus-article-buffer)
14672 (goto-char (point-min))
14674 (when (gnus-visual-p 'page-marker)
14675 (let ((buffer-read-only nil))
14676 (gnus-remove-text-with-property 'gnus-prev)
14677 (gnus-remove-text-with-property 'gnus-next)))
14680 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14682 (re-search-forward page-delimiter nil 'move arg)))
14683 (goto-char (match-end 0)))
14686 (if (re-search-forward page-delimiter nil 'move)
14687 (match-beginning 0)
14689 (when (and (gnus-visual-p 'page-marker)
14690 (not (= (point-min) 1)))
14692 (goto-char (point-min))
14693 (gnus-insert-prev-page-button)))
14694 (when (and (gnus-visual-p 'page-marker)
14695 (not (= (1- (point-max)) (buffer-size))))
14697 (goto-char (point-max))
14698 (gnus-insert-next-page-button)))))
14700 ;; Article mode commands
14702 (defun gnus-article-goto-next-page ()
14703 "Show the next page of the article."
14705 (when (gnus-article-next-page)
14706 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14708 (defun gnus-article-goto-prev-page ()
14709 "Show the next page of the article."
14711 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14712 (gnus-article-prev-page nil)))
14714 (defun gnus-article-next-page (&optional lines)
14715 "Show the next page of the current article.
14716 If end of article, return non-nil. Otherwise return nil.
14717 Argument LINES specifies lines to be scrolled up."
14719 (move-to-window-line -1)
14720 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14721 (if (save-excursion
14723 (and (pos-visible-in-window-p) ;Not continuation line.
14725 ;; Nothing in this page.
14726 (if (or (not gnus-break-pages)
14729 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14731 (gnus-narrow-to-page 1) ;Go to next page.
14733 ;; More in this page.
14737 ;; Long lines may cause an end-of-buffer error.
14738 (goto-char (point-max))))
14739 (move-to-window-line 0)
14742 (defun gnus-article-prev-page (&optional lines)
14743 "Show previous page of current article.
14744 Argument LINES specifies lines to be scrolled down."
14746 (move-to-window-line 0)
14747 (if (and gnus-break-pages
14749 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14751 (gnus-narrow-to-page -1) ;Go to previous page.
14752 (goto-char (point-max))
14756 (scroll-down lines)
14758 (move-to-window-line 0))))
14760 (defun gnus-article-refer-article ()
14761 "Read article specified by message-id around point."
14763 (let ((point (point)))
14764 (search-forward ">" nil t) ;Move point to end of "<....>".
14765 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14766 (let ((message-id (match-string 1)))
14768 (set-buffer gnus-summary-buffer)
14769 (gnus-summary-refer-article message-id))
14770 (goto-char (point))
14771 (error "No references around point"))))
14773 (defun gnus-article-show-summary ()
14774 "Reconfigure windows to show summary buffer."
14776 (gnus-configure-windows 'article)
14777 (gnus-summary-goto-subject gnus-current-article))
14779 (defun gnus-article-describe-briefly ()
14780 "Describe article mode commands briefly."
14783 (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")))
14785 (defun gnus-article-summary-command ()
14786 "Execute the last keystroke in the summary buffer."
14788 (let ((obuf (current-buffer))
14789 (owin (current-window-configuration))
14791 (switch-to-buffer gnus-summary-buffer 'norecord)
14792 (setq func (lookup-key (current-local-map) (this-command-keys)))
14793 (call-interactively func)
14795 (set-window-configuration owin)
14796 (set-window-point (get-buffer-window (current-buffer)) (point))))
14798 (defun gnus-article-summary-command-nosave ()
14799 "Execute the last keystroke in the summary buffer."
14802 (pop-to-buffer gnus-summary-buffer 'norecord)
14803 (setq func (lookup-key (current-local-map) (this-command-keys)))
14804 (call-interactively func)))
14806 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14807 "Read a summary buffer key sequence and execute it from the article buffer."
14810 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14811 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14812 "=" "^" "\M-^" "|"))
14813 (nosave-but-article
14817 (set-buffer gnus-summary-buffer)
14818 (push (or key last-command-event) unread-command-events)
14819 (setq keys (read-key-sequence nil)))
14822 (if (or (member keys nosaves)
14823 (member keys nosave-but-article))
14825 (save-window-excursion
14826 (pop-to-buffer gnus-summary-buffer 'norecord)
14827 (setq func (lookup-key (current-local-map) keys)))
14830 (set-buffer gnus-summary-buffer)
14831 (call-interactively func))
14832 (when (member keys nosave-but-article)
14833 (pop-to-buffer gnus-article-buffer 'norecord)))
14834 (let ((obuf (current-buffer))
14835 (owin (current-window-configuration))
14838 (if not-restore-window
14839 (pop-to-buffer gnus-summary-buffer 'norecord)
14840 (switch-to-buffer gnus-summary-buffer 'norecord))
14841 (setq in-buffer (current-buffer))
14842 (if (setq func (lookup-key (current-local-map) keys))
14843 (call-interactively func)
14845 (when (eq in-buffer (current-buffer))
14847 (unless not-restore-window
14848 (set-window-configuration owin))
14849 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14853 ;;; Kill file handling.
14857 (defalias 'gnus-batch-kill 'gnus-batch-score)
14859 (defun gnus-batch-score ()
14860 "Run batched scoring.
14861 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14862 Newsgroups is a list of strings in Bnews format. If you want to score
14863 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14864 score the alt hierarchy, you'd say \"!alt.all\"."
14867 (gnus-newsrc-parse-options
14868 (apply (function concat)
14869 (mapcar (lambda (g) (concat g " "))
14870 command-line-args-left))))
14871 (gnus-expert-user t)
14872 (nnmail-spool-file nil)
14873 (gnus-use-dribble-file nil)
14874 (yes (car yes-and-no))
14875 (no (cdr yes-and-no))
14877 ;; Disable verbose message.
14878 gnus-novice-user gnus-large-newsgroup)
14879 ;; Eat all arguments.
14880 (setq command-line-args-left nil)
14883 ;; Apply kills to specified newsgroups in command line arguments.
14884 (setq newsrc (cdr gnus-newsrc-alist))
14886 (setq group (caar newsrc))
14887 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14888 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14890 (or (eq (car entry) t)
14891 (not (zerop (car entry)))))
14892 (if yes (string-match yes group) t)
14893 (or (null no) (not (string-match no group))))
14895 (gnus-summary-read-group group nil t nil t)
14896 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14897 (gnus-summary-exit))))
14898 (setq newsrc (cdr newsrc)))
14900 (switch-to-buffer gnus-group-buffer)
14901 (gnus-group-save-newsrc)))
14903 (defun gnus-apply-kill-file ()
14904 "Apply a kill file to the current newsgroup.
14905 Returns the number of articles marked as read."
14906 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14907 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14908 (gnus-apply-kill-file-internal)
14911 (defun gnus-kill-save-kill-buffer ()
14912 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14913 (when (get-file-buffer file)
14915 (set-buffer (get-file-buffer file))
14916 (and (buffer-modified-p) (save-buffer))
14917 (kill-buffer (current-buffer))))))
14919 (defvar gnus-kill-file-name "KILL"
14920 "Suffix of the kill files.")
14922 (defun gnus-newsgroup-kill-file (newsgroup)
14923 "Return the name of a kill file name for NEWSGROUP.
14924 If NEWSGROUP is nil, return the global kill file name instead."
14926 ;; The global KILL file is placed at top of the directory.
14927 ((or (null newsgroup)
14928 (string-equal newsgroup ""))
14929 (expand-file-name gnus-kill-file-name
14930 gnus-kill-files-directory))
14931 ;; Append ".KILL" to newsgroup name.
14932 ((gnus-use-long-file-name 'not-kill)
14933 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14934 "." gnus-kill-file-name)
14935 gnus-kill-files-directory))
14936 ;; Place "KILL" under the hierarchical directory.
14938 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14939 "/" gnus-kill-file-name)
14940 gnus-kill-files-directory))))
14947 (defvar gnus-dribble-ignore nil)
14948 (defvar gnus-dribble-eval-file nil)
14950 (defun gnus-dribble-file-name ()
14951 "Return the dribble file for the current .newsrc."
14953 (if gnus-dribble-directory
14954 (concat (file-name-as-directory gnus-dribble-directory)
14955 (file-name-nondirectory gnus-current-startup-file))
14956 gnus-current-startup-file)
14959 (defun gnus-dribble-enter (string)
14960 "Enter STRING into the dribble buffer."
14961 (if (and (not gnus-dribble-ignore)
14962 gnus-dribble-buffer
14963 (buffer-name gnus-dribble-buffer))
14964 (let ((obuf (current-buffer)))
14965 (set-buffer gnus-dribble-buffer)
14966 (insert string "\n")
14967 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14968 (bury-buffer gnus-dribble-buffer)
14969 (set-buffer obuf))))
14971 (defun gnus-dribble-read-file ()
14972 "Read the dribble file from disk."
14973 (let ((dribble-file (gnus-dribble-file-name)))
14975 (set-buffer (setq gnus-dribble-buffer
14977 (file-name-nondirectory dribble-file))))
14978 (gnus-add-current-to-buffer-list)
14980 (setq buffer-file-name dribble-file)
14982 (buffer-disable-undo (current-buffer))
14983 (bury-buffer (current-buffer))
14984 (set-buffer-modified-p nil)
14985 (let ((auto (make-auto-save-file-name))
14986 (gnus-dribble-ignore t)
14988 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14989 ;; Load whichever file is newest -- the auto save file
14990 ;; or the "real" file.
14991 (if (file-newer-than-file-p auto dribble-file)
14992 (insert-file-contents auto)
14993 (insert-file-contents dribble-file))
14994 (unless (zerop (buffer-size))
14995 (set-buffer-modified-p t))
14996 ;; Set the file modes to reflect the .newsrc file modes.
14998 (when (and (file-exists-p gnus-current-startup-file)
14999 (setq modes (file-modes gnus-current-startup-file)))
15000 (set-file-modes dribble-file modes))
15001 ;; Possibly eval the file later.
15002 (when (gnus-y-or-n-p
15003 "Auto-save file exists. Do you want to read it? ")
15004 (setq gnus-dribble-eval-file t)))))))
15006 (defun gnus-dribble-eval-file ()
15007 (when gnus-dribble-eval-file
15008 (setq gnus-dribble-eval-file nil)
15010 (let ((gnus-dribble-ignore t))
15011 (set-buffer gnus-dribble-buffer)
15012 (eval-buffer (current-buffer))))))
15014 (defun gnus-dribble-delete-file ()
15015 (when (file-exists-p (gnus-dribble-file-name))
15016 (delete-file (gnus-dribble-file-name)))
15017 (when gnus-dribble-buffer
15019 (set-buffer gnus-dribble-buffer)
15020 (let ((auto (make-auto-save-file-name)))
15021 (if (file-exists-p auto)
15022 (delete-file auto))
15024 (set-buffer-modified-p nil)))))
15026 (defun gnus-dribble-save ()
15027 (when (and gnus-dribble-buffer
15028 (buffer-name gnus-dribble-buffer))
15030 (set-buffer gnus-dribble-buffer)
15033 (defun gnus-dribble-clear ()
15034 (when (gnus-buffer-exists-p gnus-dribble-buffer)
15036 (set-buffer gnus-dribble-buffer)
15038 (set-buffer-modified-p nil)
15039 (setq buffer-saved-size (buffer-size)))))
15043 ;;; Server Communication
15046 (defun gnus-start-news-server (&optional confirm)
15047 "Open a method for getting news.
15048 If CONFIRM is non-nil, the user will be asked for an NNTP server."
15050 (if gnus-current-select-method
15051 ;; Stream is already opened.
15053 ;; Open NNTP server.
15054 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
15057 ;; Read server name with completion.
15058 (setq gnus-nntp-server
15059 (completing-read "NNTP server: "
15060 (mapcar (lambda (server) (list server))
15061 (cons (list gnus-nntp-server)
15062 gnus-secondary-servers))
15063 nil nil gnus-nntp-server))))
15065 (if (and gnus-nntp-server
15066 (stringp gnus-nntp-server)
15067 (not (string= gnus-nntp-server "")))
15068 (setq gnus-select-method
15069 (cond ((or (string= gnus-nntp-server "")
15070 (string= gnus-nntp-server "::"))
15071 (list 'nnspool (system-name)))
15072 ((string-match "^:" gnus-nntp-server)
15073 (list 'nnmh gnus-nntp-server
15074 (list 'nnmh-directory
15075 (file-name-as-directory
15077 (concat "~/" (substring
15078 gnus-nntp-server 1)))))
15079 (list 'nnmh-get-new-mail nil)))
15081 (list 'nntp gnus-nntp-server)))))
15083 (setq how (car gnus-select-method))
15084 (cond ((eq how 'nnspool)
15086 (gnus-message 5 "Looking up local news spool..."))
15089 (gnus-message 5 "Looking up mh spool..."))
15092 (setq gnus-current-select-method gnus-select-method)
15093 (run-hooks 'gnus-open-server-hook)
15095 ;; gnus-open-server-hook might have opened it
15096 (gnus-server-opened gnus-select-method)
15097 (gnus-open-server gnus-select-method)
15100 "%s (%s) open error: '%s'. Continue? "
15101 (car gnus-select-method) (cadr gnus-select-method)
15102 (gnus-status-message gnus-select-method)))
15103 (gnus-error 1 "Couldn't open server on %s"
15104 (nth 1 gnus-select-method))))))
15106 (defun gnus-check-group (group)
15107 "Try to make sure that the server where GROUP exists is alive."
15108 (let ((method (gnus-find-method-for-group group)))
15109 (or (gnus-server-opened method)
15110 (gnus-open-server method))))
15112 (defun gnus-check-server (&optional method silent)
15113 "Check whether the connection to METHOD is down.
15114 If METHOD is nil, use `gnus-select-method'.
15115 If it is down, start it up (again)."
15116 (let ((method (or method gnus-select-method)))
15117 ;; Transform virtual server names into select methods.
15118 (when (stringp method)
15119 (setq method (gnus-server-to-method method)))
15120 (if (gnus-server-opened method)
15121 ;; The stream is already opened.
15123 ;; Open the server.
15125 (gnus-message 5 "Opening %s server%s..." (car method)
15126 (if (equal (nth 1 method) "") ""
15127 (format " on %s" (nth 1 method)))))
15128 (run-hooks 'gnus-open-server-hook)
15130 (gnus-open-server method)
15134 (defun gnus-get-function (method function &optional noerror)
15135 "Return a function symbol based on METHOD and FUNCTION."
15136 ;; Translate server names into methods.
15138 (error "Attempted use of a nil select method"))
15139 (when (stringp method)
15140 (setq method (gnus-server-to-method method)))
15141 (let ((func (intern (format "%s-%s" (car method) function))))
15142 ;; If the functions isn't bound, we require the backend in
15144 (unless (fboundp func)
15145 (require (car method))
15146 (when (and (not (fboundp func))
15148 ;; This backend doesn't implement this function.
15149 (error "No such function: %s" func)))
15154 ;;; Interface functions to the backends.
15157 (defun gnus-open-server (method)
15158 "Open a connection to METHOD."
15159 (when (stringp method)
15160 (setq method (gnus-server-to-method method)))
15161 (let ((elem (assoc method gnus-opened-servers)))
15162 ;; If this method was previously denied, we just return nil.
15163 (if (eq (nth 1 elem) 'denied)
15165 (gnus-message 1 "Denied server")
15167 ;; Open the server.
15169 (funcall (gnus-get-function method 'open-server)
15170 (nth 1 method) (nthcdr 2 method))))
15171 ;; If this hasn't been opened before, we add it to the list.
15173 (setq elem (list method nil)
15174 gnus-opened-servers (cons elem gnus-opened-servers)))
15175 ;; Set the status of this server.
15176 (setcar (cdr elem) (if result 'ok 'denied))
15177 ;; Return the result from the "open" call.
15180 (defun gnus-close-server (method)
15181 "Close the connection to METHOD."
15182 (when (stringp method)
15183 (setq method (gnus-server-to-method method)))
15184 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15186 (defun gnus-request-list (method)
15187 "Request the active file from METHOD."
15188 (when (stringp method)
15189 (setq method (gnus-server-to-method method)))
15190 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15192 (defun gnus-request-list-newsgroups (method)
15193 "Request the newsgroups file from METHOD."
15194 (when (stringp method)
15195 (setq method (gnus-server-to-method method)))
15196 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15198 (defun gnus-request-newgroups (date method)
15199 "Request all new groups since DATE from METHOD."
15200 (when (stringp method)
15201 (setq method (gnus-server-to-method method)))
15202 (funcall (gnus-get-function method 'request-newgroups)
15203 date (nth 1 method)))
15205 (defun gnus-server-opened (method)
15206 "Check whether a connection to METHOD has been opened."
15207 (when (stringp method)
15208 (setq method (gnus-server-to-method method)))
15209 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15211 (defun gnus-status-message (method)
15212 "Return the status message from METHOD.
15213 If METHOD is a string, it is interpreted as a group name. The method
15214 this group uses will be queried."
15215 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15217 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15219 (defun gnus-request-group (group &optional dont-check method)
15220 "Request GROUP. If DONT-CHECK, no information is required."
15221 (let ((method (or method (gnus-find-method-for-group group))))
15222 (when (stringp method)
15223 (setq method (gnus-server-to-method method)))
15224 (funcall (gnus-get-function method 'request-group)
15225 (gnus-group-real-name group) (nth 1 method) dont-check)))
15227 (defun gnus-request-asynchronous (group &optional articles)
15228 "Request that GROUP behave asynchronously.
15229 ARTICLES is the `data' of the group."
15230 (let ((method (gnus-find-method-for-group group)))
15231 (funcall (gnus-get-function method 'request-asynchronous)
15232 (gnus-group-real-name group) (nth 1 method) articles)))
15234 (defun gnus-list-active-group (group)
15235 "Request active information on GROUP."
15236 (let ((method (gnus-find-method-for-group group))
15237 (func 'list-active-group))
15238 (when (gnus-check-backend-function func group)
15239 (funcall (gnus-get-function method func)
15240 (gnus-group-real-name group) (nth 1 method)))))
15242 (defun gnus-request-group-description (group)
15243 "Request a description of GROUP."
15244 (let ((method (gnus-find-method-for-group group))
15245 (func 'request-group-description))
15246 (when (gnus-check-backend-function func group)
15247 (funcall (gnus-get-function method func)
15248 (gnus-group-real-name group) (nth 1 method)))))
15250 (defun gnus-close-group (group)
15251 "Request the GROUP be closed."
15252 (let ((method (gnus-find-method-for-group group)))
15253 (funcall (gnus-get-function method 'close-group)
15254 (gnus-group-real-name group) (nth 1 method))))
15256 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15257 "Request headers for ARTICLES in GROUP.
15258 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15259 (let ((method (gnus-find-method-for-group group)))
15260 (if (and gnus-use-cache (numberp (car articles)))
15261 (gnus-cache-retrieve-headers articles group fetch-old)
15262 (funcall (gnus-get-function method 'retrieve-headers)
15263 articles (gnus-group-real-name group) (nth 1 method)
15266 (defun gnus-retrieve-groups (groups method)
15267 "Request active information on GROUPS from METHOD."
15268 (when (stringp method)
15269 (setq method (gnus-server-to-method method)))
15270 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15272 (defun gnus-request-type (group &optional article)
15273 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15274 (let ((method (gnus-find-method-for-group group)))
15275 (if (not (gnus-check-backend-function 'request-type (car method)))
15277 (funcall (gnus-get-function method 'request-type)
15278 (gnus-group-real-name group) article))))
15280 (defun gnus-request-update-mark (group article mark)
15281 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15282 (let ((method (gnus-find-method-for-group group)))
15283 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15285 (funcall (gnus-get-function method 'request-update-mark)
15286 (gnus-group-real-name group) article mark))))
15288 (defun gnus-request-article (article group &optional buffer)
15289 "Request the ARTICLE in GROUP.
15290 ARTICLE can either be an article number or an article Message-ID.
15291 If BUFFER, insert the article in that group."
15292 (let ((method (gnus-find-method-for-group group)))
15293 (funcall (gnus-get-function method 'request-article)
15294 article (gnus-group-real-name group) (nth 1 method) buffer)))
15296 (defun gnus-request-head (article group)
15297 "Request the head of ARTICLE in GROUP."
15298 (let* ((method (gnus-find-method-for-group group))
15299 (head (gnus-get-function method 'request-head t)))
15301 (funcall head article (gnus-group-real-name group) (nth 1 method))
15302 (let ((res (gnus-request-article article group)))
15305 (set-buffer nntp-server-buffer)
15306 (goto-char (point-min))
15307 (when (search-forward "\n\n" nil t)
15308 (delete-region (1- (point)) (point-max)))
15309 (nnheader-fold-continuation-lines)))
15312 (defun gnus-request-body (article group)
15313 "Request the body of ARTICLE in GROUP."
15314 (let ((method (gnus-find-method-for-group group)))
15315 (funcall (gnus-get-function method 'request-body)
15316 article (gnus-group-real-name group) (nth 1 method))))
15318 (defun gnus-request-post (method)
15319 "Post the current buffer using METHOD."
15320 (when (stringp method)
15321 (setq method (gnus-server-to-method method)))
15322 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15324 (defun gnus-request-scan (group method)
15325 "Request a SCAN being performed in GROUP from METHOD.
15326 If GROUP is nil, all groups on METHOD are scanned."
15327 (let ((method (if group (gnus-find-method-for-group group) method)))
15328 (funcall (gnus-get-function method 'request-scan)
15329 (and group (gnus-group-real-name group)) (nth 1 method))))
15331 (defsubst gnus-request-update-info (info method)
15332 "Request that METHOD update INFO."
15333 (when (stringp method)
15334 (setq method (gnus-server-to-method method)))
15335 (when (gnus-check-backend-function 'request-update-info (car method))
15336 (funcall (gnus-get-function method 'request-update-info)
15337 (gnus-group-real-name (gnus-info-group info))
15338 info (nth 1 method))))
15340 (defun gnus-request-expire-articles (articles group &optional force)
15341 (let ((method (gnus-find-method-for-group group)))
15342 (funcall (gnus-get-function method 'request-expire-articles)
15343 articles (gnus-group-real-name group) (nth 1 method)
15346 (defun gnus-request-move-article
15347 (article group server accept-function &optional last)
15348 (let ((method (gnus-find-method-for-group group)))
15349 (funcall (gnus-get-function method 'request-move-article)
15350 article (gnus-group-real-name group)
15351 (nth 1 method) accept-function last)))
15353 (defun gnus-request-accept-article (group method &optional last)
15354 ;; Make sure there's a newline at the end of the article.
15355 (when (stringp method)
15356 (setq method (gnus-server-to-method method)))
15357 (when (and (not method)
15359 (setq method (gnus-group-name-to-method group)))
15360 (goto-char (point-max))
15363 (let ((func (car (or method (gnus-find-method-for-group group)))))
15364 (funcall (intern (format "%s-request-accept-article" func))
15365 (if (stringp group) (gnus-group-real-name group) group)
15369 (defun gnus-request-replace-article (article group buffer)
15370 (let ((func (car (gnus-find-method-for-group group))))
15371 (funcall (intern (format "%s-request-replace-article" func))
15372 article (gnus-group-real-name group) buffer)))
15374 (defun gnus-request-associate-buffer (group)
15375 (let ((method (gnus-find-method-for-group group)))
15376 (funcall (gnus-get-function method 'request-associate-buffer)
15377 (gnus-group-real-name group))))
15379 (defun gnus-request-restore-buffer (article group)
15380 "Request a new buffer restored to the state of ARTICLE."
15381 (let ((method (gnus-find-method-for-group group)))
15382 (funcall (gnus-get-function method 'request-restore-buffer)
15383 article (gnus-group-real-name group) (nth 1 method))))
15385 (defun gnus-request-create-group (group &optional method)
15386 (when (stringp method)
15387 (setq method (gnus-server-to-method method)))
15388 (let ((method (or method (gnus-find-method-for-group group))))
15389 (funcall (gnus-get-function method 'request-create-group)
15390 (gnus-group-real-name group) (nth 1 method))))
15392 (defun gnus-request-delete-group (group &optional force)
15393 (let ((method (gnus-find-method-for-group group)))
15394 (funcall (gnus-get-function method 'request-delete-group)
15395 (gnus-group-real-name group) force (nth 1 method))))
15397 (defun gnus-request-rename-group (group new-name)
15398 (let ((method (gnus-find-method-for-group group)))
15399 (funcall (gnus-get-function method 'request-rename-group)
15400 (gnus-group-real-name group)
15401 (gnus-group-real-name new-name) (nth 1 method))))
15403 (defun gnus-member-of-valid (symbol group)
15404 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15405 (memq symbol (assoc
15406 (symbol-name (car (gnus-find-method-for-group group)))
15407 gnus-valid-select-methods)))
15409 (defun gnus-method-option-p (method option)
15410 "Return non-nil if select METHOD has OPTION as a parameter."
15411 (when (stringp method)
15412 (setq method (gnus-server-to-method method)))
15413 (memq option (assoc (format "%s" (car method))
15414 gnus-valid-select-methods)))
15416 (defun gnus-server-extend-method (group method)
15417 ;; This function "extends" a virtual server. If the server is
15418 ;; "hello", and the select method is ("hello" (my-var "something"))
15419 ;; in the group "alt.alt", this will result in a new virtual server
15420 ;; called "hello+alt.alt".
15422 (gnus-copy-sequence
15423 (if (equal (car method) "native") gnus-select-method
15424 (cdr (assoc (car method) gnus-server-alist))))))
15425 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15426 (nconc entry (cdr method))))
15428 (defun gnus-server-status (method)
15429 "Return the status of METHOD."
15430 (nth 1 (assoc method gnus-opened-servers)))
15432 (defun gnus-group-name-to-method (group)
15433 "Return a select method suitable for GROUP."
15434 (if (string-match ":" group)
15435 (let ((server (substring group 0 (match-beginning 0))))
15436 (if (string-match "\\+" server)
15437 (list (intern (substring server 0 (match-beginning 0)))
15438 (substring server (match-end 0)))
15439 (list (intern server) "")))
15440 gnus-select-method))
15442 (defun gnus-find-method-for-group (group &optional info)
15443 "Find the select method that GROUP uses."
15444 (or gnus-override-method
15446 gnus-select-method)
15447 (let ((info (or info (gnus-get-info group)))
15450 (not (setq method (gnus-info-method info)))
15451 (equal method "native"))
15454 (cond ((stringp method)
15455 (gnus-server-to-method method))
15456 ((stringp (car method))
15457 (gnus-server-extend-method group method))
15460 (cond ((equal (cadr method) "")
15462 ((null (cadr method))
15463 (list (car method) ""))
15465 (gnus-server-add-address method)))))))
15467 (defun gnus-check-backend-function (func group)
15468 "Check whether GROUP supports function FUNC."
15469 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15471 (fboundp (intern (format "%s-%s" method func)))))
15473 (defun gnus-methods-using (feature)
15474 "Find all methods that have FEATURE."
15475 (let ((valids gnus-valid-select-methods)
15478 (if (memq feature (car valids))
15479 (setq outs (cons (car valids) outs)))
15480 (setq valids (cdr valids)))
15485 ;;; Active & Newsrc File Handling
15488 (defun gnus-setup-news (&optional rawfile level dont-connect)
15489 "Setup news information.
15490 If RAWFILE is non-nil, the .newsrc file will also be read.
15491 If LEVEL is non-nil, the news will be set up at level LEVEL."
15492 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15495 ;; Clear some variables to re-initialize news information.
15496 (setq gnus-newsrc-alist nil
15497 gnus-active-hashtb nil)
15498 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15499 (gnus-read-newsrc-file rawfile))
15501 (when (and (not (assoc "archive" gnus-server-alist))
15502 (gnus-archive-server-wanted-p))
15503 (push (cons "archive" gnus-message-archive-method)
15504 gnus-server-alist))
15506 ;; If we don't read the complete active file, we fill in the
15508 (if (or (null gnus-read-active-file)
15509 (eq gnus-read-active-file 'some))
15510 (gnus-update-active-hashtb-from-killed))
15512 ;; Read the active file and create `gnus-active-hashtb'.
15513 ;; If `gnus-read-active-file' is nil, then we just create an empty
15514 ;; hash table. The partial filling out of the hash table will be
15515 ;; done in `gnus-get-unread-articles'.
15516 (and gnus-read-active-file
15518 (gnus-read-active-file))
15520 (or gnus-active-hashtb
15521 (setq gnus-active-hashtb (make-vector 4095 0)))
15523 ;; Initialize the cache.
15524 (when gnus-use-cache
15527 ;; Possibly eval the dribble file.
15528 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15530 ;; Slave Gnusii should then clear the dribble buffer.
15531 (when (and init gnus-slave)
15532 (gnus-dribble-clear))
15534 (gnus-update-format-specifications)
15536 ;; See whether we need to read the description file.
15537 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15538 (not gnus-description-hashtb)
15540 gnus-read-active-file)
15541 (gnus-read-all-descriptions-files))
15543 ;; Find new newsgroups and treat them.
15544 (if (and init gnus-check-new-newsgroups (not level)
15545 (gnus-check-server gnus-select-method))
15546 (gnus-find-new-newsgroups))
15548 ;; We might read in new NoCeM messages here.
15549 (when (and gnus-use-nocem
15551 (not dont-connect))
15552 (gnus-nocem-scan-groups))
15554 ;; Find the number of unread articles in each non-dead group.
15555 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15556 (gnus-get-unread-articles level))
15558 (if (and init gnus-check-bogus-newsgroups
15559 gnus-read-active-file (not level)
15560 (gnus-server-opened gnus-select-method))
15561 (gnus-check-bogus-newsgroups))))
15563 (defun gnus-find-new-newsgroups (&optional arg)
15564 "Search for new newsgroups and add them.
15565 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15566 The `-n' option line from .newsrc is respected.
15567 If ARG (the prefix), use the `ask-server' method to query
15568 the server for new groups."
15570 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15571 (null gnus-read-active-file)
15572 (eq gnus-read-active-file 'some))
15573 'ask-server gnus-check-new-newsgroups)))
15574 (unless (gnus-check-first-time-used)
15575 (if (or (consp check)
15576 (eq check 'ask-server))
15577 ;; Ask the server for new groups.
15578 (gnus-ask-server-for-new-groups)
15579 ;; Go through the active hashtb and look for new groups.
15581 group new-newsgroups)
15582 (gnus-message 5 "Looking for new newsgroups...")
15583 (unless gnus-have-read-active-file
15584 (gnus-read-active-file))
15585 (setq gnus-newsrc-last-checked-date (current-time-string))
15586 (unless gnus-killed-hashtb
15587 (gnus-make-hashtable-from-killed))
15588 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15589 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15592 (if (or (null (setq group (symbol-name sym)))
15594 (null (symbol-value sym))
15595 (gnus-gethash group gnus-killed-hashtb)
15596 (gnus-gethash group gnus-newsrc-hashtb))
15598 (let ((do-sub (gnus-matches-options-n group)))
15600 ((eq do-sub 'subscribe)
15601 (setq groups (1+ groups))
15602 (gnus-sethash group group gnus-killed-hashtb)
15603 (funcall gnus-subscribe-options-newsgroup-method group))
15604 ((eq do-sub 'ignore)
15607 (setq groups (1+ groups))
15608 (gnus-sethash group group gnus-killed-hashtb)
15609 (if gnus-subscribe-hierarchical-interactive
15610 (setq new-newsgroups (cons group new-newsgroups))
15611 (funcall gnus-subscribe-newsgroup-method group)))))))
15612 gnus-active-hashtb)
15613 (when new-newsgroups
15614 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15615 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15617 (gnus-message 6 "%d new newsgroup%s arrived."
15618 groups (if (> groups 1) "s have" " has"))
15619 (gnus-message 6 "No new newsgroups.")))))))
15621 (defun gnus-matches-options-n (group)
15622 ;; Returns `subscribe' if the group is to be unconditionally
15623 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15624 ;; no match for the group.
15626 ;; First we check the two user variables.
15628 ((and gnus-options-subscribe
15629 (string-match gnus-options-subscribe group))
15631 ((and gnus-auto-subscribed-groups
15632 (string-match gnus-auto-subscribed-groups group))
15634 ((and gnus-options-not-subscribe
15635 (string-match gnus-options-not-subscribe group))
15637 ;; Then we go through the list that was retrieved from the .newsrc
15638 ;; file. This list has elements on the form
15639 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15640 ;; is in the reverse order of the options line) is returned.
15642 (let ((regs gnus-newsrc-options-n))
15644 (not (string-match (caar regs) group)))
15645 (setq regs (cdr regs)))
15646 (and regs (cdar regs))))))
15648 (defun gnus-ask-server-for-new-groups ()
15649 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15650 (methods (cons gnus-select-method
15652 (when (gnus-archive-server-wanted-p)
15655 (and (consp gnus-check-new-newsgroups)
15656 gnus-check-new-newsgroups)
15657 gnus-secondary-select-methods))))
15659 (new-date (current-time-string))
15660 group new-newsgroups got-new method hashtb
15661 gnus-override-subscribe-method)
15662 ;; Go through both primary and secondary select methods and
15663 ;; request new newsgroups.
15664 (while (setq method (gnus-server-get-method nil (pop methods)))
15665 (setq new-newsgroups nil)
15666 (setq gnus-override-subscribe-method method)
15667 (when (and (gnus-check-server method)
15668 (gnus-request-newgroups date method))
15671 (setq hashtb (gnus-make-hashtable 100))
15672 (set-buffer nntp-server-buffer)
15673 ;; Enter all the new groups into a hashtable.
15674 (gnus-active-to-gnus-format method hashtb 'ignore))
15675 ;; Now all new groups from `method' are in `hashtb'.
15677 (lambda (group-sym)
15678 (if (or (null (setq group (symbol-name group-sym)))
15679 (not (boundp group-sym))
15680 (null (symbol-value group-sym))
15681 (gnus-gethash group gnus-newsrc-hashtb)
15682 (member group gnus-zombie-list)
15683 (member group gnus-killed-list))
15684 ;; The group is already known.
15686 ;; Make this group active.
15687 (when (symbol-value group-sym)
15688 (gnus-set-active group (symbol-value group-sym)))
15689 ;; Check whether we want it or not.
15690 (let ((do-sub (gnus-matches-options-n group)))
15692 ((eq do-sub 'subscribe)
15694 (gnus-sethash group group gnus-killed-hashtb)
15695 (funcall gnus-subscribe-options-newsgroup-method group))
15696 ((eq do-sub 'ignore)
15700 (gnus-sethash group group gnus-killed-hashtb)
15701 (if gnus-subscribe-hierarchical-interactive
15702 (push group new-newsgroups)
15703 (funcall gnus-subscribe-newsgroup-method group)))))))
15705 (when new-newsgroups
15706 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15707 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15709 (gnus-message 6 "%d new newsgroup%s arrived."
15710 groups (if (> groups 1) "s have" " has")))
15711 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15714 (defun gnus-check-first-time-used ()
15715 (if (or (> (length gnus-newsrc-alist) 1)
15716 (file-exists-p gnus-startup-file)
15717 (file-exists-p (concat gnus-startup-file ".el"))
15718 (file-exists-p (concat gnus-startup-file ".eld")))
15720 (gnus-message 6 "First time user; subscribing you to default groups")
15721 (unless (gnus-read-active-file-p)
15722 (gnus-read-active-file))
15723 (setq gnus-newsrc-last-checked-date (current-time-string))
15724 (let ((groups gnus-default-subscribed-newsgroups)
15728 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15731 (if (null (setq group (symbol-name sym)))
15733 (let ((do-sub (gnus-matches-options-n group)))
15735 ((eq do-sub 'subscribe)
15736 (gnus-sethash group group gnus-killed-hashtb)
15737 (funcall gnus-subscribe-options-newsgroup-method group))
15738 ((eq do-sub 'ignore)
15741 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15742 gnus-active-hashtb)
15744 (if (gnus-active (car groups))
15745 (gnus-group-change-level
15746 (car groups) gnus-level-default-subscribed gnus-level-killed))
15747 (setq groups (cdr groups)))
15748 (gnus-group-make-help-group)
15749 (and gnus-novice-user
15750 (gnus-message 7 "`A k' to list killed groups"))))))
15752 (defun gnus-subscribe-group (group previous &optional method)
15753 (gnus-group-change-level
15755 (list t group gnus-level-default-subscribed nil nil method)
15757 gnus-level-default-subscribed gnus-level-killed previous t))
15759 ;; `gnus-group-change-level' is the fundamental function for changing
15760 ;; subscription levels of newsgroups. This might mean just changing
15761 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15762 ;; again, which subscribes/unsubscribes a group, which is equally
15763 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15764 ;; from 8-9 to 1-7 means that you remove the group from the list of
15765 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15766 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15767 ;; which is trivial.
15768 ;; ENTRY can either be a string (newsgroup name) or a list (if
15769 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15770 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15772 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15773 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15775 (defun gnus-group-change-level (entry level &optional oldlevel
15776 previous fromkilled)
15777 (let (group info active num)
15778 ;; Glean what info we can from the arguments
15780 (if fromkilled (setq group (nth 1 entry))
15781 (setq group (car (nth 2 entry))))
15782 (setq group entry))
15783 (if (and (stringp entry)
15785 (< oldlevel gnus-level-zombie))
15786 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15787 (if (and (not oldlevel)
15789 (setq oldlevel (gnus-info-level (nth 2 entry)))
15790 (setq oldlevel (or oldlevel 9)))
15791 (if (stringp previous)
15792 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15794 (if (and (>= oldlevel gnus-level-zombie)
15795 (gnus-gethash group gnus-newsrc-hashtb))
15796 ;; We are trying to subscribe a group that is already
15800 (or (gnus-ephemeral-group-p group)
15801 (gnus-dribble-enter
15802 (format "(gnus-group-change-level %S %S %S %S %S)"
15803 group level oldlevel (car (nth 2 previous)) fromkilled)))
15805 ;; Then we remove the newgroup from any old structures, if needed.
15806 ;; If the group was killed, we remove it from the killed or zombie
15807 ;; list. If not, and it is in fact going to be killed, we remove
15808 ;; it from the newsrc hash table and assoc.
15810 ((>= oldlevel gnus-level-zombie)
15811 (if (= oldlevel gnus-level-zombie)
15812 (setq gnus-zombie-list (delete group gnus-zombie-list))
15813 (setq gnus-killed-list (delete group gnus-killed-list))))
15815 (if (and (>= level gnus-level-zombie)
15818 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15820 (setcdr (gnus-gethash (car (nth 3 entry))
15821 gnus-newsrc-hashtb)
15823 (setcdr (cdr entry) (cdddr entry))))))
15825 ;; Finally we enter (if needed) the list where it is supposed to
15826 ;; go, and change the subscription level. If it is to be killed,
15827 ;; we enter it into the killed or zombie list.
15829 ((>= level gnus-level-zombie)
15830 ;; Remove from the hash table.
15831 (gnus-sethash group nil gnus-newsrc-hashtb)
15832 ;; We do not enter foreign groups into the list of dead
15834 (unless (gnus-group-foreign-p group)
15835 (if (= level gnus-level-zombie)
15836 (setq gnus-zombie-list (cons group gnus-zombie-list))
15837 (setq gnus-killed-list (cons group gnus-killed-list)))))
15839 ;; If the list is to be entered into the newsrc assoc, and
15840 ;; it was killed, we have to create an entry in the newsrc
15841 ;; hashtb format and fix the pointers in the newsrc assoc.
15842 (if (< oldlevel gnus-level-zombie)
15843 ;; It was alive, and it is going to stay alive, so we
15844 ;; just change the level and don't change any pointers or
15845 ;; hash table entries.
15846 (setcar (cdaddr entry) level)
15848 (setq info (cdr entry)
15850 (setq active (gnus-active group))
15852 (if active (- (1+ (cdr active)) (car active)) t))
15853 ;; Check whether the group is foreign. If so, the
15854 ;; foreign select method has to be entered into the
15856 (let ((method (or gnus-override-subscribe-method
15857 (gnus-group-method group))))
15858 (if (eq method gnus-select-method)
15859 (setq info (list group level nil))
15860 (setq info (list group level nil nil method)))))
15863 (let ((p gnus-newsrc-alist))
15867 (setq entry (cons info (cddr previous)))
15870 (setcdr (cdr previous) entry)
15871 (gnus-sethash group (cons num (cdr previous))
15872 gnus-newsrc-hashtb))
15873 (setcdr previous entry)
15874 (gnus-sethash group (cons num previous)
15875 gnus-newsrc-hashtb))
15877 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15878 (when gnus-group-change-level-function
15879 (funcall gnus-group-change-level-function group level oldlevel)))))
15881 (defun gnus-kill-newsgroup (newsgroup)
15882 "Obsolete function. Kills a newsgroup."
15883 (gnus-group-change-level
15884 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15886 (defun gnus-check-bogus-newsgroups (&optional confirm)
15887 "Remove bogus newsgroups.
15888 If CONFIRM is non-nil, the user has to confirm the deletion of every
15890 (let ((newsrc (cdr gnus-newsrc-alist))
15891 bogus group entry info)
15892 (gnus-message 5 "Checking bogus newsgroups...")
15893 (unless (gnus-read-active-file-p)
15894 (gnus-read-active-file))
15895 (when (gnus-read-active-file-p)
15896 ;; Find all bogus newsgroup that are subscribed.
15898 (setq info (pop newsrc)
15899 group (gnus-info-group info))
15900 (unless (or (gnus-active group) ; Active
15901 (gnus-info-method info) ; Foreign
15903 (not (gnus-y-or-n-p
15904 (format "Remove bogus newsgroup: %s " group)))))
15905 ;; Found a bogus newsgroup.
15906 (push group bogus)))
15907 ;; Remove all bogus subscribed groups by first killing them, and
15908 ;; then removing them from the list of killed groups.
15910 (when (setq entry (gnus-gethash (setq group (pop bogus))
15911 gnus-newsrc-hashtb))
15912 (gnus-group-change-level entry gnus-level-killed)
15913 (setq gnus-killed-list (delete group gnus-killed-list))))
15914 ;; Then we remove all bogus groups from the list of killed and
15915 ;; zombie groups. They are are removed without confirmation.
15916 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15919 (setq killed (symbol-value (car dead-lists)))
15921 (unless (gnus-active (setq group (pop killed)))
15922 ;; The group is bogus.
15923 ;; !!!Slow as hell.
15924 (set (car dead-lists)
15925 (delete group (symbol-value (car dead-lists))))))
15926 (setq dead-lists (cdr dead-lists))))
15927 (gnus-message 5 "Checking bogus newsgroups...done"))))
15929 (defun gnus-check-duplicate-killed-groups ()
15930 "Remove duplicates from the list of killed groups."
15932 (let ((killed gnus-killed-list))
15934 (gnus-message 9 "%d" (length killed))
15935 (setcdr killed (delete (car killed) (cdr killed)))
15936 (setq killed (cdr killed)))))
15938 ;; We want to inline a function from gnus-cache, so we cheat here:
15941 (setq gnus-directory (or (getenv "SAVEDIR") "~/News/"))
15942 (require 'gnus-cache))
15944 (defun gnus-get-unread-articles-in-group (info active &optional update)
15946 ;; Allow the backend to update the info in the group.
15948 (gnus-request-update-info
15949 info (gnus-find-method-for-group (gnus-info-group info))))
15950 (gnus-activate-group (gnus-info-group info) nil t))
15951 (let* ((range (gnus-info-read info))
15953 ;; If a cache is present, we may have to alter the active info.
15954 (when (and gnus-use-cache info)
15955 (inline (gnus-cache-possibly-alter-active
15956 (gnus-info-group info) active)))
15957 ;; Modify the list of read articles according to what articles
15958 ;; are available; then tally the unread articles and add the
15959 ;; number to the group hash table entry.
15961 ((zerop (cdr active))
15964 (setq num (- (1+ (cdr active)) (car active))))
15965 ((not (listp (cdr range)))
15966 ;; Fix a single (num . num) range according to the
15967 ;; active hash table.
15968 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15969 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15970 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15971 ;; Compute number of unread articles.
15972 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15974 ;; The read list is a list of ranges. Fix them according to
15975 ;; the active hash table.
15976 ;; First peel off any elements that are below the lower
15978 (while (and (cdr range)
15980 (or (and (atom (cadr range)) (cadr range))
15982 (if (numberp (car range))
15985 (or (and (numberp (cadr range))
15988 (setcdr (car range)
15989 (or (and (numberp (nth 1 range)) (nth 1 range))
15991 (setcdr range (cddr range)))
15992 ;; Adjust the first element to be the same as the lower limit.
15993 (if (and (not (atom (car range)))
15994 (< (cdar range) (car active)))
15995 (setcdr (car range) (1- (car active))))
15996 ;; Then we want to peel off any elements that are higher
15997 ;; than the upper active limit.
15998 (let ((srange range))
15999 ;; Go past all legal elements.
16000 (while (and (cdr srange)
16001 (<= (or (and (atom (cadr srange))
16003 (caadr srange)) (cdr active)))
16004 (setq srange (cdr srange)))
16006 ;; Nuke all remaining illegal elements.
16007 (setcdr srange nil))
16009 ;; Adjust the final element.
16010 (if (and (not (atom (car srange)))
16011 (> (cdar srange) (cdr active)))
16012 (setcdr (car srange) (cdr active))))
16013 ;; Compute the number of unread articles.
16015 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
16017 (or (and (atom (car range)) (car range))
16019 (setq range (cdr range)))
16020 (setq num (max 0 (- (cdr active) num)))))
16021 ;; Set the number of unread articles.
16023 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
16026 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
16027 ;; and compute how many unread articles there are in each group.
16028 (defun gnus-get-unread-articles (&optional level)
16029 (let* ((newsrc (cdr gnus-newsrc-alist))
16030 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
16033 (cond ((and gnus-activate-foreign-newsgroups
16034 (not (numberp gnus-activate-foreign-newsgroups)))
16035 (1+ gnus-level-subscribed))
16036 ((numberp gnus-activate-foreign-newsgroups)
16037 gnus-activate-foreign-newsgroups)
16040 info group active method)
16041 (gnus-message 5 "Checking new news...")
16044 (setq active (gnus-active (setq group (gnus-info-group
16045 (setq info (pop newsrc))))))
16047 ;; Check newsgroups. If the user doesn't want to check them, or
16048 ;; they can't be checked (for instance, if the news server can't
16049 ;; be reached) we just set the number of unread articles in this
16050 ;; newsgroup to t. This means that Gnus thinks that there are
16051 ;; unread articles, but it has no idea how many.
16052 (if (and (setq method (gnus-info-method info))
16053 (not (gnus-server-equal
16055 (setq method (gnus-server-get-method nil method))))
16056 (not (gnus-secondary-method-p method)))
16057 ;; These groups are foreign. Check the level.
16058 (when (<= (gnus-info-level info) foreign-level)
16059 (setq active (gnus-activate-group group 'scan))
16060 (unless (inline (gnus-virtual-group-p group))
16061 (inline (gnus-close-group group)))
16062 (when (fboundp (intern (concat (symbol-name (car method))
16063 "-request-update-info")))
16064 (inline (gnus-request-update-info info method))))
16065 ;; These groups are native or secondary.
16066 (when (and (<= (gnus-info-level info) level)
16067 (not gnus-read-active-file))
16068 (setq active (gnus-activate-group group 'scan))
16069 (inline (gnus-close-group group))))
16071 ;; Get the number of unread articles in the group.
16073 (inline (gnus-get-unread-articles-in-group info active))
16074 ;; The group couldn't be reached, so we nix out the number of
16075 ;; unread articles and stuff.
16076 (gnus-set-active group nil)
16077 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
16079 (gnus-message 5 "Checking new news...done")))
16081 ;; Create a hash table out of the newsrc alist. The `car's of the
16082 ;; alist elements are used as keys.
16083 (defun gnus-make-hashtable-from-newsrc-alist ()
16084 (let ((alist gnus-newsrc-alist)
16085 (ohashtb gnus-newsrc-hashtb)
16087 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
16089 (setq prev (setq gnus-newsrc-alist
16090 (if (equal (caar gnus-newsrc-alist)
16093 (cons (list "dummy.group" 0 nil) alist)))))
16097 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
16099 gnus-newsrc-hashtb)
16101 alist (cdr alist)))))
16103 (defun gnus-make-hashtable-from-killed ()
16104 "Create a hash table from the killed and zombie lists."
16105 (let ((lists '(gnus-killed-list gnus-zombie-list))
16107 (setq gnus-killed-hashtb
16108 (gnus-make-hashtable
16109 (+ (length gnus-killed-list) (length gnus-zombie-list))))
16110 (while (setq list (pop lists))
16111 (setq list (symbol-value list))
16113 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16115 (defun gnus-activate-group (group &optional scan dont-check method)
16116 ;; Check whether a group has been activated or not.
16117 ;; If SCAN, request a scan of that group as well.
16118 (let ((method (or method (gnus-find-method-for-group group)))
16120 (and (gnus-check-server method)
16121 ;; We escape all bugs and quit here to make it possible to
16122 ;; continue if a group is so out-there that it reports bugs
16126 (gnus-check-backend-function 'request-scan (car method))
16127 (gnus-request-scan group method))
16130 (gnus-request-group group dont-check method)
16134 (set-buffer nntp-server-buffer)
16135 (goto-char (point-min))
16136 ;; Parse the result we got from `gnus-request-group'.
16137 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16139 (goto-char (match-beginning 1))
16141 group (setq active (cons (read (current-buffer))
16142 (read (current-buffer)))))
16143 ;; Return the new active info.
16146 (defun gnus-update-read-articles (group unread)
16147 "Update the list of read and ticked articles in GROUP using the
16148 UNREAD and TICKED lists.
16149 Note: UNSELECTED has to be sorted over `<'.
16150 Returns whether the updating was successful."
16151 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16152 (entry (gnus-gethash group gnus-newsrc-hashtb))
16153 (info (nth 2 entry))
16155 (unread (sort (copy-sequence unread) '<))
16157 (if (or (not info) (not active))
16158 ;; There is no info on this group if it was, in fact,
16159 ;; killed. Gnus stores no information on killed groups, so
16160 ;; there's nothing to be done.
16161 ;; One could store the information somewhere temporarily,
16162 ;; perhaps... Hmmm...
16164 ;; Remove any negative articles numbers.
16165 (while (and unread (< (car unread) 0))
16166 (setq unread (cdr unread)))
16167 ;; Remove any expired article numbers
16168 (while (and unread (< (car unread) (car active)))
16169 (setq unread (cdr unread)))
16170 ;; Compute the ranges of read articles by looking at the list of
16171 ;; unread articles.
16173 (if (/= (car unread) prev)
16174 (setq read (cons (if (= prev (1- (car unread))) prev
16175 (cons prev (1- (car unread)))) read)))
16176 (setq prev (1+ (car unread)))
16177 (setq unread (cdr unread)))
16178 (when (<= prev (cdr active))
16179 (setq read (cons (cons prev (cdr active)) read)))
16180 ;; Enter this list into the group info.
16181 (gnus-info-set-read
16182 info (if (> (length read) 1) (nreverse read) read))
16183 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16184 (gnus-get-unread-articles-in-group info (gnus-active group))
16187 (defun gnus-make-articles-unread (group articles)
16188 "Mark ARTICLES in GROUP as unread."
16189 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16190 (gnus-gethash (gnus-group-real-name group)
16191 gnus-newsrc-hashtb))))
16192 (ranges (gnus-info-read info))
16195 (when (gnus-member-of-range
16196 (setq article (pop articles)) ranges)
16197 (setq news (cons article news))))
16199 (gnus-info-set-read
16200 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16201 (gnus-group-update-group group t))))
16203 ;; Enter all dead groups into the hashtb.
16204 (defun gnus-update-active-hashtb-from-killed ()
16205 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16206 (lists (list gnus-killed-list gnus-zombie-list))
16209 (setq killed (car lists))
16211 (gnus-sethash (car killed) nil hashtb)
16212 (setq killed (cdr killed)))
16213 (setq lists (cdr lists)))))
16215 (defun gnus-get-killed-groups ()
16216 "Go through the active hashtb and all all unknown groups as killed."
16217 ;; First make sure active file has been read.
16218 (unless (gnus-read-active-file-p)
16219 (let ((gnus-read-active-file t))
16220 (gnus-read-active-file)))
16221 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16222 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16226 (group (symbol-name sym)))
16227 (if (or (null group)
16228 (gnus-gethash group gnus-killed-hashtb)
16229 (gnus-gethash group gnus-newsrc-hashtb))
16231 (let ((do-sub (gnus-matches-options-n group)))
16232 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16234 (setq groups (1+ groups))
16235 (setq gnus-killed-list
16236 (cons group gnus-killed-list))
16237 (gnus-sethash group group gnus-killed-hashtb))))))
16238 gnus-active-hashtb))
16240 ;; Get the active file(s) from the backend(s).
16241 (defun gnus-read-active-file ()
16242 (gnus-group-set-mode-line)
16245 (if (gnus-check-server gnus-select-method)
16246 ;; The native server is available.
16247 (cons gnus-select-method gnus-secondary-select-methods)
16248 ;; The native server is down, so we just do the
16250 gnus-secondary-select-methods)
16251 ;; Also read from the archive server.
16252 (when (gnus-archive-server-wanted-p)
16253 (list "archive"))))
16255 (setq gnus-have-read-active-file nil)
16257 (set-buffer nntp-server-buffer)
16259 (let* ((method (if (stringp (car methods))
16260 (gnus-server-get-method nil (car methods))
16262 (where (nth 1 method))
16263 (mesg (format "Reading active file%s via %s..."
16264 (if (and where (not (zerop (length where))))
16265 (concat " from " where) "")
16267 (gnus-message 5 mesg)
16268 (when (gnus-check-server method)
16269 ;; Request that the backend scan its incoming messages.
16270 (and (gnus-check-backend-function 'request-scan (car method))
16271 (gnus-request-scan nil method))
16273 ((and (eq gnus-read-active-file 'some)
16274 (gnus-check-backend-function 'retrieve-groups (car method)))
16275 (let ((newsrc (cdr gnus-newsrc-alist))
16276 (gmethod (gnus-server-get-method nil method))
16278 (while (setq info (pop newsrc))
16279 (when (gnus-server-equal
16280 (gnus-find-method-for-group
16281 (gnus-info-group info) info)
16283 (push (gnus-group-real-name (gnus-info-group info))
16286 (gnus-check-server method)
16287 (setq list-type (gnus-retrieve-groups groups method))
16291 1.2 "Cannot read partial active file from %s server."
16293 ((eq list-type 'active)
16294 (gnus-active-to-gnus-format method gnus-active-hashtb))
16296 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16298 (if (not (gnus-request-list method))
16299 (unless (equal method gnus-message-archive-method)
16300 (gnus-error 1 "Cannot read active file from %s server."
16302 (gnus-message 5 mesg)
16303 (gnus-active-to-gnus-format method gnus-active-hashtb)
16304 ;; We mark this active file as read.
16305 (push method gnus-have-read-active-file)
16306 (gnus-message 5 "%sdone" mesg))))))
16307 (setq methods (cdr methods))))))
16309 ;; Read an active file and place the results in `gnus-active-hashtb'.
16310 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16312 (setq method gnus-select-method))
16313 (let ((cur (current-buffer))
16315 (if (and gnus-active-hashtb
16316 (not (equal method gnus-select-method)))
16318 (setq gnus-active-hashtb
16319 (if (equal method gnus-select-method)
16320 (gnus-make-hashtable
16321 (count-lines (point-min) (point-max)))
16322 (gnus-make-hashtable 4096)))))))
16323 ;; Delete unnecessary lines.
16324 (goto-char (point-min))
16325 (while (search-forward "\nto." nil t)
16326 (delete-region (1+ (match-beginning 0))
16327 (progn (forward-line 1) (point))))
16328 (or (string= gnus-ignored-newsgroups "")
16330 (goto-char (point-min))
16331 (delete-matching-lines gnus-ignored-newsgroups)))
16332 ;; Make the group names readable as a lisp expression even if they
16333 ;; contain special characters.
16334 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16335 (goto-char (point-max))
16336 (while (re-search-backward "[][';?()#]" nil t)
16338 ;; If these are groups from a foreign select method, we insert the
16339 ;; group prefix in front of the group names.
16340 (and method (not (gnus-server-equal
16341 (gnus-server-get-method nil method)
16342 (gnus-server-get-method nil gnus-select-method)))
16343 (let ((prefix (gnus-group-prefixed-name "" method)))
16344 (goto-char (point-min))
16345 (while (and (not (eobp))
16346 (progn (insert prefix)
16347 (zerop (forward-line 1)))))))
16348 ;; Store the active file in a hash table.
16349 (goto-char (point-min))
16350 (if (string-match "%[oO]" gnus-group-line-format)
16351 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16352 ;; If we want information on moderated groups, we use this
16354 (let* ((mod-hashtb (make-vector 7 0))
16355 (m (intern "m" mod-hashtb))
16357 (while (not (eobp))
16358 (condition-case nil
16360 (narrow-to-region (point) (gnus-point-at-eol))
16361 (setq group (let ((obarray hashtb)) (read cur)))
16362 (if (and (numberp (setq max (read cur)))
16363 (numberp (setq min (read cur)))
16365 (skip-chars-forward " \t")
16367 (or (= (following-char) ?=)
16368 (= (following-char) ?x)
16369 (= (following-char) ?j)))))
16370 (set group (cons min max))
16372 ;; Enter moderated groups into a list.
16373 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16374 (setq gnus-moderated-list
16375 (cons (symbol-name group) gnus-moderated-list))))
16382 ;; And if we do not care about moderation, we use this loop,
16383 ;; which is faster.
16384 (let (group max min)
16385 (while (not (eobp))
16388 (narrow-to-region (point) (gnus-point-at-eol))
16389 ;; group gets set to a symbol interned in the hash table
16390 ;; (what a hack!!) - jwz
16391 (setq group (let ((obarray hashtb)) (read cur)))
16392 (if (and (numberp (setq max (read cur)))
16393 (numberp (setq min (read cur)))
16395 (skip-chars-forward " \t")
16397 (or (= (following-char) ?=)
16398 (= (following-char) ?x)
16399 (= (following-char) ?j)))))
16400 (set group (cons min max))
16408 (gnus-message 3 "Warning - illegal active: %s"
16410 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16412 (forward-line 1))))))
16414 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16415 ;; Parse a "groups" active file.
16416 (let ((cur (current-buffer))
16418 (if (and method gnus-active-hashtb)
16420 (setq gnus-active-hashtb
16421 (gnus-make-hashtable
16422 (count-lines (point-min) (point-max)))))))
16423 (prefix (and method
16424 (not (gnus-server-equal
16425 (gnus-server-get-method nil method)
16426 (gnus-server-get-method nil gnus-select-method)))
16427 (gnus-group-prefixed-name "" method))))
16429 (goto-char (point-min))
16430 ;; We split this into to separate loops, one with the prefix
16431 ;; and one without to speed the reading up somewhat.
16433 (let (min max opoint group)
16434 (while (not (eobp))
16437 (read cur) (read cur)
16438 (setq min (read cur)
16441 (skip-chars-forward " \t")
16444 (set (let ((obarray hashtb)) (read cur))
16446 (error (and group (symbolp group) (set group nil))))
16448 (let (min max group)
16449 (while (not (eobp))
16451 (if (= (following-char) ?2)
16453 (read cur) (read cur)
16454 (setq min (read cur)
16456 (set (setq group (let ((obarray hashtb)) (read cur)))
16458 (error (and group (symbolp group) (set group nil))))
16459 (forward-line 1))))))
16461 (defun gnus-read-newsrc-file (&optional force)
16462 "Read startup file.
16463 If FORCE is non-nil, the .newsrc file is read."
16464 ;; Reset variables that might be defined in the .newsrc.eld file.
16465 (let ((variables gnus-variable-list))
16467 (set (car variables) nil)
16468 (setq variables (cdr variables))))
16469 (let* ((newsrc-file gnus-current-startup-file)
16470 (quick-file (concat newsrc-file ".el")))
16472 ;; We always load the .newsrc.eld file. If always contains
16473 ;; much information that can not be gotten from the .newsrc
16474 ;; file (ticked articles, killed groups, foreign methods, etc.)
16475 (gnus-read-newsrc-el-file quick-file)
16477 (if (and (file-exists-p gnus-current-startup-file)
16479 (and (file-newer-than-file-p newsrc-file quick-file)
16480 (file-newer-than-file-p newsrc-file
16481 (concat quick-file "d")))
16482 (not gnus-newsrc-alist)))
16483 ;; We read the .newsrc file. Note that if there if a
16484 ;; .newsrc.eld file exists, it has already been read, and
16485 ;; the `gnus-newsrc-hashtb' has been created. While reading
16486 ;; the .newsrc file, Gnus will only use the information it
16487 ;; can find there for changing the data already read -
16488 ;; ie. reading the .newsrc file will not trash the data
16489 ;; already read (except for read articles).
16491 (gnus-message 5 "Reading %s..." newsrc-file)
16492 (set-buffer (find-file-noselect newsrc-file))
16493 (buffer-disable-undo (current-buffer))
16494 (gnus-newsrc-to-gnus-format)
16495 (kill-buffer (current-buffer))
16496 (gnus-message 5 "Reading %s...done" newsrc-file)))
16498 ;; Read any slave files.
16500 (gnus-master-read-slave-newsrc))
16502 ;; Convert old to new.
16503 (gnus-convert-old-newsrc))))
16505 (defun gnus-continuum-version (version)
16506 "Return VERSION as a floating point number."
16507 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16508 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16509 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16510 (number (match-string 2 version))
16512 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16513 (setq major (string-to-number (match-string 1 number)))
16514 (setq minor (string-to-number (match-string 2 number)))
16515 (setq least (if (match-beginning 3)
16516 (string-to-number (match-string 3 number))
16520 (format "%s00%02d%02d"
16522 ((member alpha '("(ding)" "d")) "4.99")
16523 ((member alpha '("September" "s")) "5.01")
16524 ((member alpha '("Red" "r")) "5.03"))
16526 (format "%d.%02d%02d" major minor least))))))
16528 (defun gnus-convert-old-newsrc ()
16529 "Convert old newsrc into the new format, if needed."
16530 (let ((fcv (and gnus-newsrc-file-version
16531 (gnus-continuum-version gnus-newsrc-file-version))))
16533 ;; No .newsrc.eld file was loaded.
16535 ;; Gnus 5 .newsrc.eld was loaded.
16536 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16537 (gnus-convert-old-ticks)))))
16539 (defun gnus-convert-old-ticks ()
16540 (let ((newsrc (cdr gnus-newsrc-alist))
16541 marks info dormant ticked)
16542 (while (setq info (pop newsrc))
16543 (when (setq marks (gnus-info-marks info))
16544 (setq dormant (cdr (assq 'dormant marks))
16545 ticked (cdr (assq 'tick marks)))
16546 (when (or dormant ticked)
16547 (gnus-info-set-read
16550 (gnus-info-read info)
16551 (nconc (gnus-uncompress-range dormant)
16552 (gnus-uncompress-range ticked)))))))))
16554 (defun gnus-read-newsrc-el-file (file)
16555 (let ((ding-file (concat file "d")))
16556 ;; We always, always read the .eld file.
16557 (gnus-message 5 "Reading %s..." ding-file)
16558 (let (gnus-newsrc-assoc)
16559 (condition-case nil
16560 (load ding-file t t t)
16562 (gnus-error 1 "Error in %s" ding-file)))
16563 (when gnus-newsrc-assoc
16564 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16565 (gnus-make-hashtable-from-newsrc-alist)
16566 (when (file-newer-than-file-p file ding-file)
16567 ;; Old format quick file
16568 (gnus-message 5 "Reading %s..." file)
16569 ;; The .el file is newer than the .eld file, so we read that one
16571 (gnus-read-old-newsrc-el-file file))))
16573 ;; Parse the old-style quick startup file
16574 (defun gnus-read-old-newsrc-el-file (file)
16575 (let (newsrc killed marked group m info)
16577 (let ((gnus-killed-assoc nil)
16578 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16580 (condition-case nil
16583 (setq newsrc gnus-newsrc-assoc
16584 killed gnus-killed-assoc
16585 marked gnus-marked-assoc)))
16586 (setq gnus-newsrc-alist nil)
16587 (while (setq group (pop newsrc))
16588 (if (setq info (gnus-get-info (car group)))
16590 (gnus-info-set-read info (cddr group))
16591 (gnus-info-set-level
16592 info (if (nth 1 group) gnus-level-default-subscribed
16593 gnus-level-default-unsubscribed))
16594 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16597 (if (nth 1 group) gnus-level-default-subscribed
16598 gnus-level-default-unsubscribed)
16600 gnus-newsrc-alist))
16601 ;; Copy marks into info.
16602 (when (setq m (assoc (car group) marked))
16603 (unless (nthcdr 3 info)
16604 (nconc info (list nil)))
16605 (gnus-info-set-marks
16606 info (list (cons 'tick (gnus-compress-sequence
16607 (sort (cdr m) '<) t))))))
16608 (setq newsrc killed)
16610 (setcar newsrc (caar newsrc))
16611 (setq newsrc (cdr newsrc)))
16612 (setq gnus-killed-list killed))
16613 ;; The .el file version of this variable does not begin with
16614 ;; "options", while the .eld version does, so we just add it if it
16617 gnus-newsrc-options
16619 (and (not (string-match "^ *options" gnus-newsrc-options))
16620 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16621 (and (not (string-match "\n$" gnus-newsrc-options))
16622 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16623 ;; Finally, if we read some options lines, we parse them.
16624 (or (string= gnus-newsrc-options "")
16625 (gnus-newsrc-parse-options gnus-newsrc-options))))
16627 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16628 (gnus-make-hashtable-from-newsrc-alist)))
16630 (defun gnus-make-newsrc-file (file)
16631 "Make server dependent file name by catenating FILE and server host name."
16632 (let* ((file (expand-file-name file nil))
16633 (real-file (concat file "-" (nth 1 gnus-select-method))))
16634 (if (or (file-exists-p real-file)
16635 (file-exists-p (concat real-file ".el"))
16636 (file-exists-p (concat real-file ".eld")))
16639 (defun gnus-newsrc-to-gnus-format ()
16640 (setq gnus-newsrc-options "")
16641 (setq gnus-newsrc-options-n nil)
16643 (or gnus-active-hashtb
16644 (setq gnus-active-hashtb (make-vector 4095 0)))
16645 (let ((buf (current-buffer))
16646 (already-read (> (length gnus-newsrc-alist) 1))
16647 group subscribed options-symbol newsrc Options-symbol
16649 (goto-char (point-min))
16650 ;; We intern the symbol `options' in the active hashtb so that we
16651 ;; can `eq' against it later.
16652 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16653 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16655 (while (not (eobp))
16656 ;; We first read the first word on the line by narrowing and
16657 ;; then reading into `gnus-active-hashtb'. Most groups will
16658 ;; already exist in that hashtb, so this will save some string
16662 (progn (skip-chars-forward "^ \t!:\n") (point)))
16663 (goto-char (point-min))
16665 (and (/= (point-min) (point-max))
16666 (let ((obarray gnus-active-hashtb)) (read buf))))
16668 ;; Now, the symbol we have read is either `options' or a group
16669 ;; name. If it is an options line, we just add it to a string.
16671 ((or (eq symbol options-symbol)
16672 (eq symbol Options-symbol))
16673 (setq gnus-newsrc-options
16674 ;; This concating is quite inefficient, but since our
16675 ;; thorough studies show that approx 99.37% of all
16676 ;; .newsrc files only contain a single options line, we
16677 ;; don't give a damn, frankly, my dear.
16678 (concat gnus-newsrc-options
16680 (gnus-point-at-bol)
16681 ;; Options may continue on the next line.
16682 (or (and (re-search-forward "^[^ \t]" nil 'move)
16683 (progn (beginning-of-line) (point)))
16687 ;; Group names can be just numbers.
16688 (when (numberp symbol)
16689 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16690 (or (boundp symbol) (set symbol nil))
16691 ;; It was a group name.
16692 (setq subscribed (= (following-char) ?:)
16693 group (symbol-name symbol)
16696 ;; If the line ends here, this is clearly a buggy line, so
16697 ;; we put point a the beginning of line and let the cond
16698 ;; below do the error handling.
16699 (beginning-of-line)
16700 ;; We skip to the beginning of the ranges.
16701 (skip-chars-forward "!: \t"))
16702 ;; We are now at the beginning of the list of read articles.
16703 ;; We read them range by range.
16706 ((looking-at "[0-9]+")
16707 ;; We narrow and read a number instead of buffer-substring/
16708 ;; string-to-int because it's faster. narrow/widen is
16709 ;; faster than save-restriction/narrow, and save-restriction
16710 ;; produces a garbage object.
16712 (narrow-to-region (match-beginning 0) (match-end 0))
16715 ;; If the next character is a dash, then this is a range.
16716 (if (= (following-char) ?-)
16718 ;; We read the upper bound of the range.
16720 (if (not (looking-at "[0-9]+"))
16721 ;; This is a buggy line, by we pretend that
16722 ;; it's kinda OK. Perhaps the user should be
16724 (setq reads (cons num1 reads))
16729 (narrow-to-region (match-beginning 0)
16734 ;; It was just a simple number, so we add it to the
16736 (setq reads (cons num1 reads)))
16737 ;; If the next char in ?\n, then we have reached the end
16738 ;; of the line and return nil.
16739 (/= (following-char) ?\n))
16740 ((= (following-char) ?\n)
16741 ;; End of line, so we end.
16744 ;; Not numbers and not eol, so this might be a buggy
16747 ;; If it was eob instead of ?\n, we allow it.
16749 ;; The line was buggy.
16751 (gnus-error 3.1 "Mangled line: %s"
16752 (buffer-substring (gnus-point-at-bol)
16753 (gnus-point-at-eol)))))
16755 ;; Skip past ", ". Spaces are illegal in these ranges, but
16756 ;; we allow them, because it's a common mistake to put a
16757 ;; space after the comma.
16758 (skip-chars-forward ", "))
16760 ;; We have already read .newsrc.eld, so we gently update the
16761 ;; data in the hash table with the information we have just
16764 (let ((info (gnus-get-info group))
16767 ;; There is an entry for this file in the alist.
16769 (gnus-info-set-read info (nreverse reads))
16770 ;; We update the level very gently. In fact, we
16771 ;; only change it if there's been a status change
16772 ;; from subscribed to unsubscribed, or vice versa.
16773 (setq level (gnus-info-level info))
16774 (cond ((and (<= level gnus-level-subscribed)
16776 (setq level (if reads
16777 gnus-level-default-unsubscribed
16778 (1+ gnus-level-default-unsubscribed))))
16779 ((and (> level gnus-level-subscribed) subscribed)
16780 (setq level gnus-level-default-subscribed)))
16781 (gnus-info-set-level info level))
16782 ;; This is a new group.
16783 (setq info (list group
16785 gnus-level-default-subscribed
16787 (1+ gnus-level-subscribed)
16788 gnus-level-default-unsubscribed))
16789 (nreverse reads))))
16790 (setq newsrc (cons info newsrc))))))
16793 (setq newsrc (nreverse newsrc))
16795 (if (not already-read)
16797 ;; We now have two newsrc lists - `newsrc', which is what we
16798 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16799 ;; what we've read from .newsrc.eld. We have to merge these
16800 ;; lists. We do this by "attaching" any (foreign) groups in the
16801 ;; gnus-newsrc-alist to the (native) group that precedes them.
16802 (let ((rc (cdr gnus-newsrc-alist))
16803 (prev gnus-newsrc-alist)
16806 (or (null (nth 4 (car rc))) ; It's a native group.
16807 (assoc (caar rc) newsrc) ; It's already in the alist.
16808 (if (setq entry (assoc (caar prev) newsrc))
16809 (setcdr (setq mentry (memq entry newsrc))
16810 (cons (car rc) (cdr mentry)))
16811 (setq newsrc (cons (car rc) newsrc))))
16815 (setq gnus-newsrc-alist newsrc)
16816 ;; We make the newsrc hashtb.
16817 (gnus-make-hashtable-from-newsrc-alist)
16819 ;; Finally, if we read some options lines, we parse them.
16820 (or (string= gnus-newsrc-options "")
16821 (gnus-newsrc-parse-options gnus-newsrc-options))))
16823 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16824 ;; The return value will be a list on the form
16825 ;; ((regexp1 . ignore)
16826 ;; (regexp2 . subscribe)...)
16827 ;; When handling new newsgroups, groups that match a `ignore' regexp
16828 ;; will be ignored, and groups that match a `subscribe' regexp will be
16829 ;; subscribed. A line like
16830 ;; options -n !all rec.all
16831 ;; will lead to a list that looks like
16832 ;; (("^rec\\..+" . subscribe)
16833 ;; ("^.+" . ignore))
16834 ;; So all "rec.*" groups will be subscribed, while all the other
16835 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16836 ;; different from "options -n rec.all !all".
16837 (defun gnus-newsrc-parse-options (options)
16840 (gnus-set-work-buffer)
16841 (insert (regexp-quote options))
16842 ;; First we treat all continuation lines.
16843 (goto-char (point-min))
16844 (while (re-search-forward "\n[ \t]+" nil t)
16845 (replace-match " " t t))
16846 ;; Then we transform all "all"s into ".+"s.
16847 (goto-char (point-min))
16848 (while (re-search-forward "\\ball\\b" nil t)
16849 (replace-match ".+" t t))
16850 (goto-char (point-min))
16851 ;; We remove all other options than the "-n" ones.
16852 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16853 (replace-match " ")
16855 (goto-char (point-min))
16857 ;; We are only interested in "options -n" lines - we
16858 ;; ignore the other option lines.
16859 (while (re-search-forward "[ \t]-n" nil t)
16861 (or (save-excursion
16862 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16864 (gnus-point-at-eol)))
16865 ;; Search for all "words"...
16866 (while (re-search-forward "[^ \t,\n]+" eol t)
16867 (if (= (char-after (match-beginning 0)) ?!)
16868 ;; If the word begins with a bang (!), this is a "not"
16869 ;; spec. We put this spec (minus the bang) and the
16870 ;; symbol `ignore' into the list.
16871 (setq out (cons (cons (concat
16872 "^" (buffer-substring
16873 (1+ (match-beginning 0))
16876 ;; There was no bang, so this is a "yes" spec.
16877 (setq out (cons (cons (concat "^" (match-string 0))
16878 'subscribe) out)))))
16880 (setq gnus-newsrc-options-n out))))
16882 (defun gnus-save-newsrc-file (&optional force)
16883 "Save .newsrc file."
16884 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16885 ;; from the variable gnus-newsrc-alist.
16886 (when (and (or gnus-newsrc-alist gnus-killed-list)
16887 gnus-current-startup-file)
16889 (if (and (or gnus-use-dribble-file gnus-slave)
16891 (or (not gnus-dribble-buffer)
16892 (not (buffer-name gnus-dribble-buffer))
16893 (zerop (save-excursion
16894 (set-buffer gnus-dribble-buffer)
16896 (gnus-message 4 "(No changes need to be saved)")
16897 (run-hooks 'gnus-save-newsrc-hook)
16899 (gnus-slave-save-newsrc)
16901 (when gnus-save-newsrc-file
16902 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16903 (gnus-gnus-to-newsrc-format)
16904 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16905 ;; Save .newsrc.eld.
16906 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16907 (make-local-variable 'version-control)
16908 (setq version-control 'never)
16909 (setq buffer-file-name
16910 (concat gnus-current-startup-file ".eld"))
16911 (setq default-directory (file-name-directory buffer-file-name))
16912 (gnus-add-current-to-buffer-list)
16913 (buffer-disable-undo (current-buffer))
16915 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16916 (gnus-gnus-to-quick-newsrc-format)
16917 (run-hooks 'gnus-save-quick-newsrc-hook)
16919 (kill-buffer (current-buffer))
16921 5 "Saving %s.eld...done" gnus-current-startup-file))
16922 (gnus-dribble-delete-file)
16923 (gnus-group-set-mode-line)))))
16925 (defun gnus-gnus-to-quick-newsrc-format ()
16926 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16927 (insert ";; Gnus startup file.\n")
16928 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16929 (insert ";; to read .newsrc.\n")
16930 (insert "(setq gnus-newsrc-file-version "
16931 (prin1-to-string gnus-version) ")\n")
16933 (if gnus-save-killed-list gnus-variable-list
16934 ;; Remove the `gnus-killed-list' from the list of variables
16935 ;; to be saved, if required.
16936 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16937 ;; Peel off the "dummy" group.
16938 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16940 ;; Insert the variables into the file.
16942 (when (and (boundp (setq variable (pop variables)))
16943 (symbol-value variable))
16944 (insert "(setq " (symbol-name variable) " '")
16945 (prin1 (symbol-value variable) (current-buffer))
16948 (defun gnus-gnus-to-newsrc-format ()
16949 ;; Generate and save the .newsrc file.
16951 (set-buffer (create-file-buffer gnus-current-startup-file))
16952 (let ((newsrc (cdr gnus-newsrc-alist))
16953 (standard-output (current-buffer))
16954 info ranges range method)
16955 (setq buffer-file-name gnus-current-startup-file)
16956 (setq default-directory (file-name-directory buffer-file-name))
16957 (buffer-disable-undo (current-buffer))
16960 (if gnus-newsrc-options (insert gnus-newsrc-options))
16961 ;; Write subscribed and unsubscribed.
16962 (while (setq info (pop newsrc))
16963 ;; Don't write foreign groups to .newsrc.
16964 (when (or (null (setq method (gnus-info-method info)))
16965 (equal method "native")
16966 (gnus-server-equal method gnus-select-method))
16967 (insert (gnus-info-group info)
16968 (if (> (gnus-info-level info) gnus-level-subscribed)
16970 (when (setq ranges (gnus-info-read info))
16972 (if (not (listp (cdr ranges)))
16973 (if (= (car ranges) (cdr ranges))
16974 (princ (car ranges))
16975 (princ (car ranges))
16977 (princ (cdr ranges)))
16978 (while (setq range (pop ranges))
16979 (if (or (atom range) (= (car range) (cdr range)))
16980 (princ (or (and (atom range) range) (car range)))
16981 (princ (car range))
16983 (princ (cdr range)))
16984 (if ranges (insert ",")))))
16986 (make-local-variable 'version-control)
16987 (setq version-control 'never)
16988 ;; It has been reported that sometime the modtime on the .newsrc
16989 ;; file seems to be off. We really do want to overwrite it, so
16990 ;; we clear the modtime here before saving. It's a bit odd,
16992 ;; sometimes the modtime clear isn't sufficient. most brute force:
16993 ;; delete the silly thing entirely first. but this fails to provide
16994 ;; such niceties as .newsrc~ creation.
16995 (if gnus-modtime-botch
16996 (delete-file gnus-startup-file)
16997 (clear-visited-file-modtime))
16998 (run-hooks 'gnus-save-standard-newsrc-hook)
17000 (kill-buffer (current-buffer)))))
17004 ;;; Slave functions.
17007 (defun gnus-slave-save-newsrc ()
17009 (set-buffer gnus-dribble-buffer)
17011 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
17012 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
17014 (defun gnus-master-read-slave-newsrc ()
17017 (file-name-directory gnus-current-startup-file)
17021 (file-name-nondirectory gnus-current-startup-file)
17025 (if (not slave-files)
17026 () ; There are no slave files to read.
17027 (gnus-message 7 "Reading slave newsrcs...")
17029 (set-buffer (get-buffer-create " *gnus slave*"))
17030 (buffer-disable-undo (current-buffer))
17032 (sort (mapcar (lambda (file)
17033 (list (nth 5 (file-attributes file)) file))
17036 (or (< (caar f1) (caar f2))
17037 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
17040 (setq file (nth 1 (car slave-files)))
17041 (insert-file-contents file)
17042 (if (condition-case ()
17044 (eval-buffer (current-buffer))
17047 (gnus-error 3.2 "Possible error in %s" file)
17049 (or gnus-slave ; Slaves shouldn't delete these files.
17053 (setq slave-files (cdr slave-files))))
17054 (gnus-message 7 "Reading slave newsrcs...done"))))
17058 ;;; Group description.
17061 (defun gnus-read-all-descriptions-files ()
17062 (let ((methods (cons gnus-select-method
17064 (when (gnus-archive-server-wanted-p)
17066 gnus-secondary-select-methods))))
17068 (gnus-read-descriptions-file (car methods))
17069 (setq methods (cdr methods)))
17072 (defun gnus-read-descriptions-file (&optional method)
17073 (let ((method (or method gnus-select-method))
17075 (when (stringp method)
17076 (setq method (gnus-server-to-method method)))
17077 ;; We create the hashtable whether we manage to read the desc file
17078 ;; to avoid trying to re-read after a failed read.
17079 (or gnus-description-hashtb
17080 (setq gnus-description-hashtb
17081 (gnus-make-hashtable (length gnus-active-hashtb))))
17082 ;; Mark this method's desc file as read.
17083 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
17084 gnus-description-hashtb)
17086 (gnus-message 5 "Reading descriptions file via %s..." (car method))
17088 ((not (gnus-check-server method))
17089 (gnus-message 1 "Couldn't open server")
17091 ((not (gnus-request-list-newsgroups method))
17092 (gnus-message 1 "Couldn't read newsgroups descriptions")
17097 (set-buffer nntp-server-buffer)
17098 (goto-char (point-min))
17099 (when (or (search-forward "\n.\n" nil t)
17100 (goto-char (point-max)))
17101 (beginning-of-line)
17102 (narrow-to-region (point-min) (point)))
17103 ;; If these are groups from a foreign select method, we insert the
17104 ;; group prefix in front of the group names.
17105 (and method (not (gnus-server-equal
17106 (gnus-server-get-method nil method)
17107 (gnus-server-get-method nil gnus-select-method)))
17108 (let ((prefix (gnus-group-prefixed-name "" method)))
17109 (goto-char (point-min))
17110 (while (and (not (eobp))
17111 (progn (insert prefix)
17112 (zerop (forward-line 1)))))))
17113 (goto-char (point-min))
17114 (while (not (eobp))
17115 ;; If we get an error, we set group to 0, which is not a
17119 (let ((obarray gnus-description-hashtb))
17120 ;; Group is set to a symbol interned in this
17122 (read nntp-server-buffer))
17124 (skip-chars-forward " \t")
17125 ;; ... which leads to this line being effectively ignored.
17126 (and (symbolp group)
17127 (set group (buffer-substring
17128 (point) (progn (end-of-line) (point)))))
17129 (forward-line 1))))
17130 (gnus-message 5 "Reading descriptions file...done")
17133 (defun gnus-group-get-description (group)
17134 "Get the description of a group by sending XGTITLE to the server."
17135 (when (gnus-request-group-description group)
17137 (set-buffer nntp-server-buffer)
17138 (goto-char (point-min))
17139 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17140 (match-string 1)))))
17144 ;;; Buffering of read articles.
17147 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17148 (defvar gnus-backlog-articles nil)
17149 (defvar gnus-backlog-hashtb nil)
17151 (defun gnus-backlog-buffer ()
17152 "Return the backlog buffer."
17153 (or (get-buffer gnus-backlog-buffer)
17155 (set-buffer (get-buffer-create gnus-backlog-buffer))
17156 (buffer-disable-undo (current-buffer))
17157 (setq buffer-read-only t)
17158 (gnus-add-current-to-buffer-list)
17159 (get-buffer gnus-backlog-buffer))))
17161 (defun gnus-backlog-setup ()
17162 "Initialize backlog variables."
17163 (unless gnus-backlog-hashtb
17164 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17166 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17168 (defun gnus-backlog-shutdown ()
17169 "Clear all backlog variables and buffers."
17170 (when (get-buffer gnus-backlog-buffer)
17171 (kill-buffer gnus-backlog-buffer))
17172 (setq gnus-backlog-hashtb nil
17173 gnus-backlog-articles nil))
17175 (defun gnus-backlog-enter-article (group number buffer)
17176 (gnus-backlog-setup)
17177 (let ((ident (intern (concat group ":" (int-to-string number))
17178 gnus-backlog-hashtb))
17180 (if (memq ident gnus-backlog-articles)
17181 () ; It's already kept.
17182 ;; Remove the oldest article, if necessary.
17183 (and (numberp gnus-keep-backlog)
17184 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17185 (gnus-backlog-remove-oldest-article))
17186 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17187 ;; Insert the new article.
17189 (set-buffer (gnus-backlog-buffer))
17190 (let (buffer-read-only)
17191 (goto-char (point-max))
17192 (or (bolp) (insert "\n"))
17194 (insert-buffer-substring buffer)
17195 ;; Tag the beginning of the article with the ident.
17196 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17198 (defun gnus-backlog-remove-oldest-article ()
17200 (set-buffer (gnus-backlog-buffer))
17201 (goto-char (point-min))
17202 (if (zerop (buffer-size))
17203 () ; The buffer is empty.
17204 (let ((ident (get-text-property (point) 'gnus-backlog))
17206 ;; Remove the ident from the list of articles.
17208 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17209 ;; Delete the article itself.
17211 (point) (next-single-property-change
17212 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17214 (defun gnus-backlog-remove-article (group number)
17215 "Remove article NUMBER in GROUP from the backlog."
17216 (when (numberp number)
17217 (gnus-backlog-setup)
17218 (let ((ident (intern (concat group ":" (int-to-string number))
17219 gnus-backlog-hashtb))
17221 (when (memq ident gnus-backlog-articles)
17222 ;; It was in the backlog.
17224 (set-buffer (gnus-backlog-buffer))
17225 (let (buffer-read-only)
17226 (when (setq beg (text-property-any
17227 (point-min) (point-max) 'gnus-backlog
17229 ;; Find the end (i. e., the beginning of the next article).
17231 (next-single-property-change
17232 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17233 (delete-region beg end)
17237 (defun gnus-backlog-request-article (group number buffer)
17238 (when (numberp number)
17239 (gnus-backlog-setup)
17240 (let ((ident (intern (concat group ":" (int-to-string number))
17241 gnus-backlog-hashtb))
17243 (when (memq ident gnus-backlog-articles)
17244 ;; It was in the backlog.
17246 (set-buffer (gnus-backlog-buffer))
17247 (if (not (setq beg (text-property-any
17248 (point-min) (point-max) 'gnus-backlog
17250 ;; It wasn't in the backlog after all.
17252 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17253 ;; Find the end (i. e., the beginning of the next article).
17255 (next-single-property-change
17256 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17257 (let ((buffer-read-only nil))
17259 (insert-buffer-substring gnus-backlog-buffer beg end)
17262 ;; Allow redefinition of Gnus functions.
17264 (gnus-ems-redefine)
17268 ;;; gnus.el ends here