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))
35 (eval-when-compile (require 'cl))
37 ;; Site dependent variables. These variables should be defined in
40 (defvar gnus-default-nntp-server nil
41 "Specify a default NNTP server.
42 This variable should be defined in paths.el, and should never be set
44 If you want to change servers, you should use `gnus-select-method'.
45 See the documentation to that variable.")
47 (defvar gnus-backup-default-subscribed-newsgroups
48 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
49 "Default default new newsgroups the first time Gnus is run.
50 Should be set in paths.el, and shouldn't be touched by the user.")
52 (defvar gnus-local-domain nil
53 "Local domain name without a host name.
54 The DOMAINNAME environment variable is used instead if it is defined.
55 If the `system-name' function returns the full Internet name, there is
56 no need to set this variable.")
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
132 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
133 (nnfolder-active-file "~/Mail/archive/active")
134 (nnfolder-get-new-mail nil)
135 (nnfolder-inhibit-expiry t))
136 "*Method used for archiving messages you've sent.
137 This should be a mail method.")
139 (defvar gnus-refer-article-method nil
140 "*Preferred method for fetching an article by Message-ID.
141 If you are reading news from the local spool (with nnspool), fetching
142 articles by Message-ID is painfully slow. By setting this method to an
143 nntp method, you might get acceptable results.
145 The value of this variable must be a valid select method as discussed
146 in the documentation of `gnus-select-method'.")
148 (defvar gnus-secondary-select-methods nil
149 "*A list of secondary methods that will be used for reading news.
150 This is a list where each element is a complete select method (see
151 `gnus-select-method').
153 If, for instance, you want to read your mail with the nnml backend,
154 you could set this variable:
156 (setq gnus-secondary-select-methods '((nnml \"\")))")
158 (defvar gnus-secondary-servers nil
159 "*List of NNTP servers that the user can choose between interactively.
160 To make Gnus query you for a server, you have to give `gnus' a
161 non-numeric prefix - `C-u M-x gnus', in short.")
163 (defvar gnus-nntp-server nil
164 "*The name of the host running the NNTP server.
165 This variable is semi-obsolete. Use the `gnus-select-method'
168 (defvar gnus-startup-file "~/.newsrc"
169 "*Your `.newsrc' file.
170 `.newsrc-SERVER' will be used instead if that exists.")
172 (defvar gnus-init-file "~/.gnus"
173 "*Your Gnus elisp startup file.
174 If a file with the .el or .elc suffixes exist, it will be read
177 (defvar gnus-group-faq-directory
178 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
179 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
180 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
181 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
182 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
183 "/ftp@ftp.sunet.se:/pub/usenet/"
184 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
185 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
186 "/ftp@ftp.hk.super.net:/mirror/faqs/")
187 "*Directory where the group FAQs are stored.
188 This will most commonly be on a remote machine, and the file will be
191 This variable can also be a list of directories. In that case, the
192 first element in the list will be used by default, and the others will
193 be used as backup sites.
195 Note that Gnus uses an aol machine as the default directory. If this
196 feels fundamentally unclean, just think of it as a way to finally get
197 something of value back from them.
199 If the default site is too slow, try one of these:
201 North America: mirrors.aol.com /pub/rtfm/usenet
202 ftp.seas.gwu.edu /pub/rtfm
203 rtfm.mit.edu /pub/usenet/news.answers
204 Europe: ftp.uni-paderborn.de /pub/FAQ
205 src.doc.ic.ac.uk /usenet/news-FAQS
206 ftp.sunet.se /pub/usenet
207 Asia: nctuccca.edu.tw /USENET/FAQ
208 hwarang.postech.ac.kr /pub/usenet/news.answers
209 ftp.hk.super.net /mirror/faqs")
211 (defvar gnus-group-archive-directory
212 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
213 "*The address of the (ding) archives.")
215 (defvar gnus-group-recent-archive-directory
216 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
217 "*The address of the most recent (ding) articles.")
219 (defvar gnus-default-subscribed-newsgroups nil
220 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
221 It should be a list of strings.
222 If it is `t', Gnus will not do anything special the first time it is
223 started; it'll just use the normal newsgroups subscription methods.")
225 (defvar gnus-use-cross-reference t
226 "*Non-nil means that cross referenced articles will be marked as read.
227 If nil, ignore cross references. If t, mark articles as read in
228 subscribed newsgroups. If neither t nor nil, mark as read in all
231 (defvar gnus-single-article-buffer t
232 "*If non-nil, display all articles in the same buffer.
233 If nil, each group will get its own article buffer.")
235 (defvar gnus-use-dribble-file t
236 "*Non-nil means that Gnus will use a dribble file to store user updates.
237 If Emacs should crash without saving the .newsrc files, complete
238 information can be restored from the dribble file.")
240 (defvar gnus-dribble-directory nil
241 "*The directory where dribble files will be saved.
242 If this variable is nil, the directory where the .newsrc files are
243 saved will be used.")
245 (defvar gnus-asynchronous nil
246 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
248 (defvar gnus-kill-summary-on-exit t
249 "*If non-nil, kill the summary buffer when you exit from it.
250 If nil, the summary will become a \"*Dead Summary*\" buffer, and
251 it will be killed sometime later.")
253 (defvar gnus-large-newsgroup 200
254 "*The number of articles which indicates a large newsgroup.
255 If the number of articles in a newsgroup is greater than this value,
256 confirmation is required for selecting the newsgroup.")
258 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
259 (defvar gnus-no-groups-message "No news is horrible news"
260 "*Message displayed by Gnus when no groups are available.")
262 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
263 "*Non-nil means that the default name of a file to save articles in is the group name.
264 If it's nil, the directory form of the group name is used instead.
266 If this variable is a list, and the list contains the element
267 `not-score', long file names will not be used for score files; if it
268 contains the element `not-save', long file names will not be used for
269 saving; and if it contains the element `not-kill', long file names
270 will not be used for kill files.")
272 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
273 "*Name of the directory articles will be saved in (default \"~/News\").
274 Initialized from the SAVEDIR environment variable.")
276 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
277 "*Name of the directory where kill files will be stored (default \"~/News\").
278 Initialized from the SAVEDIR environment variable.")
280 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
281 "*A function to save articles in your favorite format.
282 The function must be interactively callable (in other words, it must
283 be an Emacs command).
285 Gnus provides the following functions:
287 * gnus-summary-save-in-rmail (Rmail format)
288 * gnus-summary-save-in-mail (Unix mail format)
289 * gnus-summary-save-in-folder (MH folder)
290 * gnus-summary-save-in-file (article format).
291 * gnus-summary-save-in-vm (use VM's folder format).")
293 (defvar gnus-prompt-before-saving 'always
294 "*This variable says how much prompting is to be done when saving articles.
295 If it is nil, no prompting will be done, and the articles will be
296 saved to the default files. If this variable is `always', each and
297 every article that is saved will be preceded by a prompt, even when
298 saving large batches of articles. If this variable is neither nil not
299 `always', there the user will be prompted once for a file name for
300 each invocation of the saving commands.")
302 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
303 "*A function generating a file name to save articles in Rmail format.
304 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
306 (defvar gnus-mail-save-name (function gnus-plain-save-name)
307 "*A function generating a file name to save articles in Unix mail format.
308 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
310 (defvar gnus-folder-save-name (function gnus-folder-save-name)
311 "*A function generating a file name to save articles in MH folder.
312 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
314 (defvar gnus-file-save-name (function gnus-numeric-save-name)
315 "*A function generating a file name to save articles in article format.
316 The function is called with NEWSGROUP, HEADERS, and optional
319 (defvar gnus-split-methods
320 '((gnus-article-archive-name))
321 "*Variable used to suggest where articles are to be saved.
322 For instance, if you would like to save articles related to Gnus in
323 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
324 you could set this variable to something like:
326 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
327 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
329 This variable is an alist where the where the key is the match and the
330 value is a list of possible files to save in if the match is non-nil.
332 If the match is a string, it is used as a regexp match on the
333 article. If the match is a symbol, that symbol will be funcalled
334 from the buffer of the article to be saved with the newsgroup as the
335 parameter. If it is a list, it will be evaled in the same buffer.
337 If this form or function returns a string, this string will be used as
338 a possible file name; and if it returns a non-nil list, that list will
339 be used as possible file names.")
341 (defvar gnus-move-split-methods nil
342 "*Variable used to suggest where articles are to be moved to.
343 It uses the same syntax as the `gnus-split-methods' variable.")
345 (defvar gnus-save-score nil
346 "*If non-nil, save group scoring info.")
348 (defvar gnus-use-adaptive-scoring nil
349 "*If non-nil, use some adaptive scoring scheme.")
351 (defvar gnus-use-cache nil
352 "*If nil, Gnus will ignore the article cache.
353 If `passive', it will allow entering (and reading) articles
354 explicitly entered into the cache. If anything else, use the
355 cache to the full extent of the law.")
357 (defvar gnus-use-trees nil
358 "*If non-nil, display a thread tree buffer.")
360 (defvar gnus-use-grouplens nil
361 "*If non-nil, use GroupLens ratings.")
363 (defvar gnus-keep-backlog nil
364 "*If non-nil, Gnus will keep read articles for later re-retrieval.
365 If it is a number N, then Gnus will only keep the last N articles
366 read. If it is neither nil nor a number, Gnus will keep all read
367 articles. This is not a good idea.")
369 (defvar gnus-use-nocem nil
370 "*If non-nil, Gnus will read NoCeM cancel messages.")
372 (defvar gnus-use-demon nil
373 "If non-nil, Gnus might use some demons.")
375 (defvar gnus-use-scoring t
376 "*If non-nil, enable scoring.")
378 (defvar gnus-use-picons nil
379 "*If non-nil, display picons.")
381 (defvar gnus-fetch-old-headers nil
382 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
383 If an unread article in the group refers to an older, already read (or
384 just marked as read) article, the old article will not normally be
385 displayed in the Summary buffer. If this variable is non-nil, Gnus
386 will attempt to grab the headers to the old articles, and thereby
387 build complete threads. If it has the value `some', only enough
388 headers to connect otherwise loose threads will be displayed.
389 This variable can also be a number. In that case, no more than that
390 number of old headers will be fetched.
392 The server has to support NOV for any of this to work.")
395 ;(defvar gnus-visual t
396 ; "*If non-nil, will do various highlighting.
397 ;If nil, no mouse highlights (or any other highlights) will be
398 ;performed. This might speed up Gnus some when generating large group
399 ;and summary buffers.")
401 (defvar gnus-novice-user t
402 "*Non-nil means that you are a usenet novice.
403 If non-nil, verbose messages may be displayed and confirmations may be
406 (defvar gnus-expert-user nil
407 "*Non-nil means that you will never be asked for confirmation about anything.
408 And that means *anything*.")
410 (defvar gnus-verbose 7
411 "*Integer that says how verbose Gnus should be.
412 The higher the number, the more messages Gnus will flash to say what
413 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
414 display most important messages; and at ten, Gnus will keep on
415 jabbering all the time.")
417 (defvar gnus-keep-same-level nil
418 "*Non-nil means that the next newsgroup after the current will be on the same level.
419 When you type, for instance, `n' after reading the last article in the
420 current newsgroup, you will go to the next newsgroup. If this variable
421 is nil, the next newsgroup will be the next from the group
423 If this variable is non-nil, Gnus will either put you in the
424 next newsgroup with the same level, or, if no such newsgroup is
425 available, the next newsgroup with the lowest possible level higher
426 than the current level.
427 If this variable is `best', Gnus will make the next newsgroup the one
428 with the best level.")
430 (defvar gnus-summary-make-false-root 'adopt
431 "*nil means that Gnus won't gather loose threads.
432 If the root of a thread has expired or been read in a previous
433 session, the information necessary to build a complete thread has been
434 lost. Instead of having many small sub-threads from this original thread
435 scattered all over the summary buffer, Gnus can gather them.
437 If non-nil, Gnus will try to gather all loose sub-threads from an
438 original thread into one large thread.
440 If this variable is non-nil, it should be one of `none', `adopt',
443 If this variable is `none', Gnus will not make a false root, but just
444 present the sub-threads after another.
445 If this variable is `dummy', Gnus will create a dummy root that will
446 have all the sub-threads as children.
447 If this variable is `adopt', Gnus will make one of the \"children\"
448 the parent and mark all the step-children as such.
449 If this variable is `empty', the \"children\" are printed with empty
450 subject fields. (Or rather, they will be printed with a string
451 given by the `gnus-summary-same-subject' variable.)")
453 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
454 "*A regexp to match subjects to be excluded from loose thread gathering.
455 As loose thread gathering is done on subjects only, that means that
456 there can be many false gatherings performed. By rooting out certain
457 common subjects, gathering might become saner.")
459 (defvar gnus-summary-gather-subject-limit nil
460 "*Maximum length of subject comparisons when gathering loose threads.
461 Use nil to compare full subjects. Setting this variable to a low
462 number will help gather threads that have been corrupted by
463 newsreaders chopping off subject lines, but it might also mean that
464 unrelated articles that have subject that happen to begin with the
465 same few characters will be incorrectly gathered.
467 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
468 comparing subjects.")
470 (defvar gnus-simplify-ignored-prefixes nil
471 "*Regexp, matches for which are removed from subject lines when simplifying.")
473 (defvar gnus-build-sparse-threads nil
474 "*If non-nil, fill in the gaps in threads.
475 If `some', only fill in the gaps that are needed to tie loose threads
476 together. If `more', fill in all leaf nodes that Gnus can find. If
477 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
479 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
480 "Function used for gathering loose threads.
481 There are two pre-defined functions: `gnus-gather-threads-by-subject',
482 which only takes Subjects into consideration; and
483 `gnus-gather-threads-by-references', which compared the References
484 headers of the articles to find matches.")
486 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
487 (defvar gnus-summary-same-subject ""
488 "*String indicating that the current article has the same subject as the previous.
489 This variable will only be used if the value of
490 `gnus-summary-make-false-root' is `empty'.")
492 (defvar gnus-summary-goto-unread t
493 "*If non-nil, marking commands will go to the next unread article.
494 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
495 whether it is read or not.")
497 (defvar gnus-group-goto-unread t
498 "*If non-nil, movement commands will go to the next unread and subscribed group.")
500 (defvar gnus-goto-next-group-when-activating t
501 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
503 (defvar gnus-check-new-newsgroups t
504 "*Non-nil means that Gnus will add new newsgroups at startup.
505 If this variable is `ask-server', Gnus will ask the server for new
506 groups since the last time it checked. This means that the killed list
507 is no longer necessary, so you could set `gnus-save-killed-list' to
510 A variant is to have this variable be a list of select methods. Gnus
511 will then use the `ask-server' method on all these select methods to
512 query for new groups from all those servers.
515 (setq gnus-check-new-newsgroups
516 '((nntp \"some.server\") (nntp \"other.server\")))
518 If this variable is nil, then you have to tell Gnus explicitly to
519 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
521 (defvar gnus-check-bogus-newsgroups nil
522 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
523 If this variable is nil, then you have to tell Gnus explicitly to
524 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
526 (defvar gnus-read-active-file t
527 "*Non-nil means that Gnus will read the entire active file at startup.
528 If this variable is nil, Gnus will only know about the groups in your
531 If this variable is `some', Gnus will try to only read the relevant
532 parts of the active file from the server. Not all servers support
533 this, and it might be quite slow with other servers, but this should
534 generally be faster than both the t and nil value.
536 If you set this variable to nil or `some', you probably still want to
537 be told about new newsgroups that arrive. To do that, set
538 `gnus-check-new-newsgroups' to `ask-server'. This may not work
539 properly with all servers.")
541 (defvar gnus-level-subscribed 5
542 "*Groups with levels less than or equal to this variable are subscribed.")
544 (defvar gnus-level-unsubscribed 7
545 "*Groups with levels less than or equal to this variable are unsubscribed.
546 Groups with levels less than `gnus-level-subscribed', which should be
547 less than this variable, are subscribed.")
549 (defvar gnus-level-zombie 8
550 "*Groups with this level are zombie groups.")
552 (defvar gnus-level-killed 9
553 "*Groups with this level are killed.")
555 (defvar gnus-level-default-subscribed 3
556 "*New subscribed groups will be subscribed at this level.")
558 (defvar gnus-level-default-unsubscribed 6
559 "*New unsubscribed groups will be unsubscribed at this level.")
561 (defvar gnus-activate-level (1+ gnus-level-subscribed)
562 "*Groups higher than this level won't be activated on startup.
563 Setting this variable to something log might save lots of time when
564 you have many groups that you aren't interested in.")
566 (defvar gnus-activate-foreign-newsgroups 4
567 "*If nil, Gnus will not check foreign newsgroups at startup.
568 If it is non-nil, it should be a number between one and nine. Foreign
569 newsgroups that have a level lower or equal to this number will be
570 activated on startup. For instance, if you want to active all
571 subscribed newsgroups, but not the rest, you'd set this variable to
572 `gnus-level-subscribed'.
574 If you subscribe to lots of newsgroups from different servers, startup
575 might take a while. By setting this variable to nil, you'll save time,
576 but you won't be told how many unread articles there are in the
579 (defvar gnus-save-newsrc-file t
580 "*Non-nil means that Gnus will save the `.newsrc' file.
581 Gnus always saves its own startup file, which is called
582 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
583 be readily understood by other newsreaders. If you don't plan on
584 using other newsreaders, set this variable to nil to save some time on
587 (defvar gnus-save-killed-list t
588 "*If non-nil, save the list of killed groups to the startup file.
589 If you set this variable to nil, you'll save both time (when starting
590 and quitting) and space (both memory and disk), but it will also mean
591 that Gnus has no record of which groups are new and which are old, so
592 the automatic new newsgroups subscription methods become meaningless.
594 You should always set `gnus-check-new-newsgroups' to `ask-server' or
595 nil if you set this variable to nil.")
597 (defvar gnus-interactive-catchup t
598 "*If non-nil, require your confirmation when catching up a group.")
600 (defvar gnus-interactive-post t
601 "*If non-nil, group name will be asked for when posting.")
603 (defvar gnus-interactive-exit t
604 "*If non-nil, require your confirmation when exiting Gnus.")
606 (defvar gnus-kill-killed t
607 "*If non-nil, Gnus will apply kill files to already killed articles.
608 If it is nil, Gnus will never apply kill files to articles that have
609 already been through the scoring process, which might very well save lots
612 (defvar gnus-extract-address-components 'gnus-extract-address-components
613 "*Function for extracting address components from a From header.
614 Two pre-defined function exist: `gnus-extract-address-components',
615 which is the default, quite fast, and too simplistic solution, and
616 `mail-extract-address-components', which works much better, but is
619 (defvar gnus-summary-default-score 0
620 "*Default article score level.
621 If this variable is nil, scoring will be disabled.")
623 (defvar gnus-summary-zcore-fuzz 0
624 "*Fuzziness factor for the zcore in the summary buffer.
625 Articles with scores closer than this to `gnus-summary-default-score'
626 will not be marked.")
628 (defvar gnus-simplify-subject-fuzzy-regexp nil
629 "*Strings to be removed when doing fuzzy matches.
630 This can either be a regular expression or list of regular expressions
631 that will be removed from subject strings if fuzzy subject
632 simplification is selected.")
634 (defvar gnus-permanently-visible-groups nil
635 "*Regexp to match groups that should always be listed in the group buffer.
636 This means that they will still be listed when there are no unread
637 articles in the groups.")
639 (defvar gnus-list-groups-with-ticked-articles t
640 "*If non-nil, list groups that have only ticked articles.
641 If nil, only list groups that have unread articles.")
643 (defvar gnus-group-default-list-level gnus-level-subscribed
644 "*Default listing level.
645 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
647 (defvar gnus-group-use-permanent-levels nil
648 "*If non-nil, once you set a level, Gnus will use this level.")
650 (defvar gnus-group-list-inactive-groups t
651 "*If non-nil, inactive groups will be listed.")
653 (defvar gnus-show-mime nil
654 "*If non-nil, do mime processing of articles.
655 The articles will simply be fed to the function given by
656 `gnus-show-mime-method'.")
658 (defvar gnus-strict-mime t
659 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
661 (defvar gnus-show-mime-method 'metamail-buffer
662 "*Function to process a MIME message.
663 The function is called from the article buffer.")
665 (defvar gnus-decode-encoded-word-method (lambda ())
666 "*Function to decode a MIME encoded-words.
667 The function is called from the article buffer.")
669 (defvar gnus-show-threads t
670 "*If non-nil, display threads in summary mode.")
672 (defvar gnus-thread-hide-subtree nil
673 "*If non-nil, hide all threads initially.
674 If threads are hidden, you have to run the command
675 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
676 to expose hidden threads.")
678 (defvar gnus-thread-hide-killed t
679 "*If non-nil, hide killed threads automatically.")
681 (defvar gnus-thread-ignore-subject nil
682 "*If non-nil, ignore subjects and do all threading based on the Reference header.
683 If nil, which is the default, articles that have different subjects
684 from their parents will start separate threads.")
686 (defvar gnus-thread-operation-ignore-subject t
687 "*If non-nil, subjects will be ignored when doing thread commands.
688 This affects commands like `gnus-summary-kill-thread' and
689 `gnus-summary-lower-thread'.
691 If this variable is nil, articles in the same thread with different
692 subjects will not be included in the operation in question. If this
693 variable is `fuzzy', only articles that have subjects that are fuzzily
694 equal will be included.")
696 (defvar gnus-thread-indent-level 4
697 "*Number that says how much each sub-thread should be indented.")
699 (defvar gnus-ignored-newsgroups
700 (purecopy (mapconcat 'identity
701 '("^to\\." ; not "real" groups
702 "^[0-9. \t]+ " ; all digits in name
703 "[][\"#'()]" ; bogus characters
706 "*A regexp to match uninteresting newsgroups in the active file.
707 Any lines in the active file matching this regular expression are
708 removed from the newsgroup list before anything else is done to it,
709 thus making them effectively non-existent.")
711 (defvar gnus-ignored-headers
712 "^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:"
713 "*All headers that match this regexp will be hidden.
714 This variable can also be a list of regexps of headers to be ignored.
715 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
717 (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-"
718 "*All headers that do not match this regexp will be hidden.
719 This variable can also be a list of regexp of headers to remain visible.
720 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
722 (defvar gnus-sorted-header-list
723 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
724 "^Cc:" "^Date:" "^Organization:")
725 "*This variable is a list of regular expressions.
726 If it is non-nil, headers that match the regular expressions will
727 be placed first in the article buffer in the sequence specified by
730 (defvar gnus-boring-article-headers
731 '(empty followup-to reply-to)
732 "*Headers that are only to be displayed if they have interesting data.
733 Possible values in this list are `empty', `newsgroups', `followup-to',
734 `reply-to', and `date'.")
736 (defvar gnus-show-all-headers nil
737 "*If non-nil, don't hide any headers.")
739 (defvar gnus-save-all-headers t
740 "*If non-nil, don't remove any headers before saving.")
742 (defvar gnus-saved-headers gnus-visible-headers
743 "*Headers to keep if `gnus-save-all-headers' is nil.
744 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
745 If that variable is nil, however, all headers that match this regexp
746 will be kept while the rest will be deleted before saving.")
748 (defvar gnus-inhibit-startup-message nil
749 "*If non-nil, the startup message will not be displayed.")
751 (defvar gnus-signature-separator "^-- *$"
752 "Regexp matching signature separator.")
754 (defvar gnus-signature-limit nil
755 "Provide a limit to what is considered a signature.
756 If it is a number, no signature may not be longer (in characters) than
757 that number. If it is a function, the function will be called without
758 any parameters, and if it returns nil, there is no signature in the
759 buffer. If it is a string, it will be used as a regexp. If it
760 matches, the text in question is not a signature.")
762 (defvar gnus-auto-extend-newsgroup t
763 "*If non-nil, extend newsgroup forward and backward when requested.")
765 (defvar gnus-auto-select-first t
766 "*If nil, don't select the first unread article when entering a group.
767 If this variable is `best', select the highest-scored unread article
768 in the group. If neither nil nor `best', select the first unread
771 If you want to prevent automatic selection of the first unread article
772 in some newsgroups, set the variable to nil in
773 `gnus-select-group-hook'.")
775 (defvar gnus-auto-select-next t
776 "*If non-nil, offer to go to the next group from the end of the previous.
777 If the value is t and the next newsgroup is empty, Gnus will exit
778 summary mode and go back to group mode. If the value is neither nil
779 nor t, Gnus will select the following unread newsgroup. In
780 particular, if the value is the symbol `quietly', the next unread
781 newsgroup will be selected without any confirmation, and if it is
782 `almost-quietly', the next group will be selected without any
783 confirmation if you are located on the last article in the group.
784 Finally, if this variable is `slightly-quietly', the `Z n' command
785 will go to the next group without confirmation.")
787 (defvar gnus-auto-select-same nil
788 "*If non-nil, select the next article with the same subject.")
790 (defvar gnus-summary-check-current nil
791 "*If non-nil, consider the current article when moving.
792 The \"unread\" movement commands will stay on the same line if the
793 current article is unread.")
795 (defvar gnus-auto-center-summary t
796 "*If non-nil, always center the current summary buffer.
797 In particular, if `vertical' do only vertical recentering. If non-nil
798 and non-`vertical', do both horizontal and vertical recentering.")
800 (defvar gnus-break-pages t
801 "*If non-nil, do page breaking on articles.
802 The page delimiter is specified by the `gnus-page-delimiter'
805 (defvar gnus-page-delimiter "^\^L"
806 "*Regexp describing what to use as article page delimiters.
807 The default value is \"^\^L\", which is a form linefeed at the
808 beginning of a line.")
810 (defvar gnus-use-full-window t
811 "*If non-nil, use the entire Emacs screen.")
813 (defvar gnus-window-configuration nil
814 "Obsolete variable. See `gnus-buffer-configuration'.")
816 (defvar gnus-window-min-width 2
817 "*Minimum width of Gnus buffers.")
819 (defvar gnus-window-min-height 1
820 "*Minimum height of Gnus buffers.")
822 (defvar gnus-buffer-configuration
826 (if gnus-carpal '(group-carpal 4))))
830 (if gnus-carpal '(summary-carpal 4))))
837 (if gnus-carpal '(summary-carpal 4))
839 (vertical ((height . 5) (width . 15)
841 (left . -1) (top . 1))
851 (if gnus-carpal '(summary-carpal 4))
852 (if gnus-use-trees '(tree 0.25))
857 (if gnus-carpal '(server-carpal 2))))
861 (if gnus-carpal '(browse-carpal 2))))
864 (message 1.0 point)))
867 (article 1.0 point)))
878 (edit-group 1.0 point)))
882 (edit-server 1.0 point)))
886 (edit-score 1.0 point)))
893 (message 1.0 point)))
896 (message 1.0 point)))
899 (message 1.0 point)))
903 (message 1.0 point)))
910 (if gnus-carpal '(summary-carpal 4))
911 ("*Shell Command Output*" 1.0)))
915 (message 1.0 point))))
916 "Window configuration for all possible Gnus buffers.
917 This variable is a list of lists. Each of these lists has a NAME and
918 a RULE. The NAMEs are commonsense names like `group', which names a
919 rule used when displaying the group buffer; `summary', which names a
920 rule for what happens when you enter a group and do not display an
921 article buffer; and so on. See the value of this variable for a
922 complete list of NAMEs.
924 Each RULE is a list of vectors. The first element in this vector is
925 the name of the buffer to be displayed; the second element is the
926 percentage of the screen this buffer is to occupy (a number in the
927 0.0-0.99 range); the optional third element is `point', which should
928 be present to denote which buffer point is to go to after making this
929 buffer configuration.")
931 (defvar gnus-window-to-buffer
932 '((group . gnus-group-buffer)
933 (summary . gnus-summary-buffer)
934 (article . gnus-article-buffer)
935 (server . gnus-server-buffer)
936 (browse . "*Gnus Browse Server*")
937 (edit-group . gnus-group-edit-buffer)
938 (edit-server . gnus-server-edit-buffer)
939 (group-carpal . gnus-carpal-group-buffer)
940 (summary-carpal . gnus-carpal-summary-buffer)
941 (server-carpal . gnus-carpal-server-buffer)
942 (browse-carpal . gnus-carpal-browse-buffer)
943 (edit-score . gnus-score-edit-buffer)
944 (message . gnus-message-buffer)
945 (faq . gnus-faq-buffer)
946 (picons . "*Picons*")
947 (tree . gnus-tree-buffer)
948 (info . gnus-info-buffer)
949 (article-copy . gnus-article-copy)
950 (draft . gnus-draft-buffer))
951 "Mapping from short symbols to buffer names or buffer variables.")
953 (defvar gnus-carpal nil
954 "*If non-nil, display clickable icons.")
956 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
957 "*Function called with a group name when new group is detected.
958 A few pre-made functions are supplied: `gnus-subscribe-randomly'
959 inserts new groups at the beginning of the list of groups;
960 `gnus-subscribe-alphabetically' inserts new groups in strict
961 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
962 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
963 for your decision; `gnus-subscribe-killed' kills all new groups.")
965 ;; Suggested by a bug report by Hallvard B Furuseth.
966 ;; <h.b.furuseth@usit.uio.no>.
967 (defvar gnus-subscribe-options-newsgroup-method
968 (function gnus-subscribe-alphabetically)
969 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
970 If, for instance, you want to subscribe to all newsgroups in the
971 \"no\" and \"alt\" hierarchies, you'd put the following in your
974 options -n no.all alt.all
976 Gnus will the subscribe all new newsgroups in these hierarchies with
977 the subscription method in this variable.")
979 (defvar gnus-subscribe-hierarchical-interactive nil
980 "*If non-nil, Gnus will offer to subscribe hierarchically.
981 When a new hierarchy appears, Gnus will ask the user:
983 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
985 If the user pressed `d', Gnus will descend the hierarchy, `y' will
986 subscribe to all newsgroups in the hierarchy and `s' will skip this
987 hierarchy in its entirety.")
989 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
990 "*Function used for sorting the group buffer.
991 This function will be called with group info entries as the arguments
992 for the groups to be sorted. Pre-made functions include
993 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
994 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
995 `gnus-group-sort-by-rank'.
997 This variable can also be a list of sorting functions. In that case,
998 the most significant sort function should be the last function in the
1001 ;; Mark variables suggested by Thomas Michanek
1002 ;; <Thomas.Michanek@telelogic.se>.
1003 (defvar gnus-unread-mark ?
1004 "*Mark used for unread articles.")
1005 (defvar gnus-ticked-mark ?!
1006 "*Mark used for ticked articles.")
1007 (defvar gnus-dormant-mark ??
1008 "*Mark used for dormant articles.")
1009 (defvar gnus-del-mark ?r
1010 "*Mark used for del'd articles.")
1011 (defvar gnus-read-mark ?R
1012 "*Mark used for read articles.")
1013 (defvar gnus-expirable-mark ?E
1014 "*Mark used for expirable articles.")
1015 (defvar gnus-killed-mark ?K
1016 "*Mark used for killed articles.")
1017 (defvar gnus-souped-mark ?F
1018 "*Mark used for killed articles.")
1019 (defvar gnus-kill-file-mark ?X
1020 "*Mark used for articles killed by kill files.")
1021 (defvar gnus-low-score-mark ?Y
1022 "*Mark used for articles with a low score.")
1023 (defvar gnus-catchup-mark ?C
1024 "*Mark used for articles that are caught up.")
1025 (defvar gnus-replied-mark ?A
1026 "*Mark used for articles that have been replied to.")
1027 (defvar gnus-cached-mark ?*
1028 "*Mark used for articles that are in the cache.")
1029 (defvar gnus-saved-mark ?S
1030 "*Mark used for articles that have been saved to.")
1031 (defvar gnus-process-mark ?#
1033 (defvar gnus-ancient-mark ?O
1034 "*Mark used for ancient articles.")
1035 (defvar gnus-sparse-mark ?Q
1036 "*Mark used for sparsely reffed articles.")
1037 (defvar gnus-canceled-mark ?G
1038 "*Mark used for canceled articles.")
1039 (defvar gnus-score-over-mark ?+
1040 "*Score mark used for articles with high scores.")
1041 (defvar gnus-score-below-mark ?-
1042 "*Score mark used for articles with low scores.")
1043 (defvar gnus-empty-thread-mark ?
1044 "*There is no thread under the article.")
1045 (defvar gnus-not-empty-thread-mark ?=
1046 "*There is a thread under the article.")
1048 (defvar gnus-view-pseudo-asynchronously nil
1049 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1051 (defvar gnus-view-pseudos nil
1052 "*If `automatic', pseudo-articles will be viewed automatically.
1053 If `not-confirm', pseudos will be viewed automatically, and the user
1054 will not be asked to confirm the command.")
1056 (defvar gnus-view-pseudos-separately t
1057 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1058 If nil, all files that use the same viewing command will be given as a
1059 list of parameters to that command.")
1061 (defvar gnus-insert-pseudo-articles t
1062 "*If non-nil, insert pseudo-articles when decoding articles.")
1064 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1065 "*Format of group lines.
1066 It works along the same lines as a normal formatting string,
1067 with some simple extensions.
1069 %M Only marked articles (character, \"*\" or \" \")
1070 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1071 %L Level of subscribedness (integer)
1072 %N Number of unread articles (integer)
1073 %I Number of dormant articles (integer)
1074 %i Number of ticked and dormant (integer)
1075 %T Number of ticked articles (integer)
1076 %R Number of read articles (integer)
1077 %t Total number of articles (integer)
1078 %y Number of unread, unticked articles (integer)
1079 %G Group name (string)
1080 %g Qualified group name (string)
1081 %D Group description (string)
1082 %s Select method (string)
1083 %o Moderated group (char, \"m\")
1084 %p Process mark (char)
1085 %O Moderated group (string, \"(m)\" or \"\")
1086 %P Topic indentation (string)
1087 %l Whether there are GroupLens predictions for this group (string)
1088 %n Select from where (string)
1089 %z A string that look like `<%s:%n>' if a foreign select method is used
1090 %u User defined specifier. The next character in the format string should
1091 be a letter. Gnus will call the function gnus-user-format-function-X,
1092 where X is the letter following %u. The function will be passed the
1093 current header as argument. The function should return a string, which
1094 will be inserted into the buffer just like information from any other
1097 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1098 the mouse point move inside the area. There can only be one such area.
1100 Note that this format specification is not always respected. For
1101 reasons of efficiency, when listing killed groups, this specification
1102 is ignored altogether. If the spec is changed considerably, your
1103 output may end up looking strange when listing both alive and killed
1106 If you use %o or %O, reading the active file will be slower and quite
1107 a bit of extra memory will be used. %D will also worsen performance.
1108 Also note that if you change the format specification to include any
1109 of these specs, you must probably re-start Gnus to see them go into
1112 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1113 "*The format specification of the lines in the summary buffer.
1115 It works along the same lines as a normal formatting string,
1116 with some simple extensions.
1118 %N Article number, left padded with spaces (string)
1120 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1121 %n Name of the poster (string)
1122 %a Extracted name of the poster (string)
1123 %A Extracted address of the poster (string)
1124 %F Contents of the From: header (string)
1125 %x Contents of the Xref: header (string)
1126 %D Date of the article (string)
1127 %d Date of the article (string) in DD-MMM format
1128 %M Message-id of the article (string)
1129 %r References of the article (string)
1130 %c Number of characters in the article (integer)
1131 %L Number of lines in the article (integer)
1132 %I Indentation based on thread level (a string of spaces)
1133 %T A string with two possible values: 80 spaces if the article
1134 is on thread level two or larger and 0 spaces on level one
1135 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1136 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1137 %[ Opening bracket (character, \"[\" or \"<\")
1138 %] Closing bracket (character, \"]\" or \">\")
1139 %> Spaces of length thread-level (string)
1140 %< Spaces of length (- 20 thread-level) (string)
1141 %i Article score (number)
1142 %z Article zcore (character)
1143 %t Number of articles under the current thread (number).
1144 %e Whether the thread is empty or not (character).
1145 %l GroupLens score (number)
1146 %u User defined specifier. The next character in the format string should
1147 be a letter. Gnus will call the function gnus-user-format-function-X,
1148 where X is the letter following %u. The function will be passed the
1149 current header as argument. The function should return a string, which
1150 will be inserted into the summary just like information from any other
1153 Text between %( and %) will be highlighted with `gnus-mouse-face'
1154 when the mouse point is placed inside the area. There can only be one
1157 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1158 with care. For reasons of efficiency, Gnus will compute what column
1159 these characters will end up in, and \"hard-code\" that. This means that
1160 it is illegal to have these specs after a variable-length spec. Well,
1161 you might not be arrested, but your summary buffer will look strange,
1162 which is bad enough.
1164 The smart choice is to have these specs as for to the left as
1167 This restriction may disappear in later versions of Gnus.")
1169 (defvar gnus-summary-dummy-line-format
1171 "*The format specification for the dummy roots in the summary buffer.
1172 It works along the same lines as a normal formatting string,
1173 with some simple extensions.
1177 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1178 "*The format specification for the summary mode line.
1179 It works along the same lines as a normal formatting string,
1180 with some simple extensions:
1183 %p Unprefixed group name
1184 %A Current article number
1186 %U Number of unread articles in the group
1187 %e Number of unselected articles in the group
1188 %Z A string with unread/unselected article counts
1189 %g Shortish group name
1190 %S Subject of the current article
1191 %u User-defined spec
1192 %s Current score file name
1193 %d Number of dormant articles
1194 %r Number of articles that have been marked as read in this session
1195 %E Number of articles expunged by the score files")
1197 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1198 "*The format specification for the article mode line.
1199 See `gnus-summary-mode-line-format' for a closer description.")
1201 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1202 "*The format specification for the group mode line.
1203 It works along the same lines as a normal formatting string,
1204 with some simple extensions:
1206 %S The native news server.
1207 %M The native select method.")
1209 (defvar gnus-valid-select-methods
1210 '(("nntp" post address prompt-address)
1211 ("nnspool" post address)
1212 ("nnvirtual" post-mail virtual prompt-address)
1213 ("nnmbox" mail respool address)
1214 ("nnml" mail respool address)
1215 ("nnmh" mail respool address)
1216 ("nndir" post-mail prompt-address address)
1217 ("nneething" none address prompt-address)
1218 ("nndoc" none address prompt-address)
1219 ("nnbabyl" mail address respool)
1220 ("nnkiboze" post address virtual)
1221 ("nnsoup" post-mail address)
1222 ("nndraft" post-mail)
1223 ("nnfolder" mail respool address))
1224 "An alist of valid select methods.
1225 The first element of each list lists should be a string with the name
1226 of the select method. The other elements may be be the category of
1227 this method (ie. `post', `mail', `none' or whatever) or other
1228 properties that this method has (like being respoolable).
1229 If you implement a new select method, all you should have to change is
1230 this variable. I think.")
1232 (defvar gnus-updated-mode-lines '(group article summary tree)
1233 "*List of buffers that should update their mode lines.
1234 The list may contain the symbols `group', `article' and `summary'. If
1235 the corresponding symbol is present, Gnus will keep that mode line
1236 updated with information that may be pertinent.
1237 If this variable is nil, screen refresh may be quicker.")
1239 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1240 (defvar gnus-mode-non-string-length nil
1241 "*Max length of mode-line non-string contents.
1242 If this is nil, Gnus will take space as is needed, leaving the rest
1243 of the modeline intact.")
1246 ;(defvar gnus-mouse-face 'highlight
1247 ; "*Face used for mouse highlighting in Gnus.
1248 ;No mouse highlights will be done if `gnus-visual' is nil.")
1250 (defvar gnus-summary-mark-below nil
1251 "*Mark all articles with a score below this variable as read.
1252 This variable is local to each summary buffer and usually set by the
1255 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1256 "*List of functions used for sorting articles in the summary buffer.
1257 This variable is only used when not using a threaded display.")
1259 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1260 "*List of functions used for sorting threads in the summary buffer.
1261 By default, threads are sorted by article number.
1263 Each function takes two threads and return non-nil if the first thread
1264 should be sorted before the other. If you use more than one function,
1265 the primary sort function should be the last. You should probably
1266 always include `gnus-thread-sort-by-number' in the list of sorting
1267 functions -- preferably first.
1269 Ready-mady functions include `gnus-thread-sort-by-number',
1270 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1271 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1272 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1274 (defvar gnus-thread-score-function '+
1275 "*Function used for calculating the total score of a thread.
1277 The function is called with the scores of the article and each
1278 subthread and should then return the score of the thread.
1280 Some functions you can use are `+', `max', or `min'.")
1282 (defvar gnus-summary-expunge-below nil
1283 "All articles that have a score less than this variable will be expunged.")
1285 (defvar gnus-thread-expunge-below nil
1286 "All threads that have a total score less than this variable will be expunged.
1287 See `gnus-thread-score-function' for en explanation of what a
1288 \"thread score\" is.")
1290 (defvar gnus-auto-subscribed-groups
1291 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1292 "*All new groups that match this regexp will be subscribed automatically.
1293 Note that this variable only deals with new groups. It has no effect
1294 whatsoever on old groups.")
1296 (defvar gnus-options-subscribe nil
1297 "*All new groups matching this regexp will be subscribed unconditionally.
1298 Note that this variable deals only with new newsgroups. This variable
1299 does not affect old newsgroups.")
1301 (defvar gnus-options-not-subscribe nil
1302 "*All new groups matching this regexp will be ignored.
1303 Note that this variable deals only with new newsgroups. This variable
1304 does not affect old (already subscribed) newsgroups.")
1306 (defvar gnus-auto-expirable-newsgroups nil
1307 "*Groups in which to automatically mark read articles as expirable.
1308 If non-nil, this should be a regexp that should match all groups in
1309 which to perform auto-expiry. This only makes sense for mail groups.")
1311 (defvar gnus-total-expirable-newsgroups nil
1312 "*Groups in which to perform expiry of all read articles.
1313 Use with extreme caution. All groups that match this regexp will be
1314 expiring - which means that all read articles will be deleted after
1315 (say) one week. (This only goes for mail groups and the like, of
1318 (defvar gnus-group-uncollapsed-levels 1
1319 "Number of group name elements to leave alone when making a short group name.")
1321 (defvar gnus-hidden-properties '(invisible t intangible t)
1322 "Property list to use for hiding text.")
1324 (defvar gnus-modtime-botch nil
1325 "*Non-nil means .newsrc should be deleted prior to save.
1326 Its use is due to the bogus appearance that .newsrc was modified on
1331 (defvar gnus-group-mode-hook nil
1332 "*A hook for Gnus group mode.")
1334 (defvar gnus-summary-mode-hook nil
1335 "*A hook for Gnus summary mode.
1336 This hook is run before any variables are set in the summary buffer.")
1338 (defvar gnus-article-mode-hook nil
1339 "*A hook for Gnus article mode.")
1341 (defvar gnus-summary-prepare-exit-hook nil
1342 "*A hook called when preparing to exit from the summary buffer.
1343 It calls `gnus-summary-expire-articles' by default.")
1344 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1346 (defvar gnus-summary-exit-hook nil
1347 "*A hook called on exit from the summary buffer.")
1349 (defvar gnus-group-catchup-group-hook nil
1350 "*A hook run when catching up a group from the group buffer.")
1352 (defvar gnus-open-server-hook nil
1353 "*A hook called just before opening connection to the news server.")
1355 (defvar gnus-load-hook nil
1356 "*A hook run while Gnus is loaded.")
1358 (defvar gnus-startup-hook nil
1359 "*A hook called at startup.
1360 This hook is called after Gnus is connected to the NNTP server.")
1362 (defvar gnus-get-new-news-hook nil
1363 "*A hook run just before Gnus checks for new news.")
1365 (defvar gnus-after-getting-new-news-hook nil
1366 "*A hook run after Gnus checks for new news.")
1368 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1369 "*A function that is called to generate the group buffer.
1370 The function is called with three arguments: The first is a number;
1371 all group with a level less or equal to that number should be listed,
1372 if the second is non-nil, empty groups should also be displayed. If
1373 the third is non-nil, it is a number. No groups with a level lower
1374 than this number should be displayed.
1376 The only current function implemented is `gnus-group-prepare-flat'.")
1378 (defvar gnus-group-prepare-hook nil
1379 "*A hook called after the group buffer has been generated.
1380 If you want to modify the group buffer, you can use this hook.")
1382 (defvar gnus-summary-prepare-hook nil
1383 "*A hook called after the summary buffer has been generated.
1384 If you want to modify the summary buffer, you can use this hook.")
1386 (defvar gnus-summary-generate-hook nil
1387 "*A hook run just before generating the summary buffer.
1388 This hook is commonly used to customize threading variables and the
1391 (defvar gnus-article-prepare-hook nil
1392 "*A hook called after an article has been prepared in the article buffer.
1393 If you want to run a special decoding program like nkf, use this hook.")
1395 ;(defvar gnus-article-display-hook nil
1396 ; "*A hook called after the article is displayed in the article buffer.
1397 ;The hook is designed to change the contents of the article
1398 ;buffer. Typical functions that this hook may contain are
1399 ;`gnus-article-hide-headers' (hide selected headers),
1400 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1401 ;`gnus-article-hide-signature' (hide signature) and
1402 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1403 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1404 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1405 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1407 (defvar gnus-article-x-face-command
1408 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1409 "String or function to be executed to display an X-Face header.
1410 If it is a string, the command will be executed in a sub-shell
1411 asynchronously. The compressed face will be piped to this command.")
1413 (defvar gnus-article-x-face-too-ugly nil
1414 "Regexp matching posters whose face shouldn't be shown automatically.")
1416 (defvar gnus-select-group-hook nil
1417 "*A hook called when a newsgroup is selected.
1419 If you'd like to simplify subjects like the
1420 `gnus-summary-next-same-subject' command does, you can use the
1423 (setq gnus-select-group-hook
1426 (mapcar (lambda (header)
1427 (mail-header-set-subject
1429 (gnus-simplify-subject
1430 (mail-header-subject header) 're-only)))
1431 gnus-newsgroup-headers))))")
1433 (defvar gnus-select-article-hook nil
1434 "*A hook called when an article is selected.")
1436 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1437 "*A hook called to apply kill files to a group.
1438 This hook is intended to apply a kill file to the selected newsgroup.
1439 The function `gnus-apply-kill-file' is called by default.
1441 Since a general kill file is too heavy to use only for a few
1442 newsgroups, I recommend you to use a lighter hook function. For
1443 example, if you'd like to apply a kill file to articles which contains
1444 a string `rmgroup' in subject in newsgroup `control', you can use the
1447 (setq gnus-apply-kill-hook
1450 (cond ((string-match \"control\" gnus-newsgroup-name)
1451 (gnus-kill \"Subject\" \"rmgroup\")
1452 (gnus-expunge \"X\"))))))")
1454 (defvar gnus-visual-mark-article-hook
1455 (list 'gnus-highlight-selected-summary)
1456 "*Hook run after selecting an article in the summary buffer.
1457 It is meant to be used for highlighting the article in some way. It
1458 is not run if `gnus-visual' is nil.")
1460 (defvar gnus-parse-headers-hook nil
1461 "*A hook called before parsing the headers.")
1463 (defvar gnus-exit-group-hook nil
1464 "*A hook called when exiting (not quitting) summary mode.")
1466 (defvar gnus-suspend-gnus-hook nil
1467 "*A hook called when suspending (not exiting) Gnus.")
1469 (defvar gnus-exit-gnus-hook nil
1470 "*A hook called when exiting Gnus.")
1472 (defvar gnus-after-exiting-gnus-hook nil
1473 "*A hook called after exiting Gnus.")
1475 (defvar gnus-save-newsrc-hook nil
1476 "*A hook called before saving any of the newsrc files.")
1478 (defvar gnus-save-quick-newsrc-hook nil
1479 "*A hook called just before saving the quick newsrc file.
1480 Can be used to turn version control on or off.")
1482 (defvar gnus-save-standard-newsrc-hook nil
1483 "*A hook called just before saving the standard newsrc file.
1484 Can be used to turn version control on or off.")
1486 (defvar gnus-summary-update-hook
1487 (list 'gnus-summary-highlight-line)
1488 "*A hook called when a summary line is changed.
1489 The hook will not be called if `gnus-visual' is nil.
1491 The default function `gnus-summary-highlight-line' will
1492 highlight the line according to the `gnus-summary-highlight'
1495 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1496 "*A hook called when a group line is changed.
1497 The hook will not be called if `gnus-visual' is nil.
1499 The default function `gnus-group-highlight-line' will
1500 highlight the line according to the `gnus-group-highlight'
1503 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1504 "*A hook called when an article is selected for the first time.
1505 The hook is intended to mark an article as read (or unread)
1506 automatically when it is selected.")
1508 (defvar gnus-group-change-level-function nil
1509 "Function run when a group level is changed.
1510 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1512 ;; Remove any hilit infestation.
1513 (add-hook 'gnus-startup-hook
1515 (remove-hook 'gnus-summary-prepare-hook
1516 'hilit-rehighlight-buffer-quietly)
1517 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1518 (setq gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read))
1519 (remove-hook 'gnus-article-prepare-hook
1520 'hilit-rehighlight-buffer-quietly)))
1523 ;; Internal variables
1525 (defvar gnus-server-alist nil
1526 "List of available servers.")
1528 (defvar gnus-group-indentation-function nil)
1530 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1532 (defvar gnus-goto-missing-group-function nil)
1534 (defvar gnus-override-subscribe-method nil)
1536 (defvar gnus-group-goto-next-group-function nil
1537 "Function to override finding the next group after listing groups.")
1539 (defconst gnus-article-mark-lists
1540 '((marked . tick) (replied . reply)
1541 (expirable . expire) (killed . killed)
1542 (bookmarks . bookmark) (dormant . dormant)
1543 (scored . score) (saved . save)
1547 ;; Avoid highlighting in kill files.
1548 (defvar gnus-summary-inhibit-highlight nil)
1549 (defvar gnus-newsgroup-selected-overlay nil)
1551 (defvar gnus-inhibit-hiding nil)
1552 (defvar gnus-group-indentation "")
1553 (defvar gnus-inhibit-limiting nil)
1554 (defvar gnus-created-frames nil)
1556 (defvar gnus-article-mode-map nil)
1557 (defvar gnus-dribble-buffer nil)
1558 (defvar gnus-headers-retrieved-by nil)
1559 (defvar gnus-article-reply nil)
1560 (defvar gnus-override-method nil)
1561 (defvar gnus-article-check-size nil)
1563 (defvar gnus-current-score-file nil)
1564 (defvar gnus-newsgroup-adaptive-score-file nil)
1565 (defvar gnus-scores-exclude-files nil)
1567 (defvar gnus-opened-servers nil)
1569 (defvar gnus-current-move-group nil)
1571 (defvar gnus-newsgroup-dependencies nil)
1572 (defvar gnus-newsgroup-async nil)
1573 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1575 (defvar gnus-newsgroup-adaptive nil)
1577 (defvar gnus-summary-display-table nil)
1578 (defvar gnus-summary-display-article-function nil)
1580 (defvar gnus-summary-highlight-line-function nil
1581 "Function called after highlighting a summary line.")
1583 (defvar gnus-group-line-format-alist
1584 `((?M gnus-tmp-marked-mark ?c)
1585 (?S gnus-tmp-subscribed ?c)
1586 (?L gnus-tmp-level ?d)
1587 (?N (cond ((eq number t) "*" )
1591 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1592 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1594 (?R gnus-tmp-number-of-read ?s)
1595 (?t gnus-tmp-number-total ?d)
1596 (?y gnus-tmp-number-of-unread ?s)
1597 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1598 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1599 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1600 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1601 (?g gnus-tmp-group ?s)
1602 (?G gnus-tmp-qualified-group ?s)
1603 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1604 (?D gnus-tmp-newsgroup-description ?s)
1605 (?o gnus-tmp-moderated ?c)
1606 (?O gnus-tmp-moderated-string ?s)
1607 (?p gnus-tmp-process-marked ?c)
1608 (?s gnus-tmp-news-server ?s)
1609 (?n gnus-tmp-news-method ?s)
1610 (?P gnus-group-indentation ?s)
1611 (?l gnus-tmp-grouplens ?s)
1612 (?z gnus-tmp-news-method-string ?s)
1613 (?u gnus-tmp-user-defined ?s)))
1615 (defvar gnus-summary-line-format-alist
1616 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1617 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1618 (?s gnus-tmp-subject-or-nil ?s)
1619 (?n gnus-tmp-name ?s)
1620 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1622 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1624 (?F gnus-tmp-from ?s)
1625 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1626 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1627 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1628 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1629 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1630 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1631 (?L gnus-tmp-lines ?d)
1632 (?I gnus-tmp-indentation ?s)
1633 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1634 (?R gnus-tmp-replied ?c)
1635 (?\[ gnus-tmp-opening-bracket ?c)
1636 (?\] gnus-tmp-closing-bracket ?c)
1637 (?\> (make-string gnus-tmp-level ? ) ?s)
1638 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1639 (?i gnus-tmp-score ?d)
1640 (?z gnus-tmp-score-char ?c)
1641 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1642 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1643 (?U gnus-tmp-unread ?c)
1644 (?t (gnus-summary-number-of-articles-in-thread
1645 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1647 (?e (gnus-summary-number-of-articles-in-thread
1648 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1650 (?u gnus-tmp-user-defined ?s))
1651 "An alist of format specifications that can appear in summary lines,
1652 and what variables they correspond with, along with the type of the
1653 variable (string, integer, character, etc).")
1655 (defvar gnus-summary-dummy-line-format-alist
1656 `((?S gnus-tmp-subject ?s)
1657 (?N gnus-tmp-number ?d)
1658 (?u gnus-tmp-user-defined ?s)))
1660 (defvar gnus-summary-mode-line-format-alist
1661 `((?G gnus-tmp-group-name ?s)
1662 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1663 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1664 (?A gnus-tmp-article-number ?d)
1665 (?Z gnus-tmp-unread-and-unselected ?s)
1666 (?V gnus-version ?s)
1667 (?U gnus-tmp-unread ?d)
1668 (?S gnus-tmp-subject ?s)
1669 (?e gnus-tmp-unselected ?d)
1670 (?u gnus-tmp-user-defined ?s)
1671 (?d (length gnus-newsgroup-dormant) ?d)
1672 (?t (length gnus-newsgroup-marked) ?d)
1673 (?r (length gnus-newsgroup-reads) ?d)
1674 (?E gnus-newsgroup-expunged-tally ?d)
1675 (?s (gnus-current-score-file-nondirectory) ?s)))
1677 (defvar gnus-article-mode-line-format-alist
1678 gnus-summary-mode-line-format-alist)
1680 (defvar gnus-group-mode-line-format-alist
1681 `((?S gnus-tmp-news-server ?s)
1682 (?M gnus-tmp-news-method ?s)
1683 (?u gnus-tmp-user-defined ?s)))
1685 (defvar gnus-have-read-active-file nil)
1687 (defconst gnus-maintainer
1688 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1689 "The mail address of the Gnus maintainers.")
1691 (defconst gnus-version "September Gnus v0.61"
1692 "Version number for this version of Gnus.")
1694 (defvar gnus-info-nodes
1695 '((gnus-group-mode "(gnus)The Group Buffer")
1696 (gnus-summary-mode "(gnus)The Summary Buffer")
1697 (gnus-article-mode "(gnus)The Article Buffer"))
1698 "Assoc list of major modes and related Info nodes.")
1700 (defvar gnus-group-buffer "*Group*")
1701 (defvar gnus-summary-buffer "*Summary*")
1702 (defvar gnus-article-buffer "*Article*")
1703 (defvar gnus-server-buffer "*Server*")
1705 (defvar gnus-work-buffer " *gnus work*")
1707 (defvar gnus-original-article-buffer " *Original Article*")
1708 (defvar gnus-original-article nil)
1710 (defvar gnus-buffer-list nil
1711 "Gnus buffers that should be killed on exit.")
1713 (defvar gnus-slave nil
1714 "Whether this Gnus is a slave or not.")
1716 (defvar gnus-variable-list
1717 '(gnus-newsrc-options gnus-newsrc-options-n
1718 gnus-newsrc-last-checked-date
1719 gnus-newsrc-alist gnus-server-alist
1720 gnus-killed-list gnus-zombie-list
1721 gnus-topic-topology gnus-topic-alist
1723 "Gnus variables saved in the quick startup file.")
1725 (defvar gnus-newsrc-options nil
1726 "Options line in the .newsrc file.")
1728 (defvar gnus-newsrc-options-n nil
1729 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1731 (defvar gnus-newsrc-last-checked-date nil
1732 "Date Gnus last asked server for new newsgroups.")
1734 (defvar gnus-topic-topology nil
1735 "The complete topic hierarchy.")
1737 (defvar gnus-topic-alist nil
1738 "The complete topic-group alist.")
1740 (defvar gnus-newsrc-alist nil
1741 "Assoc list of read articles.
1742 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1744 (defvar gnus-newsrc-hashtb nil
1745 "Hashtable of gnus-newsrc-alist.")
1747 (defvar gnus-killed-list nil
1748 "List of killed newsgroups.")
1750 (defvar gnus-killed-hashtb nil
1751 "Hash table equivalent of gnus-killed-list.")
1753 (defvar gnus-zombie-list nil
1754 "List of almost dead newsgroups.")
1756 (defvar gnus-description-hashtb nil
1757 "Descriptions of newsgroups.")
1759 (defvar gnus-list-of-killed-groups nil
1760 "List of newsgroups that have recently been killed by the user.")
1762 (defvar gnus-active-hashtb nil
1763 "Hashtable of active articles.")
1765 (defvar gnus-moderated-list nil
1766 "List of moderated newsgroups.")
1768 (defvar gnus-group-marked nil)
1770 (defvar gnus-current-startup-file nil
1771 "Startup file for the current host.")
1773 (defvar gnus-last-search-regexp nil
1774 "Default regexp for article search command.")
1776 (defvar gnus-last-shell-command nil
1777 "Default shell command on article.")
1779 (defvar gnus-current-select-method nil
1780 "The current method for selecting a newsgroup.")
1782 (defvar gnus-group-list-mode nil)
1784 (defvar gnus-article-internal-prepare-hook nil)
1786 (defvar gnus-newsgroup-name nil)
1787 (defvar gnus-newsgroup-begin nil)
1788 (defvar gnus-newsgroup-end nil)
1789 (defvar gnus-newsgroup-last-rmail nil)
1790 (defvar gnus-newsgroup-last-mail nil)
1791 (defvar gnus-newsgroup-last-folder nil)
1792 (defvar gnus-newsgroup-last-file nil)
1793 (defvar gnus-newsgroup-auto-expire nil)
1794 (defvar gnus-newsgroup-active nil)
1796 (defvar gnus-newsgroup-data nil)
1797 (defvar gnus-newsgroup-data-reverse nil)
1798 (defvar gnus-newsgroup-limit nil)
1799 (defvar gnus-newsgroup-limits nil)
1801 (defvar gnus-newsgroup-unreads nil
1802 "List of unread articles in the current newsgroup.")
1804 (defvar gnus-newsgroup-unselected nil
1805 "List of unselected unread articles in the current newsgroup.")
1807 (defvar gnus-newsgroup-reads nil
1808 "Alist of read articles and article marks in the current newsgroup.")
1810 (defvar gnus-newsgroup-expunged-tally nil)
1812 (defvar gnus-newsgroup-marked nil
1813 "List of ticked articles in the current newsgroup (a subset of unread art).")
1815 (defvar gnus-newsgroup-killed nil
1816 "List of ranges of articles that have been through the scoring process.")
1818 (defvar gnus-newsgroup-cached nil
1819 "List of articles that come from the article cache.")
1821 (defvar gnus-newsgroup-saved nil
1822 "List of articles that have been saved.")
1824 (defvar gnus-newsgroup-kill-headers nil)
1826 (defvar gnus-newsgroup-replied nil
1827 "List of articles that have been replied to in the current newsgroup.")
1829 (defvar gnus-newsgroup-expirable nil
1830 "List of articles in the current newsgroup that can be expired.")
1832 (defvar gnus-newsgroup-processable nil
1833 "List of articles in the current newsgroup that can be processed.")
1835 (defvar gnus-newsgroup-bookmarks nil
1836 "List of articles in the current newsgroup that have bookmarks.")
1838 (defvar gnus-newsgroup-dormant nil
1839 "List of dormant articles in the current newsgroup.")
1841 (defvar gnus-newsgroup-scored nil
1842 "List of scored articles in the current newsgroup.")
1844 (defvar gnus-newsgroup-headers nil
1845 "List of article headers in the current newsgroup.")
1847 (defvar gnus-newsgroup-threads nil)
1849 (defvar gnus-newsgroup-prepared nil
1850 "Whether the current group has been prepared properly.")
1852 (defvar gnus-newsgroup-ancient nil
1853 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1855 (defvar gnus-newsgroup-sparse nil)
1857 (defvar gnus-current-article nil)
1858 (defvar gnus-article-current nil)
1859 (defvar gnus-current-headers nil)
1860 (defvar gnus-have-all-headers nil)
1861 (defvar gnus-last-article nil)
1862 (defvar gnus-newsgroup-history nil)
1863 (defvar gnus-current-kill-article nil)
1865 ;; Save window configuration.
1866 (defvar gnus-prev-winconf nil)
1868 (defvar gnus-summary-mark-positions nil)
1869 (defvar gnus-group-mark-positions nil)
1871 (defvar gnus-reffed-article-number nil)
1873 ;;; Let the byte-compiler know that we know about this variable.
1874 (defvar rmail-default-rmail-file)
1876 (defvar gnus-cache-removable-articles nil)
1878 (defvar gnus-dead-summary nil)
1880 (defconst gnus-summary-local-variables
1881 '(gnus-newsgroup-name
1882 gnus-newsgroup-begin gnus-newsgroup-end
1883 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1884 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1885 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1886 gnus-newsgroup-unselected gnus-newsgroup-marked
1887 gnus-newsgroup-reads gnus-newsgroup-saved
1888 gnus-newsgroup-replied gnus-newsgroup-expirable
1889 gnus-newsgroup-processable gnus-newsgroup-killed
1890 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1891 gnus-newsgroup-headers gnus-newsgroup-threads
1892 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1893 gnus-current-article gnus-current-headers gnus-have-all-headers
1894 gnus-last-article gnus-article-internal-prepare-hook
1895 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1896 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1897 gnus-newsgroup-async
1898 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1899 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1900 gnus-newsgroup-history gnus-newsgroup-ancient
1901 gnus-newsgroup-sparse
1902 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1903 gnus-newsgroup-adaptive-score-file
1904 (gnus-newsgroup-expunged-tally . 0)
1905 gnus-cache-removable-articles gnus-newsgroup-cached
1906 gnus-newsgroup-data gnus-newsgroup-data-reverse
1907 gnus-newsgroup-limit gnus-newsgroup-limits)
1908 "Variables that are buffer-local to the summary buffers.")
1910 (defconst gnus-bug-message
1911 "Sending a bug report to the Gnus Towers.
1912 ========================================
1914 The buffer below is a mail buffer. When you press `C-c C-c', it will
1915 be sent to the Gnus Bug Exterminators.
1917 At the bottom of the buffer you'll see lots of variable settings.
1918 Please do not delete those. They will tell the Bug People what your
1919 environment is, so that it will be easier to locate the bugs.
1921 If you have found a bug that makes Emacs go \"beep\", set
1922 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1923 and include the backtrace in your bug report.
1925 Please describe the bug in annoying, painstaking detail.
1927 Thank you for your help in stamping out bugs.
1930 ;;; End of variables.
1932 ;; Define some autoload functions Gnus might use.
1935 ;; This little mapcar goes through the list below and marks the
1936 ;; symbols in question as autoloaded functions.
1939 (let ((interactive (nth 1 (memq ':interactive package))))
1943 (when (consp function)
1944 (setq keymap (car (memq 'keymap function)))
1945 (setq function (car function)))
1946 (autoload function (car package) nil interactive keymap)))
1947 (if (eq (nth 1 package) ':interactive)
1950 '(("metamail" metamail-buffer)
1951 ("info" Info-goto-node)
1952 ("hexl" hexl-hex-string-to-integer)
1953 ("pp" pp pp-to-string pp-eval-expression)
1954 ("mail-extr" mail-extract-address-components)
1955 ("nnmail" nnmail-split-fancy nnmail-article-group)
1956 ("nnvirtual" nnvirtual-catchup-group)
1957 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1958 timezone-make-sortable-date timezone-make-time-string)
1959 ("sendmail" mail-position-on-field mail-setup)
1960 ("rmailout" rmail-output)
1961 ("rnewspost" news-mail-other-window news-reply-yank-original
1962 news-caesar-buffer-body)
1963 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1965 ("gnus-soup" :interactive t
1966 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1967 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1968 ("nnsoup" nnsoup-pack-replies)
1969 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1970 gnus-Folder-save-name gnus-folder-save-name)
1971 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1972 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1973 gnus-server-make-menu-bar gnus-article-make-menu-bar
1974 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1975 gnus-summary-highlight-line gnus-carpal-setup-buffer
1976 gnus-group-highlight-line
1977 gnus-article-add-button gnus-insert-next-page-button
1978 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1979 ("gnus-vis" :interactive t
1980 gnus-article-push-button gnus-article-press-button
1981 gnus-article-highlight gnus-article-highlight-some
1982 gnus-article-highlight-headers gnus-article-highlight-signature
1983 gnus-article-add-buttons gnus-article-add-buttons-to-head
1984 gnus-article-next-button gnus-article-prev-button)
1985 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1986 gnus-demon-add-disconnection gnus-demon-add-handler
1987 gnus-demon-remove-handler)
1988 ("gnus-demon" :interactive t
1989 gnus-demon-init gnus-demon-cancel)
1990 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
1991 gnus-tree-open gnus-tree-close)
1992 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
1993 gnus-nocem-unwanted-article-p)
1994 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
1995 ("gnus-srvr" gnus-browse-foreign-server)
1996 ("gnus-cite" :interactive t
1997 gnus-article-highlight-citation gnus-article-hide-citation-maybe
1998 gnus-article-hide-citation gnus-article-fill-cited-article)
1999 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2000 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2001 gnus-execute gnus-expunge)
2002 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2003 gnus-cache-possibly-remove-articles gnus-cache-request-article
2004 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2005 gnus-cache-enter-remove-article gnus-cached-article-p
2006 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2007 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2008 gnus-cache-remove-article)
2009 ("gnus-score" :interactive t
2010 gnus-summary-increase-score gnus-summary-lower-score
2011 gnus-score-flush-cache gnus-score-close
2012 gnus-score-raise-same-subject-and-select
2013 gnus-score-raise-same-subject gnus-score-default
2014 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2015 gnus-score-lower-same-subject gnus-score-lower-thread
2016 gnus-possibly-score-headers)
2018 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2019 gnus-current-score-file-nondirectory gnus-score-adaptive
2020 gnus-score-find-trace gnus-score-file-name)
2021 ("gnus-edit" :interactive t gnus-score-customize)
2022 ("gnus-topic" :interactive t gnus-topic-mode)
2023 ("gnus-topic" gnus-topic-remove-group)
2024 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2025 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2026 ("gnus-uu" :interactive t
2027 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2028 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2029 gnus-uu-mark-by-regexp gnus-uu-mark-all
2030 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2031 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2032 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2033 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2034 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2035 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2036 gnus-uu-decode-binhex-view)
2037 ("gnus-msg" (gnus-summary-send-map keymap)
2038 gnus-mail-yank-original gnus-mail-send-and-exit
2039 gnus-sendmail-setup-mail gnus-article-mail
2040 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2041 ("gnus-msg" :interactive t
2042 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2043 gnus-summary-followup gnus-summary-followup-with-original
2044 gnus-summary-followup-and-reply
2045 gnus-summary-followup-and-reply-with-original
2046 gnus-summary-cancel-article gnus-summary-supersede-article
2047 gnus-post-news gnus-inews-news gnus-cancel-news
2048 gnus-summary-reply gnus-summary-reply-with-original
2049 gnus-summary-mail-forward gnus-summary-mail-other-window
2051 ("gnus-picon" :interactive t gnus-article-display-picons
2052 gnus-group-display-picons gnus-picons-article-display-x-face)
2053 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2054 gnus-grouplens-mode)
2055 ("gnus-vm" gnus-vm-mail-setup)
2056 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2057 gnus-summary-save-article-vm gnus-yank-article))))
2061 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2062 ;; If you want the cursor to go somewhere else, set these two
2063 ;; functions in some startup hook to whatever you want.
2064 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2065 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2067 ;;; Various macros and substs.
2069 (defun gnus-header-from (header)
2070 (mail-header-from header))
2072 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2073 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2074 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2075 `(let ((,tempvar (selected-window)))
2078 (pop-to-buffer ,buffer)
2080 (select-window ,tempvar)))))
2082 (defmacro gnus-gethash (string hashtable)
2083 "Get hash value of STRING in HASHTABLE."
2084 `(symbol-value (intern-soft ,string ,hashtable)))
2086 (defmacro gnus-sethash (string value hashtable)
2087 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2088 `(set (intern ,string ,hashtable) ,value))
2090 (defmacro gnus-intern-safe (string hashtable)
2091 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2092 `(let ((symbol (intern ,string ,hashtable)))
2097 (defmacro gnus-group-unread (group)
2098 "Get the currently computed number of unread articles in GROUP."
2099 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2101 (defmacro gnus-group-entry (group)
2102 "Get the newsrc entry for GROUP."
2103 `(gnus-gethash ,group gnus-newsrc-hashtb))
2105 (defmacro gnus-active (group)
2106 "Get active info on GROUP."
2107 `(gnus-gethash ,group gnus-active-hashtb))
2109 (defmacro gnus-set-active (group active)
2110 "Set GROUP's active info."
2111 `(gnus-sethash ,group ,active gnus-active-hashtb))
2113 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2114 ;; function `substring' might cut on a middle of multi-octet
2116 (defun gnus-truncate-string (str width)
2117 (substring str 0 width))
2119 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2120 ;; to limit the length of a string. This function is necessary since
2121 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2122 (defsubst gnus-limit-string (str width)
2123 (if (> (length str) width)
2124 (substring str 0 width)
2127 (defsubst gnus-simplify-subject-re (subject)
2128 "Remove \"Re:\" from subject lines."
2129 (if (string-match "^[Rr][Ee]: *" subject)
2130 (substring subject (match-end 0))
2133 (defsubst gnus-functionp (form)
2134 "Return non-nil if FORM is funcallable."
2135 (or (and (symbolp form) (fboundp form))
2136 (and (listp form) (eq (car form) 'lambda))))
2138 (defsubst gnus-goto-char (point)
2139 (and point (goto-char point)))
2141 (defmacro gnus-buffer-exists-p (buffer)
2142 `(let ((buffer ,buffer))
2144 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2147 (defmacro gnus-kill-buffer (buffer)
2148 `(let ((buf ,buffer))
2149 (if (gnus-buffer-exists-p buf)
2150 (kill-buffer buf))))
2152 (defsubst gnus-point-at-bol ()
2153 "Return point at the beginning of the line."
2160 (defsubst gnus-point-at-eol ()
2161 "Return point at the end of the line."
2168 (defun gnus-alive-p ()
2169 "Say whether Gnus is running or not."
2170 (and gnus-group-buffer
2171 (get-buffer gnus-group-buffer)))
2173 ;; Delete the current line (and the next N lines.);
2174 (defmacro gnus-delete-line (&optional n)
2175 `(delete-region (progn (beginning-of-line) (point))
2176 (progn (forward-line ,(or n 1)) (point))))
2178 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2179 (defvar gnus-init-inhibit nil)
2180 (defun gnus-read-init-file (&optional inhibit-next)
2181 (if gnus-init-inhibit
2182 (setq gnus-init-inhibit nil)
2183 (setq gnus-init-inhibit inhibit-next)
2185 (or (and (file-exists-p gnus-init-file)
2186 ;; Don't try to load a directory.
2187 (not (file-directory-p gnus-init-file)))
2188 (file-exists-p (concat gnus-init-file ".el"))
2189 (file-exists-p (concat gnus-init-file ".elc")))
2191 (load gnus-init-file nil t)
2193 (error "Error in %s: %s" gnus-init-file var))))))
2195 ;; Info access macros.
2197 (defmacro gnus-info-group (info)
2199 (defmacro gnus-info-rank (info)
2201 (defmacro gnus-info-read (info)
2203 (defmacro gnus-info-marks (info)
2205 (defmacro gnus-info-method (info)
2207 (defmacro gnus-info-params (info)
2210 (defmacro gnus-info-level (info)
2211 `(let ((rank (gnus-info-rank ,info)))
2215 (defmacro gnus-info-score (info)
2216 `(let ((rank (gnus-info-rank ,info)))
2217 (or (and (consp rank) (cdr rank)) 0)))
2219 (defmacro gnus-info-set-group (info group)
2220 `(setcar ,info ,group))
2221 (defmacro gnus-info-set-rank (info rank)
2222 `(setcar (nthcdr 1 ,info) ,rank))
2223 (defmacro gnus-info-set-read (info read)
2224 `(setcar (nthcdr 2 ,info) ,read))
2225 (defmacro gnus-info-set-marks (info marks)
2226 `(setcar (nthcdr 3 ,info) ,marks))
2227 (defmacro gnus-info-set-method (info method)
2228 `(setcar (nthcdr 4 ,info) ,method))
2229 (defmacro gnus-info-set-params (info params)
2230 `(setcar (nthcdr 5 ,info) ,params))
2232 (defmacro gnus-info-set-level (info level)
2233 `(let ((rank (cdr ,info)))
2234 (if (consp (car rank))
2235 (setcar (car rank) ,level)
2236 (setcar rank ,level))))
2237 (defmacro gnus-info-set-score (info score)
2238 `(let ((rank (cdr ,info)))
2239 (if (consp (car rank))
2240 (setcdr (car rank) ,score)
2241 (setcar rank (cons (car rank) ,score)))))
2243 (defmacro gnus-get-info (group)
2244 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2246 (defun gnus-byte-code (func)
2247 "Return a form that can be `eval'ed based on FUNC."
2248 (let ((fval (symbol-function func)))
2249 (if (byte-code-function-p fval)
2250 (let ((flist (append fval nil)))
2251 (setcar flist 'byte-code)
2253 (cons 'progn (cddr fval)))))
2255 ;;; Load the compatability functions.
2265 (defvar gnus-shutdown-alist nil)
2267 (defun gnus-add-shutdown (function &rest symbols)
2268 "Run FUNCTION whenever one of SYMBOLS is shut down."
2269 (push (cons function symbols) gnus-shutdown-alist))
2271 (defun gnus-shutdown (symbol)
2272 "Shut down everything that waits for SYMBOL."
2273 (let ((alist gnus-shutdown-alist)
2275 (while (setq entry (pop alist))
2276 (when (memq symbol (cdr entry))
2277 (funcall (car entry))))))
2281 ;; Format specs. The chunks below are the machine-generated forms
2282 ;; that are to be evaled as the result of the default format strings.
2283 ;; We write them in here to get them byte-compiled. That way the
2284 ;; default actions will be quite fast, while still retaining the full
2285 ;; flexibility of the user-defined format specs.
2287 ;; First we have lots of dummy defvars to let the compiler know these
2288 ;; are really dynamic variables.
2290 (defvar gnus-tmp-unread)
2291 (defvar gnus-tmp-replied)
2292 (defvar gnus-tmp-score-char)
2293 (defvar gnus-tmp-indentation)
2294 (defvar gnus-tmp-opening-bracket)
2295 (defvar gnus-tmp-lines)
2296 (defvar gnus-tmp-name)
2297 (defvar gnus-tmp-closing-bracket)
2298 (defvar gnus-tmp-subject-or-nil)
2299 (defvar gnus-tmp-subject)
2300 (defvar gnus-tmp-marked)
2301 (defvar gnus-tmp-marked-mark)
2302 (defvar gnus-tmp-subscribed)
2303 (defvar gnus-tmp-process-marked)
2304 (defvar gnus-tmp-number-of-unread)
2305 (defvar gnus-tmp-group-name)
2306 (defvar gnus-tmp-group)
2307 (defvar gnus-tmp-article-number)
2308 (defvar gnus-tmp-unread-and-unselected)
2309 (defvar gnus-tmp-news-method)
2310 (defvar gnus-tmp-news-server)
2311 (defvar gnus-tmp-article-number)
2312 (defvar gnus-mouse-face)
2313 (defvar gnus-mouse-face-prop)
2315 (defun gnus-summary-line-format-spec ()
2316 (insert gnus-tmp-unread gnus-tmp-replied
2317 gnus-tmp-score-char gnus-tmp-indentation)
2322 gnus-tmp-opening-bracket
2323 (format "%4d: %-20s"
2325 (if (> (length gnus-tmp-name) 20)
2326 (substring gnus-tmp-name 0 20)
2328 gnus-tmp-closing-bracket)
2330 gnus-mouse-face-prop gnus-mouse-face)
2331 (insert " " gnus-tmp-subject-or-nil "\n"))
2333 (defvar gnus-summary-line-format-spec
2334 (gnus-byte-code 'gnus-summary-line-format-spec))
2336 (defun gnus-summary-dummy-line-format-spec ()
2343 gnus-mouse-face-prop gnus-mouse-face)
2344 (insert " " gnus-tmp-subject "\n"))
2346 (defvar gnus-summary-dummy-line-format-spec
2347 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2349 (defun gnus-group-line-format-spec ()
2350 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2351 gnus-tmp-process-marked
2352 gnus-group-indentation
2353 (format "%5s: " gnus-tmp-number-of-unread))
2357 (insert gnus-tmp-group "\n")
2359 gnus-mouse-face-prop gnus-mouse-face))
2360 (defvar gnus-group-line-format-spec
2361 (gnus-byte-code 'gnus-group-line-format-spec))
2363 (defvar gnus-format-specs
2364 `((version . ,emacs-version)
2365 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2366 (summary-dummy ,gnus-summary-dummy-line-format
2367 ,gnus-summary-dummy-line-format-spec)
2368 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2370 (defvar gnus-article-mode-line-format-spec nil)
2371 (defvar gnus-summary-mode-line-format-spec nil)
2372 (defvar gnus-group-mode-line-format-spec nil)
2374 ;;; Phew. All that gruft is over, fortunately.
2378 ;;; Gnus Utility Functions
2381 (defun gnus-extract-address-components (from)
2383 ;; First find the address - the thing with the @ in it. This may
2384 ;; not be accurate in mail addresses, but does the trick most of
2385 ;; the time in news messages.
2386 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2387 (setq address (substring from (match-beginning 0) (match-end 0))))
2388 ;; Then we check whether the "name <address>" format is used.
2390 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2391 ;; Linear white space is not required.
2392 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2393 (and (setq name (substring from 0 (match-beginning 0)))
2394 ;; Strip any quotes from the name.
2395 (string-match "\".*\"" name)
2396 (setq name (substring name 1 (1- (match-end 0))))))
2397 ;; If not, then "address (name)" is used.
2399 (and (string-match "(.+)" from)
2400 (setq name (substring from (1+ (match-beginning 0))
2401 (1- (match-end 0)))))
2402 (and (string-match "()" from)
2403 (setq name address))
2404 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2405 ;; XOVER might not support folded From headers.
2406 (and (string-match "(.*" from)
2407 (setq name (substring from (1+ (match-beginning 0))
2409 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2410 (list (or name from) (or address from))))
2412 (defun gnus-fetch-field (field)
2413 "Return the value of the header FIELD of current article."
2416 (let ((case-fold-search t))
2417 (nnheader-narrow-to-headers)
2418 (mail-fetch-field field)))))
2420 (defun gnus-goto-colon ()
2422 (search-forward ":" (gnus-point-at-eol) t))
2425 (defun gnus-update-format (var)
2426 "Update the format specification near point."
2431 ;; Find the end of the current word.
2432 (re-search-forward "[ \t\n]" nil t)
2434 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2435 (match-string 1)))))
2436 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2437 (match-string 1 var))))
2438 (entry (assq type gnus-format-specs))
2441 (setq gnus-format-specs (delq entry gnus-format-specs)))
2443 (intern (format "%s-spec" var))
2444 (gnus-parse-format (setq value (symbol-value (intern var)))
2445 (symbol-value (intern (format "%s-alist" var)))
2446 (not (string-match "mode" var))))
2447 (setq spec (symbol-value (intern (format "%s-spec" var))))
2448 (push (list type value spec) gnus-format-specs)
2450 (pop-to-buffer "*Gnus Format*")
2452 (lisp-interaction-mode)
2453 (insert (pp-to-string spec))))
2455 (defun gnus-update-format-specifications (&optional force)
2456 "Update all (necessary) format specifications."
2457 ;; Make the indentation array.
2458 (gnus-make-thread-indent-array)
2460 ;; See whether all the stored info needs to be flushed.
2462 (not (equal emacs-version
2463 (cdr (assq 'version gnus-format-specs)))))
2464 (setq gnus-format-specs nil))
2466 ;; Go through all the formats and see whether they need updating.
2467 (let ((types '(summary summary-dummy group
2468 summary-mode group-mode article-mode))
2469 new-format entry type val)
2470 (while (setq type (pop types))
2471 ;; Jump to the proper buffer to find out the value of
2472 ;; the variable, if possible. (It may be buffer-local.)
2474 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2476 (when (and (boundp buffer)
2477 (setq val (symbol-value buffer))
2479 (buffer-name (get-buffer val)))
2480 (set-buffer (get-buffer val)))
2481 (setq new-format (symbol-value
2482 (intern (format "gnus-%s-line-format" type))))))
2483 (setq entry (cdr (assq type gnus-format-specs)))
2485 (equal (car entry) new-format))
2486 ;; Use the old format.
2487 (set (intern (format "gnus-%s-line-format-spec" type))
2489 ;; This is a new format.
2491 (if (not (stringp new-format))
2492 ;; This is a function call or something.
2494 ;; This is a "real" format.
2498 (intern (format "gnus-%s-line-format-alist"
2499 (if (eq type 'article-mode)
2500 'summary-mode type))))
2501 (not (string-match "mode$" (symbol-name type))))))
2502 ;; Enter the new format spec into the list.
2505 (setcar (cdr entry) val)
2506 (setcar entry new-format))
2507 (push (list type new-format val) gnus-format-specs))
2508 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2510 (unless (assq 'version gnus-format-specs)
2511 (push (cons 'version emacs-version) gnus-format-specs))
2513 (gnus-update-group-mark-positions)
2514 (gnus-update-summary-mark-positions))
2516 (defun gnus-update-summary-mark-positions ()
2517 "Compute where the summary marks are to go."
2519 (let ((gnus-replied-mark 129)
2520 (gnus-score-below-mark 130)
2521 (gnus-score-over-mark 130)
2525 (gnus-set-work-buffer)
2526 (gnus-summary-insert-line
2527 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2528 (goto-char (point-min))
2529 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2531 (goto-char (point-min))
2532 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2534 (goto-char (point-min))
2535 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2537 (setq gnus-summary-mark-positions pos))))
2539 (defun gnus-update-group-mark-positions ()
2541 (let ((gnus-process-mark 128)
2542 (gnus-group-marked '("dummy.group")))
2543 (gnus-set-active "dummy.group" '(0 . 0))
2544 (gnus-set-work-buffer)
2545 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2546 (goto-char (point-min))
2547 (setq gnus-group-mark-positions
2548 (list (cons 'process (and (search-forward "\200" nil t)
2549 (- (point) 2))))))))
2551 (defvar gnus-mouse-face-0 'highlight)
2552 (defvar gnus-mouse-face-1 'highlight)
2553 (defvar gnus-mouse-face-2 'highlight)
2554 (defvar gnus-mouse-face-3 'highlight)
2555 (defvar gnus-mouse-face-4 'highlight)
2557 (defun gnus-mouse-face-function (form type)
2559 (point) (progn ,@form (point))
2560 gnus-mouse-face-prop
2563 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2565 (defvar gnus-face-0 'bold)
2566 (defvar gnus-face-1 'italic)
2567 (defvar gnus-face-2 'bold-italic)
2568 (defvar gnus-face-3 'bold)
2569 (defvar gnus-face-4 'bold)
2571 (defun gnus-face-face-function (form type)
2573 (point) (progn ,@form (point))
2574 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2576 (defun gnus-max-width-function (el max-width)
2577 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2579 `(if (> (length ,el) ,max-width)
2580 (substring ,el 0 ,max-width)
2582 `(let ((val (eval ,el)))
2584 (setq val (int-to-string val)))
2585 (if (> (length val) ,max-width)
2586 (substring val 0 ,max-width)
2589 (defun gnus-parse-format (format spec-alist &optional insert)
2590 ;; This function parses the FORMAT string with the help of the
2591 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2592 ;; string. If the FORMAT string contains the specifiers %( and %)
2593 ;; the text between them will have the mouse-face text property.
2595 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2597 (gnus-parse-complex-format format spec-alist)
2598 ;; This is a simple format.
2599 (gnus-parse-simple-format format spec-alist insert)))
2601 (defun gnus-parse-complex-format (format spec-alist)
2603 (gnus-set-work-buffer)
2605 (goto-char (point-min))
2606 (while (re-search-forward "\"" nil t)
2607 (replace-match "\\\"" nil t))
2608 (goto-char (point-min))
2610 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2611 (let ((number (if (match-beginning 1)
2612 (match-string 1) "0"))
2613 (delim (aref (match-string 2) 0)))
2614 (if (or (= delim ?\() (= delim ?\{))
2615 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2617 (replace-match "\")\""))))
2618 (goto-char (point-max))
2620 (goto-char (point-min))
2621 (let ((form (read (current-buffer))))
2622 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2624 (defun gnus-complex-form-to-spec (form spec-alist)
2629 (gnus-parse-simple-format sform spec-alist t)
2630 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2631 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2635 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2636 ;; This function parses the FORMAT string with the help of the
2637 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2640 spec flist fstring newspec elem beg result dontinsert)
2642 (gnus-set-work-buffer)
2644 (goto-char (point-min))
2645 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2647 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2649 beg (1+ (match-beginning 0)))
2650 ;; First check if there are any specs that look anything like
2651 ;; "%12,12A", ie. with a "max width specification". These have
2652 ;; to be treated specially.
2653 (if (setq beg (match-beginning 1))
2657 (1+ (match-beginning 1)) (match-end 1))))
2659 (setq beg (match-beginning 2)))
2660 ;; Find the specification from `spec-alist'.
2661 (unless (setq elem (cdr (assq spec spec-alist)))
2662 (setq elem '("*" ?s)))
2663 ;; Treat user defined format specifiers specially.
2664 (when (eq (car elem) 'gnus-tmp-user-defined)
2667 (list (intern (concat "gnus-user-format-function-"
2669 'gnus-tmp-header) ?s))
2670 (delete-region (match-beginning 3) (match-end 3)))
2671 (if (not (zerop max-width))
2672 (let ((el (car elem)))
2673 (cond ((= (cadr elem) ?c)
2674 (setq el (list 'char-to-string el)))
2676 (setq el (list 'int-to-string el))))
2677 (setq flist (cons (gnus-max-width-function el max-width)
2681 (setq flist (cons (car elem) flist))
2682 (setq newspec (cadr elem)))))
2683 ;; Remove the old specification (and possibly a ",12" string).
2684 (delete-region beg (match-end 2))
2685 ;; Insert the new specification.
2688 (setq fstring (buffer-substring 1 (point-max))))
2689 ;; Do some postprocessing to increase efficiency.
2694 ((string= fstring "")
2696 ;; Not a format string.
2697 ((not (string-match "%" fstring))
2699 ;; A format string with just a single string spec.
2700 ((string= fstring "%s")
2702 ;; A single character.
2703 ((string= fstring "%c")
2706 ((string= fstring "%d")
2709 (list `(princ ,(car flist)))
2710 (list `(int-to-string ,(car flist)))))
2711 ;; Just lots of chars and strings.
2712 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2714 ;; A single string spec at the beginning of the spec.
2715 ((string-match "\\`%[sc][^%]+\\'" fstring)
2716 (list (car flist) (substring fstring 2)))
2717 ;; A single string spec in the middle of the spec.
2718 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2719 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2720 ;; A single string spec in the end of the spec.
2721 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2722 (list (match-string 1 fstring) (car flist)))
2723 ;; A more complex spec.
2725 (list (cons 'format (cons fstring (nreverse flist)))))))
2731 (cons 'insert result)))
2732 (cond ((stringp result)
2735 (cons 'concat result))
2738 (defun gnus-eval-format (format &optional alist props)
2739 "Eval the format variable FORMAT, using ALIST.
2740 If PROPS, insert the result."
2741 (let ((form (gnus-parse-format format alist props)))
2743 (add-text-properties (point) (progn (eval form) (point)) props)
2746 (defun gnus-remove-text-with-property (prop)
2747 "Delete all text in the current buffer with text property PROP."
2749 (goto-char (point-min))
2751 (while (get-text-property (point) prop)
2753 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2755 (defun gnus-set-work-buffer ()
2756 (if (get-buffer gnus-work-buffer)
2758 (set-buffer gnus-work-buffer)
2760 (set-buffer (get-buffer-create gnus-work-buffer))
2761 (kill-all-local-variables)
2762 (buffer-disable-undo (current-buffer))
2763 (gnus-add-current-to-buffer-list)))
2765 ;; Article file names when saving.
2767 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2768 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2769 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2770 Otherwise, it is like ~/News/news/group/num."
2773 (concat (if (gnus-use-long-file-name 'not-save)
2774 (gnus-capitalize-newsgroup newsgroup)
2775 (gnus-newsgroup-directory-form newsgroup))
2776 "/" (int-to-string (mail-header-number headers)))
2777 (or gnus-article-save-directory "~/News"))))
2779 (string-equal (file-name-directory default)
2780 (file-name-directory last-file))
2781 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2783 (or last-file default))))
2785 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2786 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2787 If variable `gnus-use-long-file-name' is non-nil, it is
2788 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2791 (concat (if (gnus-use-long-file-name 'not-save)
2793 (gnus-newsgroup-directory-form newsgroup))
2794 "/" (int-to-string (mail-header-number headers)))
2795 (or gnus-article-save-directory "~/News"))))
2797 (string-equal (file-name-directory default)
2798 (file-name-directory last-file))
2799 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2801 (or last-file default))))
2803 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2804 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2805 If variable `gnus-use-long-file-name' is non-nil, it is
2806 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2809 (if (gnus-use-long-file-name 'not-save)
2810 (gnus-capitalize-newsgroup newsgroup)
2811 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2812 (or gnus-article-save-directory "~/News"))))
2814 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2815 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2816 If variable `gnus-use-long-file-name' is non-nil, it is
2817 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2820 (if (gnus-use-long-file-name 'not-save)
2822 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2823 (or gnus-article-save-directory "~/News"))))
2825 ;; For subscribing new newsgroup
2827 (defun gnus-subscribe-hierarchical-interactive (groups)
2828 (let ((groups (sort groups 'string<))
2829 prefixes prefix start ans group starts)
2831 (setq prefixes (list "^"))
2832 (while (and groups prefixes)
2833 (while (not (string-match (car prefixes) (car groups)))
2834 (setq prefixes (cdr prefixes)))
2835 (setq prefix (car prefixes))
2836 (setq start (1- (length prefix)))
2837 (if (and (string-match "[^\\.]\\." (car groups) start)
2840 (concat "^" (substring (car groups) 0 (match-end 0))))
2841 (string-match prefix (cadr groups)))
2843 (setq prefixes (cons prefix prefixes))
2844 (message "Descend hierarchy %s? ([y]nsq): "
2845 (substring prefix 1 (1- (length prefix))))
2846 (setq ans (read-char))
2849 (string-match prefix
2850 (setq group (car groups))))
2851 (setq gnus-killed-list
2852 (cons group gnus-killed-list))
2853 (gnus-sethash group group gnus-killed-hashtb)
2854 (setq groups (cdr groups)))
2855 (setq starts (cdr starts)))
2858 (string-match prefix
2859 (setq group (car groups))))
2860 (gnus-sethash group group gnus-killed-hashtb)
2861 (gnus-subscribe-alphabetically (car groups))
2862 (setq groups (cdr groups)))
2863 (setq starts (cdr starts)))
2866 (setq group (car groups))
2867 (setq gnus-killed-list (cons group gnus-killed-list))
2868 (gnus-sethash group group gnus-killed-hashtb)
2869 (setq groups (cdr groups))))
2871 (message "Subscribe %s? ([n]yq)" (car groups))
2872 (setq ans (read-char))
2873 (setq group (car groups))
2875 (gnus-subscribe-alphabetically (car groups))
2876 (gnus-sethash group group gnus-killed-hashtb))
2879 (setq group (car groups))
2880 (setq gnus-killed-list (cons group gnus-killed-list))
2881 (gnus-sethash group group gnus-killed-hashtb)
2882 (setq groups (cdr groups))))
2884 (setq gnus-killed-list (cons group gnus-killed-list))
2885 (gnus-sethash group group gnus-killed-hashtb)))
2886 (setq groups (cdr groups)))))))
2888 (defun gnus-subscribe-randomly (newsgroup)
2889 "Subscribe new NEWSGROUP by making it the first newsgroup."
2890 (gnus-subscribe-newsgroup newsgroup))
2892 (defun gnus-subscribe-alphabetically (newgroup)
2893 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2894 (let ((groups (cdr gnus-newsrc-alist))
2896 (while (and (not before) groups)
2897 (if (string< newgroup (caar groups))
2898 (setq before (caar groups))
2899 (setq groups (cdr groups))))
2900 (gnus-subscribe-newsgroup newgroup before)))
2902 (defun gnus-subscribe-hierarchically (newgroup)
2903 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2904 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2906 (set-buffer (find-file-noselect gnus-current-startup-file))
2907 (let ((groupkey newgroup)
2909 (while (and (not before) groupkey)
2910 (goto-char (point-min))
2912 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2913 (while (and (re-search-forward groupkey-re nil t)
2915 (setq before (match-string 1))
2916 (string< before newgroup)))))
2917 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2919 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2920 (substring groupkey (match-beginning 1) (match-end 1)))))
2921 (gnus-subscribe-newsgroup newgroup before))))
2923 (defun gnus-subscribe-interactively (group)
2924 "Subscribe the new GROUP interactively.
2925 It is inserted in hierarchical newsgroup order if subscribed. If not,
2927 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2928 (gnus-subscribe-hierarchically group)
2929 (push group gnus-killed-list)))
2931 (defun gnus-subscribe-zombies (group)
2932 "Make the new GROUP into a zombie group."
2933 (push group gnus-zombie-list))
2935 (defun gnus-subscribe-killed (group)
2936 "Make the new GROUP a killed group."
2937 (push group gnus-killed-list))
2939 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2940 "Subscribe new NEWSGROUP.
2941 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2942 the first newsgroup."
2943 ;; We subscribe the group by changing its level to `subscribed'.
2944 (gnus-group-change-level
2945 newsgroup gnus-level-default-subscribed
2946 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2947 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2951 (defun gnus-newsgroup-directory-form (newsgroup)
2952 "Make hierarchical directory name from NEWSGROUP name."
2953 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2954 (len (length newsgroup))
2956 ;; If this is a foreign group, we don't want to translate the
2958 (if (setq idx (string-match ":" newsgroup))
2959 (aset newsgroup idx ?/)
2961 ;; Replace all occurrences of `.' with `/'.
2963 (if (= (aref newsgroup idx) ?.)
2964 (aset newsgroup idx ?/))
2965 (setq idx (1+ idx)))
2968 (defun gnus-newsgroup-savable-name (group)
2969 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2971 (nnheader-replace-chars-in-string group ?/ ?.))
2973 (defun gnus-make-directory (dir)
2974 "Make DIRECTORY recursively."
2975 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2976 ;; of the many mysteries of the universe.
2977 (let* ((dir (expand-file-name dir default-directory))
2979 (if (string-match "/$" dir)
2980 (setq dir (substring dir 0 (match-beginning 0))))
2981 ;; First go down the path until we find a directory that exists.
2982 (while (not (file-exists-p dir))
2983 (setq dirs (cons dir dirs))
2984 (string-match "/[^/]+$" dir)
2985 (setq dir (substring dir 0 (match-beginning 0))))
2986 ;; Then create all the subdirs.
2987 (while (and dirs (not err))
2989 (make-directory (car dirs))
2990 (error (setq err t)))
2991 (setq dirs (cdr dirs)))
2992 ;; We return whether we were successful or not.
2995 (defun gnus-capitalize-newsgroup (newsgroup)
2996 "Capitalize NEWSGROUP name."
2997 (and (not (zerop (length newsgroup)))
2998 (concat (char-to-string (upcase (aref newsgroup 0)))
2999 (substring newsgroup 1))))
3001 ;; Various... things.
3003 (defun gnus-simplify-subject (subject &optional re-only)
3004 "Remove `Re:' and words in parentheses.
3005 If RE-ONLY is non-nil, strip leading `Re:'s only."
3006 (let ((case-fold-search t)) ;Ignore case.
3007 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3008 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3009 (setq subject (substring subject (match-end 0))))
3010 ;; Remove uninteresting prefixes.
3011 (if (and (not re-only)
3012 gnus-simplify-ignored-prefixes
3013 (string-match gnus-simplify-ignored-prefixes subject))
3014 (setq subject (substring subject (match-end 0))))
3015 ;; Remove words in parentheses from end.
3017 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3018 (setq subject (substring subject 0 (match-beginning 0)))))
3019 ;; Return subject string.
3022 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3024 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3025 (defun gnus-simplify-buffer-fuzzy ()
3026 (goto-char (point-min))
3027 (while (search-forward "\t" nil t)
3028 (replace-match " " t t))
3029 (goto-char (point-min))
3030 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3031 (goto-char (match-beginning 0))
3033 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3034 (looking-at "^[[].*: .*[]]$"))
3035 (goto-char (point-min))
3036 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3038 (replace-match "" t t))
3039 (goto-char (point-min))
3040 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3041 (goto-char (match-end 0))
3044 (progn (goto-char (match-beginning 0)))
3045 (re-search-forward ":"))))
3046 (goto-char (point-min))
3047 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3048 (replace-match "" t t))
3049 (goto-char (point-min))
3050 (while (re-search-forward " +" nil t)
3051 (replace-match " " t t))
3052 (goto-char (point-min))
3053 (while (re-search-forward " $" nil t)
3054 (replace-match "" t t))
3055 (goto-char (point-min))
3056 (while (re-search-forward "^ +" nil t)
3057 (replace-match "" t t))
3058 (goto-char (point-min))
3059 (when gnus-simplify-subject-fuzzy-regexp
3060 (if (listp gnus-simplify-subject-fuzzy-regexp)
3061 (let ((list gnus-simplify-subject-fuzzy-regexp))
3063 (goto-char (point-min))
3064 (while (re-search-forward (car list) nil t)
3065 (replace-match "" t t))
3066 (setq list (cdr list))))
3067 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3068 (replace-match "" t t)))))
3070 (defun gnus-simplify-subject-fuzzy (subject)
3071 "Siplify a subject string fuzzily."
3073 (gnus-set-work-buffer)
3074 (let ((case-fold-search t))
3076 (inline (gnus-simplify-buffer-fuzzy))
3079 ;; Add the current buffer to the list of buffers to be killed on exit.
3080 (defun gnus-add-current-to-buffer-list ()
3081 (or (memq (current-buffer) gnus-buffer-list)
3082 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3084 (defun gnus-string> (s1 s2)
3085 (not (or (string< s1 s2)
3088 ;;; General various misc type functions.
3090 (defun gnus-clear-system ()
3091 "Clear all variables and buffers."
3092 ;; Clear Gnus variables.
3093 (let ((variables gnus-variable-list))
3095 (set (car variables) nil)
3096 (setq variables (cdr variables))))
3097 ;; Clear other internal variables.
3098 (setq gnus-list-of-killed-groups nil
3099 gnus-have-read-active-file nil
3100 gnus-newsrc-alist nil
3101 gnus-newsrc-hashtb nil
3102 gnus-killed-list nil
3103 gnus-zombie-list nil
3104 gnus-killed-hashtb nil
3105 gnus-active-hashtb nil
3106 gnus-moderated-list nil
3107 gnus-description-hashtb nil
3108 gnus-current-headers nil
3109 gnus-thread-indent-array nil
3110 gnus-newsgroup-headers nil
3111 gnus-newsgroup-name nil
3112 gnus-server-alist nil
3113 gnus-group-list-mode nil
3114 gnus-opened-servers nil
3115 gnus-current-select-method nil)
3116 (gnus-shutdown 'gnus)
3117 ;; Kill the startup file.
3118 (and gnus-current-startup-file
3119 (get-file-buffer gnus-current-startup-file)
3120 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3121 ;; Clear the dribble buffer.
3122 (gnus-dribble-clear)
3123 ;; Kill global KILL file buffer.
3124 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3125 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3126 (gnus-kill-buffer nntp-server-buffer)
3127 ;; Kill Gnus buffers.
3128 (while gnus-buffer-list
3129 (gnus-kill-buffer (pop gnus-buffer-list)))
3130 ;; Remove Gnus frames.
3131 (while gnus-created-frames
3132 (when (frame-live-p (car gnus-created-frames))
3133 ;; We slap a condition-case around this `delete-frame' to ensure
3134 ;; agains errors if we try do delete the single frame that's left.
3136 (delete-frame (car gnus-created-frames))
3138 (pop gnus-created-frames)))
3140 (defun gnus-windows-old-to-new (setting)
3141 ;; First we take care of the really, really old Gnus 3 actions.
3142 (when (symbolp setting)
3144 ;; Take care of ooold GNUS 3.x values.
3145 (cond ((eq setting 'SelectArticle) 'article)
3146 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3147 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3149 (if (or (listp setting)
3150 (not (and gnus-window-configuration
3151 (memq setting '(group summary article)))))
3153 (let* ((setting (if (eq setting 'group)
3154 (if (assq 'newsgroup gnus-window-configuration)
3156 'newsgroups) setting))
3157 (elem (cadr (assq setting gnus-window-configuration)))
3158 (total (apply '+ elem))
3159 (types '(group summary article))
3160 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3165 (or (not (numberp (nth i elem)))
3166 (zerop (nth i elem))
3168 (setq perc (/ (float (nth 0 elem)) total))
3169 (setq out (cons (if (eq pbuf (nth i types))
3170 (vector (nth i types) perc 'point)
3171 (vector (nth i types) perc))
3174 (list (nreverse out)))))
3177 (defun gnus-add-configuration (conf)
3178 "Add the window configuration CONF to `gnus-buffer-configuration'."
3179 (setq gnus-buffer-configuration
3180 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3181 gnus-buffer-configuration))))
3183 (defvar gnus-frame-list nil)
3185 (defun gnus-configure-frame (split &optional window)
3186 "Split WINDOW according to SPLIT."
3188 (setq window (get-buffer-window (current-buffer))))
3189 (select-window window)
3190 ;; This might be an old-stylee buffer config.
3191 (when (vectorp split)
3192 (setq split (append split nil)))
3193 (when (or (consp (car split))
3194 (vectorp (car split)))
3196 (push 'vertical split))
3197 ;; The SPLIT might be something that is to be evaled to
3198 ;; return a new SPLIT.
3199 (while (and (not (assq (car split) gnus-window-to-buffer))
3200 (gnus-functionp (car split)))
3201 (setq split (eval split)))
3202 (let* ((type (car split))
3204 (len (if (eq type 'horizontal) (window-width) (window-height)))
3206 (window-min-width (or gnus-window-min-width window-min-width))
3207 (window-min-height (or gnus-window-min-height window-min-height))
3208 s result new-win rest comp-subs size sub)
3210 ;; Nothing to do here.
3212 ;; Don't switch buffers.
3214 (and (memq 'point split) window))
3215 ;; This is a buffer to be selected.
3216 ((not (memq type '(frame horizontal vertical)))
3217 (let ((buffer (cond ((stringp type) type)
3218 (t (cdr (assq type gnus-window-to-buffer)))))
3221 (error "Illegal buffer type: %s" type))
3222 (unless (setq buf (get-buffer (if (symbolp buffer)
3223 (symbol-value buffer) buffer)))
3224 (setq buf (get-buffer-create (if (symbolp buffer)
3225 (symbol-value buffer) buffer))))
3226 (switch-to-buffer buf)
3227 ;; We return the window if it has the `point' spec.
3228 (and (memq 'point split) window)))
3229 ;; This is a frame split.
3231 (unless gnus-frame-list
3232 (setq gnus-frame-list (list (window-frame
3233 (get-buffer-window (current-buffer))))))
3235 params frame fresult)
3236 (while (< i (length subs))
3237 ;; Frame parameter is gotten from the sub-split.
3238 (setq params (cadr (elt subs i)))
3239 ;; It should be a list.
3240 (unless (listp params)
3242 ;; Create a new frame?
3243 (unless (setq frame (elt gnus-frame-list i))
3244 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3245 (push frame gnus-created-frames))
3246 ;; Is the old frame still alive?
3247 (unless (frame-live-p frame)
3248 (setcar (nthcdr i gnus-frame-list)
3249 (setq frame (make-frame params))))
3250 ;; Select the frame in question and do more splits there.
3251 (select-frame frame)
3252 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3254 ;; Select the frame that has the selected buffer.
3256 (select-frame (window-frame fresult)))))
3257 ;; This is a normal split.
3259 (when (> (length subs) 0)
3260 ;; First we have to compute the sizes of all new windows.
3262 (setq sub (append (pop subs) nil))
3263 (while (and (not (assq (car sub) gnus-window-to-buffer))
3264 (gnus-functionp (car sub)))
3265 (setq sub (eval sub)))
3267 (push sub comp-subs)
3268 (setq size (cadar comp-subs))
3269 (cond ((equal size 1.0)
3270 (setq rest (car comp-subs))
3273 (setq s (floor (* size len))))
3277 (error "Illegal size: %s" size)))
3278 ;; Try to make sure that we are inside the safe limits.
3280 ((eq type 'horizontal)
3281 (setq s (max s window-min-width)))
3282 ((eq type 'vertical)
3283 (setq s (max s window-min-height))))
3284 (setcar (cdar comp-subs) s)
3286 ;; Take care of the "1.0" spec.
3288 (setcar (cdr rest) (- len total))
3289 (error "No 1.0 specs in %s" split))
3290 ;; The we do the actual splitting in a nice recursive
3292 (setq comp-subs (nreverse comp-subs))
3294 (if (null (cdr comp-subs))
3295 (setq new-win window)
3297 (split-window window (cadar comp-subs)
3298 (eq type 'horizontal))))
3299 (setq result (or (gnus-configure-frame
3300 (car comp-subs) window) result))
3301 (select-window new-win)
3302 (setq window new-win)
3303 (setq comp-subs (cdr comp-subs))))
3304 ;; Return the proper window, if any.
3306 (select-window result))))))
3308 (defvar gnus-frame-split-p nil)
3310 (defun gnus-configure-windows (setting &optional force)
3311 (setq setting (gnus-windows-old-to-new setting))
3312 (let ((split (if (symbolp setting)
3313 (cadr (assq setting gnus-buffer-configuration))
3317 (setq gnus-frame-split-p nil)
3320 (error "No such setting: %s" setting))
3322 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3324 ;; All the windows mentioned are already visible, so we just
3325 ;; put point in the assigned buffer, and do not touch the
3327 (select-window all-visible)
3329 ;; Either remove all windows or just remove all Gnus windows.
3330 (let ((frame (selected-frame)))
3332 (if gnus-use-full-window
3333 ;; We want to remove all other windows.
3334 (if (not gnus-frame-split-p)
3335 ;; This is not a `frame' split, so we ignore the
3337 (delete-other-windows)
3338 ;; This is a `frame' split, so we delete all windows
3342 (unless (eq (cdr (assq 'minibuffer
3343 (frame-parameters frame)))
3345 (select-frame frame)
3346 (delete-other-windows)))
3348 ;; Just remove some windows.
3349 (gnus-remove-some-windows)
3350 (switch-to-buffer nntp-server-buffer))
3351 (select-frame frame)))
3353 (switch-to-buffer nntp-server-buffer)
3354 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3356 (defun gnus-all-windows-visible-p (split)
3357 "Say whether all buffers in SPLIT are currently visible.
3358 In particular, the value returned will be the window that
3360 (let ((stack (list split))
3362 type buffer win buf)
3363 (while (and (setq split (pop stack))
3365 ;; Be backwards compatible.
3366 (when (vectorp split)
3367 (setq split (append split nil)))
3368 (when (or (consp (car split))
3369 (vectorp (car split)))
3371 (push 'vertical split))
3372 ;; The SPLIT might be something that is to be evaled to
3373 ;; return a new SPLIT.
3374 (while (and (not (assq (car split) gnus-window-to-buffer))
3375 (gnus-functionp (car split)))
3376 (setq split (eval split)))
3378 (setq type (elt split 0))
3383 ((not (memq type '(horizontal vertical frame)))
3384 (setq buffer (cond ((stringp type) type)
3385 (t (cdr (assq type gnus-window-to-buffer)))))
3387 (error "Illegal buffer type: %s" type))
3388 (when (setq buf (get-buffer (if (symbolp buffer)
3389 (symbol-value buffer)
3391 (setq win (get-buffer-window buf t)))
3393 (when (memq 'point split)
3394 (setq all-visible win))
3395 (setq all-visible nil)))
3397 (when (eq type 'frame)
3398 (setq gnus-frame-split-p t))
3399 (setq stack (append (cddr split) stack)))))
3400 (unless (eq all-visible t)
3403 (defun gnus-window-top-edge (&optional window)
3404 (nth 1 (window-edges window)))
3406 (defun gnus-remove-some-windows ()
3407 (let ((buffers gnus-window-to-buffer)
3408 buf bufs lowest-buf lowest)
3410 ;; Remove windows on all known Gnus buffers.
3412 (setq buf (cdar buffers))
3414 (setq buf (and (boundp buf) (symbol-value buf))))
3416 (get-buffer-window buf)
3418 (setq bufs (cons buf bufs))
3420 (if (or (not lowest)
3421 (< (gnus-window-top-edge) lowest))
3423 (setq lowest (gnus-window-top-edge))
3424 (setq lowest-buf buf)))))
3425 (setq buffers (cdr buffers)))
3426 ;; Remove windows on *all* summary buffers.
3429 (let ((buf (window-buffer win)))
3430 (if (string-match "^\\*Summary" (buffer-name buf))
3432 (setq bufs (cons buf bufs))
3434 (if (or (not lowest)
3435 (< (gnus-window-top-edge) lowest))
3437 (setq lowest-buf buf)
3438 (setq lowest (gnus-window-top-edge)))))))))
3441 (pop-to-buffer lowest-buf)
3442 (switch-to-buffer nntp-server-buffer)))
3444 (and (not (eq (car bufs) lowest-buf))
3445 (delete-windows-on (car bufs)))
3446 (setq bufs (cdr bufs))))))
3448 (defun gnus-version ()
3449 "Version numbers of this version of Gnus."
3451 (let ((methods gnus-valid-select-methods)
3454 ;; Go through all the legal select methods and add their version
3455 ;; numbers to the total version string. Only the backends that are
3456 ;; currently in use will have their message numbers taken into
3459 (setq meth (intern (concat (caar methods) "-version")))
3461 (stringp (symbol-value meth))
3462 (setq mess (concat mess "; " (symbol-value meth))))
3463 (setq methods (cdr methods)))
3464 (gnus-message 2 mess)))
3466 (defun gnus-info-find-node ()
3467 "Find Info documentation of Gnus."
3469 ;; Enlarge info window if needed.
3470 (let ((mode major-mode)
3472 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3473 (setq gnus-info-buffer (current-buffer))
3474 (gnus-configure-windows 'info)))
3476 (defun gnus-days-between (date1 date2)
3477 ;; Return the number of days between date1 and date2.
3478 (- (gnus-day-number date1) (gnus-day-number date2)))
3480 (defun gnus-day-number (date)
3481 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3482 (timezone-parse-date date))))
3483 (timezone-absolute-from-gregorian
3484 (nth 1 dat) (nth 2 dat) (car dat))))
3486 (defun gnus-encode-date (date)
3487 "Convert DATE to internal time."
3488 (let* ((parse (timezone-parse-date date))
3489 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3490 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3491 (encode-time (caddr time) (cadr time) (car time)
3492 (caddr date) (cadr date) (car date) (nth 4 date))))
3494 (defun gnus-time-minus (t1 t2)
3495 "Subtract two internal times."
3496 (let ((borrow (< (cadr t1) (cadr t2))))
3497 (list (- (car t1) (car t2) (if borrow 1 0))
3498 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3500 (defun gnus-file-newer-than (file date)
3501 (let ((fdate (nth 5 (file-attributes file))))
3502 (or (> (car fdate) (car date))
3503 (and (= (car fdate) (car date))
3504 (> (nth 1 fdate) (nth 1 date))))))
3506 (defmacro gnus-local-set-keys (&rest plist)
3507 "Set the keys in PLIST in the current keymap."
3508 `(gnus-define-keys-1 (current-local-map) ',plist))
3510 (defmacro gnus-define-keys (keymap &rest plist)
3511 "Define all keys in PLIST in KEYMAP."
3512 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3514 (put 'gnus-define-keys 'lisp-indent-function 1)
3515 (put 'gnus-define-keys 'lisp-indent-hook 1)
3516 (put 'gnus-define-keymap 'lisp-indent-function 1)
3517 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3519 (defmacro gnus-define-keymap (keymap &rest plist)
3520 "Define all keys in PLIST in KEYMAP."
3521 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3523 (defun gnus-define-keys-1 (keymap plist)
3525 (error "Can't set keys in a null keymap"))
3526 (cond ((symbolp keymap)
3527 (setq keymap (symbol-value keymap)))
3530 (set (car keymap) nil)
3531 (define-prefix-command (car keymap))
3532 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3533 (setq keymap (symbol-value (car keymap)))))
3536 (when (symbolp (setq key (pop plist)))
3537 (setq key (symbol-value key)))
3538 (define-key keymap key (pop plist)))))
3540 (defun gnus-group-read-only-p (&optional group)
3541 "Check whether GROUP supports editing or not.
3542 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3543 that that variable is buffer-local to the summary buffers."
3544 (let ((group (or group gnus-newsgroup-name)))
3545 (not (gnus-check-backend-function 'request-replace-article group))))
3547 (defun gnus-group-total-expirable-p (group)
3548 "Check whether GROUP is total-expirable or not."
3549 (let ((params (gnus-info-params (gnus-get-info group))))
3550 (or (memq 'total-expire params)
3551 (cdr (assq 'total-expire params)) ; (total-expire . t)
3552 (and gnus-total-expirable-newsgroups ; Check var.
3553 (string-match gnus-total-expirable-newsgroups group)))))
3555 (defun gnus-group-auto-expirable-p (group)
3556 "Check whether GROUP is total-expirable or not."
3557 (let ((params (gnus-info-params (gnus-get-info group))))
3558 (or (memq 'auto-expire params)
3559 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3560 (and gnus-auto-expirable-newsgroups ; Check var.
3561 (string-match gnus-auto-expirable-newsgroups group)))))
3563 (defun gnus-virtual-group-p (group)
3564 "Say whether GROUP is virtual or not."
3565 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3566 gnus-valid-select-methods)))
3568 (defun gnus-news-group-p (group &optional article)
3569 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3570 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3571 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3572 (eq (gnus-request-type group article) 'news))))
3574 (defsubst gnus-simplify-subject-fully (subject)
3575 "Simplify a subject string according to the user's wishes."
3577 ((null gnus-summary-gather-subject-limit)
3578 (gnus-simplify-subject-re subject))
3579 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3580 (gnus-simplify-subject-fuzzy subject))
3581 ((numberp gnus-summary-gather-subject-limit)
3582 (gnus-limit-string (gnus-simplify-subject-re subject)
3583 gnus-summary-gather-subject-limit))
3587 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3588 "Check whether two subjects are equal. If optional argument
3589 simple-first is t, first argument is already simplified."
3591 ((null simple-first)
3592 (equal (gnus-simplify-subject-fully s1)
3593 (gnus-simplify-subject-fully s2)))
3596 (gnus-simplify-subject-fully s2)))))
3598 ;; Returns a list of writable groups.
3599 (defun gnus-writable-groups ()
3600 (let ((alist gnus-newsrc-alist)
3602 (while (setq group (car (pop alist)))
3603 (unless (gnus-group-read-only-p group)
3604 (push group groups)))
3607 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3609 (defun gnus-y-or-n-p (prompt)
3614 (defun gnus-yes-or-no-p (prompt)
3616 (yes-or-no-p prompt)
3619 ;; Check whether to use long file names.
3620 (defun gnus-use-long-file-name (symbol)
3621 ;; The variable has to be set...
3622 (and gnus-use-long-file-name
3623 ;; If it isn't a list, then we return t.
3624 (or (not (listp gnus-use-long-file-name))
3625 ;; If it is a list, and the list contains `symbol', we
3627 (not (memq symbol gnus-use-long-file-name)))))
3629 ;; I suspect there's a better way, but I haven't taken the time to do
3630 ;; it yet. -erik selberg@cs.washington.edu
3631 (defun gnus-dd-mmm (messy-date)
3632 "Return a string like DD-MMM from a big messy string"
3633 (let ((datevec (timezone-parse-date messy-date)))
3636 ;; Make sure leading zeroes are stripped.
3637 (number-to-string (string-to-number (aref datevec 2)))
3641 (nth (1- (string-to-number (aref datevec 1)))
3642 timezone-months-assoc))
3645 ;; Make a hash table (default and minimum size is 255).
3646 ;; Optional argument HASHSIZE specifies the table size.
3647 (defun gnus-make-hashtable (&optional hashsize)
3648 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3650 ;; Make a number that is suitable for hashing; bigger than MIN and one
3652 (defun gnus-create-hash-size (min)
3658 ;; Show message if message has a lower level than `gnus-verbose'.
3659 ;; Guideline for numbers:
3660 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3661 ;; for things that take a long time, 7 - not very important messages
3662 ;; on stuff, 9 - messages inside loops.
3663 (defun gnus-message (level &rest args)
3664 (if (<= level gnus-verbose)
3665 (apply 'message args)
3666 ;; We have to do this format thingy here even if the result isn't
3667 ;; shown - the return value has to be the same as the return value
3669 (apply 'format args)))
3671 ;; Generate a unique new group name.
3672 (defun gnus-generate-new-group-name (leaf)
3675 (while (gnus-gethash name gnus-newsrc-hashtb)
3676 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3679 (defsubst gnus-hide-text (b e props)
3680 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3681 (add-text-properties b e props)
3682 (when (memq 'intangible props)
3683 (put-text-property (max (1- b) (point-min))
3684 b 'intangible (cddr (memq 'intangible props)))))
3686 (defsubst gnus-unhide-text (b e)
3687 "Remove hidden text properties from region between B and E."
3688 (remove-text-properties b e gnus-hidden-properties)
3689 (when (memq 'intangible gnus-hidden-properties)
3690 (put-text-property (max (1- b) (point-min))
3691 b 'intangible nil)))
3693 (defun gnus-hide-text-type (b e type)
3694 "Hide text of TYPE between B and E."
3695 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3697 ;; Find out whether the gnus-visual TYPE is wanted.
3698 (defun gnus-visual-p (&optional type class)
3699 (and gnus-visual ; Has to be non-nil, at least.
3700 (if (not type) ; We don't care about type.
3702 (if (listp gnus-visual) ; It's a list, so we check it.
3703 (or (memq type gnus-visual)
3704 (memq class gnus-visual))
3707 (defun gnus-parent-id (references)
3708 "Return the last Message-ID in REFERENCES."
3709 (when (and references
3710 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3711 (substring references (match-beginning 1) (match-end 1))))
3713 (defun gnus-split-references (references)
3714 "Return a list of Message-IDs in REFERENCES."
3717 (while (string-match "<[^>]+>" references beg)
3718 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3722 (defun gnus-buffer-live-p (buffer)
3723 "Say whether BUFFER is alive or not."
3726 (buffer-name (get-buffer buffer))))
3728 (defun gnus-ephemeral-group-p (group)
3729 "Say whether GROUP is ephemeral or not."
3730 (gnus-group-get-parameter group 'quit-config))
3732 (defun gnus-group-quit-config (group)
3733 "Return the quit-config of GROUP."
3734 (gnus-group-get-parameter group 'quit-config))
3736 (defun gnus-simplify-mode-line ()
3737 "Make mode lines a bit simpler."
3738 (setq mode-line-modified "-- ")
3739 (when (listp mode-line-format)
3740 (make-local-variable 'mode-line-format)
3741 (setq mode-line-format (copy-sequence mode-line-format))
3742 (when (equal (nth 3 mode-line-format) " ")
3743 (setcar (nthcdr 3 mode-line-format) " "))))
3745 ;;; List and range functions
3747 (defun gnus-last-element (list)
3748 "Return last element of LIST."
3750 (setq list (cdr list)))
3753 (defun gnus-copy-sequence (list)
3754 "Do a complete, total copy of a list."
3755 (if (and (consp list) (not (consp (cdr list))))
3756 (cons (car list) (cdr list))
3757 (mapcar (lambda (elem) (if (consp elem)
3758 (if (consp (cdr elem))
3759 (gnus-copy-sequence elem)
3760 (cons (car elem) (cdr elem)))
3764 (defun gnus-set-difference (list1 list2)
3765 "Return a list of elements of LIST1 that do not appear in LIST2."
3766 (let ((list1 (copy-sequence list1)))
3768 (setq list1 (delq (car list2) list1))
3769 (setq list2 (cdr list2)))
3772 (defun gnus-sorted-complement (list1 list2)
3773 "Return a list of elements of LIST1 that do not appear in LIST2.
3774 Both lists have to be sorted over <."
3776 (if (or (null list1) (null list2))
3778 (while (and list1 list2)
3779 (cond ((= (car list1) (car list2))
3780 (setq list1 (cdr list1)
3782 ((< (car list1) (car list2))
3783 (setq out (cons (car list1) out))
3784 (setq list1 (cdr list1)))
3786 (setq out (cons (car list2) out))
3787 (setq list2 (cdr list2)))))
3788 (nconc (nreverse out) (or list1 list2)))))
3790 (defun gnus-intersection (list1 list2)
3793 (if (memq (car list2) list1)
3794 (setq result (cons (car list2) result)))
3795 (setq list2 (cdr list2)))
3798 (defun gnus-sorted-intersection (list1 list2)
3799 ;; LIST1 and LIST2 have to be sorted over <.
3801 (while (and list1 list2)
3802 (cond ((= (car list1) (car list2))
3803 (setq out (cons (car list1) out)
3806 ((< (car list1) (car list2))
3807 (setq list1 (cdr list1)))
3809 (setq list2 (cdr list2)))))
3812 (defun gnus-set-sorted-intersection (list1 list2)
3813 ;; LIST1 and LIST2 have to be sorted over <.
3814 ;; This function modifies LIST1.
3815 (let* ((top (cons nil list1))
3817 (while (and list1 list2)
3818 (cond ((= (car list1) (car list2))
3822 ((< (car list1) (car list2))
3823 (setcdr prev (cdr list1))
3824 (setq list1 (cdr list1)))
3826 (setq list2 (cdr list2)))))
3830 (defun gnus-compress-sequence (numbers &optional always-list)
3831 "Convert list of numbers to a list of ranges or a single range.
3832 If ALWAYS-LIST is non-nil, this function will always release a list of
3834 (let* ((first (car numbers))
3835 (last (car numbers))
3839 (if (not (listp (cdr numbers)))
3842 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3843 ((= (1+ last) (car numbers)) ;Still in sequence
3844 (setq last (car numbers)))
3845 (t ;End of one sequence
3847 (cons (if (= first last) first
3848 (cons first last)) result))
3849 (setq first (car numbers))
3850 (setq last (car numbers))))
3851 (setq numbers (cdr numbers)))
3852 (if (and (not always-list) (null result))
3853 (if (= first last) (list first) (cons first last))
3854 (nreverse (cons (if (= first last) first (cons first last))
3857 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3858 (defun gnus-uncompress-range (ranges)
3859 "Expand a list of ranges into a list of numbers.
3860 RANGES is either a single range on the form `(num . num)' or a list of
3862 (let (first last result)
3866 ((not (listp (cdr ranges)))
3867 (setq first (car ranges))
3868 (setq last (cdr ranges))
3869 (while (<= first last)
3870 (setq result (cons first result))
3871 (setq first (1+ first)))
3875 (if (atom (car ranges))
3876 (if (numberp (car ranges))
3877 (setq result (cons (car ranges) result)))
3878 (setq first (caar ranges))
3879 (setq last (cdar ranges))
3880 (while (<= first last)
3881 (setq result (cons first result))
3882 (setq first (1+ first))))
3883 (setq ranges (cdr ranges)))
3884 (nreverse result)))))
3886 (defun gnus-add-to-range (ranges list)
3887 "Return a list of ranges that has all articles from both RANGES and LIST.
3888 Note: LIST has to be sorted over `<'."
3890 (gnus-compress-sequence list t)
3891 (setq list (copy-sequence list))
3892 (or (listp (cdr ranges))
3893 (setq ranges (list ranges)))
3895 ilist lowest highest temp)
3896 (while (and ranges list)
3898 (setq lowest (or (and (atom (car ranges)) (car ranges))
3900 (while (and list (cdr list) (< (cadr list) lowest))
3901 (setq list (cdr list)))
3902 (if (< (car ilist) lowest)
3905 (setq list (cdr list))
3907 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3908 (setq highest (or (and (atom (car ranges)) (car ranges))
3910 (while (and list (<= (car list) highest))
3911 (setq list (cdr list)))
3912 (setq ranges (cdr ranges)))
3914 (setq out (nconc (gnus-compress-sequence list t) out)))
3915 (setq out (sort out (lambda (r1 r2)
3916 (< (or (and (atom r1) r1) (car r1))
3917 (or (and (atom r2) r2) (car r2))))))
3920 (if (atom (car ranges))
3922 (if (atom (cadr ranges))
3923 (if (= (1+ (car ranges)) (cadr ranges))
3925 (setcar ranges (cons (car ranges)
3927 (setcdr ranges (cddr ranges))))
3928 (if (= (1+ (car ranges)) (caadr ranges))
3930 (setcar (cadr ranges) (car ranges))
3931 (setcar ranges (cadr ranges))
3932 (setcdr ranges (cddr ranges))))))
3934 (if (atom (cadr ranges))
3935 (if (= (1+ (cdar ranges)) (cadr ranges))
3937 (setcdr (car ranges) (cadr ranges))
3938 (setcdr ranges (cddr ranges))))
3939 (if (= (1+ (cdar ranges)) (caadr ranges))
3941 (setcdr (car ranges) (cdadr ranges))
3942 (setcdr ranges (cddr ranges)))))))
3943 (setq ranges (cdr ranges)))
3946 (defun gnus-remove-from-range (ranges list)
3947 "Return a list of ranges that has all articles from LIST removed from RANGES.
3948 Note: LIST has to be sorted over `<'."
3949 ;; !!! This function shouldn't look like this, but I've got a headache.
3950 (gnus-compress-sequence
3951 (gnus-sorted-complement
3952 (gnus-uncompress-range ranges) list)))
3954 (defun gnus-member-of-range (number ranges)
3955 (if (not (listp (cdr ranges)))
3956 (and (>= number (car ranges))
3957 (<= number (cdr ranges)))
3960 (if (numberp (car ranges))
3961 (>= number (car ranges))
3962 (>= number (caar ranges)))
3964 (if (if (numberp (car ranges))
3965 (= number (car ranges))
3966 (and (>= number (caar ranges))
3967 (<= number (cdar ranges))))
3968 (setq not-stop nil))
3969 (setq ranges (cdr ranges)))
3972 (defun gnus-range-length (range)
3973 "Return the length RANGE would have if uncompressed."
3974 (length (gnus-uncompress-range range)))
3976 (defun gnus-sublist-p (list sublist)
3977 "Test whether all elements in SUBLIST are members of LIST."
3980 (unless (memq (pop sublist) list)
3990 (defvar gnus-group-mode-map nil)
3991 (put 'gnus-group-mode 'mode-class 'special)
3993 (unless gnus-group-mode-map
3994 (setq gnus-group-mode-map (make-keymap))
3995 (suppress-keymap gnus-group-mode-map)
3997 (gnus-define-keys gnus-group-mode-map
3998 " " gnus-group-read-group
3999 "=" gnus-group-select-group
4000 "\r" gnus-group-select-group
4001 "\M-\r" gnus-group-quick-select-group
4002 "j" gnus-group-jump-to-group
4003 "n" gnus-group-next-unread-group
4004 "p" gnus-group-prev-unread-group
4005 "\177" gnus-group-prev-unread-group
4006 [delete] gnus-group-prev-unread-group
4007 "N" gnus-group-next-group
4008 "P" gnus-group-prev-group
4009 "\M-n" gnus-group-next-unread-group-same-level
4010 "\M-p" gnus-group-prev-unread-group-same-level
4011 "," gnus-group-best-unread-group
4012 "." gnus-group-first-unread-group
4013 "u" gnus-group-unsubscribe-current-group
4014 "U" gnus-group-unsubscribe-group
4015 "c" gnus-group-catchup-current
4016 "C" gnus-group-catchup-current-all
4017 "l" gnus-group-list-groups
4018 "L" gnus-group-list-all-groups
4020 "g" gnus-group-get-new-news
4021 "\M-g" gnus-group-get-new-news-this-group
4022 "R" gnus-group-restart
4023 "r" gnus-group-read-init-file
4024 "B" gnus-group-browse-foreign-server
4025 "b" gnus-group-check-bogus-groups
4026 "F" gnus-find-new-newsgroups
4027 "\C-c\C-d" gnus-group-describe-group
4028 "\M-d" gnus-group-describe-all-groups
4029 "\C-c\C-a" gnus-group-apropos
4030 "\C-c\M-\C-a" gnus-group-description-apropos
4031 "a" gnus-group-post-news
4032 "\ek" gnus-group-edit-local-kill
4033 "\eK" gnus-group-edit-global-kill
4034 "\C-k" gnus-group-kill-group
4035 "\C-y" gnus-group-yank-group
4036 "\C-w" gnus-group-kill-region
4037 "\C-x\C-t" gnus-group-transpose-groups
4038 "\C-c\C-l" gnus-group-list-killed
4039 "\C-c\C-x" gnus-group-expire-articles
4040 "\C-c\M-\C-x" gnus-group-expire-all-groups
4042 "s" gnus-group-save-newsrc
4043 "z" gnus-group-suspend
4044 "Z" gnus-group-clear-dribble
4047 "?" gnus-group-describe-briefly
4048 "\C-c\C-i" gnus-info-find-node
4049 "\M-e" gnus-group-edit-group-method
4050 "^" gnus-group-enter-server-mode
4051 gnus-mouse-2 gnus-mouse-pick-group
4052 "<" beginning-of-buffer
4055 "\C-c\C-s" gnus-group-sort-groups
4057 "\C-c\M-g" gnus-activate-all-groups
4058 "\M-&" gnus-group-universal-argument
4059 "#" gnus-group-mark-group
4060 "\M-#" gnus-group-unmark-group)
4062 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4063 "m" gnus-group-mark-group
4064 "u" gnus-group-unmark-group
4065 "w" gnus-group-mark-region
4066 "m" gnus-group-mark-buffer
4067 "r" gnus-group-mark-regexp
4068 "U" gnus-group-unmark-all-groups)
4070 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4071 "d" gnus-group-make-directory-group
4072 "h" gnus-group-make-help-group
4073 "a" gnus-group-make-archive-group
4074 "k" gnus-group-make-kiboze-group
4075 "m" gnus-group-make-group
4076 "E" gnus-group-edit-group
4077 "e" gnus-group-edit-group-method
4078 "p" gnus-group-edit-group-parameters
4079 "v" gnus-group-add-to-virtual
4080 "V" gnus-group-make-empty-virtual
4081 "D" gnus-group-enter-directory
4082 "f" gnus-group-make-doc-group
4083 "r" gnus-group-rename-group
4084 "\177" gnus-group-delete-group
4085 [delete] gnus-group-delete-group)
4087 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4088 "b" gnus-group-brew-soup
4089 "w" gnus-soup-save-areas
4090 "s" gnus-soup-send-replies
4091 "p" gnus-soup-pack-packet
4092 "r" nnsoup-pack-replies)
4094 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4095 "s" gnus-group-sort-groups
4096 "a" gnus-group-sort-groups-by-alphabet
4097 "u" gnus-group-sort-groups-by-unread
4098 "l" gnus-group-sort-groups-by-level
4099 "v" gnus-group-sort-groups-by-score
4100 "r" gnus-group-sort-groups-by-rank
4101 "m" gnus-group-sort-groups-by-method)
4103 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4104 "k" gnus-group-list-killed
4105 "z" gnus-group-list-zombies
4106 "s" gnus-group-list-groups
4107 "u" gnus-group-list-all-groups
4108 "A" gnus-group-list-active
4109 "a" gnus-group-apropos
4110 "d" gnus-group-description-apropos
4111 "m" gnus-group-list-matching
4112 "M" gnus-group-list-all-matching
4113 "l" gnus-group-list-level)
4115 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4116 "f" gnus-score-flush-cache)
4118 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4119 "f" gnus-group-fetch-faq)
4121 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4122 "l" gnus-group-set-current-level
4123 "t" gnus-group-unsubscribe-current-group
4124 "s" gnus-group-unsubscribe-group
4125 "k" gnus-group-kill-group
4126 "y" gnus-group-yank-group
4127 "w" gnus-group-kill-region
4128 "\C-k" gnus-group-kill-level
4129 "z" gnus-group-kill-all-zombies))
4131 (defun gnus-group-mode ()
4132 "Major mode for reading news.
4134 All normal editing commands are switched off.
4135 \\<gnus-group-mode-map>
4136 The group buffer lists (some of) the groups available. For instance,
4137 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4138 lists all zombie groups.
4140 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4141 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4143 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4145 The following commands are available:
4147 \\{gnus-group-mode-map}"
4149 (when (and menu-bar-mode
4150 (gnus-visual-p 'group-menu 'menu))
4151 (gnus-group-make-menu-bar))
4152 (kill-all-local-variables)
4153 (gnus-simplify-mode-line)
4154 (setq major-mode 'gnus-group-mode)
4155 (setq mode-name "Group")
4156 (gnus-group-set-mode-line)
4157 (setq mode-line-process nil)
4158 (use-local-map gnus-group-mode-map)
4159 (buffer-disable-undo (current-buffer))
4160 (setq truncate-lines t)
4161 (setq buffer-read-only t)
4162 (run-hooks 'gnus-group-mode-hook))
4164 (defun gnus-mouse-pick-group (e)
4165 "Enter the group under the mouse pointer."
4168 (gnus-group-read-group nil))
4170 ;; Look at LEVEL and find out what the level is really supposed to be.
4171 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4172 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4173 (defun gnus-group-default-level (&optional level number-or-nil)
4175 (gnus-group-use-permanent-levels
4176 (setq gnus-group-default-list-level
4177 (or level gnus-group-default-list-level))
4178 (or gnus-group-default-list-level gnus-level-subscribed))
4182 (or level gnus-group-default-list-level gnus-level-subscribed))))
4185 (defun gnus-slave-no-server (&optional arg)
4186 "Read network news as a slave, without connecting to local server"
4188 (gnus-no-server arg t))
4191 (defun gnus-no-server (&optional arg slave)
4193 If ARG is a positive number, Gnus will use that as the
4194 startup level. If ARG is nil, Gnus will be started at level 2.
4195 If ARG is non-nil and not a positive number, Gnus will
4196 prompt the user for the name of an NNTP server to use.
4197 As opposed to `gnus', this command will not connect to the local server."
4199 (let ((gnus-group-use-permanent-levels t))
4200 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4201 (make-local-variable 'gnus-group-use-permanent-levels)
4202 (setq gnus-group-use-permanent-levels t))
4205 (defun gnus-slave (&optional arg)
4206 "Read news as a slave."
4208 (gnus arg nil 'slave))
4211 (defun gnus-other-frame (&optional arg)
4212 "Pop up a frame to read news."
4214 (if (get-buffer gnus-group-buffer)
4215 (let ((pop-up-frames t))
4217 (select-frame (make-frame))
4221 (defun gnus (&optional arg dont-connect slave)
4223 If ARG is non-nil and a positive number, Gnus will use that as the
4224 startup level. If ARG is non-nil and not a positive number, Gnus will
4225 prompt the user for the name of an NNTP server to use."
4228 (if (get-buffer gnus-group-buffer)
4230 (switch-to-buffer gnus-group-buffer)
4231 (gnus-group-get-new-news))
4234 (nnheader-init-server-buffer)
4235 (gnus-read-init-file)
4236 (setq gnus-slave slave)
4238 (gnus-group-setup-buffer)
4239 (let ((buffer-read-only nil))
4241 (if (not gnus-inhibit-startup-message)
4243 (gnus-group-startup-message)
4246 (let ((level (and (numberp arg) (> arg 0) arg))
4252 (gnus-start-news-server (and arg (not level))))))
4253 (if (and (not dont-connect)
4256 (run-hooks 'gnus-startup-hook)
4257 ;; NNTP server is successfully open.
4259 ;; Find the current startup file name.
4260 (setq gnus-current-startup-file
4261 (gnus-make-newsrc-file gnus-startup-file))
4263 ;; Read the dribble file.
4264 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4266 ;; Allow using GroupLens predictions.
4267 (when gnus-use-grouplens
4269 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4271 (gnus-summary-make-display-table)
4272 ;; Do the actual startup.
4273 (gnus-setup-news nil level dont-connect)
4274 ;; Generate the group buffer.
4275 (gnus-group-list-groups level)
4276 (gnus-group-first-unread-group)
4277 (gnus-configure-windows 'group)
4278 (gnus-group-set-mode-line))))))
4280 (defun gnus-unload ()
4281 "Unload all Gnus features."
4283 (or (boundp 'load-history)
4284 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4285 (let ((history load-history)
4288 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4289 (setq feature (cdr (assq 'provide (car history))))
4290 (unload-feature feature 'force))
4291 (setq history (cdr history)))))
4293 (defun gnus-compile ()
4294 "Byte-compile the user-defined format specs."
4296 (let ((entries gnus-format-specs)
4297 entry gnus-tmp-func)
4299 (gnus-message 7 "Compiling format specs...")
4302 (setq entry (pop entries))
4303 (if (eq (car entry) 'version)
4304 (setq gnus-format-specs (delq entry gnus-format-specs))
4305 (when (and (listp (caddr entry))
4306 (not (eq 'byte-code (caaddr entry))))
4307 (fset 'gnus-tmp-func
4308 `(lambda () ,(caddr entry)))
4309 (byte-compile 'gnus-tmp-func)
4310 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4312 (push (cons 'version emacs-version) gnus-format-specs)
4314 (gnus-message 7 "Compiling user specs...done"))))
4316 (defun gnus-indent-rigidly (start end arg)
4317 "Indent rigidly using only spaces and no tabs."
4320 (narrow-to-region start end)
4321 (indent-rigidly start end arg)
4322 (goto-char (point-min))
4323 (while (search-forward "\t" nil t)
4324 (replace-match " " t t)))))
4326 (defun gnus-group-startup-message (&optional x y)
4327 "Insert startup message in current buffer."
4328 ;; Insert the message.
4333 _ ___ __ ___ __ _ ___
4352 ;; And then hack it.
4353 (gnus-indent-rigidly (point-min) (point-max)
4354 (/ (max (- (window-width) (or x 46)) 0) 2))
4355 (goto-char (point-min))
4357 (let* ((pheight (count-lines (point-min) (point-max)))
4358 (wheight (window-height))
4359 (rest (- wheight pheight)))
4360 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4362 (goto-char (point-min))
4363 (and (search-forward "Praxis" nil t)
4364 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4365 (goto-char (point-min))
4366 (let* ((mode-string (gnus-group-set-mode-line)))
4367 (setq mode-line-buffer-identification
4368 (list (concat gnus-version (substring (car mode-string) 4))))
4369 (set-buffer-modified-p t)))
4371 (defun gnus-group-setup-buffer ()
4372 (or (get-buffer gnus-group-buffer)
4374 (switch-to-buffer gnus-group-buffer)
4375 (gnus-add-current-to-buffer-list)
4377 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4379 (defun gnus-group-list-groups (&optional level unread lowest)
4380 "List newsgroups with level LEVEL or lower that have unread articles.
4381 Default is all subscribed groups.
4382 If argument UNREAD is non-nil, groups with no unread articles are also
4384 (interactive (list (if current-prefix-arg
4385 (prefix-numeric-value current-prefix-arg)
4387 (gnus-group-default-level nil t)
4388 gnus-group-default-list-level
4389 gnus-level-subscribed))))
4391 (setq level (car gnus-group-list-mode)
4392 unread (cdr gnus-group-list-mode)))
4393 (setq level (gnus-group-default-level level))
4394 (gnus-group-setup-buffer) ;May call from out of group buffer
4395 (gnus-update-format-specifications)
4396 (let ((case-fold-search nil)
4397 (props (text-properties-at (gnus-point-at-bol)))
4398 (group (gnus-group-group-name)))
4399 (set-buffer gnus-group-buffer)
4400 (funcall gnus-group-prepare-function level unread lowest)
4401 (if (zerop (buffer-size))
4402 (gnus-message 5 gnus-no-groups-message)
4403 (goto-char (point-max))
4404 (when (or (not gnus-group-goto-next-group-function)
4405 (not (funcall gnus-group-goto-next-group-function
4408 ;; Go to the first group with unread articles.
4409 (gnus-group-search-forward t)
4410 ;; Find the right group to put point on. If the current group
4411 ;; has disappeared in the new listing, try to find the next
4412 ;; one. If no next one can be found, just leave point at the
4413 ;; first newsgroup in the buffer.
4414 (if (not (gnus-goto-char
4416 (point-min) (point-max)
4417 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4418 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4420 (not (gnus-goto-char
4422 (point-min) (point-max) 'gnus-group
4424 (caar newsrc) gnus-active-hashtb)))))
4425 (setq newsrc (cdr newsrc)))
4426 (or newsrc (progn (goto-char (point-max))
4427 (forward-line -1)))))))
4428 ;; Adjust cursor point.
4429 (gnus-group-position-point))))
4431 (defun gnus-group-list-level (level &optional all)
4432 "List groups on LEVEL.
4433 If ALL (the prefix), also list groups that have no unread articles."
4434 (interactive "nList groups on level: \nP")
4435 (gnus-group-list-groups level all level))
4437 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4438 "List all newsgroups with unread articles of level LEVEL or lower.
4439 If ALL is non-nil, list groups that have no unread articles.
4440 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4441 If REGEXP, only list groups matching REGEXP."
4442 (set-buffer gnus-group-buffer)
4443 (let ((buffer-read-only nil)
4444 (newsrc (cdr gnus-newsrc-alist))
4445 (lowest (or lowest 1))
4446 info clevel unread group params)
4448 (if (< lowest gnus-level-zombie)
4449 ;; List living groups.
4451 (setq info (car newsrc)
4452 group (gnus-info-group info)
4453 params (gnus-info-params info)
4455 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4456 (and unread ; This group might be bogus
4458 (string-match regexp group))
4459 (<= (setq clevel (gnus-info-level info)) level)
4461 (or all ; We list all groups?
4462 (if (eq unread t) ; Unactivated?
4463 gnus-group-list-inactive-groups ; We list unactivated
4464 (> unread 0)) ; We list groups with unread articles
4465 (and gnus-list-groups-with-ticked-articles
4466 (cdr (assq 'tick (gnus-info-marks info))))
4467 ; And groups with tickeds
4468 ;; Check for permanent visibility.
4469 (and gnus-permanently-visible-groups
4470 (string-match gnus-permanently-visible-groups
4472 (memq 'visible params)
4473 (cdr (assq 'visible params)))
4474 (gnus-group-insert-group-line
4475 group (gnus-info-level info)
4476 (gnus-info-marks info) unread (gnus-info-method info)))))
4478 ;; List dead groups.
4479 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4480 (gnus-group-prepare-flat-list-dead
4481 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4482 gnus-level-zombie ?Z
4484 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4485 (gnus-group-prepare-flat-list-dead
4486 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4487 gnus-level-killed ?K regexp))
4489 (gnus-group-set-mode-line)
4490 (setq gnus-group-list-mode (cons level all))
4491 (run-hooks 'gnus-group-prepare-hook)))
4493 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4494 ;; List zombies and killed lists somewhat faster, which was
4495 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4496 ;; this by ignoring the group format specification altogether.
4499 ;; This loop is used when listing groups that match some
4502 (setq group (pop groups))
4503 (when (string-match regexp group)
4504 (add-text-properties
4505 (point) (prog1 (1+ (point))
4506 (insert " " mark " *: " group "\n"))
4507 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4509 'gnus-level level))))
4510 ;; This loop is used when listing all groups.
4512 (add-text-properties
4513 (point) (prog1 (1+ (point))
4514 (insert " " mark " *: "
4515 (setq group (pop groups)) "\n"))
4516 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4518 'gnus-level level))))))
4520 (defmacro gnus-group-real-name (group)
4521 "Find the real name of a foreign newsgroup."
4522 `(let ((gname ,group))
4523 (if (string-match ":[^:]+$" gname)
4524 (substring gname (1+ (match-beginning 0)))
4527 (defsubst gnus-server-add-address (method)
4528 (let ((method-name (symbol-name (car method))))
4529 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4530 (not (assq (intern (concat method-name "-address")) method)))
4531 (append method (list (list (intern (concat method-name "-address"))
4535 (defsubst gnus-server-get-method (group method)
4536 ;; Input either a server name, and extended server name, or a
4537 ;; select method, and return a select method.
4538 (cond ((stringp method)
4539 (gnus-server-to-method method))
4540 ((and (stringp (car method)) group)
4541 (gnus-server-extend-method group method))
4543 (gnus-server-add-address method))))
4545 (defun gnus-server-to-method (server)
4546 "Map virtual server names to select methods."
4548 ;; Perhaps this is the native server?
4549 (and (equal server "native") gnus-select-method)
4550 ;; It should be in the server alist.
4551 (cdr (assoc server gnus-server-alist))
4552 ;; If not, we look through all the opened server
4553 ;; to see whether we can find it there.
4554 (let ((opened gnus-opened-servers))
4556 (not (equal server (format "%s:%s" (caaar opened)
4561 (defmacro gnus-method-equal (ss1 ss2)
4562 "Say whether two servers are equal."
4566 (and (= (length s1) (length s2))
4568 (while (and s1 (member (car s1) s2))
4572 (defun gnus-server-equal (m1 m2)
4573 "Say whether two methods are equal."
4574 (let ((m1 (cond ((null m1) gnus-select-method)
4575 ((stringp m1) (gnus-server-to-method m1))
4577 (m2 (cond ((null m2) gnus-select-method)
4578 ((stringp m2) (gnus-server-to-method m2))
4580 (gnus-method-equal m1 m2)))
4582 (defun gnus-group-prefixed-name (group method)
4583 "Return the whole name from GROUP and METHOD."
4584 (and (stringp method) (setq method (gnus-server-to-method method)))
4585 (concat (format "%s" (car method))
4587 (or (assoc (format "%s" (car method))
4588 (gnus-methods-using 'address))
4589 (gnus-server-equal method gnus-message-archive-method))
4591 (not (string= (nth 1 method) "")))
4592 (concat "+" (nth 1 method)))
4595 (defun gnus-group-real-prefix (group)
4596 "Return the prefix of the current group name."
4597 (if (string-match "^[^:]+:" group)
4598 (substring group 0 (match-end 0))
4601 (defun gnus-group-method (group)
4602 "Return the server or method used for selecting GROUP."
4603 (let ((prefix (gnus-group-real-prefix group)))
4604 (if (equal prefix "")
4606 (let ((servers gnus-opened-servers)
4608 backend possible found)
4609 (if (string-match "^[^\\+]+\\+" prefix)
4610 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4611 server (substring prefix (match-end 0) (1- (length prefix))))
4612 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4614 (when (eq (caaar servers) backend)
4615 (setq possible (caar servers))
4616 (when (equal (cadaar servers) server)
4617 (setq found (caar servers))))
4619 (or (car (rassoc found gnus-server-alist))
4621 (car (rassoc possible gnus-server-alist))
4623 (list backend server))))))
4625 (defsubst gnus-secondary-method-p (method)
4626 "Return whether METHOD is a secondary select method."
4627 (let ((methods gnus-secondary-select-methods)
4628 (gmethod (gnus-server-get-method nil method)))
4630 (not (equal (gnus-server-get-method nil (car methods))
4632 (setq methods (cdr methods)))
4635 (defun gnus-group-foreign-p (group)
4636 "Say whether a group is foreign or not."
4637 (and (not (gnus-group-native-p group))
4638 (not (gnus-group-secondary-p group))))
4640 (defun gnus-group-native-p (group)
4641 "Say whether the group is native or not."
4642 (not (string-match ":" group)))
4644 (defun gnus-group-secondary-p (group)
4645 "Say whether the group is secondary or not."
4646 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4648 (defun gnus-group-get-parameter (group &optional symbol)
4649 "Returns the group parameters for GROUP.
4650 If SYMBOL, return the value of that symbol in the group parameters."
4651 (let ((params (gnus-info-params (gnus-get-info group))))
4653 (gnus-group-parameter-value params symbol)
4656 (defun gnus-group-parameter-value (params symbol)
4657 "Return the value of SYMBOL in group PARAMS."
4658 (or (car (memq symbol params)) ; It's either a simple symbol
4659 (cdr (assq symbol params)))) ; or a cons.
4661 (defun gnus-group-add-parameter (group param)
4662 "Add parameter PARAM to GROUP."
4663 (let ((info (gnus-get-info group)))
4665 () ; This is a dead group. We just ignore it.
4666 ;; Cons the new param to the old one and update.
4667 (gnus-group-set-info (cons param (gnus-info-params info))
4670 (defun gnus-group-set-parameter (group name value)
4671 "Set parameter NAME to VALUE in GROUP."
4672 (let ((info (gnus-get-info group)))
4674 () ; This is a dead group. We just ignore it.
4675 (let ((old-params (gnus-info-params info))
4676 (new-params (list (cons name value))))
4678 (if (or (not (listp (car old-params)))
4679 (not (eq (caar old-params) name)))
4680 (setq new-params (append new-params (list (car old-params)))))
4681 (setq old-params (cdr old-params)))
4682 (gnus-group-set-info new-params group 'params)))))
4684 (defun gnus-group-add-score (group &optional score)
4685 "Add SCORE to the GROUP score.
4686 If SCORE is nil, add 1 to the score of GROUP."
4687 (let ((info (gnus-get-info group)))
4689 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4691 (defun gnus-summary-bubble-group ()
4692 "Increase the score of the current group.
4693 This is a handy function to add to `gnus-summary-exit-hook' to
4694 increase the score of each group you read."
4695 (gnus-group-add-score gnus-newsgroup-name))
4697 (defun gnus-group-set-info (info &optional method-only-group part)
4698 (let* ((entry (gnus-gethash
4699 (or method-only-group (gnus-info-group info))
4700 gnus-newsrc-hashtb))
4702 (info (if method-only-group (nth 2 entry) info))
4704 (when method-only-group
4706 (error "Trying to change non-existent group %s" method-only-group))
4707 ;; We have received parts of the actual group info - either the
4708 ;; select method or the group parameters. We first check
4709 ;; whether we have to extend the info, and if so, do that.
4710 (let ((len (length info))
4711 (total (if (eq part 'method) 5 6)))
4713 (setcdr (nthcdr (1- len) info)
4714 (make-list (- total len) nil)))
4715 ;; Then we enter the new info.
4716 (setcar (nthcdr (1- total) info) part-info)))
4718 ;; This is a new group, so we just create it.
4720 (set-buffer gnus-group-buffer)
4721 (setq method (gnus-info-method info))
4722 (when (gnus-server-equal method "native")
4725 ;; It's a foreign group...
4726 (gnus-group-make-group
4727 (gnus-group-real-name (gnus-info-group info))
4728 (if (stringp method) method
4729 (prin1-to-string (car method)))
4731 (nth 1 (gnus-info-method info))))
4732 ;; It's a native group.
4733 (gnus-group-make-group (gnus-info-group info)))
4734 (gnus-message 6 "Note: New group created")
4736 (gnus-gethash (gnus-group-prefixed-name
4737 (gnus-group-real-name (gnus-info-group info))
4738 (or (gnus-info-method info) gnus-select-method))
4739 gnus-newsrc-hashtb))))
4740 ;; Whether it was a new group or not, we now have the entry, so we
4741 ;; can do the update.
4744 (setcar (nthcdr 2 entry) info)
4745 (when (and (not (eq (car entry) t))
4746 (gnus-active (gnus-info-group info)))
4747 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4748 (error "No such group: %s" (gnus-info-group info)))))
4750 (defun gnus-group-set-method-info (group select-method)
4751 (gnus-group-set-info select-method group 'method))
4753 (defun gnus-group-set-params-info (group params)
4754 (gnus-group-set-info params group 'params))
4756 (defun gnus-group-update-group-line ()
4757 "Update the current line in the group buffer."
4758 (let* ((buffer-read-only nil)
4759 (group (gnus-group-group-name))
4760 (gnus-group-indentation (gnus-group-group-indentation))
4761 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4763 (not (gnus-ephemeral-group-p group))
4765 (concat "(gnus-group-set-info '"
4766 (prin1-to-string (nth 2 entry)) ")")))
4768 (gnus-group-insert-group-line-info group)
4770 (gnus-group-position-point)))
4772 (defun gnus-group-insert-group-line-info (group)
4773 "Insert GROUP on the current line."
4774 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4778 ;; (Un)subscribed group.
4779 (setq info (nth 2 entry))
4780 (gnus-group-insert-group-line
4781 group (gnus-info-level info) (gnus-info-marks info)
4782 (or (car entry) t) (gnus-info-method info)))
4783 ;; This group is dead.
4784 (gnus-group-insert-group-line
4786 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4788 (if (setq active (gnus-active group))
4789 (- (1+ (cdr active)) (car active)) 0)
4792 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4793 gnus-tmp-marked number
4795 "Insert a group line in the group buffer."
4796 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4797 (gnus-tmp-number-total
4799 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4801 (gnus-tmp-number-of-unread
4802 (if (numberp number) (int-to-string (max 0 number))
4804 (gnus-tmp-number-of-read
4805 (if (numberp number)
4806 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4808 (gnus-tmp-subscribed
4809 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4810 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4811 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4813 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4814 (gnus-tmp-newsgroup-description
4815 (if gnus-description-hashtb
4816 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4819 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4820 (gnus-tmp-moderated-string
4821 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4823 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4824 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4825 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4826 (gnus-tmp-news-method-string
4828 (format "(%s:%s)" (car gnus-tmp-method)
4829 (cadr gnus-tmp-method)) ""))
4830 (gnus-tmp-marked-mark
4831 (if (and (numberp number)
4833 (cdr (assq 'tick gnus-tmp-marked)))
4835 (gnus-tmp-process-marked
4836 (if (member gnus-tmp-group gnus-group-marked)
4837 gnus-process-mark ? ))
4839 (or (and gnus-use-grouplens
4840 (bbb-grouplens-group-p gnus-tmp-group))
4842 (buffer-read-only nil)
4843 header gnus-tmp-header) ; passed as parameter to user-funcs.
4845 (add-text-properties
4849 (eval gnus-group-line-format-spec))
4850 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4851 gnus-unread ,(if (numberp number)
4852 (string-to-int gnus-tmp-number-of-unread)
4854 gnus-marked ,gnus-tmp-marked-mark
4855 gnus-indentation ,gnus-group-indentation
4856 gnus-level ,gnus-tmp-level))
4857 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4859 (run-hooks 'gnus-group-update-hook)
4861 ;; Allow XEmacs to remove front-sticky text properties.
4862 (gnus-group-remove-excess-properties)))
4864 (defun gnus-group-update-group (group &optional visible-only)
4865 "Update all lines where GROUP appear.
4866 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4869 (set-buffer gnus-group-buffer)
4870 ;; The buffer may be narrowed.
4873 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4875 found buffer-read-only)
4876 ;; Enter the current status into the dribble buffer.
4877 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4878 (if (and entry (not (gnus-ephemeral-group-p group)))
4880 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4882 ;; Find all group instances. If topics are in use, each group
4883 ;; may be listed in more than once.
4884 (while (setq loc (text-property-any
4885 loc (point-max) 'gnus-group ident))
4888 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4890 (gnus-group-insert-group-line-info group))
4891 (setq loc (1+ loc)))
4892 (unless (or found visible-only)
4893 ;; No such line in the buffer, find out where it's supposed to
4894 ;; go, and insert it there (or at the end of the buffer).
4895 (if gnus-goto-missing-group-function
4896 (funcall gnus-goto-missing-group-function group)
4897 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4898 (while (and entry (car entry)
4902 (point-min) (point-max)
4903 'gnus-group (gnus-intern-safe
4904 (caar entry) gnus-active-hashtb)))))
4905 (setq entry (cdr entry)))
4906 (or entry (goto-char (point-max)))))
4907 ;; Finally insert the line.
4908 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4909 (gnus-group-insert-group-line-info group)))
4910 (gnus-group-set-mode-line)))))
4912 (defun gnus-group-set-mode-line ()
4913 (when (memq 'group gnus-updated-mode-lines)
4914 (let* ((gformat (or gnus-group-mode-line-format-spec
4915 (setq gnus-group-mode-line-format-spec
4917 gnus-group-mode-line-format
4918 gnus-group-mode-line-format-alist))))
4919 (gnus-tmp-news-server (cadr gnus-select-method))
4920 (gnus-tmp-news-method (car gnus-select-method))
4922 gnus-tmp-header ;Dummy binding for user-defined formats
4923 ;; Get the resulting string.
4924 (mode-string (eval gformat)))
4925 ;; If the line is too long, we chop it off.
4926 (when (> (length mode-string) max-len)
4927 (setq mode-string (substring mode-string 0 (- max-len 4))))
4929 (setq mode-line-buffer-identification (list mode-string))
4930 (set-buffer-modified-p t)))))
4932 (defun gnus-group-group-name ()
4933 "Get the name of the newsgroup on the current line."
4934 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4935 (and group (symbol-name group))))
4937 (defun gnus-group-group-level ()
4938 "Get the level of the newsgroup on the current line."
4939 (get-text-property (gnus-point-at-bol) 'gnus-level))
4941 (defun gnus-group-group-indentation ()
4942 "Get the indentation of the newsgroup on the current line."
4943 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
4944 (and gnus-group-indentation-function
4945 (funcall gnus-group-indentation-function))
4948 (defun gnus-group-group-unread ()
4949 "Get the number of unread articles of the newsgroup on the current line."
4950 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4952 (defun gnus-group-search-forward (&optional backward all level first-too)
4953 "Find the next newsgroup with unread articles.
4954 If BACKWARD is non-nil, find the previous newsgroup instead.
4955 If ALL is non-nil, just find any newsgroup.
4956 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4958 If FIRST-TOO, the current line is also eligible as a target."
4959 (let ((way (if backward -1 1))
4960 (low gnus-level-killed)
4963 (if (and backward (progn (beginning-of-line)) (bobp))
4965 (or first-too (forward-line way))
4973 (get-text-property (point) 'gnus-unread)))
4974 (and (numberp unread) (> unread 0)))
4975 (setq lev (get-text-property (point)
4977 (<= lev gnus-level-subscribed)))
4979 (and (setq lev (get-text-property (point)
4988 (zerop (forward-line way)))))
4990 (progn (gnus-group-position-point) t)
4991 (goto-char (or pos beg))
4994 ;;; Gnus group mode commands
4998 (defun gnus-group-mark-group (n &optional unmark no-advance)
4999 "Mark the current group."
5001 (let ((buffer-read-only nil)
5005 (setq group (gnus-group-group-name))
5009 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5014 (setq gnus-group-marked (delete group gnus-group-marked)))
5016 (setq gnus-group-marked
5017 (cons group (delete group gnus-group-marked))))
5019 (or no-advance (zerop (gnus-group-next-group 1))))
5021 (gnus-summary-position-point)
5024 (defun gnus-group-unmark-group (n)
5025 "Remove the mark from the current group."
5027 (gnus-group-mark-group n 'unmark)
5028 (gnus-group-position-point))
5030 (defun gnus-group-unmark-all-groups ()
5031 "Unmark all groups."
5033 (let ((groups gnus-group-marked))
5036 (gnus-group-remove-mark (pop groups)))))
5037 (gnus-group-position-point))
5039 (defun gnus-group-mark-region (unmark beg end)
5040 "Mark all groups between point and mark.
5041 If UNMARK, remove the mark instead."
5042 (interactive "P\nr")
5043 (let ((num (count-lines beg end)))
5046 (- num (gnus-group-mark-group num unmark)))))
5048 (defun gnus-group-mark-buffer (&optional unmark)
5049 "Mark all groups in the buffer.
5050 If UNMARK, remove the mark instead."
5052 (gnus-group-mark-region unmark (point-min) (point-max)))
5054 (defun gnus-group-mark-regexp (regexp)
5055 "Mark all groups that match some regexp."
5056 (interactive "sMark (regexp): ")
5057 (let ((alist (cdr gnus-newsrc-alist))
5060 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5061 (gnus-group-set-mark group))))
5062 (gnus-group-position-point))
5064 (defun gnus-group-remove-mark (group)
5065 "Remove the process mark from GROUP and move point there.
5066 Return nil if the group isn't displayed."
5067 (if (gnus-group-goto-group group)
5069 (gnus-group-mark-group 1 'unmark t)
5071 (setq gnus-group-marked
5072 (delete group gnus-group-marked))
5075 (defun gnus-group-set-mark (group)
5076 "Set the process mark on GROUP."
5077 (if (gnus-group-goto-group group)
5079 (gnus-group-mark-group 1 nil t))
5080 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5082 (defun gnus-group-universal-argument (arg &optional groups func)
5083 "Perform any command on all groups accoring to the process/prefix convention."
5085 (let ((groups (or groups (gnus-group-process-prefix arg)))
5087 (if (eq (setq func (or func
5090 (substitute-command-keys
5091 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5094 (message "Undefined key")
5097 (gnus-group-remove-mark (setq group (pop groups)))
5098 (command-execute func))))
5099 (gnus-group-position-point))
5101 (defun gnus-group-process-prefix (n)
5102 "Return a list of groups to work on.
5103 Take into consideration N (the prefix) and the list of marked groups."
5106 (setq n (prefix-numeric-value n))
5107 ;; There is a prefix, so we return a list of the N next
5109 (let ((way (if (< n 0) -1 1))
5114 (setq group (gnus-group-group-name)))
5115 (setq groups (cons group groups))
5117 (gnus-group-next-group way)))
5119 ((and (boundp 'transient-mark-mode)
5122 ;; Work on the region between point and mark.
5123 (let ((max (max (point) (mark)))
5126 (goto-char (min (point) (mark)))
5129 (push (gnus-group-group-name) groups)
5130 (zerop (gnus-group-next-group 1))
5132 (nreverse groups))))
5134 ;; No prefix, but a list of marked articles.
5135 (reverse gnus-group-marked))
5137 ;; Neither marked articles or a prefix, so we return the
5139 (let ((group (gnus-group-group-name)))
5140 (and group (list group))))))
5142 ;; Selecting groups.
5144 (defun gnus-group-read-group (&optional all no-article group)
5145 "Read news in this newsgroup.
5146 If the prefix argument ALL is non-nil, already read articles become
5147 readable. IF ALL is a number, fetch this number of articles. If the
5148 optional argument NO-ARTICLE is non-nil, no article will be
5149 auto-selected upon group entry. If GROUP is non-nil, fetch that
5152 (let ((group (or group (gnus-group-group-name)))
5153 number active marked entry)
5154 (or group (error "No group on current line"))
5155 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5156 group gnus-newsrc-hashtb)))))
5157 ;; This group might be a dead group. In that case we have to get
5158 ;; the number of unread articles from `gnus-active-hashtb'.
5160 (cond ((numberp all) all)
5162 ((setq active (gnus-active group))
5163 (- (1+ (cdr active)) (car active)))))
5164 (gnus-summary-read-group
5165 group (or all (and (numberp number)
5166 (zerop (+ number (length (cdr (assq 'tick marked)))
5167 (length (cdr (assq 'dormant marked)))))))
5170 (defun gnus-group-select-group (&optional all)
5171 "Select this newsgroup.
5172 No article is selected automatically.
5173 If ALL is non-nil, already read articles become readable.
5174 If ALL is a number, fetch this number of articles."
5176 (gnus-group-read-group all t))
5178 (defun gnus-group-quick-select-group (&optional all)
5179 "Select the current group \"quickly\".
5180 This means that no highlighting or scoring will be performed."
5183 gnus-score-find-score-files-function
5184 gnus-apply-kill-hook
5185 gnus-summary-expunge-below)
5186 (gnus-group-read-group all t)))
5188 (defun gnus-group-visible-select-group (&optional all)
5189 "Select the current group without hiding any articles."
5191 (let ((gnus-inhibit-limiting t))
5192 (gnus-group-read-group all t)))
5195 (defun gnus-fetch-group (group)
5196 "Start Gnus if necessary and enter GROUP.
5197 Returns whether the fetching was successful or not."
5198 (interactive "sGroup name: ")
5199 (or (get-buffer gnus-group-buffer)
5201 (gnus-group-read-group nil nil group))
5203 ;; Enter a group that is not in the group buffer. Non-nil is returned
5204 ;; if selection was successful.
5205 (defun gnus-group-read-ephemeral-group
5206 (group method &optional activate quit-config)
5207 (let ((group (if (gnus-group-foreign-p group) group
5208 (gnus-group-prefixed-name group method))))
5211 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5212 ((quit-config . ,(if quit-config quit-config
5213 (cons (current-buffer) 'summary))))))
5215 (set-buffer gnus-group-buffer)
5216 (or (gnus-check-server method)
5217 (error "Unable to contact server: %s" (gnus-status-message method)))
5218 (if activate (or (gnus-request-group group)
5219 (error "Couldn't request group")))
5221 (gnus-group-read-group t t group)
5225 (defun gnus-group-jump-to-group (group)
5226 "Jump to newsgroup GROUP."
5228 (list (completing-read
5229 "Group: " gnus-active-hashtb nil
5230 (memq gnus-select-method gnus-have-read-active-file))))
5232 (if (equal group "")
5233 (error "Empty group name"))
5235 (let ((b (text-property-any
5236 (point-min) (point-max)
5237 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5238 (unless (gnus-ephemeral-group-p group)
5240 ;; Either go to the line in the group buffer...
5242 ;; ... or insert the line.
5245 (gnus-activate-group group)
5246 (error "%s error: %s" group (gnus-status-message group)))
5248 (gnus-group-update-group group)
5249 (goto-char (text-property-any
5250 (point-min) (point-max)
5251 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5252 ;; Adjust cursor point.
5253 (gnus-group-position-point)))
5255 (defun gnus-group-goto-group (group)
5256 "Goto to newsgroup GROUP."
5258 (let ((b (text-property-any (point-min) (point-max)
5259 'gnus-group (gnus-intern-safe
5260 group gnus-active-hashtb))))
5261 (and b (goto-char b)))))
5263 (defun gnus-group-next-group (n)
5264 "Go to next N'th newsgroup.
5265 If N is negative, search backward instead.
5266 Returns the difference between N and the number of skips actually
5269 (gnus-group-next-unread-group n t))
5271 (defun gnus-group-next-unread-group (n &optional all level)
5272 "Go to next N'th unread newsgroup.
5273 If N is negative, search backward instead.
5274 If ALL is non-nil, choose any newsgroup, unread or not.
5275 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5276 such group can be found, the next group with a level higher than
5278 Returns the difference between N and the number of skips actually
5281 (let ((backward (< n 0))
5284 (gnus-group-search-forward
5285 backward (or (not gnus-group-goto-unread) all) level))
5287 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5288 (if level " on this level or higher" "")))
5291 (defun gnus-group-prev-group (n)
5292 "Go to previous N'th newsgroup.
5293 Returns the difference between N and the number of skips actually
5296 (gnus-group-next-unread-group (- n) t))
5298 (defun gnus-group-prev-unread-group (n)
5299 "Go to previous N'th unread newsgroup.
5300 Returns the difference between N and the number of skips actually
5303 (gnus-group-next-unread-group (- n)))
5305 (defun gnus-group-next-unread-group-same-level (n)
5306 "Go to next N'th unread newsgroup on the same level.
5307 If N is negative, search backward instead.
5308 Returns the difference between N and the number of skips actually
5311 (gnus-group-next-unread-group n t (gnus-group-group-level))
5312 (gnus-group-position-point))
5314 (defun gnus-group-prev-unread-group-same-level (n)
5315 "Go to next N'th unread newsgroup on the same level.
5316 Returns the difference between N and the number of skips actually
5319 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5320 (gnus-group-position-point))
5322 (defun gnus-group-best-unread-group (&optional exclude-group)
5323 "Go to the group with the highest level.
5324 If EXCLUDE-GROUP, do not go to that group."
5326 (goto-char (point-min))
5330 (setq unread (get-text-property (point) 'gnus-unread))
5331 (if (and (numberp unread) (> unread 0))
5333 (if (and (get-text-property (point) 'gnus-level)
5334 (< (get-text-property (point) 'gnus-level) best)
5335 (or (not exclude-group)
5336 (not (equal exclude-group (gnus-group-group-name)))))
5338 (setq best (get-text-property (point) 'gnus-level))
5339 (setq best-point (point))))))
5341 (if best-point (goto-char best-point))
5342 (gnus-summary-position-point)
5343 (and best-point (gnus-group-group-name))))
5345 (defun gnus-group-first-unread-group ()
5346 "Go to the first group with unread articles."
5349 (let ((opoint (point))
5351 (goto-char (point-min))
5352 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5353 (and (numberp unread) ; Not a topic.
5354 (not (zerop unread))) ; Has unread articles.
5355 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5358 nil)) ; Not success.
5359 (gnus-group-position-point)))
5361 (defun gnus-group-enter-server-mode ()
5362 "Jump to the server buffer."
5364 (gnus-enter-server-buffer))
5366 (defun gnus-group-make-group (name &optional method address)
5367 "Add a new newsgroup.
5368 The user will be prompted for a NAME, for a select METHOD, and an
5372 (read-string "Group name: ")
5375 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5377 (cond ((assoc method gnus-valid-select-methods)
5379 (if (memq 'prompt-address
5380 (assoc method gnus-valid-select-methods))
5381 (read-string "Address: ")
5383 ((assoc method gnus-server-alist)
5386 (list method ""))))))
5389 (set-buffer gnus-group-buffer)
5390 (let* ((meth (and method (if address (list (intern method) address)
5392 (nname (if method (gnus-group-prefixed-name name meth) name))
5394 (and (gnus-gethash nname gnus-newsrc-hashtb)
5395 (error "Group %s already exists" nname))
5396 (gnus-group-change-level
5397 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5398 gnus-level-default-subscribed gnus-level-killed
5399 (and (gnus-group-group-name)
5400 (gnus-gethash (gnus-group-group-name)
5401 gnus-newsrc-hashtb))
5403 (gnus-set-active nname (cons 1 0))
5404 (or (gnus-ephemeral-group-p name)
5406 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5407 (gnus-group-insert-group-line-info nname)
5409 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5411 gnus-valid-select-methods)
5413 (gnus-check-server meth)
5414 (and (gnus-check-backend-function 'request-create-group nname)
5415 (gnus-request-create-group nname))
5418 (defun gnus-group-delete-group (group &optional force)
5419 "Delete the current group.
5420 If FORCE (the prefix) is non-nil, all the articles in the group will
5421 be deleted. This is \"deleted\" as in \"removed forever from the face
5422 of the Earth\". There is no undo."
5424 (list (gnus-group-group-name)
5425 current-prefix-arg))
5426 (or group (error "No group to rename"))
5427 (or (gnus-check-backend-function 'request-delete-group group)
5428 (error "This backend does not support group deletion"))
5430 (if (not (gnus-yes-or-no-p
5432 "Do you really want to delete %s%s? "
5433 group (if force " and all its contents" ""))))
5435 (gnus-message 6 "Deleting group %s..." group)
5436 (if (not (gnus-request-delete-group group force))
5438 (gnus-message 3 "Couldn't delete group %s" group)
5440 (gnus-message 6 "Deleting group %s...done" group)
5441 (gnus-group-goto-group group)
5442 (gnus-group-kill-group 1 t)
5443 (gnus-sethash group nil gnus-active-hashtb)
5445 (gnus-group-position-point)))
5447 (defun gnus-group-rename-group (group new-name)
5450 (gnus-group-group-name)
5452 (or (gnus-check-backend-function
5453 'request-rename-group (gnus-group-group-name))
5454 (error "This backend does not support renaming groups"))
5455 (read-string "New group name: "))))
5457 (or (gnus-check-backend-function 'request-rename-group group)
5458 (error "This backend does not support renaming groups"))
5460 (or group (error "No group to rename"))
5461 (and (string-match "^[ \t]*$" new-name)
5462 (error "Not a valid group name"))
5464 ;; We find the proper prefixed name.
5466 (gnus-group-prefixed-name
5467 (gnus-group-real-name new-name)
5468 (gnus-info-method (gnus-get-info group))))
5470 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5472 (if (not (gnus-request-rename-group group new-name))
5474 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5476 ;; We rename the group internally by killing it...
5477 (gnus-group-goto-group group)
5478 (gnus-group-kill-group)
5479 ;; ... changing its name ...
5480 (setcar (cdar gnus-list-of-killed-groups) new-name)
5481 ;; ... and then yanking it. Magic!
5482 (gnus-group-yank-group)
5483 (gnus-set-active new-name (gnus-active group))
5484 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5486 (gnus-group-position-point)))
5488 (defun gnus-group-edit-group (group &optional part)
5489 "Edit the group on the current line."
5490 (interactive (list (gnus-group-group-name)))
5491 (let* ((part (or part 'info))
5492 (done-func `(lambda ()
5493 "Exit editing mode and update the information."
5495 (gnus-group-edit-group-done ',part ,group)))
5496 (winconf (current-window-configuration))
5498 (or group (error "No group on current line"))
5499 (or (setq info (gnus-get-info group))
5500 (error "Killed group; can't be edited"))
5501 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5502 (gnus-configure-windows 'edit-group)
5503 (gnus-add-current-to-buffer-list)
5505 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5506 (use-local-map (copy-keymap emacs-lisp-mode-map))
5507 (local-set-key "\C-c\C-c" done-func)
5508 (make-local-variable 'gnus-prev-winconf)
5509 (setq gnus-prev-winconf winconf)
5514 ";; Type `C-c C-c' after editing the select method.\n\n")
5516 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5518 ";; Type `C-c C-c' after editing the group info.\n\n")))
5521 (cond ((eq part 'method)
5522 (or (gnus-info-method info) "native"))
5524 (gnus-info-params info))
5528 (defun gnus-group-edit-group-method (group)
5529 "Edit the select method of GROUP."
5530 (interactive (list (gnus-group-group-name)))
5531 (gnus-group-edit-group group 'method))
5533 (defun gnus-group-edit-group-parameters (group)
5534 "Edit the group parameters of GROUP."
5535 (interactive (list (gnus-group-group-name)))
5536 (gnus-group-edit-group group 'params))
5538 (defun gnus-group-edit-group-done (part group)
5539 "Get info from buffer, update variables and jump to the group buffer."
5540 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5541 (goto-char (point-min))
5542 (let* ((form (read (current-buffer)))
5543 (winconf gnus-prev-winconf)
5544 (method (cond ((eq part 'info) (nth 4 form))
5545 ((eq part 'method) form)
5547 (info (cond ((eq part 'info) form)
5548 ((eq part 'method) (gnus-get-info group))
5551 (if (or (not method)
5553 gnus-select-method method))
5554 (gnus-group-real-name (car info))
5555 (gnus-group-prefixed-name
5556 (gnus-group-real-name (car info)) method))
5558 (when (and new-group
5559 (not (equal new-group group)))
5560 (when (gnus-group-goto-group group)
5561 (gnus-group-kill-group 1))
5562 (gnus-activate-group new-group))
5564 (if (and info new-group)
5566 (setq info (gnus-copy-sequence info))
5567 (setcar info new-group)
5568 (unless (gnus-server-equal method "native")
5569 (unless (nthcdr 3 info)
5570 (nconc info (list nil nil)))
5571 (unless (nthcdr 4 info)
5572 (nconc info (list nil)))
5573 (gnus-info-set-method info method))
5574 (gnus-group-set-info info))
5575 (gnus-group-set-info form (or new-group group) part))
5576 (kill-buffer (current-buffer))
5577 (and winconf (set-window-configuration winconf))
5578 (set-buffer gnus-group-buffer)
5579 (gnus-group-update-group (or new-group group))
5580 (gnus-group-position-point)))
5582 (defun gnus-group-make-help-group ()
5583 "Create the Gnus documentation group."
5585 (let ((path load-path)
5586 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5588 (and (gnus-gethash name gnus-newsrc-hashtb)
5589 (error "Documentation group already exists"))
5591 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5593 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5595 (setq file (concat (file-name-directory
5596 (directory-file-name dir))
5597 "etc/gnus-tut.txt"))))
5600 (message "Couldn't find doc group")
5601 (gnus-group-make-group
5602 (gnus-group-real-name name)
5603 (list 'nndoc "gnus-help"
5604 (list 'nndoc-address file)
5605 (list 'nndoc-article-type 'mbox)))))
5606 (gnus-group-position-point))
5608 (defun gnus-group-make-doc-group (file type)
5609 "Create a group that uses a single file as the source."
5611 (list (read-file-name "File name: ")
5612 (and current-prefix-arg 'ask)))
5613 (when (eq type 'ask)
5618 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5620 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5621 ((= char ?b) 'babyl)
5622 ((= char ?d) 'digest)
5623 ((= char ?f) 'forward)
5625 (t (setq err (format "%c unknown. " char))
5628 (let* ((file (expand-file-name file))
5629 (name (gnus-generate-new-group-name
5630 (gnus-group-prefixed-name
5631 (file-name-nondirectory file) '(nndoc "")))))
5632 (gnus-group-make-group
5633 (gnus-group-real-name name)
5634 (list 'nndoc (file-name-nondirectory file)
5635 (list 'nndoc-address file)
5636 (list 'nndoc-article-type (or type 'guess))))
5638 (gnus-group-position-point)))
5640 (defun gnus-group-make-archive-group (&optional all)
5641 "Create the (ding) Gnus archive group of the most recent articles.
5642 Given a prefix, create a full group."
5644 (let ((group (gnus-group-prefixed-name
5645 (if all "ding.archives" "ding.recent") '(nndir ""))))
5646 (and (gnus-gethash group gnus-newsrc-hashtb)
5647 (error "Archive group already exists"))
5648 (gnus-group-make-group
5649 (gnus-group-real-name group)
5650 (list 'nndir (if all "hpc" "edu")
5651 (list 'nndir-directory
5652 (if all gnus-group-archive-directory
5653 gnus-group-recent-archive-directory)))))
5655 (gnus-group-position-point))
5657 (defun gnus-group-make-directory-group (dir)
5658 "Create an nndir group.
5659 The user will be prompted for a directory. The contents of this
5660 directory will be used as a newsgroup. The directory should contain
5661 mail messages or news articles in files that have numeric names."
5663 (list (read-file-name "Create group from directory: ")))
5664 (or (file-exists-p dir) (error "No such directory"))
5665 (or (file-directory-p dir) (error "Not a directory"))
5669 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5671 (gnus-group-prefixed-name
5672 (concat (file-name-as-directory (directory-file-name dir))
5675 (setq ext (format "<%d>" (setq i (1+ i)))))
5676 (gnus-group-make-group
5677 (gnus-group-real-name group)
5678 (list 'nndir group (list 'nndir-directory dir))))
5680 (gnus-group-position-point))
5682 (defun gnus-group-make-kiboze-group (group address scores)
5683 "Create an nnkiboze group.
5684 The user will be prompted for a name, a regexp to match groups, and
5685 score file entries for articles to include in the group."
5688 (read-string "nnkiboze group name: ")
5689 (read-string "Source groups (regexp): ")
5690 (let ((headers (mapcar (lambda (group) (list group))
5691 '("subject" "from" "number" "date" "message-id"
5692 "references" "chars" "lines" "xref"
5693 "followup" "all" "body" "head")))
5694 scores header regexp regexps)
5695 (while (not (equal "" (setq header (completing-read
5696 "Match on header: " headers nil t))))
5698 (while (not (equal "" (setq regexp (read-string
5699 (format "Match on %s (string): "
5701 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5702 (setq scores (cons (cons header regexps) scores)))
5704 (gnus-group-make-group group "nnkiboze" address)
5706 (gnus-set-work-buffer)
5707 (let (emacs-lisp-mode-hook)
5708 (pp scores (current-buffer)))
5709 (write-region (point-min) (point-max)
5710 (gnus-score-file-name (concat "nnkiboze:" group))))
5712 (gnus-group-position-point))
5714 (defun gnus-group-add-to-virtual (n vgroup)
5715 "Add the current group to a virtual group."
5717 (list current-prefix-arg
5718 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5720 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5721 (error "%s is not an nnvirtual group" vgroup))
5722 (let* ((groups (gnus-group-process-prefix n))
5723 (method (gnus-info-method (gnus-get-info vgroup))))
5724 (setcar (cdr method)
5726 (nth 1 method) "\\|"
5729 (gnus-group-remove-mark s)
5730 (concat "\\(^" (regexp-quote s) "$\\)"))
5732 (gnus-group-position-point))
5734 (defun gnus-group-make-empty-virtual (group)
5735 "Create a new, fresh, empty virtual group."
5736 (interactive "sCreate new, empty virtual group: ")
5737 (let* ((method (list 'nnvirtual "^$"))
5738 (pgroup (gnus-group-prefixed-name group method)))
5739 ;; Check whether it exists already.
5740 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5741 (error "Group %s already exists." pgroup))
5742 ;; Subscribe the new group after the group on the current line.
5743 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5744 (gnus-group-update-group pgroup)
5746 (gnus-group-position-point)))
5748 (defun gnus-group-enter-directory (dir)
5749 "Enter an ephemeral nneething group."
5750 (interactive "DDirectory to read: ")
5751 (let* ((method (list 'nneething dir))
5752 (leaf (gnus-group-prefixed-name
5753 (file-name-nondirectory (directory-file-name dir))
5755 (name (gnus-generate-new-group-name leaf)))
5756 (let ((nneething-read-only t))
5757 (or (gnus-group-read-ephemeral-group
5759 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5761 (error "Couldn't enter %s" dir)))))
5763 ;; Group sorting commands
5764 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5766 (defun gnus-group-sort-groups (func &optional reverse)
5767 "Sort the group buffer according to FUNC.
5768 If REVERSE, reverse the sorting order."
5769 (interactive (list gnus-group-sort-function
5770 current-prefix-arg))
5772 ((not (listp func)) func)
5774 ((= 1 (length func)) (car func))
5776 ,(gnus-make-sort-function
5777 (reverse func)))))))
5778 ;; We peel off the dummy group from the alist.
5780 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5781 (pop gnus-newsrc-alist))
5783 (setq gnus-newsrc-alist
5784 (sort gnus-newsrc-alist func))
5786 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5787 ;; Regenerate the hash table.
5788 (gnus-make-hashtable-from-newsrc-alist)
5789 (gnus-group-list-groups))))
5791 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5792 "Sort the group buffer alphabetically by group name.
5793 If REVERSE, sort in reverse order."
5795 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5797 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5798 "Sort the group buffer by number of unread articles.
5799 If REVERSE, sort in reverse order."
5801 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5803 (defun gnus-group-sort-groups-by-level (&optional reverse)
5804 "Sort the group buffer by group level.
5805 If REVERSE, sort in reverse order."
5807 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5809 (defun gnus-group-sort-groups-by-score (&optional reverse)
5810 "Sort the group buffer by group score.
5811 If REVERSE, sort in reverse order."
5813 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5815 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5816 "Sort the group buffer by group rank.
5817 If REVERSE, sort in reverse order."
5819 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5821 (defun gnus-group-sort-groups-by-method (&optional reverse)
5822 "Sort the group buffer alphabetically by backend name.
5823 If REVERSE, sort in reverse order."
5825 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5827 (defun gnus-group-sort-by-alphabet (info1 info2)
5828 "Sort alphabetically."
5829 (string< (gnus-info-group info1) (gnus-info-group info2)))
5831 (defun gnus-group-sort-by-unread (info1 info2)
5832 "Sort by number of unread articles."
5833 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5834 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5835 (< (or (and (numberp n1) n1) 0)
5836 (or (and (numberp n2) n2) 0))))
5838 (defun gnus-group-sort-by-level (info1 info2)
5840 (< (gnus-info-level info1) (gnus-info-level info2)))
5842 (defun gnus-group-sort-by-method (info1 info2)
5843 "Sort alphabetically by backend name."
5844 (string< (symbol-name (car (gnus-find-method-for-group
5845 (gnus-info-group info1) info1)))
5846 (symbol-name (car (gnus-find-method-for-group
5847 (gnus-info-group info2) info2)))))
5849 (defun gnus-group-sort-by-score (info1 info2)
5850 "Sort by group score."
5851 (< (gnus-info-score info1) (gnus-info-score info2)))
5853 (defun gnus-group-sort-by-rank (info1 info2)
5854 "Sort by level and score."
5855 (let ((level1 (gnus-info-level info1))
5856 (level2 (gnus-info-level info2)))
5857 (or (< level1 level2)
5858 (and (= level1 level2)
5859 (< (gnus-info-score info1) (gnus-info-score info2))))))
5861 ;; Group catching up.
5863 (defun gnus-group-clear-data (n)
5864 "Clear all marks and read ranges from the current group."
5866 (let ((groups (gnus-group-process-prefix n))
5868 (while (setq group (pop groups))
5869 (setq info (gnus-get-info group))
5870 (gnus-info-set-read info nil)
5871 (when (gnus-info-marks info)
5872 (gnus-info-set-marks info nil))
5873 (gnus-get-unread-articles-in-group info (gnus-active group) t)
5874 (when (gnus-group-goto-group group)
5875 (gnus-group-remove-mark group)
5876 (gnus-group-update-group-line)))))
5878 (defun gnus-group-catchup-current (&optional n all)
5879 "Mark all articles not marked as unread in current newsgroup as read.
5880 If prefix argument N is numeric, the ARG next newsgroups will be
5881 caught up. If ALL is non-nil, marked articles will also be marked as
5882 read. Cross references (Xref: header) of articles are ignored.
5883 The difference between N and actual number of newsgroups that were
5884 caught up is returned."
5886 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5890 "Do you really want to mark all articles as read? "
5891 "Mark all unread articles as read? "))))
5893 (let ((groups (gnus-group-process-prefix n))
5896 ;; Virtual groups have to be given special treatment.
5897 (let ((method (gnus-find-method-for-group (car groups))))
5898 (if (eq 'nnvirtual (car method))
5899 (nnvirtual-catchup-group
5900 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5901 (gnus-group-remove-mark (car groups))
5903 (gnus-group-goto-group (car groups))
5904 (gnus-group-catchup (car groups) all))
5905 (gnus-group-update-group-line)
5906 (setq ret (1+ ret)))
5907 (setq groups (cdr groups)))
5908 (gnus-group-next-unread-group 1)
5911 (defun gnus-group-catchup-current-all (&optional n)
5912 "Mark all articles in current newsgroup as read.
5913 Cross references (Xref: header) of articles are ignored."
5915 (gnus-group-catchup-current n 'all))
5917 (defun gnus-group-catchup (group &optional all)
5918 "Mark all articles in GROUP as read.
5919 If ALL is non-nil, all articles are marked as read.
5920 The return value is the number of articles that were marked as read,
5921 or nil if no action could be taken."
5922 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5924 ;; Do the updating only if the newsgroup isn't killed.
5925 (if (not (numberp (car entry)))
5926 (gnus-message 1 "Can't catch up; non-active group")
5927 ;; Do auto-expirable marks if that's required.
5928 (when (gnus-group-auto-expirable-p group)
5929 (gnus-add-marked-articles
5930 group 'expire (gnus-list-of-unread-articles group))
5932 (let ((marks (nth 3 (nth 2 entry))))
5933 (gnus-add-marked-articles
5934 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5935 (gnus-add-marked-articles
5936 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5938 (gnus-update-read-articles group nil)
5939 ;; Also nix out the lists of marks and dormants.
5941 (gnus-add-marked-articles group 'tick nil nil 'force)
5942 (gnus-add-marked-articles group 'dormant nil nil 'force))
5943 (run-hooks 'gnus-group-catchup-group-hook)
5946 (defun gnus-group-expire-articles (&optional n)
5947 "Expire all expirable articles in the current newsgroup."
5949 (let ((groups (gnus-group-process-prefix n))
5952 (error "No groups to expire"))
5953 (while (setq group (pop groups))
5954 (gnus-group-remove-mark group)
5955 (when (gnus-check-backend-function 'request-expire-articles group)
5956 (gnus-message 6 "Expiring articles in %s..." group)
5957 (let* ((info (gnus-get-info group))
5958 (expirable (if (gnus-group-total-expirable-p group)
5959 (cons nil (gnus-list-of-read-articles group))
5960 (assq 'expire (gnus-info-marks info))))
5961 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5965 (gnus-compress-sequence
5967 ;; We set the expiry variables to the groupp
5969 (let ((nnmail-expiry-wait-function nil)
5970 (nnmail-expiry-wait expiry-wait))
5971 (gnus-request-expire-articles
5972 (gnus-uncompress-sequence (cdr expirable)) group))
5973 ;; Just expire using the normal expiry values.
5974 (gnus-request-expire-articles
5975 (gnus-uncompress-sequence (cdr expirable)) group)))))
5976 (gnus-message 6 "Expiring articles in %s...done" group)))
5977 (gnus-group-position-point))))
5979 (defun gnus-group-expire-all-groups ()
5980 "Expire all expirable articles in all newsgroups."
5983 (gnus-message 5 "Expiring...")
5984 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5985 (cdr gnus-newsrc-alist))))
5986 (gnus-group-expire-articles nil)))
5987 (gnus-group-position-point)
5988 (gnus-message 5 "Expiring...done"))
5990 (defun gnus-group-set-current-level (n level)
5991 "Set the level of the next N groups to LEVEL."
5996 (let ((s (read-string
5997 (format "Level (default %s): "
5998 (or (gnus-group-group-level)
5999 gnus-level-default-subscribed)))))
6000 (if (string-match "^\\s-*$" s)
6001 (int-to-string (or (gnus-group-group-level)
6002 gnus-level-default-subscribed))
6004 (or (and (>= level 1) (<= level gnus-level-killed))
6005 (error "Illegal level: %d" level))
6006 (let ((groups (gnus-group-process-prefix n))
6008 (while (setq group (pop groups))
6009 (gnus-group-remove-mark group)
6010 (gnus-message 6 "Changed level of %s from %d to %d"
6011 group (or (gnus-group-group-level) gnus-level-killed)
6013 (gnus-group-change-level
6014 group level (or (gnus-group-group-level) gnus-level-killed))
6015 (gnus-group-update-group-line)))
6016 (gnus-group-position-point))
6018 (defun gnus-group-unsubscribe-current-group (&optional n)
6019 "Toggle subscription of the current group.
6020 If given numerical prefix, toggle the N next groups."
6022 (let ((groups (gnus-group-process-prefix n))
6025 (setq group (car groups)
6026 groups (cdr groups))
6027 (gnus-group-remove-mark group)
6028 (gnus-group-unsubscribe-group
6029 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6030 gnus-level-default-unsubscribed
6031 gnus-level-default-subscribed) t)
6032 (gnus-group-update-group-line))
6033 (gnus-group-next-group 1)))
6035 (defun gnus-group-unsubscribe-group (group &optional level silent)
6036 "Toggle subscription to GROUP.
6037 Killed newsgroups are subscribed. If SILENT, don't try to update the
6040 (list (completing-read
6041 "Group: " gnus-active-hashtb nil
6042 (memq gnus-select-method gnus-have-read-active-file))))
6043 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6045 ((string-match "^[ \t]$" group)
6046 (error "Empty group name"))
6048 ;; Toggle subscription flag.
6049 (gnus-group-change-level
6050 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6051 gnus-level-subscribed)
6052 (1+ gnus-level-subscribed)
6053 gnus-level-default-subscribed)))
6055 (gnus-group-update-group group)))
6056 ((and (stringp group)
6057 (or (not (memq gnus-select-method gnus-have-read-active-file))
6058 (gnus-active group)))
6059 ;; Add new newsgroup.
6060 (gnus-group-change-level
6062 (if level level gnus-level-default-subscribed)
6063 (or (and (member group gnus-zombie-list)
6066 (and (gnus-group-group-name)
6067 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6069 (gnus-group-update-group group)))
6070 (t (error "No such newsgroup: %s" group)))
6071 (gnus-group-position-point)))
6073 (defun gnus-group-transpose-groups (n)
6074 "Move the current newsgroup up N places.
6075 If given a negative prefix, move down instead. The difference between
6076 N and the number of steps taken is returned."
6078 (or (gnus-group-group-name)
6079 (error "No group on current line"))
6080 (gnus-group-kill-group 1)
6082 (forward-line (- n))
6083 (gnus-group-yank-group)
6084 (gnus-group-position-point)))
6086 (defun gnus-group-kill-all-zombies ()
6087 "Kill all zombie newsgroups."
6089 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6090 (setq gnus-zombie-list nil)
6091 (gnus-group-list-groups))
6093 (defun gnus-group-kill-region (begin end)
6094 "Kill newsgroups in current region (excluding current point).
6095 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6110 (beginning-of-line) ;Important when LINES < 1
6111 (gnus-group-kill-group lines)))
6113 (defun gnus-group-kill-group (&optional n discard)
6114 "Kill the next N groups.
6115 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6116 However, only groups that were alive can be yanked; already killed
6117 groups or zombie groups can't be yanked.
6118 The return value is the name of the group that was killed, or a list
6121 (let ((buffer-read-only nil)
6122 (groups (gnus-group-process-prefix n))
6123 group entry level out)
6124 (if (< (length groups) 10)
6125 ;; This is faster when there are few groups.
6127 (push (setq group (pop groups)) out)
6128 (gnus-group-remove-mark group)
6129 (setq level (gnus-group-group-level))
6131 (when (and (not discard)
6132 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6133 (push (cons (car entry) (nth 2 entry))
6134 gnus-list-of-killed-groups))
6135 (gnus-group-change-level
6136 (if entry entry group) gnus-level-killed (if entry nil level)))
6137 ;; If there are lots and lots of groups to be killed, we use
6138 ;; this thing instead.
6140 (setq groups (nreverse groups))
6142 (gnus-group-remove-mark (setq group (pop groups)))
6145 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6146 (push (cons (car entry) (nth 2 entry))
6147 gnus-list-of-killed-groups)
6148 (setcdr (cdr entry) (cdddr entry)))
6149 ((member group gnus-zombie-list)
6150 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6151 (gnus-make-hashtable-from-newsrc-alist)))
6153 (gnus-group-position-point)
6154 (if (< (length out) 2) (car out) (nreverse out))))
6156 (defun gnus-group-yank-group (&optional arg)
6157 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6158 inserting it before the current newsgroup. The numeric ARG specifies
6159 how many newsgroups are to be yanked. The name of the newsgroup yanked
6160 is returned, or (if several groups are yanked) a list of yanked groups
6163 (setq arg (or arg 1))
6164 (let (info group prev out)
6165 (while (>= (decf arg) 0)
6166 (if (not (setq info (pop gnus-list-of-killed-groups)))
6167 (error "No more newsgroups to yank"))
6168 (push (setq group (nth 1 info)) out)
6169 ;; Find which newsgroup to insert this one before - search
6170 ;; backward until something suitable is found. If there are no
6171 ;; other newsgroups in this buffer, just make this newsgroup the
6173 (setq prev (gnus-group-group-name))
6174 (gnus-group-change-level
6175 info (gnus-info-level (cdr info)) gnus-level-killed
6176 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6178 (gnus-group-insert-group-line-info group))
6180 (gnus-group-position-point)
6181 (if (< (length out) 2) (car out) (nreverse out))))
6183 (defun gnus-group-kill-level (level)
6184 "Kill all groups that is on a certain LEVEL."
6185 (interactive "nKill all groups on level: ")
6187 ((= level gnus-level-zombie)
6188 (setq gnus-killed-list
6189 (nconc gnus-zombie-list gnus-killed-list))
6190 (setq gnus-zombie-list nil))
6191 ((and (< level gnus-level-zombie)
6193 (or gnus-expert-user
6196 "Do you really want to kill all groups on level %d? "
6198 (let* ((prev gnus-newsrc-alist)
6201 (if (= (gnus-info-level level) level)
6202 (setcdr prev (cdr alist))
6204 (setq alist (cdr alist)))
6205 (gnus-make-hashtable-from-newsrc-alist)
6206 (gnus-group-list-groups)))
6208 (error "Can't kill; illegal level: %d" level))))
6210 (defun gnus-group-list-all-groups (&optional arg)
6211 "List all newsgroups with level ARG or lower.
6212 Default is gnus-level-unsubscribed, which lists all subscribed and most
6213 unsubscribed groups."
6215 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6217 ;; Redefine this to list ALL killed groups if prefix arg used.
6218 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6219 (defun gnus-group-list-killed (&optional arg)
6220 "List all killed newsgroups in the group buffer.
6221 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6222 entail asking the server for the groups."
6224 ;; Find all possible killed newsgroups if arg.
6226 ;; First make sure active file has been read.
6227 (unless gnus-have-read-active-file
6228 (let ((gnus-read-active-file t))
6229 (gnus-read-active-file)))
6230 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6231 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6235 (group (symbol-name sym)))
6236 (if (or (null group)
6237 (gnus-gethash group gnus-killed-hashtb)
6238 (gnus-gethash group gnus-newsrc-hashtb))
6240 (let ((do-sub (gnus-matches-options-n group)))
6241 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6243 (setq groups (1+ groups))
6244 (setq gnus-killed-list
6245 (cons group gnus-killed-list))
6246 (gnus-sethash group group gnus-killed-hashtb))))))
6247 gnus-active-hashtb))
6248 (if (not gnus-killed-list)
6249 (gnus-message 6 "No killed groups")
6250 (let (gnus-group-list-mode)
6251 (funcall gnus-group-prepare-function
6252 gnus-level-killed t gnus-level-killed))
6253 (goto-char (point-min)))
6254 (gnus-group-position-point))
6256 (defun gnus-group-list-zombies ()
6257 "List all zombie newsgroups in the group buffer."
6259 (if (not gnus-zombie-list)
6260 (gnus-message 6 "No zombie groups")
6261 (let (gnus-group-list-mode)
6262 (funcall gnus-group-prepare-function
6263 gnus-level-zombie t gnus-level-zombie))
6264 (goto-char (point-min)))
6265 (gnus-group-position-point))
6267 (defun gnus-group-list-active ()
6268 "List all groups that are available from the server(s)."
6270 ;; First we make sure that we have really read the active file.
6271 (unless gnus-have-read-active-file
6272 (let ((gnus-read-active-file t))
6273 (gnus-read-active-file)))
6274 ;; Find all groups and sort them.
6280 (and (symbol-value sym)
6281 (setq list (cons (symbol-name sym) list))))
6285 (buffer-read-only nil))
6288 (gnus-group-insert-group-line-info (pop groups)))
6289 (goto-char (point-min))))
6291 (defun gnus-activate-all-groups (level)
6292 "Activate absolutely all groups."
6293 (interactive (list 7))
6294 (let ((gnus-activate-level level)
6295 (gnus-activate-foreign-newsgroups level))
6296 (gnus-group-get-new-news)))
6298 (defun gnus-group-get-new-news (&optional arg)
6299 "Get newly arrived articles.
6300 If ARG is a number, it specifies which levels you are interested in
6301 re-scanning. If ARG is non-nil and not a number, this will force
6302 \"hard\" re-reading of the active files from all servers."
6304 (run-hooks 'gnus-get-new-news-hook)
6305 ;; We might read in new NoCeM messages here.
6306 (when (and gnus-use-nocem
6308 (gnus-nocem-scan-groups))
6309 ;; If ARG is not a number, then we read the active file.
6310 (when (and arg (not (numberp arg)))
6311 (let ((gnus-read-active-file t))
6312 (gnus-read-active-file))
6315 (setq arg (gnus-group-default-level arg t))
6316 (if (and gnus-read-active-file (not arg))
6318 (gnus-read-active-file)
6319 (gnus-get-unread-articles arg))
6320 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6321 (gnus-get-unread-articles arg)))
6322 (run-hooks 'gnus-after-getting-new-news-hook)
6323 (gnus-group-list-groups))
6325 (defun gnus-group-get-new-news-this-group (&optional n)
6326 "Check for newly arrived news in the current group (and the N-1 next groups).
6327 The difference between N and the number of newsgroup checked is returned.
6328 If N is negative, this group and the N-1 previous groups will be checked."
6330 (let* ((groups (gnus-group-process-prefix n))
6331 (ret (if (numberp n) (- n (length groups)) 0))
6334 (setq group (car groups)
6335 groups (cdr groups))
6336 (gnus-group-remove-mark group)
6337 (unless (gnus-get-new-news-in-group group)
6339 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6340 (when gnus-goto-next-group-when-activating
6341 (gnus-group-next-unread-group 1 t))
6342 (gnus-summary-position-point)
6345 (defun gnus-get-new-news-in-group (group)
6346 (when (and group (gnus-activate-group group 'scan))
6347 (gnus-get-unread-articles-in-group
6348 (gnus-get-info group) (gnus-active group) t)
6349 (gnus-close-group group)
6350 (when (gnus-group-goto-group group)
6351 (gnus-group-update-group-line))
6354 (defun gnus-group-fetch-faq (group &optional faq-dir)
6355 "Fetch the FAQ for the current group."
6358 (gnus-group-real-name (gnus-group-group-name))
6359 (cond (current-prefix-arg
6361 "Faq dir: " (and (listp gnus-group-faq-directory)
6362 gnus-group-faq-directory))))))
6364 (setq faq-dir (if (listp gnus-group-faq-directory)
6365 (car gnus-group-faq-directory)
6366 gnus-group-faq-directory)))
6367 (or group (error "No group name given"))
6368 (let ((file (concat (file-name-as-directory faq-dir)
6369 (gnus-group-real-name group))))
6370 (if (not (file-exists-p file))
6371 (error "No such file: %s" file)
6374 (defun gnus-group-describe-group (force &optional group)
6375 "Display a description of the current newsgroup."
6376 (interactive (list current-prefix-arg (gnus-group-group-name)))
6377 (and force (setq gnus-description-hashtb nil))
6378 (let ((method (gnus-find-method-for-group group))
6380 (or group (error "No group name given"))
6381 (and (or (and gnus-description-hashtb
6382 ;; We check whether this group's method has been
6383 ;; queried for a description file.
6385 (gnus-group-prefixed-name "" method)
6386 gnus-description-hashtb))
6387 (setq desc (gnus-group-get-description group))
6388 (gnus-read-descriptions-file method))
6390 (or desc (gnus-gethash group gnus-description-hashtb)
6391 "No description available")))))
6393 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6394 (defun gnus-group-describe-all-groups (&optional force)
6395 "Pop up a buffer with descriptions of all newsgroups."
6397 (and force (setq gnus-description-hashtb nil))
6398 (if (not (or gnus-description-hashtb
6399 (gnus-read-all-descriptions-files)))
6400 (error "Couldn't request descriptions file"))
6401 (let ((buffer-read-only nil)
6407 (insert (format " *: %-20s %s\n" (symbol-name group)
6408 (symbol-value group)))
6409 (add-text-properties
6410 b (1+ b) (list 'gnus-group group
6411 'gnus-unread t 'gnus-marked nil
6412 'gnus-level (1+ gnus-level-subscribed))))
6413 gnus-description-hashtb)
6414 (goto-char (point-min))
6415 (gnus-group-position-point)))
6417 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6418 (defun gnus-group-apropos (regexp &optional search-description)
6419 "List all newsgroups that have names that match a regexp."
6420 (interactive "sGnus apropos (regexp): ")
6422 (obuf (current-buffer))
6424 ;; Go through all newsgroups that are known to Gnus.
6427 (and (symbol-name group)
6428 (string-match regexp (symbol-name group))
6429 (setq groups (cons (symbol-name group) groups))))
6431 ;; Also go through all descriptions that are known to Gnus.
6432 (when search-description
6435 (and (string-match regexp (symbol-value group))
6436 (gnus-active (symbol-name group))
6437 (setq groups (cons (symbol-name group) groups))))
6438 gnus-description-hashtb))
6440 (gnus-message 3 "No groups matched \"%s\"." regexp)
6441 ;; Print out all the groups.
6443 (pop-to-buffer "*Gnus Help*")
6444 (buffer-disable-undo (current-buffer))
6446 (setq groups (sort groups 'string<))
6448 ;; Groups may be entered twice into the list of groups.
6449 (if (not (string= (car groups) prev))
6451 (insert (setq prev (car groups)) "\n")
6452 (if (and gnus-description-hashtb
6453 (setq des (gnus-gethash (car groups)
6454 gnus-description-hashtb)))
6455 (insert " " des "\n"))))
6456 (setq groups (cdr groups)))
6457 (goto-char (point-min))))
6458 (pop-to-buffer obuf)))
6460 (defun gnus-group-description-apropos (regexp)
6461 "List all newsgroups that have names or descriptions that match a regexp."
6462 (interactive "sGnus description apropos (regexp): ")
6463 (if (not (or gnus-description-hashtb
6464 (gnus-read-all-descriptions-files)))
6465 (error "Couldn't request descriptions file"))
6466 (gnus-group-apropos regexp t))
6468 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6469 (defun gnus-group-list-matching (level regexp &optional all lowest)
6470 "List all groups with unread articles that match REGEXP.
6471 If the prefix LEVEL is non-nil, it should be a number that says which
6472 level to cut off listing groups.
6473 If ALL, also list groups with no unread articles.
6474 If LOWEST, don't list groups with level lower than LOWEST."
6475 (interactive "P\nsList newsgroups matching: ")
6476 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6477 all (or lowest 1) regexp)
6478 (goto-char (point-min))
6479 (gnus-group-position-point))
6481 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6482 "List all groups that match REGEXP.
6483 If the prefix LEVEL is non-nil, it should be a number that says which
6484 level to cut off listing groups.
6485 If LOWEST, don't list groups with level lower than LOWEST."
6486 (interactive "P\nsList newsgroups matching: ")
6487 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6489 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6490 (defun gnus-group-save-newsrc (&optional force)
6491 "Save the Gnus startup files.
6492 If FORCE, force saving whether it is necessary or not."
6494 (gnus-save-newsrc-file force))
6496 (defun gnus-group-restart (&optional arg)
6497 "Force Gnus to read the .newsrc file."
6499 (when (gnus-yes-or-no-p
6500 (format "Are you sure you want to read %s? "
6501 gnus-current-startup-file))
6502 (gnus-save-newsrc-file)
6503 (gnus-setup-news 'force)
6504 (gnus-group-list-groups arg)))
6506 (defun gnus-group-read-init-file ()
6507 "Read the Gnus elisp init file."
6509 (gnus-read-init-file))
6511 (defun gnus-group-check-bogus-groups (&optional silent)
6512 "Check bogus newsgroups.
6513 If given a prefix, don't ask for confirmation before removing a bogus
6516 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6517 (gnus-group-list-groups))
6519 (defun gnus-group-edit-global-kill (&optional article group)
6520 "Edit the global kill file.
6521 If GROUP, edit that local kill file instead."
6523 (setq gnus-current-kill-article article)
6524 (gnus-kill-file-edit-file group)
6527 (substitute-command-keys
6528 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6529 (if group "local" "global")))))
6531 (defun gnus-group-edit-local-kill (article group)
6532 "Edit a local kill file."
6533 (interactive (list nil (gnus-group-group-name)))
6534 (gnus-group-edit-global-kill article group))
6536 (defun gnus-group-force-update ()
6537 "Update `.newsrc' file."
6539 (gnus-save-newsrc-file))
6541 (defun gnus-group-suspend ()
6542 "Suspend the current Gnus session.
6543 In fact, cleanup buffers except for group mode buffer.
6544 The hook gnus-suspend-gnus-hook is called before actually suspending."
6546 (run-hooks 'gnus-suspend-gnus-hook)
6547 ;; Kill Gnus buffers except for group mode buffer.
6548 (let ((group-buf (get-buffer gnus-group-buffer)))
6549 ;; Do this on a separate list in case the user does a ^G before we finish
6550 (let ((gnus-buffer-list
6551 (delq group-buf (delq gnus-dribble-buffer
6552 (append gnus-buffer-list nil)))))
6553 (while gnus-buffer-list
6554 (gnus-kill-buffer (car gnus-buffer-list))
6555 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6558 (setq gnus-buffer-list (list group-buf))
6559 (bury-buffer group-buf)
6560 (delete-windows-on group-buf t)))))
6562 (defun gnus-group-clear-dribble ()
6563 "Clear all information from the dribble buffer."
6565 (gnus-dribble-clear)
6566 (gnus-message 7 "Cleared dribble buffer"))
6568 (defun gnus-group-exit ()
6569 "Quit reading news after updating .newsrc.eld and .newsrc.
6570 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6573 (or noninteractive ;For gnus-batch-kill
6574 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6575 (not gnus-interactive-exit) ;Without confirmation
6577 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6578 (run-hooks 'gnus-exit-gnus-hook)
6579 ;; Offer to save data from non-quitted summary buffers.
6580 (gnus-offer-save-summaries)
6581 ;; Save the newsrc file(s).
6582 (gnus-save-newsrc-file)
6584 (gnus-close-backends)
6585 ;; Reset everything.
6587 ;; Allow the user to do things after cleaning up.
6588 (run-hooks 'gnus-after-exiting-gnus-hook)))
6590 (defun gnus-close-backends ()
6591 ;; Send a close request to all backends that support such a request.
6592 (let ((methods gnus-valid-select-methods)
6595 (if (fboundp (setq func (intern (concat (caar methods)
6596 "-request-close"))))
6598 (setq methods (cdr methods)))))
6600 (defun gnus-group-quit ()
6601 "Quit reading news without updating .newsrc.eld or .newsrc.
6602 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6604 (when (or noninteractive ;For gnus-batch-kill
6605 (zerop (buffer-size))
6606 (not (gnus-server-opened gnus-select-method))
6608 (not gnus-current-startup-file)
6610 (format "Quit reading news without saving %s? "
6611 (file-name-nondirectory gnus-current-startup-file))))
6612 (run-hooks 'gnus-exit-gnus-hook)
6613 (if gnus-use-full-window
6614 (delete-other-windows)
6615 (gnus-remove-some-windows))
6617 (gnus-close-backends)
6619 ;; Allow the user to do things after cleaning up.
6620 (run-hooks 'gnus-after-exiting-gnus-hook)))
6622 (defun gnus-offer-save-summaries ()
6623 "Offer to save all active summary buffers."
6625 (let ((buflist (buffer-list))
6627 ;; Go through all buffers and find all summaries.
6629 (and (setq bufname (buffer-name (car buflist)))
6630 (string-match "Summary" bufname)
6632 (set-buffer bufname)
6633 ;; We check that this is, indeed, a summary buffer.
6634 (and (eq major-mode 'gnus-summary-mode)
6635 ;; Also make sure this isn't bogus.
6636 gnus-newsgroup-prepared))
6637 (push bufname buffers))
6638 (setq buflist (cdr buflist)))
6639 ;; Go through all these summary buffers and offer to save them.
6642 "Update summary buffer %s? "
6643 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6646 (defun gnus-group-describe-briefly ()
6647 "Give a one line description of the group mode commands."
6649 (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")))
6651 (defun gnus-group-browse-foreign-server (method)
6652 "Browse a foreign news server.
6653 If called interactively, this function will ask for a select method
6654 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6655 If not, METHOD should be a list where the first element is the method
6656 and the second element is the address."
6658 (list (let ((how (completing-read
6660 (append gnus-valid-select-methods gnus-server-alist)
6661 nil t (cons "nntp" 0))))
6662 ;; We either got a backend name or a virtual server name.
6663 ;; If the first, we also need an address.
6664 (if (assoc how gnus-valid-select-methods)
6666 ;; Suggested by mapjph@bath.ac.uk.
6669 (mapcar (lambda (server) (list server))
6670 gnus-secondary-servers)))
6671 ;; We got a server name, so we find the method.
6672 (gnus-server-to-method how)))))
6673 (gnus-browse-foreign-server method))
6677 ;;; Gnus summary mode
6680 (defvar gnus-summary-mode-map nil)
6682 (put 'gnus-summary-mode 'mode-class 'special)
6684 (unless gnus-summary-mode-map
6685 (setq gnus-summary-mode-map (make-keymap))
6686 (suppress-keymap gnus-summary-mode-map)
6688 ;; Non-orthogonal keys
6690 (gnus-define-keys gnus-summary-mode-map
6691 " " gnus-summary-next-page
6692 "\177" gnus-summary-prev-page
6693 [delete] gnus-summary-prev-page
6694 "\r" gnus-summary-scroll-up
6695 "n" gnus-summary-next-unread-article
6696 "p" gnus-summary-prev-unread-article
6697 "N" gnus-summary-next-article
6698 "P" gnus-summary-prev-article
6699 "\M-\C-n" gnus-summary-next-same-subject
6700 "\M-\C-p" gnus-summary-prev-same-subject
6701 "\M-n" gnus-summary-next-unread-subject
6702 "\M-p" gnus-summary-prev-unread-subject
6703 "." gnus-summary-first-unread-article
6704 "," gnus-summary-best-unread-article
6705 "\M-s" gnus-summary-search-article-forward
6706 "\M-r" gnus-summary-search-article-backward
6707 "<" gnus-summary-beginning-of-article
6708 ">" gnus-summary-end-of-article
6709 "j" gnus-summary-goto-article
6710 "^" gnus-summary-refer-parent-article
6711 "\M-^" gnus-summary-refer-article
6712 "u" gnus-summary-tick-article-forward
6713 "!" gnus-summary-tick-article-forward
6714 "U" gnus-summary-tick-article-backward
6715 "d" gnus-summary-mark-as-read-forward
6716 "D" gnus-summary-mark-as-read-backward
6717 "E" gnus-summary-mark-as-expirable
6718 "\M-u" gnus-summary-clear-mark-forward
6719 "\M-U" gnus-summary-clear-mark-backward
6720 "k" gnus-summary-kill-same-subject-and-select
6721 "\C-k" gnus-summary-kill-same-subject
6722 "\M-\C-k" gnus-summary-kill-thread
6723 "\M-\C-l" gnus-summary-lower-thread
6724 "e" gnus-summary-edit-article
6725 "#" gnus-summary-mark-as-processable
6726 "\M-#" gnus-summary-unmark-as-processable
6727 "\M-\C-t" gnus-summary-toggle-threads
6728 "\M-\C-s" gnus-summary-show-thread
6729 "\M-\C-h" gnus-summary-hide-thread
6730 "\M-\C-f" gnus-summary-next-thread
6731 "\M-\C-b" gnus-summary-prev-thread
6732 "\M-\C-u" gnus-summary-up-thread
6733 "\M-\C-d" gnus-summary-down-thread
6734 "&" gnus-summary-execute-command
6735 "c" gnus-summary-catchup-and-exit
6736 "\C-w" gnus-summary-mark-region-as-read
6737 "\C-t" gnus-summary-toggle-truncation
6738 "?" gnus-summary-mark-as-dormant
6739 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6740 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6741 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6742 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6743 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6744 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6745 "=" gnus-summary-expand-window
6746 "\C-x\C-s" gnus-summary-reselect-current-group
6747 "\M-g" gnus-summary-rescan-group
6748 "w" gnus-summary-stop-page-breaking
6749 "\C-c\C-r" gnus-summary-caesar-message
6750 "\M-t" gnus-summary-toggle-mime
6751 "f" gnus-summary-followup
6752 "F" gnus-summary-followup-with-original
6753 "C" gnus-summary-cancel-article
6754 "r" gnus-summary-reply
6755 "R" gnus-summary-reply-with-original
6756 "\C-c\C-f" gnus-summary-mail-forward
6757 "o" gnus-summary-save-article
6758 "\C-o" gnus-summary-save-article-mail
6759 "|" gnus-summary-pipe-output
6760 "\M-k" gnus-summary-edit-local-kill
6761 "\M-K" gnus-summary-edit-global-kill
6763 "\C-c\C-d" gnus-summary-describe-group
6764 "q" gnus-summary-exit
6765 "Q" gnus-summary-exit-no-update
6766 "\C-c\C-i" gnus-info-find-node
6767 gnus-mouse-2 gnus-mouse-pick-article
6768 "m" gnus-summary-mail-other-window
6769 "a" gnus-summary-post-news
6770 "x" gnus-summary-limit-to-unread
6771 "s" gnus-summary-isearch-article
6772 "t" gnus-article-hide-headers
6773 "g" gnus-summary-show-article
6774 "l" gnus-summary-goto-last-article
6775 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6776 "\C-d" gnus-summary-enter-digest-group
6778 "*" gnus-cache-enter-article
6779 "\M-*" gnus-cache-remove-article
6780 "\M-&" gnus-summary-universal-argument
6781 "\C-l" gnus-recenter
6782 "I" gnus-summary-increase-score
6783 "L" gnus-summary-lower-score
6785 "V" gnus-summary-score-map
6786 "X" gnus-uu-extract-map
6787 "S" gnus-summary-send-map)
6789 ;; Sort of orthogonal keymap
6790 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6791 "t" gnus-summary-tick-article-forward
6792 "!" gnus-summary-tick-article-forward
6793 "d" gnus-summary-mark-as-read-forward
6794 "r" gnus-summary-mark-as-read-forward
6795 "c" gnus-summary-clear-mark-forward
6796 " " gnus-summary-clear-mark-forward
6797 "e" gnus-summary-mark-as-expirable
6798 "x" gnus-summary-mark-as-expirable
6799 "?" gnus-summary-mark-as-dormant
6800 "b" gnus-summary-set-bookmark
6801 "B" gnus-summary-remove-bookmark
6802 "#" gnus-summary-mark-as-processable
6803 "\M-#" gnus-summary-unmark-as-processable
6804 "S" gnus-summary-limit-include-expunged
6805 "C" gnus-summary-catchup
6806 "H" gnus-summary-catchup-to-here
6807 "\C-c" gnus-summary-catchup-all
6808 "k" gnus-summary-kill-same-subject-and-select
6809 "K" gnus-summary-kill-same-subject
6810 "P" gnus-uu-mark-map)
6812 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6813 "c" gnus-summary-clear-above
6814 "u" gnus-summary-tick-above
6815 "m" gnus-summary-mark-above
6816 "k" gnus-summary-kill-below)
6818 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6819 "/" gnus-summary-limit-to-subject
6820 "n" gnus-summary-limit-to-articles
6821 "w" gnus-summary-pop-limit
6822 "s" gnus-summary-limit-to-subject
6823 "a" gnus-summary-limit-to-author
6824 "u" gnus-summary-limit-to-unread
6825 "m" gnus-summary-limit-to-marks
6826 "v" gnus-summary-limit-to-score
6827 "D" gnus-summary-limit-include-dormant
6828 "d" gnus-summary-limit-exclude-dormant
6829 ;; "t" gnus-summary-limit-exclude-thread
6830 "E" gnus-summary-limit-include-expunged
6831 "c" gnus-summary-limit-exclude-childless-dormant
6832 "C" gnus-summary-limit-mark-excluded-as-read)
6834 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6835 "n" gnus-summary-next-unread-article
6836 "p" gnus-summary-prev-unread-article
6837 "N" gnus-summary-next-article
6838 "P" gnus-summary-prev-article
6839 "\C-n" gnus-summary-next-same-subject
6840 "\C-p" gnus-summary-prev-same-subject
6841 "\M-n" gnus-summary-next-unread-subject
6842 "\M-p" gnus-summary-prev-unread-subject
6843 "f" gnus-summary-first-unread-article
6844 "b" gnus-summary-best-unread-article
6845 "j" gnus-summary-goto-article
6846 "g" gnus-summary-goto-subject
6847 "l" gnus-summary-goto-last-article
6848 "p" gnus-summary-pop-article)
6850 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6851 "k" gnus-summary-kill-thread
6852 "l" gnus-summary-lower-thread
6853 "i" gnus-summary-raise-thread
6854 "T" gnus-summary-toggle-threads
6855 "t" gnus-summary-rethread-current
6856 "^" gnus-summary-reparent-thread
6857 "s" gnus-summary-show-thread
6858 "S" gnus-summary-show-all-threads
6859 "h" gnus-summary-hide-thread
6860 "H" gnus-summary-hide-all-threads
6861 "n" gnus-summary-next-thread
6862 "p" gnus-summary-prev-thread
6863 "u" gnus-summary-up-thread
6864 "o" gnus-summary-top-thread
6865 "d" gnus-summary-down-thread
6866 "#" gnus-uu-mark-thread
6867 "\M-#" gnus-uu-unmark-thread)
6869 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6870 "c" gnus-summary-catchup-and-exit
6871 "C" gnus-summary-catchup-all-and-exit
6872 "E" gnus-summary-exit-no-update
6873 "Q" gnus-summary-exit
6874 "Z" gnus-summary-exit
6875 "n" gnus-summary-catchup-and-goto-next-group
6876 "R" gnus-summary-reselect-current-group
6877 "G" gnus-summary-rescan-group
6878 "N" gnus-summary-next-group
6879 "P" gnus-summary-prev-group)
6881 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6882 " " gnus-summary-next-page
6883 "n" gnus-summary-next-page
6884 "\177" gnus-summary-prev-page
6885 [delete] gnus-summary-prev-page
6886 "p" gnus-summary-prev-page
6887 "\r" gnus-summary-scroll-up
6888 "<" gnus-summary-beginning-of-article
6889 ">" gnus-summary-end-of-article
6890 "b" gnus-summary-beginning-of-article
6891 "e" gnus-summary-end-of-article
6892 "^" gnus-summary-refer-parent-article
6893 "r" gnus-summary-refer-parent-article
6894 "R" gnus-summary-refer-references
6895 "g" gnus-summary-show-article
6896 "s" gnus-summary-isearch-article)
6898 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6899 "b" gnus-article-add-buttons
6900 "B" gnus-article-add-buttons-to-head
6901 "o" gnus-article-treat-overstrike
6902 ;; "w" gnus-article-word-wrap
6903 "w" gnus-article-fill-cited-article
6904 "c" gnus-article-remove-cr
6905 "L" gnus-article-remove-trailing-blank-lines
6906 "q" gnus-article-de-quoted-unreadable
6907 "f" gnus-article-display-x-face
6908 "l" gnus-summary-stop-page-breaking
6909 "r" gnus-summary-caesar-message
6910 "t" gnus-article-hide-headers
6911 "v" gnus-summary-verbose-headers
6912 "m" gnus-summary-toggle-mime)
6914 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6915 "a" gnus-article-hide
6916 "h" gnus-article-hide-headers
6917 "b" gnus-article-hide-boring-headers
6918 "s" gnus-article-hide-signature
6919 "c" gnus-article-hide-citation
6920 "p" gnus-article-hide-pgp
6921 "\C-c" gnus-article-hide-citation-maybe)
6923 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6924 "a" gnus-article-highlight
6925 "h" gnus-article-highlight-headers
6926 "c" gnus-article-highlight-citation
6927 "s" gnus-article-highlight-signature)
6929 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6930 "z" gnus-article-date-ut
6931 "u" gnus-article-date-ut
6932 "l" gnus-article-date-local
6933 "e" gnus-article-date-lapsed
6934 "o" gnus-article-date-original)
6936 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6938 "f" gnus-summary-fetch-faq
6939 "d" gnus-summary-describe-group
6940 "h" gnus-summary-describe-briefly
6941 "i" gnus-info-find-node)
6943 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6944 "e" gnus-summary-expire-articles
6945 "\M-\C-e" gnus-summary-expire-articles-now
6946 "\177" gnus-summary-delete-article
6947 [delete] gnus-summary-delete-article
6948 "m" gnus-summary-move-article
6949 "r" gnus-summary-respool-article
6950 "w" gnus-summary-edit-article
6951 "c" gnus-summary-copy-article
6952 "B" gnus-summary-crosspost-article
6953 "q" gnus-summary-respool-query
6954 "i" gnus-summary-import-article)
6956 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6957 "o" gnus-summary-save-article
6958 "m" gnus-summary-save-article-mail
6959 "r" gnus-summary-save-article-rmail
6960 "f" gnus-summary-save-article-file
6961 "b" gnus-summary-save-article-body-file
6962 "h" gnus-summary-save-article-folder
6963 "v" gnus-summary-save-article-vm
6964 "p" gnus-summary-pipe-output
6965 "s" gnus-soup-add-article)
6970 (defun gnus-summary-mode (&optional group)
6971 "Major mode for reading articles.
6973 All normal editing commands are switched off.
6974 \\<gnus-summary-mode-map>
6975 Each line in this buffer represents one article. To read an
6976 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6977 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6980 You can also post articles and send mail from this buffer. To
6981 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6982 of an article, type `\\[gnus-summary-reply]'.
6984 There are approx. one gazillion commands you can execute in this
6985 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6987 The following commands are available:
6989 \\{gnus-summary-mode-map}"
6991 (when (and menu-bar-mode
6992 (gnus-visual-p 'summary-menu 'menu))
6993 (gnus-summary-make-menu-bar))
6994 (kill-all-local-variables)
6995 (let ((locals gnus-summary-local-variables))
6997 (if (consp (car locals))
6999 (make-local-variable (caar locals))
7000 (set (caar locals) (eval (cdar locals))))
7001 (make-local-variable (car locals))
7002 (set (car locals) nil))
7003 (setq locals (cdr locals))))
7004 (gnus-make-thread-indent-array)
7005 (gnus-simplify-mode-line)
7006 (setq major-mode 'gnus-summary-mode)
7007 (setq mode-name "Summary")
7008 (make-local-variable 'minor-mode-alist)
7009 (use-local-map gnus-summary-mode-map)
7010 (buffer-disable-undo (current-buffer))
7011 (setq buffer-read-only t) ;Disable modification
7012 (setq truncate-lines t)
7013 (setq selective-display t)
7014 (setq selective-display-ellipses t) ;Display `...'
7015 (setq buffer-display-table gnus-summary-display-table)
7016 (setq gnus-newsgroup-name group)
7017 (run-hooks 'gnus-summary-mode-hook))
7019 (defun gnus-summary-make-display-table ()
7020 ;; Change the display table. Odd characters have a tendency to mess
7021 ;; up nicely formatted displays - we make all possible glyphs
7022 ;; display only a single character.
7024 ;; We start from the standard display table, if any.
7025 (setq gnus-summary-display-table
7026 (or (copy-sequence standard-display-table)
7027 (make-display-table)))
7028 ;; Nix out all the control chars...
7030 (while (>= (setq i (1- i)) 0)
7031 (aset gnus-summary-display-table i [??])))
7032 ;; ... but not newline and cr, of course. (cr is necessary for the
7033 ;; selective display).
7034 (aset gnus-summary-display-table ?\n nil)
7035 (aset gnus-summary-display-table ?\r nil)
7036 ;; We nix out any glyphs over 126 that are not set already.
7038 (while (>= (setq i (1- i)) 127)
7039 ;; Only modify if the entry is nil.
7040 (or (aref gnus-summary-display-table i)
7041 (aset gnus-summary-display-table i [??])))))
7043 (defun gnus-summary-clear-local-variables ()
7044 (let ((locals gnus-summary-local-variables))
7046 (if (consp (car locals))
7047 (and (vectorp (caar locals))
7048 (set (caar locals) nil))
7049 (and (vectorp (car locals))
7050 (set (car locals) nil)))
7051 (setq locals (cdr locals)))))
7053 ;; Summary data functions.
7055 (defmacro gnus-data-number (data)
7058 (defmacro gnus-data-set-number (data number)
7059 `(setcar ,data ,number))
7061 (defmacro gnus-data-mark (data)
7064 (defmacro gnus-data-set-mark (data mark)
7065 `(setcar (nthcdr 1 ,data) ,mark))
7067 (defmacro gnus-data-pos (data)
7070 (defmacro gnus-data-set-pos (data pos)
7071 `(setcar (nthcdr 2 ,data) ,pos))
7073 (defmacro gnus-data-header (data)
7076 (defmacro gnus-data-level (data)
7079 (defmacro gnus-data-unread-p (data)
7080 `(= (nth 1 ,data) gnus-unread-mark))
7082 (defmacro gnus-data-pseudo-p (data)
7083 `(consp (nth 3 ,data)))
7085 (defmacro gnus-data-find (number)
7086 `(assq ,number gnus-newsgroup-data))
7088 (defmacro gnus-data-find-list (number &optional data)
7089 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7090 (memq (assq ,number bdata)
7093 (defmacro gnus-data-make (number mark pos header level)
7094 `(list ,number ,mark ,pos ,header ,level))
7096 (defun gnus-data-enter (after-article number mark pos header level offset)
7097 (let ((data (gnus-data-find-list after-article)))
7098 (or data (error "No such article: %d" after-article))
7099 (setcdr data (cons (gnus-data-make number mark pos header level)
7101 (setq gnus-newsgroup-data-reverse nil)
7102 (gnus-data-update-list (cddr data) offset)))
7104 (defun gnus-data-enter-list (after-article list &optional offset)
7106 (let ((data (and after-article (gnus-data-find-list after-article)))
7108 (or data (not after-article) (error "No such article: %d" after-article))
7109 ;; Find the last element in the list to be spliced into the main
7112 (setq list (cdr list)))
7115 (setcdr list gnus-newsgroup-data)
7116 (setq gnus-newsgroup-data ilist)
7117 (and offset (gnus-data-update-list (cdr list) offset)))
7118 (setcdr list (cdr data))
7120 (and offset (gnus-data-update-list (cdr data) offset)))
7121 (setq gnus-newsgroup-data-reverse nil))))
7123 (defun gnus-data-remove (article &optional offset)
7124 (let ((data gnus-newsgroup-data))
7125 (if (= (gnus-data-number (car data)) article)
7126 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7127 gnus-newsgroup-data-reverse nil)
7129 (and (= (gnus-data-number (cadr data)) article)
7131 (setcdr data (cddr data))
7132 (and offset (gnus-data-update-list (cdr data) offset))
7134 gnus-newsgroup-data-reverse nil)))
7135 (setq data (cdr data))))))
7137 (defmacro gnus-data-list (backward)
7139 (or gnus-newsgroup-data-reverse
7140 (setq gnus-newsgroup-data-reverse
7141 (reverse gnus-newsgroup-data)))
7142 gnus-newsgroup-data))
7144 (defun gnus-data-update-list (data offset)
7145 "Add OFFSET to the POS of all data entries in DATA."
7147 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7148 (setq data (cdr data))))
7150 (defun gnus-data-compute-positions ()
7151 "Compute the positions of all articles."
7152 (let ((data gnus-newsgroup-data)
7155 (when (setq pos (text-property-any
7156 (point-min) (point-max)
7157 'gnus-number (gnus-data-number (car data))))
7158 (gnus-data-set-pos (car data) (+ pos 3)))
7159 (setq data (cdr data)))))
7161 (defun gnus-summary-article-pseudo-p (article)
7162 "Say whether this article is a pseudo article or not."
7163 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7165 (defun gnus-article-parent-p (number)
7166 "Say whether this article is a parent or not."
7167 (let ((data (gnus-data-find-list number)))
7168 (and (cdr data) ; There has to be an article after...
7169 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7170 (gnus-data-level (nth 1 data))))))
7172 (defun gnus-article-children (number)
7173 "Return a list of all children to NUMBER."
7174 (let* ((data (gnus-data-find-list number))
7175 (level (gnus-data-level (car data)))
7177 (setq data (cdr data))
7179 (= (gnus-data-level (car data)) (1+ level)))
7180 (push (gnus-data-number (car data)) children)
7181 (setq data (cdr data)))
7184 (defmacro gnus-summary-skip-intangible ()
7185 "If the current article is intangible, then jump to a different article."
7186 '(let ((to (get-text-property (point) 'gnus-intangible)))
7187 (and to (gnus-summary-goto-subject to))))
7189 (defmacro gnus-summary-article-intangible-p ()
7190 "Say whether this article is intangible or not."
7191 '(get-text-property (point) 'gnus-intangible))
7193 ;; Some summary mode macros.
7195 (defmacro gnus-summary-article-number ()
7196 "The article number of the article on the current line.
7197 If there isn's an article number here, then we return the current
7200 (gnus-summary-skip-intangible)
7201 (or (get-text-property (point) 'gnus-number)
7202 (gnus-summary-last-subject))))
7204 (defmacro gnus-summary-article-header (&optional number)
7205 `(gnus-data-header (gnus-data-find
7206 ,(or number '(gnus-summary-article-number)))))
7208 (defmacro gnus-summary-thread-level (&optional number)
7209 `(if (and (eq gnus-summary-make-false-root 'dummy)
7210 (get-text-property (point) 'gnus-intangible))
7212 (gnus-data-level (gnus-data-find
7213 ,(or number '(gnus-summary-article-number))))))
7215 (defmacro gnus-summary-article-mark (&optional number)
7216 `(gnus-data-mark (gnus-data-find
7217 ,(or number '(gnus-summary-article-number)))))
7219 (defmacro gnus-summary-article-pos (&optional number)
7220 `(gnus-data-pos (gnus-data-find
7221 ,(or number '(gnus-summary-article-number)))))
7223 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7224 (defmacro gnus-summary-article-subject (&optional number)
7225 "Return current subject string or nil if nothing."
7228 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7229 '(gnus-data-header (assq (gnus-summary-article-number)
7230 gnus-newsgroup-data)))))
7233 (mail-header-subject headers))))
7235 (defmacro gnus-summary-article-score (&optional number)
7236 "Return current article score."
7237 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7238 gnus-newsgroup-scored))
7239 gnus-summary-default-score 0))
7241 (defun gnus-summary-article-children (&optional number)
7242 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7243 (level (gnus-data-level (car data)))
7245 (while (and (setq data (cdr data))
7246 (> (setq l (gnus-data-level (car data))) level))
7247 (and (= (1+ level) l)
7248 (setq children (cons (gnus-data-number (car data))
7250 (nreverse children)))
7252 (defun gnus-summary-article-parent (&optional number)
7253 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7254 (gnus-data-list t)))
7255 (level (gnus-data-level (car data))))
7257 () ; This is a root.
7258 ;; We search until we find an article with a level less than
7259 ;; this one. That function has to be the parent.
7260 (while (and (setq data (cdr data))
7261 (not (< (gnus-data-level (car data)) level))))
7262 (and data (gnus-data-number (car data))))))
7264 (defun gnus-unread-mark-p (mark)
7265 "Say whether MARK is the unread mark."
7266 (= mark gnus-unread-mark))
7268 (defun gnus-read-mark-p (mark)
7269 "Say whether MARK is one of the marks that mark as read.
7270 This is all marks except unread, ticked, dormant, and expirable."
7271 (not (or (= mark gnus-unread-mark)
7272 (= mark gnus-ticked-mark)
7273 (= mark gnus-dormant-mark)
7274 (= mark gnus-expirable-mark))))
7276 ;; Various summary mode internalish functions.
7278 (defun gnus-mouse-pick-article (e)
7281 (gnus-summary-next-page nil t))
7283 (defun gnus-summary-setup-buffer (group)
7284 "Initialize summary buffer."
7285 (let ((buffer (concat "*Summary " group "*")))
7286 (if (get-buffer buffer)
7289 (setq gnus-summary-buffer (current-buffer))
7290 (not gnus-newsgroup-prepared))
7291 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7292 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7293 (gnus-add-current-to-buffer-list)
7294 (gnus-summary-mode group)
7296 (gnus-carpal-setup-buffer 'summary))
7297 (unless gnus-single-article-buffer
7298 (make-local-variable 'gnus-article-buffer)
7299 (make-local-variable 'gnus-article-current)
7300 (make-local-variable 'gnus-original-article-buffer))
7301 (setq gnus-newsgroup-name group)
7304 (defun gnus-set-global-variables ()
7305 ;; Set the global equivalents of the summary buffer-local variables
7306 ;; to the latest values they had. These reflect the summary buffer
7307 ;; that was in action when the last article was fetched.
7308 (when (eq major-mode 'gnus-summary-mode)
7309 (setq gnus-summary-buffer (current-buffer))
7310 (let ((name gnus-newsgroup-name)
7311 (marked gnus-newsgroup-marked)
7312 (unread gnus-newsgroup-unreads)
7313 (headers gnus-current-headers)
7314 (data gnus-newsgroup-data)
7315 (summary gnus-summary-buffer)
7316 (article-buffer gnus-article-buffer)
7317 (original gnus-original-article-buffer)
7318 (gac gnus-article-current)
7319 (score-file gnus-current-score-file))
7321 (set-buffer gnus-group-buffer)
7322 (setq gnus-newsgroup-name name)
7323 (setq gnus-newsgroup-marked marked)
7324 (setq gnus-newsgroup-unreads unread)
7325 (setq gnus-current-headers headers)
7326 (setq gnus-newsgroup-data data)
7327 (setq gnus-article-current gac)
7328 (setq gnus-summary-buffer summary)
7329 (setq gnus-article-buffer article-buffer)
7330 (setq gnus-original-article-buffer original)
7331 (setq gnus-current-score-file score-file)))))
7333 (defun gnus-summary-last-article-p (&optional article)
7334 "Return whether ARTICLE is the last article in the buffer."
7335 (if (not (setq article (or article (gnus-summary-article-number))))
7336 t ; All non-existant numbers are the last article. :-)
7337 (cdr (gnus-data-find-list article))))
7339 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7340 "Insert a dummy root in the summary buffer."
7342 (add-text-properties
7343 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7344 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7346 (defvar gnus-thread-indent-array nil)
7347 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7348 (defun gnus-make-thread-indent-array ()
7350 (unless (and gnus-thread-indent-array
7351 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7352 (setq gnus-thread-indent-array (make-vector 201 "")
7353 gnus-thread-indent-array-level gnus-thread-indent-level)
7355 (aset gnus-thread-indent-array n
7356 (make-string (* n gnus-thread-indent-level) ? ))
7359 (defun gnus-summary-insert-line
7360 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7361 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7362 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7363 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7364 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7365 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7366 (gnus-tmp-score-char
7367 (if (or (null gnus-summary-default-score)
7368 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7369 gnus-summary-zcore-fuzz)) ?
7370 (if (< gnus-tmp-score gnus-summary-default-score)
7371 gnus-score-below-mark gnus-score-over-mark)))
7372 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7373 ((memq gnus-tmp-current gnus-newsgroup-cached)
7375 (gnus-tmp-replied gnus-replied-mark)
7376 ((memq gnus-tmp-current gnus-newsgroup-saved)
7378 (t gnus-unread-mark)))
7379 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7382 ((string-match "(.+)" gnus-tmp-from)
7383 (substring gnus-tmp-from
7384 (1+ (match-beginning 0)) (1- (match-end 0))))
7385 ((string-match "<[^>]+> *$" gnus-tmp-from)
7386 (let ((beg (match-beginning 0)))
7387 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7388 (substring gnus-tmp-from (1+ (match-beginning 0))
7389 (1- (match-end 0))))
7390 (substring gnus-tmp-from 0 beg))))
7392 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7393 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7394 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7395 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7396 (buffer-read-only nil))
7397 (when (string= gnus-tmp-name "")
7398 (setq gnus-tmp-name gnus-tmp-from))
7399 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7402 (progn (eval gnus-summary-line-format-spec) (point))
7403 'gnus-number gnus-tmp-number)
7404 (when (gnus-visual-p 'summary-highlight 'highlight)
7406 (run-hooks 'gnus-summary-update-hook)
7409 (defun gnus-summary-update-line (&optional dont-update)
7410 ;; Update summary line after change.
7411 (when (and gnus-summary-default-score
7412 (not gnus-summary-inhibit-highlight))
7413 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7414 (article (gnus-summary-article-number))
7415 (score (gnus-summary-article-score article)))
7417 (if (and gnus-summary-mark-below
7418 (< (gnus-summary-article-score)
7419 gnus-summary-mark-below))
7420 ;; This article has a low score, so we mark it as read.
7421 (when (memq article gnus-newsgroup-unreads)
7422 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7423 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7424 ;; This article was previously marked as read on account
7425 ;; of a low score, but now it has risen, so we mark it as
7427 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7428 (gnus-summary-update-mark
7429 (if (or (null gnus-summary-default-score)
7430 (<= (abs (- score gnus-summary-default-score))
7431 gnus-summary-zcore-fuzz)) ?
7432 (if (< score gnus-summary-default-score)
7433 gnus-score-below-mark gnus-score-over-mark)) 'score))
7434 ;; Do visual highlighting.
7435 (when (gnus-visual-p 'summary-highlight 'highlight)
7436 (run-hooks 'gnus-summary-update-hook)))))
7438 (defvar gnus-tmp-new-adopts nil)
7440 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7441 ;; Sum up all elements (and sub-elements) in a list.
7443 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7445 ((and (consp thread) (cdr thread))
7448 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7451 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7454 (when (and level (zerop level) gnus-tmp-new-adopts)
7457 'gnus-summary-number-of-articles-in-thread
7458 gnus-tmp-new-adopts))))
7460 (if (> number 1) gnus-not-empty-thread-mark
7461 gnus-empty-thread-mark)
7464 (defun gnus-summary-set-local-parameters (group)
7465 "Go through the local params of GROUP and set all variable specs in that list."
7466 (let ((params (gnus-info-params (gnus-get-info group)))
7469 (setq elem (car params)
7470 params (cdr params))
7471 (and (consp elem) ; Has to be a cons.
7472 (consp (cdr elem)) ; The cdr has to be a list.
7473 (symbolp (car elem)) ; Has to be a symbol in there.
7474 (not (memq (car elem)
7475 '(quit-config to-address to-list to-group)))
7476 (progn ; So we set it.
7477 (make-local-variable (car elem))
7478 (set (car elem) (eval (nth 1 elem))))))))
7480 (defun gnus-summary-read-group (group &optional show-all no-article
7481 kill-buffer no-display)
7482 "Start reading news in newsgroup GROUP.
7483 If SHOW-ALL is non-nil, already read articles are also listed.
7484 If NO-ARTICLE is non-nil, no article is selected initially.
7485 If NO-DISPLAY, don't generate a summary buffer."
7486 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7487 (let* ((new-group (gnus-summary-setup-buffer group))
7488 (quit-config (gnus-group-quit-config group))
7489 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7491 ;; This summary buffer exists already, so we just select it.
7493 (gnus-set-global-variables)
7495 (gnus-kill-or-deaden-summary kill-buffer))
7496 (gnus-configure-windows 'summary 'force)
7497 (gnus-set-mode-line 'summary)
7498 (gnus-summary-position-point)
7501 ;; We couldn't select this group.
7503 (when (and (eq major-mode 'gnus-summary-mode)
7504 (not (equal (current-buffer) kill-buffer)))
7505 (kill-buffer (current-buffer))
7506 (if (not quit-config)
7508 (set-buffer gnus-group-buffer)
7509 (gnus-group-jump-to-group group)
7510 (gnus-group-next-unread-group 1))
7511 (if (not (buffer-name (car quit-config)))
7512 (gnus-configure-windows 'group 'force)
7513 (set-buffer (car quit-config))
7514 (and (eq major-mode 'gnus-summary-mode)
7515 (gnus-set-global-variables))
7516 (gnus-configure-windows (cdr quit-config)))))
7517 (gnus-message 3 "Can't select group")
7519 ;; The user did a `C-g' while prompting for number of articles,
7520 ;; so we exit this group.
7521 ((eq did-select 'quit)
7522 (and (eq major-mode 'gnus-summary-mode)
7523 (not (equal (current-buffer) kill-buffer))
7524 (kill-buffer (current-buffer)))
7526 (gnus-kill-or-deaden-summary kill-buffer))
7527 (if (not quit-config)
7529 (set-buffer gnus-group-buffer)
7530 (gnus-group-jump-to-group group)
7531 (gnus-group-next-unread-group 1)
7532 (gnus-configure-windows 'group 'force))
7533 (if (not (buffer-name (car quit-config)))
7534 (gnus-configure-windows 'group 'force)
7535 (set-buffer (car quit-config))
7536 (and (eq major-mode 'gnus-summary-mode)
7537 (gnus-set-global-variables))
7538 (gnus-configure-windows (cdr quit-config))))
7539 ;; Finally signal the quit.
7541 ;; The group was successfully selected.
7543 (gnus-set-global-variables)
7544 ;; Save the active value in effect when the group was entered.
7545 (setq gnus-newsgroup-active
7547 (gnus-active gnus-newsgroup-name)))
7548 ;; You can change the summary buffer in some way with this hook.
7549 (run-hooks 'gnus-select-group-hook)
7550 ;; Set any local variables in the group parameters.
7551 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7552 (gnus-update-format-specifications)
7553 ;; Do score processing.
7554 (when gnus-use-scoring
7555 (gnus-possibly-score-headers))
7556 ;; Check whether to fill in the gaps in the threads.
7557 (when gnus-build-sparse-threads
7558 (gnus-build-sparse-threads))
7559 ;; Find the initial limit.
7561 (let ((gnus-newsgroup-dormant nil))
7562 (gnus-summary-initial-limit show-all))
7563 (gnus-summary-initial-limit show-all))
7564 ;; Generate the summary buffer.
7566 (gnus-summary-prepare))
7567 (when gnus-use-trees
7568 (gnus-tree-open group)
7569 (setq gnus-summary-highlight-line-function
7570 'gnus-tree-highlight-article))
7571 ;; If the summary buffer is empty, but there are some low-scored
7572 ;; articles or some excluded dormants, we include these in the
7574 (when (and (zerop (buffer-size))
7576 (cond (gnus-newsgroup-dormant
7577 (gnus-summary-limit-include-dormant))
7578 ((and gnus-newsgroup-scored show-all)
7579 (gnus-summary-limit-include-expunged))))
7580 ;; Function `gnus-apply-kill-file' must be called in this hook.
7581 (run-hooks 'gnus-apply-kill-hook)
7582 (if (and (zerop (buffer-size))
7585 ;; This newsgroup is empty.
7586 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7587 (gnus-message 6 "No unread news")
7589 (gnus-kill-or-deaden-summary kill-buffer))
7590 ;; Return nil from this function.
7592 ;; Hide conversation thread subtrees. We cannot do this in
7593 ;; gnus-summary-prepare-hook since kill processing may not
7594 ;; work with hidden articles.
7595 (and gnus-show-threads
7596 gnus-thread-hide-subtree
7597 (gnus-summary-hide-all-threads))
7598 ;; Show first unread article if requested.
7599 (if (and (not no-article)
7601 gnus-newsgroup-unreads
7602 gnus-auto-select-first)
7603 (if (eq gnus-auto-select-first 'best)
7604 (gnus-summary-best-unread-article)
7605 (gnus-summary-first-unread-article))
7606 ;; Don't select any articles, just move point to the first
7607 ;; article in the group.
7608 (goto-char (point-min))
7609 (gnus-summary-position-point)
7610 (gnus-set-mode-line 'summary)
7611 (gnus-configure-windows 'summary 'force))
7612 ;; If we are in async mode, we send some info to the backend.
7613 (when gnus-newsgroup-async
7614 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7616 (gnus-kill-or-deaden-summary kill-buffer))
7617 (when (get-buffer-window gnus-group-buffer t)
7618 ;; Gotta use windows, because recenter does wierd stuff if
7619 ;; the current buffer ain't the displayed window.
7620 (let ((owin (selected-window)))
7621 (select-window (get-buffer-window gnus-group-buffer t))
7622 (when (gnus-group-goto-group group)
7624 (select-window owin))))
7625 ;; Mark this buffer as "prepared".
7626 (setq gnus-newsgroup-prepared t)
7629 (defun gnus-summary-prepare ()
7630 "Generate the summary buffer."
7631 (let ((buffer-read-only nil))
7633 (setq gnus-newsgroup-data nil
7634 gnus-newsgroup-data-reverse nil)
7635 (run-hooks 'gnus-summary-generate-hook)
7636 ;; Generate the buffer, either with threads or without.
7637 (when gnus-newsgroup-headers
7638 (gnus-summary-prepare-threads
7639 (if gnus-show-threads
7640 (gnus-sort-gathered-threads
7641 (funcall gnus-summary-thread-gathering-function
7643 (gnus-cut-threads (gnus-make-threads)))))
7644 ;; Unthreaded display.
7645 (gnus-sort-articles gnus-newsgroup-headers))))
7646 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7647 ;; Call hooks for modifying summary buffer.
7648 (goto-char (point-min))
7649 (run-hooks 'gnus-summary-prepare-hook)))
7651 (defun gnus-gather-threads-by-subject (threads)
7652 "Gather threads by looking at Subject headers."
7653 (if (not gnus-summary-make-false-root)
7655 (let ((hashtb (gnus-make-hashtable 1023))
7658 subject hthread whole-subject)
7660 (setq whole-subject (mail-header-subject (caar threads)))
7663 ;; Truncate the subject.
7664 ((numberp gnus-summary-gather-subject-limit)
7665 (setq subject (gnus-simplify-subject-re whole-subject))
7666 (if (> (length subject) gnus-summary-gather-subject-limit)
7667 (substring subject 0 gnus-summary-gather-subject-limit)
7669 ;; Fuzzily simplify it.
7670 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7671 (gnus-simplify-subject-fuzzy whole-subject))
7672 ;; Just remove the leading "Re:".
7674 (gnus-simplify-subject-re whole-subject))))
7676 (if (and gnus-summary-gather-exclude-subject
7677 (string-match gnus-summary-gather-exclude-subject
7679 () ; We don't want to do anything with this article.
7680 ;; We simplify the subject before looking it up in the
7683 (if (setq hthread (gnus-gethash subject hashtb))
7685 ;; We enter a dummy root into the thread, if we
7686 ;; haven't done that already.
7687 (unless (stringp (caar hthread))
7688 (setcar hthread (list whole-subject (car hthread))))
7689 ;; We add this new gathered thread to this gathered
7691 (setcdr (car hthread)
7692 (nconc (cdar hthread) (list (car threads))))
7693 ;; Remove it from the list of threads.
7694 (setcdr prev (cdr threads))
7695 (setq threads prev))
7696 ;; Enter this thread into the hash table.
7697 (gnus-sethash subject threads hashtb)))
7699 (setq threads (cdr threads)))
7702 (defun gnus-gather-threads-by-references (threads)
7703 "Gather threads by looking at References headers."
7704 (let ((idhashtb (gnus-make-hashtable 1023))
7705 (thhashtb (gnus-make-hashtable 1023))
7708 ids references id gthread gid entered)
7710 (when (setq references (mail-header-references (caar threads)))
7711 (setq id (mail-header-id (caar threads)))
7712 (setq ids (gnus-split-references references))
7715 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7717 (gnus-sethash (car ids) id idhashtb)
7718 (gnus-sethash id threads thhashtb))
7719 (setq gthread (gnus-gethash gid thhashtb))
7721 ;; We enter a dummy root into the thread, if we
7722 ;; haven't done that already.
7723 (unless (stringp (caar gthread))
7724 (setcar gthread (list (mail-header-subject (caar gthread))
7726 ;; We add this new gathered thread to this gathered
7728 (setcdr (car gthread)
7729 (nconc (cdar gthread) (list (car threads)))))
7730 ;; Add it into the thread hash table.
7731 (gnus-sethash id gthread thhashtb)
7733 ;; Remove it from the list of threads.
7734 (setcdr prev (cdr threads))
7735 (setq threads prev))
7736 (setq ids (cdr ids))))
7738 (setq threads (cdr threads)))
7741 (defun gnus-sort-gathered-threads (threads)
7742 "Sort subtreads inside each gathered thread by article number."
7743 (let ((result threads))
7745 (when (stringp (caar threads))
7746 (setcdr (car threads)
7747 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7748 (setq threads (cdr threads)))
7751 (defun gnus-make-threads ()
7752 "Go through the dependency hashtb and find the roots. Return all threads."
7756 (unless (car (symbol-value refs))
7757 ;; These threads do not refer back to any other articles,
7758 ;; so they're roots.
7759 (setq threads (append (cdr (symbol-value refs)) threads))))
7760 gnus-newsgroup-dependencies)
7763 (defun gnus-build-sparse-threads ()
7764 (let ((headers gnus-newsgroup-headers)
7765 (deps gnus-newsgroup-dependencies)
7766 header references generation relations
7767 cthread subject child end pthread relation)
7768 ;; First we create an alist of generations/relations, where
7769 ;; generations is how much we trust the ralation, and the relation
7771 (gnus-message 7 "Making sparse threads...")
7773 (nnheader-set-temp-buffer " *gnus sparse threads*")
7774 (while (setq header (pop headers))
7775 (when (and (setq references (mail-header-references header))
7776 (not (string= references "")))
7778 (setq child (mail-header-id header)
7779 subject (mail-header-subject header))
7781 (while (search-backward ">" nil t)
7782 (setq end (1+ (point)))
7783 (when (search-backward "<" nil t)
7784 (push (list (incf generation)
7785 child (setq child (buffer-substring (point) end))
7788 (push (list (1+ generation) child nil subject) relations)
7790 (kill-buffer (current-buffer)))
7791 ;; Sort over trustworthiness.
7792 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7793 (while (setq relation (pop relations))
7794 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7795 (unless (car (symbol-value cthread))
7796 ;; Make this article the parent of these threads.
7797 (setcar (symbol-value cthread)
7798 (vector gnus-reffed-article-number
7802 (or (caddr relation) "") 0 0 "")))
7803 (set cthread (list (vector gnus-reffed-article-number
7805 "" "" (cadr relation)
7806 (or (caddr relation) "") 0 0 ""))))
7807 (push gnus-reffed-article-number gnus-newsgroup-limit)
7808 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7809 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7810 gnus-newsgroup-reads)
7811 (decf gnus-reffed-article-number)
7812 ;; Make this new thread the child of its parent.
7813 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7814 (setcdr (symbol-value pthread)
7815 (nconc (cdr (symbol-value pthread))
7816 (list (symbol-value cthread))))
7817 (set pthread (list nil (symbol-value cthread))))))
7818 (gnus-message 7 "Making sparse threads...done")))
7820 (defun gnus-build-old-threads ()
7821 ;; Look at all the articles that refer back to old articles, and
7822 ;; fetch the headers for the articles that aren't there. This will
7823 ;; build complete threads - if the roots haven't been expired by the
7828 (when (not (car (symbol-value refs)))
7829 (setq heads (cdr (symbol-value refs)))
7831 (if (memq (mail-header-number (caar heads))
7832 gnus-newsgroup-dormant)
7833 (setq heads (cdr heads))
7834 (setq id (symbol-name refs))
7835 (while (and (setq id (gnus-build-get-header id))
7836 (not (car (gnus-gethash
7837 id gnus-newsgroup-dependencies)))))
7838 (setq heads nil)))))
7839 gnus-newsgroup-dependencies)))
7841 (defun gnus-build-get-header (id)
7842 ;; Look through the buffer of NOV lines and find the header to
7843 ;; ID. Enter this line into the dependencies hash table, and return
7844 ;; the id of the parent article (if any).
7845 (let ((deps gnus-newsgroup-dependencies)
7849 (set-buffer nntp-server-buffer)
7850 (goto-char (point-min))
7851 (while (and (not found) (search-forward id nil t))
7853 (setq found (looking-at
7854 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7855 (regexp-quote id))))
7856 (or found (beginning-of-line 2)))
7860 (setq header (gnus-nov-parse-line
7861 (read (current-buffer)) deps))
7862 (gnus-parent-id (mail-header-references header)))))
7864 (let ((number (mail-header-number header)))
7865 (push number gnus-newsgroup-limit)
7866 (push header gnus-newsgroup-headers)
7867 (if (memq number gnus-newsgroup-unselected)
7869 (push number gnus-newsgroup-unreads)
7870 (setq gnus-newsgroup-unselected
7871 (delq number gnus-newsgroup-unselected)))
7872 (push number gnus-newsgroup-ancient)))))))
7874 (defun gnus-summary-update-article (article &optional header)
7875 "Update ARTICLE in the summary buffer."
7876 (set-buffer gnus-summary-buffer)
7877 (let* ((header (or header (gnus-summary-article-header article)))
7878 (id (mail-header-id header))
7879 (data (gnus-data-find article))
7880 (thread (gnus-id-to-thread id))
7882 (gnus-id-to-thread (or (gnus-parent-id
7883 (mail-header-references header))
7885 (buffer-read-only nil)
7887 (number (mail-header-number header))
7892 (delq thread parent))
7893 (if (gnus-summary-insert-subject id header)
7894 ;; Set the (possibly) new article number in the data structure.
7895 (gnus-data-set-number data (gnus-id-to-article id))
7899 (defun gnus-rebuild-thread (id)
7900 "Rebuild the thread containing ID."
7901 (let ((buffer-read-only nil)
7902 current thread data)
7903 (if (not gnus-show-threads)
7904 (setq thread (list (car (gnus-id-to-thread id))))
7905 ;; Get the thread this article is part of.
7906 (setq thread (gnus-remove-thread id)))
7907 (setq current (save-excursion
7908 (and (zerop (forward-line -1))
7909 (gnus-summary-article-number))))
7910 ;; If this is a gathered thread, we have to go some re-gathering.
7911 (when (stringp (car thread))
7912 (let ((subject (car thread))
7914 (setq thread (cdr thread))
7916 (unless (memq (setq thr (gnus-id-to-thread
7918 (mail-header-id (caar thread)))))
7921 (setq thread (cdr thread)))
7922 ;; We now have all (unique) roots.
7923 (if (= (length roots) 1)
7924 ;; All the loose roots are now one solid root.
7925 (setq thread (car roots))
7926 (setq thread (cons subject (gnus-sort-threads roots))))))
7928 ;; We then insert this thread into the summary buffer.
7929 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7930 (gnus-summary-prepare-threads (list thread))
7931 (setq data (nreverse gnus-newsgroup-data))
7932 (setq threads gnus-newsgroup-threads))
7933 ;; We splice the new data into the data structure.
7934 (gnus-data-enter-list current data)
7935 (gnus-data-compute-positions)
7936 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7938 (defun gnus-id-to-thread (id)
7939 "Return the (sub-)thread where ID appears."
7940 (gnus-gethash id gnus-newsgroup-dependencies))
7942 (defun gnus-id-to-article (id)
7943 "Return the article number of ID."
7944 (let ((thread (gnus-id-to-thread id)))
7946 (mail-header-number (car thread)))))
7948 (defun gnus-id-to-header (id)
7949 "Return the article headers of ID."
7950 (car (gnus-id-to-thread id)))
7952 (defun gnus-article-displayed-root-p (article)
7953 "Say whether ARTICLE is a root(ish) article."
7954 (let ((level (gnus-summary-thread-level article))
7960 (null (setq particle (gnus-id-to-article
7962 (mail-header-references
7963 (gnus-summary-article-header article))))))
7964 (null (gnus-summary-thread-level particle)))))))
7966 (defun gnus-root-id (id)
7967 "Return the id of the root of the thread where ID appears."
7969 (while (and id (setq prev (car (gnus-gethash
7970 id gnus-newsgroup-dependencies))))
7972 id (gnus-parent-id (mail-header-references prev))))
7975 (defun gnus-remove-thread (id &optional dont-remove)
7976 "Remove the thread that has ID in it."
7977 (let ((dep gnus-newsgroup-dependencies)
7978 headers thread last-id)
7979 ;; First go up in this thread until we find the root.
7980 (setq last-id (gnus-root-id id))
7981 (setq headers (list (car (gnus-id-to-thread last-id))
7982 (caadr (gnus-id-to-thread last-id))))
7983 ;; We have now found the real root of this thread. It might have
7984 ;; been gathered into some loose thread, so we have to search
7985 ;; through the threads to find the thread we wanted.
7986 (let ((threads gnus-newsgroup-threads)
7989 (setq sub (car threads))
7990 (if (stringp (car sub))
7991 ;; This is a gathered threads, so we look at the roots
7992 ;; below it to find whether this article in in this
7995 (setq sub (cdr sub))
7997 (when (member (caar sub) headers)
7998 (setq thread (car threads)
8001 (setq sub (cdr sub))))
8002 ;; It's an ordinary thread, so we check it.
8003 (when (eq (car sub) (car headers))
8006 (setq threads (cdr threads)))
8007 ;; If this article is in no thread, then it's a root.
8010 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8011 (setq thread (gnus-gethash last-id dep)))
8014 thread ; We return this thread.
8016 (if (stringp (car thread))
8018 ;; If we use dummy roots, then we have to remove the
8019 ;; dummy root as well.
8020 (when (eq gnus-summary-make-false-root 'dummy)
8023 (setq thread (cdr thread))
8025 (gnus-remove-thread-1 (car thread))
8026 (setq thread (cdr thread))))
8027 (gnus-remove-thread-1 thread))))))))
8029 (defun gnus-remove-thread-1 (thread)
8030 "Remove the thread THREAD recursively."
8031 (let ((number (mail-header-number (car thread)))
8033 (when (setq pos (text-property-any
8034 (point-min) (point-max) 'gnus-number number))
8037 (gnus-data-remove number))
8038 (setq thread (cdr thread))
8040 (gnus-remove-thread-1 (pop thread)))))
8042 (defun gnus-sort-threads (threads)
8044 (if (not gnus-thread-sort-functions)
8046 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8047 (car gnus-thread-sort-functions)
8049 ,(gnus-make-sort-function
8050 (reverse gnus-thread-sort-functions))))))
8051 (gnus-message 7 "Sorting threads...")
8054 (gnus-message 7 "Sorting threads...done")))))
8056 (defun gnus-sort-articles (articles)
8058 (when gnus-article-sort-functions
8059 (let ((func (if (= 1 (length gnus-article-sort-functions))
8060 (car gnus-article-sort-functions)
8062 ,(gnus-make-sort-function
8063 (reverse gnus-article-sort-functions))))))
8064 (gnus-message 7 "Sorting articles...")
8066 (setq gnus-newsgroup-headers (sort articles func))
8067 (gnus-message 7 "Sorting articles...done")))))
8069 (defun gnus-make-sort-function (funs)
8070 "Return a composite sort condition based on the functions in FUNC."
8072 `(or (,(car funs) t1 t2)
8073 (and (not (,(car funs) t2 t1))
8074 ,(gnus-make-sort-function (cdr funs))))
8075 `(,(car funs) t1 t2)))
8077 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8078 (defmacro gnus-thread-header (thread)
8079 ;; Return header of first article in THREAD.
8080 ;; Note that THREAD must never, ever be anything else than a variable -
8081 ;; using some other form will lead to serious barfage.
8082 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8083 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8084 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8087 (defsubst gnus-article-sort-by-number (h1 h2)
8088 "Sort articles by article number."
8089 (< (mail-header-number h1)
8090 (mail-header-number h2)))
8092 (defun gnus-thread-sort-by-number (h1 h2)
8093 "Sort threads by root article number."
8094 (gnus-article-sort-by-number
8095 (gnus-thread-header h1) (gnus-thread-header h2)))
8097 (defsubst gnus-article-sort-by-author (h1 h2)
8098 "Sort articles by root author."
8100 (let ((extract (funcall
8101 gnus-extract-address-components
8102 (mail-header-from h1))))
8103 (or (car extract) (cdr extract)))
8104 (let ((extract (funcall
8105 gnus-extract-address-components
8106 (mail-header-from h2))))
8107 (or (car extract) (cdr extract)))))
8109 (defun gnus-thread-sort-by-author (h1 h2)
8110 "Sort threads by root author."
8111 (gnus-article-sort-by-author
8112 (gnus-thread-header h1) (gnus-thread-header h2)))
8114 (defsubst gnus-article-sort-by-subject (h1 h2)
8115 "Sort articles by root subject."
8117 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8118 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8120 (defun gnus-thread-sort-by-subject (h1 h2)
8121 "Sort threads by root subject."
8122 (gnus-article-sort-by-subject
8123 (gnus-thread-header h1) (gnus-thread-header h2)))
8125 (defsubst gnus-article-sort-by-date (h1 h2)
8126 "Sort articles by root article date."
8128 (gnus-sortable-date (mail-header-date h1))
8129 (gnus-sortable-date (mail-header-date h2))))
8131 (defun gnus-thread-sort-by-date (h1 h2)
8132 "Sort threads by root article date."
8133 (gnus-article-sort-by-date
8134 (gnus-thread-header h1) (gnus-thread-header h2)))
8136 (defsubst gnus-article-sort-by-score (h1 h2)
8137 "Sort articles by root article score.
8138 Unscored articles will be counted as having a score of zero."
8139 (> (or (cdr (assq (mail-header-number h1)
8140 gnus-newsgroup-scored))
8141 gnus-summary-default-score 0)
8142 (or (cdr (assq (mail-header-number h2)
8143 gnus-newsgroup-scored))
8144 gnus-summary-default-score 0)))
8146 (defun gnus-thread-sort-by-score (h1 h2)
8147 "Sort threads by root article score."
8148 (gnus-article-sort-by-score
8149 (gnus-thread-header h1) (gnus-thread-header h2)))
8151 (defun gnus-thread-sort-by-total-score (h1 h2)
8152 "Sort threads by the sum of all scores in the thread.
8153 Unscored articles will be counted as having a score of zero."
8154 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8156 (defun gnus-thread-total-score (thread)
8157 ;; This function find the total score of THREAD.
8159 (if (stringp (car thread))
8160 (apply gnus-thread-score-function 0
8161 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8162 (gnus-thread-total-score-1 thread))
8163 (gnus-thread-total-score-1 (list thread))))
8165 (defun gnus-thread-total-score-1 (root)
8166 ;; This function find the total score of the thread below ROOT.
8167 (setq root (car root))
8168 (apply gnus-thread-score-function
8169 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8170 gnus-summary-default-score 0)
8171 (mapcar 'gnus-thread-total-score
8172 (cdr (gnus-gethash (mail-header-id root)
8173 gnus-newsgroup-dependencies)))))
8175 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8176 (defvar gnus-tmp-prev-subject nil)
8177 (defvar gnus-tmp-false-parent nil)
8178 (defvar gnus-tmp-root-expunged nil)
8179 (defvar gnus-tmp-dummy-line nil)
8181 (defun gnus-summary-prepare-threads (threads)
8182 "Prepare summary buffer from THREADS and indentation LEVEL.
8183 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8184 or a straight list of headers."
8185 (gnus-message 7 "Generating summary...")
8187 (setq gnus-newsgroup-threads threads)
8190 (let ((gnus-tmp-level 0)
8191 (default-score (or gnus-summary-default-score 0))
8192 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8193 thread number subject stack state gnus-tmp-gathered beg-match
8194 new-roots gnus-tmp-new-adopts thread-end
8195 gnus-tmp-header gnus-tmp-unread
8196 gnus-tmp-replied gnus-tmp-subject-or-nil
8197 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8198 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8199 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8201 (setq gnus-tmp-prev-subject nil)
8203 (if (vectorp (car threads))
8204 ;; If this is a straight (sic) list of headers, then a
8205 ;; threaded summary display isn't required, so we just create
8206 ;; an unthreaded one.
8207 (gnus-summary-prepare-unthreaded threads)
8209 ;; Do the threaded display.
8211 (while (or threads stack gnus-tmp-new-adopts new-roots)
8213 (if (and (= gnus-tmp-level 0)
8214 (not (setq gnus-tmp-dummy-line nil))
8217 (not gnus-tmp-false-parent)
8218 (or gnus-tmp-new-adopts new-roots))
8219 (if gnus-tmp-new-adopts
8220 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8221 thread (list (car gnus-tmp-new-adopts))
8222 gnus-tmp-header (caar thread)
8223 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8225 (setq thread (list (car new-roots))
8226 gnus-tmp-header (caar thread)
8227 new-roots (cdr new-roots))))
8230 ;; If there are some threads, we do them before the
8231 ;; threads on the stack.
8232 (setq thread threads
8233 gnus-tmp-header (caar thread))
8234 ;; There were no current threads, so we pop something off
8236 (setq state (car stack)
8237 gnus-tmp-level (car state)
8240 gnus-tmp-header (caar thread))))
8242 (setq gnus-tmp-false-parent nil)
8243 (setq gnus-tmp-root-expunged nil)
8244 (setq thread-end nil)
8246 (if (stringp gnus-tmp-header)
8247 ;; The header is a dummy root.
8249 ((eq gnus-summary-make-false-root 'adopt)
8250 ;; We let the first article adopt the rest.
8251 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8253 (setq gnus-tmp-gathered
8255 (lambda (h) (mail-header-number (car h)))
8258 (setq thread (cons (list (caar thread)
8261 (setq gnus-tmp-level -1
8262 gnus-tmp-false-parent t))
8263 ((eq gnus-summary-make-false-root 'empty)
8264 ;; We print adopted articles with empty subject fields.
8265 (setq gnus-tmp-gathered
8267 (lambda (h) (mail-header-number (car h)))
8270 (setq gnus-tmp-level -1))
8271 ((eq gnus-summary-make-false-root 'dummy)
8272 ;; We remember that we probably want to output a dummy
8274 (setq gnus-tmp-dummy-line gnus-tmp-header)
8275 (setq gnus-tmp-prev-subject gnus-tmp-header))
8277 ;; We do not make a root for the gathered
8278 ;; sub-threads at all.
8279 (setq gnus-tmp-level -1)))
8281 (setq number (mail-header-number gnus-tmp-header)
8282 subject (mail-header-subject gnus-tmp-header))
8285 ;; If the thread has changed subject, we might want to make
8286 ;; this subthread into a root.
8287 ((and (null gnus-thread-ignore-subject)
8288 (not (zerop gnus-tmp-level))
8289 gnus-tmp-prev-subject
8291 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8292 (setq new-roots (nconc new-roots (list (car thread)))
8294 gnus-tmp-header nil))
8295 ;; If the article lies outside the current limit,
8296 ;; then we do not display it.
8297 ((and (not (memq number gnus-newsgroup-limit))
8298 (not gnus-tmp-dummy-line))
8299 (setq gnus-tmp-gathered
8301 (lambda (h) (mail-header-number (car h)))
8304 (setq gnus-tmp-new-adopts (if (cdar thread)
8305 (append gnus-tmp-new-adopts
8307 gnus-tmp-new-adopts)
8309 gnus-tmp-header nil)
8310 (when (zerop gnus-tmp-level)
8311 (setq gnus-tmp-root-expunged t)))
8312 ;; Perhaps this article is to be marked as read?
8313 ((and gnus-summary-mark-below
8314 (< (or (cdr (assq number gnus-newsgroup-scored))
8316 gnus-summary-mark-below)
8317 ;; Don't touch sparse articles.
8318 (not (memq number gnus-newsgroup-sparse)))
8319 (setq gnus-newsgroup-unreads
8320 (delq number gnus-newsgroup-unreads))
8321 (if gnus-newsgroup-auto-expire
8322 (push number gnus-newsgroup-expirable)
8323 (push (cons number gnus-low-score-mark)
8324 gnus-newsgroup-reads))))
8326 (when gnus-tmp-header
8327 ;; We may have an old dummy line to output before this
8329 (when gnus-tmp-dummy-line
8330 (gnus-summary-insert-dummy-line
8331 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8332 (setq gnus-tmp-dummy-line nil))
8334 ;; Compute the mark.
8338 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8339 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8340 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8341 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8342 (t (or (cdr (assq number gnus-newsgroup-reads))
8343 gnus-ancient-mark))))
8345 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8346 gnus-tmp-header gnus-tmp-level)
8347 gnus-newsgroup-data)
8349 ;; Actually insert the line.
8351 gnus-tmp-subject-or-nil
8353 ((and gnus-thread-ignore-subject
8354 gnus-tmp-prev-subject
8355 (not (inline (gnus-subject-equal
8356 gnus-tmp-prev-subject subject))))
8358 ((zerop gnus-tmp-level)
8359 (if (and (eq gnus-summary-make-false-root 'empty)
8360 (memq number gnus-tmp-gathered)
8361 gnus-tmp-prev-subject
8362 (inline (gnus-subject-equal
8363 gnus-tmp-prev-subject subject)))
8364 gnus-summary-same-subject
8366 (t gnus-summary-same-subject)))
8367 (if (and (eq gnus-summary-make-false-root 'adopt)
8368 (= gnus-tmp-level 1)
8369 (memq number gnus-tmp-gathered))
8370 (setq gnus-tmp-opening-bracket ?\<
8371 gnus-tmp-closing-bracket ?\>)
8372 (setq gnus-tmp-opening-bracket ?\[
8373 gnus-tmp-closing-bracket ?\]))
8375 gnus-tmp-indentation
8376 (aref gnus-thread-indent-array gnus-tmp-level)
8377 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8378 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8379 gnus-summary-default-score 0)
8381 (if (or (null gnus-summary-default-score)
8382 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8383 gnus-summary-zcore-fuzz)) ?
8384 (if (< gnus-tmp-score gnus-summary-default-score)
8385 gnus-score-below-mark gnus-score-over-mark))
8387 (cond ((memq number gnus-newsgroup-processable)
8389 ((memq number gnus-newsgroup-cached)
8391 ((memq number gnus-newsgroup-replied)
8393 (t gnus-unread-mark))
8394 gnus-tmp-from (mail-header-from gnus-tmp-header)
8397 ((string-match "(.+)" gnus-tmp-from)
8398 (substring gnus-tmp-from
8399 (1+ (match-beginning 0)) (1- (match-end 0))))
8400 ((string-match "<[^>]+> *$" gnus-tmp-from)
8401 (setq beg-match (match-beginning 0))
8402 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8403 (substring gnus-tmp-from (1+ (match-beginning 0))
8404 (1- (match-end 0))))
8405 (substring gnus-tmp-from 0 beg-match)))
8407 (when (string= gnus-tmp-name "")
8408 (setq gnus-tmp-name gnus-tmp-from))
8409 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8412 (progn (eval gnus-summary-line-format-spec) (point))
8413 'gnus-number number)
8416 (run-hooks 'gnus-summary-update-hook)
8419 (setq gnus-tmp-prev-subject subject)))
8421 (when (nth 1 thread)
8422 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8423 (incf gnus-tmp-level)
8424 (setq threads (if thread-end nil (cdar thread)))
8426 (setq gnus-tmp-level 0)))))
8427 (gnus-message 7 "Generating summary...done"))
8429 (defun gnus-summary-prepare-unthreaded (headers)
8430 "Generate an unthreaded summary buffer based on HEADERS."
8431 (let (header number mark)
8434 (setq header (car headers)
8435 headers (cdr headers)
8436 number (mail-header-number header))
8438 ;; We may have to root out some bad articles...
8439 (when (memq number gnus-newsgroup-limit)
8440 (when (and gnus-summary-mark-below
8441 (< (or (cdr (assq number gnus-newsgroup-scored))
8442 gnus-summary-default-score 0)
8443 gnus-summary-mark-below))
8444 (setq gnus-newsgroup-unreads
8445 (delq number gnus-newsgroup-unreads))
8446 (if gnus-newsgroup-auto-expire
8447 (push number gnus-newsgroup-expirable)
8448 (push (cons number gnus-low-score-mark)
8449 gnus-newsgroup-reads)))
8453 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8454 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8455 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8456 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8457 (t (or (cdr (assq number gnus-newsgroup-reads))
8458 gnus-ancient-mark))))
8459 (setq gnus-newsgroup-data
8460 (cons (gnus-data-make number mark (1+ (point)) header 0)
8461 gnus-newsgroup-data))
8462 (gnus-summary-insert-line
8463 header 0 nil mark (memq number gnus-newsgroup-replied)
8464 (memq number gnus-newsgroup-expirable)
8465 (mail-header-subject header) nil
8466 (cdr (assq number gnus-newsgroup-scored))
8467 (memq number gnus-newsgroup-processable))))))
8469 (defun gnus-select-newsgroup (group &optional read-all)
8470 "Select newsgroup GROUP.
8471 If READ-ALL is non-nil, all articles in the group are selected."
8472 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8473 (info (nth 2 entry))
8474 articles fetched-articles cached)
8476 (or (gnus-check-server
8477 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8478 (error "Couldn't open server"))
8480 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8481 (gnus-activate-group group) ; Or we can activate it...
8482 (progn ; Or we bug out.
8483 (when (equal major-mode 'gnus-summary-mode)
8484 (kill-buffer (current-buffer)))
8485 (error "Couldn't request group %s: %s"
8486 group (gnus-status-message group))))
8488 (setq gnus-newsgroup-name group)
8489 (setq gnus-newsgroup-unselected nil)
8490 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8492 (and gnus-asynchronous
8493 (gnus-check-backend-function
8494 'request-asynchronous gnus-newsgroup-name)
8495 (setq gnus-newsgroup-async
8496 (gnus-request-asynchronous gnus-newsgroup-name)))
8498 ;; Adjust and set lists of article marks.
8500 (gnus-adjust-marked-articles info))
8502 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8503 (when (gnus-virtual-group-p group)
8504 (setq cached gnus-newsgroup-cached))
8506 (setq gnus-newsgroup-unreads
8507 (gnus-set-difference
8508 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8509 gnus-newsgroup-dormant))
8511 (setq gnus-newsgroup-processable nil)
8513 (setq articles (gnus-articles-to-read group read-all))
8517 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8519 ((eq articles 0) nil)
8521 ;; Init the dependencies hash table.
8522 (setq gnus-newsgroup-dependencies
8523 (gnus-make-hashtable (length articles)))
8524 ;; Retrieve the headers and read them in.
8525 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8526 (setq gnus-newsgroup-headers
8528 (setq gnus-headers-retrieved-by
8529 (gnus-retrieve-headers
8530 articles gnus-newsgroup-name
8531 ;; We might want to fetch old headers, but
8532 ;; not if there is only 1 article.
8533 (and gnus-fetch-old-headers
8535 (not (eq gnus-fetch-old-headers 'some))
8536 (not (numberp gnus-fetch-old-headers)))
8537 (> (length articles) 1))))))
8538 (gnus-get-newsgroup-headers-xover articles)
8539 (gnus-get-newsgroup-headers)))
8540 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8542 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8544 (setq gnus-newsgroup-cached cached))
8546 ;; Set the initial limit.
8547 (setq gnus-newsgroup-limit (copy-sequence articles))
8548 ;; Remove canceled articles from the list of unread articles.
8549 (setq gnus-newsgroup-unreads
8550 (gnus-set-sorted-intersection
8551 gnus-newsgroup-unreads
8552 (setq fetched-articles
8553 (mapcar (lambda (headers) (mail-header-number headers))
8554 gnus-newsgroup-headers))))
8555 ;; Removed marked articles that do not exist.
8556 (gnus-update-missing-marks
8557 (gnus-sorted-complement fetched-articles articles))
8558 ;; We might want to build some more threads first.
8559 (and gnus-fetch-old-headers
8560 (eq gnus-headers-retrieved-by 'nov)
8561 (gnus-build-old-threads))
8562 ;; Check whether auto-expire is to be done in this group.
8563 (setq gnus-newsgroup-auto-expire
8564 (gnus-group-auto-expirable-p group))
8565 ;; Set up the article buffer now, if necessary.
8566 (unless gnus-single-article-buffer
8567 (gnus-article-setup-buffer))
8568 ;; First and last article in this newsgroup.
8569 (and gnus-newsgroup-headers
8570 (setq gnus-newsgroup-begin
8571 (mail-header-number (car gnus-newsgroup-headers)))
8572 (setq gnus-newsgroup-end
8574 (gnus-last-element gnus-newsgroup-headers))))
8575 (setq gnus-reffed-article-number -1)
8576 ;; GROUP is successfully selected.
8577 (or gnus-newsgroup-headers t)))))
8579 (defun gnus-articles-to-read (group read-all)
8580 ;; Find out what articles the user wants to read.
8582 ;; Select all articles if `read-all' is non-nil, or if there
8583 ;; are no unread articles.
8585 (and (zerop (length gnus-newsgroup-marked))
8586 (zerop (length gnus-newsgroup-unreads))))
8587 (gnus-uncompress-range (gnus-active group))
8588 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8589 (copy-sequence gnus-newsgroup-unreads))
8591 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8592 (scored (length scored-list))
8593 (number (length articles))
8594 (marked (+ (length gnus-newsgroup-marked)
8595 (length gnus-newsgroup-dormant)))
8603 ((and (or (<= scored marked) (= scored number))
8604 (numberp gnus-large-newsgroup)
8605 (> number gnus-large-newsgroup))
8609 "How many articles from %s (default %d): "
8610 gnus-newsgroup-name number))))
8611 (if (string-match "^[ \t]*$" input) number input)))
8612 ((and (> scored marked) (< scored number))
8615 (format "%s %s (%d scored, %d total): "
8616 "How many articles from"
8617 group scored number))))
8618 (if (string-match "^[ \t]*$" input)
8622 (setq select (if (stringp select) (string-to-number select) select))
8623 (if (or (null select) (zerop select))
8625 (if (and (not (zerop scored)) (<= (abs select) scored))
8627 (setq articles (sort scored-list '<))
8628 (setq number (length articles)))
8629 (setq articles (copy-sequence articles)))
8631 (if (< (abs select) number)
8633 ;; Select the N oldest articles.
8634 (setcdr (nthcdr (1- (abs select)) articles) nil)
8635 ;; Select the N most recent articles.
8636 (setq articles (nthcdr (- number select) articles))))
8637 (setq gnus-newsgroup-unselected
8638 (gnus-sorted-intersection
8639 gnus-newsgroup-unreads
8640 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8643 (defun gnus-killed-articles (killed articles)
8646 (if (inline (gnus-member-of-range (car articles) killed))
8647 (setq out (cons (car articles) out)))
8648 (setq articles (cdr articles)))
8651 (defun gnus-uncompress-marks (marks)
8652 "Uncompress the mark ranges in MARKS."
8653 (let ((uncompressed '(score bookmark))
8656 (if (memq (caar marks) uncompressed)
8657 (push (car marks) out)
8658 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8659 (setq marks (cdr marks)))
8662 (defun gnus-adjust-marked-articles (info)
8663 "Set all article lists and remove all marks that are no longer legal."
8664 (let* ((marked-lists (gnus-info-marks info))
8665 (active (gnus-active (gnus-info-group info)))
8668 (types gnus-article-mark-lists)
8669 (uncompressed '(score bookmark))
8670 marks var articles article mark)
8673 (setq marks (pop marked-lists))
8674 (set (setq var (intern (format "gnus-newsgroup-%s"
8675 (car (rassq (setq mark (car marks))
8677 (if (memq (car marks) uncompressed) (cdr marks)
8678 (gnus-uncompress-range (cdr marks))))
8680 (setq articles (symbol-value var))
8682 ;; All articles have to be subsets of the active articles.
8684 ;; Adjust "simple" lists.
8685 ((memq mark '(tick dormant expirable reply killed save))
8687 (when (or (< (setq article (pop articles)) min) (> article max))
8688 (set var (delq article (symbol-value var))))))
8690 ((memq mark '(score bookmark))
8692 (when (or (< (car (setq article (pop articles))) min)
8693 (> (car article) max))
8694 (set var (delq article (symbol-value var))))))))))
8696 (defun gnus-update-missing-marks (missing)
8697 "Go through the list of MISSING articles and remove them mark lists."
8699 (let ((types gnus-article-mark-lists)
8701 ;; Go through all types.
8703 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8704 (when (symbol-value var)
8705 ;; This list has articles. So we delete all missing articles
8709 (set var (delq (pop m) (symbol-value var)))))))))
8711 (defun gnus-update-marks ()
8712 "Enter the various lists of marked articles into the newsgroup info list."
8713 (let ((types gnus-article-mark-lists)
8714 (info (gnus-get-info gnus-newsgroup-name))
8715 (uncompressed '(score bookmark killed))
8716 type list newmarked symbol)
8718 ;; Add all marks lists that are non-nil to the list of marks lists.
8720 (setq type (pop types))
8721 (when (setq list (symbol-value
8723 (intern (format "gnus-newsgroup-%s"
8725 (push (cons (cdr type)
8726 (if (memq (cdr type) uncompressed) list
8727 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8730 ;; Enter these new marks into the info of the group.
8732 (setcar (nthcdr 3 info) newmarked)
8733 ;; Add the marks lists to the end of the info.
8735 (setcdr (nthcdr 2 info) (list newmarked))))
8737 ;; Cut off the end of the info if there's nothing else there.
8741 (when (nthcdr (decf i) info)
8742 (setcdr (nthcdr i info) nil)))))))
8744 (defun gnus-add-marked-articles (group type articles &optional info force)
8745 ;; Add ARTICLES of TYPE to the info of GROUP.
8746 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8747 ;; add, but replace marked articles of TYPE with ARTICLES.
8748 (let ((info (or info (gnus-get-info group)))
8749 (uncompressed '(score bookmark killed))
8752 (and (not (setq marked (nthcdr 3 info)))
8754 (setcdr (nthcdr 2 info)
8755 (list (list (cons type (gnus-compress-sequence
8757 (and (not (setq m (assq type (car marked))))
8760 (cons (cons type (gnus-compress-sequence articles t) )
8764 (setcar (nthcdr 3 info)
8765 (delq (assq type (car marked)) (car marked)))
8766 (setcdr m (gnus-compress-sequence articles t)))
8767 (setcdr m (gnus-compress-sequence
8768 (sort (nconc (gnus-uncompress-range (cdr m))
8769 (copy-sequence articles)) '<) t))))))
8771 (defun gnus-set-mode-line (where)
8772 "This function sets the mode line of the article or summary buffers.
8773 If WHERE is `summary', the summary mode line format will be used."
8774 ;; Is this mode line one we keep updated?
8775 (when (memq where gnus-updated-mode-lines)
8778 ;; We evaluate this in the summary buffer since these
8779 ;; variables are buffer-local to that buffer.
8780 (set-buffer gnus-summary-buffer)
8781 ;; We bind all these variables that are used in the `eval' form
8783 (let* ((mformat (symbol-value
8785 (format "gnus-%s-mode-line-format-spec" where))))
8786 (gnus-tmp-group-name gnus-newsgroup-name)
8787 (gnus-tmp-article-number (or gnus-current-article 0))
8788 (gnus-tmp-unread gnus-newsgroup-unreads)
8789 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8790 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8791 (gnus-tmp-unread-and-unselected
8792 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8793 (zerop gnus-tmp-unselected)) "")
8794 ((zerop gnus-tmp-unselected)
8795 (format "{%d more}" gnus-tmp-unread-and-unticked))
8796 (t (format "{%d(+%d) more}"
8797 gnus-tmp-unread-and-unticked
8798 gnus-tmp-unselected))))
8800 (if (and gnus-current-headers
8801 (vectorp gnus-current-headers))
8802 (mail-header-subject gnus-current-headers) ""))
8804 gnus-tmp-header);; passed as argument to any user-format-funcs
8805 (setq mode-string (eval mformat))
8806 (setq max-len (max 4 (if gnus-mode-non-string-length
8808 gnus-mode-non-string-length)
8809 (length mode-string))))
8810 ;; We might have to chop a bit of the string off...
8811 (when (> (length mode-string) max-len)
8813 (concat (gnus-truncate-string mode-string (- max-len 3))
8815 ;; Pad the mode string a bit.
8816 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8817 ;; Update the mode line.
8818 (setq mode-line-buffer-identification (list mode-string))
8819 (set-buffer-modified-p t))))
8821 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8822 "Go through the HEADERS list and add all Xrefs to a hash table.
8823 The resulting hash table is returned, or nil if no Xrefs were found."
8824 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8825 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8826 (xref-hashtb (make-vector 63 0))
8827 start group entry number xrefs header)
8829 (setq header (pop headers))
8830 (when (and (setq xrefs (mail-header-xref header))
8831 (not (memq (setq number (mail-header-number header))
8834 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8835 (setq start (match-end 0))
8836 (setq group (if prefix
8837 (concat prefix (substring xrefs (match-beginning 1)
8839 (substring xrefs (match-beginning 1) (match-end 1))))
8841 (string-to-int (substring xrefs (match-beginning 2)
8843 (if (setq entry (gnus-gethash group xref-hashtb))
8844 (setcdr entry (cons number (cdr entry)))
8845 (gnus-sethash group (cons number nil) xref-hashtb)))))
8846 (and start xref-hashtb)))
8848 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8849 "Look through all the headers and mark the Xrefs as read."
8850 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8851 name entry info xref-hashtb idlist method nth4)
8853 (set-buffer gnus-group-buffer)
8854 (when (setq xref-hashtb
8855 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8858 (unless (string= from-newsgroup (setq name (symbol-name group)))
8859 (setq idlist (symbol-value group))
8860 ;; Dead groups are not updated.
8862 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8864 (if (stringp (setq nth4 (gnus-info-method info)))
8865 (setq nth4 (gnus-server-to-method nth4))))
8866 ;; Only do the xrefs if the group has the same
8867 ;; select method as the group we have just read.
8868 (or (gnus-methods-equal-p
8869 nth4 (gnus-find-method-for-group from-newsgroup))
8871 (equal nth4 (setq method (gnus-find-method-for-group
8873 (and (equal (car nth4) (car method))
8874 (equal (nth 1 nth4) (nth 1 method))))
8875 gnus-use-cross-reference
8876 (or (not (eq gnus-use-cross-reference t))
8878 ;; Only do cross-references on subscribed
8879 ;; groups, if that is what is wanted.
8880 (<= (gnus-info-level info) gnus-level-subscribed))
8881 (gnus-group-make-articles-read name idlist))))
8884 (defun gnus-group-make-articles-read (group articles)
8886 (entry (gnus-gethash group gnus-newsrc-hashtb))
8887 (info (nth 2 entry))
8888 (active (gnus-active group))
8890 ;; First peel off all illegal article numbers.
8892 (let ((ids articles)
8896 (if (and first (> id (cdr active)))
8898 ;; We'll end up in this situation in one particular
8899 ;; obscure situation. If you re-scan a group and get
8900 ;; a new article that is cross-posted to a different
8901 ;; group that has not been re-scanned, you might get
8902 ;; crossposted article that has a higher number than
8903 ;; Gnus believes possible. So we re-activate this
8904 ;; group as well. This might mean doing the
8905 ;; crossposting thingy will *increase* the number
8906 ;; of articles in some groups. Tsk, tsk.
8907 (setq active (or (gnus-activate-group group) active))))
8908 (if (or (> id (cdr active))
8909 (< id (car active)))
8910 (setq articles (delq id articles)))
8911 (setq ids (cdr ids)))))
8912 ;; If the read list is nil, we init it.
8914 (null (gnus-info-read info))
8916 (gnus-info-set-read info (cons 1 (1- (car active)))))
8917 ;; Then we add the read articles to the range.
8922 (gnus-info-read info) (setq articles (sort articles '<)))))
8923 ;; Then we have to re-compute how many unread
8924 ;; articles there are in this group.
8929 (setq num (- (1+ (cdr active)) (car active))))
8930 ((not (listp (cdr range)))
8931 (setq num (- (cdr active) (- (1+ (cdr range))
8935 (if (numberp (car range))
8937 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8938 (setq range (cdr range)))
8939 (setq num (- (cdr active) num))))
8940 ;; Update the number of unread articles.
8942 ;; Update the group buffer.
8943 (gnus-group-update-group group t)))))
8945 (defun gnus-methods-equal-p (m1 m2)
8946 (let ((m1 (or m1 gnus-select-method))
8947 (m2 (or m2 gnus-select-method)))
8949 (and (eq (car m1) (car m2))
8950 (or (not (memq 'address (assoc (symbol-name (car m1))
8951 gnus-valid-select-methods)))
8952 (equal (nth 1 m1) (nth 1 m2)))))))
8954 (defsubst gnus-header-value ()
8955 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8957 (defvar gnus-newsgroup-none-id 0)
8959 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8960 (let ((cur nntp-server-buffer)
8963 (save-excursion (set-buffer gnus-summary-buffer)
8964 gnus-newsgroup-dependencies)))
8965 headers id id-dep ref-dep end ref)
8967 (set-buffer nntp-server-buffer)
8968 (let ((case-fold-search t)
8969 in-reply-to header p lines)
8970 (goto-char (point-min))
8971 ;; Search to the beginning of the next header. Error messages
8972 ;; do not begin with 2 or 3.
8973 (while (re-search-forward "^[23][0-9]+ " nil t)
8976 ;; This implementation of this function, with nine
8977 ;; search-forwards instead of the one re-search-forward and
8978 ;; a case (which basically was the old function) is actually
8979 ;; about twice as fast, even though it looks messier. You
8980 ;; can't have everything, I guess. Speed and elegance
8981 ;; doesn't always go hand in hand.
8990 (narrow-to-region (point)
8991 (or (and (search-forward "\n.\n" nil t)
8997 (if (search-forward "\nsubject: " nil t)
8998 (gnus-header-value) "(none)"))
9002 (if (search-forward "\nfrom: " nil t)
9003 (gnus-header-value) "(nobody)"))
9007 (if (search-forward "\ndate: " nil t)
9008 (gnus-header-value) ""))
9012 (if (search-forward "\nmessage-id: " nil t)
9013 (setq id (gnus-header-value))
9014 ;; If there was no message-id, we just fake one to make
9015 ;; subsequent routines simpler.
9016 (setq id (concat "none+"
9018 (setq gnus-newsgroup-none-id
9019 (1+ gnus-newsgroup-none-id)))))))
9023 (if (search-forward "\nreferences: " nil t)
9026 (setq end (match-end 0))
9032 (search-backward ">" end t)
9035 (search-backward "<" end t)
9037 ;; Get the references from the in-reply-to header if there
9038 ;; were no references and the in-reply-to header looks
9040 (if (and (search-forward "\nin-reply-to: " nil t)
9041 (setq in-reply-to (gnus-header-value))
9042 (string-match "<[^>]+>" in-reply-to))
9043 (setq ref (substring in-reply-to (match-beginning 0)
9051 (if (search-forward "\nlines: " nil t)
9052 (if (numberp (setq lines (read cur)))
9058 (and (search-forward "\nxref: " nil t)
9059 (gnus-header-value)))))
9060 ;; We do the threading while we read the headers. The
9061 ;; message-id and the last reference are both entered into
9062 ;; the same hash table. Some tippy-toeing around has to be
9063 ;; done in case an article has arrived before the article
9064 ;; which it refers to.
9065 (if (boundp (setq id-dep (intern id dependencies)))
9066 (if (and (car (symbol-value id-dep))
9068 ;; An article with this Message-ID has already
9069 ;; been seen, so we ignore this one, except we add
9070 ;; any additional Xrefs (in case the two articles
9071 ;; came from different servers).
9073 (mail-header-set-xref
9074 (car (symbol-value id-dep))
9075 (concat (or (mail-header-xref
9076 (car (symbol-value id-dep))) "")
9077 (or (mail-header-xref header) "")))
9079 (setcar (symbol-value id-dep) header))
9080 (set id-dep (list header)))
9082 (if (boundp (setq ref-dep (intern ref dependencies)))
9083 (setcdr (symbol-value ref-dep)
9084 (nconc (cdr (symbol-value ref-dep))
9085 (list (symbol-value id-dep))))
9086 (set ref-dep (list nil (symbol-value id-dep))))
9087 (setq headers (cons header headers)))
9088 (goto-char (point-max))
9090 (nreverse headers)))))
9092 ;; The following macros and functions were written by Felix Lee
9093 ;; <flee@cse.psu.edu>.
9095 (defmacro gnus-nov-read-integer ()
9097 (if (= (following-char) ?\t)
9099 (let ((num (condition-case nil (read buffer) (error nil))))
9100 (if (numberp num) num 0)))
9101 (or (eobp) (forward-char 1))))
9103 (defmacro gnus-nov-skip-field ()
9104 '(search-forward "\t" eol 'move))
9106 (defmacro gnus-nov-field ()
9107 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9109 ;; Goes through the xover lines and returns a list of vectors
9110 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9111 "Parse the news overview data in the server buffer, and return a
9112 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9113 ;; Get the Xref when the users reads the articles since most/some
9114 ;; NNTP servers do not include Xrefs when using XOVER.
9115 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9116 (let ((cur nntp-server-buffer)
9117 (dependencies gnus-newsgroup-dependencies)
9118 number headers header)
9120 (set-buffer nntp-server-buffer)
9121 ;; Allow the user to mangle the headers before parsing them.
9122 (run-hooks 'gnus-parse-headers-hook)
9123 ;; Allow the user to mangle the headers before parsing them.
9124 (run-hooks 'gnus-parse-headers-hook)
9125 (goto-char (point-min))
9126 (while (and sequence (not (eobp)))
9127 (setq number (read cur))
9128 (while (and sequence (< (car sequence) number))
9129 (setq sequence (cdr sequence)))
9131 (eq number (car sequence))
9133 (setq sequence (cdr sequence))
9135 (inline (gnus-nov-parse-line
9136 number dependencies force-new)))
9137 (setq headers (cons header headers)))))
9139 (setq headers (nreverse headers)))
9142 ;; This function has to be called with point after the article number
9143 ;; on the beginning of the line.
9144 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9146 (eol (gnus-point-at-eol))
9147 (buffer (current-buffer))
9148 header ref id id-dep ref-dep)
9150 ;; overview: [num subject from date id refs chars lines misc]
9151 (narrow-to-region (point) eol)
9152 (or (eobp) (forward-char))
9158 (gnus-nov-field) ; subject
9159 (gnus-nov-field) ; from
9160 (gnus-nov-field) ; date
9161 (setq id (or (gnus-nov-field)
9164 (setq none (1+ none)))))) ; id
9167 (let ((beg (point)))
9168 (search-forward "\t" eol)
9169 (if (search-backward ">" beg t)
9173 (search-backward "<" beg t)))
9175 (gnus-nov-field)) ; refs
9176 (gnus-nov-read-integer) ; chars
9177 (gnus-nov-read-integer) ; lines
9178 (if (= (following-char) ?\n)
9180 (gnus-nov-field)) ; misc
9184 (gnus-message 4 "Strange nov line")
9190 ;; We build the thread tree.
9192 (if (boundp (setq id-dep (intern id dependencies)))
9193 (if (and (car (symbol-value id-dep))
9195 ;; An article with this Message-ID has already been seen,
9196 ;; so we ignore this one, except we add any additional
9197 ;; Xrefs (in case the two articles came from different
9200 (mail-header-set-xref
9201 (car (symbol-value id-dep))
9202 (concat (or (mail-header-xref
9203 (car (symbol-value id-dep))) "")
9204 (or (mail-header-xref header) "")))
9206 (setcar (symbol-value id-dep) header))
9207 (set id-dep (list header))))
9210 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9211 (setcdr (symbol-value ref-dep)
9212 (nconc (cdr (symbol-value ref-dep))
9213 (list (symbol-value id-dep))))
9214 (set ref-dep (list nil (symbol-value id-dep))))))
9217 (defun gnus-article-get-xrefs ()
9218 "Fill in the Xref value in `gnus-current-headers', if necessary.
9219 This is meant to be called in `gnus-article-internal-prepare-hook'."
9220 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9221 gnus-current-headers)))
9222 (or (not gnus-use-cross-reference)
9224 (and (mail-header-xref headers)
9225 (not (string= (mail-header-xref headers) "")))
9226 (let ((case-fold-search t)
9229 (nnheader-narrow-to-headers)
9230 (goto-char (point-min))
9231 (if (or (and (eq (downcase (following-char)) ?x)
9232 (looking-at "Xref:"))
9233 (search-forward "\nXref:" nil t))
9235 (goto-char (1+ (match-end 0)))
9236 (setq xref (buffer-substring (point)
9237 (progn (end-of-line) (point))))
9238 (mail-header-set-xref headers xref))))))))
9240 (defun gnus-summary-insert-subject (id &optional old-header)
9241 "Find article ID and insert the summary line for that article."
9242 (let ((header (gnus-read-header id))
9243 (number (and (numberp id) id))
9246 ;; Rebuild the thread that this article is part of and go to the
9247 ;; article we have fetched.
9249 (when (setq pos (text-property-any
9250 (point-min) (point-max) 'gnus-number
9251 (mail-header-number old-header)))
9254 (gnus-data-remove (mail-header-number old-header))))
9255 (gnus-rebuild-thread (mail-header-id header))
9256 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9257 (when (and (numberp number)
9259 ;; We have to update the boundaries even if we can't fetch the
9260 ;; article if ID is a number -- so that the next `P' or `N'
9261 ;; command will fetch the previous (or next) article even
9262 ;; if the one we tried to fetch this time has been canceled.
9263 (and (> number gnus-newsgroup-end)
9264 (setq gnus-newsgroup-end number))
9265 (and (< number gnus-newsgroup-begin)
9266 (setq gnus-newsgroup-begin number))
9267 (setq gnus-newsgroup-unselected
9268 (delq number gnus-newsgroup-unselected)))
9269 ;; Report back a success?
9270 (and header (mail-header-number header))))
9272 (defun gnus-summary-work-articles (n)
9273 "Return a list of articles to be worked upon. The prefix argument,
9274 the list of process marked articles, and the current article will be
9275 taken into consideration."
9277 ((and n (numberp n))
9278 ;; A numerical prefix has been given.
9279 (let ((backward (< n 0))
9285 (push (setq article (gnus-summary-article-number))
9288 (gnus-summary-find-prev nil article)
9289 (gnus-summary-find-next nil article)))
9291 (nreverse articles)))
9292 ((and (boundp 'transient-mark-mode)
9295 ;; Work on the region between point and mark.
9296 (let ((max (max (point) (mark)))
9299 (goto-char (min (point) (mark)))
9302 (push (setq article (gnus-summary-article-number)) articles)
9303 (gnus-summary-find-next nil article)
9305 (nreverse articles))))
9306 (gnus-newsgroup-processable
9307 ;; There are process-marked articles present.
9308 (reverse gnus-newsgroup-processable))
9310 ;; Just return the current article.
9311 (list (gnus-summary-article-number)))))
9313 (defun gnus-summary-search-group (&optional backward use-level)
9314 "Search for next unread newsgroup.
9315 If optional argument BACKWARD is non-nil, search backward instead."
9317 (set-buffer gnus-group-buffer)
9318 (if (gnus-group-search-forward
9319 backward nil (if use-level (gnus-group-group-level) nil))
9320 (gnus-group-group-name))))
9322 (defun gnus-summary-best-group (&optional exclude-group)
9323 "Find the name of the best unread group.
9324 If EXCLUDE-GROUP, do not go to this group."
9326 (set-buffer gnus-group-buffer)
9328 (gnus-group-best-unread-group exclude-group))))
9330 (defun gnus-summary-find-next (&optional unread article backward)
9331 (if backward (gnus-summary-find-prev)
9332 (let* ((article (or article (gnus-summary-article-number)))
9333 (arts (gnus-data-find-list article))
9335 (when (or (not gnus-summary-check-current)
9337 (not (gnus-data-unread-p (car arts))))
9338 (setq arts (cdr arts)))
9343 (when (gnus-data-unread-p (car arts))
9344 (setq result (car arts)
9346 (setq arts (cdr arts)))
9349 (goto-char (gnus-data-pos result))
9350 (gnus-data-number result)))))
9352 (defun gnus-summary-find-prev (&optional unread article)
9353 (let* ((article (or article (gnus-summary-article-number)))
9354 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9356 (when (or (not gnus-summary-check-current)
9358 (not (gnus-data-unread-p (car arts))))
9359 (setq arts (cdr arts)))
9364 (and (gnus-data-unread-p (car arts))
9365 (setq result (car arts)
9367 (setq arts (cdr arts)))
9371 (goto-char (gnus-data-pos result))
9372 (gnus-data-number result)))))
9374 (defun gnus-summary-find-subject (subject &optional unread backward article)
9375 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9376 (article (or article (gnus-summary-article-number)))
9377 (articles (gnus-data-list backward))
9378 (arts (gnus-data-find-list article articles))
9380 (when (or (not gnus-summary-check-current)
9382 (not (gnus-data-unread-p (car arts))))
9383 (setq arts (cdr arts)))
9385 (and (or (not unread)
9386 (gnus-data-unread-p (car arts)))
9387 (vectorp (gnus-data-header (car arts)))
9389 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9390 (setq result (car arts)
9392 (setq arts (cdr arts)))
9394 (goto-char (gnus-data-pos result))
9395 (gnus-data-number result))))
9397 (defun gnus-summary-search-forward (&optional unread subject backward)
9398 "Search forward for an article.
9399 If UNREAD, look for unread articles. If SUBJECT, look for
9400 articles with that subject. If BACKWARD, search backward instead."
9401 (cond (subject (gnus-summary-find-subject subject unread backward))
9402 (backward (gnus-summary-find-prev unread))
9403 (t (gnus-summary-find-next unread))))
9405 (defun gnus-recenter (&optional n)
9406 "Center point in window and redisplay frame.
9407 Also do horizontal recentering."
9409 (when (and gnus-auto-center-summary
9410 (not (eq gnus-auto-center-summary 'vertical)))
9411 (gnus-horizontal-recenter))
9414 (defun gnus-summary-recenter ()
9415 "Center point in the summary window.
9416 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9417 displayed, no centering will be performed."
9418 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9419 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9420 (let* ((top (cond ((< (window-height) 4) 0)
9421 ((< (window-height) 7) 1)
9423 (height (1- (window-height)))
9424 (bottom (save-excursion (goto-char (point-max))
9425 (forward-line (- height))
9427 (window (get-buffer-window (current-buffer))))
9428 ;; The user has to want it.
9429 (when gnus-auto-center-summary
9430 (when (get-buffer-window gnus-article-buffer)
9431 ;; Only do recentering when the article buffer is displayed,
9432 ;; Set the window start to either `bottom', which is the biggest
9433 ;; possible valid number, or the second line from the top,
9434 ;; whichever is the least.
9436 window (min bottom (save-excursion
9437 (forward-line (- top)) (point)))))
9438 ;; Do horizontal recentering while we're at it.
9439 (when (and (get-buffer-window (current-buffer) t)
9440 (not (eq gnus-auto-center-summary 'vertical)))
9441 (let ((selected (selected-window)))
9442 (select-window (get-buffer-window (current-buffer) t))
9443 (gnus-summary-position-point)
9444 (gnus-horizontal-recenter)
9445 (select-window selected))))))
9447 (defun gnus-horizontal-recenter ()
9448 "Recenter the current buffer horizontally."
9449 (if (< (current-column) (/ (window-width) 2))
9450 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9451 (let* ((orig (point))
9452 (end (window-end (get-buffer-window (current-buffer) t)))
9454 ;; Find the longest line currently displayed in the window.
9455 (goto-char (window-start))
9456 (while (and (not (eobp))
9459 (setq max (max max (current-column)))
9462 ;; Scroll horizontally to center (sort of) the point.
9463 (if (> max (window-width))
9465 (get-buffer-window (current-buffer) t)
9466 (min (- (current-column) (/ (window-width) 3))
9467 (+ 2 (- max (window-width)))))
9468 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9471 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9472 (defun gnus-short-group-name (group &optional levels)
9473 "Collapse GROUP name LEVELS."
9480 (while (string-match "\\." group skip)
9481 (setq skip (match-end 0)
9484 (if (string-match ":" group)
9485 (setq foreign (substring group 0 (match-end 0))
9486 group (substring group (match-end 0))))
9488 (if (and (string-match "\\." group)
9489 (> levels (- gnus-group-uncollapsed-levels 1)))
9490 (setq name (concat name (substring group 0 1))
9491 group (substring group (match-end 0))
9493 name (concat name "."))
9494 (setq name (concat foreign name group)
9498 (defun gnus-summary-jump-to-group (newsgroup)
9499 "Move point to NEWSGROUP in group mode buffer."
9500 ;; Keep update point of group mode buffer if visible.
9501 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9502 (save-window-excursion
9503 ;; Take care of tree window mode.
9504 (if (get-buffer-window gnus-group-buffer)
9505 (pop-to-buffer gnus-group-buffer))
9506 (gnus-group-jump-to-group newsgroup))
9508 ;; Take care of tree window mode.
9509 (if (get-buffer-window gnus-group-buffer)
9510 (pop-to-buffer gnus-group-buffer)
9511 (set-buffer gnus-group-buffer))
9512 (gnus-group-jump-to-group newsgroup))))
9514 ;; This function returns a list of article numbers based on the
9515 ;; difference between the ranges of read articles in this group and
9516 ;; the range of active articles.
9517 (defun gnus-list-of-unread-articles (group)
9518 (let* ((read (gnus-info-read (gnus-get-info group)))
9519 (active (gnus-active group))
9522 ;; If none are read, then all are unread.
9524 (setq first (car active))
9525 ;; If the range of read articles is a single range, then the
9526 ;; first unread article is the article after the last read
9527 ;; article. Sounds logical, doesn't it?
9528 (if (not (listp (cdr read)))
9529 (setq first (1+ (cdr read)))
9530 ;; `read' is a list of ranges.
9531 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9536 (while (< first nlast)
9537 (setq unread (cons first unread))
9538 (setq first (1+ first))))
9539 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9540 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9541 (setq read (cdr read)))))
9542 ;; And add the last unread articles.
9543 (while (<= first last)
9544 (setq unread (cons first unread))
9545 (setq first (1+ first)))
9546 ;; Return the list of unread articles.
9549 (defun gnus-list-of-read-articles (group)
9550 "Return a list of unread, unticked and non-dormant articles."
9551 (let* ((info (gnus-get-info group))
9552 (marked (gnus-info-marks info))
9553 (active (gnus-active group)))
9555 (gnus-set-difference
9556 (gnus-sorted-complement
9557 (gnus-uncompress-range active)
9558 (gnus-list-of-unread-articles group))
9560 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9561 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9563 ;; Various summary commands
9565 (defun gnus-summary-universal-argument (arg)
9566 "Perform any operation on all articles that are process/prefixed."
9568 (gnus-set-global-variables)
9569 (let ((articles (gnus-summary-work-articles arg))
9576 (substitute-command-keys
9577 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9581 (message "Undefined key")
9585 (gnus-summary-goto-subject (setq article (pop articles)))
9586 (command-execute func)
9587 (gnus-summary-remove-process-mark article)))))
9588 (gnus-summary-position-point))
9590 (defun gnus-summary-toggle-truncation (&optional arg)
9591 "Toggle truncation of summary lines.
9592 With arg, turn line truncation on iff arg is positive."
9594 (setq truncate-lines
9595 (if (null arg) (not truncate-lines)
9596 (> (prefix-numeric-value arg) 0)))
9599 (defun gnus-summary-reselect-current-group (&optional all rescan)
9600 "Exit and then reselect the current newsgroup.
9601 The prefix argument ALL means to select all articles."
9603 (gnus-set-global-variables)
9604 (let ((current-subject (gnus-summary-article-number))
9605 (group gnus-newsgroup-name))
9606 (setq gnus-newsgroup-begin nil)
9608 ;; We have to adjust the point of group mode buffer because the
9609 ;; current point was moved to the next unread newsgroup by
9611 (gnus-summary-jump-to-group group)
9614 (gnus-group-get-new-news-this-group 1)))
9615 (gnus-group-read-group all t)
9616 (gnus-summary-goto-subject current-subject)))
9618 (defun gnus-summary-rescan-group (&optional all)
9619 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9621 (gnus-summary-reselect-current-group all t))
9623 (defun gnus-summary-update-info ()
9624 (let* ((group gnus-newsgroup-name))
9625 (when gnus-newsgroup-kill-headers
9626 (setq gnus-newsgroup-killed
9627 (gnus-compress-sequence
9629 (gnus-set-sorted-intersection
9630 (gnus-uncompress-range gnus-newsgroup-killed)
9631 (setq gnus-newsgroup-unselected
9632 (sort gnus-newsgroup-unselected '<)))
9633 (setq gnus-newsgroup-unreads
9634 (sort gnus-newsgroup-unreads '<))) t)))
9635 (unless (listp (cdr gnus-newsgroup-killed))
9636 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9637 (let ((headers gnus-newsgroup-headers))
9638 (run-hooks 'gnus-exit-group-hook)
9639 (unless gnus-save-score
9640 (setq gnus-newsgroup-scored nil))
9641 ;; Set the new ranges of read articles.
9642 (gnus-update-read-articles
9643 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9644 ;; Set the current article marks.
9646 ;; Do the cross-ref thing.
9647 (when gnus-use-cross-reference
9648 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9649 ;; Do adaptive scoring, and possibly save score files.
9650 (when gnus-newsgroup-adaptive
9651 (gnus-score-adaptive))
9652 (when gnus-use-scoring
9654 ;; Do not switch windows but change the buffer to work.
9655 (set-buffer gnus-group-buffer)
9656 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9657 (gnus-group-update-group group)))))
9659 (defun gnus-summary-exit (&optional temporary)
9660 "Exit reading current newsgroup, and then return to group selection mode.
9661 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9663 (gnus-set-global-variables)
9664 (gnus-kill-save-kill-buffer)
9665 (let* ((group gnus-newsgroup-name)
9666 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9668 (buf (current-buffer)))
9670 (run-hooks 'gnus-summary-prepare-exit-hook))
9671 ;; If we have several article buffers, we kill them at exit.
9672 (unless gnus-single-article-buffer
9673 (gnus-kill-buffer gnus-article-buffer)
9674 (gnus-kill-buffer gnus-original-article-buffer)
9675 (setq gnus-article-current nil))
9676 (when gnus-use-cache
9677 (gnus-cache-possibly-remove-articles)
9678 (gnus-cache-save-buffers))
9679 (when gnus-use-trees
9680 (gnus-tree-close group))
9681 ;; Make all changes in this group permanent.
9683 (gnus-summary-update-info))
9684 (gnus-close-group group)
9685 ;; Make sure where I was, and go to next newsgroup.
9686 (set-buffer gnus-group-buffer)
9688 (gnus-group-jump-to-group group)
9689 (gnus-group-next-unread-group 1))
9690 (run-hooks 'gnus-summary-exit-hook)
9691 (unless gnus-single-article-buffer
9692 (setq gnus-article-current nil))
9695 ;; If we have several article buffers, we kill them at exit.
9696 (unless gnus-single-article-buffer
9697 (gnus-kill-buffer gnus-article-buffer)
9698 (gnus-kill-buffer gnus-original-article-buffer)
9699 (setq gnus-article-current nil))
9701 (if (not gnus-kill-summary-on-exit)
9702 (gnus-deaden-summary)
9703 ;; We set all buffer-local variables to nil. It is unclear why
9704 ;; this is needed, but if we don't, buffer-local variables are
9705 ;; not garbage-collected, it seems. This would the lead to en
9706 ;; ever-growing Emacs.
9707 (gnus-summary-clear-local-variables)
9708 (when (get-buffer gnus-article-buffer)
9709 (bury-buffer gnus-article-buffer))
9710 ;; We clear the global counterparts of the buffer-local
9711 ;; variables as well, just to be on the safe side.
9712 (gnus-configure-windows 'group 'force)
9713 (gnus-summary-clear-local-variables)
9714 ;; Return to group mode buffer.
9715 (if (eq mode 'gnus-summary-mode)
9716 (gnus-kill-buffer buf)))
9717 (setq gnus-current-select-method gnus-select-method)
9718 (pop-to-buffer gnus-group-buffer)
9719 ;; Clear the current group name.
9720 (if (not quit-config)
9722 (gnus-group-jump-to-group group)
9723 (gnus-group-next-unread-group 1)
9724 (gnus-configure-windows 'group 'force))
9725 (if (not (buffer-name (car quit-config)))
9726 (gnus-configure-windows 'group 'force)
9727 (set-buffer (car quit-config))
9728 (and (eq major-mode 'gnus-summary-mode)
9729 (gnus-set-global-variables))
9730 (gnus-configure-windows (cdr quit-config))))
9732 (setq gnus-newsgroup-name nil)))))
9734 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9735 (defun gnus-summary-exit-no-update (&optional no-questions)
9736 "Quit reading current newsgroup without updating read article info."
9738 (gnus-set-global-variables)
9739 (let* ((group gnus-newsgroup-name)
9740 (quit-config (gnus-group-quit-config group)))
9741 (when (or no-questions
9743 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9744 ;; If we have several article buffers, we kill them at exit.
9745 (unless gnus-single-article-buffer
9746 (gnus-kill-buffer gnus-article-buffer)
9747 (gnus-kill-buffer gnus-original-article-buffer)
9748 (setq gnus-article-current nil))
9749 (if (not gnus-kill-summary-on-exit)
9750 (gnus-deaden-summary)
9751 (gnus-close-group group)
9752 (gnus-summary-clear-local-variables)
9753 (set-buffer gnus-group-buffer)
9754 (gnus-summary-clear-local-variables)
9755 (when (get-buffer gnus-summary-buffer)
9756 (kill-buffer gnus-summary-buffer)))
9757 (unless gnus-single-article-buffer
9758 (setq gnus-article-current nil))
9759 (when gnus-use-trees
9760 (gnus-tree-close group))
9761 (when (get-buffer gnus-article-buffer)
9762 (bury-buffer gnus-article-buffer))
9763 ;; Return to the group buffer.
9764 (gnus-configure-windows 'group 'force)
9765 ;; Clear the current group name.
9766 (setq gnus-newsgroup-name nil)
9767 (when (equal (gnus-group-group-name) group)
9768 (gnus-group-next-unread-group 1))
9770 (if (not (buffer-name (car quit-config)))
9771 (gnus-configure-windows 'group 'force)
9772 (set-buffer (car quit-config))
9773 (when (eq major-mode 'gnus-summary-mode)
9774 (gnus-set-global-variables))
9775 (gnus-configure-windows (cdr quit-config)))))))
9779 (defvar gnus-dead-summary-mode-map nil)
9781 (if gnus-dead-summary-mode-map
9783 (setq gnus-dead-summary-mode-map (make-keymap))
9784 (suppress-keymap gnus-dead-summary-mode-map)
9785 (substitute-key-definition
9786 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9787 (let ((keys '("\C-d" "\r" "\177")))
9789 (define-key gnus-dead-summary-mode-map
9790 (pop keys) 'gnus-summary-wake-up-the-dead))))
9792 (defvar gnus-dead-summary-mode nil
9793 "Minor mode for Gnus summary buffers.")
9795 (defun gnus-dead-summary-mode (&optional arg)
9796 "Minor mode for Gnus summary buffers."
9798 (when (eq major-mode 'gnus-summary-mode)
9799 (make-local-variable 'gnus-dead-summary-mode)
9800 (setq gnus-dead-summary-mode
9801 (if (null arg) (not gnus-dead-summary-mode)
9802 (> (prefix-numeric-value arg) 0)))
9803 (when gnus-dead-summary-mode
9804 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9805 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9806 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9807 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9808 minor-mode-map-alist)))))
9810 (defun gnus-deaden-summary ()
9811 "Make the current summary buffer into a dead summary buffer."
9812 ;; Kill any previous dead summary buffer.
9813 (when (and gnus-dead-summary
9814 (buffer-name gnus-dead-summary))
9816 (set-buffer gnus-dead-summary)
9817 (when gnus-dead-summary-mode
9818 (kill-buffer (current-buffer)))))
9819 ;; Make this the current dead summary.
9820 (setq gnus-dead-summary (current-buffer))
9821 (gnus-dead-summary-mode 1)
9822 (let ((name (buffer-name)))
9823 (when (string-match "Summary" name)
9825 (concat (substring name 0 (match-beginning 0)) "Dead "
9826 (substring name (match-beginning 0))) t))))
9828 (defun gnus-kill-or-deaden-summary (buffer)
9829 "Kill or deaden the summary BUFFER."
9830 (cond (gnus-kill-summary-on-exit
9831 (when (and gnus-use-trees
9832 (and (get-buffer buffer)
9833 (buffer-name (get-buffer buffer))))
9835 (set-buffer (get-buffer buffer))
9836 (gnus-tree-close gnus-newsgroup-name)))
9837 (gnus-kill-buffer buffer))
9838 ((and (get-buffer buffer)
9839 (buffer-name (get-buffer buffer)))
9842 (gnus-deaden-summary)))))
9844 (defun gnus-summary-wake-up-the-dead (&rest args)
9845 "Wake up the dead summary buffer."
9847 (gnus-dead-summary-mode -1)
9848 (let ((name (buffer-name)))
9849 (when (string-match "Dead " name)
9851 (concat (substring name 0 (match-beginning 0))
9852 (substring name (match-end 0))) t)))
9853 (gnus-message 3 "This dead summary is now alive again"))
9855 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9856 (defun gnus-summary-fetch-faq (&optional faq-dir)
9857 "Fetch the FAQ for the current group.
9858 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9862 (if current-prefix-arg
9864 "Faq dir: " (and (listp gnus-group-faq-directory)
9865 gnus-group-faq-directory)))))
9866 (let (gnus-faq-buffer)
9867 (and (setq gnus-faq-buffer
9868 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9869 (gnus-configure-windows 'summary-faq))))
9871 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9872 (defun gnus-summary-describe-group (&optional force)
9873 "Describe the current newsgroup."
9875 (gnus-group-describe-group force gnus-newsgroup-name))
9877 (defun gnus-summary-describe-briefly ()
9878 "Describe summary mode commands briefly."
9881 (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")))
9883 ;; Walking around group mode buffer from summary mode.
9885 (defun gnus-summary-next-group (&optional no-article target-group backward)
9886 "Exit current newsgroup and then select next unread newsgroup.
9887 If prefix argument NO-ARTICLE is non-nil, no article is selected
9888 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9889 previous group instead."
9891 (gnus-set-global-variables)
9892 (let ((current-group gnus-newsgroup-name)
9893 (current-buffer (current-buffer))
9895 ;; First we semi-exit this group to update Xrefs and all variables.
9896 ;; We can't do a real exit, because the window conf must remain
9897 ;; the same in case the user is prompted for info, and we don't
9898 ;; want the window conf to change before that...
9899 (gnus-summary-exit t)
9900 (while (not entered)
9901 ;; Then we find what group we are supposed to enter.
9902 (set-buffer gnus-group-buffer)
9903 (gnus-group-jump-to-group current-group)
9906 (if (eq gnus-keep-same-level 'best)
9907 (gnus-summary-best-group gnus-newsgroup-name)
9908 (gnus-summary-search-group backward gnus-keep-same-level))))
9909 (if (not target-group)
9910 ;; There are no further groups, so we return to the group
9913 (gnus-message 5 "Returning to the group buffer")
9915 (set-buffer current-buffer)
9916 (gnus-summary-exit))
9917 ;; We try to enter the target group.
9918 (gnus-group-jump-to-group target-group)
9919 (let ((unreads (gnus-group-group-unread)))
9920 (if (and (or (eq t unreads)
9921 (and unreads (not (zerop unreads))))
9922 (gnus-summary-read-group
9923 target-group nil no-article current-buffer))
9925 (setq current-group target-group
9926 target-group nil)))))))
9928 (defun gnus-summary-prev-group (&optional no-article)
9929 "Exit current newsgroup and then select previous unread newsgroup.
9930 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9932 (gnus-summary-next-group no-article nil t))
9934 ;; Walking around summary lines.
9936 (defun gnus-summary-first-subject (&optional unread)
9937 "Go to the first unread subject.
9938 If UNREAD is non-nil, go to the first unread article.
9939 Returns the article selected or nil if there are no unread articles."
9944 ((null gnus-newsgroup-data)
9945 (gnus-message 3 "No articles in the group")
9947 ;; Pick the first article.
9949 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9950 (gnus-data-number (car gnus-newsgroup-data)))
9951 ;; No unread articles.
9952 ((null gnus-newsgroup-unreads)
9953 (gnus-message 3 "No more unread articles")
9955 ;; Find the first unread article.
9957 (let ((data gnus-newsgroup-data))
9959 (not (gnus-data-unread-p (car data))))
9960 (setq data (cdr data)))
9963 (goto-char (gnus-data-pos (car data)))
9964 (gnus-data-number (car data)))))))
9965 (gnus-summary-position-point)))
9967 (defun gnus-summary-next-subject (n &optional unread dont-display)
9968 "Go to next N'th summary line.
9969 If N is negative, go to the previous N'th subject line.
9970 If UNREAD is non-nil, only unread articles are selected.
9971 The difference between N and the actual number of steps taken is
9974 (let ((backward (< n 0))
9978 (gnus-summary-find-prev unread)
9979 (gnus-summary-find-next unread)))
9981 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9982 (if unread " unread" "")))
9983 (unless dont-display
9984 (gnus-summary-recenter)
9985 (gnus-summary-position-point))
9988 (defun gnus-summary-next-unread-subject (n)
9989 "Go to next N'th unread summary line."
9991 (gnus-summary-next-subject n t))
9993 (defun gnus-summary-prev-subject (n &optional unread)
9994 "Go to previous N'th summary line.
9995 If optional argument UNREAD is non-nil, only unread article is selected."
9997 (gnus-summary-next-subject (- n) unread))
9999 (defun gnus-summary-prev-unread-subject (n)
10000 "Go to previous N'th unread summary line."
10002 (gnus-summary-next-subject (- n) t))
10004 (defun gnus-summary-goto-subject (article &optional force silent)
10005 "Go the subject line of ARTICLE.
10006 If FORCE, also allow jumping to articles not currently shown."
10008 (data (gnus-data-find article)))
10009 ;; We read in the article if we have to.
10012 (gnus-summary-insert-subject article)
10013 (setq data (gnus-data-find article)))
10018 (gnus-message 3 "Can't find article %d" article))
10020 (goto-char (gnus-data-pos data))
10023 ;; Walking around summary lines with displaying articles.
10025 (defun gnus-summary-expand-window (&optional arg)
10026 "Make the summary buffer take up the entire Emacs frame.
10027 Given a prefix, will force an `article' buffer configuration."
10029 (gnus-set-global-variables)
10031 (gnus-configure-windows 'article 'force)
10032 (gnus-configure-windows 'summary 'force)))
10034 (defun gnus-summary-display-article (article &optional all-header)
10035 "Display ARTICLE in article buffer."
10036 (gnus-set-global-variables)
10040 (if gnus-summary-display-article-function
10041 (funcall gnus-summary-display-article-function article all-header)
10042 (gnus-article-prepare article all-header))
10043 (run-hooks 'gnus-select-article-hook)
10044 (gnus-summary-recenter)
10045 (gnus-summary-goto-subject article)
10046 (when gnus-use-trees
10047 (gnus-possibly-generate-tree article)
10048 (gnus-highlight-selected-tree article))
10049 ;; Successfully display article.
10050 (gnus-article-set-window-start
10051 (cdr (assq article gnus-newsgroup-bookmarks)))
10054 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10055 "Select the current article.
10056 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10057 non-nil, the article will be re-fetched even if it already present in
10058 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10060 (let ((article (or article (gnus-summary-article-number)))
10061 (all-headers (not (not all-headers))) ;Must be T or NIL.
10062 gnus-summary-display-article-function
10065 (gnus-summary-article-pseudo-p article)
10066 (error "This is a pseudo-article."))
10069 (set-buffer gnus-summary-buffer)
10070 (if (or (and gnus-single-article-buffer
10071 (or (null gnus-current-article)
10072 (null gnus-article-current)
10073 (null (get-buffer gnus-article-buffer))
10074 (not (eq article (cdr gnus-article-current)))
10075 (not (equal (car gnus-article-current)
10076 gnus-newsgroup-name))))
10077 (and (not gnus-single-article-buffer)
10078 (or (null gnus-current-article)
10079 (not (eq gnus-current-article article))))
10081 ;; The requested article is different from the current article.
10083 (gnus-summary-display-article article all-headers)
10084 (setq did article))
10085 (if (or all-headers gnus-show-all-headers)
10086 (gnus-article-show-all-headers))
10089 (gnus-article-set-window-start
10090 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10092 (defun gnus-summary-set-current-mark (&optional current-mark)
10093 "Obsolete function."
10096 (defun gnus-summary-next-article (&optional unread subject backward push)
10097 "Select the next article.
10098 If UNREAD, only unread articles are selected.
10099 If SUBJECT, only articles with SUBJECT are selected.
10100 If BACKWARD, the previous article is selected instead of the next."
10102 (gnus-set-global-variables)
10104 ;; Is there such an article?
10105 ((and (gnus-summary-search-forward unread subject backward)
10106 (or (gnus-summary-display-article (gnus-summary-article-number))
10107 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10108 (gnus-summary-position-point))
10109 ;; If not, we try the first unread, if that is wanted.
10111 gnus-auto-select-same
10112 (or (gnus-summary-first-unread-article)
10113 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10114 (gnus-summary-position-point)
10115 (gnus-message 6 "Wrapped"))
10116 ;; Try to get next/previous article not displayed in this group.
10117 ((and gnus-auto-extend-newsgroup
10118 (not unread) (not subject))
10119 (gnus-summary-goto-article
10120 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10122 ;; Go to next/previous group.
10124 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10125 (gnus-summary-jump-to-group gnus-newsgroup-name))
10126 (let ((cmd last-command-char)
10128 (if (eq gnus-keep-same-level 'best)
10129 (gnus-summary-best-group gnus-newsgroup-name)
10130 (gnus-summary-search-group backward gnus-keep-same-level))))
10131 ;; For some reason, the group window gets selected. We change
10133 (select-window (get-buffer-window (current-buffer)))
10134 ;; Select next unread newsgroup automagically.
10136 ((not gnus-auto-select-next)
10137 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10138 ((or (eq gnus-auto-select-next 'quietly)
10139 (and (eq gnus-auto-select-next 'slightly-quietly)
10141 (and (eq gnus-auto-select-next 'almost-quietly)
10142 (gnus-summary-last-article-p)))
10144 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10145 (gnus-summary-exit)
10146 (gnus-message 7 "No more%s articles (%s)..."
10147 (if unread " unread" "")
10148 (if group (concat "selecting " group)
10150 (gnus-summary-next-group nil group backward)))
10152 (gnus-summary-walk-group-buffer
10153 gnus-newsgroup-name cmd unread backward)))))))
10155 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10156 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10157 (?\C-p (gnus-group-prev-unread-group 1))))
10158 keve key group ended)
10160 (set-buffer gnus-group-buffer)
10161 (gnus-summary-jump-to-group from-group)
10163 (if (eq gnus-keep-same-level 'best)
10164 (gnus-summary-best-group gnus-newsgroup-name)
10165 (gnus-summary-search-group backward gnus-keep-same-level))))
10168 5 "No more%s articles%s" (if unread " unread" "")
10170 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10171 (format " (Type %s for %s [%s])"
10172 (single-key-description cmd) group
10173 (car (gnus-gethash group gnus-newsrc-hashtb)))
10174 (format " (Type %s to exit %s)"
10175 (single-key-description cmd)
10176 gnus-newsgroup-name)))
10177 ;; Confirm auto selection.
10178 (setq key (car (setq keve (gnus-read-event-char))))
10181 ((assq key keystrokes)
10182 (let ((obuf (current-buffer)))
10183 (switch-to-buffer gnus-group-buffer)
10185 (gnus-group-jump-to-group group))
10186 (eval (cadr (assq key keystrokes)))
10187 (setq group (gnus-group-group-name))
10188 (switch-to-buffer obuf))
10191 (if (or (not group)
10192 (gnus-ephemeral-group-p gnus-newsgroup-name))
10193 (gnus-summary-exit)
10194 (gnus-summary-next-group nil group backward)))
10196 (push (cdr keve) unread-command-events))))))
10198 (defun gnus-read-event-char ()
10199 "Get the next event."
10200 (let ((event (read-event)))
10201 (cons (and (numberp event) event) event)))
10203 (defun gnus-summary-next-unread-article ()
10204 "Select unread article after current one."
10206 (gnus-summary-next-article t (and gnus-auto-select-same
10207 (gnus-summary-article-subject))))
10209 (defun gnus-summary-prev-article (&optional unread subject)
10210 "Select the article after the current one.
10211 If UNREAD is non-nil, only unread articles are selected."
10213 (gnus-summary-next-article unread subject t))
10215 (defun gnus-summary-prev-unread-article ()
10216 "Select unred article before current one."
10218 (gnus-summary-prev-article t (and gnus-auto-select-same
10219 (gnus-summary-article-subject))))
10221 (defun gnus-summary-next-page (&optional lines circular)
10222 "Show next page of the selected article.
10223 If at the end of the current article, select the next article.
10224 LINES says how many lines should be scrolled up.
10226 If CIRCULAR is non-nil, go to the start of the article instead of
10227 selecting the next article when reaching the end of the current
10230 (setq gnus-summary-buffer (current-buffer))
10231 (gnus-set-global-variables)
10232 (let ((article (gnus-summary-article-number))
10234 (gnus-configure-windows 'article)
10235 (if (or (null gnus-current-article)
10236 (null gnus-article-current)
10237 (/= article (cdr gnus-article-current))
10238 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10239 ;; Selected subject is different from current article's.
10240 (gnus-summary-display-article article)
10241 (gnus-eval-in-buffer-window
10242 gnus-article-buffer
10243 (setq endp (gnus-article-next-page lines)))
10246 (gnus-summary-beginning-of-article))
10248 (gnus-message 3 "End of message"))
10250 (if (and (eq gnus-summary-goto-unread 'never)
10251 (not (gnus-summary-last-article-p article)))
10252 (gnus-summary-next-article)
10253 (gnus-summary-next-unread-article))))))
10254 (gnus-summary-recenter)
10255 (gnus-summary-position-point)))
10257 (defun gnus-summary-prev-page (&optional lines)
10258 "Show previous page of selected article.
10259 Argument LINES specifies lines to be scrolled down."
10261 (gnus-set-global-variables)
10262 (let ((article (gnus-summary-article-number)))
10263 (gnus-configure-windows 'article)
10264 (if (or (null gnus-current-article)
10265 (null gnus-article-current)
10266 (/= article (cdr gnus-article-current))
10267 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10268 ;; Selected subject is different from current article's.
10269 (gnus-summary-display-article article)
10270 (gnus-summary-recenter)
10271 (gnus-eval-in-buffer-window gnus-article-buffer
10272 (gnus-article-prev-page lines))))
10273 (gnus-summary-position-point))
10275 (defun gnus-summary-scroll-up (lines)
10276 "Scroll up (or down) one line current article.
10277 Argument LINES specifies lines to be scrolled up (or down if negative)."
10279 (gnus-set-global-variables)
10280 (gnus-configure-windows 'article)
10281 (gnus-summary-show-thread)
10282 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10283 (gnus-eval-in-buffer-window
10284 gnus-article-buffer
10286 (if (gnus-article-next-page lines)
10287 (gnus-message 3 "End of message")))
10289 (gnus-article-prev-page (- lines))))))
10290 (gnus-summary-recenter)
10291 (gnus-summary-position-point))
10293 (defun gnus-summary-next-same-subject ()
10294 "Select next article which has the same subject as current one."
10296 (gnus-set-global-variables)
10297 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10299 (defun gnus-summary-prev-same-subject ()
10300 "Select previous article which has the same subject as current one."
10302 (gnus-set-global-variables)
10303 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10305 (defun gnus-summary-next-unread-same-subject ()
10306 "Select next unread article which has the same subject as current one."
10308 (gnus-set-global-variables)
10309 (gnus-summary-next-article t (gnus-summary-article-subject)))
10311 (defun gnus-summary-prev-unread-same-subject ()
10312 "Select previous unread article which has the same subject as current one."
10314 (gnus-set-global-variables)
10315 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10317 (defun gnus-summary-first-unread-article ()
10318 "Select the first unread article.
10319 Return nil if there are no unread articles."
10321 (gnus-set-global-variables)
10323 (if (gnus-summary-first-subject t)
10325 (gnus-summary-show-thread)
10326 (gnus-summary-first-subject t)
10327 (gnus-summary-display-article (gnus-summary-article-number))))
10328 (gnus-summary-position-point)))
10330 (defun gnus-summary-best-unread-article ()
10331 "Select the unread article with the highest score."
10333 (gnus-set-global-variables)
10334 (let ((best -1000000)
10335 (data gnus-newsgroup-data)
10338 (and (gnus-data-unread-p (car data))
10340 (gnus-summary-article-score (gnus-data-number (car data))))
10343 article (gnus-data-number (car data))))
10344 (setq data (cdr data)))
10346 (gnus-summary-goto-article article)
10347 (error "No unread articles"))
10348 (gnus-summary-position-point)))
10350 (defun gnus-summary-last-subject ()
10351 "Go to the last displayed subject line in the group."
10352 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10354 (gnus-summary-goto-subject article))))
10356 (defun gnus-summary-goto-article (article &optional all-headers force)
10357 "Fetch ARTICLE and display it if it exists.
10358 If ALL-HEADERS is non-nil, no header lines are hidden."
10364 (mapcar (lambda (number) (list (int-to-string number)))
10365 gnus-newsgroup-limit)))
10369 (if (gnus-summary-goto-subject article force)
10370 (gnus-summary-display-article article all-headers)
10371 (gnus-message 4 "Couldn't go to article %s" article) nil)
10372 (gnus-summary-position-point)))
10374 (defun gnus-summary-goto-last-article ()
10375 "Go to the previously read article."
10378 (and gnus-last-article
10379 (gnus-summary-goto-article gnus-last-article))
10380 (gnus-summary-position-point)))
10382 (defun gnus-summary-pop-article (number)
10383 "Pop one article off the history and go to the previous.
10384 NUMBER articles will be popped off."
10387 (setq gnus-newsgroup-history
10388 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10390 (gnus-summary-goto-article (car to))
10391 (error "Article history empty")))
10392 (gnus-summary-position-point))
10394 ;; Summary commands and functions for limiting the summary buffer.
10396 (defun gnus-summary-limit-to-articles (n)
10397 "Limit the summary buffer to the next N articles.
10398 If not given a prefix, use the process marked articles instead."
10400 (gnus-set-global-variables)
10402 (let ((articles (gnus-summary-work-articles n)))
10403 (setq gnus-newsgroup-processable nil)
10404 (gnus-summary-limit articles))
10405 (gnus-summary-position-point)))
10407 (defun gnus-summary-pop-limit (&optional total)
10408 "Restore the previous limit.
10409 If given a prefix, remove all limits."
10411 (gnus-set-global-variables)
10413 (setq gnus-newsgroup-limits
10414 (list (mapcar (lambda (h) (mail-header-number h))
10415 gnus-newsgroup-headers))))
10416 (unless gnus-newsgroup-limits
10417 (error "No limit to pop"))
10419 (gnus-summary-limit nil 'pop)
10420 (gnus-summary-position-point)))
10422 (defun gnus-summary-limit-to-subject (subject &optional header)
10423 "Limit the summary buffer to articles that have subjects that match a regexp."
10424 (interactive "sRegexp: ")
10426 (setq header "subject"))
10427 (when (not (equal "" subject))
10429 (let ((articles (gnus-summary-find-matching
10430 (or header "subject") subject 'all)))
10431 (or articles (error "Found no matches for \"%s\"" subject))
10432 (gnus-summary-limit articles))
10433 (gnus-summary-position-point))))
10435 (defun gnus-summary-limit-to-author (from)
10436 "Limit the summary buffer to articles that have authors that match a regexp."
10437 (interactive "sRegexp: ")
10438 (gnus-summary-limit-to-subject from "from"))
10440 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10442 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10444 (defun gnus-summary-limit-to-unread (&optional all)
10445 "Limit the summary buffer to articles that are not marked as read.
10446 If ALL is non-nil, limit strictly to unread articles."
10449 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10450 (gnus-summary-limit-to-marks
10451 ;; Concat all the marks that say that an article is read and have
10453 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10454 gnus-killed-mark gnus-kill-file-mark
10455 gnus-low-score-mark gnus-expirable-mark
10456 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10459 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10460 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10462 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10463 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10464 If REVERSE, limit the summary buffer to articles that are not marked
10465 with MARKS. MARKS can either be a string of marks or a list of marks.
10466 Returns how many articles were removed."
10467 (interactive "sMarks: ")
10468 (gnus-set-global-variables)
10470 (let ((data gnus-newsgroup-data)
10471 (marks (if (listp marks) marks
10472 (append marks nil))) ; Transform to list.
10475 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10476 (memq (gnus-data-mark (car data)) marks))
10477 (setq articles (cons (gnus-data-number (car data)) articles)))
10478 (setq data (cdr data)))
10479 (gnus-summary-limit articles))
10480 (gnus-summary-position-point)))
10482 (defun gnus-summary-limit-to-score (&optional score)
10483 "Limit to articles with score at or above SCORE."
10485 (gnus-set-global-variables)
10486 (setq score (if score
10487 (prefix-numeric-value score)
10488 (or gnus-summary-default-score 0)))
10489 (let ((data gnus-newsgroup-data)
10492 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10494 (push (gnus-data-number (car data)) articles))
10495 (setq data (cdr data)))
10497 (gnus-summary-limit articles)
10498 (gnus-summary-position-point))))
10500 (defun gnus-summary-limit-include-dormant ()
10501 "Display all the hidden articles that are marked as dormant."
10503 (gnus-set-global-variables)
10504 (or gnus-newsgroup-dormant
10505 (error "There are no dormant articles in this group"))
10507 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10508 (gnus-summary-position-point)))
10510 (defun gnus-summary-limit-exclude-dormant ()
10511 "Hide all dormant articles."
10513 (gnus-set-global-variables)
10515 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10516 (gnus-summary-position-point)))
10518 (defun gnus-summary-limit-exclude-childless-dormant ()
10519 "Hide all dormant articles that have no children."
10521 (gnus-set-global-variables)
10522 (let ((data (gnus-data-list t))
10523 articles d children)
10524 ;; Find all articles that are either not dormant or have
10526 (while (setq d (pop data))
10527 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10528 (and (setq children
10529 (gnus-article-children (gnus-data-number d)))
10532 (when (memq (car children) articles)
10537 (push (gnus-data-number d) articles)))
10538 ;; Do the limiting.
10540 (gnus-summary-limit articles)
10541 (gnus-summary-position-point))))
10543 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10544 "Mark all unread excluded articles as read.
10545 If ALL, mark even excluded ticked and dormants as read."
10547 (let ((articles (gnus-sorted-complement
10549 (mapcar (lambda (h) (mail-header-number h))
10550 gnus-newsgroup-headers)
10552 (sort gnus-newsgroup-limit '<)))
10554 (setq gnus-newsgroup-unreads nil)
10556 (setq gnus-newsgroup-dormant nil
10557 gnus-newsgroup-marked nil
10558 gnus-newsgroup-reads
10560 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10561 gnus-newsgroup-reads))
10562 (while (setq article (pop articles))
10563 (unless (or (memq article gnus-newsgroup-dormant)
10564 (memq article gnus-newsgroup-marked))
10565 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10567 (defun gnus-summary-limit (articles &optional pop)
10569 ;; We pop the previous limit off the stack and use that.
10570 (setq articles (car gnus-newsgroup-limits)
10571 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10572 ;; We use the new limit, so we push the old limit on the stack.
10573 (setq gnus-newsgroup-limits
10574 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10576 (setq gnus-newsgroup-limit articles)
10577 (let ((total (length gnus-newsgroup-data))
10578 (data (gnus-data-find-list (gnus-summary-article-number)))
10580 ;; This will do all the work of generating the new summary buffer
10581 ;; according to the new limit.
10582 (gnus-summary-prepare)
10583 ;; Hide any threads, possibly.
10584 (and gnus-show-threads
10585 gnus-thread-hide-subtree
10586 (gnus-summary-hide-all-threads))
10587 ;; Try to return to the article you were at, or one in the
10590 ;; We try to find some article after the current one.
10592 (and (gnus-summary-goto-subject
10593 (gnus-data-number (car data)) nil t)
10596 (setq data (cdr data))))
10598 ;; If there is no data, that means that we were after the last
10599 ;; article. The same goes when we can't find any articles
10600 ;; after the current one.
10602 (goto-char (point-max))
10603 (gnus-summary-find-prev)))
10604 ;; We return how many articles were removed from the summary
10605 ;; buffer as a result of the new limit.
10606 (- total (length gnus-newsgroup-data))))
10608 (defsubst gnus-cut-thread (thread)
10609 "Go forwards in the thread until we find an article that we want to display."
10610 (when (eq gnus-fetch-old-headers 'some)
10611 ;; Deal with old-fetched headers.
10613 (memq (mail-header-number (car thread))
10614 gnus-newsgroup-ancient)
10615 (<= (length (cdr thread)) 1))
10616 (setq thread (cadr thread))))
10617 ;; Deal with sparse threads.
10618 (when (or (eq gnus-build-sparse-threads 'some)
10619 (eq gnus-build-sparse-threads 'more))
10621 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10622 (= (length (cdr thread)) 1))
10623 (setq thread (cadr thread))))
10626 (defun gnus-cut-threads (threads)
10627 "Cut off all uninteresting articles from the beginning of threads."
10628 (when (or (eq gnus-fetch-old-headers 'some)
10629 (eq gnus-build-sparse-threads 'some)
10630 (eq gnus-build-sparse-threads 'more))
10631 (let ((th threads))
10633 (setcar th (gnus-cut-thread (car th)))
10634 (setq th (cdr th)))))
10635 ;; Remove nixed out threads.
10636 (delq nil threads))
10638 (defun gnus-summary-initial-limit (&optional show-if-empty)
10639 "Figure out what the initial limit is supposed to be on group entry.
10640 This entails weeding out unwanted dormants, low-scored articles,
10641 fetch-old-headers verbiage, and so on."
10642 ;; Most groups have nothing to remove.
10643 (if (or gnus-inhibit-limiting
10644 (and (null gnus-newsgroup-dormant)
10645 (not (eq gnus-fetch-old-headers 'some))
10646 (null gnus-summary-expunge-below)
10647 (not (eq gnus-build-sparse-threads 'some))
10648 (not (eq gnus-build-sparse-threads 'more))
10649 (null gnus-thread-expunge-below)
10650 (not gnus-use-nocem)))
10652 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10653 (setq gnus-newsgroup-limit nil)
10656 (unless (car (symbol-value node))
10657 ;; These threads have no parents -- they are roots.
10658 (let ((nodes (cdr (symbol-value node)))
10661 (if (and gnus-thread-expunge-below
10662 (< (gnus-thread-total-score (car nodes))
10663 gnus-thread-expunge-below))
10664 (gnus-expunge-thread (pop nodes))
10665 (setq thread (pop nodes))
10666 (gnus-summary-limit-children thread))))))
10667 gnus-newsgroup-dependencies)
10668 ;; If this limitation resulted in an empty group, we might
10669 ;; pop the previous limit and use it instead.
10670 (when (and (not gnus-newsgroup-limit)
10672 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10673 gnus-newsgroup-limit))
10675 (defun gnus-summary-limit-children (thread)
10676 "Return 1 if this subthread is visible and 0 if it is not."
10677 ;; First we get the number of visible children to this thread. This
10678 ;; is done by recursing down the thread using this function, so this
10679 ;; will really go down to a leaf article first, before slowly
10680 ;; working its way up towards the root.
10684 (apply '+ (mapcar 'gnus-summary-limit-children
10687 (number (mail-header-number (car thread)))
10690 ;; If this article is dormant and has absolutely no visible
10691 ;; children, then this article isn't visible.
10692 (and (memq number gnus-newsgroup-dormant)
10694 ;; If this is a "fetch-old-headered" and there is only one
10695 ;; visible child (or less), then we don't want this article.
10696 (and (eq gnus-fetch-old-headers 'some)
10697 (memq number gnus-newsgroup-ancient)
10699 ;; If this is a sparsely inserted article with no children,
10700 ;; we don't want it.
10701 (and (eq gnus-build-sparse-threads 'some)
10702 (memq number gnus-newsgroup-sparse)
10704 ;; If we use expunging, and this article is really
10705 ;; low-scored, then we don't want this article.
10706 (when (and gnus-summary-expunge-below
10708 (or (cdr (assq number gnus-newsgroup-scored))
10709 gnus-summary-default-score))
10710 gnus-summary-expunge-below))
10711 ;; We increase the expunge-tally here, but that has
10712 ;; nothing to do with the limits, really.
10713 (incf gnus-newsgroup-expunged-tally)
10714 ;; We also mark as read here, if that's wanted.
10715 (when (and gnus-summary-mark-below
10716 (< score gnus-summary-mark-below))
10717 (setq gnus-newsgroup-unreads
10718 (delq number gnus-newsgroup-unreads))
10719 (if gnus-newsgroup-auto-expire
10720 (push number gnus-newsgroup-expirable)
10721 (push (cons number gnus-low-score-mark)
10722 gnus-newsgroup-reads)))
10724 (and gnus-use-nocem
10725 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10726 ;; Nope, invisible article.
10728 ;; Ok, this article is to be visible, so we add it to the limit
10730 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10733 (defun gnus-expunge-thread (thread)
10734 "Mark all articles in THREAD as read."
10735 (let* ((number (mail-header-number (car thread))))
10736 (incf gnus-newsgroup-expunged-tally)
10737 ;; We also mark as read here, if that's wanted.
10738 (setq gnus-newsgroup-unreads
10739 (delq number gnus-newsgroup-unreads))
10740 (if gnus-newsgroup-auto-expire
10741 (push number gnus-newsgroup-expirable)
10742 (push (cons number gnus-low-score-mark)
10743 gnus-newsgroup-reads)))
10744 ;; Go recursively through all subthreads.
10745 (mapcar 'gnus-expunge-thread (cdr thread)))
10747 ;; Summary article oriented commands
10749 (defun gnus-summary-refer-parent-article (n)
10750 "Refer parent article N times.
10751 The difference between N and the number of articles fetched is returned."
10753 (gnus-set-global-variables)
10757 (let* ((header (gnus-summary-article-header))
10759 ;; If we try to find the parent of the currently
10760 ;; displayed article, then we take a look at the actual
10761 ;; References header, since this is slightly more
10762 ;; reliable than the References field we got from the
10764 (if (and (eq (mail-header-number header)
10765 (cdr gnus-article-current))
10766 (equal gnus-newsgroup-name
10767 (car gnus-article-current)))
10769 (set-buffer gnus-original-article-buffer)
10770 (nnheader-narrow-to-headers)
10772 (mail-fetch-field "references")
10774 ;; It's not the current article, so we take a bet on
10775 ;; the value we got from the server.
10776 (mail-header-references header))))
10777 (if (setq ref (or ref (mail-header-references header)))
10778 (or (gnus-summary-refer-article (gnus-parent-id ref))
10779 (gnus-message 1 "Couldn't find parent"))
10780 (gnus-message 1 "No references in article %d"
10781 (gnus-summary-article-number))
10784 (gnus-summary-position-point)
10787 (defun gnus-summary-refer-references ()
10788 "Fetch all articles mentioned in the References header.
10789 Return how many articles were fetched."
10791 (gnus-set-global-variables)
10792 (let ((ref (mail-header-references (gnus-summary-article-header)))
10793 (current (gnus-summary-article-number))
10795 ;; For each Message-ID in the References header...
10796 (while (string-match "<[^>]*>" ref)
10798 ;; ... fetch that article.
10799 (gnus-summary-refer-article
10800 (prog1 (match-string 0 ref)
10801 (setq ref (substring ref (match-end 0))))))
10802 (gnus-summary-goto-subject current)
10803 (gnus-summary-position-point)
10806 (defun gnus-summary-refer-article (message-id)
10807 "Fetch an article specified by MESSAGE-ID."
10808 (interactive "sMessage-ID: ")
10809 (when (and (stringp message-id)
10810 (not (zerop (length message-id))))
10811 ;; Construct the correct Message-ID if necessary.
10812 ;; Suggested by tale@pawl.rpi.edu.
10813 (unless (string-match "^<" message-id)
10814 (setq message-id (concat "<" message-id)))
10815 (unless (string-match ">$" message-id)
10816 (setq message-id (concat message-id ">")))
10817 (let ((header (car (gnus-gethash message-id
10818 gnus-newsgroup-dependencies))))
10820 ;; The article is present in the buffer, to we just go to it.
10821 (gnus-summary-goto-article (mail-header-number header) nil t)
10822 ;; We fetch the article
10823 (let ((gnus-override-method
10824 (and (gnus-news-group-p gnus-newsgroup-name)
10825 gnus-refer-article-method))
10827 ;; Start the special refer-article method, if necessary.
10828 (when gnus-refer-article-method
10829 (gnus-check-server gnus-refer-article-method))
10830 ;; Fetch the header, and display the article.
10831 (if (setq number (gnus-summary-insert-subject message-id))
10832 (gnus-summary-select-article nil nil nil number)
10833 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10835 (defun gnus-summary-enter-digest-group (&optional force)
10836 "Enter a digest group based on the current article."
10838 (gnus-set-global-variables)
10839 (gnus-summary-select-article)
10840 (let ((name (format "%s-%d"
10841 (gnus-group-prefixed-name
10842 gnus-newsgroup-name (list 'nndoc ""))
10843 gnus-current-article))
10844 (ogroup gnus-newsgroup-name)
10845 (case-fold-search t)
10846 (buf (current-buffer))
10849 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10850 (insert-buffer-substring gnus-original-article-buffer)
10852 (goto-char (point-min))
10853 (or (search-forward "\n\n" nil t) (point)))
10854 (goto-char (point-min))
10855 (delete-matching-lines "^\\(Path\\):\\|^From ")
10858 (if (gnus-group-read-ephemeral-group
10859 name `(nndoc ,name (nndoc-address
10861 (nndoc-article-type ,(if force 'digest 'guess))) t)
10862 ;; Make all postings to this group go to the parent group.
10863 (nconc (gnus-info-params (gnus-get-info name))
10864 (list (cons 'to-group ogroup)))
10865 ;; Couldn't select this doc group.
10866 (switch-to-buffer buf)
10867 (gnus-set-global-variables)
10868 (gnus-configure-windows 'summary)
10869 (gnus-message 3 "Article couldn't be entered?"))
10870 (kill-buffer dig))))
10872 (defun gnus-summary-isearch-article (&optional regexp-p)
10873 "Do incremental search forward on the current article.
10874 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10876 (gnus-set-global-variables)
10877 (gnus-summary-select-article)
10878 (gnus-configure-windows 'article)
10879 (gnus-eval-in-buffer-window
10880 gnus-article-buffer
10881 (goto-char (point-min))
10882 (isearch-forward regexp-p)))
10884 (defun gnus-summary-search-article-forward (regexp &optional backward)
10885 "Search for an article containing REGEXP forward.
10886 If BACKWARD, search backward instead."
10889 (format "Search article %s (regexp%s): "
10890 (if current-prefix-arg "backward" "forward")
10891 (if gnus-last-search-regexp
10892 (concat ", default " gnus-last-search-regexp)
10894 current-prefix-arg))
10895 (gnus-set-global-variables)
10896 (if (string-equal regexp "")
10897 (setq regexp (or gnus-last-search-regexp ""))
10898 (setq gnus-last-search-regexp regexp))
10899 (if (gnus-summary-search-article regexp backward)
10900 (gnus-article-set-window-start
10901 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10902 (error "Search failed: \"%s\"" regexp)))
10904 (defun gnus-summary-search-article-backward (regexp)
10905 "Search for an article containing REGEXP backward."
10908 (format "Search article backward (regexp%s): "
10909 (if gnus-last-search-regexp
10910 (concat ", default " gnus-last-search-regexp)
10912 (gnus-summary-search-article-forward regexp 'backward))
10914 (defun gnus-summary-search-article (regexp &optional backward)
10915 "Search for an article containing REGEXP.
10916 Optional argument BACKWARD means do search for backward.
10917 gnus-select-article-hook is not called during the search."
10918 (let ((gnus-select-article-hook nil) ;Disable hook.
10919 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10922 (function re-search-backward) (function re-search-forward)))
10925 ;; Hidden thread subtrees must be searched for ,too.
10926 (gnus-summary-show-all-threads)
10927 ;; First of all, search current article.
10928 ;; We don't want to read article again from NNTP server nor reset
10930 (gnus-summary-select-article)
10931 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10932 (setq last gnus-current-article)
10933 (gnus-eval-in-buffer-window
10934 gnus-article-buffer
10937 ;; Begin search from current point.
10938 (setq found (funcall re-search regexp nil t))))
10939 ;; Then search next articles.
10940 (while (and (not found)
10941 (gnus-summary-display-article
10942 (if backward (gnus-summary-find-prev)
10943 (gnus-summary-find-next))))
10944 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10945 (gnus-eval-in-buffer-window
10946 gnus-article-buffer
10949 (goto-char (if backward (point-max) (point-min)))
10950 (setq found (funcall re-search regexp nil t)))))
10952 ;; Adjust article pointer.
10953 (or (eq last gnus-current-article)
10954 (setq gnus-last-article last))
10955 ;; Return T if found such article.
10958 (defun gnus-summary-find-matching (header regexp &optional backward unread
10960 "Return a list of all articles that match REGEXP on HEADER.
10961 The search stars on the current article and goes forwards unless
10962 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10963 If UNREAD is non-nil, only unread articles will
10964 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10965 in the comparisons."
10966 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10967 (gnus-data-find-list
10968 (gnus-summary-article-number) (gnus-data-list backward))))
10969 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10970 (case-fold-search (not not-case-fold))
10972 (or (fboundp (intern (concat "mail-header-" header)))
10973 (error "%s is not a valid header" header))
10975 (setq d (car data))
10976 (and (or (not unread) ; We want all articles...
10977 (gnus-data-unread-p d)) ; Or just unreads.
10978 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10979 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10980 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10981 (setq data (cdr data)))
10982 (nreverse articles)))
10984 (defun gnus-summary-execute-command (header regexp command &optional backward)
10985 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10986 If HEADER is an empty string (or nil), the match is done on the entire
10987 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10989 (list (let ((completion-ignore-case t))
10992 (mapcar (lambda (string) (list string))
10993 '("Number" "Subject" "From" "Lines" "Date"
10994 "Message-ID" "Xref" "References" "Body"))
10995 nil 'require-match))
10996 (read-string "Regexp: ")
10997 (read-key-sequence "Command: ")
10998 current-prefix-arg))
10999 (when (equal header "Body")
11001 (gnus-set-global-variables)
11002 ;; Hidden thread subtrees must be searched as well.
11003 (gnus-summary-show-all-threads)
11004 ;; We don't want to change current point nor window configuration.
11006 (save-window-excursion
11007 (gnus-message 6 "Executing %s..." (key-description command))
11008 ;; We'd like to execute COMMAND interactively so as to give arguments.
11009 (gnus-execute header regexp
11010 `(lambda () (call-interactively ',(key-binding command)))
11012 (gnus-message 6 "Executing %s...done" (key-description command)))))
11014 (defun gnus-summary-beginning-of-article ()
11015 "Scroll the article back to the beginning."
11017 (gnus-set-global-variables)
11018 (gnus-summary-select-article)
11019 (gnus-configure-windows 'article)
11020 (gnus-eval-in-buffer-window
11021 gnus-article-buffer
11023 (goto-char (point-min))
11024 (and gnus-break-pages (gnus-narrow-to-page))))
11026 (defun gnus-summary-end-of-article ()
11027 "Scroll to the end of the article."
11029 (gnus-set-global-variables)
11030 (gnus-summary-select-article)
11031 (gnus-configure-windows 'article)
11032 (gnus-eval-in-buffer-window
11033 gnus-article-buffer
11035 (goto-char (point-max))
11037 (and gnus-break-pages (gnus-narrow-to-page))))
11039 (defun gnus-summary-show-article (&optional arg)
11040 "Force re-fetching of the current article.
11041 If ARG (the prefix) is non-nil, show the raw article without any
11042 article massaging functions being run."
11044 (gnus-set-global-variables)
11046 ;; Select the article the normal way.
11047 (gnus-summary-select-article nil 'force)
11048 ;; Bind the article treatment functions to nil.
11049 (let ((gnus-have-all-headers t)
11050 gnus-article-display-hook
11051 gnus-article-prepare-hook
11053 (gnus-summary-select-article nil 'force)))
11054 ; (gnus-configure-windows 'article)
11055 (gnus-summary-position-point))
11057 (defun gnus-summary-verbose-headers (&optional arg)
11058 "Toggle permanent full header display.
11059 If ARG is a positive number, turn header display on.
11060 If ARG is a negative number, turn header display off."
11062 (gnus-set-global-variables)
11063 (gnus-summary-toggle-header arg)
11064 (setq gnus-show-all-headers
11065 (cond ((or (not (numberp arg))
11067 (not gnus-show-all-headers))
11071 (defun gnus-summary-toggle-header (&optional arg)
11072 "Show the headers if they are hidden, or hide them if they are shown.
11073 If ARG is a positive number, show the entire header.
11074 If ARG is a negative number, hide the unwanted header lines."
11076 (gnus-set-global-variables)
11078 (set-buffer gnus-article-buffer)
11079 (let* ((buffer-read-only nil)
11080 (inhibit-point-motion-hooks t)
11081 (hidden (text-property-any
11082 (goto-char (point-min)) (search-forward "\n\n")
11085 (goto-char (point-min))
11086 (when (search-forward "\n\n" nil t)
11087 (delete-region (point-min) (1- (point))))
11088 (goto-char (point-min))
11090 (set-buffer gnus-original-article-buffer)
11091 (goto-char (point-min))
11092 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11093 (insert-buffer-substring gnus-original-article-buffer 1 e)
11094 (let ((gnus-inhibit-hiding t))
11095 (run-hooks 'gnus-article-display-hook))
11096 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11097 (gnus-article-hide-headers)))))
11099 (defun gnus-summary-show-all-headers ()
11100 "Make all header lines visible."
11102 (gnus-set-global-variables)
11103 (gnus-article-show-all-headers))
11105 (defun gnus-summary-toggle-mime (&optional arg)
11106 "Toggle MIME processing.
11107 If ARG is a positive number, turn MIME processing on."
11109 (gnus-set-global-variables)
11110 (setq gnus-show-mime
11111 (if (null arg) (not gnus-show-mime)
11112 (> (prefix-numeric-value arg) 0)))
11113 (gnus-summary-select-article t 'force))
11115 (defun gnus-summary-caesar-message (&optional arg)
11116 "Caesar rotate the current article by 13.
11117 The numerical prefix specifies how manu places to rotate each letter
11120 (gnus-set-global-variables)
11121 (gnus-summary-select-article)
11122 (let ((mail-header-separator ""))
11123 (gnus-eval-in-buffer-window
11124 gnus-article-buffer
11127 (let ((start (window-start)))
11128 (news-caesar-buffer-body arg)
11129 (set-window-start (get-buffer-window (current-buffer)) start))))))
11131 (defun gnus-summary-stop-page-breaking ()
11132 "Stop page breaking in the current article."
11134 (gnus-set-global-variables)
11135 (gnus-summary-select-article)
11136 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11138 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11139 "Move the current article to a different newsgroup.
11140 If N is a positive number, move the N next articles.
11141 If N is a negative number, move the N previous articles.
11142 If N is nil and any articles have been marked with the process mark,
11143 move those articles instead.
11144 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11145 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11146 re-spool using this method.
11148 For this function to work, both the current newsgroup and the
11149 newsgroup that you want to move to have to support the `request-move'
11150 and `request-accept' functions."
11152 (unless action (setq action 'move))
11153 (gnus-set-global-variables)
11154 ;; Check whether the source group supports the required functions.
11155 (cond ((and (eq action 'move)
11156 (not (gnus-check-backend-function
11157 'request-move-article gnus-newsgroup-name)))
11158 (error "The current group does not support article moving"))
11159 ((and (eq action 'crosspost)
11160 (not (gnus-check-backend-function
11161 'request-replace-article gnus-newsgroup-name)))
11162 (error "The current group does not support article editing")))
11163 (let ((articles (gnus-summary-work-articles n))
11164 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11165 (names '((move "move" "Moving")
11166 (copy "copy" "Copying")
11167 (crosspost "crosspost" "Crossposting")))
11168 (copy-buf (save-excursion
11169 (nnheader-set-temp-buffer " *copy article*")))
11170 art-group to-method new-xref article to-groups)
11171 (unless (assq action names)
11172 (error "Unknown action %s" action))
11173 ;; Read the newsgroup name.
11174 (when (and (not to-newsgroup)
11175 (not select-method))
11177 (gnus-read-move-group-name
11178 (cadr (assq action names))
11179 gnus-current-move-group articles prefix))
11180 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11181 (setq to-method (if select-method (list select-method "")
11182 (gnus-find-method-for-group to-newsgroup)))
11183 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11184 ;;(error "Can't %s to the same group you're already in" action))
11185 ;; Check the method we are to move this article to...
11186 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11187 (error "%s does not support article copying" (car to-method)))
11188 (or (gnus-check-server to-method)
11189 (error "Can't open server %s" (car to-method)))
11190 (gnus-message 6 "%s to %s: %s..."
11191 (caddr (assq action names))
11192 (or select-method to-newsgroup) articles)
11194 (setq article (pop articles))
11198 ;; Move the article.
11200 (gnus-request-move-article
11201 article ; Article to move
11202 gnus-newsgroup-name ; From newsgrouo
11203 (nth 1 (gnus-find-method-for-group
11204 gnus-newsgroup-name)) ; Server
11205 (list 'gnus-request-accept-article
11207 (list 'quote select-method)
11209 (not articles)) ; Accept form
11210 (not articles))) ; Only save nov last time
11211 ;; Copy the article.
11214 (set-buffer copy-buf)
11215 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11216 (gnus-request-accept-article
11217 (if select-method select-method to-newsgroup)
11219 ;; Crosspost the article.
11220 ((eq action 'crosspost)
11221 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11222 (setq new-xref (concat gnus-newsgroup-name ":" article))
11223 (if (and xref (not (string= xref "")))
11225 (when (string-match "^Xref: " xref)
11226 (setq xref (substring xref (match-end 0))))
11227 (setq new-xref (concat xref " " new-xref)))
11228 (setq new-xref (concat (system-name) " " new-xref)))
11230 (set-buffer copy-buf)
11231 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11232 (nnheader-replace-header "xref" new-xref)
11233 (gnus-request-accept-article
11234 (if select-method select-method to-newsgroup)
11235 (not articles)))))))
11236 (if (not art-group)
11237 (gnus-message 1 "Couldn't %s article %s"
11238 (cadr (assq action names)) article)
11241 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11243 (gnus-group-prefixed-name
11245 (if select-method (list select-method "")
11246 (gnus-find-method-for-group to-newsgroup)))
11247 gnus-newsrc-hashtb)))
11248 (info (nth 2 entry))
11249 (to-group (gnus-info-group info)))
11250 ;; Update the group that has been moved to.
11252 (memq action '(move copy)))
11253 (unless (member to-group to-groups)
11254 (push to-group to-groups))
11256 (unless (memq article gnus-newsgroup-unreads)
11257 (gnus-info-set-read
11258 info (gnus-add-to-range (gnus-info-read info)
11259 (list (cdr art-group)))))
11261 ;; Copy any marks over to the new group.
11262 (let ((marks gnus-article-mark-lists)
11263 (to-article (cdr art-group)))
11265 ;; See whether the article is to be put in the cache.
11266 (when gnus-use-cache
11267 (gnus-cache-possibly-enter-article
11268 to-group to-article
11269 (let ((header (copy-sequence
11270 (gnus-summary-article-header article))))
11271 (mail-header-set-number header to-article)
11273 (memq article gnus-newsgroup-marked)
11274 (memq article gnus-newsgroup-dormant)
11275 (memq article gnus-newsgroup-unreads)))
11278 (when (memq article (symbol-value
11279 (intern (format "gnus-newsgroup-%s"
11281 ;; If the other group is the same as this group,
11282 ;; then we have to add the mark to the list.
11283 (when (equal to-group gnus-newsgroup-name)
11284 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11287 (intern (format "gnus-newsgroup-%s"
11289 ;; Copy mark to other group.
11290 (gnus-add-marked-articles
11291 to-group (cdar marks) (list to-article) info))
11292 (setq marks (cdr marks)))))
11294 ;; Update the Xref header in this article to point to
11295 ;; the new crossposted article we have just created.
11296 (when (eq action 'crosspost)
11298 (set-buffer copy-buf)
11299 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11300 (nnheader-replace-header
11301 "xref" (concat new-xref " " (gnus-group-prefixed-name
11302 (car art-group) to-method)
11303 ":" (cdr art-group)))
11304 (gnus-request-replace-article
11305 article gnus-newsgroup-name (current-buffer)))))
11307 (gnus-summary-goto-subject article)
11308 (when (eq action 'move)
11309 (gnus-summary-mark-article article gnus-canceled-mark)))
11310 (gnus-summary-remove-process-mark article))
11311 ;; Re-activate all groups that have been moved to.
11313 (gnus-activate-group (pop to-groups)))
11315 (gnus-kill-buffer copy-buf)
11316 (gnus-summary-position-point)
11317 (gnus-set-mode-line 'summary)))
11319 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11320 "Move the current article to a different newsgroup.
11321 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11322 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11323 re-spool using this method."
11325 (gnus-summary-move-article n nil select-method 'copy))
11327 (defun gnus-summary-crosspost-article (&optional n)
11328 "Crosspost the current article to some other group."
11330 (gnus-summary-move-article n nil nil 'crosspost))
11332 (defun gnus-summary-respool-article (&optional n respool-method)
11333 "Respool the current article.
11334 The article will be squeezed through the mail spooling process again,
11335 which means that it will be put in some mail newsgroup or other
11336 depending on `nnmail-split-methods'.
11337 If N is a positive number, respool the N next articles.
11338 If N is a negative number, respool the N previous articles.
11339 If N is nil and any articles have been marked with the process mark,
11340 respool those articles instead.
11342 Respooling can be done both from mail groups and \"real\" newsgroups.
11343 In the former case, the articles in question will be moved from the
11344 current group into whatever groups they are destined to. In the
11345 latter case, they will be copied into the relevant groups."
11347 (gnus-set-global-variables)
11348 (let ((respool-methods (gnus-methods-using 'respool))
11350 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11351 (unless respool-method
11352 (setq respool-method
11354 "What method do you want to use when respooling? "
11355 respool-methods nil t (cons methname 0))))
11356 (unless (string= respool-method "")
11357 (if (assoc (symbol-name
11358 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11360 (gnus-summary-move-article n nil (intern respool-method))
11361 (gnus-summary-copy-article n nil (intern respool-method))))))
11363 (defun gnus-summary-import-article (file)
11364 "Import a random file into a mail newsgroup."
11365 (interactive "fImport file: ")
11366 (gnus-set-global-variables)
11367 (let ((group gnus-newsgroup-name)
11368 (now (current-time))
11370 (or (gnus-check-backend-function 'request-accept-article group)
11371 (error "%s does not support article importing" group))
11372 (or (file-readable-p file)
11373 (not (file-regular-p file))
11374 (error "Can't read %s" file))
11376 (set-buffer (get-buffer-create " *import file*"))
11377 (buffer-disable-undo (current-buffer))
11379 (insert-file-contents file)
11380 (goto-char (point-min))
11381 (unless (nnheader-article-p)
11382 ;; This doesn't look like an article, so we fudge some headers.
11383 (setq atts (file-attributes file)
11384 lines (count-lines (point-min) (point-max)))
11385 (insert "From: " (read-string "From: ") "\n"
11386 "Subject: " (read-string "Subject: ") "\n"
11387 "Date: " (timezone-make-date-arpa-standard
11388 (current-time-string (nth 5 atts))
11389 (current-time-zone now)
11390 (current-time-zone now)) "\n"
11391 "Message-ID: " (gnus-inews-message-id) "\n"
11392 "Lines: " (int-to-string lines) "\n"
11393 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11394 (gnus-request-accept-article group t)
11395 (kill-buffer (current-buffer)))))
11397 (defun gnus-summary-expire-articles ()
11398 "Expire all articles that are marked as expirable in the current group."
11400 (gnus-set-global-variables)
11401 (when (gnus-check-backend-function
11402 'request-expire-articles gnus-newsgroup-name)
11403 ;; This backend supports expiry.
11404 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11405 (expirable (if total
11406 (gnus-list-of-read-articles gnus-newsgroup-name)
11407 (setq gnus-newsgroup-expirable
11408 (sort gnus-newsgroup-expirable '<))))
11409 (expiry-wait (gnus-group-get-parameter
11410 gnus-newsgroup-name 'expiry-wait))
11413 ;; There are expirable articles in this group, so we run them
11414 ;; through the expiry process.
11415 (gnus-message 6 "Expiring articles...")
11416 ;; The list of articles that weren't expired is returned.
11418 (let ((nnmail-expiry-wait-function nil)
11419 (nnmail-expiry-wait expiry-wait))
11420 (setq es (gnus-request-expire-articles
11421 expirable gnus-newsgroup-name)))
11422 (setq es (gnus-request-expire-articles
11423 expirable gnus-newsgroup-name)))
11424 (or total (setq gnus-newsgroup-expirable es))
11425 ;; We go through the old list of expirable, and mark all
11426 ;; really expired articles as nonexistent.
11427 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11428 (let ((gnus-use-cache nil))
11430 (unless (memq (car expirable) es)
11431 (when (gnus-data-find (car expirable))
11432 (gnus-summary-mark-article
11433 (car expirable) gnus-canceled-mark)))
11434 (setq expirable (cdr expirable)))))
11435 (gnus-message 6 "Expiring articles...done")))))
11437 (defun gnus-summary-expire-articles-now ()
11438 "Expunge all expirable articles in the current group.
11439 This means that *all* articles that are marked as expirable will be
11440 deleted forever, right now."
11442 (gnus-set-global-variables)
11443 (or gnus-expert-user
11445 "Are you really, really, really sure you want to expunge? ")
11447 (let ((nnmail-expiry-wait 'immediate)
11448 (nnmail-expiry-wait-function nil))
11449 (gnus-summary-expire-articles)))
11451 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11452 (defun gnus-summary-delete-article (&optional n)
11453 "Delete the N next (mail) articles.
11454 This command actually deletes articles. This is not a marking
11455 command. The article will disappear forever from your life, never to
11457 If N is negative, delete backwards.
11458 If N is nil and articles have been marked with the process mark,
11459 delete these instead."
11461 (gnus-set-global-variables)
11462 (or (gnus-check-backend-function 'request-expire-articles
11463 gnus-newsgroup-name)
11464 (error "The current newsgroup does not support article deletion."))
11465 ;; Compute the list of articles to delete.
11466 (let ((articles (gnus-summary-work-articles n))
11468 (if (and gnus-novice-user
11469 (not (gnus-y-or-n-p
11470 (format "Do you really want to delete %s forever? "
11471 (if (> (length articles) 1) "these articles"
11472 "this article")))))
11474 ;; Delete the articles.
11475 (setq not-deleted (gnus-request-expire-articles
11476 articles gnus-newsgroup-name 'force))
11478 (gnus-summary-remove-process-mark (car articles))
11479 ;; The backend might not have been able to delete the article
11481 (or (memq (car articles) not-deleted)
11482 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11483 (setq articles (cdr articles))))
11484 (gnus-summary-position-point)
11485 (gnus-set-mode-line 'summary)
11488 (defun gnus-summary-edit-article (&optional force)
11489 "Enter into a buffer and edit the current article.
11490 This will have permanent effect only in mail groups.
11491 If FORCE is non-nil, allow editing of articles even in read-only
11495 (set-buffer gnus-summary-buffer)
11496 (gnus-set-global-variables)
11497 (when (and (not force)
11498 (gnus-group-read-only-p))
11499 (error "The current newsgroup does not support article editing."))
11500 (gnus-summary-select-article t nil t)
11501 (gnus-configure-windows 'article)
11502 (select-window (get-buffer-window gnus-article-buffer))
11503 (gnus-message 6 "C-c C-c to end edits")
11504 (setq buffer-read-only nil)
11506 (use-local-map (copy-keymap (current-local-map)))
11507 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11508 (buffer-enable-undo)
11510 (goto-char (point-min))
11511 (search-forward "\n\n" nil t)))
11513 (defun gnus-summary-edit-article-done ()
11514 "Make edits to the current article permanent."
11516 (if (gnus-group-read-only-p)
11518 (gnus-summary-edit-article-postpone)
11520 1 "The current newsgroup does not support article editing.")
11522 (let ((buf (format "%s" (buffer-string))))
11525 (if (not (gnus-request-replace-article
11526 (cdr gnus-article-current) (car gnus-article-current)
11528 (error "Couldn't replace article.")
11529 (gnus-article-mode)
11530 (use-local-map gnus-article-mode-map)
11531 (setq buffer-read-only t)
11532 (buffer-disable-undo (current-buffer))
11533 (gnus-configure-windows 'summary)
11534 (gnus-summary-update-article (cdr gnus-article-current))
11535 (when gnus-use-cache
11536 (gnus-cache-update-article
11537 (cdr gnus-article-current) (car gnus-article-current))))
11538 (run-hooks 'gnus-article-display-hook)
11539 (and (gnus-visual-p 'summary-highlight 'highlight)
11540 (run-hooks 'gnus-visual-mark-article-hook)))))
11542 (defun gnus-summary-edit-article-postpone ()
11543 "Postpone changes to the current article."
11545 (gnus-article-mode)
11546 (use-local-map gnus-article-mode-map)
11547 (setq buffer-read-only t)
11548 (buffer-disable-undo (current-buffer))
11549 (gnus-configure-windows 'summary)
11550 (and (gnus-visual-p 'summary-highlight 'highlight)
11551 (run-hooks 'gnus-visual-mark-article-hook)))
11553 (defun gnus-summary-respool-query ()
11554 "Query where the respool algorithm would put this article."
11556 (gnus-set-global-variables)
11557 (gnus-summary-select-article)
11559 (set-buffer gnus-article-buffer)
11561 (goto-char (point-min))
11562 (search-forward "\n\n")
11563 (narrow-to-region (point-min) (point))
11564 (pp-eval-expression
11565 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11567 ;; Summary score commands.
11569 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11571 (defun gnus-summary-raise-score (n)
11572 "Raise the score of the current article by N."
11574 (gnus-set-global-variables)
11575 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11577 (defun gnus-summary-set-score (n)
11578 "Set the score of the current article to N."
11580 (gnus-set-global-variables)
11582 (gnus-summary-show-thread)
11583 (let ((buffer-read-only nil))
11585 (gnus-summary-update-mark
11586 (if (= n (or gnus-summary-default-score 0)) ?
11587 (if (< n (or gnus-summary-default-score 0))
11588 gnus-score-below-mark gnus-score-over-mark)) 'score))
11589 (let* ((article (gnus-summary-article-number))
11590 (score (assq article gnus-newsgroup-scored)))
11591 (if score (setcdr score n)
11592 (setq gnus-newsgroup-scored
11593 (cons (cons article n) gnus-newsgroup-scored))))
11594 (gnus-summary-update-line)))
11596 (defun gnus-summary-current-score ()
11597 "Return the score of the current article."
11599 (gnus-set-global-variables)
11600 (message "%s" (gnus-summary-article-score)))
11602 ;; Summary marking commands.
11604 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11605 "Mark articles which has the same subject as read, and then select the next.
11606 If UNMARK is positive, remove any kind of mark.
11607 If UNMARK is negative, tick articles."
11609 (gnus-set-global-variables)
11611 (setq unmark (prefix-numeric-value unmark)))
11613 (gnus-summary-mark-same-subject
11614 (gnus-summary-article-subject) unmark)))
11615 ;; Select next unread article. If auto-select-same mode, should
11616 ;; select the first unread article.
11617 (gnus-summary-next-article t (and gnus-auto-select-same
11618 (gnus-summary-article-subject)))
11619 (gnus-message 7 "%d article%s marked as %s"
11620 count (if (= count 1) " is" "s are")
11621 (if unmark "unread" "read"))))
11623 (defun gnus-summary-kill-same-subject (&optional unmark)
11624 "Mark articles which has the same subject as read.
11625 If UNMARK is positive, remove any kind of mark.
11626 If UNMARK is negative, tick articles."
11628 (gnus-set-global-variables)
11630 (setq unmark (prefix-numeric-value unmark)))
11632 (gnus-summary-mark-same-subject
11633 (gnus-summary-article-subject) unmark)))
11634 ;; If marked as read, go to next unread subject.
11636 ;; Go to next unread subject.
11637 (gnus-summary-next-subject 1 t))
11638 (gnus-message 7 "%d articles are marked as %s"
11639 count (if unmark "unread" "read"))))
11641 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11642 "Mark articles with same SUBJECT as read, and return marked number.
11643 If optional argument UNMARK is positive, remove any kinds of marks.
11644 If optional argument UNMARK is negative, mark articles as unread instead."
11648 ((null unmark) ; Mark as read.
11651 (gnus-summary-mark-article-as-read gnus-killed-mark)
11652 (gnus-summary-show-thread) t)
11653 (gnus-summary-find-subject subject))
11654 (setq count (1+ count))))
11655 ((> unmark 0) ; Tick.
11658 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11659 (gnus-summary-show-thread) t)
11660 (gnus-summary-find-subject subject))
11661 (setq count (1+ count))))
11662 (t ; Mark as unread.
11665 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11666 (gnus-summary-show-thread) t)
11667 (gnus-summary-find-subject subject))
11668 (setq count (1+ count)))))
11669 (gnus-set-mode-line 'summary)
11670 ;; Return the number of marked articles.
11673 (defun gnus-summary-mark-as-processable (n &optional unmark)
11674 "Set the process mark on the next N articles.
11675 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11676 the process mark instead. The difference between N and the actual
11677 number of articles marked is returned."
11679 (gnus-set-global-variables)
11680 (let ((backward (< n 0))
11685 (gnus-summary-remove-process-mark
11686 (gnus-summary-article-number))
11687 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11688 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11690 (if (/= 0 n) (gnus-message 7 "No more articles"))
11691 (gnus-summary-recenter)
11692 (gnus-summary-position-point)
11695 (defun gnus-summary-unmark-as-processable (n)
11696 "Remove the process mark from the next N articles.
11697 If N is negative, mark backward instead. The difference between N and
11698 the actual number of articles marked is returned."
11700 (gnus-set-global-variables)
11701 (gnus-summary-mark-as-processable n t))
11703 (defun gnus-summary-unmark-all-processable ()
11704 "Remove the process mark from all articles."
11706 (gnus-set-global-variables)
11708 (while gnus-newsgroup-processable
11709 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11710 (gnus-summary-position-point))
11712 (defun gnus-summary-mark-as-expirable (n)
11713 "Mark N articles forward as expirable.
11714 If N is negative, mark backward instead. The difference between N and
11715 the actual number of articles marked is returned."
11717 (gnus-set-global-variables)
11718 (gnus-summary-mark-forward n gnus-expirable-mark))
11720 (defun gnus-summary-mark-article-as-replied (article)
11721 "Mark ARTICLE replied and update the summary line."
11722 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11723 (let ((buffer-read-only nil))
11724 (when (gnus-summary-goto-subject article)
11725 (gnus-summary-update-secondary-mark article))))
11727 (defun gnus-summary-set-bookmark (article)
11728 "Set a bookmark in current article."
11729 (interactive (list (gnus-summary-article-number)))
11730 (gnus-set-global-variables)
11731 (if (or (not (get-buffer gnus-article-buffer))
11732 (not gnus-current-article)
11733 (not gnus-article-current)
11734 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11735 (error "No current article selected"))
11736 ;; Remove old bookmark, if one exists.
11737 (let ((old (assq article gnus-newsgroup-bookmarks)))
11738 (if old (setq gnus-newsgroup-bookmarks
11739 (delq old gnus-newsgroup-bookmarks))))
11740 ;; Set the new bookmark, which is on the form
11741 ;; (article-number . line-number-in-body).
11742 (setq gnus-newsgroup-bookmarks
11746 (set-buffer gnus-article-buffer)
11750 (goto-char (point-min))
11751 (search-forward "\n\n" nil t)
11754 gnus-newsgroup-bookmarks))
11755 (gnus-message 6 "A bookmark has been added to the current article."))
11757 (defun gnus-summary-remove-bookmark (article)
11758 "Remove the bookmark from the current article."
11759 (interactive (list (gnus-summary-article-number)))
11760 (gnus-set-global-variables)
11761 ;; Remove old bookmark, if one exists.
11762 (let ((old (assq article gnus-newsgroup-bookmarks)))
11765 (setq gnus-newsgroup-bookmarks
11766 (delq old gnus-newsgroup-bookmarks))
11767 (gnus-message 6 "Removed bookmark."))
11768 (gnus-message 6 "No bookmark in current article."))))
11770 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11771 (defun gnus-summary-mark-as-dormant (n)
11772 "Mark N articles forward as dormant.
11773 If N is negative, mark backward instead. The difference between N and
11774 the actual number of articles marked is returned."
11776 (gnus-set-global-variables)
11777 (gnus-summary-mark-forward n gnus-dormant-mark))
11779 (defun gnus-summary-set-process-mark (article)
11780 "Set the process mark on ARTICLE and update the summary line."
11781 (setq gnus-newsgroup-processable
11783 (delq article gnus-newsgroup-processable)))
11784 (when (gnus-summary-goto-subject article)
11785 (gnus-summary-show-thread)
11786 (gnus-summary-update-secondary-mark article)))
11788 (defun gnus-summary-remove-process-mark (article)
11789 "Remove the process mark from ARTICLE and update the summary line."
11790 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11791 (when (gnus-summary-goto-subject article)
11792 (gnus-summary-show-thread)
11793 (gnus-summary-update-secondary-mark article)))
11795 (defun gnus-summary-set-saved-mark (article)
11796 "Set the process mark on ARTICLE and update the summary line."
11797 (push article gnus-newsgroup-saved)
11798 (when (gnus-summary-goto-subject article)
11799 (gnus-summary-update-secondary-mark article)))
11801 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11802 "Mark N articles as read forwards.
11803 If N is negative, mark backwards instead.
11804 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11806 The difference between N and the actual number of articles marked is
11809 (gnus-set-global-variables)
11810 (let ((backward (< n 0))
11811 (gnus-summary-goto-unread
11812 (and gnus-summary-goto-unread
11813 (not (eq gnus-summary-goto-unread 'never))
11814 (not (memq mark (list gnus-unread-mark
11815 gnus-ticked-mark gnus-dormant-mark)))))
11817 (mark (or mark gnus-del-mark)))
11818 (while (and (> n 0)
11819 (gnus-summary-mark-article nil mark no-expire)
11820 (zerop (gnus-summary-next-subject
11822 (and gnus-summary-goto-unread
11823 (not (eq gnus-summary-goto-unread 'never)))
11826 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11827 (gnus-summary-recenter)
11828 (gnus-summary-position-point)
11829 (gnus-set-mode-line 'summary)
11832 (defun gnus-summary-mark-article-as-read (mark)
11833 "Mark the current article quickly as read with MARK."
11834 (let ((article (gnus-summary-article-number)))
11835 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11836 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11837 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11838 (setq gnus-newsgroup-reads
11839 (cons (cons article mark) gnus-newsgroup-reads))
11840 ;; Possibly remove from cache, if that is used.
11841 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11842 ;; Allow the backend to change the mark.
11843 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11844 ;; Check for auto-expiry.
11845 (when (and gnus-newsgroup-auto-expire
11846 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11847 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11848 (= mark gnus-ancient-mark)
11849 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11850 (setq mark gnus-expirable-mark)
11851 (push article gnus-newsgroup-expirable))
11852 ;; Set the mark in the buffer.
11853 (gnus-summary-update-mark mark 'unread)
11856 (defun gnus-summary-mark-article-as-unread (mark)
11857 "Mark the current article quickly as unread with MARK."
11858 (let ((article (gnus-summary-article-number)))
11859 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11860 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11861 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11862 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11863 (cond ((= mark gnus-ticked-mark)
11864 (push article gnus-newsgroup-marked))
11865 ((= mark gnus-dormant-mark)
11866 (push article gnus-newsgroup-dormant))
11868 (push article gnus-newsgroup-unreads)))
11869 (setq gnus-newsgroup-reads
11870 (delq (assq article gnus-newsgroup-reads)
11871 gnus-newsgroup-reads))
11873 ;; See whether the article is to be put in the cache.
11874 (and gnus-use-cache
11875 (vectorp (gnus-summary-article-header article))
11877 (gnus-cache-possibly-enter-article
11878 gnus-newsgroup-name article
11879 (gnus-summary-article-header article)
11880 (= mark gnus-ticked-mark)
11881 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11884 (gnus-summary-update-mark mark 'unread)
11887 (defun gnus-summary-mark-article (&optional article mark no-expire)
11888 "Mark ARTICLE with MARK. MARK can be any character.
11889 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11890 `??' (dormant) and `?E' (expirable).
11891 If MARK is nil, then the default character `?D' is used.
11892 If ARTICLE is nil, then the article on the current line will be
11894 ;; The mark might be a string.
11895 (and (stringp mark)
11896 (setq mark (aref mark 0)))
11897 ;; If no mark is given, then we check auto-expiring.
11898 (and (not no-expire)
11899 gnus-newsgroup-auto-expire
11901 (and (numberp mark)
11902 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11903 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11904 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11905 (setq mark gnus-expirable-mark))
11906 (let* ((mark (or mark gnus-del-mark))
11907 (article (or article (gnus-summary-article-number))))
11908 (or article (error "No article on current line"))
11909 (if (or (= mark gnus-unread-mark)
11910 (= mark gnus-ticked-mark)
11911 (= mark gnus-dormant-mark))
11912 (gnus-mark-article-as-unread article mark)
11913 (gnus-mark-article-as-read article mark))
11915 ;; See whether the article is to be put in the cache.
11916 (and gnus-use-cache
11917 (not (= mark gnus-canceled-mark))
11918 (vectorp (gnus-summary-article-header article))
11920 (gnus-cache-possibly-enter-article
11921 gnus-newsgroup-name article
11922 (gnus-summary-article-header article)
11923 (= mark gnus-ticked-mark)
11924 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11926 (if (gnus-summary-goto-subject article nil t)
11927 (let ((buffer-read-only nil))
11928 (gnus-summary-show-thread)
11930 (gnus-summary-update-mark mark 'unread)
11933 (defun gnus-summary-update-secondary-mark (article)
11934 "Update the secondary (read, process, cache) mark."
11935 (gnus-summary-update-mark
11936 (cond ((memq article gnus-newsgroup-processable)
11938 ((memq article gnus-newsgroup-cached)
11940 ((memq article gnus-newsgroup-replied)
11942 ((memq article gnus-newsgroup-saved)
11944 (t gnus-unread-mark))
11946 (when (gnus-visual-p 'summary-highlight 'highlight)
11947 (run-hooks 'gnus-summary-update-hook))
11950 (defun gnus-summary-update-mark (mark type)
11951 (beginning-of-line)
11952 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11953 (buffer-read-only nil))
11955 ;; Go to the right position on the line.
11956 (forward-char forward)
11957 ;; Replace the old mark with the new mark.
11958 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11959 ;; Optionally update the marks by some user rule.
11960 (when (eq type 'unread)
11961 (gnus-data-set-mark
11962 (gnus-data-find (gnus-summary-article-number)) mark)
11963 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11965 (defun gnus-mark-article-as-read (article &optional mark)
11966 "Enter ARTICLE in the pertinent lists and remove it from others."
11967 ;; Make the article expirable.
11968 (let ((mark (or mark gnus-del-mark)))
11969 (if (= mark gnus-expirable-mark)
11970 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11971 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11972 ;; Remove from unread and marked lists.
11973 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11974 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11975 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11976 (push (cons article mark) gnus-newsgroup-reads)
11977 ;; Possibly remove from cache, if that is used.
11978 (when gnus-use-cache
11979 (gnus-cache-enter-remove-article article))))
11981 (defun gnus-mark-article-as-unread (article &optional mark)
11982 "Enter ARTICLE in the pertinent lists and remove it from others."
11983 (let ((mark (or mark gnus-ticked-mark)))
11984 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11985 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11986 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11987 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11988 (cond ((= mark gnus-ticked-mark)
11989 (push article gnus-newsgroup-marked))
11990 ((= mark gnus-dormant-mark)
11991 (push article gnus-newsgroup-dormant))
11993 (push article gnus-newsgroup-unreads)))
11994 (setq gnus-newsgroup-reads
11995 (delq (assq article gnus-newsgroup-reads)
11996 gnus-newsgroup-reads))))
11998 (defalias 'gnus-summary-mark-as-unread-forward
11999 'gnus-summary-tick-article-forward)
12000 (make-obsolete 'gnus-summary-mark-as-unread-forward
12001 'gnus-summary-tick-article-forward)
12002 (defun gnus-summary-tick-article-forward (n)
12003 "Tick N articles forwards.
12004 If N is negative, tick backwards instead.
12005 The difference between N and the number of articles ticked is returned."
12007 (gnus-summary-mark-forward n gnus-ticked-mark))
12009 (defalias 'gnus-summary-mark-as-unread-backward
12010 'gnus-summary-tick-article-backward)
12011 (make-obsolete 'gnus-summary-mark-as-unread-backward
12012 'gnus-summary-tick-article-backward)
12013 (defun gnus-summary-tick-article-backward (n)
12014 "Tick N articles backwards.
12015 The difference between N and the number of articles ticked is returned."
12017 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12019 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12020 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12021 (defun gnus-summary-tick-article (&optional article clear-mark)
12022 "Mark current article as unread.
12023 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12024 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12026 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12027 gnus-ticked-mark)))
12029 (defun gnus-summary-mark-as-read-forward (n)
12030 "Mark N articles as read forwards.
12031 If N is negative, mark backwards instead.
12032 The difference between N and the actual number of articles marked is
12035 (gnus-summary-mark-forward n gnus-del-mark t))
12037 (defun gnus-summary-mark-as-read-backward (n)
12038 "Mark the N articles as read backwards.
12039 The difference between N and the actual number of articles marked is
12042 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12044 (defun gnus-summary-mark-as-read (&optional article mark)
12045 "Mark current article as read.
12046 ARTICLE specifies the article to be marked as read.
12047 MARK specifies a string to be inserted at the beginning of the line."
12048 (gnus-summary-mark-article article mark))
12050 (defun gnus-summary-clear-mark-forward (n)
12051 "Clear marks from N articles forward.
12052 If N is negative, clear backward instead.
12053 The difference between N and the number of marks cleared is returned."
12055 (gnus-summary-mark-forward n gnus-unread-mark))
12057 (defun gnus-summary-clear-mark-backward (n)
12058 "Clear marks from N articles backward.
12059 The difference between N and the number of marks cleared is returned."
12061 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12063 (defun gnus-summary-mark-unread-as-read ()
12064 "Intended to be used by `gnus-summary-mark-article-hook'."
12065 (when (memq gnus-current-article gnus-newsgroup-unreads)
12066 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12068 (defun gnus-summary-mark-read-and-unread-as-read ()
12069 "Intended to be used by `gnus-summary-mark-article-hook'."
12070 (let ((mark (gnus-summary-article-mark)))
12071 (when (or (gnus-unread-mark-p mark)
12072 (gnus-read-mark-p mark))
12073 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12075 (defun gnus-summary-mark-region-as-read (point mark all)
12076 "Mark all unread articles between point and mark as read.
12077 If given a prefix, mark all articles between point and mark as read,
12078 even ticked and dormant ones."
12079 (interactive "r\nP")
12083 (beginning-of-line)
12088 (memq (setq article (gnus-summary-article-number))
12089 gnus-newsgroup-unreads))
12090 (gnus-summary-mark-article article gnus-del-mark))
12092 (gnus-summary-find-next))))))
12094 (defun gnus-summary-mark-below (score mark)
12095 "Mark articles with score less than SCORE with MARK."
12096 (interactive "P\ncMark: ")
12097 (gnus-set-global-variables)
12098 (setq score (if score
12099 (prefix-numeric-value score)
12100 (or gnus-summary-default-score 0)))
12102 (set-buffer gnus-summary-buffer)
12103 (goto-char (point-min))
12106 (and (< (gnus-summary-article-score) score)
12107 (gnus-summary-mark-article nil mark))
12108 (gnus-summary-find-next)))))
12110 (defun gnus-summary-kill-below (&optional score)
12111 "Mark articles with score below SCORE as read."
12113 (gnus-set-global-variables)
12114 (gnus-summary-mark-below score gnus-killed-mark))
12116 (defun gnus-summary-clear-above (&optional score)
12117 "Clear all marks from articles with score above SCORE."
12119 (gnus-set-global-variables)
12120 (gnus-summary-mark-above score gnus-unread-mark))
12122 (defun gnus-summary-tick-above (&optional score)
12123 "Tick all articles with score above SCORE."
12125 (gnus-set-global-variables)
12126 (gnus-summary-mark-above score gnus-ticked-mark))
12128 (defun gnus-summary-mark-above (score mark)
12129 "Mark articles with score over SCORE with MARK."
12130 (interactive "P\ncMark: ")
12131 (gnus-set-global-variables)
12132 (setq score (if score
12133 (prefix-numeric-value score)
12134 (or gnus-summary-default-score 0)))
12136 (set-buffer gnus-summary-buffer)
12137 (goto-char (point-min))
12139 (if (> (gnus-summary-article-score) score)
12140 (gnus-summary-mark-article nil mark))
12142 (gnus-summary-find-next)))))
12144 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12145 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12146 (defun gnus-summary-limit-include-expunged ()
12147 "Display all the hidden articles that were expunged for low scores."
12149 (gnus-set-global-variables)
12150 (let ((buffer-read-only nil))
12151 (let ((scored gnus-newsgroup-scored)
12154 (or (gnus-summary-goto-subject (caar scored))
12155 (and (setq h (gnus-summary-article-header (caar scored)))
12156 (< (cdar scored) gnus-summary-expunge-below)
12157 (setq headers (cons h headers))))
12158 (setq scored (cdr scored)))
12159 (or headers (error "No expunged articles hidden."))
12160 (goto-char (point-min))
12161 (gnus-summary-prepare-unthreaded (nreverse headers)))
12162 (goto-char (point-min))
12163 (gnus-summary-position-point)))
12165 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12166 "Mark all articles not marked as unread in this newsgroup as read.
12167 If prefix argument ALL is non-nil, all articles are marked as read.
12168 If QUIETLY is non-nil, no questions will be asked.
12169 If TO-HERE is non-nil, it should be a point in the buffer. All
12170 articles before this point will be marked as read.
12171 The number of articles marked as read is returned."
12173 (gnus-set-global-variables)
12176 (not gnus-interactive-catchup) ;Without confirmation?
12180 "Mark absolutely all articles as read? "
12181 "Mark all unread articles as read? ")))
12183 (not gnus-newsgroup-adaptive)
12184 (not gnus-newsgroup-auto-expire))
12187 (setq gnus-newsgroup-marked nil
12188 gnus-newsgroup-dormant nil))
12189 (setq gnus-newsgroup-unreads nil))
12190 ;; We actually mark all articles as canceled, which we
12191 ;; have to do when using auto-expiry or adaptive scoring.
12192 (gnus-summary-show-all-threads)
12193 (if (gnus-summary-first-subject (not all))
12195 (if to-here (< (point) to-here) t)
12196 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12197 (gnus-summary-find-next (not all)))))
12199 (setq gnus-newsgroup-unreads nil))
12200 (gnus-set-mode-line 'summary)))
12201 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12202 (if (and (not to-here) (eq 'nnvirtual (car method)))
12203 (nnvirtual-catchup-group
12204 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12205 (gnus-summary-position-point)))
12207 (defun gnus-summary-catchup-to-here (&optional all)
12208 "Mark all unticked articles before the current one as read.
12209 If ALL is non-nil, also mark ticked and dormant articles as read."
12211 (gnus-set-global-variables)
12213 (let ((beg (point)))
12214 ;; We check that there are unread articles.
12215 (when (or all (gnus-summary-find-prev))
12216 (gnus-summary-catchup all t beg))))
12217 (gnus-summary-position-point))
12219 (defun gnus-summary-catchup-all (&optional quietly)
12220 "Mark all articles in this newsgroup as read."
12222 (gnus-set-global-variables)
12223 (gnus-summary-catchup t quietly))
12225 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12226 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12227 If prefix argument ALL is non-nil, all articles are marked as read."
12229 (gnus-set-global-variables)
12230 (gnus-summary-catchup all quietly nil 'fast)
12231 ;; Select next newsgroup or exit.
12232 (if (eq gnus-auto-select-next 'quietly)
12233 (gnus-summary-next-group nil)
12234 (gnus-summary-exit)))
12236 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12237 "Mark all articles in this newsgroup as read, and then exit."
12239 (gnus-set-global-variables)
12240 (gnus-summary-catchup-and-exit t quietly))
12242 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12243 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12244 "Mark all articles in this group as read and select the next group.
12245 If given a prefix, mark all articles, unread as well as ticked, as
12248 (gnus-set-global-variables)
12250 (gnus-summary-catchup all))
12251 (gnus-summary-next-article t nil nil t))
12253 ;; Thread-based commands.
12255 (defun gnus-summary-articles-in-thread (&optional article)
12256 "Return a list of all articles in the current thread.
12257 If ARTICLE is non-nil, return all articles in the thread that starts
12258 with that article."
12259 (let* ((article (or article (gnus-summary-article-number)))
12260 (data (gnus-data-find-list article))
12261 (top-level (gnus-data-level (car data)))
12263 (cond ((null gnus-thread-operation-ignore-subject)
12264 (gnus-simplify-subject-re
12265 (mail-header-subject (gnus-data-header (car data)))))
12266 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12267 (gnus-simplify-subject-fuzzy
12268 (mail-header-subject (gnus-data-header (car data)))))
12272 () ; This article doesn't exist.
12274 (and (or (not top-subject)
12275 (string= top-subject
12276 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12277 (gnus-simplify-subject-fuzzy
12278 (mail-header-subject
12279 (gnus-data-header (car data))))
12280 (gnus-simplify-subject-re
12281 (mail-header-subject
12282 (gnus-data-header (car data)))))))
12283 (setq articles (cons (gnus-data-number (car data)) articles)))
12284 (if (and (setq data (cdr data))
12285 (> (gnus-data-level (car data)) top-level))
12288 ;; Return the list of articles.
12289 (nreverse articles))))
12291 (defun gnus-summary-rethread-current ()
12292 "Rethread the thread the current article is part of."
12294 (gnus-set-global-variables)
12295 (let* ((gnus-show-threads t)
12296 (article (gnus-summary-article-number))
12297 (id (mail-header-id (gnus-summary-article-header)))
12298 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12300 (error "No article on the current line"))
12301 (gnus-rebuild-thread id)
12302 (gnus-summary-goto-subject article)))
12304 (defun gnus-summary-reparent-thread ()
12305 "Make current article child of the marked (or previous) article.
12307 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12308 is non-nil or the Subject: of both articles are the same."
12310 (or (not (gnus-group-read-only-p))
12311 (error "The current newsgroup does not support article editing."))
12312 (or (<= (length gnus-newsgroup-processable) 1)
12313 (error "No more than one article may be marked."))
12314 (save-window-excursion
12315 (let ((gnus-article-buffer " *reparent*")
12316 (current-article (gnus-summary-article-number))
12317 ; first grab the marked article, otherwise one line up.
12318 (parent-article (if (not (null gnus-newsgroup-processable))
12319 (car gnus-newsgroup-processable)
12321 (if (eq (forward-line -1) 0)
12322 (gnus-summary-article-number)
12323 (error "Beginning of summary buffer."))))))
12324 (or (not (eq current-article parent-article))
12325 (error "An article may not be self-referential."))
12326 (let ((message-id (mail-header-id
12327 (gnus-summary-article-header parent-article))))
12328 (or (and message-id (not (equal message-id "")))
12329 (error "No message-id in desired parent."))
12330 (gnus-summary-select-article t t nil current-article)
12331 (set-buffer gnus-article-buffer)
12332 (setq buffer-read-only nil)
12333 (let ((buf (format "%s" (buffer-string))))
12336 (goto-char (point-min))
12337 (if (search-forward-regexp "^References: " nil t)
12338 (insert message-id " " )
12339 (insert "References: " message-id "\n"))
12340 (or (gnus-request-replace-article current-article
12341 (car gnus-article-current)
12342 gnus-article-buffer)
12343 (error "Couldn't replace article."))
12344 (set-buffer gnus-summary-buffer)
12345 (gnus-summary-unmark-all-processable)
12346 (gnus-summary-rethread-current)
12347 (message "Article %d is now the child of article %d."
12348 current-article parent-article)))))
12350 (defun gnus-summary-toggle-threads (&optional arg)
12351 "Toggle showing conversation threads.
12352 If ARG is positive number, turn showing conversation threads on."
12354 (gnus-set-global-variables)
12355 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12356 (setq gnus-show-threads
12357 (if (null arg) (not gnus-show-threads)
12358 (> (prefix-numeric-value arg) 0)))
12359 (gnus-summary-prepare)
12360 (gnus-summary-goto-subject current)
12361 (gnus-summary-position-point)))
12363 (defun gnus-summary-show-all-threads ()
12364 "Show all threads."
12366 (gnus-set-global-variables)
12368 (let ((buffer-read-only nil))
12369 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12370 (gnus-summary-position-point))
12372 (defun gnus-summary-show-thread ()
12373 "Show thread subtrees.
12374 Returns nil if no thread was there to be shown."
12376 (gnus-set-global-variables)
12377 (let ((buffer-read-only nil)
12379 ;; first goto end then to beg, to have point at beg after let
12380 (end (progn (end-of-line) (point)))
12381 (beg (progn (beginning-of-line) (point))))
12383 ;; Any hidden lines here?
12384 (search-forward "\r" end t)
12385 (subst-char-in-region beg end ?\^M ?\n t)
12387 (gnus-summary-position-point))))
12389 (defun gnus-summary-hide-all-threads ()
12390 "Hide all thread subtrees."
12392 (gnus-set-global-variables)
12394 (goto-char (point-min))
12395 (gnus-summary-hide-thread)
12396 (while (zerop (gnus-summary-next-thread 1 t))
12397 (gnus-summary-hide-thread)))
12398 (gnus-summary-position-point))
12400 (defun gnus-summary-hide-thread ()
12401 "Hide thread subtrees.
12402 Returns nil if no threads were there to be hidden."
12404 (gnus-set-global-variables)
12405 (let ((buffer-read-only nil)
12407 (article (gnus-summary-article-number)))
12409 ;; Go forward until either the buffer ends or the subthread
12411 (when (and (not (eobp))
12412 (or (zerop (gnus-summary-next-thread 1 t))
12413 (goto-char (point-max))))
12415 (if (and (> (point) start)
12416 (search-backward "\n" start t))
12418 (subst-char-in-region start (point) ?\n ?\^M)
12419 (gnus-summary-goto-subject article))
12422 ;;(gnus-summary-position-point)
12425 (defun gnus-summary-go-to-next-thread (&optional previous)
12426 "Go to the same level (or less) next thread.
12427 If PREVIOUS is non-nil, go to previous thread instead.
12428 Return the article number moved to, or nil if moving was impossible."
12429 (let ((level (gnus-summary-thread-level))
12430 (way (if previous -1 1))
12433 (while (and (not (eobp))
12434 (< level (gnus-summary-thread-level)))
12435 (forward-line way))
12442 (gnus-summary-article-number)
12443 (goto-char beg)))))
12445 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12446 "Go to the same level (or less) next thread.
12447 If PREVIOUS is non-nil, go to previous thread instead.
12448 Return the article number moved to, or nil if moving was impossible."
12449 (if (and (eq gnus-summary-make-false-root 'dummy)
12450 (gnus-summary-article-intangible-p))
12451 (let ((beg (point)))
12452 (while (and (zerop (forward-line 1))
12453 (not (gnus-summary-article-intangible-p))
12454 (not (zerop (save-excursion
12455 (gnus-summary-thread-level))))))
12461 (let* ((level (gnus-summary-thread-level))
12462 (article (gnus-summary-article-number))
12463 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12466 (if (<= (gnus-data-level (car data)) level)
12467 (setq oart (gnus-data-number (car data))
12469 (setq data (cdr data))))
12471 (gnus-summary-goto-subject oart)))))
12473 (defun gnus-summary-next-thread (n &optional silent)
12474 "Go to the same level next N'th thread.
12475 If N is negative, search backward instead.
12476 Returns the difference between N and the number of skips actually
12479 If SILENT, don't output messages."
12481 (gnus-set-global-variables)
12482 (let ((backward (< n 0))
12485 (while (and (> n 0)
12486 (gnus-summary-go-to-next-thread backward))
12489 (gnus-summary-position-point))
12490 (when (and (not silent) (/= 0 n))
12491 (gnus-message 7 "No more threads"))
12494 (defun gnus-summary-prev-thread (n)
12495 "Go to the same level previous N'th thread.
12496 Returns the difference between N and the number of skips actually
12499 (gnus-set-global-variables)
12500 (gnus-summary-next-thread (- n)))
12502 (defun gnus-summary-go-down-thread ()
12503 "Go down one level in the current thread."
12504 (let ((children (gnus-summary-article-children)))
12506 (gnus-summary-goto-subject (car children)))))
12508 (defun gnus-summary-go-up-thread ()
12509 "Go up one level in the current thread."
12510 (let ((parent (gnus-summary-article-parent)))
12512 (gnus-summary-goto-subject parent))))
12514 (defun gnus-summary-down-thread (n)
12515 "Go down thread N steps.
12516 If N is negative, go up instead.
12517 Returns the difference between N and how many steps down that were
12520 (gnus-set-global-variables)
12523 (while (and (> n 0)
12524 (if up (gnus-summary-go-up-thread)
12525 (gnus-summary-go-down-thread)))
12527 (gnus-summary-position-point)
12528 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12531 (defun gnus-summary-up-thread (n)
12532 "Go up thread N steps.
12533 If N is negative, go up instead.
12534 Returns the difference between N and how many steps down that were
12537 (gnus-set-global-variables)
12538 (gnus-summary-down-thread (- n)))
12540 (defun gnus-summary-top-thread ()
12541 "Go to the top of the thread."
12543 (gnus-set-global-variables)
12544 (while (gnus-summary-go-up-thread))
12545 (gnus-summary-article-number))
12547 (defun gnus-summary-kill-thread (&optional unmark)
12548 "Mark articles under current thread as read.
12549 If the prefix argument is positive, remove any kinds of marks.
12550 If the prefix argument is negative, tick articles instead."
12552 (gnus-set-global-variables)
12554 (setq unmark (prefix-numeric-value unmark)))
12555 (let ((articles (gnus-summary-articles-in-thread)))
12557 ;; Expand the thread.
12558 (gnus-summary-show-thread)
12559 ;; Mark all the articles.
12561 (gnus-summary-goto-subject (car articles))
12562 (cond ((null unmark)
12563 (gnus-summary-mark-article-as-read gnus-killed-mark))
12565 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12567 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12568 (setq articles (cdr articles))))
12569 ;; Hide killed subtrees.
12571 gnus-thread-hide-killed
12572 (gnus-summary-hide-thread))
12573 ;; If marked as read, go to next unread subject.
12575 ;; Go to next unread subject.
12576 (gnus-summary-next-subject 1 t)))
12577 (gnus-set-mode-line 'summary))
12579 ;; Summary sorting commands
12581 (defun gnus-summary-sort-by-number (&optional reverse)
12582 "Sort summary buffer by article number.
12583 Argument REVERSE means reverse order."
12585 (gnus-summary-sort 'number reverse))
12587 (defun gnus-summary-sort-by-author (&optional reverse)
12588 "Sort summary buffer by author name alphabetically.
12589 If case-fold-search is non-nil, case of letters is ignored.
12590 Argument REVERSE means reverse order."
12592 (gnus-summary-sort 'author reverse))
12594 (defun gnus-summary-sort-by-subject (&optional reverse)
12595 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12596 If case-fold-search is non-nil, case of letters is ignored.
12597 Argument REVERSE means reverse order."
12599 (gnus-summary-sort 'subject reverse))
12601 (defun gnus-summary-sort-by-date (&optional reverse)
12602 "Sort summary buffer by date.
12603 Argument REVERSE means reverse order."
12605 (gnus-summary-sort 'date reverse))
12607 (defun gnus-summary-sort-by-score (&optional reverse)
12608 "Sort summary buffer by score.
12609 Argument REVERSE means reverse order."
12611 (gnus-summary-sort 'score reverse))
12613 (defun gnus-summary-sort (predicate reverse)
12614 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12615 (gnus-set-global-variables)
12616 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12617 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12618 (gnus-thread-sort-functions
12623 (,thread t2 t1)))))
12624 (gnus-article-sort-functions
12629 (,article t2 t1)))))
12631 (gnus-summary-prepare-hook nil))
12632 ;; We do the sorting by regenerating the threads.
12633 (gnus-summary-prepare)
12634 ;; Hide subthreads if needed.
12635 (when (and gnus-show-threads gnus-thread-hide-subtree)
12636 (gnus-summary-hide-all-threads)))
12637 ;; If in async mode, we send some info to the backend.
12638 (when gnus-newsgroup-async
12639 (gnus-request-asynchronous
12640 gnus-newsgroup-name gnus-newsgroup-data)))
12642 (defun gnus-sortable-date (date)
12643 "Make sortable string by string-lessp from DATE.
12644 Timezone package is used."
12645 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12646 (year (aref date 0))
12647 (month (aref date 1))
12648 (day (aref date 2)))
12649 (timezone-make-sortable-date
12651 (timezone-make-time-string
12652 (aref date 3) (aref date 4) (aref date 5)))))
12654 ;; Summary saving commands.
12656 (defun gnus-summary-save-article (&optional n not-saved)
12657 "Save the current article using the default saver function.
12658 If N is a positive number, save the N next articles.
12659 If N is a negative number, save the N previous articles.
12660 If N is nil and any articles have been marked with the process mark,
12661 save those articles instead.
12662 The variable `gnus-default-article-saver' specifies the saver function."
12664 (gnus-set-global-variables)
12665 (let ((articles (gnus-summary-work-articles n))
12666 file header article)
12668 (setq header (gnus-summary-article-header
12669 (setq article (pop articles))))
12670 (if (not (vectorp header))
12671 ;; This is a pseudo-article.
12672 (if (assq 'name header)
12673 (gnus-copy-file (cdr (assq 'name header)))
12674 (gnus-message 1 "Article %d is unsaveable" article))
12675 ;; This is a real article.
12676 (save-window-excursion
12677 (gnus-summary-select-article t nil nil article))
12678 (unless gnus-save-all-headers
12679 ;; Remove headers accoring to `gnus-saved-headers'.
12680 (let ((gnus-visible-headers
12681 (or gnus-saved-headers gnus-visible-headers)))
12682 (gnus-article-hide-headers nil t)))
12683 ;; Remove any X-Gnus lines.
12685 (set-buffer gnus-article-buffer)
12687 (let ((buffer-read-only nil))
12688 (nnheader-narrow-to-headers)
12689 (while (re-search-forward "^X-Gnus" nil t)
12690 (gnus-delete-line)))))
12691 (save-window-excursion
12692 (if (not gnus-default-article-saver)
12693 (error "No default saver is defined.")
12694 (setq file (funcall
12695 gnus-default-article-saver
12697 ((not gnus-prompt-before-saving)
12699 ((eq gnus-prompt-before-saving 'always)
12702 (gnus-summary-remove-process-mark article)
12704 (gnus-summary-set-saved-mark article))))
12705 (gnus-summary-position-point)
12708 (defun gnus-summary-pipe-output (&optional arg)
12709 "Pipe the current article to a subprocess.
12710 If N is a positive number, pipe the N next articles.
12711 If N is a negative number, pipe the N previous articles.
12712 If N is nil and any articles have been marked with the process mark,
12713 pipe those articles instead."
12715 (gnus-set-global-variables)
12716 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12717 (gnus-summary-save-article arg t))
12718 (gnus-configure-windows 'pipe))
12720 (defun gnus-summary-save-article-mail (&optional arg)
12721 "Append the current article to an mail file.
12722 If N is a positive number, save the N next articles.
12723 If N is a negative number, save the N previous articles.
12724 If N is nil and any articles have been marked with the process mark,
12725 save those articles instead."
12727 (gnus-set-global-variables)
12728 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12729 (gnus-summary-save-article arg)))
12731 (defun gnus-summary-save-article-rmail (&optional arg)
12732 "Append the current article to an rmail file.
12733 If N is a positive number, save the N next articles.
12734 If N is a negative number, save the N previous articles.
12735 If N is nil and any articles have been marked with the process mark,
12736 save those articles instead."
12738 (gnus-set-global-variables)
12739 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12740 (gnus-summary-save-article arg)))
12742 (defun gnus-summary-save-article-file (&optional arg)
12743 "Append the current article to a file.
12744 If N is a positive number, save the N next articles.
12745 If N is a negative number, save the N previous articles.
12746 If N is nil and any articles have been marked with the process mark,
12747 save those articles instead."
12749 (gnus-set-global-variables)
12750 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12751 (gnus-summary-save-article arg)))
12753 (defun gnus-summary-save-article-body-file (&optional arg)
12754 "Append the current article body to a file.
12755 If N is a positive number, save the N next articles.
12756 If N is a negative number, save the N previous articles.
12757 If N is nil and any articles have been marked with the process mark,
12758 save those articles instead."
12760 (gnus-set-global-variables)
12761 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12762 (gnus-summary-save-article arg)))
12764 (defun gnus-get-split-value (methods)
12765 "Return a value based on the split METHODS."
12766 (let (split-name method result match)
12769 (set-buffer gnus-original-article-buffer)
12771 (nnheader-narrow-to-headers)
12773 (goto-char (point-min))
12774 (setq method (pop methods))
12775 (setq match (car method))
12778 ;; Regular expression.
12780 (re-search-forward match nil t)
12782 ((gnus-functionp match)
12786 (setq result (funcall match gnus-newsgroup-name))))
12791 (setq result (eval match)))))
12792 (setq split-name (append (cdr method) split-name))
12793 (cond ((stringp result)
12794 (push result split-name))
12796 (setq split-name (append result split-name)))))))))
12799 (defun gnus-read-move-group-name (prompt default articles prefix)
12800 "Read a group name."
12801 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12803 (format "Where do you want to %s %s? "
12805 (if (> (length articles) 1)
12806 (format "these %d articles" (length articles))
12814 (format "(default %s) " default)
12816 gnus-active-hashtb nil nil prefix))
12817 ((= 1 (length split-name))
12818 (completing-read prom gnus-active-hashtb
12819 nil nil (cons (car split-name) 0)))
12822 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12825 (if (or (string= to-newsgroup "")
12826 (string= to-newsgroup prefix))
12827 (setq to-newsgroup (or default "")))
12828 (or (gnus-active to-newsgroup)
12829 (gnus-activate-group to-newsgroup)
12830 (error "No such group: %s" to-newsgroup)))
12833 (defun gnus-read-save-file-name (prompt default-name)
12834 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12836 ;; Let the split methods have their say.
12838 ;; No split name was found.
12841 (concat prompt " (default "
12842 (file-name-nondirectory default-name) ") ")
12843 (file-name-directory default-name)
12845 ;; A single split name was found
12846 ((= 1 (length split-name))
12848 (concat prompt " (default " (car split-name) ") ")
12849 gnus-article-save-directory
12850 (concat gnus-article-save-directory (car split-name))))
12851 ;; A list of splits was found.
12853 (setq split-name (mapcar (lambda (el) (list el))
12854 (nreverse split-name)))
12855 (let ((result (completing-read
12856 (concat prompt " ") split-name nil nil)))
12857 (concat gnus-article-save-directory
12858 (if (string= result "")
12861 ;; If we have read a directory, we append the default file name.
12862 (when (file-directory-p file)
12863 (setq file (concat (file-name-as-directory file)
12864 (file-name-nondirectory default-name))))
12865 ;; Possibly translate some charaters.
12866 (nnheader-translate-file-chars file)))
12868 (defun gnus-article-archive-name (group)
12869 "Return the first instance of an \"Archive-name\" in the current buffer."
12870 (let ((case-fold-search t))
12871 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12872 (match-string 1))))
12874 (defun gnus-summary-save-in-rmail (&optional filename)
12875 "Append this article to Rmail file.
12876 Optional argument FILENAME specifies file name.
12877 Directory to save to is default to `gnus-article-save-directory' which
12878 is initialized from the SAVEDIR environment variable."
12880 (gnus-set-global-variables)
12881 (let ((default-name
12882 (funcall gnus-rmail-save-name gnus-newsgroup-name
12883 gnus-current-headers gnus-newsgroup-last-rmail)))
12885 (cond ((eq filename 'default)
12887 (filename filename)
12888 (t (gnus-read-save-file-name
12889 "Save in rmail file:" default-name))))
12890 (gnus-make-directory (file-name-directory filename))
12891 (gnus-eval-in-buffer-window
12892 gnus-original-article-buffer
12896 (gnus-output-to-rmail filename))))
12897 ;; Remember the directory name to save articles
12898 (setq gnus-newsgroup-last-rmail filename)))
12900 (defun gnus-summary-save-in-mail (&optional filename)
12901 "Append this article to Unix mail file.
12902 Optional argument FILENAME specifies file name.
12903 Directory to save to is default to `gnus-article-save-directory' which
12904 is initialized from the SAVEDIR environment variable."
12906 (gnus-set-global-variables)
12907 (let ((default-name
12908 (funcall gnus-mail-save-name gnus-newsgroup-name
12909 gnus-current-headers gnus-newsgroup-last-mail)))
12911 (cond ((eq filename 'default)
12913 (filename filename)
12914 (t (gnus-read-save-file-name
12915 "Save in Unix mail file:" default-name))))
12917 (expand-file-name filename
12919 (file-name-directory default-name))))
12920 (gnus-make-directory (file-name-directory filename))
12921 (gnus-eval-in-buffer-window
12922 gnus-original-article-buffer
12926 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12927 (gnus-output-to-rmail filename)
12928 (let ((mail-use-rfc822 t))
12929 (rmail-output filename 1 t t))))))
12930 ;; Remember the directory name to save articles.
12931 (setq gnus-newsgroup-last-mail filename)))
12933 (defun gnus-summary-save-in-file (&optional filename)
12934 "Append this article to file.
12935 Optional argument FILENAME specifies file name.
12936 Directory to save to is default to `gnus-article-save-directory' which
12937 is initialized from the SAVEDIR environment variable."
12939 (gnus-set-global-variables)
12940 (let ((default-name
12941 (funcall gnus-file-save-name gnus-newsgroup-name
12942 gnus-current-headers gnus-newsgroup-last-file)))
12944 (cond ((eq filename 'default)
12946 (filename filename)
12947 (t (gnus-read-save-file-name
12948 "Save in file:" default-name))))
12949 (gnus-make-directory (file-name-directory filename))
12950 (gnus-eval-in-buffer-window
12951 gnus-original-article-buffer
12955 (gnus-output-to-file filename))))
12956 ;; Remember the directory name to save articles.
12957 (setq gnus-newsgroup-last-file filename)))
12959 (defun gnus-summary-save-body-in-file (&optional filename)
12960 "Append this article body to a file.
12961 Optional argument FILENAME specifies file name.
12962 The directory to save in defaults to `gnus-article-save-directory' which
12963 is initialized from the SAVEDIR environment variable."
12965 (gnus-set-global-variables)
12966 (let ((default-name
12967 (funcall gnus-file-save-name gnus-newsgroup-name
12968 gnus-current-headers gnus-newsgroup-last-file)))
12970 (cond ((eq filename 'default)
12972 (filename filename)
12973 (t (gnus-read-save-file-name
12974 "Save body in file:" default-name))))
12975 (gnus-make-directory (file-name-directory filename))
12976 (gnus-eval-in-buffer-window
12977 gnus-article-buffer
12981 (goto-char (point-min))
12982 (and (search-forward "\n\n" nil t)
12983 (narrow-to-region (point) (point-max)))
12984 (gnus-output-to-file filename))))
12985 ;; Remember the directory name to save articles.
12986 (setq gnus-newsgroup-last-file filename)))
12988 (defun gnus-summary-save-in-pipe (&optional command)
12989 "Pipe this article to subprocess."
12991 (gnus-set-global-variables)
12993 (cond ((eq command 'default)
12994 gnus-last-shell-command)
12996 (t (read-string "Shell command on article: "
12997 gnus-last-shell-command))))
12998 (if (string-equal command "")
12999 (setq command gnus-last-shell-command))
13000 (gnus-eval-in-buffer-window
13001 gnus-article-buffer
13004 (shell-command-on-region (point-min) (point-max) command nil)))
13005 (setq gnus-last-shell-command command))
13007 ;; Summary extract commands
13009 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13010 (let ((buffer-read-only nil)
13011 (article (gnus-summary-article-number))
13013 (or (gnus-summary-goto-subject article)
13014 (error (format "No such article: %d" article)))
13015 (gnus-summary-position-point)
13016 ;; If all commands are to be bunched up on one line, we collect
13018 (if gnus-view-pseudos-separately
13020 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13023 (setq action (cdr (assq 'action (car ps))))
13024 (setq files (list (cdr (assq 'name (car ps)))))
13025 (while (and ps (cdr ps)
13026 (string= (or action "1")
13027 (or (cdr (assq 'action (cadr ps))) "2")))
13028 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13029 (setcdr ps (cddr ps)))
13032 (if (not (string-match "%s" action))
13033 (setq files (cons " " files)))
13034 (setq files (cons " " files))
13035 (and (assq 'execute (car ps))
13036 (setcdr (assq 'execute (car ps))
13037 (funcall (if (string-match "%s" action)
13040 (mapconcat (lambda (f) f) files " ")))))
13041 (setq ps (cdr ps)))))
13042 (if (and gnus-view-pseudos (not not-view))
13044 (and (assq 'execute (car pslist))
13045 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13046 (eq gnus-view-pseudos 'not-confirm)))
13047 (setq pslist (cdr pslist)))
13050 (setq after-article (or (cdr (assq 'article (car pslist)))
13051 (gnus-summary-article-number)))
13052 (gnus-summary-goto-subject after-article)
13055 (insert " " (file-name-nondirectory
13056 (cdr (assq 'name (car pslist))))
13057 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13059 (forward-line -1) ; back to `b'
13060 (add-text-properties
13061 b e (list 'gnus-number gnus-reffed-article-number
13062 gnus-mouse-face-prop gnus-mouse-face))
13064 after-article gnus-reffed-article-number
13065 gnus-unread-mark b (car pslist) 0 (- e b))
13066 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13067 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13068 (setq pslist (cdr pslist)))))))
13070 (defun gnus-pseudos< (p1 p2)
13071 (let ((c1 (cdr (assq 'action p1)))
13072 (c2 (cdr (assq 'action p2))))
13073 (and c1 c2 (string< c1 c2))))
13075 (defun gnus-request-pseudo-article (props)
13076 (cond ((assq 'execute props)
13077 (gnus-execute-command (cdr (assq 'execute props)))))
13078 (let ((gnus-current-article (gnus-summary-article-number)))
13079 (run-hooks 'gnus-mark-article-hook)))
13081 (defun gnus-execute-command (command &optional automatic)
13083 (gnus-article-setup-buffer)
13084 (set-buffer gnus-article-buffer)
13085 (let ((command (if automatic command (read-string "Command: " command)))
13086 (buffer-read-only nil))
13088 (insert "$ " command "\n\n")
13089 (if gnus-view-pseudo-asynchronously
13090 (start-process "gnus-execute" nil "sh" "-c" command)
13091 (call-process "sh" nil t nil "-c" command)))))
13093 (defun gnus-copy-file (file &optional to)
13096 (list (read-file-name "Copy file: " default-directory)
13097 (read-file-name "Copy file to: " default-directory)))
13098 (gnus-set-global-variables)
13099 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13100 (and (file-directory-p to)
13101 (setq to (concat (file-name-as-directory to)
13102 (file-name-nondirectory file))))
13103 (copy-file file to))
13105 ;; Summary kill commands.
13107 (defun gnus-summary-edit-global-kill (article)
13108 "Edit the \"global\" kill file."
13109 (interactive (list (gnus-summary-article-number)))
13110 (gnus-set-global-variables)
13111 (gnus-group-edit-global-kill article))
13113 (defun gnus-summary-edit-local-kill ()
13114 "Edit a local kill file applied to the current newsgroup."
13116 (gnus-set-global-variables)
13117 (setq gnus-current-headers (gnus-summary-article-header))
13118 (gnus-set-global-variables)
13119 (gnus-group-edit-local-kill
13120 (gnus-summary-article-number) gnus-newsgroup-name))
13124 ;;; Gnus article mode
13127 (put 'gnus-article-mode 'mode-class 'special)
13129 (if gnus-article-mode-map
13131 (setq gnus-article-mode-map (make-keymap))
13132 (suppress-keymap gnus-article-mode-map)
13134 (gnus-define-keys gnus-article-mode-map
13135 " " gnus-article-goto-next-page
13136 "\177" gnus-article-goto-prev-page
13137 [delete] gnus-article-goto-prev-page
13138 "\C-c^" gnus-article-refer-article
13139 "h" gnus-article-show-summary
13140 "s" gnus-article-show-summary
13141 "\C-c\C-m" gnus-article-mail
13142 "?" gnus-article-describe-briefly
13143 gnus-mouse-2 gnus-article-push-button
13144 "\r" gnus-article-press-button
13145 "\t" gnus-article-next-button
13146 "\M-\t" gnus-article-prev-button
13147 "\C-c\C-b" gnus-bug)
13149 (substitute-key-definition
13150 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13152 (defun gnus-article-mode ()
13153 "Major mode for displaying an article.
13155 All normal editing commands are switched off.
13157 The following commands are available:
13159 \\<gnus-article-mode-map>
13160 \\[gnus-article-next-page]\t Scroll the article one page forwards
13161 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13162 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13163 \\[gnus-article-show-summary]\t Display the summary buffer
13164 \\[gnus-article-mail]\t Send a reply to the address near point
13165 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13166 \\[gnus-info-find-node]\t Go to the Gnus info node"
13168 (when (and menu-bar-mode
13169 (gnus-visual-p 'article-menu 'menu))
13170 (gnus-article-make-menu-bar))
13171 (kill-all-local-variables)
13172 (gnus-simplify-mode-line)
13173 (setq mode-name "Article")
13174 (setq major-mode 'gnus-article-mode)
13175 (make-local-variable 'minor-mode-alist)
13176 (or (assq 'gnus-show-mime minor-mode-alist)
13177 (setq minor-mode-alist
13178 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13179 (use-local-map gnus-article-mode-map)
13180 (make-local-variable 'page-delimiter)
13181 (setq page-delimiter gnus-page-delimiter)
13182 (buffer-disable-undo (current-buffer))
13183 (setq buffer-read-only t) ;Disable modification
13184 (run-hooks 'gnus-article-mode-hook))
13186 (defun gnus-article-setup-buffer ()
13187 "Initialize the article buffer."
13188 (let* ((name (if gnus-single-article-buffer "*Article*"
13189 (concat "*Article " gnus-newsgroup-name "*")))
13191 (progn (string-match "\\*Article" name)
13192 (concat " *Original Article"
13193 (substring name (match-end 0))))))
13194 (setq gnus-article-buffer name)
13195 (setq gnus-original-article-buffer original)
13196 ;; This might be a variable local to the summary buffer.
13197 (unless gnus-single-article-buffer
13199 (set-buffer gnus-summary-buffer)
13200 (setq gnus-article-buffer name)
13201 (setq gnus-original-article-buffer original)
13202 (gnus-set-global-variables))
13203 (make-local-variable 'gnus-summary-buffer))
13204 ;; Init original article buffer.
13206 (set-buffer (get-buffer-create gnus-original-article-buffer))
13207 (buffer-disable-undo (current-buffer))
13208 (setq major-mode 'gnus-original-article-mode)
13209 (make-local-variable 'gnus-original-article))
13210 (if (get-buffer name)
13213 (buffer-disable-undo (current-buffer))
13214 (setq buffer-read-only t)
13215 (gnus-add-current-to-buffer-list)
13216 (or (eq major-mode 'gnus-article-mode)
13217 (gnus-article-mode))
13220 (set-buffer (get-buffer-create name))
13221 (gnus-add-current-to-buffer-list)
13222 (gnus-article-mode)
13223 (current-buffer)))))
13225 ;; Set article window start at LINE, where LINE is the number of lines
13226 ;; from the head of the article.
13227 (defun gnus-article-set-window-start (&optional line)
13229 (get-buffer-window gnus-article-buffer)
13231 (set-buffer gnus-article-buffer)
13232 (goto-char (point-min))
13235 (gnus-message 6 "Moved to bookmark")
13236 (search-forward "\n\n" nil t)
13237 (forward-line line)
13240 (defun gnus-kill-all-overlays ()
13241 "Delete all overlays in the current buffer."
13242 (when (fboundp 'overlay-lists)
13243 (let* ((overlayss (overlay-lists))
13244 (buffer-read-only nil)
13245 (overlays (nconc (car overlayss) (cdr overlayss))))
13247 (delete-overlay (pop overlays))))))
13249 (defun gnus-request-article-this-buffer (article group)
13250 "Get an article and insert it into this buffer."
13251 (let (do-update-line)
13255 (gnus-kill-all-overlays)
13256 (setq group (or group gnus-newsgroup-name))
13258 ;; Open server if it has closed.
13259 (gnus-check-server (gnus-find-method-for-group group))
13261 ;; Using `gnus-request-article' directly will insert the article into
13262 ;; `nntp-server-buffer' - so we'll save some time by not having to
13263 ;; copy it from the server buffer into the article buffer.
13265 ;; We only request an article by message-id when we do not have the
13266 ;; headers for it, so we'll have to get those.
13267 (when (stringp article)
13268 (let ((gnus-override-method gnus-refer-article-method))
13269 (gnus-read-header article)))
13271 ;; If the article number is negative, that means that this article
13272 ;; doesn't belong in this newsgroup (possibly), so we find its
13273 ;; message-id and request it by id instead of number.
13274 (when (and (numberp article)
13275 gnus-summary-buffer
13276 (get-buffer gnus-summary-buffer)
13277 (buffer-name (get-buffer gnus-summary-buffer)))
13279 (set-buffer gnus-summary-buffer)
13280 (let ((header (gnus-summary-article-header article)))
13283 ((memq article gnus-newsgroup-sparse)
13284 ;; This is a sparse gap article.
13285 (setq do-update-line article)
13286 (setq article (mail-header-id header))
13287 (let ((gnus-override-method gnus-refer-article-method))
13288 (gnus-read-header article)))
13290 ;; It's a real article.
13291 (setq article (mail-header-id header)))
13293 ;; It is an extracted pseudo-article.
13294 (setq article 'pseudo)
13295 (gnus-request-pseudo-article header))))
13297 (let ((method (gnus-find-method-for-group
13298 gnus-newsgroup-name)))
13299 (if (not (eq (car method) 'nneething))
13301 (let ((dir (concat (file-name-as-directory (nth 1 method))
13302 (mail-header-subject header))))
13303 (if (file-directory-p dir)
13305 (setq article 'nneething)
13306 (gnus-group-enter-directory dir)))))))))
13309 ;; We first check `gnus-original-article-buffer'.
13310 ((and (get-buffer gnus-original-article-buffer)
13312 (set-buffer gnus-original-article-buffer)
13313 (and (equal (car gnus-original-article) group)
13314 (eq (cdr gnus-original-article) article))))
13315 (insert-buffer-substring gnus-original-article-buffer)
13317 ;; Check the backlog.
13318 ((and gnus-keep-backlog
13319 (gnus-backlog-request-article group article (current-buffer)))
13321 ;; Check the cache.
13322 ((and gnus-use-cache
13324 (gnus-cache-request-article article group))
13326 ;; Get the article and put into the article buffer.
13327 ((or (stringp article) (numberp article))
13328 (let ((gnus-override-method
13329 (and (stringp article) gnus-refer-article-method))
13330 (buffer-read-only nil))
13332 (gnus-kill-all-overlays)
13333 (if (gnus-request-article article group (current-buffer))
13335 (and gnus-keep-backlog
13336 (gnus-backlog-enter-article
13337 group article (current-buffer)))
13339 ;; It was a pseudo.
13342 ;; Take the article from the original article buffer
13343 ;; and place it in the buffer it's supposed to be in.
13344 (when (and (get-buffer gnus-article-buffer)
13345 (equal (buffer-name (current-buffer))
13346 (buffer-name (get-buffer gnus-article-buffer))))
13348 (if (get-buffer gnus-original-article-buffer)
13349 (set-buffer (get-buffer gnus-original-article-buffer))
13350 (set-buffer (get-buffer-create gnus-original-article-buffer))
13351 (buffer-disable-undo (current-buffer))
13352 (setq major-mode 'gnus-original-article-mode)
13353 (setq buffer-read-only t)
13354 (gnus-add-current-to-buffer-list))
13355 (let (buffer-read-only)
13357 (insert-buffer-substring gnus-article-buffer))
13358 (setq gnus-original-article (cons group article))))
13360 ;; Update sparse articles.
13361 (when do-update-line
13363 (set-buffer gnus-summary-buffer)
13364 (gnus-summary-update-article do-update-line)
13365 (gnus-summary-goto-subject do-update-line)
13366 (set-window-point (get-buffer-window (current-buffer) t)
13369 (defun gnus-read-header (id &optional header)
13370 "Read the headers of article ID and enter them into the Gnus system."
13371 (let ((group gnus-newsgroup-name)
13373 ;; First we check to see whether the header in question is already
13376 ;; This is a Message-ID.
13377 (setq header (or header (gnus-id-to-header id)))
13378 ;; This is an article number.
13379 (setq header (or header (gnus-summary-article-header id))))
13381 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13382 ;; We have found the header.
13384 ;; We have to really fetch the header to this article.
13386 (if (gnus-check-backend-function 'request-head group)
13387 (gnus-request-head id group)
13388 (gnus-request-article id group)))
13390 (set-buffer nntp-server-buffer)
13391 (and (search-forward "\n\n" nil t)
13392 (delete-region (1- (point)) (point-max)))
13393 (goto-char (point-max))
13395 (goto-char (point-min))
13399 ((cdr where) (cdr where))
13400 (header (mail-header-number header))
13401 (t gnus-reffed-article-number))
13403 (insert " Article retrieved.\n"))
13405 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13406 ; (setcar (gnus-id-to-thread id) nil))
13407 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13408 () ; Malformed head.
13409 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13410 (if (and (stringp id)
13411 (not (string= (gnus-group-real-name group)
13413 ;; If we fetched by Message-ID and the article came
13414 ;; from a different group, we fudge some bogus article
13415 ;; numbers for this article.
13416 (mail-header-set-number header gnus-reffed-article-number))
13417 (decf gnus-reffed-article-number)
13418 (push header gnus-newsgroup-headers)
13419 (setq gnus-current-headers header)
13420 (push (mail-header-number header) gnus-newsgroup-limit))
13423 (defun gnus-article-prepare (article &optional all-headers header)
13424 "Prepare ARTICLE in article mode buffer.
13425 ARTICLE should either be an article number or a Message-ID.
13426 If ARTICLE is an id, HEADER should be the article headers.
13427 If ALL-HEADERS is non-nil, no headers are hidden."
13429 ;; Make sure we start in a summary buffer.
13430 (unless (eq major-mode 'gnus-summary-mode)
13431 (set-buffer gnus-summary-buffer))
13432 (setq gnus-summary-buffer (current-buffer))
13433 ;; Make sure the connection to the server is alive.
13434 (unless (gnus-server-opened
13435 (gnus-find-method-for-group gnus-newsgroup-name))
13436 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13437 (gnus-request-group gnus-newsgroup-name t))
13438 (let* ((article (if header (mail-header-number header) article))
13439 (summary-buffer (current-buffer))
13440 (internal-hook gnus-article-internal-prepare-hook)
13441 (group gnus-newsgroup-name)
13444 (gnus-article-setup-buffer)
13445 (set-buffer gnus-article-buffer)
13446 ;; Deactivate active regions.
13447 (when (and (boundp 'transient-mark-mode)
13448 transient-mark-mode)
13449 (setq mark-active nil))
13450 (if (not (setq result (let ((buffer-read-only nil))
13451 (gnus-request-article-this-buffer
13453 ;; There is no such article.
13455 (when (and (numberp article)
13456 (not (memq article gnus-newsgroup-sparse)))
13457 (setq gnus-article-current
13458 (cons gnus-newsgroup-name article))
13459 (set-buffer gnus-summary-buffer)
13460 (setq gnus-current-article article)
13461 (gnus-summary-mark-article article gnus-canceled-mark))
13462 (unless (memq article gnus-newsgroup-sparse)
13464 1 "No such article (may have expired or been canceled)")
13467 (if (or (eq result 'pseudo) (eq result 'nneething))
13470 (set-buffer summary-buffer)
13471 (setq gnus-last-article gnus-current-article
13472 gnus-newsgroup-history (cons gnus-current-article
13473 gnus-newsgroup-history)
13474 gnus-current-article 0
13475 gnus-current-headers nil
13476 gnus-article-current nil)
13477 (if (eq result 'nneething)
13478 (gnus-configure-windows 'summary)
13479 (gnus-configure-windows 'article))
13480 (gnus-set-global-variables))
13481 (gnus-set-mode-line 'article))
13482 ;; The result from the `request' was an actual article -
13483 ;; or at least some text that is now displayed in the
13485 (if (and (numberp article)
13486 (not (eq article gnus-current-article)))
13487 ;; Seems like a new article has been selected.
13488 ;; `gnus-current-article' must be an article number.
13490 (set-buffer summary-buffer)
13491 (setq gnus-last-article gnus-current-article
13492 gnus-newsgroup-history (cons gnus-current-article
13493 gnus-newsgroup-history)
13494 gnus-current-article article
13495 gnus-current-headers
13496 (gnus-summary-article-header gnus-current-article)
13497 gnus-article-current
13498 (cons gnus-newsgroup-name gnus-current-article))
13499 (unless (vectorp gnus-current-headers)
13500 (setq gnus-current-headers nil))
13501 (gnus-summary-show-thread)
13502 (run-hooks 'gnus-mark-article-hook)
13503 (gnus-set-mode-line 'summary)
13504 (and (gnus-visual-p 'article-highlight 'highlight)
13505 (run-hooks 'gnus-visual-mark-article-hook))
13506 ;; Set the global newsgroup variables here.
13507 ;; Suggested by Jim Sisolak
13508 ;; <sisolak@trans4.neep.wisc.edu>.
13509 (gnus-set-global-variables)
13510 (setq gnus-have-all-headers
13511 (or all-headers gnus-show-all-headers))
13512 (and gnus-use-cache
13513 (vectorp (gnus-summary-article-header article))
13514 (gnus-cache-possibly-enter-article
13516 (gnus-summary-article-header article)
13517 (memq article gnus-newsgroup-marked)
13518 (memq article gnus-newsgroup-dormant)
13519 (memq article gnus-newsgroup-unreads)))))
13520 ;; Hooks for getting information from the article.
13521 ;; This hook must be called before being narrowed.
13522 (let (buffer-read-only)
13523 (run-hooks 'internal-hook)
13524 (run-hooks 'gnus-article-prepare-hook)
13525 ;; Decode MIME message.
13527 (if (or (not gnus-strict-mime)
13528 (gnus-fetch-field "Mime-Version"))
13529 (funcall gnus-show-mime-method)
13530 (funcall gnus-decode-encoded-word-method)))
13531 ;; Perform the article display hooks.
13532 (run-hooks 'gnus-article-display-hook))
13534 (goto-char (point-min))
13535 (and gnus-break-pages (gnus-narrow-to-page))
13536 (gnus-set-mode-line 'article)
13537 (gnus-configure-windows 'article)
13538 (goto-char (point-min))
13541 (defun gnus-article-show-all-headers ()
13542 "Show all article headers in article mode buffer."
13544 (gnus-article-setup-buffer)
13545 (set-buffer gnus-article-buffer)
13546 (let ((buffer-read-only nil))
13547 (gnus-unhide-text (point-min) (point-max)))))
13549 (defun gnus-article-hide-headers-if-wanted ()
13550 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13551 Provided for backwards compatibility."
13552 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13553 gnus-inhibit-hiding
13554 (gnus-article-hide-headers)))
13556 (defun gnus-article-hide-headers (&optional arg delete)
13557 "Toggle whether to hide unwanted headers and possibly sort them as well.
13558 If given a negative prefix, always show; if given a positive prefix,
13561 (unless (gnus-article-check-hidden-text 'headers arg)
13562 ;; This function might be inhibited.
13563 (unless gnus-inhibit-hiding
13565 (set-buffer gnus-article-buffer)
13567 (let ((buffer-read-only nil)
13568 (props (nconc (list 'gnus-type 'headers)
13569 gnus-hidden-properties))
13570 (ignored (when (not (stringp gnus-visible-headers))
13571 (cond ((stringp gnus-ignored-headers)
13572 gnus-ignored-headers)
13573 ((listp gnus-ignored-headers)
13574 (mapconcat 'identity gnus-ignored-headers
13577 (cond ((stringp gnus-visible-headers)
13578 gnus-visible-headers)
13579 ((and gnus-visible-headers
13580 (listp gnus-visible-headers))
13581 (mapconcat 'identity gnus-visible-headers "\\|"))))
13583 ;; First we narrow to just the headers.
13585 (goto-char (point-min))
13586 ;; Hide any "From " lines at the beginning of (mail) articles.
13587 (while (looking-at "From ")
13590 (gnus-hide-text (point-min) (point) props))
13591 ;; Then treat the rest of the header lines.
13594 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13595 ;; Then we use the two regular expressions
13596 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13597 ;; select which header lines is to remain visible in the
13599 (goto-char (point-min))
13600 (while (re-search-forward "^[^ \t]*:" nil t)
13601 (beginning-of-line)
13602 ;; We add the headers we want to keep to a list and delete
13603 ;; them from the buffer.
13604 (if (or (and visible (looking-at visible))
13605 (and ignored (not (looking-at ignored))))
13607 (push (buffer-substring
13611 ;; Be sure to get multi-line headers...
13612 (re-search-forward "^[^ \t]*:" nil t)
13613 (beginning-of-line)
13616 (delete-region beg (point)))
13618 ;; Sort the headers that we want to display.
13619 (setq want-list (sort want-list 'gnus-article-header-less))
13620 (goto-char (point-min))
13622 (insert (pop want-list)))
13623 ;; We make the unwanted headers invisible.
13625 (delete-region (point-min) (point-max))
13626 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13627 (gnus-hide-text-type (point) (point-max) 'headers))))))))
13629 (defsubst gnus-article-header-rank (header)
13630 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13631 (let ((list gnus-sorted-header-list)
13634 (when (string-match (car list) header)
13636 (setq list (cdr list))
13640 (defun gnus-article-header-less (h1 h2)
13641 "Say whether string H1 is \"less\" than string H2."
13642 (< (gnus-article-header-rank h1)
13643 (gnus-article-header-rank h2)))
13645 (defun gnus-article-hide-boring-headers (&optional arg)
13646 "Toggle hiding of headers that aren't very interesting.
13647 If given a negative prefix, always show; if given a positive prefix,
13650 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13652 (set-buffer gnus-article-buffer)
13654 (let ((buffer-read-only nil)
13655 (list gnus-boring-article-headers)
13656 (inhibit-point-motion-hooks t)
13658 (nnheader-narrow-to-headers)
13660 (setq elem (pop list))
13661 (goto-char (point-min))
13663 ;; Hide empty headers.
13665 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13667 (gnus-hide-text-type
13668 (progn (beginning-of-line) (point))
13671 (if (re-search-forward "^[^ \t]" nil t)
13672 (match-beginning 0)
13675 ;; Hide boring Newsgroups header.
13676 ((eq elem 'newsgroups)
13677 (when (equal (mail-fetch-field "newsgroups")
13678 (gnus-group-real-name gnus-newsgroup-name))
13679 (gnus-article-hide-header "newsgroups")))
13680 ((eq elem 'followup-to)
13681 (when (equal (mail-fetch-field "followup-to")
13682 (mail-fetch-field "newsgroups"))
13683 (gnus-article-hide-header "followup-to")))
13684 ((eq elem 'reply-to)
13685 (let ((from (mail-fetch-field "from"))
13686 (reply-to (mail-fetch-field "reply-to")))
13690 (nth 1 (funcall gnus-extract-address-components from))
13691 (nth 1 (funcall gnus-extract-address-components
13693 (gnus-article-hide-header "reply-to"))))
13695 (let ((date (mail-fetch-field "date")))
13697 (< (gnus-days-between date (current-time-string))
13699 (gnus-article-hide-header "date")))))))))))
13701 (defun gnus-article-hide-header (header)
13703 (goto-char (point-min))
13704 (when (re-search-forward (concat "^" header ":") nil t)
13705 (gnus-hide-text-type
13706 (progn (beginning-of-line) (point))
13709 (if (re-search-forward "^[^ \t]" nil t)
13710 (match-beginning 0)
13712 'boring-headers))))
13714 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13715 (defun gnus-article-treat-overstrike ()
13716 "Translate overstrikes into bold text."
13719 (set-buffer gnus-article-buffer)
13720 (let ((buffer-read-only nil))
13721 (while (search-forward "\b" nil t)
13722 (let ((next (following-char))
13723 (previous (char-after (- (point) 2))))
13724 (cond ((eq next previous)
13725 (put-text-property (- (point) 2) (point) 'invisible t)
13726 (put-text-property (point) (1+ (point)) 'face 'bold))
13728 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13730 (- (point) 2) (1- (point)) 'face 'underline))
13732 (put-text-property (- (point) 2) (point) 'invisible t)
13734 (point) (1+ (point)) 'face 'underline))))))))
13736 (defun gnus-article-word-wrap ()
13737 "Format too long lines."
13740 (set-buffer gnus-article-buffer)
13741 (let ((buffer-read-only nil))
13743 (goto-char (point-min))
13744 (search-forward "\n\n" nil t)
13746 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13747 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13748 (adaptive-fill-mode t))
13749 (while (not (eobp))
13750 (and (>= (current-column) (min fill-column (window-width)))
13751 (/= (preceding-char) ?:)
13752 (fill-paragraph nil))
13753 (end-of-line 2))))))
13755 (defun gnus-article-remove-cr ()
13756 "Remove carriage returns from an article."
13759 (set-buffer gnus-article-buffer)
13760 (let ((buffer-read-only nil))
13761 (goto-char (point-min))
13762 (while (search-forward "\r" nil t)
13763 (replace-match "" t t)))))
13765 (defun gnus-article-remove-trailing-blank-lines ()
13766 "Remove all trailing blank lines from the article."
13769 (set-buffer gnus-article-buffer)
13770 (let ((buffer-read-only nil))
13771 (goto-char (point-max))
13775 (while (looking-at "^[ \t]*$")
13780 (defun gnus-article-display-x-face (&optional force)
13781 "Look for an X-Face header and display it if present."
13782 (interactive (list 'force))
13784 (set-buffer gnus-article-buffer)
13785 ;; Delete the old process, if any.
13786 (when (process-status "gnus-x-face")
13787 (delete-process "gnus-x-face"))
13788 (let ((inhibit-point-motion-hooks t)
13789 (case-fold-search nil)
13792 (nnheader-narrow-to-headers)
13793 (setq from (mail-fetch-field "from"))
13794 (goto-char (point-min))
13795 (when (and gnus-article-x-face-command
13797 ;; Check whether this face is censored.
13798 (not gnus-article-x-face-too-ugly)
13799 (and gnus-article-x-face-too-ugly from
13800 (not (string-match gnus-article-x-face-too-ugly
13802 ;; Has to be present.
13803 (re-search-forward "^X-Face: " nil t))
13804 ;; We now have the area of the buffer where the X-Face is stored.
13805 (let ((beg (point))
13806 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13807 ;; We display the face.
13808 (if (symbolp gnus-article-x-face-command)
13809 ;; The command is a lisp function, so we call it.
13810 (if (gnus-functionp gnus-article-x-face-command)
13811 (funcall gnus-article-x-face-command beg end)
13812 (error "%s is not a function" gnus-article-x-face-command))
13813 ;; The command is a string, so we interpret the command
13814 ;; as a, well, command, and fork it off.
13815 (let ((process-connection-type nil))
13816 (process-kill-without-query
13818 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13819 (process-send-region "gnus-x-face" beg end)
13820 (process-send-eof "gnus-x-face")))))))))
13822 (defun gnus-headers-decode-quoted-printable ()
13823 "Hack to remove QP encoding from headers."
13824 (let ((case-fold-search t)
13825 (inhibit-point-motion-hooks t)
13827 (goto-char (point-min))
13828 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13829 (setq string (match-string 1))
13830 (narrow-to-region (match-beginning 0) (match-end 0))
13831 (delete-region (point-min) (point-max))
13833 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13834 (subst-char-in-region (point-min) (point-max) ?_ ? )
13836 (goto-char (point-min)))))
13838 (defun gnus-article-de-quoted-unreadable (&optional force)
13839 "Do a naive translation of a quoted-printable-encoded article.
13840 This is in no way, shape or form meant as a replacement for real MIME
13841 processing, but is simply a stop-gap measure until MIME support is
13843 If FORCE, decode the article whether it is marked as quoted-printable
13845 (interactive (list 'force))
13847 (set-buffer gnus-article-buffer)
13848 (let ((case-fold-search t)
13849 (buffer-read-only nil)
13850 (type (gnus-fetch-field "content-transfer-encoding")))
13852 (and type (string-match "quoted-printable" type)))
13853 (gnus-headers-decode-quoted-printable)
13854 (goto-char (point-min))
13855 (search-forward "\n\n" nil 'move)
13856 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13858 (defun gnus-mime-decode-quoted-printable (from to)
13859 "Decode Quoted-Printable in the region between FROM and TO."
13861 (while (search-forward "=" to t)
13862 (cond ((eq (following-char) ?\n)
13865 ((looking-at "[0-9A-F][0-9A-F]")
13867 (insert (hexl-hex-string-to-integer
13868 (buffer-substring (point) (+ 2 (point)))))
13872 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13874 (defun gnus-article-hide-pgp (&optional arg)
13875 "Toggle hiding of any PGP headers and signatures in the current article.
13876 If given a negative prefix, always show; if given a positive prefix,
13879 (unless (gnus-article-check-hidden-text 'pgp arg)
13881 (set-buffer gnus-article-buffer)
13882 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13883 buffer-read-only beg end)
13885 (goto-char (point-min))
13886 ;; Hide the "header".
13887 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13888 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13890 ;; Hide the actual signature.
13891 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13892 (setq end (1+ (match-beginning 0)))
13895 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13897 ;; Perhaps we shouldn't hide to the end of the buffer
13898 ;; if there is no end to the signature?
13901 ;; Hide "- " PGP quotation markers.
13902 (when (and beg end)
13903 (narrow-to-region beg end)
13904 (goto-char (point-min))
13905 (while (re-search-forward "^- " nil t)
13906 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13909 (defun gnus-article-hide-signature (&optional arg)
13910 "Hide the signature in the current article.
13911 If given a negative prefix, always show; if given a positive prefix,
13914 (unless (gnus-article-check-hidden-text 'signature arg)
13916 (set-buffer gnus-article-buffer)
13918 (let ((buffer-read-only nil))
13919 (when (gnus-narrow-to-signature)
13920 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
13922 (defun gnus-article-strip-leading-blank-lines ()
13923 "Remove all blank lines from the beginning of the article."
13926 (set-buffer gnus-article-buffer)
13927 (let (buffer-read-only)
13928 (goto-char (point-min))
13929 (when (search-forward "\n\n" nil t)
13930 (while (looking-at "[ \t]$")
13931 (gnus-delete-line))))))
13933 (defun gnus-narrow-to-signature ()
13934 "Narrow to the signature."
13936 (goto-char (point-max))
13937 (when (re-search-backward gnus-signature-separator nil t)
13939 (when (or (null gnus-signature-limit)
13940 (and (numberp gnus-signature-limit)
13941 (< (- (point-max) (point)) gnus-signature-limit))
13942 (and (gnus-functionp gnus-signature-limit)
13943 (funcall gnus-signature-limit))
13944 (and (stringp gnus-signature-limit)
13945 (not (re-search-forward gnus-signature-limit nil t))))
13946 (narrow-to-region (point) (point-max))
13949 (defun gnus-article-check-hidden-text (type arg)
13950 "Return nil if hiding is necessary."
13952 (set-buffer gnus-article-buffer)
13953 (let ((hide (gnus-article-hidden-text-p type)))
13954 (cond ((or (and (null arg) (eq hide 'hidden))
13955 (and arg (< 0 (prefix-numeric-value arg))))
13956 (gnus-article-show-hidden-text type))
13958 (gnus-article-show-hidden-text type t))
13961 (defun gnus-article-hidden-text-p (type)
13962 "Say whether the current buffer contains hidden text of type TYPE."
13963 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
13965 (if (get-text-property pos 'invisible)
13969 (defun gnus-article-hide (&optional arg force)
13970 "Hide all the gruft in the current article.
13971 This means that PGP stuff, signatures, cited text and (some)
13972 headers will be hidden.
13973 If given a prefix, show the hidden text instead."
13974 (interactive (list current-prefix-arg 'force))
13975 (gnus-article-hide-headers arg)
13976 (gnus-article-hide-pgp arg)
13977 (gnus-article-hide-citation-maybe arg force)
13978 (gnus-article-hide-signature arg))
13980 (defun gnus-article-show-hidden-text (type &optional hide)
13981 "Show all hidden text of type TYPE.
13982 If HIDE, hide the text instead."
13984 (set-buffer gnus-article-buffer)
13985 (let ((buffer-read-only nil)
13986 (inhibit-point-motion-hooks t)
13988 (while (gnus-goto-char (text-property-any
13989 beg (point-max) 'gnus-type type))
13993 (gnus-hide-text beg (point) gnus-hidden-properties)
13994 (gnus-unhide-text beg (point)))
13995 (setq beg (point)))
13998 (defvar gnus-article-time-units
13999 `((year . ,(* 365.25 24 60 60))
14000 (week . ,(* 7 24 60 60))
14001 (day . ,(* 24 60 60))
14002 (hour . ,(* 60 60))
14005 "Mapping from time units to seconds.")
14007 (defun gnus-article-date-ut (&optional type highlight)
14008 "Convert DATE date to universal time in the current article.
14009 If TYPE is `local', convert to local time; if it is `lapsed', output
14010 how much time has lapsed since DATE."
14011 (interactive (list 'ut t))
14012 (let* ((header (or gnus-current-headers
14013 (gnus-summary-article-header) ""))
14014 (date (and (vectorp header) (mail-header-date header)))
14015 (date-regexp "^Date: \\|^X-Sent: ")
14016 (now (current-time))
14017 (inhibit-point-motion-hooks t))
14018 (when (and date (not (string= date "")))
14020 (set-buffer gnus-article-buffer)
14022 (nnheader-narrow-to-headers)
14023 (let ((buffer-read-only nil))
14024 ;; Delete any old Date headers.
14025 (if (zerop (message-remove-header date-regexp t))
14026 (beginning-of-line)
14027 (goto-char (point-max)))
14030 ;; Convert to the local timezone. We have to slap a
14031 ;; `condition-case' round the calls to the timezone
14032 ;; functions since they aren't particularly resistant to
14035 (concat "Date: " (condition-case ()
14036 (timezone-make-date-arpa-standard date)
14039 ;; Convert to Universal Time.
14043 (timezone-make-date-arpa-standard date nil "UT")
14046 ;; Get the original date from the article.
14047 ((eq type 'original)
14048 (concat "Date: " date "\n"))
14049 ;; Do an X-Sent lapsed format.
14051 ;; If the date is seriously mangled, the timezone
14052 ;; functions are liable to bug out, so we condition-case
14053 ;; the entire thing.
14058 (timezone-make-date-arpa-standard
14059 (current-time-string now)
14060 (current-time-zone now) "UT"))
14062 (timezone-make-date-arpa-standard
14065 (real-sec (+ (* (float (car real-time)) 65536)
14067 (sec (abs real-sec))
14073 ;; This is a bit convoluted, but basically we go
14074 ;; through the time units for years, weeks, etc,
14075 ;; and divide things to see whether that results
14076 ;; in positive answers.
14079 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14080 ;; The (remaining) seconds are too few to
14081 ;; be divided into this time unit.
14083 ;; It's big enough, so we output it.
14084 (setq sec (- sec (* num (cdr unit))))
14086 (concat (if prev ", " "") (int-to-string
14088 " " (symbol-name (car unit))
14089 (if (> num 1) "s" ""))
14091 gnus-article-time-units "")
14092 ;; If dates are odd, then it might appear like the
14093 ;; article was sent in the future.
14096 " in the future\n")))))
14098 (error "Unknown conversion type: %s" type)))))
14099 ;; Do highlighting.
14100 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
14101 (gnus-article-highlight-headers)))))))
14103 (defun gnus-article-date-local (&optional highlight)
14104 "Convert the current article date to the local timezone."
14105 (interactive (list t))
14106 (gnus-article-date-ut 'local highlight))
14108 (defun gnus-article-date-original (&optional highlight)
14109 "Convert the current article date to what it was originally.
14110 This is only useful if you have used some other date conversion
14111 function and want to see what the date was before converting."
14112 (interactive (list t))
14113 (gnus-article-date-ut 'original highlight))
14115 (defun gnus-article-date-lapsed (&optional highlight)
14116 "Convert the current article date to time lapsed since it was sent."
14117 (interactive (list t))
14118 (gnus-article-date-ut 'lapsed highlight))
14120 (defun gnus-article-maybe-highlight ()
14121 "Do some article highlighting if `gnus-visual' is non-nil."
14122 (if (gnus-visual-p 'article-highlight 'highlight)
14123 (gnus-article-highlight-some)))
14127 (defun gnus-output-to-rmail (file-name)
14128 "Append the current article to an Rmail file named FILE-NAME."
14130 ;; Most of these codes are borrowed from rmailout.el.
14131 (setq file-name (expand-file-name file-name))
14132 (setq rmail-default-rmail-file file-name)
14133 (let ((artbuf (current-buffer))
14134 (tmpbuf (get-buffer-create " *Gnus-output*")))
14136 (or (get-file-buffer file-name)
14137 (file-exists-p file-name)
14138 (if (gnus-yes-or-no-p
14139 (concat "\"" file-name "\" does not exist, create it? "))
14140 (let ((file-buffer (create-file-buffer file-name)))
14142 (set-buffer file-buffer)
14143 (rmail-insert-rmail-file-header)
14144 (let ((require-final-newline nil))
14145 (write-region (point-min) (point-max) file-name t 1)))
14146 (kill-buffer file-buffer))
14147 (error "Output file does not exist")))
14148 (set-buffer tmpbuf)
14149 (buffer-disable-undo (current-buffer))
14151 (insert-buffer-substring artbuf)
14152 (gnus-convert-article-to-rmail)
14153 ;; Decide whether to append to a file or to an Emacs buffer.
14154 (let ((outbuf (get-file-buffer file-name)))
14156 (append-to-file (point-min) (point-max) file-name)
14157 ;; File has been visited, in buffer OUTBUF.
14158 (set-buffer outbuf)
14159 (let ((buffer-read-only nil)
14160 (msg (and (boundp 'rmail-current-message)
14161 (symbol-value 'rmail-current-message))))
14162 ;; If MSG is non-nil, buffer is in RMAIL mode.
14165 (narrow-to-region (point-max) (point-max))))
14166 (insert-buffer-substring tmpbuf)
14169 (goto-char (point-min))
14171 (search-backward "\^_")
14172 (narrow-to-region (point) (point-max))
14173 (goto-char (1+ (point-min)))
14174 (rmail-count-new-messages t)
14175 (rmail-show-message msg)))))))
14176 (kill-buffer tmpbuf)))
14178 (defun gnus-output-to-file (file-name)
14179 "Append the current article to a file named FILE-NAME."
14180 (setq file-name (expand-file-name file-name))
14181 (let ((artbuf (current-buffer))
14182 (tmpbuf (get-buffer-create " *Gnus-output*")))
14184 (set-buffer tmpbuf)
14185 (buffer-disable-undo (current-buffer))
14187 (insert-buffer-substring artbuf)
14188 ;; Append newline at end of the buffer as separator, and then
14189 ;; save it to file.
14190 (goto-char (point-max))
14192 (append-to-file (point-min) (point-max) file-name))
14193 (kill-buffer tmpbuf)))
14195 (defun gnus-convert-article-to-rmail ()
14196 "Convert article in current buffer to Rmail message format."
14197 (let ((buffer-read-only nil))
14198 ;; Convert article directly into Babyl format.
14199 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14200 (goto-char (point-min))
14201 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14202 (while (search-forward "\n\^_" nil t) ;single char
14203 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14204 (goto-char (point-max))
14207 (defun gnus-narrow-to-page (&optional arg)
14208 "Narrow the article buffer to a page.
14209 If given a numerical ARG, move forward ARG pages."
14211 (setq arg (if arg (prefix-numeric-value arg) 0))
14213 (set-buffer gnus-article-buffer)
14214 (goto-char (point-min))
14216 (when (gnus-visual-p 'page-marker)
14217 (let ((buffer-read-only nil))
14218 (gnus-remove-text-with-property 'gnus-prev)
14219 (gnus-remove-text-with-property 'gnus-next)))
14222 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14224 (re-search-forward page-delimiter nil 'move arg)))
14225 (goto-char (match-end 0)))
14228 (if (re-search-forward page-delimiter nil 'move)
14229 (match-beginning 0)
14231 (when (and (gnus-visual-p 'page-marker)
14232 (not (= (point-min) 1)))
14234 (goto-char (point-min))
14235 (gnus-insert-prev-page-button)))
14236 (when (and (gnus-visual-p 'page-marker)
14237 (not (= (1- (point-max)) (buffer-size))))
14239 (goto-char (point-max))
14240 (gnus-insert-next-page-button)))))
14242 ;; Article mode commands
14244 (defun gnus-article-goto-next-page ()
14245 "Show the next page of the article."
14247 (when (gnus-article-next-page)
14248 (gnus-article-read-summary-keys nil ?n)))
14250 (defun gnus-article-goto-prev-page ()
14251 "Show the next page of the article."
14253 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14254 (gnus-article-prev-page nil)))
14256 (defun gnus-article-next-page (&optional lines)
14257 "Show the next page of the current article.
14258 If end of article, return non-nil. Otherwise return nil.
14259 Argument LINES specifies lines to be scrolled up."
14261 (move-to-window-line -1)
14262 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14263 (if (save-excursion
14265 (and (pos-visible-in-window-p) ;Not continuation line.
14267 ;; Nothing in this page.
14268 (if (or (not gnus-break-pages)
14271 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14273 (gnus-narrow-to-page 1) ;Go to next page.
14275 ;; More in this page.
14279 ;; Long lines may cause an end-of-buffer error.
14280 (goto-char (point-max))))
14281 (move-to-window-line 0)
14284 (defun gnus-article-prev-page (&optional lines)
14285 "Show previous page of current article.
14286 Argument LINES specifies lines to be scrolled down."
14288 (move-to-window-line 0)
14289 (if (and gnus-break-pages
14291 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14293 (gnus-narrow-to-page -1) ;Go to previous page.
14294 (goto-char (point-max))
14298 (scroll-down lines)
14300 (move-to-window-line 0))))
14302 (defun gnus-article-refer-article ()
14303 "Read article specified by message-id around point."
14305 (let ((point (point)))
14306 (search-forward ">" nil t) ;Move point to end of "<....>".
14307 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14308 (let ((message-id (match-string 1)))
14310 (set-buffer gnus-summary-buffer)
14311 (gnus-summary-refer-article message-id))
14312 (goto-char (point))
14313 (error "No references around point"))))
14315 (defun gnus-article-show-summary ()
14316 "Reconfigure windows to show summary buffer."
14318 (gnus-configure-windows 'article)
14319 (gnus-summary-goto-subject gnus-current-article))
14321 (defun gnus-article-describe-briefly ()
14322 "Describe article mode commands briefly."
14325 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14327 (defun gnus-article-summary-command ()
14328 "Execute the last keystroke in the summary buffer."
14330 (let ((obuf (current-buffer))
14331 (owin (current-window-configuration))
14333 (switch-to-buffer gnus-summary-buffer 'norecord)
14334 (setq func (lookup-key (current-local-map) (this-command-keys)))
14335 (call-interactively func)
14337 (set-window-configuration owin)
14338 (set-window-point (get-buffer-window (current-buffer)) (point))))
14340 (defun gnus-article-summary-command-nosave ()
14341 "Execute the last keystroke in the summary buffer."
14344 (pop-to-buffer gnus-summary-buffer 'norecord)
14345 (setq func (lookup-key (current-local-map) (this-command-keys)))
14346 (call-interactively func)))
14348 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14349 "Read a summary buffer key sequence and execute it from the article buffer."
14352 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14353 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14357 (set-buffer gnus-summary-buffer)
14358 (push (or key last-command-event) unread-command-events)
14359 (setq keys (read-key-sequence nil)))
14362 (if (member keys nosaves)
14364 (pop-to-buffer gnus-summary-buffer 'norecord)
14365 (if (setq func (lookup-key (current-local-map) keys))
14366 (call-interactively func)
14368 (let ((obuf (current-buffer))
14369 (owin (current-window-configuration))
14372 (if not-restore-window
14373 (pop-to-buffer gnus-summary-buffer 'norecord)
14374 (switch-to-buffer gnus-summary-buffer 'norecord))
14375 (setq in-buffer (current-buffer))
14376 (if (setq func (lookup-key (current-local-map) keys))
14377 (call-interactively func)
14379 (when (eq in-buffer (current-buffer))
14381 (unless not-restore-window
14382 (set-window-configuration owin))
14383 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14387 ;;; Kill file handling.
14391 (defalias 'gnus-batch-kill 'gnus-batch-score)
14393 (defun gnus-batch-score ()
14394 "Run batched scoring.
14395 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14396 Newsgroups is a list of strings in Bnews format. If you want to score
14397 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14398 score the alt hierarchy, you'd say \"!alt.all\"."
14401 (gnus-newsrc-parse-options
14402 (apply (function concat)
14403 (mapcar (lambda (g) (concat g " "))
14404 command-line-args-left))))
14405 (gnus-expert-user t)
14406 (nnmail-spool-file nil)
14407 (gnus-use-dribble-file nil)
14408 (yes (car yes-and-no))
14409 (no (cdr yes-and-no))
14411 ;; Disable verbose message.
14412 gnus-novice-user gnus-large-newsgroup)
14413 ;; Eat all arguments.
14414 (setq command-line-args-left nil)
14417 ;; Apply kills to specified newsgroups in command line arguments.
14418 (setq newsrc (cdr gnus-newsrc-alist))
14420 (setq group (caar newsrc))
14421 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14422 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14424 (or (eq (car entry) t)
14425 (not (zerop (car entry)))))
14426 (if yes (string-match yes group) t)
14427 (or (null no) (not (string-match no group))))
14429 (gnus-summary-read-group group nil t nil t)
14430 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14431 (gnus-summary-exit))))
14432 (setq newsrc (cdr newsrc)))
14434 (switch-to-buffer gnus-group-buffer)
14435 (gnus-group-save-newsrc)))
14437 (defun gnus-apply-kill-file ()
14438 "Apply a kill file to the current newsgroup.
14439 Returns the number of articles marked as read."
14440 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14441 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14442 (gnus-apply-kill-file-internal)
14445 (defun gnus-kill-save-kill-buffer ()
14446 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14447 (when (get-file-buffer file)
14449 (set-buffer (get-file-buffer file))
14450 (and (buffer-modified-p) (save-buffer))
14451 (kill-buffer (current-buffer))))))
14453 (defvar gnus-kill-file-name "KILL"
14454 "Suffix of the kill files.")
14456 (defun gnus-newsgroup-kill-file (newsgroup)
14457 "Return the name of a kill file name for NEWSGROUP.
14458 If NEWSGROUP is nil, return the global kill file name instead."
14460 ;; The global KILL file is placed at top of the directory.
14461 ((or (null newsgroup)
14462 (string-equal newsgroup ""))
14463 (expand-file-name gnus-kill-file-name
14464 (or gnus-kill-files-directory "~/News")))
14465 ;; Append ".KILL" to newsgroup name.
14466 ((gnus-use-long-file-name 'not-kill)
14467 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14468 "." gnus-kill-file-name)
14469 (or gnus-kill-files-directory "~/News")))
14470 ;; Place "KILL" under the hierarchical directory.
14472 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14473 "/" gnus-kill-file-name)
14474 (or gnus-kill-files-directory "~/News")))))
14481 (defvar gnus-dribble-ignore nil)
14482 (defvar gnus-dribble-eval-file nil)
14484 (defun gnus-dribble-file-name ()
14485 "Return the dribble file for the current .newsrc."
14487 (if gnus-dribble-directory
14488 (concat (file-name-as-directory gnus-dribble-directory)
14489 (file-name-nondirectory gnus-current-startup-file))
14490 gnus-current-startup-file)
14493 (defun gnus-dribble-enter (string)
14494 "Enter STRING into the dribble buffer."
14495 (if (and (not gnus-dribble-ignore)
14496 gnus-dribble-buffer
14497 (buffer-name gnus-dribble-buffer))
14498 (let ((obuf (current-buffer)))
14499 (set-buffer gnus-dribble-buffer)
14500 (insert string "\n")
14501 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14502 (set-buffer obuf))))
14504 (defun gnus-dribble-read-file ()
14505 "Read the dribble file from disk."
14506 (let ((dribble-file (gnus-dribble-file-name)))
14508 (set-buffer (setq gnus-dribble-buffer
14510 (file-name-nondirectory dribble-file))))
14511 (gnus-add-current-to-buffer-list)
14513 (setq buffer-file-name dribble-file)
14515 (buffer-disable-undo (current-buffer))
14516 (bury-buffer (current-buffer))
14517 (set-buffer-modified-p nil)
14518 (let ((auto (make-auto-save-file-name))
14519 (gnus-dribble-ignore t))
14520 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14521 ;; Load whichever file is newest -- the auto save file
14522 ;; or the "real" file.
14523 (if (file-newer-than-file-p auto dribble-file)
14524 (insert-file-contents auto)
14525 (insert-file-contents dribble-file))
14526 (unless (zerop (buffer-size))
14527 (set-buffer-modified-p t))
14528 ;; Set the file modes to reflect the .newsrc file modes.
14530 (when (file-exists-p gnus-current-startup-file)
14531 (set-file-modes dribble-file
14532 (file-modes gnus-current-startup-file)))
14533 ;; Possibly eval the file later.
14534 (when (gnus-y-or-n-p
14535 "Auto-save file exists. Do you want to read it? ")
14536 (setq gnus-dribble-eval-file t)))))))
14538 (defun gnus-dribble-eval-file ()
14539 (if (not gnus-dribble-eval-file)
14541 (setq gnus-dribble-eval-file nil)
14543 (let ((gnus-dribble-ignore t))
14544 (set-buffer gnus-dribble-buffer)
14545 (eval-buffer (current-buffer))))))
14547 (defun gnus-dribble-delete-file ()
14548 (if (file-exists-p (gnus-dribble-file-name))
14549 (delete-file (gnus-dribble-file-name)))
14550 (if gnus-dribble-buffer
14552 (set-buffer gnus-dribble-buffer)
14553 (let ((auto (make-auto-save-file-name)))
14554 (if (file-exists-p auto)
14555 (delete-file auto))
14557 (set-buffer-modified-p nil)))))
14559 (defun gnus-dribble-save ()
14560 (if (and gnus-dribble-buffer
14561 (buffer-name gnus-dribble-buffer))
14563 (set-buffer gnus-dribble-buffer)
14566 (defun gnus-dribble-clear ()
14568 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14570 (set-buffer gnus-dribble-buffer)
14572 (set-buffer-modified-p nil)
14573 (setq buffer-saved-size (buffer-size))))))
14577 ;;; Server Communication
14580 (defun gnus-start-news-server (&optional confirm)
14581 "Open a method for getting news.
14582 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14584 (if gnus-current-select-method
14585 ;; Stream is already opened.
14587 ;; Open NNTP server.
14588 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14591 ;; Read server name with completion.
14592 (setq gnus-nntp-server
14593 (completing-read "NNTP server: "
14594 (mapcar (lambda (server) (list server))
14595 (cons (list gnus-nntp-server)
14596 gnus-secondary-servers))
14597 nil nil gnus-nntp-server))))
14599 (if (and gnus-nntp-server
14600 (stringp gnus-nntp-server)
14601 (not (string= gnus-nntp-server "")))
14602 (setq gnus-select-method
14603 (cond ((or (string= gnus-nntp-server "")
14604 (string= gnus-nntp-server "::"))
14605 (list 'nnspool (system-name)))
14606 ((string-match "^:" gnus-nntp-server)
14607 (list 'nnmh gnus-nntp-server
14608 (list 'nnmh-directory
14609 (file-name-as-directory
14611 (concat "~/" (substring
14612 gnus-nntp-server 1)))))
14613 (list 'nnmh-get-new-mail nil)))
14615 (list 'nntp gnus-nntp-server)))))
14617 (setq how (car gnus-select-method))
14618 (cond ((eq how 'nnspool)
14620 (gnus-message 5 "Looking up local news spool..."))
14623 (gnus-message 5 "Looking up mh spool..."))
14626 (setq gnus-current-select-method gnus-select-method)
14627 (run-hooks 'gnus-open-server-hook)
14629 ;; gnus-open-server-hook might have opened it
14630 (gnus-server-opened gnus-select-method)
14631 (gnus-open-server gnus-select-method)
14634 "%s (%s) open error: '%s'. Continue? "
14635 (car gnus-select-method) (cadr gnus-select-method)
14636 (gnus-status-message gnus-select-method)))
14638 (gnus-message 1 "Couldn't open server on %s"
14639 (nth 1 gnus-select-method))
14643 (defun gnus-check-group (group)
14644 "Try to make sure that the server where GROUP exists is alive."
14645 (let ((method (gnus-find-method-for-group group)))
14646 (or (gnus-server-opened method)
14647 (gnus-open-server method))))
14649 (defun gnus-check-server (&optional method silent)
14650 "Check whether the connection to METHOD is down.
14651 If METHOD is nil, use `gnus-select-method'.
14652 If it is down, start it up (again)."
14653 (let ((method (or method gnus-select-method)))
14654 ;; Transform virtual server names into select methods.
14655 (when (stringp method)
14656 (setq method (gnus-server-to-method method)))
14657 (if (gnus-server-opened method)
14658 ;; The stream is already opened.
14660 ;; Open the server.
14662 (gnus-message 5 "Opening %s server%s..." (car method)
14663 (if (equal (nth 1 method) "") ""
14664 (format " on %s" (nth 1 method)))))
14665 (run-hooks 'gnus-open-server-hook)
14667 (gnus-open-server method)
14671 (defun gnus-get-function (method function)
14672 "Return a function symbol based on METHOD and FUNCTION."
14673 ;; Translate server names into methods.
14675 (error "Attempted use of a nil select method"))
14676 (when (stringp method)
14677 (setq method (gnus-server-to-method method)))
14678 (let ((func (intern (format "%s-%s" (car method) function))))
14679 ;; If the functions isn't bound, we require the backend in
14681 (unless (fboundp func)
14682 (require (car method))
14683 (unless (fboundp func)
14684 ;; This backend doesn't implement this function.
14685 (error "No such function: %s" func)))
14690 ;;; Interface functions to the backends.
14693 (defun gnus-open-server (method)
14694 "Open a connection to METHOD."
14695 (when (stringp method)
14696 (setq method (gnus-server-to-method method)))
14697 (let ((elem (assoc method gnus-opened-servers)))
14698 ;; If this method was previously denied, we just return nil.
14699 (if (eq (nth 1 elem) 'denied)
14701 (gnus-message 1 "Denied server")
14703 ;; Open the server.
14705 (funcall (gnus-get-function method 'open-server)
14706 (nth 1 method) (nthcdr 2 method))))
14707 ;; If this hasn't been opened before, we add it to the list.
14709 (setq elem (list method nil)
14710 gnus-opened-servers (cons elem gnus-opened-servers)))
14711 ;; Set the status of this server.
14712 (setcar (cdr elem) (if result 'ok 'denied))
14713 ;; Return the result from the "open" call.
14716 (defun gnus-close-server (method)
14717 "Close the connection to METHOD."
14718 (when (stringp method)
14719 (setq method (gnus-server-to-method method)))
14720 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14722 (defun gnus-request-list (method)
14723 "Request the active file from METHOD."
14724 (when (stringp method)
14725 (setq method (gnus-server-to-method method)))
14726 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14728 (defun gnus-request-list-newsgroups (method)
14729 "Request the newsgroups file from METHOD."
14730 (when (stringp method)
14731 (setq method (gnus-server-to-method method)))
14732 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14734 (defun gnus-request-newgroups (date method)
14735 "Request all new groups since DATE from METHOD."
14736 (when (stringp method)
14737 (setq method (gnus-server-to-method method)))
14738 (funcall (gnus-get-function method 'request-newgroups)
14739 date (nth 1 method)))
14741 (defun gnus-server-opened (method)
14742 "Check whether a connection to METHOD has been opened."
14743 (when (stringp method)
14744 (setq method (gnus-server-to-method method)))
14745 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14747 (defun gnus-status-message (method)
14748 "Return the status message from METHOD.
14749 If METHOD is a string, it is interpreted as a group name. The method
14750 this group uses will be queried."
14751 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14753 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14755 (defun gnus-request-group (group &optional dont-check method)
14756 "Request GROUP. If DONT-CHECK, no information is required."
14757 (let ((method (or method (gnus-find-method-for-group group))))
14758 (when (stringp method)
14759 (setq method (gnus-server-to-method method)))
14760 (funcall (gnus-get-function method 'request-group)
14761 (gnus-group-real-name group) (nth 1 method) dont-check)))
14763 (defun gnus-request-asynchronous (group &optional articles)
14764 "Request that GROUP behave asynchronously.
14765 ARTICLES is the `data' of the group."
14766 (let ((method (gnus-find-method-for-group group)))
14767 (funcall (gnus-get-function method 'request-asynchronous)
14768 (gnus-group-real-name group) (nth 1 method) articles)))
14770 (defun gnus-list-active-group (group)
14771 "Request active information on GROUP."
14772 (let ((method (gnus-find-method-for-group group))
14773 (func 'list-active-group))
14774 (when (gnus-check-backend-function func group)
14775 (funcall (gnus-get-function method func)
14776 (gnus-group-real-name group) (nth 1 method)))))
14778 (defun gnus-request-group-description (group)
14779 "Request a description of GROUP."
14780 (let ((method (gnus-find-method-for-group group))
14781 (func 'request-group-description))
14782 (when (gnus-check-backend-function func group)
14783 (funcall (gnus-get-function method func)
14784 (gnus-group-real-name group) (nth 1 method)))))
14786 (defun gnus-close-group (group)
14787 "Request the GROUP be closed."
14788 (let ((method (gnus-find-method-for-group group)))
14789 (funcall (gnus-get-function method 'close-group)
14790 (gnus-group-real-name group) (nth 1 method))))
14792 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14793 "Request headers for ARTICLES in GROUP.
14794 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14795 (let ((method (gnus-find-method-for-group group)))
14796 (if (and gnus-use-cache (numberp (car articles)))
14797 (gnus-cache-retrieve-headers articles group fetch-old)
14798 (funcall (gnus-get-function method 'retrieve-headers)
14799 articles (gnus-group-real-name group) (nth 1 method)
14802 (defun gnus-retrieve-groups (groups method)
14803 "Request active information on GROUPS from METHOD."
14804 (when (stringp method)
14805 (setq method (gnus-server-to-method method)))
14806 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14808 (defun gnus-request-type (group &optional article)
14809 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14810 (let ((method (gnus-find-method-for-group group)))
14811 (if (not (gnus-check-backend-function 'request-type (car method)))
14813 (funcall (gnus-get-function method 'request-type)
14814 (gnus-group-real-name group) article))))
14816 (defun gnus-request-update-mark (group article mark)
14817 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14818 (let ((method (gnus-find-method-for-group group)))
14819 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14821 (funcall (gnus-get-function method 'request-update-mark)
14822 (gnus-group-real-name group) article mark))))
14824 (defun gnus-request-article (article group &optional buffer)
14825 "Request the ARTICLE in GROUP.
14826 ARTICLE can either be an article number or an article Message-ID.
14827 If BUFFER, insert the article in that group."
14828 (let ((method (gnus-find-method-for-group group)))
14829 (funcall (gnus-get-function method 'request-article)
14830 article (gnus-group-real-name group) (nth 1 method) buffer)))
14832 (defun gnus-request-head (article group)
14833 "Request the head of ARTICLE in GROUP."
14834 (let ((method (gnus-find-method-for-group group)))
14835 (funcall (gnus-get-function method 'request-head)
14836 article (gnus-group-real-name group) (nth 1 method))))
14838 (defun gnus-request-body (article group)
14839 "Request the body of ARTICLE in GROUP."
14840 (let ((method (gnus-find-method-for-group group)))
14841 (funcall (gnus-get-function method 'request-body)
14842 article (gnus-group-real-name group) (nth 1 method))))
14844 (defun gnus-request-post (method)
14845 "Post the current buffer using METHOD."
14846 (when (stringp method)
14847 (setq method (gnus-server-to-method method)))
14848 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14850 (defun gnus-request-scan (group method)
14851 "Request a SCAN being performed in GROUP from METHOD.
14852 If GROUP is nil, all groups on METHOD are scanned."
14853 (let ((method (if group (gnus-find-method-for-group group) method)))
14854 (funcall (gnus-get-function method 'request-scan)
14855 (and group (gnus-group-real-name group)) (nth 1 method))))
14857 (defsubst gnus-request-update-info (info method)
14858 "Request that METHOD update INFO."
14859 (when (stringp method)
14860 (setq method (gnus-server-to-method method)))
14861 (when (gnus-check-backend-function 'request-update-info (car method))
14862 (funcall (gnus-get-function method 'request-update-info)
14863 (gnus-group-real-name (gnus-info-group info))
14864 info (nth 1 method))))
14866 (defun gnus-request-expire-articles (articles group &optional force)
14867 (let ((method (gnus-find-method-for-group group)))
14868 (funcall (gnus-get-function method 'request-expire-articles)
14869 articles (gnus-group-real-name group) (nth 1 method)
14872 (defun gnus-request-move-article
14873 (article group server accept-function &optional last)
14874 (let ((method (gnus-find-method-for-group group)))
14875 (funcall (gnus-get-function method 'request-move-article)
14876 article (gnus-group-real-name group)
14877 (nth 1 method) accept-function last)))
14879 (defun gnus-request-accept-article (group &optional last method)
14880 ;; Make sure there's a newline at the end of the article.
14881 (when (stringp method)
14882 (setq method (gnus-server-to-method method)))
14883 (goto-char (point-max))
14886 (let ((func (if (symbolp group) group
14887 (car (or method (gnus-find-method-for-group group))))))
14888 (funcall (intern (format "%s-request-accept-article" func))
14889 (if (stringp group) (gnus-group-real-name group) group)
14892 (defun gnus-request-replace-article (article group buffer)
14893 (let ((func (car (gnus-find-method-for-group group))))
14894 (funcall (intern (format "%s-request-replace-article" func))
14895 article (gnus-group-real-name group) buffer)))
14897 (defun gnus-request-associate-buffer (group)
14898 (let ((method (gnus-find-method-for-group group)))
14899 (funcall (gnus-get-function method 'request-associate-buffer)
14900 (gnus-group-real-name group))))
14902 (defun gnus-request-restore-buffer (article group)
14903 "Request a new buffer restored to the state of ARTICLE."
14904 (let ((method (gnus-find-method-for-group group)))
14905 (funcall (gnus-get-function method 'request-restore-buffer)
14906 article (gnus-group-real-name group) (nth 1 method))))
14908 (defun gnus-request-create-group (group &optional method)
14909 (when (stringp method)
14910 (setq method (gnus-server-to-method method)))
14911 (let ((method (or method (gnus-find-method-for-group group))))
14912 (funcall (gnus-get-function method 'request-create-group)
14913 (gnus-group-real-name group) (nth 1 method))))
14915 (defun gnus-request-delete-group (group &optional force)
14916 (let ((method (gnus-find-method-for-group group)))
14917 (funcall (gnus-get-function method 'request-delete-group)
14918 (gnus-group-real-name group) force (nth 1 method))))
14920 (defun gnus-request-rename-group (group new-name)
14921 (let ((method (gnus-find-method-for-group group)))
14922 (funcall (gnus-get-function method 'request-rename-group)
14923 (gnus-group-real-name group)
14924 (gnus-group-real-name new-name) (nth 1 method))))
14926 (defun gnus-member-of-valid (symbol group)
14927 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14928 (memq symbol (assoc
14929 (symbol-name (car (gnus-find-method-for-group group)))
14930 gnus-valid-select-methods)))
14932 (defun gnus-method-option-p (method option)
14933 "Return non-nil if select METHOD has OPTION as a parameter."
14934 (when (stringp method)
14935 (setq method (gnus-server-to-method method)))
14936 (memq option (assoc (format "%s" (car method))
14937 gnus-valid-select-methods)))
14939 (defun gnus-server-extend-method (group method)
14940 ;; This function "extends" a virtual server. If the server is
14941 ;; "hello", and the select method is ("hello" (my-var "something"))
14942 ;; in the group "alt.alt", this will result in a new virtual server
14943 ;; called "hello+alt.alt".
14945 (gnus-copy-sequence
14946 (if (equal (car method) "native") gnus-select-method
14947 (cdr (assoc (car method) gnus-server-alist))))))
14948 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14949 (nconc entry (cdr method))))
14951 (defun gnus-find-method-for-group (group &optional info)
14952 "Find the select method that GROUP uses."
14953 (or gnus-override-method
14955 gnus-select-method)
14956 (let ((info (or info (gnus-get-info group)))
14959 (not (setq method (gnus-info-method info)))
14960 (equal method "native"))
14963 (cond ((stringp method)
14964 (gnus-server-to-method method))
14965 ((stringp (car method))
14966 (gnus-server-extend-method group method))
14969 (if (equal (cadr method) "")
14971 (gnus-server-add-address method))))))
14973 (defun gnus-check-backend-function (func group)
14974 "Check whether GROUP supports function FUNC."
14975 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14977 (fboundp (intern (format "%s-%s" method func)))))
14979 (defun gnus-methods-using (feature)
14980 "Find all methods that have FEATURE."
14981 (let ((valids gnus-valid-select-methods)
14984 (if (memq feature (car valids))
14985 (setq outs (cons (car valids) outs)))
14986 (setq valids (cdr valids)))
14991 ;;; Active & Newsrc File Handling
14994 (defun gnus-setup-news (&optional rawfile level dont-connect)
14995 "Setup news information.
14996 If RAWFILE is non-nil, the .newsrc file will also be read.
14997 If LEVEL is non-nil, the news will be set up at level LEVEL."
14998 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15001 ;; Clear some variables to re-initialize news information.
15002 (setq gnus-newsrc-alist nil
15003 gnus-active-hashtb nil)
15004 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15005 (gnus-read-newsrc-file rawfile))
15007 (when (and (not (assoc "archive" gnus-server-alist))
15008 gnus-message-archive-method)
15009 (push (cons "archive" gnus-message-archive-method)
15010 gnus-server-alist))
15012 ;; If we don't read the complete active file, we fill in the
15014 (if (or (null gnus-read-active-file)
15015 (eq gnus-read-active-file 'some))
15016 (gnus-update-active-hashtb-from-killed))
15018 ;; Read the active file and create `gnus-active-hashtb'.
15019 ;; If `gnus-read-active-file' is nil, then we just create an empty
15020 ;; hash table. The partial filling out of the hash table will be
15021 ;; done in `gnus-get-unread-articles'.
15022 (and gnus-read-active-file
15024 (gnus-read-active-file))
15026 (or gnus-active-hashtb
15027 (setq gnus-active-hashtb (make-vector 4095 0)))
15029 ;; Initialize the cache.
15030 (when gnus-use-cache
15033 ;; Possibly eval the dribble file.
15034 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15036 (gnus-update-format-specifications)
15038 ;; See whether we need to read the description file.
15039 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15040 (not gnus-description-hashtb)
15042 gnus-read-active-file)
15043 (gnus-read-all-descriptions-files))
15045 ;; Find new newsgroups and treat them.
15046 (if (and init gnus-check-new-newsgroups (not level)
15047 (gnus-check-server gnus-select-method))
15048 (gnus-find-new-newsgroups))
15050 ;; We might read in new NoCeM messages here.
15051 (when gnus-use-nocem
15052 (gnus-nocem-scan-groups))
15054 ;; Find the number of unread articles in each non-dead group.
15055 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15056 (gnus-get-unread-articles level))
15058 (if (and init gnus-check-bogus-newsgroups
15059 gnus-read-active-file (not level)
15060 (gnus-server-opened gnus-select-method))
15061 (gnus-check-bogus-newsgroups))))
15063 (defun gnus-find-new-newsgroups (&optional arg)
15064 "Search for new newsgroups and add them.
15065 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15066 The `-n' option line from .newsrc is respected.
15067 If ARG (the prefix), use the `ask-server' method to query
15068 the server for new groups."
15070 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15071 (null gnus-read-active-file)
15072 (eq gnus-read-active-file 'some))
15073 'ask-server gnus-check-new-newsgroups)))
15074 (unless (gnus-check-first-time-used)
15075 (if (or (consp check)
15076 (eq check 'ask-server))
15077 ;; Ask the server for new groups.
15078 (gnus-ask-server-for-new-groups)
15079 ;; Go through the active hashtb and look for new groups.
15081 group new-newsgroups)
15082 (gnus-message 5 "Looking for new newsgroups...")
15083 (unless gnus-have-read-active-file
15084 (gnus-read-active-file))
15085 (setq gnus-newsrc-last-checked-date (current-time-string))
15086 (unless gnus-killed-hashtb
15087 (gnus-make-hashtable-from-killed))
15088 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15089 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15092 (if (or (null (setq group (symbol-name sym)))
15094 (null (symbol-value sym))
15095 (gnus-gethash group gnus-killed-hashtb)
15096 (gnus-gethash group gnus-newsrc-hashtb))
15098 (let ((do-sub (gnus-matches-options-n group)))
15100 ((eq do-sub 'subscribe)
15101 (setq groups (1+ groups))
15102 (gnus-sethash group group gnus-killed-hashtb)
15103 (funcall gnus-subscribe-options-newsgroup-method group))
15104 ((eq do-sub 'ignore)
15107 (setq groups (1+ groups))
15108 (gnus-sethash group group gnus-killed-hashtb)
15109 (if gnus-subscribe-hierarchical-interactive
15110 (setq new-newsgroups (cons group new-newsgroups))
15111 (funcall gnus-subscribe-newsgroup-method group)))))))
15112 gnus-active-hashtb)
15113 (when new-newsgroups
15114 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15115 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15117 (gnus-message 6 "%d new newsgroup%s arrived."
15118 groups (if (> groups 1) "s have" " has"))
15119 (gnus-message 6 "No new newsgroups.")))))))
15121 (defun gnus-matches-options-n (group)
15122 ;; Returns `subscribe' if the group is to be unconditionally
15123 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15124 ;; no match for the group.
15126 ;; First we check the two user variables.
15128 ((and gnus-options-subscribe
15129 (string-match gnus-options-subscribe group))
15131 ((and gnus-auto-subscribed-groups
15132 (string-match gnus-auto-subscribed-groups group))
15134 ((and gnus-options-not-subscribe
15135 (string-match gnus-options-not-subscribe group))
15137 ;; Then we go through the list that was retrieved from the .newsrc
15138 ;; file. This list has elements on the form
15139 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15140 ;; is in the reverse order of the options line) is returned.
15142 (let ((regs gnus-newsrc-options-n))
15144 (not (string-match (caar regs) group)))
15145 (setq regs (cdr regs)))
15146 (and regs (cdar regs))))))
15148 (defun gnus-ask-server-for-new-groups ()
15149 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15150 (methods (cons gnus-select-method
15152 (when gnus-message-archive-method
15155 (and (consp gnus-check-new-newsgroups)
15156 gnus-check-new-newsgroups)
15157 gnus-secondary-select-methods))))
15159 (new-date (current-time-string))
15160 group new-newsgroups got-new method hashtb
15161 gnus-override-subscribe-method)
15162 ;; Go through both primary and secondary select methods and
15163 ;; request new newsgroups.
15164 (while (setq method (gnus-server-get-method nil (pop methods)))
15165 (setq new-newsgroups nil)
15166 (setq gnus-override-subscribe-method method)
15167 (when (and (gnus-check-server method)
15168 (gnus-request-newgroups date method))
15171 (setq hashtb (gnus-make-hashtable 100))
15172 (set-buffer nntp-server-buffer)
15173 ;; Enter all the new groups into a hashtable.
15174 (gnus-active-to-gnus-format method hashtb 'ignore)))
15175 ;; Now all new groups from `method' are in `hashtb'.
15177 (lambda (group-sym)
15178 (if (or (null (setq group (symbol-name group-sym)))
15179 (null (symbol-value group-sym))
15180 (gnus-gethash group gnus-newsrc-hashtb)
15181 (member group gnus-zombie-list)
15182 (member group gnus-killed-list))
15183 ;; The group is already known.
15185 ;; Make this group active.
15186 (when (symbol-value group-sym)
15187 (gnus-set-active group (symbol-value group-sym)))
15188 ;; Check whether we want it or not.
15189 (let ((do-sub (gnus-matches-options-n group)))
15191 ((eq do-sub 'subscribe)
15193 (gnus-sethash group group gnus-killed-hashtb)
15194 (funcall gnus-subscribe-options-newsgroup-method group))
15195 ((eq do-sub 'ignore)
15199 (gnus-sethash group group gnus-killed-hashtb)
15200 (if gnus-subscribe-hierarchical-interactive
15201 (push group new-newsgroups)
15202 (funcall gnus-subscribe-newsgroup-method group)))))))
15204 (when new-newsgroups
15205 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15206 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15208 (gnus-message 6 "%d new newsgroup%s arrived."
15209 groups (if (> groups 1) "s have" " has")))
15210 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15213 (defun gnus-check-first-time-used ()
15214 (if (or (> (length gnus-newsrc-alist) 1)
15215 (file-exists-p gnus-startup-file)
15216 (file-exists-p (concat gnus-startup-file ".el"))
15217 (file-exists-p (concat gnus-startup-file ".eld")))
15219 (gnus-message 6 "First time user; subscribing you to default groups")
15220 (unless gnus-have-read-active-file
15221 (gnus-read-active-file))
15222 (setq gnus-newsrc-last-checked-date (current-time-string))
15223 (let ((groups gnus-default-subscribed-newsgroups)
15227 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15230 (if (null (setq group (symbol-name sym)))
15232 (let ((do-sub (gnus-matches-options-n group)))
15234 ((eq do-sub 'subscribe)
15235 (gnus-sethash group group gnus-killed-hashtb)
15236 (funcall gnus-subscribe-options-newsgroup-method group))
15237 ((eq do-sub 'ignore)
15240 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15241 gnus-active-hashtb)
15243 (if (gnus-active (car groups))
15244 (gnus-group-change-level
15245 (car groups) gnus-level-default-subscribed gnus-level-killed))
15246 (setq groups (cdr groups)))
15247 (gnus-group-make-help-group)
15248 (and gnus-novice-user
15249 (gnus-message 7 "`A k' to list killed groups"))))))
15251 (defun gnus-subscribe-group (group previous &optional method)
15252 (gnus-group-change-level
15254 (list t group gnus-level-default-subscribed nil nil method)
15256 gnus-level-default-subscribed gnus-level-killed previous t))
15258 ;; `gnus-group-change-level' is the fundamental function for changing
15259 ;; subscription levels of newsgroups. This might mean just changing
15260 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15261 ;; again, which subscribes/unsubscribes a group, which is equally
15262 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15263 ;; from 8-9 to 1-7 means that you remove the group from the list of
15264 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15265 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15266 ;; which is trivial.
15267 ;; ENTRY can either be a string (newsgroup name) or a list (if
15268 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15269 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15271 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15272 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15274 (defun gnus-group-change-level (entry level &optional oldlevel
15275 previous fromkilled)
15276 (let (group info active num)
15277 ;; Glean what info we can from the arguments
15279 (if fromkilled (setq group (nth 1 entry))
15280 (setq group (car (nth 2 entry))))
15281 (setq group entry))
15282 (if (and (stringp entry)
15284 (< oldlevel gnus-level-zombie))
15285 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15286 (if (and (not oldlevel)
15288 (setq oldlevel (gnus-info-level (nth 2 entry)))
15289 (setq oldlevel (or oldlevel 9)))
15290 (if (stringp previous)
15291 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15293 (if (and (>= oldlevel gnus-level-zombie)
15294 (gnus-gethash group gnus-newsrc-hashtb))
15295 ;; We are trying to subscribe a group that is already
15299 (or (gnus-ephemeral-group-p group)
15300 (gnus-dribble-enter
15301 (format "(gnus-group-change-level %S %S %S %S %S)"
15302 group level oldlevel (car (nth 2 previous)) fromkilled)))
15304 ;; Then we remove the newgroup from any old structures, if needed.
15305 ;; If the group was killed, we remove it from the killed or zombie
15306 ;; list. If not, and it is in fact going to be killed, we remove
15307 ;; it from the newsrc hash table and assoc.
15309 ((>= oldlevel gnus-level-zombie)
15310 (if (= oldlevel gnus-level-zombie)
15311 (setq gnus-zombie-list (delete group gnus-zombie-list))
15312 (setq gnus-killed-list (delete group gnus-killed-list))))
15314 (if (and (>= level gnus-level-zombie)
15317 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15319 (setcdr (gnus-gethash (car (nth 3 entry))
15320 gnus-newsrc-hashtb)
15322 (setcdr (cdr entry) (cdddr entry))))))
15324 ;; Finally we enter (if needed) the list where it is supposed to
15325 ;; go, and change the subscription level. If it is to be killed,
15326 ;; we enter it into the killed or zombie list.
15328 ((>= level gnus-level-zombie)
15329 ;; Remove from the hash table.
15330 (gnus-sethash group nil gnus-newsrc-hashtb)
15331 ;; We do not enter foreign groups into the list of dead
15333 (unless (gnus-group-foreign-p group)
15334 (if (= level gnus-level-zombie)
15335 (setq gnus-zombie-list (cons group gnus-zombie-list))
15336 (setq gnus-killed-list (cons group gnus-killed-list)))))
15338 ;; If the list is to be entered into the newsrc assoc, and
15339 ;; it was killed, we have to create an entry in the newsrc
15340 ;; hashtb format and fix the pointers in the newsrc assoc.
15341 (if (< oldlevel gnus-level-zombie)
15342 ;; It was alive, and it is going to stay alive, so we
15343 ;; just change the level and don't change any pointers or
15344 ;; hash table entries.
15345 (setcar (cdaddr entry) level)
15347 (setq info (cdr entry)
15349 (setq active (gnus-active group))
15351 (if active (- (1+ (cdr active)) (car active)) t))
15352 ;; Check whether the group is foreign. If so, the
15353 ;; foreign select method has to be entered into the
15355 (let ((method (or gnus-override-subscribe-method
15356 (gnus-group-method group))))
15357 (if (eq method gnus-select-method)
15358 (setq info (list group level nil))
15359 (setq info (list group level nil nil method)))))
15362 (let ((p gnus-newsrc-alist))
15366 (setq entry (cons info (cddr previous)))
15369 (setcdr (cdr previous) entry)
15370 (gnus-sethash group (cons num (cdr previous))
15371 gnus-newsrc-hashtb))
15372 (setcdr previous entry)
15373 (gnus-sethash group (cons num previous)
15374 gnus-newsrc-hashtb))
15376 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15377 (when gnus-group-change-level-function
15378 (funcall gnus-group-change-level-function group level oldlevel)))))
15380 (defun gnus-kill-newsgroup (newsgroup)
15381 "Obsolete function. Kills a newsgroup."
15382 (gnus-group-change-level
15383 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15385 (defun gnus-check-bogus-newsgroups (&optional confirm)
15386 "Remove bogus newsgroups.
15387 If CONFIRM is non-nil, the user has to confirm the deletion of every
15389 (let ((newsrc (cdr gnus-newsrc-alist))
15390 bogus group entry info)
15391 (gnus-message 5 "Checking bogus newsgroups...")
15392 (unless gnus-have-read-active-file
15393 (gnus-read-active-file))
15394 (when (member gnus-select-method gnus-have-read-active-file)
15395 ;; Find all bogus newsgroup that are subscribed.
15397 (setq info (pop newsrc)
15398 group (gnus-info-group info))
15399 (unless (or (gnus-active group) ; Active
15400 (gnus-info-method info) ; Foreign
15402 (not (gnus-y-or-n-p
15403 (format "Remove bogus newsgroup: %s " group)))))
15404 ;; Found a bogus newsgroup.
15405 (push group bogus)))
15406 ;; Remove all bogus subscribed groups by first killing them, and
15407 ;; then removing them from the list of killed groups.
15409 (when (setq entry (gnus-gethash (setq group (pop bogus))
15410 gnus-newsrc-hashtb))
15411 (gnus-group-change-level entry gnus-level-killed)
15412 (setq gnus-killed-list (delete group gnus-killed-list))))
15413 ;; Then we remove all bogus groups from the list of killed and
15414 ;; zombie groups. They are are removed without confirmation.
15415 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15418 (setq killed (symbol-value (car dead-lists)))
15420 (unless (gnus-active (setq group (pop killed)))
15421 ;; The group is bogus.
15422 ;; !!!Slow as hell.
15423 (set (car dead-lists)
15424 (delete group (symbol-value (car dead-lists))))))
15425 (setq dead-lists (cdr dead-lists))))
15426 (gnus-message 5 "Checking bogus newsgroups...done"))))
15428 (defun gnus-check-duplicate-killed-groups ()
15429 "Remove duplicates from the list of killed groups."
15431 (let ((killed gnus-killed-list))
15433 (gnus-message 9 "%d" (length killed))
15434 (setcdr killed (delete (car killed) (cdr killed)))
15435 (setq killed (cdr killed)))))
15437 ;; We want to inline a function from gnus-cache, so we cheat here:
15440 (require 'gnus-cache))
15442 (defun gnus-get-unread-articles-in-group (info active &optional update)
15444 ;; Allow the backend to update the info in the group.
15446 (gnus-request-update-info
15447 info (gnus-find-method-for-group (gnus-info-group info))))
15448 (gnus-activate-group (gnus-info-group info)))
15449 (let* ((range (gnus-info-read info))
15451 ;; If a cache is present, we may have to alter the active info.
15452 (when (and gnus-use-cache info)
15453 (inline (gnus-cache-possibly-alter-active
15454 (gnus-info-group info) active)))
15455 ;; Modify the list of read articles according to what articles
15456 ;; are available; then tally the unread articles and add the
15457 ;; number to the group hash table entry.
15459 ((zerop (cdr active))
15462 (setq num (- (1+ (cdr active)) (car active))))
15463 ((not (listp (cdr range)))
15464 ;; Fix a single (num . num) range according to the
15465 ;; active hash table.
15466 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15467 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15468 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15469 ;; Compute number of unread articles.
15470 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15472 ;; The read list is a list of ranges. Fix them according to
15473 ;; the active hash table.
15474 ;; First peel off any elements that are below the lower
15476 (while (and (cdr range)
15478 (or (and (atom (cadr range)) (cadr range))
15480 (if (numberp (car range))
15483 (or (and (numberp (cadr range))
15486 (setcdr (car range)
15487 (or (and (numberp (nth 1 range)) (nth 1 range))
15489 (setcdr range (cddr range)))
15490 ;; Adjust the first element to be the same as the lower limit.
15491 (if (and (not (atom (car range)))
15492 (< (cdar range) (car active)))
15493 (setcdr (car range) (1- (car active))))
15494 ;; Then we want to peel off any elements that are higher
15495 ;; than the upper active limit.
15496 (let ((srange range))
15497 ;; Go past all legal elements.
15498 (while (and (cdr srange)
15499 (<= (or (and (atom (cadr srange))
15501 (caadr srange)) (cdr active)))
15502 (setq srange (cdr srange)))
15504 ;; Nuke all remaining illegal elements.
15505 (setcdr srange nil))
15507 ;; Adjust the final element.
15508 (if (and (not (atom (car srange)))
15509 (> (cdar srange) (cdr active)))
15510 (setcdr (car srange) (cdr active))))
15511 ;; Compute the number of unread articles.
15513 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15515 (or (and (atom (car range)) (car range))
15517 (setq range (cdr range)))
15518 (setq num (max 0 (- (cdr active) num)))))
15519 ;; Set the number of unread articles.
15521 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15524 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15525 ;; and compute how many unread articles there are in each group.
15526 (defun gnus-get-unread-articles (&optional level)
15527 (let* ((newsrc (cdr gnus-newsrc-alist))
15528 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15531 (cond ((and gnus-activate-foreign-newsgroups
15532 (not (numberp gnus-activate-foreign-newsgroups)))
15533 (1+ gnus-level-subscribed))
15534 ((numberp gnus-activate-foreign-newsgroups)
15535 gnus-activate-foreign-newsgroups)
15538 info group active method)
15539 (gnus-message 5 "Checking new news...")
15542 (setq active (gnus-active (setq group (gnus-info-group
15543 (setq info (pop newsrc))))))
15545 ;; Check newsgroups. If the user doesn't want to check them, or
15546 ;; they can't be checked (for instance, if the news server can't
15547 ;; be reached) we just set the number of unread articles in this
15548 ;; newsgroup to t. This means that Gnus thinks that there are
15549 ;; unread articles, but it has no idea how many.
15550 (if (and (setq method (gnus-info-method info))
15551 (not (gnus-server-equal
15553 (setq method (gnus-server-get-method nil method))))
15554 (not (gnus-secondary-method-p method)))
15555 ;; These groups are foreign. Check the level.
15556 (when (<= (gnus-info-level info) foreign-level)
15557 (setq active (gnus-activate-group group 'scan))
15558 (gnus-close-group group))
15560 ;; These groups are native or secondary.
15561 (when (and (<= (gnus-info-level info) level)
15562 (not gnus-read-active-file))
15563 (setq active (gnus-activate-group group 'scan))
15564 (gnus-close-group group)))
15567 (inline (gnus-get-unread-articles-in-group
15570 (fboundp (intern (concat (symbol-name (car method))
15571 "-request-scan"))))))
15572 ;; The group couldn't be reached, so we nix out the number of
15573 ;; unread articles and stuff.
15574 (gnus-set-active group nil)
15575 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15577 (gnus-message 5 "Checking new news...done")))
15579 ;; Create a hash table out of the newsrc alist. The `car's of the
15580 ;; alist elements are used as keys.
15581 (defun gnus-make-hashtable-from-newsrc-alist ()
15582 (let ((alist gnus-newsrc-alist)
15583 (ohashtb gnus-newsrc-hashtb)
15585 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15587 (setq prev (setq gnus-newsrc-alist
15588 (if (equal (caar gnus-newsrc-alist)
15591 (cons (list "dummy.group" 0 nil) alist)))))
15595 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15597 gnus-newsrc-hashtb)
15599 alist (cdr alist)))))
15601 (defun gnus-make-hashtable-from-killed ()
15602 "Create a hash table from the killed and zombie lists."
15603 (let ((lists '(gnus-killed-list gnus-zombie-list))
15605 (setq gnus-killed-hashtb
15606 (gnus-make-hashtable
15607 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15608 (while (setq list (symbol-value (pop lists)))
15610 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15612 (defun gnus-activate-group (group &optional scan)
15613 ;; Check whether a group has been activated or not.
15614 ;; If SCAN, request a scan of that group as well.
15615 (let ((method (gnus-find-method-for-group group))
15617 (and (gnus-check-server method)
15618 ;; We escape all bugs and quit here to make it possible to
15619 ;; continue if a group is so out-there that it reports bugs
15623 (gnus-check-backend-function 'request-scan (car method))
15624 (gnus-request-scan group method))
15627 (gnus-request-group group)
15631 (set-buffer nntp-server-buffer)
15632 (goto-char (point-min))
15633 ;; Parse the result we got from `gnus-request-group'.
15634 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15636 (goto-char (match-beginning 1))
15638 group (setq active (cons (read (current-buffer))
15639 (read (current-buffer)))))
15640 ;; Return the new active info.
15643 (defun gnus-update-read-articles (group unread)
15644 "Update the list of read and ticked articles in GROUP using the
15645 UNREAD and TICKED lists.
15646 Note: UNSELECTED has to be sorted over `<'.
15647 Returns whether the updating was successful."
15648 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15649 (entry (gnus-gethash group gnus-newsrc-hashtb))
15650 (info (nth 2 entry))
15652 (unread (sort (copy-sequence unread) '<))
15654 (if (or (not info) (not active))
15655 ;; There is no info on this group if it was, in fact,
15656 ;; killed. Gnus stores no information on killed groups, so
15657 ;; there's nothing to be done.
15658 ;; One could store the information somewhere temporarily,
15659 ;; perhaps... Hmmm...
15661 ;; Remove any negative articles numbers.
15662 (while (and unread (< (car unread) 0))
15663 (setq unread (cdr unread)))
15664 ;; Remove any expired article numbers
15665 (while (and unread (< (car unread) (car active)))
15666 (setq unread (cdr unread)))
15667 ;; Compute the ranges of read articles by looking at the list of
15668 ;; unread articles.
15670 (if (/= (car unread) prev)
15671 (setq read (cons (if (= prev (1- (car unread))) prev
15672 (cons prev (1- (car unread)))) read)))
15673 (setq prev (1+ (car unread)))
15674 (setq unread (cdr unread)))
15675 (when (<= prev (cdr active))
15676 (setq read (cons (cons prev (cdr active)) read)))
15677 ;; Enter this list into the group info.
15678 (gnus-info-set-read
15679 info (if (> (length read) 1) (nreverse read) read))
15680 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15681 (gnus-get-unread-articles-in-group info (gnus-active group))
15684 (defun gnus-make-articles-unread (group articles)
15685 "Mark ARTICLES in GROUP as unread."
15686 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15687 (gnus-gethash (gnus-group-real-name group)
15688 gnus-newsrc-hashtb))))
15689 (ranges (gnus-info-read info))
15692 (when (gnus-member-of-range
15693 (setq article (pop articles)) ranges)
15694 (setq news (cons article news))))
15696 (gnus-info-set-read
15697 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15698 (gnus-group-update-group group t))))
15700 ;; Enter all dead groups into the hashtb.
15701 (defun gnus-update-active-hashtb-from-killed ()
15702 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15703 (lists (list gnus-killed-list gnus-zombie-list))
15706 (setq killed (car lists))
15708 (gnus-sethash (car killed) nil hashtb)
15709 (setq killed (cdr killed)))
15710 (setq lists (cdr lists)))))
15712 ;; Get the active file(s) from the backend(s).
15713 (defun gnus-read-active-file ()
15714 (gnus-group-set-mode-line)
15717 (if (gnus-check-server gnus-select-method)
15718 ;; The native server is available.
15719 (cons gnus-select-method gnus-secondary-select-methods)
15720 ;; The native server is down, so we just do the
15722 gnus-secondary-select-methods)
15723 ;; Also read from the archive server.
15724 (when gnus-message-archive-method
15725 (list "archive"))))
15727 (setq gnus-have-read-active-file nil)
15729 (set-buffer nntp-server-buffer)
15731 (let* ((method (if (stringp (car methods))
15732 (gnus-server-get-method nil (car methods))
15734 (where (nth 1 method))
15735 (mesg (format "Reading active file%s via %s..."
15736 (if (and where (not (zerop (length where))))
15737 (concat " from " where) "")
15739 (gnus-message 5 mesg)
15740 (when (gnus-check-server method)
15741 ;; Request that the backend scan its incoming messages.
15742 (and (gnus-check-backend-function 'request-scan (car method))
15743 (gnus-request-scan nil method))
15745 ((and (eq gnus-read-active-file 'some)
15746 (gnus-check-backend-function 'retrieve-groups (car method)))
15747 (let ((newsrc (cdr gnus-newsrc-alist))
15748 (gmethod (gnus-server-get-method nil method))
15750 (while (setq info (pop newsrc))
15751 (when (gnus-server-equal
15752 (gnus-find-method-for-group
15753 (gnus-info-group info) info)
15755 (push (gnus-group-real-name (gnus-info-group info))
15758 (gnus-check-server method)
15759 (setq list-type (gnus-retrieve-groups groups method))
15763 1 "Cannot read partial active file from %s server."
15767 ((eq list-type 'active)
15768 (gnus-active-to-gnus-format method gnus-active-hashtb))
15770 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15772 (if (not (gnus-request-list method))
15774 (unless (equal method gnus-message-archive-method)
15775 (gnus-message 1 "Cannot read active file from %s server."
15778 (gnus-active-to-gnus-format method)
15779 ;; We mark this active file as read.
15780 (push method gnus-have-read-active-file)
15781 (gnus-message 5 "%sdone" mesg))))))
15782 (setq methods (cdr methods))))))
15784 ;; Read an active file and place the results in `gnus-active-hashtb'.
15785 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15787 (setq method gnus-select-method))
15788 (let ((cur (current-buffer))
15790 (if (and gnus-active-hashtb
15791 (not (equal method gnus-select-method)))
15793 (setq gnus-active-hashtb
15794 (if (equal method gnus-select-method)
15795 (gnus-make-hashtable
15796 (count-lines (point-min) (point-max)))
15797 (gnus-make-hashtable 4096)))))))
15798 ;; Delete unnecessary lines.
15799 (goto-char (point-min))
15800 (while (search-forward "\nto." nil t)
15801 (delete-region (1+ (match-beginning 0))
15802 (progn (forward-line 1) (point))))
15803 (or (string= gnus-ignored-newsgroups "")
15805 (goto-char (point-min))
15806 (delete-matching-lines gnus-ignored-newsgroups)))
15807 ;; Make the group names readable as a lisp expression even if they
15808 ;; contain special characters.
15809 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15810 (goto-char (point-max))
15811 (while (re-search-backward "[][';?()#]" nil t)
15813 ;; If these are groups from a foreign select method, we insert the
15814 ;; group prefix in front of the group names.
15815 (and method (not (gnus-server-equal
15816 (gnus-server-get-method nil method)
15817 (gnus-server-get-method nil gnus-select-method)))
15818 (let ((prefix (gnus-group-prefixed-name "" method)))
15819 (goto-char (point-min))
15820 (while (and (not (eobp))
15821 (progn (insert prefix)
15822 (zerop (forward-line 1)))))))
15823 ;; Store the active file in a hash table.
15824 (goto-char (point-min))
15825 (if (string-match "%[oO]" gnus-group-line-format)
15826 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15827 ;; If we want information on moderated groups, we use this
15829 (let* ((mod-hashtb (make-vector 7 0))
15830 (m (intern "m" mod-hashtb))
15832 (while (not (eobp))
15833 (condition-case nil
15835 (narrow-to-region (point) (gnus-point-at-eol))
15836 (setq group (let ((obarray hashtb)) (read cur)))
15837 (if (and (numberp (setq max (read cur)))
15838 (numberp (setq min (read cur)))
15840 (skip-chars-forward " \t")
15842 (or (= (following-char) ?=)
15843 (= (following-char) ?x)
15844 (= (following-char) ?j)))))
15845 (set group (cons min max))
15847 ;; Enter moderated groups into a list.
15848 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15849 (setq gnus-moderated-list
15850 (cons (symbol-name group) gnus-moderated-list))))
15857 ;; And if we do not care about moderation, we use this loop,
15858 ;; which is faster.
15859 (let (group max min)
15860 (while (not (eobp))
15863 (narrow-to-region (point) (gnus-point-at-eol))
15864 ;; group gets set to a symbol interned in the hash table
15865 ;; (what a hack!!) - jwz
15866 (setq group (let ((obarray hashtb)) (read cur)))
15867 (if (and (numberp (setq max (read cur)))
15868 (numberp (setq min (read cur)))
15870 (skip-chars-forward " \t")
15872 (or (= (following-char) ?=)
15873 (= (following-char) ?x)
15874 (= (following-char) ?j)))))
15875 (set group (cons min max))
15883 (gnus-message 3 "Warning - illegal active: %s"
15885 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15887 (forward-line 1))))))
15889 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15890 ;; Parse a "groups" active file.
15891 (let ((cur (current-buffer))
15893 (if (and method gnus-active-hashtb)
15895 (setq gnus-active-hashtb
15896 (gnus-make-hashtable
15897 (count-lines (point-min) (point-max)))))))
15898 (prefix (and method
15899 (not (gnus-server-equal
15900 (gnus-server-get-method nil method)
15901 (gnus-server-get-method nil gnus-select-method)))
15902 (gnus-group-prefixed-name "" method))))
15904 (goto-char (point-min))
15905 ;; We split this into to separate loops, one with the prefix
15906 ;; and one without to speed the reading up somewhat.
15908 (let (min max opoint group)
15909 (while (not (eobp))
15912 (read cur) (read cur)
15913 (setq min (read cur)
15916 (skip-chars-forward " \t")
15919 (set (let ((obarray hashtb)) (read cur))
15921 (error (and group (symbolp group) (set group nil))))
15923 (let (min max group)
15924 (while (not (eobp))
15926 (if (= (following-char) ?2)
15928 (read cur) (read cur)
15929 (setq min (read cur)
15931 (set (setq group (let ((obarray hashtb)) (read cur)))
15933 (error (and group (symbolp group) (set group nil))))
15934 (forward-line 1))))))
15936 (defun gnus-read-newsrc-file (&optional force)
15937 "Read startup file.
15938 If FORCE is non-nil, the .newsrc file is read."
15939 ;; Reset variables that might be defined in the .newsrc.eld file.
15940 (let ((variables gnus-variable-list))
15942 (set (car variables) nil)
15943 (setq variables (cdr variables))))
15944 (let* ((newsrc-file gnus-current-startup-file)
15945 (quick-file (concat newsrc-file ".el")))
15947 ;; We always load the .newsrc.eld file. If always contains
15948 ;; much information that can not be gotten from the .newsrc
15949 ;; file (ticked articles, killed groups, foreign methods, etc.)
15950 (gnus-read-newsrc-el-file quick-file)
15952 (if (and (file-exists-p gnus-current-startup-file)
15954 (and (file-newer-than-file-p newsrc-file quick-file)
15955 (file-newer-than-file-p newsrc-file
15956 (concat quick-file "d")))
15957 (not gnus-newsrc-alist)))
15958 ;; We read the .newsrc file. Note that if there if a
15959 ;; .newsrc.eld file exists, it has already been read, and
15960 ;; the `gnus-newsrc-hashtb' has been created. While reading
15961 ;; the .newsrc file, Gnus will only use the information it
15962 ;; can find there for changing the data already read -
15963 ;; ie. reading the .newsrc file will not trash the data
15964 ;; already read (except for read articles).
15966 (gnus-message 5 "Reading %s..." newsrc-file)
15967 (set-buffer (find-file-noselect newsrc-file))
15968 (buffer-disable-undo (current-buffer))
15969 (gnus-newsrc-to-gnus-format)
15970 (kill-buffer (current-buffer))
15971 (gnus-message 5 "Reading %s...done" newsrc-file)))
15973 ;; Read any slave files.
15975 (gnus-master-read-slave-newsrc)))))
15977 (defun gnus-read-newsrc-el-file (file)
15978 (let ((ding-file (concat file "d")))
15979 ;; We always, always read the .eld file.
15980 (gnus-message 5 "Reading %s..." ding-file)
15981 (let (gnus-newsrc-assoc)
15982 (condition-case nil
15983 (load ding-file t t t)
15985 (gnus-message 1 "Error in %s" ding-file)
15987 (when gnus-newsrc-assoc
15988 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15989 (gnus-make-hashtable-from-newsrc-alist)
15990 (when (file-newer-than-file-p file ding-file)
15991 ;; Old format quick file
15992 (gnus-message 5 "Reading %s..." file)
15993 ;; The .el file is newer than the .eld file, so we read that one
15995 (gnus-read-old-newsrc-el-file file))))
15997 ;; Parse the old-style quick startup file
15998 (defun gnus-read-old-newsrc-el-file (file)
15999 (let (newsrc killed marked group m info)
16001 (let ((gnus-killed-assoc nil)
16002 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16004 (condition-case nil
16007 (setq newsrc gnus-newsrc-assoc
16008 killed gnus-killed-assoc
16009 marked gnus-marked-assoc)))
16010 (setq gnus-newsrc-alist nil)
16011 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16014 (gnus-info-set-read info (cddr group))
16015 (gnus-info-set-level
16016 info (if (nth 1 group) gnus-level-default-subscribed
16017 gnus-level-default-unsubscribed))
16018 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16021 (if (nth 1 group) gnus-level-default-subscribed
16022 gnus-level-default-unsubscribed)
16024 gnus-newsrc-alist))
16025 ;; Copy marks into info.
16026 (when (setq m (assoc (car group) marked))
16027 (unless (nthcdr 3 info)
16028 (nconc info (list nil)))
16029 (gnus-info-set-marks
16030 info (list (cons 'tick (gnus-compress-sequence
16031 (sort (cdr m) '<) t))))))
16032 (setq newsrc killed)
16034 (setcar newsrc (caar newsrc))
16035 (setq newsrc (cdr newsrc)))
16036 (setq gnus-killed-list killed))
16037 ;; The .el file version of this variable does not begin with
16038 ;; "options", while the .eld version does, so we just add it if it
16041 gnus-newsrc-options
16043 (and (not (string-match "^ *options" gnus-newsrc-options))
16044 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16045 (and (not (string-match "\n$" gnus-newsrc-options))
16046 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16047 ;; Finally, if we read some options lines, we parse them.
16048 (or (string= gnus-newsrc-options "")
16049 (gnus-newsrc-parse-options gnus-newsrc-options))))
16051 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16052 (gnus-make-hashtable-from-newsrc-alist)))
16054 (defun gnus-make-newsrc-file (file)
16055 "Make server dependent file name by catenating FILE and server host name."
16056 (let* ((file (expand-file-name file nil))
16057 (real-file (concat file "-" (nth 1 gnus-select-method))))
16058 (if (or (file-exists-p real-file)
16059 (file-exists-p (concat real-file ".el"))
16060 (file-exists-p (concat real-file ".eld")))
16063 (defun gnus-newsrc-to-gnus-format ()
16064 (setq gnus-newsrc-options "")
16065 (setq gnus-newsrc-options-n nil)
16067 (or gnus-active-hashtb
16068 (setq gnus-active-hashtb (make-vector 4095 0)))
16069 (let ((buf (current-buffer))
16070 (already-read (> (length gnus-newsrc-alist) 1))
16071 group subscribed options-symbol newsrc Options-symbol
16073 (goto-char (point-min))
16074 ;; We intern the symbol `options' in the active hashtb so that we
16075 ;; can `eq' against it later.
16076 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16077 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16079 (while (not (eobp))
16080 ;; We first read the first word on the line by narrowing and
16081 ;; then reading into `gnus-active-hashtb'. Most groups will
16082 ;; already exist in that hashtb, so this will save some string
16086 (progn (skip-chars-forward "^ \t!:\n") (point)))
16087 (goto-char (point-min))
16089 (and (/= (point-min) (point-max))
16090 (let ((obarray gnus-active-hashtb)) (read buf))))
16092 ;; Now, the symbol we have read is either `options' or a group
16093 ;; name. If it is an options line, we just add it to a string.
16095 ((or (eq symbol options-symbol)
16096 (eq symbol Options-symbol))
16097 (setq gnus-newsrc-options
16098 ;; This concating is quite inefficient, but since our
16099 ;; thorough studies show that approx 99.37% of all
16100 ;; .newsrc files only contain a single options line, we
16101 ;; don't give a damn, frankly, my dear.
16102 (concat gnus-newsrc-options
16104 (gnus-point-at-bol)
16105 ;; Options may continue on the next line.
16106 (or (and (re-search-forward "^[^ \t]" nil 'move)
16107 (progn (beginning-of-line) (point)))
16111 ;; Group names can be just numbers.
16112 (when (numberp symbol)
16113 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16114 (or (boundp symbol) (set symbol nil))
16115 ;; It was a group name.
16116 (setq subscribed (= (following-char) ?:)
16117 group (symbol-name symbol)
16120 ;; If the line ends here, this is clearly a buggy line, so
16121 ;; we put point a the beginning of line and let the cond
16122 ;; below do the error handling.
16123 (beginning-of-line)
16124 ;; We skip to the beginning of the ranges.
16125 (skip-chars-forward "!: \t"))
16126 ;; We are now at the beginning of the list of read articles.
16127 ;; We read them range by range.
16130 ((looking-at "[0-9]+")
16131 ;; We narrow and read a number instead of buffer-substring/
16132 ;; string-to-int because it's faster. narrow/widen is
16133 ;; faster than save-restriction/narrow, and save-restriction
16134 ;; produces a garbage object.
16136 (narrow-to-region (match-beginning 0) (match-end 0))
16139 ;; If the next character is a dash, then this is a range.
16140 (if (= (following-char) ?-)
16142 ;; We read the upper bound of the range.
16144 (if (not (looking-at "[0-9]+"))
16145 ;; This is a buggy line, by we pretend that
16146 ;; it's kinda OK. Perhaps the user should be
16148 (setq reads (cons num1 reads))
16153 (narrow-to-region (match-beginning 0)
16158 ;; It was just a simple number, so we add it to the
16160 (setq reads (cons num1 reads)))
16161 ;; If the next char in ?\n, then we have reached the end
16162 ;; of the line and return nil.
16163 (/= (following-char) ?\n))
16164 ((= (following-char) ?\n)
16165 ;; End of line, so we end.
16168 ;; Not numbers and not eol, so this might be a buggy
16171 ;; If it was eob instead of ?\n, we allow it.
16173 ;; The line was buggy.
16175 (gnus-message 3 "Mangled line: %s"
16176 (buffer-substring (gnus-point-at-bol)
16177 (gnus-point-at-eol)))
16181 ;; Skip past ", ". Spaces are illegal in these ranges, but
16182 ;; we allow them, because it's a common mistake to put a
16183 ;; space after the comma.
16184 (skip-chars-forward ", "))
16186 ;; We have already read .newsrc.eld, so we gently update the
16187 ;; data in the hash table with the information we have just
16190 (let ((info (gnus-get-info group))
16193 ;; There is an entry for this file in the alist.
16195 (gnus-info-set-read info (nreverse reads))
16196 ;; We update the level very gently. In fact, we
16197 ;; only change it if there's been a status change
16198 ;; from subscribed to unsubscribed, or vice versa.
16199 (setq level (gnus-info-level info))
16200 (cond ((and (<= level gnus-level-subscribed)
16202 (setq level (if reads
16203 gnus-level-default-unsubscribed
16204 (1+ gnus-level-default-unsubscribed))))
16205 ((and (> level gnus-level-subscribed) subscribed)
16206 (setq level gnus-level-default-subscribed)))
16207 (gnus-info-set-level info level))
16208 ;; This is a new group.
16209 (setq info (list group
16211 gnus-level-default-subscribed
16213 (1+ gnus-level-subscribed)
16214 gnus-level-default-unsubscribed))
16215 (nreverse reads))))
16216 (setq newsrc (cons info newsrc))))))
16219 (setq newsrc (nreverse newsrc))
16221 (if (not already-read)
16223 ;; We now have two newsrc lists - `newsrc', which is what we
16224 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16225 ;; what we've read from .newsrc.eld. We have to merge these
16226 ;; lists. We do this by "attaching" any (foreign) groups in the
16227 ;; gnus-newsrc-alist to the (native) group that precedes them.
16228 (let ((rc (cdr gnus-newsrc-alist))
16229 (prev gnus-newsrc-alist)
16232 (or (null (nth 4 (car rc))) ; It's a native group.
16233 (assoc (caar rc) newsrc) ; It's already in the alist.
16234 (if (setq entry (assoc (caar prev) newsrc))
16235 (setcdr (setq mentry (memq entry newsrc))
16236 (cons (car rc) (cdr mentry)))
16237 (setq newsrc (cons (car rc) newsrc))))
16241 (setq gnus-newsrc-alist newsrc)
16242 ;; We make the newsrc hashtb.
16243 (gnus-make-hashtable-from-newsrc-alist)
16245 ;; Finally, if we read some options lines, we parse them.
16246 (or (string= gnus-newsrc-options "")
16247 (gnus-newsrc-parse-options gnus-newsrc-options))))
16249 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16250 ;; The return value will be a list on the form
16251 ;; ((regexp1 . ignore)
16252 ;; (regexp2 . subscribe)...)
16253 ;; When handling new newsgroups, groups that match a `ignore' regexp
16254 ;; will be ignored, and groups that match a `subscribe' regexp will be
16255 ;; subscribed. A line like
16256 ;; options -n !all rec.all
16257 ;; will lead to a list that looks like
16258 ;; (("^rec\\..+" . subscribe)
16259 ;; ("^.+" . ignore))
16260 ;; So all "rec.*" groups will be subscribed, while all the other
16261 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16262 ;; different from "options -n rec.all !all".
16263 (defun gnus-newsrc-parse-options (options)
16266 (gnus-set-work-buffer)
16267 (insert (regexp-quote options))
16268 ;; First we treat all continuation lines.
16269 (goto-char (point-min))
16270 (while (re-search-forward "\n[ \t]+" nil t)
16271 (replace-match " " t t))
16272 ;; Then we transform all "all"s into ".+"s.
16273 (goto-char (point-min))
16274 (while (re-search-forward "\\ball\\b" nil t)
16275 (replace-match ".+" t t))
16276 (goto-char (point-min))
16277 ;; We remove all other options than the "-n" ones.
16278 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16279 (replace-match " ")
16281 (goto-char (point-min))
16283 ;; We are only interested in "options -n" lines - we
16284 ;; ignore the other option lines.
16285 (while (re-search-forward "[ \t]-n" nil t)
16287 (or (save-excursion
16288 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16290 (gnus-point-at-eol)))
16291 ;; Search for all "words"...
16292 (while (re-search-forward "[^ \t,\n]+" eol t)
16293 (if (= (char-after (match-beginning 0)) ?!)
16294 ;; If the word begins with a bang (!), this is a "not"
16295 ;; spec. We put this spec (minus the bang) and the
16296 ;; symbol `ignore' into the list.
16297 (setq out (cons (cons (concat
16298 "^" (buffer-substring
16299 (1+ (match-beginning 0))
16302 ;; There was no bang, so this is a "yes" spec.
16303 (setq out (cons (cons (concat "^" (match-string 0))
16304 'subscribe) out)))))
16306 (setq gnus-newsrc-options-n out))))
16308 (defun gnus-save-newsrc-file (&optional force)
16309 "Save .newsrc file."
16310 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16311 ;; from the variable gnus-newsrc-alist.
16312 (when (and (or gnus-newsrc-alist gnus-killed-list)
16313 gnus-current-startup-file)
16315 (if (and (or gnus-use-dribble-file gnus-slave)
16317 (or (not gnus-dribble-buffer)
16318 (not (buffer-name gnus-dribble-buffer))
16319 (zerop (save-excursion
16320 (set-buffer gnus-dribble-buffer)
16322 (gnus-message 4 "(No changes need to be saved)")
16323 (run-hooks 'gnus-save-newsrc-hook)
16325 (gnus-slave-save-newsrc)
16327 (when gnus-save-newsrc-file
16328 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16329 (gnus-gnus-to-newsrc-format)
16330 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16331 ;; Save .newsrc.eld.
16332 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16333 (make-local-variable 'version-control)
16334 (setq version-control 'never)
16335 (setq buffer-file-name
16336 (concat gnus-current-startup-file ".eld"))
16337 (gnus-add-current-to-buffer-list)
16338 (buffer-disable-undo (current-buffer))
16340 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16341 (gnus-gnus-to-quick-newsrc-format)
16342 (run-hooks 'gnus-save-quick-newsrc-hook)
16344 (kill-buffer (current-buffer))
16346 5 "Saving %s.eld...done" gnus-current-startup-file))
16347 (gnus-dribble-delete-file)))))
16349 (defun gnus-gnus-to-quick-newsrc-format ()
16350 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16351 (insert ";; Gnus startup file.\n")
16352 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16353 (insert ";; to read .newsrc.\n")
16354 (insert "(setq gnus-newsrc-file-version "
16355 (prin1-to-string gnus-version) ")\n")
16357 (if gnus-save-killed-list gnus-variable-list
16358 ;; Remove the `gnus-killed-list' from the list of variables
16359 ;; to be saved, if required.
16360 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16361 ;; Peel off the "dummy" group.
16362 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16364 ;; Insert the variables into the file.
16366 (when (and (boundp (setq variable (pop variables)))
16367 (symbol-value variable))
16368 (insert "(setq " (symbol-name variable) " '")
16369 (prin1 (symbol-value variable) (current-buffer))
16372 (defun gnus-gnus-to-newsrc-format ()
16373 ;; Generate and save the .newsrc file.
16375 (set-buffer (create-file-buffer gnus-current-startup-file))
16376 (let ((newsrc (cdr gnus-newsrc-alist))
16377 (standard-output (current-buffer))
16378 info ranges range method)
16379 (setq buffer-file-name gnus-current-startup-file)
16380 (buffer-disable-undo (current-buffer))
16383 (if gnus-newsrc-options (insert gnus-newsrc-options))
16384 ;; Write subscribed and unsubscribed.
16385 (while (setq info (pop newsrc))
16386 ;; Don't write foreign groups to .newsrc.
16387 (when (or (null (setq method (gnus-info-method info)))
16388 (equal method "native")
16389 (gnus-server-equal method gnus-select-method))
16390 (insert (gnus-info-group info)
16391 (if (> (gnus-info-level info) gnus-level-subscribed)
16393 (when (setq ranges (gnus-info-read info))
16395 (if (not (listp (cdr ranges)))
16396 (if (= (car ranges) (cdr ranges))
16397 (princ (car ranges))
16398 (princ (car ranges))
16400 (princ (cdr ranges)))
16401 (while (setq range (pop ranges))
16402 (if (or (atom range) (= (car range) (cdr range)))
16403 (princ (or (and (atom range) range) (car range)))
16404 (princ (car range))
16406 (princ (cdr range)))
16407 (if ranges (insert ",")))))
16409 (make-local-variable 'version-control)
16410 (setq version-control 'never)
16411 ;; It has been reported that sometime the modtime on the .newsrc
16412 ;; file seems to be off. We really do want to overwrite it, so
16413 ;; we clear the modtime here before saving. It's a bit odd,
16415 ;; sometimes the modtime clear isn't sufficient. most brute force:
16416 ;; delete the silly thing entirely first. but this fails to provide
16417 ;; such niceties as .newsrc~ creation.
16418 (if gnus-modtime-botch
16419 (delete-file gnus-startup-file)
16420 (clear-visited-file-modtime))
16421 (run-hooks 'gnus-save-standard-newsrc-hook)
16423 (kill-buffer (current-buffer)))))
16427 ;;; Slave functions.
16430 (defun gnus-slave-save-newsrc ()
16432 (set-buffer gnus-dribble-buffer)
16434 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16435 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16437 (defun gnus-master-read-slave-newsrc ()
16440 (file-name-directory gnus-current-startup-file)
16444 (file-name-nondirectory gnus-current-startup-file)
16448 (if (not slave-files)
16449 () ; There are no slave files to read.
16450 (gnus-message 7 "Reading slave newsrcs...")
16452 (set-buffer (get-buffer-create " *gnus slave*"))
16453 (buffer-disable-undo (current-buffer))
16455 (sort (mapcar (lambda (file)
16456 (list (nth 5 (file-attributes file)) file))
16459 (or (< (caar f1) (caar f2))
16460 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16463 (setq file (nth 1 (car slave-files)))
16464 (insert-file-contents file)
16465 (if (condition-case ()
16467 (eval-buffer (current-buffer))
16470 (gnus-message 3 "Possible error in %s" file)
16474 (or gnus-slave ; Slaves shouldn't delete these files.
16478 (setq slave-files (cdr slave-files))))
16479 (gnus-message 7 "Reading slave newsrcs...done"))))
16483 ;;; Group description.
16486 (defun gnus-read-all-descriptions-files ()
16487 (let ((methods (cons gnus-select-method
16489 (when gnus-message-archive-method
16491 gnus-secondary-select-methods))))
16493 (gnus-read-descriptions-file (car methods))
16494 (setq methods (cdr methods)))
16497 (defun gnus-read-descriptions-file (&optional method)
16498 (let ((method (or method gnus-select-method)))
16499 (when (stringp method)
16500 (setq method (gnus-server-to-method method)))
16501 ;; We create the hashtable whether we manage to read the desc file
16502 ;; to avoid trying to re-read after a failed read.
16503 (or gnus-description-hashtb
16504 (setq gnus-description-hashtb
16505 (gnus-make-hashtable (length gnus-active-hashtb))))
16506 ;; Mark this method's desc file as read.
16507 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16508 gnus-description-hashtb)
16510 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16512 ((not (gnus-check-server method))
16513 (gnus-message 1 "Couldn't open server")
16515 ((not (gnus-request-list-newsgroups method))
16516 (gnus-message 1 "Couldn't read newsgroups descriptions")
16522 (set-buffer nntp-server-buffer)
16523 (goto-char (point-min))
16524 (if (or (search-forward "\n.\n" nil t)
16525 (goto-char (point-max)))
16527 (beginning-of-line)
16528 (narrow-to-region (point-min) (point))))
16529 (goto-char (point-min))
16530 (while (not (eobp))
16531 ;; If we get an error, we set group to 0, which is not a
16535 (let ((obarray gnus-description-hashtb))
16536 ;; Group is set to a symbol interned in this
16538 (read nntp-server-buffer))
16540 (skip-chars-forward " \t")
16541 ;; ... which leads to this line being effectively ignored.
16542 (and (symbolp group)
16543 (set group (buffer-substring
16544 (point) (progn (end-of-line) (point)))))
16545 (forward-line 1))))
16546 (gnus-message 5 "Reading descriptions file...done")
16549 (defun gnus-group-get-description (group)
16550 "Get the description of a group by sending XGTITLE to the server."
16551 (when (gnus-request-group-description group)
16553 (set-buffer nntp-server-buffer)
16554 (goto-char (point-min))
16555 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16556 (match-string 1)))))
16560 ;;; Buffering of read articles.
16563 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16564 (defvar gnus-backlog-articles nil)
16565 (defvar gnus-backlog-hashtb nil)
16567 (defun gnus-backlog-buffer ()
16568 "Return the backlog buffer."
16569 (or (get-buffer gnus-backlog-buffer)
16571 (set-buffer (get-buffer-create gnus-backlog-buffer))
16572 (buffer-disable-undo (current-buffer))
16573 (setq buffer-read-only t)
16574 (gnus-add-current-to-buffer-list)
16575 (get-buffer gnus-backlog-buffer))))
16577 (defun gnus-backlog-setup ()
16578 "Initialize backlog variables."
16579 (unless gnus-backlog-hashtb
16580 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16582 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16584 (defun gnus-backlog-shutdown ()
16585 "Clear all backlog variables and buffers."
16586 (when (get-buffer gnus-backlog-buffer)
16587 (kill-buffer gnus-backlog-buffer))
16588 (setq gnus-backlog-hashtb nil
16589 gnus-backlog-articles nil))
16591 (defun gnus-backlog-enter-article (group number buffer)
16592 (gnus-backlog-setup)
16593 (let ((ident (intern (concat group ":" (int-to-string number))
16594 gnus-backlog-hashtb))
16596 (if (memq ident gnus-backlog-articles)
16597 () ; It's already kept.
16598 ;; Remove the oldest article, if necessary.
16599 (and (numberp gnus-keep-backlog)
16600 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16601 (gnus-backlog-remove-oldest-article))
16602 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16603 ;; Insert the new article.
16605 (set-buffer (gnus-backlog-buffer))
16606 (let (buffer-read-only)
16607 (goto-char (point-max))
16608 (or (bolp) (insert "\n"))
16610 (insert-buffer-substring buffer)
16611 ;; Tag the beginning of the article with the ident.
16612 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16614 (defun gnus-backlog-remove-oldest-article ()
16616 (set-buffer (gnus-backlog-buffer))
16617 (goto-char (point-min))
16618 (if (zerop (buffer-size))
16619 () ; The buffer is empty.
16620 (let ((ident (get-text-property (point) 'gnus-backlog))
16622 ;; Remove the ident from the list of articles.
16624 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16625 ;; Delete the article itself.
16627 (point) (next-single-property-change
16628 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16630 (defun gnus-backlog-request-article (group number buffer)
16631 (when (numberp number)
16632 (gnus-backlog-setup)
16633 (let ((ident (intern (concat group ":" (int-to-string number))
16634 gnus-backlog-hashtb))
16636 (when (memq ident gnus-backlog-articles)
16637 ;; It was in the backlog.
16639 (set-buffer (gnus-backlog-buffer))
16640 (if (not (setq beg (text-property-any
16641 (point-min) (point-max) 'gnus-backlog
16643 ;; It wasn't in the backlog after all.
16645 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16646 ;; Find the end (i. e., the beginning of the next article).
16648 (next-single-property-change
16649 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16650 (let ((buffer-read-only nil))
16652 (insert-buffer-substring gnus-backlog-buffer beg end)
16655 ;; Allow redefinition of Gnus functions.
16657 (gnus-ems-redefine)
16661 ;;; gnus.el ends here