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))
36 (eval-when-compile (require 'cl))
38 ;; Site dependent variables. These variables should be defined in
41 (defvar gnus-default-nntp-server nil
42 "Specify a default NNTP server.
43 This variable should be defined in paths.el, and should never be set
45 If you want to change servers, you should use `gnus-select-method'.
46 See the documentation to that variable.")
48 (defvar gnus-backup-default-subscribed-newsgroups
49 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
50 "Default default new newsgroups the first time Gnus is run.
51 Should be set in paths.el, and shouldn't be touched by the user.")
53 (defvar gnus-local-domain nil
54 "Local domain name without a host name.
55 The DOMAINNAME environment variable is used instead if it is defined.
56 If the `system-name' function returns the full Internet name, there is
57 no need to set this variable.")
59 (defvar gnus-local-organization nil
60 "String with a description of what organization (if any) the user belongs to.
61 The ORGANIZATION environment variable is used instead if it is defined.
62 If this variable contains a function, this function will be called
63 with the current newsgroup name as the argument. The function should
66 In any case, if the string (either in the variable, in the environment
67 variable, or returned by the function) is a file name, the contents of
68 this file will be used as the organization.")
70 ;; Customization variables
72 ;; Don't touch this variable.
73 (defvar gnus-nntp-service "nntp"
74 "*NNTP service name (\"nntp\" or 119).
75 This is an obsolete variable, which is scarcely used. If you use an
76 nntp server for your newsgroup and want to change the port number
77 used to 899, you would say something along these lines:
79 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
81 (defvar gnus-nntpserver-file "/etc/nntpserver"
82 "*A file with only the name of the nntp server in it.")
84 ;; This function is used to check both the environment variable
85 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
86 ;; an nntp server name default.
87 (defun gnus-getenv-nntpserver ()
88 (or (getenv "NNTPSERVER")
89 (and (file-readable-p gnus-nntpserver-file)
91 (set-buffer (get-buffer-create " *gnus nntp*"))
92 (buffer-disable-undo (current-buffer))
93 (insert-file-contents gnus-nntpserver-file)
94 (let ((name (buffer-string)))
96 (if (string-match "^[ \t\n]*$" name)
99 (kill-buffer (current-buffer))))))))
101 (defvar gnus-select-method
103 (list 'nntp (or (condition-case ()
104 (gnus-getenv-nntpserver)
106 (if (and gnus-default-nntp-server
107 (not (string= gnus-default-nntp-server "")))
108 gnus-default-nntp-server)
110 (if (or (null gnus-nntp-service)
111 (equal gnus-nntp-service "nntp"))
113 (list gnus-nntp-service)))
114 "*Default method for selecting a newsgroup.
115 This variable should be a list, where the first element is how the
116 news is to be fetched, the second is the address.
118 For instance, if you want to get your news via NNTP from
119 \"flab.flab.edu\", you could say:
121 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
123 If you want to use your local spool, say:
125 (setq gnus-select-method (list 'nnspool (system-name)))
127 If you use this variable, you must set `gnus-nntp-server' to nil.
129 There is a lot more to know about select methods and virtual servers -
130 see the manual for details.")
132 (defvar gnus-message-archive-method
133 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
134 (nnfolder-active-file "~/Mail/archive/active")
135 (nnfolder-get-new-mail nil)
136 (nnfolder-inhibit-expiry t))
137 "*Method used for archiving messages you've sent.
138 This should be a mail method.")
140 (defvar gnus-refer-article-method nil
141 "*Preferred method for fetching an article by Message-ID.
142 If you are reading news from the local spool (with nnspool), fetching
143 articles by Message-ID is painfully slow. By setting this method to an
144 nntp method, you might get acceptable results.
146 The value of this variable must be a valid select method as discussed
147 in the documentation of `gnus-select-method'.")
149 (defvar gnus-secondary-select-methods nil
150 "*A list of secondary methods that will be used for reading news.
151 This is a list where each element is a complete select method (see
152 `gnus-select-method').
154 If, for instance, you want to read your mail with the nnml backend,
155 you could set this variable:
157 (setq gnus-secondary-select-methods '((nnml \"\")))")
159 (defvar gnus-secondary-servers nil
160 "*List of NNTP servers that the user can choose between interactively.
161 To make Gnus query you for a server, you have to give `gnus' a
162 non-numeric prefix - `C-u M-x gnus', in short.")
164 (defvar gnus-nntp-server nil
165 "*The name of the host running the NNTP server.
166 This variable is semi-obsolete. Use the `gnus-select-method'
169 (defvar gnus-startup-file "~/.newsrc"
170 "*Your `.newsrc' file.
171 `.newsrc-SERVER' will be used instead if that exists.")
173 (defvar gnus-init-file "~/.gnus"
174 "*Your Gnus elisp startup file.
175 If a file with the .el or .elc suffixes exist, it will be read
178 (defvar gnus-group-faq-directory
179 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
180 "/ftp@sunsite.auc.dk:/pub/usenet/"
181 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
182 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
183 "/ftp@rtfm.mit.edu:/pub/usenet/"
184 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
185 "/ftp@ftp.sunet.se:/pub/usenet/"
186 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
187 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
188 "/ftp@ftp.hk.super.net:/mirror/faqs/")
189 "*Directory where the group FAQs are stored.
190 This will most commonly be on a remote machine, and the file will be
193 This variable can also be a list of directories. In that case, the
194 first element in the list will be used by default, and the others will
195 be used as backup sites.
197 Note that Gnus uses an aol machine as the default directory. If this
198 feels fundamentally unclean, just think of it as a way to finally get
199 something of value back from them.
201 If the default site is too slow, try one of these:
203 North America: mirrors.aol.com /pub/rtfm/usenet
204 ftp.seas.gwu.edu /pub/rtfm
205 rtfm.mit.edu /pub/usenet
206 Europe: ftp.uni-paderborn.de /pub/FAQ
207 src.doc.ic.ac.uk /usenet/news-FAQS
208 ftp.sunet.se /pub/usenet
209 sunsite.auc.dk /pub/usenet
210 Asia: nctuccca.edu.tw /USENET/FAQ
211 hwarang.postech.ac.kr /pub/usenet
212 ftp.hk.super.net /mirror/faqs")
214 (defvar gnus-group-archive-directory
215 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
216 "*The address of the (ding) archives.")
218 (defvar gnus-group-recent-archive-directory
219 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
220 "*The address of the most recent (ding) articles.")
222 (defvar gnus-default-subscribed-newsgroups nil
223 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
224 It should be a list of strings.
225 If it is `t', Gnus will not do anything special the first time it is
226 started; it'll just use the normal newsgroups subscription methods.")
228 (defvar gnus-use-cross-reference t
229 "*Non-nil means that cross referenced articles will be marked as read.
230 If nil, ignore cross references. If t, mark articles as read in
231 subscribed newsgroups. If neither t nor nil, mark as read in all
234 (defvar gnus-single-article-buffer t
235 "*If non-nil, display all articles in the same buffer.
236 If nil, each group will get its own article buffer.")
238 (defvar gnus-use-dribble-file t
239 "*Non-nil means that Gnus will use a dribble file to store user updates.
240 If Emacs should crash without saving the .newsrc files, complete
241 information can be restored from the dribble file.")
243 (defvar gnus-dribble-directory nil
244 "*The directory where dribble files will be saved.
245 If this variable is nil, the directory where the .newsrc files are
246 saved will be used.")
248 (defvar gnus-asynchronous nil
249 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
251 (defvar gnus-kill-summary-on-exit t
252 "*If non-nil, kill the summary buffer when you exit from it.
253 If nil, the summary will become a \"*Dead Summary*\" buffer, and
254 it will be killed sometime later.")
256 (defvar gnus-large-newsgroup 200
257 "*The number of articles which indicates a large newsgroup.
258 If the number of articles in a newsgroup is greater than this value,
259 confirmation is required for selecting the newsgroup.")
261 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
262 (defvar gnus-no-groups-message "No news is horrible news"
263 "*Message displayed by Gnus when no groups are available.")
265 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
266 "*Non-nil means that the default name of a file to save articles in is the group name.
267 If it's nil, the directory form of the group name is used instead.
269 If this variable is a list, and the list contains the element
270 `not-score', long file names will not be used for score files; if it
271 contains the element `not-save', long file names will not be used for
272 saving; and if it contains the element `not-kill', long file names
273 will not be used for kill files.")
275 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
276 "*Name of the directory articles will be saved in (default \"~/News\").
277 Initialized from the SAVEDIR environment variable.")
279 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
280 "*Name of the directory where kill files will be stored (default \"~/News\").
281 Initialized from the SAVEDIR environment variable.")
283 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
284 "*A function to save articles in your favorite format.
285 The function must be interactively callable (in other words, it must
286 be an Emacs command).
288 Gnus provides the following functions:
290 * gnus-summary-save-in-rmail (Rmail format)
291 * gnus-summary-save-in-mail (Unix mail format)
292 * gnus-summary-save-in-folder (MH folder)
293 * gnus-summary-save-in-file (article format).
294 * gnus-summary-save-in-vm (use VM's folder format).")
296 (defvar gnus-prompt-before-saving 'always
297 "*This variable says how much prompting is to be done when saving articles.
298 If it is nil, no prompting will be done, and the articles will be
299 saved to the default files. If this variable is `always', each and
300 every article that is saved will be preceded by a prompt, even when
301 saving large batches of articles. If this variable is neither nil not
302 `always', there the user will be prompted once for a file name for
303 each invocation of the saving commands.")
305 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
306 "*A function generating a file name to save articles in Rmail format.
307 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
309 (defvar gnus-mail-save-name (function gnus-plain-save-name)
310 "*A function generating a file name to save articles in Unix mail format.
311 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
313 (defvar gnus-folder-save-name (function gnus-folder-save-name)
314 "*A function generating a file name to save articles in MH folder.
315 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
317 (defvar gnus-file-save-name (function gnus-numeric-save-name)
318 "*A function generating a file name to save articles in article format.
319 The function is called with NEWSGROUP, HEADERS, and optional
322 (defvar gnus-split-methods
323 '((gnus-article-archive-name))
324 "*Variable used to suggest where articles are to be saved.
325 For instance, if you would like to save articles related to Gnus in
326 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
327 you could set this variable to something like:
329 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
330 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
332 This variable is an alist where the where the key is the match and the
333 value is a list of possible files to save in if the match is non-nil.
335 If the match is a string, it is used as a regexp match on the
336 article. If the match is a symbol, that symbol will be funcalled
337 from the buffer of the article to be saved with the newsgroup as the
338 parameter. If it is a list, it will be evaled in the same buffer.
340 If this form or function returns a string, this string will be used as
341 a possible file name; and if it returns a non-nil list, that list will
342 be used as possible file names.")
344 (defvar gnus-move-split-methods nil
345 "*Variable used to suggest where articles are to be moved to.
346 It uses the same syntax as the `gnus-split-methods' variable.")
348 (defvar gnus-save-score nil
349 "*If non-nil, save group scoring info.")
351 (defvar gnus-use-adaptive-scoring nil
352 "*If non-nil, use some adaptive scoring scheme.")
354 (defvar gnus-use-cache nil
355 "*If nil, Gnus will ignore the article cache.
356 If `passive', it will allow entering (and reading) articles
357 explicitly entered into the cache. If anything else, use the
358 cache to the full extent of the law.")
360 (defvar gnus-use-trees nil
361 "*If non-nil, display a thread tree buffer.")
363 (defvar gnus-use-grouplens nil
364 "*If non-nil, use GroupLens ratings.")
366 (defvar gnus-keep-backlog nil
367 "*If non-nil, Gnus will keep read articles for later re-retrieval.
368 If it is a number N, then Gnus will only keep the last N articles
369 read. If it is neither nil nor a number, Gnus will keep all read
370 articles. This is not a good idea.")
372 (defvar gnus-use-nocem nil
373 "*If non-nil, Gnus will read NoCeM cancel messages.")
375 (defvar gnus-use-demon nil
376 "If non-nil, Gnus might use some demons.")
378 (defvar gnus-use-scoring t
379 "*If non-nil, enable scoring.")
381 (defvar gnus-use-picons nil
382 "*If non-nil, display picons.")
384 (defvar gnus-fetch-old-headers nil
385 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
386 If an unread article in the group refers to an older, already read (or
387 just marked as read) article, the old article will not normally be
388 displayed in the Summary buffer. If this variable is non-nil, Gnus
389 will attempt to grab the headers to the old articles, and thereby
390 build complete threads. If it has the value `some', only enough
391 headers to connect otherwise loose threads will be displayed.
392 This variable can also be a number. In that case, no more than that
393 number of old headers will be fetched.
395 The server has to support NOV for any of this to work.")
398 ;(defvar gnus-visual t
399 ; "*If non-nil, will do various highlighting.
400 ;If nil, no mouse highlights (or any other highlights) will be
401 ;performed. This might speed up Gnus some when generating large group
402 ;and summary buffers.")
404 (defvar gnus-novice-user t
405 "*Non-nil means that you are a usenet novice.
406 If non-nil, verbose messages may be displayed and confirmations may be
409 (defvar gnus-expert-user nil
410 "*Non-nil means that you will never be asked for confirmation about anything.
411 And that means *anything*.")
413 (defvar gnus-verbose 7
414 "*Integer that says how verbose Gnus should be.
415 The higher the number, the more messages Gnus will flash to say what
416 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
417 display most important messages; and at ten, Gnus will keep on
418 jabbering all the time.")
420 (defvar gnus-keep-same-level nil
421 "*Non-nil means that the next newsgroup after the current will be on the same level.
422 When you type, for instance, `n' after reading the last article in the
423 current newsgroup, you will go to the next newsgroup. If this variable
424 is nil, the next newsgroup will be the next from the group
426 If this variable is non-nil, Gnus will either put you in the
427 next newsgroup with the same level, or, if no such newsgroup is
428 available, the next newsgroup with the lowest possible level higher
429 than the current level.
430 If this variable is `best', Gnus will make the next newsgroup the one
431 with the best level.")
433 (defvar gnus-summary-make-false-root 'adopt
434 "*nil means that Gnus won't gather loose threads.
435 If the root of a thread has expired or been read in a previous
436 session, the information necessary to build a complete thread has been
437 lost. Instead of having many small sub-threads from this original thread
438 scattered all over the summary buffer, Gnus can gather them.
440 If non-nil, Gnus will try to gather all loose sub-threads from an
441 original thread into one large thread.
443 If this variable is non-nil, it should be one of `none', `adopt',
446 If this variable is `none', Gnus will not make a false root, but just
447 present the sub-threads after another.
448 If this variable is `dummy', Gnus will create a dummy root that will
449 have all the sub-threads as children.
450 If this variable is `adopt', Gnus will make one of the \"children\"
451 the parent and mark all the step-children as such.
452 If this variable is `empty', the \"children\" are printed with empty
453 subject fields. (Or rather, they will be printed with a string
454 given by the `gnus-summary-same-subject' variable.)")
456 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
457 "*A regexp to match subjects to be excluded from loose thread gathering.
458 As loose thread gathering is done on subjects only, that means that
459 there can be many false gatherings performed. By rooting out certain
460 common subjects, gathering might become saner.")
462 (defvar gnus-summary-gather-subject-limit nil
463 "*Maximum length of subject comparisons when gathering loose threads.
464 Use nil to compare full subjects. Setting this variable to a low
465 number will help gather threads that have been corrupted by
466 newsreaders chopping off subject lines, but it might also mean that
467 unrelated articles that have subject that happen to begin with the
468 same few characters will be incorrectly gathered.
470 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
471 comparing subjects.")
473 (defvar gnus-simplify-ignored-prefixes nil
474 "*Regexp, matches for which are removed from subject lines when simplifying.")
476 (defvar gnus-build-sparse-threads nil
477 "*If non-nil, fill in the gaps in threads.
478 If `some', only fill in the gaps that are needed to tie loose threads
479 together. If `more', fill in all leaf nodes that Gnus can find. If
480 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
482 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
483 "Function used for gathering loose threads.
484 There are two pre-defined functions: `gnus-gather-threads-by-subject',
485 which only takes Subjects into consideration; and
486 `gnus-gather-threads-by-references', which compared the References
487 headers of the articles to find matches.")
489 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
490 (defvar gnus-summary-same-subject ""
491 "*String indicating that the current article has the same subject as the previous.
492 This variable will only be used if the value of
493 `gnus-summary-make-false-root' is `empty'.")
495 (defvar gnus-summary-goto-unread t
496 "*If non-nil, marking commands will go to the next unread article.
497 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
498 whether it is read or not.")
500 (defvar gnus-group-goto-unread t
501 "*If non-nil, movement commands will go to the next unread and subscribed group.")
503 (defvar gnus-goto-next-group-when-activating t
504 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
506 (defvar gnus-check-new-newsgroups t
507 "*Non-nil means that Gnus will add new newsgroups at startup.
508 If this variable is `ask-server', Gnus will ask the server for new
509 groups since the last time it checked. This means that the killed list
510 is no longer necessary, so you could set `gnus-save-killed-list' to
513 A variant is to have this variable be a list of select methods. Gnus
514 will then use the `ask-server' method on all these select methods to
515 query for new groups from all those servers.
518 (setq gnus-check-new-newsgroups
519 '((nntp \"some.server\") (nntp \"other.server\")))
521 If this variable is nil, then you have to tell Gnus explicitly to
522 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
524 (defvar gnus-check-bogus-newsgroups nil
525 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
526 If this variable is nil, then you have to tell Gnus explicitly to
527 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
529 (defvar gnus-read-active-file t
530 "*Non-nil means that Gnus will read the entire active file at startup.
531 If this variable is nil, Gnus will only know about the groups in your
534 If this variable is `some', Gnus will try to only read the relevant
535 parts of the active file from the server. Not all servers support
536 this, and it might be quite slow with other servers, but this should
537 generally be faster than both the t and nil value.
539 If you set this variable to nil or `some', you probably still want to
540 be told about new newsgroups that arrive. To do that, set
541 `gnus-check-new-newsgroups' to `ask-server'. This may not work
542 properly with all servers.")
544 (defvar gnus-level-subscribed 5
545 "*Groups with levels less than or equal to this variable are subscribed.")
547 (defvar gnus-level-unsubscribed 7
548 "*Groups with levels less than or equal to this variable are unsubscribed.
549 Groups with levels less than `gnus-level-subscribed', which should be
550 less than this variable, are subscribed.")
552 (defvar gnus-level-zombie 8
553 "*Groups with this level are zombie groups.")
555 (defvar gnus-level-killed 9
556 "*Groups with this level are killed.")
558 (defvar gnus-level-default-subscribed 3
559 "*New subscribed groups will be subscribed at this level.")
561 (defvar gnus-level-default-unsubscribed 6
562 "*New unsubscribed groups will be unsubscribed at this level.")
564 (defvar gnus-activate-level (1+ gnus-level-subscribed)
565 "*Groups higher than this level won't be activated on startup.
566 Setting this variable to something log might save lots of time when
567 you have many groups that you aren't interested in.")
569 (defvar gnus-activate-foreign-newsgroups 4
570 "*If nil, Gnus will not check foreign newsgroups at startup.
571 If it is non-nil, it should be a number between one and nine. Foreign
572 newsgroups that have a level lower or equal to this number will be
573 activated on startup. For instance, if you want to active all
574 subscribed newsgroups, but not the rest, you'd set this variable to
575 `gnus-level-subscribed'.
577 If you subscribe to lots of newsgroups from different servers, startup
578 might take a while. By setting this variable to nil, you'll save time,
579 but you won't be told how many unread articles there are in the
582 (defvar gnus-save-newsrc-file t
583 "*Non-nil means that Gnus will save the `.newsrc' file.
584 Gnus always saves its own startup file, which is called
585 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
586 be readily understood by other newsreaders. If you don't plan on
587 using other newsreaders, set this variable to nil to save some time on
590 (defvar gnus-save-killed-list t
591 "*If non-nil, save the list of killed groups to the startup file.
592 If you set this variable to nil, you'll save both time (when starting
593 and quitting) and space (both memory and disk), but it will also mean
594 that Gnus has no record of which groups are new and which are old, so
595 the automatic new newsgroups subscription methods become meaningless.
597 You should always set `gnus-check-new-newsgroups' to `ask-server' or
598 nil if you set this variable to nil.")
600 (defvar gnus-interactive-catchup t
601 "*If non-nil, require your confirmation when catching up a group.")
603 (defvar gnus-interactive-post t
604 "*If non-nil, group name will be asked for when posting.")
606 (defvar gnus-interactive-exit t
607 "*If non-nil, require your confirmation when exiting Gnus.")
609 (defvar gnus-kill-killed t
610 "*If non-nil, Gnus will apply kill files to already killed articles.
611 If it is nil, Gnus will never apply kill files to articles that have
612 already been through the scoring process, which might very well save lots
615 (defvar gnus-extract-address-components 'gnus-extract-address-components
616 "*Function for extracting address components from a From header.
617 Two pre-defined function exist: `gnus-extract-address-components',
618 which is the default, quite fast, and too simplistic solution, and
619 `mail-extract-address-components', which works much better, but is
622 (defvar gnus-summary-default-score 0
623 "*Default article score level.
624 If this variable is nil, scoring will be disabled.")
626 (defvar gnus-summary-zcore-fuzz 0
627 "*Fuzziness factor for the zcore in the summary buffer.
628 Articles with scores closer than this to `gnus-summary-default-score'
629 will not be marked.")
631 (defvar gnus-simplify-subject-fuzzy-regexp nil
632 "*Strings to be removed when doing fuzzy matches.
633 This can either be a regular expression or list of regular expressions
634 that will be removed from subject strings if fuzzy subject
635 simplification is selected.")
637 (defvar gnus-permanently-visible-groups nil
638 "*Regexp to match groups that should always be listed in the group buffer.
639 This means that they will still be listed when there are no unread
640 articles in the groups.")
642 (defvar gnus-list-groups-with-ticked-articles t
643 "*If non-nil, list groups that have only ticked articles.
644 If nil, only list groups that have unread articles.")
646 (defvar gnus-group-default-list-level gnus-level-subscribed
647 "*Default listing level.
648 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
650 (defvar gnus-group-use-permanent-levels nil
651 "*If non-nil, once you set a level, Gnus will use this level.")
653 (defvar gnus-group-list-inactive-groups t
654 "*If non-nil, inactive groups will be listed.")
656 (defvar gnus-show-mime nil
657 "*If non-nil, do mime processing of articles.
658 The articles will simply be fed to the function given by
659 `gnus-show-mime-method'.")
661 (defvar gnus-strict-mime t
662 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
664 (defvar gnus-show-mime-method 'metamail-buffer
665 "*Function to process a MIME message.
666 The function is called from the article buffer.")
668 (defvar gnus-decode-encoded-word-method (lambda ())
669 "*Function to decode a MIME encoded-words.
670 The function is called from the article buffer.")
672 (defvar gnus-show-threads t
673 "*If non-nil, display threads in summary mode.")
675 (defvar gnus-thread-hide-subtree nil
676 "*If non-nil, hide all threads initially.
677 If threads are hidden, you have to run the command
678 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
679 to expose hidden threads.")
681 (defvar gnus-thread-hide-killed t
682 "*If non-nil, hide killed threads automatically.")
684 (defvar gnus-thread-ignore-subject nil
685 "*If non-nil, ignore subjects and do all threading based on the Reference header.
686 If nil, which is the default, articles that have different subjects
687 from their parents will start separate threads.")
689 (defvar gnus-thread-operation-ignore-subject t
690 "*If non-nil, subjects will be ignored when doing thread commands.
691 This affects commands like `gnus-summary-kill-thread' and
692 `gnus-summary-lower-thread'.
694 If this variable is nil, articles in the same thread with different
695 subjects will not be included in the operation in question. If this
696 variable is `fuzzy', only articles that have subjects that are fuzzily
697 equal will be included.")
699 (defvar gnus-thread-indent-level 4
700 "*Number that says how much each sub-thread should be indented.")
702 (defvar gnus-ignored-newsgroups
703 (purecopy (mapconcat 'identity
704 '("^to\\." ; not "real" groups
705 "^[0-9. \t]+ " ; all digits in name
706 "[][\"#'()]" ; bogus characters
709 "*A regexp to match uninteresting newsgroups in the active file.
710 Any lines in the active file matching this regular expression are
711 removed from the newsgroup list before anything else is done to it,
712 thus making them effectively non-existent.")
714 (defvar gnus-ignored-headers
715 "^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:"
716 "*All headers that match this regexp will be hidden.
717 This variable can also be a list of regexps of headers to be ignored.
718 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
720 (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-"
721 "*All headers that do not match this regexp will be hidden.
722 This variable can also be a list of regexp of headers to remain visible.
723 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
725 (defvar gnus-sorted-header-list
726 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
727 "^Cc:" "^Date:" "^Organization:")
728 "*This variable is a list of regular expressions.
729 If it is non-nil, headers that match the regular expressions will
730 be placed first in the article buffer in the sequence specified by
733 (defvar gnus-boring-article-headers
734 '(empty followup-to reply-to)
735 "*Headers that are only to be displayed if they have interesting data.
736 Possible values in this list are `empty', `newsgroups', `followup-to',
737 `reply-to', and `date'.")
739 (defvar gnus-show-all-headers nil
740 "*If non-nil, don't hide any headers.")
742 (defvar gnus-save-all-headers t
743 "*If non-nil, don't remove any headers before saving.")
745 (defvar gnus-saved-headers gnus-visible-headers
746 "*Headers to keep if `gnus-save-all-headers' is nil.
747 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
748 If that variable is nil, however, all headers that match this regexp
749 will be kept while the rest will be deleted before saving.")
751 (defvar gnus-inhibit-startup-message nil
752 "*If non-nil, the startup message will not be displayed.")
754 (defvar gnus-signature-separator "^-- *$"
755 "Regexp matching signature separator.")
757 (defvar gnus-signature-limit nil
758 "Provide a limit to what is considered a signature.
759 If it is a number, no signature may not be longer (in characters) than
760 that number. If it is a function, the function will be called without
761 any parameters, and if it returns nil, there is no signature in the
762 buffer. If it is a string, it will be used as a regexp. If it
763 matches, the text in question is not a signature.")
765 (defvar gnus-auto-extend-newsgroup t
766 "*If non-nil, extend newsgroup forward and backward when requested.")
768 (defvar gnus-auto-select-first t
769 "*If nil, don't select the first unread article when entering a group.
770 If this variable is `best', select the highest-scored unread article
771 in the group. If neither nil nor `best', select the first unread
774 If you want to prevent automatic selection of the first unread article
775 in some newsgroups, set the variable to nil in
776 `gnus-select-group-hook'.")
778 (defvar gnus-auto-select-next t
779 "*If non-nil, offer to go to the next group from the end of the previous.
780 If the value is t and the next newsgroup is empty, Gnus will exit
781 summary mode and go back to group mode. If the value is neither nil
782 nor t, Gnus will select the following unread newsgroup. In
783 particular, if the value is the symbol `quietly', the next unread
784 newsgroup will be selected without any confirmation, and if it is
785 `almost-quietly', the next group will be selected without any
786 confirmation if you are located on the last article in the group.
787 Finally, if this variable is `slightly-quietly', the `Z n' command
788 will go to the next group without confirmation.")
790 (defvar gnus-auto-select-same nil
791 "*If non-nil, select the next article with the same subject.")
793 (defvar gnus-summary-check-current nil
794 "*If non-nil, consider the current article when moving.
795 The \"unread\" movement commands will stay on the same line if the
796 current article is unread.")
798 (defvar gnus-auto-center-summary t
799 "*If non-nil, always center the current summary buffer.
800 In particular, if `vertical' do only vertical recentering. If non-nil
801 and non-`vertical', do both horizontal and vertical recentering.")
803 (defvar gnus-break-pages t
804 "*If non-nil, do page breaking on articles.
805 The page delimiter is specified by the `gnus-page-delimiter'
808 (defvar gnus-page-delimiter "^\^L"
809 "*Regexp describing what to use as article page delimiters.
810 The default value is \"^\^L\", which is a form linefeed at the
811 beginning of a line.")
813 (defvar gnus-use-full-window t
814 "*If non-nil, use the entire Emacs screen.")
816 (defvar gnus-window-configuration nil
817 "Obsolete variable. See `gnus-buffer-configuration'.")
819 (defvar gnus-window-min-width 2
820 "*Minimum width of Gnus buffers.")
822 (defvar gnus-window-min-height 1
823 "*Minimum height of Gnus buffers.")
825 (defvar gnus-buffer-configuration
829 (if gnus-carpal '(group-carpal 4))))
833 (if gnus-carpal '(summary-carpal 4))))
840 (if gnus-carpal '(summary-carpal 4))
842 (vertical ((height . 5) (width . 15)
844 (left . -1) (top . 1))
854 (if gnus-carpal '(summary-carpal 4))
855 (if gnus-use-trees '(tree 0.25))
860 (if gnus-carpal '(server-carpal 2))))
864 (if gnus-carpal '(browse-carpal 2))))
867 (message 1.0 point)))
870 (article 1.0 point)))
881 (edit-group 1.0 point)))
885 (edit-server 1.0 point)))
889 (edit-score 1.0 point)))
896 (message 1.0 point)))
899 (message 1.0 point)))
902 (message 1.0 point)))
906 (message 1.0 point)))
913 (if gnus-carpal '(summary-carpal 4))
914 ("*Shell Command Output*" 1.0)))
917 ("*Gnus Help Bug*" 0.5)
918 ("*Gnus Bug*" 1.0 point)))
922 (message 1.0 point))))
923 "Window configuration for all possible Gnus buffers.
924 This variable is a list of lists. Each of these lists has a NAME and
925 a RULE. The NAMEs are commonsense names like `group', which names a
926 rule used when displaying the group buffer; `summary', which names a
927 rule for what happens when you enter a group and do not display an
928 article buffer; and so on. See the value of this variable for a
929 complete list of NAMEs.
931 Each RULE is a list of vectors. The first element in this vector is
932 the name of the buffer to be displayed; the second element is the
933 percentage of the screen this buffer is to occupy (a number in the
934 0.0-0.99 range); the optional third element is `point', which should
935 be present to denote which buffer point is to go to after making this
936 buffer configuration.")
938 (defvar gnus-window-to-buffer
939 '((group . gnus-group-buffer)
940 (summary . gnus-summary-buffer)
941 (article . gnus-article-buffer)
942 (server . gnus-server-buffer)
943 (browse . "*Gnus Browse Server*")
944 (edit-group . gnus-group-edit-buffer)
945 (edit-server . gnus-server-edit-buffer)
946 (group-carpal . gnus-carpal-group-buffer)
947 (summary-carpal . gnus-carpal-summary-buffer)
948 (server-carpal . gnus-carpal-server-buffer)
949 (browse-carpal . gnus-carpal-browse-buffer)
950 (edit-score . gnus-score-edit-buffer)
951 (message . gnus-message-buffer)
952 (faq . gnus-faq-buffer)
953 (picons . "*Picons*")
954 (tree . gnus-tree-buffer)
955 (info . gnus-info-buffer)
956 (article-copy . gnus-article-copy)
957 (draft . gnus-draft-buffer))
958 "Mapping from short symbols to buffer names or buffer variables.")
960 (defvar gnus-carpal nil
961 "*If non-nil, display clickable icons.")
963 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
964 "*Function called with a group name when new group is detected.
965 A few pre-made functions are supplied: `gnus-subscribe-randomly'
966 inserts new groups at the beginning of the list of groups;
967 `gnus-subscribe-alphabetically' inserts new groups in strict
968 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
969 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
970 for your decision; `gnus-subscribe-killed' kills all new groups.")
972 ;; Suggested by a bug report by Hallvard B Furuseth.
973 ;; <h.b.furuseth@usit.uio.no>.
974 (defvar gnus-subscribe-options-newsgroup-method
975 (function gnus-subscribe-alphabetically)
976 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
977 If, for instance, you want to subscribe to all newsgroups in the
978 \"no\" and \"alt\" hierarchies, you'd put the following in your
981 options -n no.all alt.all
983 Gnus will the subscribe all new newsgroups in these hierarchies with
984 the subscription method in this variable.")
986 (defvar gnus-subscribe-hierarchical-interactive nil
987 "*If non-nil, Gnus will offer to subscribe hierarchically.
988 When a new hierarchy appears, Gnus will ask the user:
990 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
992 If the user pressed `d', Gnus will descend the hierarchy, `y' will
993 subscribe to all newsgroups in the hierarchy and `s' will skip this
994 hierarchy in its entirety.")
996 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
997 "*Function used for sorting the group buffer.
998 This function will be called with group info entries as the arguments
999 for the groups to be sorted. Pre-made functions include
1000 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1001 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1002 `gnus-group-sort-by-rank'.
1004 This variable can also be a list of sorting functions. In that case,
1005 the most significant sort function should be the last function in the
1008 ;; Mark variables suggested by Thomas Michanek
1009 ;; <Thomas.Michanek@telelogic.se>.
1010 (defvar gnus-unread-mark ?
1011 "*Mark used for unread articles.")
1012 (defvar gnus-ticked-mark ?!
1013 "*Mark used for ticked articles.")
1014 (defvar gnus-dormant-mark ??
1015 "*Mark used for dormant articles.")
1016 (defvar gnus-del-mark ?r
1017 "*Mark used for del'd articles.")
1018 (defvar gnus-read-mark ?R
1019 "*Mark used for read articles.")
1020 (defvar gnus-expirable-mark ?E
1021 "*Mark used for expirable articles.")
1022 (defvar gnus-killed-mark ?K
1023 "*Mark used for killed articles.")
1024 (defvar gnus-souped-mark ?F
1025 "*Mark used for killed articles.")
1026 (defvar gnus-kill-file-mark ?X
1027 "*Mark used for articles killed by kill files.")
1028 (defvar gnus-low-score-mark ?Y
1029 "*Mark used for articles with a low score.")
1030 (defvar gnus-catchup-mark ?C
1031 "*Mark used for articles that are caught up.")
1032 (defvar gnus-replied-mark ?A
1033 "*Mark used for articles that have been replied to.")
1034 (defvar gnus-cached-mark ?*
1035 "*Mark used for articles that are in the cache.")
1036 (defvar gnus-saved-mark ?S
1037 "*Mark used for articles that have been saved to.")
1038 (defvar gnus-process-mark ?#
1040 (defvar gnus-ancient-mark ?O
1041 "*Mark used for ancient articles.")
1042 (defvar gnus-sparse-mark ?Q
1043 "*Mark used for sparsely reffed articles.")
1044 (defvar gnus-canceled-mark ?G
1045 "*Mark used for canceled articles.")
1046 (defvar gnus-score-over-mark ?+
1047 "*Score mark used for articles with high scores.")
1048 (defvar gnus-score-below-mark ?-
1049 "*Score mark used for articles with low scores.")
1050 (defvar gnus-empty-thread-mark ?
1051 "*There is no thread under the article.")
1052 (defvar gnus-not-empty-thread-mark ?=
1053 "*There is a thread under the article.")
1055 (defvar gnus-view-pseudo-asynchronously nil
1056 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1058 (defvar gnus-view-pseudos nil
1059 "*If `automatic', pseudo-articles will be viewed automatically.
1060 If `not-confirm', pseudos will be viewed automatically, and the user
1061 will not be asked to confirm the command.")
1063 (defvar gnus-view-pseudos-separately t
1064 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1065 If nil, all files that use the same viewing command will be given as a
1066 list of parameters to that command.")
1068 (defvar gnus-insert-pseudo-articles t
1069 "*If non-nil, insert pseudo-articles when decoding articles.")
1071 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1072 "*Format of group lines.
1073 It works along the same lines as a normal formatting string,
1074 with some simple extensions.
1076 %M Only marked articles (character, \"*\" or \" \")
1077 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1078 %L Level of subscribedness (integer)
1079 %N Number of unread articles (integer)
1080 %I Number of dormant articles (integer)
1081 %i Number of ticked and dormant (integer)
1082 %T Number of ticked articles (integer)
1083 %R Number of read articles (integer)
1084 %t Total number of articles (integer)
1085 %y Number of unread, unticked articles (integer)
1086 %G Group name (string)
1087 %g Qualified group name (string)
1088 %D Group description (string)
1089 %s Select method (string)
1090 %o Moderated group (char, \"m\")
1091 %p Process mark (char)
1092 %O Moderated group (string, \"(m)\" or \"\")
1093 %P Topic indentation (string)
1094 %l Whether there are GroupLens predictions for this group (string)
1095 %n Select from where (string)
1096 %z A string that look like `<%s:%n>' if a foreign select method is used
1097 %u User defined specifier. The next character in the format string should
1098 be a letter. Gnus will call the function gnus-user-format-function-X,
1099 where X is the letter following %u. The function will be passed the
1100 current header as argument. The function should return a string, which
1101 will be inserted into the buffer just like information from any other
1104 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1105 the mouse point move inside the area. There can only be one such area.
1107 Note that this format specification is not always respected. For
1108 reasons of efficiency, when listing killed groups, this specification
1109 is ignored altogether. If the spec is changed considerably, your
1110 output may end up looking strange when listing both alive and killed
1113 If you use %o or %O, reading the active file will be slower and quite
1114 a bit of extra memory will be used. %D will also worsen performance.
1115 Also note that if you change the format specification to include any
1116 of these specs, you must probably re-start Gnus to see them go into
1119 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1120 "*The format specification of the lines in the summary buffer.
1122 It works along the same lines as a normal formatting string,
1123 with some simple extensions.
1125 %N Article number, left padded with spaces (string)
1127 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1128 %n Name of the poster (string)
1129 %a Extracted name of the poster (string)
1130 %A Extracted address of the poster (string)
1131 %F Contents of the From: header (string)
1132 %x Contents of the Xref: header (string)
1133 %D Date of the article (string)
1134 %d Date of the article (string) in DD-MMM format
1135 %M Message-id of the article (string)
1136 %r References of the article (string)
1137 %c Number of characters in the article (integer)
1138 %L Number of lines in the article (integer)
1139 %I Indentation based on thread level (a string of spaces)
1140 %T A string with two possible values: 80 spaces if the article
1141 is on thread level two or larger and 0 spaces on level one
1142 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1143 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1144 %[ Opening bracket (character, \"[\" or \"<\")
1145 %] Closing bracket (character, \"]\" or \">\")
1146 %> Spaces of length thread-level (string)
1147 %< Spaces of length (- 20 thread-level) (string)
1148 %i Article score (number)
1149 %z Article zcore (character)
1150 %t Number of articles under the current thread (number).
1151 %e Whether the thread is empty or not (character).
1152 %l GroupLens score (string).
1153 %u User defined specifier. The next character in the format string should
1154 be a letter. Gnus will call the function gnus-user-format-function-X,
1155 where X is the letter following %u. The function will be passed the
1156 current header as argument. The function should return a string, which
1157 will be inserted into the summary just like information from any other
1160 Text between %( and %) will be highlighted with `gnus-mouse-face'
1161 when the mouse point is placed inside the area. There can only be one
1164 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1165 with care. For reasons of efficiency, Gnus will compute what column
1166 these characters will end up in, and \"hard-code\" that. This means that
1167 it is illegal to have these specs after a variable-length spec. Well,
1168 you might not be arrested, but your summary buffer will look strange,
1169 which is bad enough.
1171 The smart choice is to have these specs as for to the left as
1174 This restriction may disappear in later versions of Gnus.")
1176 (defvar gnus-summary-dummy-line-format
1178 "*The format specification for the dummy roots in the summary buffer.
1179 It works along the same lines as a normal formatting string,
1180 with some simple extensions.
1184 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1185 "*The format specification for the summary mode line.
1186 It works along the same lines as a normal formatting string,
1187 with some simple extensions:
1190 %p Unprefixed group name
1191 %A Current article number
1193 %U Number of unread articles in the group
1194 %e Number of unselected articles in the group
1195 %Z A string with unread/unselected article counts
1196 %g Shortish group name
1197 %S Subject of the current article
1198 %u User-defined spec
1199 %s Current score file name
1200 %d Number of dormant articles
1201 %r Number of articles that have been marked as read in this session
1202 %E Number of articles expunged by the score files")
1204 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1205 "*The format specification for the article mode line.
1206 See `gnus-summary-mode-line-format' for a closer description.")
1208 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1209 "*The format specification for the group mode line.
1210 It works along the same lines as a normal formatting string,
1211 with some simple extensions:
1213 %S The native news server.
1214 %M The native select method.")
1216 (defvar gnus-valid-select-methods
1217 '(("nntp" post address prompt-address)
1218 ("nnspool" post address)
1219 ("nnvirtual" post-mail virtual prompt-address)
1220 ("nnmbox" mail respool address)
1221 ("nnml" mail respool address)
1222 ("nnmh" mail respool address)
1223 ("nndir" post-mail prompt-address address)
1224 ("nneething" none address prompt-address)
1225 ("nndoc" none address prompt-address)
1226 ("nnbabyl" mail address respool)
1227 ("nnkiboze" post address virtual)
1228 ("nnsoup" post-mail address)
1229 ("nndraft" post-mail)
1230 ("nnfolder" mail respool address))
1231 "An alist of valid select methods.
1232 The first element of each list lists should be a string with the name
1233 of the select method. The other elements may be be the category of
1234 this method (ie. `post', `mail', `none' or whatever) or other
1235 properties that this method has (like being respoolable).
1236 If you implement a new select method, all you should have to change is
1237 this variable. I think.")
1239 (defvar gnus-updated-mode-lines '(group article summary tree)
1240 "*List of buffers that should update their mode lines.
1241 The list may contain the symbols `group', `article' and `summary'. If
1242 the corresponding symbol is present, Gnus will keep that mode line
1243 updated with information that may be pertinent.
1244 If this variable is nil, screen refresh may be quicker.")
1246 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1247 (defvar gnus-mode-non-string-length nil
1248 "*Max length of mode-line non-string contents.
1249 If this is nil, Gnus will take space as is needed, leaving the rest
1250 of the modeline intact.")
1253 ;(defvar gnus-mouse-face 'highlight
1254 ; "*Face used for mouse highlighting in Gnus.
1255 ;No mouse highlights will be done if `gnus-visual' is nil.")
1257 (defvar gnus-summary-mark-below nil
1258 "*Mark all articles with a score below this variable as read.
1259 This variable is local to each summary buffer and usually set by the
1262 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1263 "*List of functions used for sorting articles in the summary buffer.
1264 This variable is only used when not using a threaded display.")
1266 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1267 "*List of functions used for sorting threads in the summary buffer.
1268 By default, threads are sorted by article number.
1270 Each function takes two threads and return non-nil if the first thread
1271 should be sorted before the other. If you use more than one function,
1272 the primary sort function should be the last. You should probably
1273 always include `gnus-thread-sort-by-number' in the list of sorting
1274 functions -- preferably first.
1276 Ready-mady functions include `gnus-thread-sort-by-number',
1277 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1278 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1279 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1281 (defvar gnus-thread-score-function '+
1282 "*Function used for calculating the total score of a thread.
1284 The function is called with the scores of the article and each
1285 subthread and should then return the score of the thread.
1287 Some functions you can use are `+', `max', or `min'.")
1289 (defvar gnus-summary-expunge-below nil
1290 "All articles that have a score less than this variable will be expunged.")
1292 (defvar gnus-thread-expunge-below nil
1293 "All threads that have a total score less than this variable will be expunged.
1294 See `gnus-thread-score-function' for en explanation of what a
1295 \"thread score\" is.")
1297 (defvar gnus-auto-subscribed-groups
1298 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1299 "*All new groups that match this regexp will be subscribed automatically.
1300 Note that this variable only deals with new groups. It has no effect
1301 whatsoever on old groups.")
1303 (defvar gnus-options-subscribe nil
1304 "*All new groups matching this regexp will be subscribed unconditionally.
1305 Note that this variable deals only with new newsgroups. This variable
1306 does not affect old newsgroups.")
1308 (defvar gnus-options-not-subscribe nil
1309 "*All new groups matching this regexp will be ignored.
1310 Note that this variable deals only with new newsgroups. This variable
1311 does not affect old (already subscribed) newsgroups.")
1313 (defvar gnus-auto-expirable-newsgroups nil
1314 "*Groups in which to automatically mark read articles as expirable.
1315 If non-nil, this should be a regexp that should match all groups in
1316 which to perform auto-expiry. This only makes sense for mail groups.")
1318 (defvar gnus-total-expirable-newsgroups nil
1319 "*Groups in which to perform expiry of all read articles.
1320 Use with extreme caution. All groups that match this regexp will be
1321 expiring - which means that all read articles will be deleted after
1322 (say) one week. (This only goes for mail groups and the like, of
1325 (defvar gnus-group-uncollapsed-levels 1
1326 "Number of group name elements to leave alone when making a short group name.")
1328 (defvar gnus-hidden-properties '(invisible t intangible t)
1329 "Property list to use for hiding text.")
1331 (defvar gnus-modtime-botch nil
1332 "*Non-nil means .newsrc should be deleted prior to save.
1333 Its use is due to the bogus appearance that .newsrc was modified on
1338 (defvar gnus-group-mode-hook nil
1339 "*A hook for Gnus group mode.")
1341 (defvar gnus-summary-mode-hook nil
1342 "*A hook for Gnus summary mode.
1343 This hook is run before any variables are set in the summary buffer.")
1345 (defvar gnus-article-mode-hook nil
1346 "*A hook for Gnus article mode.")
1348 (defvar gnus-summary-prepare-exit-hook nil
1349 "*A hook called when preparing to exit from the summary buffer.
1350 It calls `gnus-summary-expire-articles' by default.")
1351 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1353 (defvar gnus-summary-exit-hook nil
1354 "*A hook called on exit from the summary buffer.")
1356 (defvar gnus-group-catchup-group-hook nil
1357 "*A hook run when catching up a group from the group buffer.")
1359 (defvar gnus-open-server-hook nil
1360 "*A hook called just before opening connection to the news server.")
1362 (defvar gnus-load-hook nil
1363 "*A hook run while Gnus is loaded.")
1365 (defvar gnus-startup-hook nil
1366 "*A hook called at startup.
1367 This hook is called after Gnus is connected to the NNTP server.")
1369 (defvar gnus-get-new-news-hook nil
1370 "*A hook run just before Gnus checks for new news.")
1372 (defvar gnus-after-getting-new-news-hook nil
1373 "*A hook run after Gnus checks for new news.")
1375 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1376 "*A function that is called to generate the group buffer.
1377 The function is called with three arguments: The first is a number;
1378 all group with a level less or equal to that number should be listed,
1379 if the second is non-nil, empty groups should also be displayed. If
1380 the third is non-nil, it is a number. No groups with a level lower
1381 than this number should be displayed.
1383 The only current function implemented is `gnus-group-prepare-flat'.")
1385 (defvar gnus-group-prepare-hook nil
1386 "*A hook called after the group buffer has been generated.
1387 If you want to modify the group buffer, you can use this hook.")
1389 (defvar gnus-summary-prepare-hook nil
1390 "*A hook called after the summary buffer has been generated.
1391 If you want to modify the summary buffer, you can use this hook.")
1393 (defvar gnus-summary-generate-hook nil
1394 "*A hook run just before generating the summary buffer.
1395 This hook is commonly used to customize threading variables and the
1398 (defvar gnus-article-prepare-hook nil
1399 "*A hook called after an article has been prepared in the article buffer.
1400 If you want to run a special decoding program like nkf, use this hook.")
1402 ;(defvar gnus-article-display-hook nil
1403 ; "*A hook called after the article is displayed in the article buffer.
1404 ;The hook is designed to change the contents of the article
1405 ;buffer. Typical functions that this hook may contain are
1406 ;`gnus-article-hide-headers' (hide selected headers),
1407 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1408 ;`gnus-article-hide-signature' (hide signature) and
1409 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1410 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1411 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1412 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1414 (defvar gnus-article-x-face-command
1415 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1416 "String or function to be executed to display an X-Face header.
1417 If it is a string, the command will be executed in a sub-shell
1418 asynchronously. The compressed face will be piped to this command.")
1420 (defvar gnus-article-x-face-too-ugly nil
1421 "Regexp matching posters whose face shouldn't be shown automatically.")
1423 (defvar gnus-select-group-hook nil
1424 "*A hook called when a newsgroup is selected.
1426 If you'd like to simplify subjects like the
1427 `gnus-summary-next-same-subject' command does, you can use the
1430 (setq gnus-select-group-hook
1433 (mapcar (lambda (header)
1434 (mail-header-set-subject
1436 (gnus-simplify-subject
1437 (mail-header-subject header) 're-only)))
1438 gnus-newsgroup-headers))))")
1440 (defvar gnus-select-article-hook nil
1441 "*A hook called when an article is selected.")
1443 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1444 "*A hook called to apply kill files to a group.
1445 This hook is intended to apply a kill file to the selected newsgroup.
1446 The function `gnus-apply-kill-file' is called by default.
1448 Since a general kill file is too heavy to use only for a few
1449 newsgroups, I recommend you to use a lighter hook function. For
1450 example, if you'd like to apply a kill file to articles which contains
1451 a string `rmgroup' in subject in newsgroup `control', you can use the
1454 (setq gnus-apply-kill-hook
1457 (cond ((string-match \"control\" gnus-newsgroup-name)
1458 (gnus-kill \"Subject\" \"rmgroup\")
1459 (gnus-expunge \"X\"))))))")
1461 (defvar gnus-visual-mark-article-hook
1462 (list 'gnus-highlight-selected-summary)
1463 "*Hook run after selecting an article in the summary buffer.
1464 It is meant to be used for highlighting the article in some way. It
1465 is not run if `gnus-visual' is nil.")
1467 (defvar gnus-parse-headers-hook nil
1468 "*A hook called before parsing the headers.")
1470 (defvar gnus-exit-group-hook nil
1471 "*A hook called when exiting (not quitting) summary mode.")
1473 (defvar gnus-suspend-gnus-hook nil
1474 "*A hook called when suspending (not exiting) Gnus.")
1476 (defvar gnus-exit-gnus-hook nil
1477 "*A hook called when exiting Gnus.")
1479 (defvar gnus-after-exiting-gnus-hook nil
1480 "*A hook called after exiting Gnus.")
1482 (defvar gnus-save-newsrc-hook nil
1483 "*A hook called before saving any of the newsrc files.")
1485 (defvar gnus-save-quick-newsrc-hook nil
1486 "*A hook called just before saving the quick newsrc file.
1487 Can be used to turn version control on or off.")
1489 (defvar gnus-save-standard-newsrc-hook nil
1490 "*A hook called just before saving the standard newsrc file.
1491 Can be used to turn version control on or off.")
1493 (defvar gnus-summary-update-hook
1494 (list 'gnus-summary-highlight-line)
1495 "*A hook called when a summary line is changed.
1496 The hook will not be called if `gnus-visual' is nil.
1498 The default function `gnus-summary-highlight-line' will
1499 highlight the line according to the `gnus-summary-highlight'
1502 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1503 "*A hook called when a group line is changed.
1504 The hook will not be called if `gnus-visual' is nil.
1506 The default function `gnus-group-highlight-line' will
1507 highlight the line according to the `gnus-group-highlight'
1510 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1511 "*A hook called when an article is selected for the first time.
1512 The hook is intended to mark an article as read (or unread)
1513 automatically when it is selected.")
1515 (defvar gnus-group-change-level-function nil
1516 "Function run when a group level is changed.
1517 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1519 ;; Remove any hilit infestation.
1520 (add-hook 'gnus-startup-hook
1522 (remove-hook 'gnus-summary-prepare-hook
1523 'hilit-rehighlight-buffer-quietly)
1524 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1525 (setq gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read))
1526 (remove-hook 'gnus-article-prepare-hook
1527 'hilit-rehighlight-buffer-quietly)))
1530 ;; Internal variables
1532 (defvar gnus-server-alist nil
1533 "List of available servers.")
1535 (defvar gnus-group-indentation-function nil)
1537 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1539 (defvar gnus-goto-missing-group-function nil)
1541 (defvar gnus-override-subscribe-method nil)
1543 (defvar gnus-group-goto-next-group-function nil
1544 "Function to override finding the next group after listing groups.")
1546 (defconst gnus-article-mark-lists
1547 '((marked . tick) (replied . reply)
1548 (expirable . expire) (killed . killed)
1549 (bookmarks . bookmark) (dormant . dormant)
1550 (scored . score) (saved . save)
1554 ;; Avoid highlighting in kill files.
1555 (defvar gnus-summary-inhibit-highlight nil)
1556 (defvar gnus-newsgroup-selected-overlay nil)
1558 (defvar gnus-inhibit-hiding nil)
1559 (defvar gnus-group-indentation "")
1560 (defvar gnus-inhibit-limiting nil)
1561 (defvar gnus-created-frames nil)
1563 (defvar gnus-article-mode-map nil)
1564 (defvar gnus-dribble-buffer nil)
1565 (defvar gnus-headers-retrieved-by nil)
1566 (defvar gnus-article-reply nil)
1567 (defvar gnus-override-method nil)
1568 (defvar gnus-article-check-size nil)
1570 (defvar gnus-current-score-file nil)
1571 (defvar gnus-newsgroup-adaptive-score-file nil)
1572 (defvar gnus-scores-exclude-files nil)
1574 (defvar gnus-opened-servers nil)
1576 (defvar gnus-current-move-group nil)
1578 (defvar gnus-newsgroup-dependencies nil)
1579 (defvar gnus-newsgroup-async nil)
1580 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1582 (defvar gnus-newsgroup-adaptive nil)
1584 (defvar gnus-summary-display-table nil)
1585 (defvar gnus-summary-display-article-function nil)
1587 (defvar gnus-summary-highlight-line-function nil
1588 "Function called after highlighting a summary line.")
1590 (defvar gnus-group-line-format-alist
1591 `((?M gnus-tmp-marked-mark ?c)
1592 (?S gnus-tmp-subscribed ?c)
1593 (?L gnus-tmp-level ?d)
1594 (?N (cond ((eq number t) "*" )
1598 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1599 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1601 (?R gnus-tmp-number-of-read ?s)
1602 (?t gnus-tmp-number-total ?d)
1603 (?y gnus-tmp-number-of-unread ?s)
1604 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1605 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1606 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1607 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1608 (?g gnus-tmp-group ?s)
1609 (?G gnus-tmp-qualified-group ?s)
1610 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1611 (?D gnus-tmp-newsgroup-description ?s)
1612 (?o gnus-tmp-moderated ?c)
1613 (?O gnus-tmp-moderated-string ?s)
1614 (?p gnus-tmp-process-marked ?c)
1615 (?s gnus-tmp-news-server ?s)
1616 (?n gnus-tmp-news-method ?s)
1617 (?P gnus-group-indentation ?s)
1618 (?l gnus-tmp-grouplens ?s)
1619 (?z gnus-tmp-news-method-string ?s)
1620 (?u gnus-tmp-user-defined ?s)))
1622 (defvar gnus-summary-line-format-alist
1623 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1624 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1625 (?s gnus-tmp-subject-or-nil ?s)
1626 (?n gnus-tmp-name ?s)
1627 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1629 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1631 (?F gnus-tmp-from ?s)
1632 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1633 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1634 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1635 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1636 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1637 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1638 (?L gnus-tmp-lines ?d)
1639 (?I gnus-tmp-indentation ?s)
1640 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1641 (?R gnus-tmp-replied ?c)
1642 (?\[ gnus-tmp-opening-bracket ?c)
1643 (?\] gnus-tmp-closing-bracket ?c)
1644 (?\> (make-string gnus-tmp-level ? ) ?s)
1645 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1646 (?i gnus-tmp-score ?d)
1647 (?z gnus-tmp-score-char ?c)
1648 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1649 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1650 (?U gnus-tmp-unread ?c)
1651 (?t (gnus-summary-number-of-articles-in-thread
1652 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1654 (?e (gnus-summary-number-of-articles-in-thread
1655 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1657 (?u gnus-tmp-user-defined ?s))
1658 "An alist of format specifications that can appear in summary lines,
1659 and what variables they correspond with, along with the type of the
1660 variable (string, integer, character, etc).")
1662 (defvar gnus-summary-dummy-line-format-alist
1663 `((?S gnus-tmp-subject ?s)
1664 (?N gnus-tmp-number ?d)
1665 (?u gnus-tmp-user-defined ?s)))
1667 (defvar gnus-summary-mode-line-format-alist
1668 `((?G gnus-tmp-group-name ?s)
1669 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1670 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1671 (?A gnus-tmp-article-number ?d)
1672 (?Z gnus-tmp-unread-and-unselected ?s)
1673 (?V gnus-version ?s)
1674 (?U gnus-tmp-unread ?d)
1675 (?S gnus-tmp-subject ?s)
1676 (?e gnus-tmp-unselected ?d)
1677 (?u gnus-tmp-user-defined ?s)
1678 (?d (length gnus-newsgroup-dormant) ?d)
1679 (?t (length gnus-newsgroup-marked) ?d)
1680 (?r (length gnus-newsgroup-reads) ?d)
1681 (?E gnus-newsgroup-expunged-tally ?d)
1682 (?s (gnus-current-score-file-nondirectory) ?s)))
1684 (defvar gnus-article-mode-line-format-alist
1685 gnus-summary-mode-line-format-alist)
1687 (defvar gnus-group-mode-line-format-alist
1688 `((?S gnus-tmp-news-server ?s)
1689 (?M gnus-tmp-news-method ?s)
1690 (?u gnus-tmp-user-defined ?s)))
1692 (defvar gnus-have-read-active-file nil)
1694 (defconst gnus-maintainer
1695 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1696 "The mail address of the Gnus maintainers.")
1698 (defconst gnus-version "September Gnus v0.69"
1699 "Version number for this version of Gnus.")
1701 (defvar gnus-info-nodes
1702 '((gnus-group-mode "(gnus)The Group Buffer")
1703 (gnus-summary-mode "(gnus)The Summary Buffer")
1704 (gnus-article-mode "(gnus)The Article Buffer"))
1705 "Assoc list of major modes and related Info nodes.")
1707 (defvar gnus-group-buffer "*Group*")
1708 (defvar gnus-summary-buffer "*Summary*")
1709 (defvar gnus-article-buffer "*Article*")
1710 (defvar gnus-server-buffer "*Server*")
1712 (defvar gnus-work-buffer " *gnus work*")
1714 (defvar gnus-original-article-buffer " *Original Article*")
1715 (defvar gnus-original-article nil)
1717 (defvar gnus-buffer-list nil
1718 "Gnus buffers that should be killed on exit.")
1720 (defvar gnus-slave nil
1721 "Whether this Gnus is a slave or not.")
1723 (defvar gnus-variable-list
1724 '(gnus-newsrc-options gnus-newsrc-options-n
1725 gnus-newsrc-last-checked-date
1726 gnus-newsrc-alist gnus-server-alist
1727 gnus-killed-list gnus-zombie-list
1728 gnus-topic-topology gnus-topic-alist
1730 "Gnus variables saved in the quick startup file.")
1732 (defvar gnus-newsrc-options nil
1733 "Options line in the .newsrc file.")
1735 (defvar gnus-newsrc-options-n nil
1736 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1738 (defvar gnus-newsrc-last-checked-date nil
1739 "Date Gnus last asked server for new newsgroups.")
1741 (defvar gnus-topic-topology nil
1742 "The complete topic hierarchy.")
1744 (defvar gnus-topic-alist nil
1745 "The complete topic-group alist.")
1747 (defvar gnus-newsrc-alist nil
1748 "Assoc list of read articles.
1749 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1751 (defvar gnus-newsrc-hashtb nil
1752 "Hashtable of gnus-newsrc-alist.")
1754 (defvar gnus-killed-list nil
1755 "List of killed newsgroups.")
1757 (defvar gnus-killed-hashtb nil
1758 "Hash table equivalent of gnus-killed-list.")
1760 (defvar gnus-zombie-list nil
1761 "List of almost dead newsgroups.")
1763 (defvar gnus-description-hashtb nil
1764 "Descriptions of newsgroups.")
1766 (defvar gnus-list-of-killed-groups nil
1767 "List of newsgroups that have recently been killed by the user.")
1769 (defvar gnus-active-hashtb nil
1770 "Hashtable of active articles.")
1772 (defvar gnus-moderated-list nil
1773 "List of moderated newsgroups.")
1775 (defvar gnus-group-marked nil)
1777 (defvar gnus-current-startup-file nil
1778 "Startup file for the current host.")
1780 (defvar gnus-last-search-regexp nil
1781 "Default regexp for article search command.")
1783 (defvar gnus-last-shell-command nil
1784 "Default shell command on article.")
1786 (defvar gnus-current-select-method nil
1787 "The current method for selecting a newsgroup.")
1789 (defvar gnus-group-list-mode nil)
1791 (defvar gnus-article-internal-prepare-hook nil)
1793 (defvar gnus-newsgroup-name nil)
1794 (defvar gnus-newsgroup-begin nil)
1795 (defvar gnus-newsgroup-end nil)
1796 (defvar gnus-newsgroup-last-rmail nil)
1797 (defvar gnus-newsgroup-last-mail nil)
1798 (defvar gnus-newsgroup-last-folder nil)
1799 (defvar gnus-newsgroup-last-file nil)
1800 (defvar gnus-newsgroup-auto-expire nil)
1801 (defvar gnus-newsgroup-active nil)
1803 (defvar gnus-newsgroup-data nil)
1804 (defvar gnus-newsgroup-data-reverse nil)
1805 (defvar gnus-newsgroup-limit nil)
1806 (defvar gnus-newsgroup-limits nil)
1808 (defvar gnus-newsgroup-unreads nil
1809 "List of unread articles in the current newsgroup.")
1811 (defvar gnus-newsgroup-unselected nil
1812 "List of unselected unread articles in the current newsgroup.")
1814 (defvar gnus-newsgroup-reads nil
1815 "Alist of read articles and article marks in the current newsgroup.")
1817 (defvar gnus-newsgroup-expunged-tally nil)
1819 (defvar gnus-newsgroup-marked nil
1820 "List of ticked articles in the current newsgroup (a subset of unread art).")
1822 (defvar gnus-newsgroup-killed nil
1823 "List of ranges of articles that have been through the scoring process.")
1825 (defvar gnus-newsgroup-cached nil
1826 "List of articles that come from the article cache.")
1828 (defvar gnus-newsgroup-saved nil
1829 "List of articles that have been saved.")
1831 (defvar gnus-newsgroup-kill-headers nil)
1833 (defvar gnus-newsgroup-replied nil
1834 "List of articles that have been replied to in the current newsgroup.")
1836 (defvar gnus-newsgroup-expirable nil
1837 "List of articles in the current newsgroup that can be expired.")
1839 (defvar gnus-newsgroup-processable nil
1840 "List of articles in the current newsgroup that can be processed.")
1842 (defvar gnus-newsgroup-bookmarks nil
1843 "List of articles in the current newsgroup that have bookmarks.")
1845 (defvar gnus-newsgroup-dormant nil
1846 "List of dormant articles in the current newsgroup.")
1848 (defvar gnus-newsgroup-scored nil
1849 "List of scored articles in the current newsgroup.")
1851 (defvar gnus-newsgroup-headers nil
1852 "List of article headers in the current newsgroup.")
1854 (defvar gnus-newsgroup-threads nil)
1856 (defvar gnus-newsgroup-prepared nil
1857 "Whether the current group has been prepared properly.")
1859 (defvar gnus-newsgroup-ancient nil
1860 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1862 (defvar gnus-newsgroup-sparse nil)
1864 (defvar gnus-current-article nil)
1865 (defvar gnus-article-current nil)
1866 (defvar gnus-current-headers nil)
1867 (defvar gnus-have-all-headers nil)
1868 (defvar gnus-last-article nil)
1869 (defvar gnus-newsgroup-history nil)
1870 (defvar gnus-current-kill-article nil)
1872 ;; Save window configuration.
1873 (defvar gnus-prev-winconf nil)
1875 (defvar gnus-summary-mark-positions nil)
1876 (defvar gnus-group-mark-positions nil)
1878 (defvar gnus-reffed-article-number nil)
1880 ;;; Let the byte-compiler know that we know about this variable.
1881 (defvar rmail-default-rmail-file)
1883 (defvar gnus-cache-removable-articles nil)
1885 (defvar gnus-dead-summary nil)
1887 (defconst gnus-summary-local-variables
1888 '(gnus-newsgroup-name
1889 gnus-newsgroup-begin gnus-newsgroup-end
1890 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1891 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1892 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1893 gnus-newsgroup-unselected gnus-newsgroup-marked
1894 gnus-newsgroup-reads gnus-newsgroup-saved
1895 gnus-newsgroup-replied gnus-newsgroup-expirable
1896 gnus-newsgroup-processable gnus-newsgroup-killed
1897 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1898 gnus-newsgroup-headers gnus-newsgroup-threads
1899 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1900 gnus-current-article gnus-current-headers gnus-have-all-headers
1901 gnus-last-article gnus-article-internal-prepare-hook
1902 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1903 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1904 gnus-newsgroup-async
1905 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1906 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1907 gnus-newsgroup-history gnus-newsgroup-ancient
1908 gnus-newsgroup-sparse
1909 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1910 gnus-newsgroup-adaptive-score-file
1911 (gnus-newsgroup-expunged-tally . 0)
1912 gnus-cache-removable-articles gnus-newsgroup-cached
1913 gnus-newsgroup-data gnus-newsgroup-data-reverse
1914 gnus-newsgroup-limit gnus-newsgroup-limits)
1915 "Variables that are buffer-local to the summary buffers.")
1917 (defconst gnus-bug-message
1918 "Sending a bug report to the Gnus Towers.
1919 ========================================
1921 The buffer below is a mail buffer. When you press `C-c C-c', it will
1922 be sent to the Gnus Bug Exterminators.
1924 At the bottom of the buffer you'll see lots of variable settings.
1925 Please do not delete those. They will tell the Bug People what your
1926 environment is, so that it will be easier to locate the bugs.
1928 If you have found a bug that makes Emacs go \"beep\", set
1929 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1930 and include the backtrace in your bug report.
1932 Please describe the bug in annoying, painstaking detail.
1934 Thank you for your help in stamping out bugs.
1937 ;;; End of variables.
1939 ;; Define some autoload functions Gnus might use.
1942 ;; This little mapcar goes through the list below and marks the
1943 ;; symbols in question as autoloaded functions.
1946 (let ((interactive (nth 1 (memq ':interactive package))))
1950 (when (consp function)
1951 (setq keymap (car (memq 'keymap function)))
1952 (setq function (car function)))
1953 (autoload function (car package) nil interactive keymap)))
1954 (if (eq (nth 1 package) ':interactive)
1957 '(("metamail" metamail-buffer)
1958 ("info" Info-goto-node)
1959 ("hexl" hexl-hex-string-to-integer)
1960 ("pp" pp pp-to-string pp-eval-expression)
1961 ("mail-extr" mail-extract-address-components)
1962 ("nnmail" nnmail-split-fancy nnmail-article-group)
1963 ("nnvirtual" nnvirtual-catchup-group)
1964 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1965 timezone-make-sortable-date timezone-make-time-string)
1966 ("sendmail" mail-position-on-field mail-setup)
1967 ("rmailout" rmail-output)
1968 ("rnewspost" news-mail-other-window news-reply-yank-original
1969 news-caesar-buffer-body)
1970 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1972 ("gnus-soup" :interactive t
1973 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1974 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1975 ("nnsoup" nnsoup-pack-replies)
1976 ("gnus-scomo" :interactive t gnus-score-mode)
1977 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1978 gnus-Folder-save-name gnus-folder-save-name)
1979 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1980 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1981 gnus-server-make-menu-bar gnus-article-make-menu-bar
1982 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1983 gnus-summary-highlight-line gnus-carpal-setup-buffer
1984 gnus-group-highlight-line
1985 gnus-article-add-button gnus-insert-next-page-button
1986 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1987 ("gnus-vis" :interactive t
1988 gnus-article-push-button gnus-article-press-button
1989 gnus-article-highlight gnus-article-highlight-some
1990 gnus-article-highlight-headers gnus-article-highlight-signature
1991 gnus-article-add-buttons gnus-article-add-buttons-to-head
1992 gnus-article-next-button gnus-article-prev-button)
1993 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1994 gnus-demon-add-disconnection gnus-demon-add-handler
1995 gnus-demon-remove-handler)
1996 ("gnus-demon" :interactive t
1997 gnus-demon-init gnus-demon-cancel)
1998 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
1999 gnus-tree-open gnus-tree-close)
2000 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2001 gnus-nocem-unwanted-article-p)
2002 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2003 ("gnus-srvr" gnus-browse-foreign-server)
2004 ("gnus-cite" :interactive t
2005 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2006 gnus-article-hide-citation gnus-article-fill-cited-article)
2007 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2008 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2009 gnus-execute gnus-expunge)
2010 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2011 gnus-cache-possibly-remove-articles gnus-cache-request-article
2012 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2013 gnus-cache-enter-remove-article gnus-cached-article-p
2014 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2015 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2016 gnus-cache-remove-article)
2017 ("gnus-score" :interactive t
2018 gnus-summary-increase-score gnus-summary-lower-score
2019 gnus-score-flush-cache gnus-score-close
2020 gnus-score-raise-same-subject-and-select
2021 gnus-score-raise-same-subject gnus-score-default
2022 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2023 gnus-score-lower-same-subject gnus-score-lower-thread
2024 gnus-possibly-score-headers)
2026 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2027 gnus-current-score-file-nondirectory gnus-score-adaptive
2028 gnus-score-find-trace gnus-score-file-name)
2029 ("gnus-edit" :interactive t gnus-score-customize)
2030 ("gnus-topic" :interactive t gnus-topic-mode)
2031 ("gnus-topic" gnus-topic-remove-group)
2032 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2033 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2034 ("gnus-uu" :interactive t
2035 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2036 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2037 gnus-uu-mark-by-regexp gnus-uu-mark-all
2038 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2039 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2040 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2041 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2042 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2043 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2044 gnus-uu-decode-binhex-view)
2045 ("gnus-msg" (gnus-summary-send-map keymap)
2046 gnus-mail-yank-original gnus-mail-send-and-exit
2047 gnus-sendmail-setup-mail gnus-article-mail
2048 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2049 ("gnus-msg" :interactive t
2050 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2051 gnus-summary-followup gnus-summary-followup-with-original
2052 gnus-summary-followup-and-reply
2053 gnus-summary-followup-and-reply-with-original
2054 gnus-summary-cancel-article gnus-summary-supersede-article
2055 gnus-post-news gnus-inews-news gnus-cancel-news
2056 gnus-summary-reply gnus-summary-reply-with-original
2057 gnus-summary-mail-forward gnus-summary-mail-other-window
2059 ("gnus-picon" :interactive t gnus-article-display-picons
2060 gnus-group-display-picons gnus-picons-article-display-x-face)
2061 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2062 gnus-grouplens-mode)
2063 ("gnus-vm" gnus-vm-mail-setup)
2064 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2065 gnus-summary-save-article-vm gnus-yank-article))))
2069 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2070 ;; If you want the cursor to go somewhere else, set these two
2071 ;; functions in some startup hook to whatever you want.
2072 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2073 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2075 ;;; Various macros and substs.
2077 (defun gnus-header-from (header)
2078 (mail-header-from header))
2080 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2081 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2082 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2083 `(let ((,tempvar (selected-window)))
2086 (pop-to-buffer ,buffer)
2088 (select-window ,tempvar)))))
2090 (defmacro gnus-gethash (string hashtable)
2091 "Get hash value of STRING in HASHTABLE."
2092 `(symbol-value (intern-soft ,string ,hashtable)))
2094 (defmacro gnus-sethash (string value hashtable)
2095 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2096 `(set (intern ,string ,hashtable) ,value))
2098 (defmacro gnus-intern-safe (string hashtable)
2099 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2100 `(let ((symbol (intern ,string ,hashtable)))
2105 (defmacro gnus-group-unread (group)
2106 "Get the currently computed number of unread articles in GROUP."
2107 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2109 (defmacro gnus-group-entry (group)
2110 "Get the newsrc entry for GROUP."
2111 `(gnus-gethash ,group gnus-newsrc-hashtb))
2113 (defmacro gnus-active (group)
2114 "Get active info on GROUP."
2115 `(gnus-gethash ,group gnus-active-hashtb))
2117 (defmacro gnus-set-active (group active)
2118 "Set GROUP's active info."
2119 `(gnus-sethash ,group ,active gnus-active-hashtb))
2121 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2122 ;; function `substring' might cut on a middle of multi-octet
2124 (defun gnus-truncate-string (str width)
2125 (substring str 0 width))
2127 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2128 ;; to limit the length of a string. This function is necessary since
2129 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2130 (defsubst gnus-limit-string (str width)
2131 (if (> (length str) width)
2132 (substring str 0 width)
2135 (defsubst gnus-simplify-subject-re (subject)
2136 "Remove \"Re:\" from subject lines."
2137 (if (string-match "^[Rr][Ee]: *" subject)
2138 (substring subject (match-end 0))
2141 (defsubst gnus-functionp (form)
2142 "Return non-nil if FORM is funcallable."
2143 (or (and (symbolp form) (fboundp form))
2144 (and (listp form) (eq (car form) 'lambda))))
2146 (defsubst gnus-goto-char (point)
2147 (and point (goto-char point)))
2149 (defmacro gnus-buffer-exists-p (buffer)
2150 `(let ((buffer ,buffer))
2152 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2155 (defmacro gnus-kill-buffer (buffer)
2156 `(let ((buf ,buffer))
2157 (if (gnus-buffer-exists-p buf)
2158 (kill-buffer buf))))
2160 (defsubst gnus-point-at-bol ()
2161 "Return point at the beginning of the line."
2168 (defsubst gnus-point-at-eol ()
2169 "Return point at the end of the line."
2176 (defun gnus-alive-p ()
2177 "Say whether Gnus is running or not."
2178 (and gnus-group-buffer
2179 (get-buffer gnus-group-buffer)))
2181 ;; Delete the current line (and the next N lines.);
2182 (defmacro gnus-delete-line (&optional n)
2183 `(delete-region (progn (beginning-of-line) (point))
2184 (progn (forward-line ,(or n 1)) (point))))
2186 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2187 (defvar gnus-init-inhibit nil)
2188 (defun gnus-read-init-file (&optional inhibit-next)
2189 (if gnus-init-inhibit
2190 (setq gnus-init-inhibit nil)
2191 (setq gnus-init-inhibit inhibit-next)
2193 (or (and (file-exists-p gnus-init-file)
2194 ;; Don't try to load a directory.
2195 (not (file-directory-p gnus-init-file)))
2196 (file-exists-p (concat gnus-init-file ".el"))
2197 (file-exists-p (concat gnus-init-file ".elc")))
2199 (load gnus-init-file nil t)
2201 (error "Error in %s: %s" gnus-init-file var))))))
2203 ;; Info access macros.
2205 (defmacro gnus-info-group (info)
2207 (defmacro gnus-info-rank (info)
2209 (defmacro gnus-info-read (info)
2211 (defmacro gnus-info-marks (info)
2213 (defmacro gnus-info-method (info)
2215 (defmacro gnus-info-params (info)
2218 (defmacro gnus-info-level (info)
2219 `(let ((rank (gnus-info-rank ,info)))
2223 (defmacro gnus-info-score (info)
2224 `(let ((rank (gnus-info-rank ,info)))
2225 (or (and (consp rank) (cdr rank)) 0)))
2227 (defmacro gnus-info-set-group (info group)
2228 `(setcar ,info ,group))
2229 (defmacro gnus-info-set-rank (info rank)
2230 `(setcar (nthcdr 1 ,info) ,rank))
2231 (defmacro gnus-info-set-read (info read)
2232 `(setcar (nthcdr 2 ,info) ,read))
2233 (defmacro gnus-info-set-marks (info marks)
2234 `(setcar (nthcdr 3 ,info) ,marks))
2235 (defmacro gnus-info-set-method (info method)
2236 `(setcar (nthcdr 4 ,info) ,method))
2237 (defmacro gnus-info-set-params (info params)
2238 `(setcar (nthcdr 5 ,info) ,params))
2240 (defmacro gnus-info-set-level (info level)
2241 `(let ((rank (cdr ,info)))
2242 (if (consp (car rank))
2243 (setcar (car rank) ,level)
2244 (setcar rank ,level))))
2245 (defmacro gnus-info-set-score (info score)
2246 `(let ((rank (cdr ,info)))
2247 (if (consp (car rank))
2248 (setcdr (car rank) ,score)
2249 (setcar rank (cons (car rank) ,score)))))
2251 (defmacro gnus-get-info (group)
2252 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2254 (defun gnus-byte-code (func)
2255 "Return a form that can be `eval'ed based on FUNC."
2256 (let ((fval (symbol-function func)))
2257 (if (byte-code-function-p fval)
2258 (let ((flist (append fval nil)))
2259 (setcar flist 'byte-code)
2261 (cons 'progn (cddr fval)))))
2263 ;;; Load the compatability functions.
2273 (defvar gnus-shutdown-alist nil)
2275 (defun gnus-add-shutdown (function &rest symbols)
2276 "Run FUNCTION whenever one of SYMBOLS is shut down."
2277 (push (cons function symbols) gnus-shutdown-alist))
2279 (defun gnus-shutdown (symbol)
2280 "Shut down everything that waits for SYMBOL."
2281 (let ((alist gnus-shutdown-alist)
2283 (while (setq entry (pop alist))
2284 (when (memq symbol (cdr entry))
2285 (funcall (car entry))))))
2289 ;; Format specs. The chunks below are the machine-generated forms
2290 ;; that are to be evaled as the result of the default format strings.
2291 ;; We write them in here to get them byte-compiled. That way the
2292 ;; default actions will be quite fast, while still retaining the full
2293 ;; flexibility of the user-defined format specs.
2295 ;; First we have lots of dummy defvars to let the compiler know these
2296 ;; are really dynamic variables.
2298 (defvar gnus-tmp-unread)
2299 (defvar gnus-tmp-replied)
2300 (defvar gnus-tmp-score-char)
2301 (defvar gnus-tmp-indentation)
2302 (defvar gnus-tmp-opening-bracket)
2303 (defvar gnus-tmp-lines)
2304 (defvar gnus-tmp-name)
2305 (defvar gnus-tmp-closing-bracket)
2306 (defvar gnus-tmp-subject-or-nil)
2307 (defvar gnus-tmp-subject)
2308 (defvar gnus-tmp-marked)
2309 (defvar gnus-tmp-marked-mark)
2310 (defvar gnus-tmp-subscribed)
2311 (defvar gnus-tmp-process-marked)
2312 (defvar gnus-tmp-number-of-unread)
2313 (defvar gnus-tmp-group-name)
2314 (defvar gnus-tmp-group)
2315 (defvar gnus-tmp-article-number)
2316 (defvar gnus-tmp-unread-and-unselected)
2317 (defvar gnus-tmp-news-method)
2318 (defvar gnus-tmp-news-server)
2319 (defvar gnus-tmp-article-number)
2320 (defvar gnus-mouse-face)
2321 (defvar gnus-mouse-face-prop)
2323 (defun gnus-summary-line-format-spec ()
2324 (insert gnus-tmp-unread gnus-tmp-replied
2325 gnus-tmp-score-char gnus-tmp-indentation)
2330 gnus-tmp-opening-bracket
2331 (format "%4d: %-20s"
2333 (if (> (length gnus-tmp-name) 20)
2334 (substring gnus-tmp-name 0 20)
2336 gnus-tmp-closing-bracket)
2338 gnus-mouse-face-prop gnus-mouse-face)
2339 (insert " " gnus-tmp-subject-or-nil "\n"))
2341 (defvar gnus-summary-line-format-spec
2342 (gnus-byte-code 'gnus-summary-line-format-spec))
2344 (defun gnus-summary-dummy-line-format-spec ()
2351 gnus-mouse-face-prop gnus-mouse-face)
2352 (insert " " gnus-tmp-subject "\n"))
2354 (defvar gnus-summary-dummy-line-format-spec
2355 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2357 (defun gnus-group-line-format-spec ()
2358 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2359 gnus-tmp-process-marked
2360 gnus-group-indentation
2361 (format "%5s: " gnus-tmp-number-of-unread))
2365 (insert gnus-tmp-group "\n")
2367 gnus-mouse-face-prop gnus-mouse-face))
2368 (defvar gnus-group-line-format-spec
2369 (gnus-byte-code 'gnus-group-line-format-spec))
2371 (defvar gnus-format-specs
2372 `((version . ,emacs-version)
2373 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2374 (summary-dummy ,gnus-summary-dummy-line-format
2375 ,gnus-summary-dummy-line-format-spec)
2376 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2378 (defvar gnus-article-mode-line-format-spec nil)
2379 (defvar gnus-summary-mode-line-format-spec nil)
2380 (defvar gnus-group-mode-line-format-spec nil)
2382 ;;; Phew. All that gruft is over, fortunately.
2386 ;;; Gnus Utility Functions
2389 (defun gnus-extract-address-components (from)
2391 ;; First find the address - the thing with the @ in it. This may
2392 ;; not be accurate in mail addresses, but does the trick most of
2393 ;; the time in news messages.
2394 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2395 (setq address (substring from (match-beginning 0) (match-end 0))))
2396 ;; Then we check whether the "name <address>" format is used.
2398 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2399 ;; Linear white space is not required.
2400 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2401 (and (setq name (substring from 0 (match-beginning 0)))
2402 ;; Strip any quotes from the name.
2403 (string-match "\".*\"" name)
2404 (setq name (substring name 1 (1- (match-end 0))))))
2405 ;; If not, then "address (name)" is used.
2407 (and (string-match "(.+)" from)
2408 (setq name (substring from (1+ (match-beginning 0))
2409 (1- (match-end 0)))))
2410 (and (string-match "()" from)
2411 (setq name address))
2412 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2413 ;; XOVER might not support folded From headers.
2414 (and (string-match "(.*" from)
2415 (setq name (substring from (1+ (match-beginning 0))
2417 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2418 (list (or name from) (or address from))))
2420 (defun gnus-fetch-field (field)
2421 "Return the value of the header FIELD of current article."
2424 (let ((case-fold-search t)
2425 (inhibit-point-motion-hooks t))
2426 (nnheader-narrow-to-headers)
2427 (mail-fetch-field field)))))
2429 (defun gnus-goto-colon ()
2431 (search-forward ":" (gnus-point-at-eol) t))
2434 (defun gnus-update-format (var)
2435 "Update the format specification near point."
2440 ;; Find the end of the current word.
2441 (re-search-forward "[ \t\n]" nil t)
2443 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2444 (match-string 1)))))
2445 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2446 (match-string 1 var))))
2447 (entry (assq type gnus-format-specs))
2450 (setq gnus-format-specs (delq entry gnus-format-specs)))
2452 (intern (format "%s-spec" var))
2453 (gnus-parse-format (setq value (symbol-value (intern var)))
2454 (symbol-value (intern (format "%s-alist" var)))
2455 (not (string-match "mode" var))))
2456 (setq spec (symbol-value (intern (format "%s-spec" var))))
2457 (push (list type value spec) gnus-format-specs)
2459 (pop-to-buffer "*Gnus Format*")
2461 (lisp-interaction-mode)
2462 (insert (pp-to-string spec))))
2464 (defun gnus-update-format-specifications (&optional force)
2465 "Update all (necessary) format specifications."
2466 ;; Make the indentation array.
2467 (gnus-make-thread-indent-array)
2469 ;; See whether all the stored info needs to be flushed.
2471 (not (equal emacs-version
2472 (cdr (assq 'version gnus-format-specs)))))
2473 (setq gnus-format-specs nil))
2475 ;; Go through all the formats and see whether they need updating.
2476 (let ((types '(summary summary-dummy group
2477 summary-mode group-mode article-mode))
2478 new-format entry type val)
2479 (while (setq type (pop types))
2480 ;; Jump to the proper buffer to find out the value of
2481 ;; the variable, if possible. (It may be buffer-local.)
2483 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2485 (when (and (boundp buffer)
2486 (setq val (symbol-value buffer))
2488 (buffer-name (get-buffer val)))
2489 (set-buffer (get-buffer val)))
2490 (setq new-format (symbol-value
2491 (intern (format "gnus-%s-line-format" type))))))
2492 (setq entry (cdr (assq type gnus-format-specs)))
2494 (equal (car entry) new-format))
2495 ;; Use the old format.
2496 (set (intern (format "gnus-%s-line-format-spec" type))
2498 ;; This is a new format.
2500 (if (not (stringp new-format))
2501 ;; This is a function call or something.
2503 ;; This is a "real" format.
2507 (intern (format "gnus-%s-line-format-alist"
2508 (if (eq type 'article-mode)
2509 'summary-mode type))))
2510 (not (string-match "mode$" (symbol-name type))))))
2511 ;; Enter the new format spec into the list.
2514 (setcar (cdr entry) val)
2515 (setcar entry new-format))
2516 (push (list type new-format val) gnus-format-specs))
2517 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2519 (unless (assq 'version gnus-format-specs)
2520 (push (cons 'version emacs-version) gnus-format-specs))
2522 (gnus-update-group-mark-positions)
2523 (gnus-update-summary-mark-positions))
2525 (defun gnus-update-summary-mark-positions ()
2526 "Compute where the summary marks are to go."
2528 (let ((gnus-replied-mark 129)
2529 (gnus-score-below-mark 130)
2530 (gnus-score-over-mark 130)
2534 (gnus-set-work-buffer)
2535 (gnus-summary-insert-line
2536 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2537 (goto-char (point-min))
2538 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2540 (goto-char (point-min))
2541 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2543 (goto-char (point-min))
2544 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2546 (setq gnus-summary-mark-positions pos))))
2548 (defun gnus-update-group-mark-positions ()
2550 (let ((gnus-process-mark 128)
2551 (gnus-group-marked '("dummy.group")))
2552 (gnus-set-active "dummy.group" '(0 . 0))
2553 (gnus-set-work-buffer)
2554 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2555 (goto-char (point-min))
2556 (setq gnus-group-mark-positions
2557 (list (cons 'process (and (search-forward "\200" nil t)
2558 (- (point) 2))))))))
2560 (defvar gnus-mouse-face-0 'highlight)
2561 (defvar gnus-mouse-face-1 'highlight)
2562 (defvar gnus-mouse-face-2 'highlight)
2563 (defvar gnus-mouse-face-3 'highlight)
2564 (defvar gnus-mouse-face-4 'highlight)
2566 (defun gnus-mouse-face-function (form type)
2568 (point) (progn ,@form (point))
2569 gnus-mouse-face-prop
2572 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2574 (defvar gnus-face-0 'bold)
2575 (defvar gnus-face-1 'italic)
2576 (defvar gnus-face-2 'bold-italic)
2577 (defvar gnus-face-3 'bold)
2578 (defvar gnus-face-4 'bold)
2580 (defun gnus-face-face-function (form type)
2582 (point) (progn ,@form (point))
2583 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2585 (defun gnus-max-width-function (el max-width)
2586 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2588 `(if (> (length ,el) ,max-width)
2589 (substring ,el 0 ,max-width)
2591 `(let ((val (eval ,el)))
2593 (setq val (int-to-string val)))
2594 (if (> (length val) ,max-width)
2595 (substring val 0 ,max-width)
2598 (defun gnus-parse-format (format spec-alist &optional insert)
2599 ;; This function parses the FORMAT string with the help of the
2600 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2601 ;; string. If the FORMAT string contains the specifiers %( and %)
2602 ;; the text between them will have the mouse-face text property.
2604 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2606 (gnus-parse-complex-format format spec-alist)
2607 ;; This is a simple format.
2608 (gnus-parse-simple-format format spec-alist insert)))
2610 (defun gnus-parse-complex-format (format spec-alist)
2612 (gnus-set-work-buffer)
2614 (goto-char (point-min))
2615 (while (re-search-forward "\"" nil t)
2616 (replace-match "\\\"" nil t))
2617 (goto-char (point-min))
2619 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2620 (let ((number (if (match-beginning 1)
2621 (match-string 1) "0"))
2622 (delim (aref (match-string 2) 0)))
2623 (if (or (= delim ?\() (= delim ?\{))
2624 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2626 (replace-match "\")\""))))
2627 (goto-char (point-max))
2629 (goto-char (point-min))
2630 (let ((form (read (current-buffer))))
2631 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2633 (defun gnus-complex-form-to-spec (form spec-alist)
2638 (gnus-parse-simple-format sform spec-alist t)
2639 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2640 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2644 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2645 ;; This function parses the FORMAT string with the help of the
2646 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2649 spec flist fstring newspec elem beg result dontinsert)
2651 (gnus-set-work-buffer)
2653 (goto-char (point-min))
2654 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2656 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2658 beg (1+ (match-beginning 0)))
2659 ;; First check if there are any specs that look anything like
2660 ;; "%12,12A", ie. with a "max width specification". These have
2661 ;; to be treated specially.
2662 (if (setq beg (match-beginning 1))
2666 (1+ (match-beginning 1)) (match-end 1))))
2668 (setq beg (match-beginning 2)))
2669 ;; Find the specification from `spec-alist'.
2670 (unless (setq elem (cdr (assq spec spec-alist)))
2671 (setq elem '("*" ?s)))
2672 ;; Treat user defined format specifiers specially.
2673 (when (eq (car elem) 'gnus-tmp-user-defined)
2676 (list (intern (concat "gnus-user-format-function-"
2678 'gnus-tmp-header) ?s))
2679 (delete-region (match-beginning 3) (match-end 3)))
2680 (if (not (zerop max-width))
2681 (let ((el (car elem)))
2682 (cond ((= (cadr elem) ?c)
2683 (setq el (list 'char-to-string el)))
2685 (setq el (list 'int-to-string el))))
2686 (setq flist (cons (gnus-max-width-function el max-width)
2690 (setq flist (cons (car elem) flist))
2691 (setq newspec (cadr elem)))))
2692 ;; Remove the old specification (and possibly a ",12" string).
2693 (delete-region beg (match-end 2))
2694 ;; Insert the new specification.
2697 (setq fstring (buffer-substring 1 (point-max))))
2698 ;; Do some postprocessing to increase efficiency.
2703 ((string= fstring "")
2705 ;; Not a format string.
2706 ((not (string-match "%" fstring))
2708 ;; A format string with just a single string spec.
2709 ((string= fstring "%s")
2711 ;; A single character.
2712 ((string= fstring "%c")
2715 ((string= fstring "%d")
2718 (list `(princ ,(car flist)))
2719 (list `(int-to-string ,(car flist)))))
2720 ;; Just lots of chars and strings.
2721 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2723 ;; A single string spec at the beginning of the spec.
2724 ((string-match "\\`%[sc][^%]+\\'" fstring)
2725 (list (car flist) (substring fstring 2)))
2726 ;; A single string spec in the middle of the spec.
2727 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2728 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2729 ;; A single string spec in the end of the spec.
2730 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2731 (list (match-string 1 fstring) (car flist)))
2732 ;; A more complex spec.
2734 (list (cons 'format (cons fstring (nreverse flist)))))))
2740 (cons 'insert result)))
2741 (cond ((stringp result)
2744 (cons 'concat result))
2747 (defun gnus-eval-format (format &optional alist props)
2748 "Eval the format variable FORMAT, using ALIST.
2749 If PROPS, insert the result."
2750 (let ((form (gnus-parse-format format alist props)))
2752 (add-text-properties (point) (progn (eval form) (point)) props)
2755 (defun gnus-remove-text-with-property (prop)
2756 "Delete all text in the current buffer with text property PROP."
2758 (goto-char (point-min))
2760 (while (get-text-property (point) prop)
2762 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2764 (defun gnus-set-work-buffer ()
2765 (if (get-buffer gnus-work-buffer)
2767 (set-buffer gnus-work-buffer)
2769 (set-buffer (get-buffer-create gnus-work-buffer))
2770 (kill-all-local-variables)
2771 (buffer-disable-undo (current-buffer))
2772 (gnus-add-current-to-buffer-list)))
2774 ;; Article file names when saving.
2776 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2777 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2778 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2779 Otherwise, it is like ~/News/news/group/num."
2782 (concat (if (gnus-use-long-file-name 'not-save)
2783 (gnus-capitalize-newsgroup newsgroup)
2784 (gnus-newsgroup-directory-form newsgroup))
2785 "/" (int-to-string (mail-header-number headers)))
2786 (or gnus-article-save-directory "~/News"))))
2788 (string-equal (file-name-directory default)
2789 (file-name-directory last-file))
2790 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2792 (or last-file default))))
2794 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2795 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2796 If variable `gnus-use-long-file-name' is non-nil, it is
2797 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2800 (concat (if (gnus-use-long-file-name 'not-save)
2802 (gnus-newsgroup-directory-form newsgroup))
2803 "/" (int-to-string (mail-header-number headers)))
2804 (or gnus-article-save-directory "~/News"))))
2806 (string-equal (file-name-directory default)
2807 (file-name-directory last-file))
2808 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2810 (or last-file default))))
2812 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2813 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2814 If variable `gnus-use-long-file-name' is non-nil, it is
2815 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2818 (if (gnus-use-long-file-name 'not-save)
2819 (gnus-capitalize-newsgroup newsgroup)
2820 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2821 (or gnus-article-save-directory "~/News"))))
2823 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2824 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2825 If variable `gnus-use-long-file-name' is non-nil, it is
2826 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2829 (if (gnus-use-long-file-name 'not-save)
2831 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2832 (or gnus-article-save-directory "~/News"))))
2834 ;; For subscribing new newsgroup
2836 (defun gnus-subscribe-hierarchical-interactive (groups)
2837 (let ((groups (sort groups 'string<))
2838 prefixes prefix start ans group starts)
2840 (setq prefixes (list "^"))
2841 (while (and groups prefixes)
2842 (while (not (string-match (car prefixes) (car groups)))
2843 (setq prefixes (cdr prefixes)))
2844 (setq prefix (car prefixes))
2845 (setq start (1- (length prefix)))
2846 (if (and (string-match "[^\\.]\\." (car groups) start)
2849 (concat "^" (substring (car groups) 0 (match-end 0))))
2850 (string-match prefix (cadr groups)))
2852 (setq prefixes (cons prefix prefixes))
2853 (message "Descend hierarchy %s? ([y]nsq): "
2854 (substring prefix 1 (1- (length prefix))))
2855 (setq ans (read-char))
2858 (string-match prefix
2859 (setq group (car groups))))
2860 (setq gnus-killed-list
2861 (cons group gnus-killed-list))
2862 (gnus-sethash group group gnus-killed-hashtb)
2863 (setq groups (cdr groups)))
2864 (setq starts (cdr starts)))
2867 (string-match prefix
2868 (setq group (car groups))))
2869 (gnus-sethash group group gnus-killed-hashtb)
2870 (gnus-subscribe-alphabetically (car groups))
2871 (setq groups (cdr groups)))
2872 (setq starts (cdr starts)))
2875 (setq group (car groups))
2876 (setq gnus-killed-list (cons group gnus-killed-list))
2877 (gnus-sethash group group gnus-killed-hashtb)
2878 (setq groups (cdr groups))))
2880 (message "Subscribe %s? ([n]yq)" (car groups))
2881 (setq ans (read-char))
2882 (setq group (car groups))
2884 (gnus-subscribe-alphabetically (car groups))
2885 (gnus-sethash group group gnus-killed-hashtb))
2888 (setq group (car groups))
2889 (setq gnus-killed-list (cons group gnus-killed-list))
2890 (gnus-sethash group group gnus-killed-hashtb)
2891 (setq groups (cdr groups))))
2893 (setq gnus-killed-list (cons group gnus-killed-list))
2894 (gnus-sethash group group gnus-killed-hashtb)))
2895 (setq groups (cdr groups)))))))
2897 (defun gnus-subscribe-randomly (newsgroup)
2898 "Subscribe new NEWSGROUP by making it the first newsgroup."
2899 (gnus-subscribe-newsgroup newsgroup))
2901 (defun gnus-subscribe-alphabetically (newgroup)
2902 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2903 (let ((groups (cdr gnus-newsrc-alist))
2905 (while (and (not before) groups)
2906 (if (string< newgroup (caar groups))
2907 (setq before (caar groups))
2908 (setq groups (cdr groups))))
2909 (gnus-subscribe-newsgroup newgroup before)))
2911 (defun gnus-subscribe-hierarchically (newgroup)
2912 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2913 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2915 (set-buffer (find-file-noselect gnus-current-startup-file))
2916 (let ((groupkey newgroup)
2918 (while (and (not before) groupkey)
2919 (goto-char (point-min))
2921 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2922 (while (and (re-search-forward groupkey-re nil t)
2924 (setq before (match-string 1))
2925 (string< before newgroup)))))
2926 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2928 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2929 (substring groupkey (match-beginning 1) (match-end 1)))))
2930 (gnus-subscribe-newsgroup newgroup before))))
2932 (defun gnus-subscribe-interactively (group)
2933 "Subscribe the new GROUP interactively.
2934 It is inserted in hierarchical newsgroup order if subscribed. If not,
2936 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2937 (gnus-subscribe-hierarchically group)
2938 (push group gnus-killed-list)))
2940 (defun gnus-subscribe-zombies (group)
2941 "Make the new GROUP into a zombie group."
2942 (push group gnus-zombie-list))
2944 (defun gnus-subscribe-killed (group)
2945 "Make the new GROUP a killed group."
2946 (push group gnus-killed-list))
2948 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2949 "Subscribe new NEWSGROUP.
2950 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2951 the first newsgroup."
2952 ;; We subscribe the group by changing its level to `subscribed'.
2953 (gnus-group-change-level
2954 newsgroup gnus-level-default-subscribed
2955 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2956 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2960 (defun gnus-newsgroup-directory-form (newsgroup)
2961 "Make hierarchical directory name from NEWSGROUP name."
2962 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2963 (len (length newsgroup))
2965 ;; If this is a foreign group, we don't want to translate the
2967 (if (setq idx (string-match ":" newsgroup))
2968 (aset newsgroup idx ?/)
2970 ;; Replace all occurrences of `.' with `/'.
2972 (if (= (aref newsgroup idx) ?.)
2973 (aset newsgroup idx ?/))
2974 (setq idx (1+ idx)))
2977 (defun gnus-newsgroup-savable-name (group)
2978 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2980 (nnheader-replace-chars-in-string group ?/ ?.))
2982 (defun gnus-make-directory (dir)
2983 "Make DIRECTORY recursively."
2984 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2985 ;; of the many mysteries of the universe.
2986 (let* ((dir (expand-file-name dir default-directory))
2988 (if (string-match "/$" dir)
2989 (setq dir (substring dir 0 (match-beginning 0))))
2990 ;; First go down the path until we find a directory that exists.
2991 (while (not (file-exists-p dir))
2992 (setq dirs (cons dir dirs))
2993 (string-match "/[^/]+$" dir)
2994 (setq dir (substring dir 0 (match-beginning 0))))
2995 ;; Then create all the subdirs.
2996 (while (and dirs (not err))
2998 (make-directory (car dirs))
2999 (error (setq err t)))
3000 (setq dirs (cdr dirs)))
3001 ;; We return whether we were successful or not.
3004 (defun gnus-capitalize-newsgroup (newsgroup)
3005 "Capitalize NEWSGROUP name."
3006 (and (not (zerop (length newsgroup)))
3007 (concat (char-to-string (upcase (aref newsgroup 0)))
3008 (substring newsgroup 1))))
3010 ;; Various... things.
3012 (defun gnus-simplify-subject (subject &optional re-only)
3013 "Remove `Re:' and words in parentheses.
3014 If RE-ONLY is non-nil, strip leading `Re:'s only."
3015 (let ((case-fold-search t)) ;Ignore case.
3016 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3017 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3018 (setq subject (substring subject (match-end 0))))
3019 ;; Remove uninteresting prefixes.
3020 (if (and (not re-only)
3021 gnus-simplify-ignored-prefixes
3022 (string-match gnus-simplify-ignored-prefixes subject))
3023 (setq subject (substring subject (match-end 0))))
3024 ;; Remove words in parentheses from end.
3026 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3027 (setq subject (substring subject 0 (match-beginning 0)))))
3028 ;; Return subject string.
3031 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3033 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3034 (defun gnus-simplify-buffer-fuzzy ()
3035 (goto-char (point-min))
3036 (while (search-forward "\t" nil t)
3037 (replace-match " " t t))
3038 (goto-char (point-min))
3039 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3040 (goto-char (match-beginning 0))
3042 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3043 (looking-at "^[[].*: .*[]]$"))
3044 (goto-char (point-min))
3045 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3047 (replace-match "" t t))
3048 (goto-char (point-min))
3049 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3050 (goto-char (match-end 0))
3053 (progn (goto-char (match-beginning 0)))
3054 (re-search-forward ":"))))
3055 (goto-char (point-min))
3056 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3057 (replace-match "" t t))
3058 (goto-char (point-min))
3059 (while (re-search-forward " +" nil t)
3060 (replace-match " " t t))
3061 (goto-char (point-min))
3062 (while (re-search-forward " $" nil t)
3063 (replace-match "" t t))
3064 (goto-char (point-min))
3065 (while (re-search-forward "^ +" nil t)
3066 (replace-match "" t t))
3067 (goto-char (point-min))
3068 (when gnus-simplify-subject-fuzzy-regexp
3069 (if (listp gnus-simplify-subject-fuzzy-regexp)
3070 (let ((list gnus-simplify-subject-fuzzy-regexp))
3072 (goto-char (point-min))
3073 (while (re-search-forward (car list) nil t)
3074 (replace-match "" t t))
3075 (setq list (cdr list))))
3076 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3077 (replace-match "" t t)))))
3079 (defun gnus-simplify-subject-fuzzy (subject)
3080 "Siplify a subject string fuzzily."
3082 (gnus-set-work-buffer)
3083 (let ((case-fold-search t))
3085 (inline (gnus-simplify-buffer-fuzzy))
3088 ;; Add the current buffer to the list of buffers to be killed on exit.
3089 (defun gnus-add-current-to-buffer-list ()
3090 (or (memq (current-buffer) gnus-buffer-list)
3091 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3093 (defun gnus-string> (s1 s2)
3094 (not (or (string< s1 s2)
3097 ;;; General various misc type functions.
3099 (defun gnus-clear-system ()
3100 "Clear all variables and buffers."
3101 ;; Clear Gnus variables.
3102 (let ((variables gnus-variable-list))
3104 (set (car variables) nil)
3105 (setq variables (cdr variables))))
3106 ;; Clear other internal variables.
3107 (setq gnus-list-of-killed-groups nil
3108 gnus-have-read-active-file nil
3109 gnus-newsrc-alist nil
3110 gnus-newsrc-hashtb nil
3111 gnus-killed-list nil
3112 gnus-zombie-list nil
3113 gnus-killed-hashtb nil
3114 gnus-active-hashtb nil
3115 gnus-moderated-list nil
3116 gnus-description-hashtb nil
3117 gnus-current-headers nil
3118 gnus-thread-indent-array nil
3119 gnus-newsgroup-headers nil
3120 gnus-newsgroup-name nil
3121 gnus-server-alist nil
3122 gnus-group-list-mode nil
3123 gnus-opened-servers nil
3124 gnus-current-select-method nil)
3125 (gnus-shutdown 'gnus)
3126 ;; Kill the startup file.
3127 (and gnus-current-startup-file
3128 (get-file-buffer gnus-current-startup-file)
3129 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3130 ;; Clear the dribble buffer.
3131 (gnus-dribble-clear)
3132 ;; Kill global KILL file buffer.
3133 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3134 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3135 (gnus-kill-buffer nntp-server-buffer)
3136 ;; Kill Gnus buffers.
3137 (while gnus-buffer-list
3138 (gnus-kill-buffer (pop gnus-buffer-list)))
3139 ;; Remove Gnus frames.
3140 (while gnus-created-frames
3141 (when (frame-live-p (car gnus-created-frames))
3142 ;; We slap a condition-case around this `delete-frame' to ensure
3143 ;; agains errors if we try do delete the single frame that's left.
3145 (delete-frame (car gnus-created-frames))
3147 (pop gnus-created-frames)))
3149 (defun gnus-windows-old-to-new (setting)
3150 ;; First we take care of the really, really old Gnus 3 actions.
3151 (when (symbolp setting)
3153 ;; Take care of ooold GNUS 3.x values.
3154 (cond ((eq setting 'SelectArticle) 'article)
3155 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3156 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3158 (if (or (listp setting)
3159 (not (and gnus-window-configuration
3160 (memq setting '(group summary article)))))
3162 (let* ((setting (if (eq setting 'group)
3163 (if (assq 'newsgroup gnus-window-configuration)
3165 'newsgroups) setting))
3166 (elem (cadr (assq setting gnus-window-configuration)))
3167 (total (apply '+ elem))
3168 (types '(group summary article))
3169 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3174 (or (not (numberp (nth i elem)))
3175 (zerop (nth i elem))
3177 (setq perc (/ (float (nth 0 elem)) total))
3178 (setq out (cons (if (eq pbuf (nth i types))
3179 (vector (nth i types) perc 'point)
3180 (vector (nth i types) perc))
3183 (list (nreverse out)))))
3186 (defun gnus-add-configuration (conf)
3187 "Add the window configuration CONF to `gnus-buffer-configuration'."
3188 (setq gnus-buffer-configuration
3189 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3190 gnus-buffer-configuration))))
3192 (defvar gnus-frame-list nil)
3194 (defun gnus-configure-frame (split &optional window)
3195 "Split WINDOW according to SPLIT."
3197 (setq window (get-buffer-window (current-buffer))))
3198 (select-window window)
3199 ;; This might be an old-stylee buffer config.
3200 (when (vectorp split)
3201 (setq split (append split nil)))
3202 (when (or (consp (car split))
3203 (vectorp (car split)))
3205 (push 'vertical split))
3206 ;; The SPLIT might be something that is to be evaled to
3207 ;; return a new SPLIT.
3208 (while (and (not (assq (car split) gnus-window-to-buffer))
3209 (gnus-functionp (car split)))
3210 (setq split (eval split)))
3211 (let* ((type (car split))
3213 (len (if (eq type 'horizontal) (window-width) (window-height)))
3215 (window-min-width (or gnus-window-min-width window-min-width))
3216 (window-min-height (or gnus-window-min-height window-min-height))
3217 s result new-win rest comp-subs size sub)
3219 ;; Nothing to do here.
3221 ;; Don't switch buffers.
3223 (and (memq 'point split) window))
3224 ;; This is a buffer to be selected.
3225 ((not (memq type '(frame horizontal vertical)))
3226 (let ((buffer (cond ((stringp type) type)
3227 (t (cdr (assq type gnus-window-to-buffer)))))
3230 (error "Illegal buffer type: %s" type))
3231 (unless (setq buf (get-buffer (if (symbolp buffer)
3232 (symbol-value buffer) buffer)))
3233 (setq buf (get-buffer-create (if (symbolp buffer)
3234 (symbol-value buffer) buffer))))
3235 (switch-to-buffer buf)
3236 ;; We return the window if it has the `point' spec.
3237 (and (memq 'point split) window)))
3238 ;; This is a frame split.
3240 (unless gnus-frame-list
3241 (setq gnus-frame-list (list (window-frame
3242 (get-buffer-window (current-buffer))))))
3244 params frame fresult)
3245 (while (< i (length subs))
3246 ;; Frame parameter is gotten from the sub-split.
3247 (setq params (cadr (elt subs i)))
3248 ;; It should be a list.
3249 (unless (listp params)
3251 ;; Create a new frame?
3252 (unless (setq frame (elt gnus-frame-list i))
3253 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3254 (push frame gnus-created-frames))
3255 ;; Is the old frame still alive?
3256 (unless (frame-live-p frame)
3257 (setcar (nthcdr i gnus-frame-list)
3258 (setq frame (make-frame params))))
3259 ;; Select the frame in question and do more splits there.
3260 (select-frame frame)
3261 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3263 ;; Select the frame that has the selected buffer.
3265 (select-frame (window-frame fresult)))))
3266 ;; This is a normal split.
3268 (when (> (length subs) 0)
3269 ;; First we have to compute the sizes of all new windows.
3271 (setq sub (append (pop subs) nil))
3272 (while (and (not (assq (car sub) gnus-window-to-buffer))
3273 (gnus-functionp (car sub)))
3274 (setq sub (eval sub)))
3276 (push sub comp-subs)
3277 (setq size (cadar comp-subs))
3278 (cond ((equal size 1.0)
3279 (setq rest (car comp-subs))
3282 (setq s (floor (* size len))))
3286 (error "Illegal size: %s" size)))
3287 ;; Try to make sure that we are inside the safe limits.
3289 ((eq type 'horizontal)
3290 (setq s (max s window-min-width)))
3291 ((eq type 'vertical)
3292 (setq s (max s window-min-height))))
3293 (setcar (cdar comp-subs) s)
3295 ;; Take care of the "1.0" spec.
3297 (setcar (cdr rest) (- len total))
3298 (error "No 1.0 specs in %s" split))
3299 ;; The we do the actual splitting in a nice recursive
3301 (setq comp-subs (nreverse comp-subs))
3303 (if (null (cdr comp-subs))
3304 (setq new-win window)
3306 (split-window window (cadar comp-subs)
3307 (eq type 'horizontal))))
3308 (setq result (or (gnus-configure-frame
3309 (car comp-subs) window) result))
3310 (select-window new-win)
3311 (setq window new-win)
3312 (setq comp-subs (cdr comp-subs))))
3313 ;; Return the proper window, if any.
3315 (select-window result))))))
3317 (defvar gnus-frame-split-p nil)
3319 (defun gnus-configure-windows (setting &optional force)
3320 (setq setting (gnus-windows-old-to-new setting))
3321 (let ((split (if (symbolp setting)
3322 (cadr (assq setting gnus-buffer-configuration))
3326 (setq gnus-frame-split-p nil)
3329 (error "No such setting: %s" setting))
3331 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3333 ;; All the windows mentioned are already visible, so we just
3334 ;; put point in the assigned buffer, and do not touch the
3336 (select-window all-visible)
3338 ;; Either remove all windows or just remove all Gnus windows.
3339 (let ((frame (selected-frame)))
3341 (if gnus-use-full-window
3342 ;; We want to remove all other windows.
3343 (if (not gnus-frame-split-p)
3344 ;; This is not a `frame' split, so we ignore the
3346 (delete-other-windows)
3347 ;; This is a `frame' split, so we delete all windows
3351 (unless (eq (cdr (assq 'minibuffer
3352 (frame-parameters frame)))
3354 (select-frame frame)
3355 (delete-other-windows)))
3357 ;; Just remove some windows.
3358 (gnus-remove-some-windows)
3359 (switch-to-buffer nntp-server-buffer))
3360 (select-frame frame)))
3362 (switch-to-buffer nntp-server-buffer)
3363 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3365 (defun gnus-all-windows-visible-p (split)
3366 "Say whether all buffers in SPLIT are currently visible.
3367 In particular, the value returned will be the window that
3369 (let ((stack (list split))
3371 type buffer win buf)
3372 (while (and (setq split (pop stack))
3374 ;; Be backwards compatible.
3375 (when (vectorp split)
3376 (setq split (append split nil)))
3377 (when (or (consp (car split))
3378 (vectorp (car split)))
3380 (push 'vertical split))
3381 ;; The SPLIT might be something that is to be evaled to
3382 ;; return a new SPLIT.
3383 (while (and (not (assq (car split) gnus-window-to-buffer))
3384 (gnus-functionp (car split)))
3385 (setq split (eval split)))
3387 (setq type (elt split 0))
3392 ((not (memq type '(horizontal vertical frame)))
3393 (setq buffer (cond ((stringp type) type)
3394 (t (cdr (assq type gnus-window-to-buffer)))))
3396 (error "Illegal buffer type: %s" type))
3397 (when (setq buf (get-buffer (if (symbolp buffer)
3398 (symbol-value buffer)
3400 (setq win (get-buffer-window buf t)))
3402 (when (memq 'point split)
3403 (setq all-visible win))
3404 (setq all-visible nil)))
3406 (when (eq type 'frame)
3407 (setq gnus-frame-split-p t))
3408 (setq stack (append (cddr split) stack)))))
3409 (unless (eq all-visible t)
3412 (defun gnus-window-top-edge (&optional window)
3413 (nth 1 (window-edges window)))
3415 (defun gnus-remove-some-windows ()
3416 (let ((buffers gnus-window-to-buffer)
3417 buf bufs lowest-buf lowest)
3419 ;; Remove windows on all known Gnus buffers.
3421 (setq buf (cdar buffers))
3423 (setq buf (and (boundp buf) (symbol-value buf))))
3425 (get-buffer-window buf)
3427 (setq bufs (cons buf bufs))
3429 (if (or (not lowest)
3430 (< (gnus-window-top-edge) lowest))
3432 (setq lowest (gnus-window-top-edge))
3433 (setq lowest-buf buf)))))
3434 (setq buffers (cdr buffers)))
3435 ;; Remove windows on *all* summary buffers.
3438 (let ((buf (window-buffer win)))
3439 (if (string-match "^\\*Summary" (buffer-name buf))
3441 (setq bufs (cons buf bufs))
3443 (if (or (not lowest)
3444 (< (gnus-window-top-edge) lowest))
3446 (setq lowest-buf buf)
3447 (setq lowest (gnus-window-top-edge)))))))))
3450 (pop-to-buffer lowest-buf)
3451 (switch-to-buffer nntp-server-buffer)))
3453 (and (not (eq (car bufs) lowest-buf))
3454 (delete-windows-on (car bufs)))
3455 (setq bufs (cdr bufs))))))
3457 (defun gnus-version ()
3458 "Version numbers of this version of Gnus."
3460 (let ((methods gnus-valid-select-methods)
3463 ;; Go through all the legal select methods and add their version
3464 ;; numbers to the total version string. Only the backends that are
3465 ;; currently in use will have their message numbers taken into
3468 (setq meth (intern (concat (caar methods) "-version")))
3470 (stringp (symbol-value meth))
3471 (setq mess (concat mess "; " (symbol-value meth))))
3472 (setq methods (cdr methods)))
3473 (gnus-message 2 mess)))
3475 (defun gnus-info-find-node ()
3476 "Find Info documentation of Gnus."
3478 ;; Enlarge info window if needed.
3479 (let ((mode major-mode)
3481 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3482 (setq gnus-info-buffer (current-buffer))
3483 (gnus-configure-windows 'info)))
3485 (defun gnus-days-between (date1 date2)
3486 ;; Return the number of days between date1 and date2.
3487 (- (gnus-day-number date1) (gnus-day-number date2)))
3489 (defun gnus-day-number (date)
3490 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3491 (timezone-parse-date date))))
3492 (timezone-absolute-from-gregorian
3493 (nth 1 dat) (nth 2 dat) (car dat))))
3495 (defun gnus-encode-date (date)
3496 "Convert DATE to internal time."
3497 (let* ((parse (timezone-parse-date date))
3498 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3499 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3500 (encode-time (caddr time) (cadr time) (car time)
3501 (caddr date) (cadr date) (car date) (nth 4 date))))
3503 (defun gnus-time-minus (t1 t2)
3504 "Subtract two internal times."
3505 (let ((borrow (< (cadr t1) (cadr t2))))
3506 (list (- (car t1) (car t2) (if borrow 1 0))
3507 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3509 (defun gnus-file-newer-than (file date)
3510 (let ((fdate (nth 5 (file-attributes file))))
3511 (or (> (car fdate) (car date))
3512 (and (= (car fdate) (car date))
3513 (> (nth 1 fdate) (nth 1 date))))))
3515 (defmacro gnus-local-set-keys (&rest plist)
3516 "Set the keys in PLIST in the current keymap."
3517 `(gnus-define-keys-1 (current-local-map) ',plist))
3519 (defmacro gnus-define-keys (keymap &rest plist)
3520 "Define all keys in PLIST in KEYMAP."
3521 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3523 (put 'gnus-define-keys 'lisp-indent-function 1)
3524 (put 'gnus-define-keys 'lisp-indent-hook 1)
3525 (put 'gnus-define-keymap 'lisp-indent-function 1)
3526 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3528 (defmacro gnus-define-keymap (keymap &rest plist)
3529 "Define all keys in PLIST in KEYMAP."
3530 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3532 (defun gnus-define-keys-1 (keymap plist)
3534 (error "Can't set keys in a null keymap"))
3535 (cond ((symbolp keymap)
3536 (setq keymap (symbol-value keymap)))
3539 (set (car keymap) nil)
3540 (define-prefix-command (car keymap))
3541 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3542 (setq keymap (symbol-value (car keymap)))))
3545 (when (symbolp (setq key (pop plist)))
3546 (setq key (symbol-value key)))
3547 (define-key keymap key (pop plist)))))
3549 (defun gnus-group-read-only-p (&optional group)
3550 "Check whether GROUP supports editing or not.
3551 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3552 that that variable is buffer-local to the summary buffers."
3553 (let ((group (or group gnus-newsgroup-name)))
3554 (not (gnus-check-backend-function 'request-replace-article group))))
3556 (defun gnus-group-total-expirable-p (group)
3557 "Check whether GROUP is total-expirable or not."
3558 (let ((params (gnus-info-params (gnus-get-info group))))
3559 (or (memq 'total-expire params)
3560 (cdr (assq 'total-expire params)) ; (total-expire . t)
3561 (and gnus-total-expirable-newsgroups ; Check var.
3562 (string-match gnus-total-expirable-newsgroups group)))))
3564 (defun gnus-group-auto-expirable-p (group)
3565 "Check whether GROUP is total-expirable or not."
3566 (let ((params (gnus-info-params (gnus-get-info group))))
3567 (or (memq 'auto-expire params)
3568 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3569 (and gnus-auto-expirable-newsgroups ; Check var.
3570 (string-match gnus-auto-expirable-newsgroups group)))))
3572 (defun gnus-virtual-group-p (group)
3573 "Say whether GROUP is virtual or not."
3574 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3575 gnus-valid-select-methods)))
3577 (defun gnus-news-group-p (group &optional article)
3578 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3579 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3580 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3581 (eq (gnus-request-type group article) 'news))))
3583 (defsubst gnus-simplify-subject-fully (subject)
3584 "Simplify a subject string according to the user's wishes."
3586 ((null gnus-summary-gather-subject-limit)
3587 (gnus-simplify-subject-re subject))
3588 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3589 (gnus-simplify-subject-fuzzy subject))
3590 ((numberp gnus-summary-gather-subject-limit)
3591 (gnus-limit-string (gnus-simplify-subject-re subject)
3592 gnus-summary-gather-subject-limit))
3596 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3597 "Check whether two subjects are equal. If optional argument
3598 simple-first is t, first argument is already simplified."
3600 ((null simple-first)
3601 (equal (gnus-simplify-subject-fully s1)
3602 (gnus-simplify-subject-fully s2)))
3605 (gnus-simplify-subject-fully s2)))))
3607 ;; Returns a list of writable groups.
3608 (defun gnus-writable-groups ()
3609 (let ((alist gnus-newsrc-alist)
3611 (while (setq group (car (pop alist)))
3612 (unless (gnus-group-read-only-p group)
3613 (push group groups)))
3616 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3618 (defun gnus-y-or-n-p (prompt)
3623 (defun gnus-yes-or-no-p (prompt)
3625 (yes-or-no-p prompt)
3628 ;; Check whether to use long file names.
3629 (defun gnus-use-long-file-name (symbol)
3630 ;; The variable has to be set...
3631 (and gnus-use-long-file-name
3632 ;; If it isn't a list, then we return t.
3633 (or (not (listp gnus-use-long-file-name))
3634 ;; If it is a list, and the list contains `symbol', we
3636 (not (memq symbol gnus-use-long-file-name)))))
3638 ;; I suspect there's a better way, but I haven't taken the time to do
3639 ;; it yet. -erik selberg@cs.washington.edu
3640 (defun gnus-dd-mmm (messy-date)
3641 "Return a string like DD-MMM from a big messy string"
3642 (let ((datevec (timezone-parse-date messy-date)))
3645 ;; Make sure leading zeroes are stripped.
3646 (number-to-string (string-to-number (aref datevec 2)))
3650 (nth (1- (string-to-number (aref datevec 1)))
3651 timezone-months-assoc))
3654 ;; Make a hash table (default and minimum size is 255).
3655 ;; Optional argument HASHSIZE specifies the table size.
3656 (defun gnus-make-hashtable (&optional hashsize)
3657 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3659 ;; Make a number that is suitable for hashing; bigger than MIN and one
3661 (defun gnus-create-hash-size (min)
3667 ;; Show message if message has a lower level than `gnus-verbose'.
3668 ;; Guideline for numbers:
3669 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3670 ;; for things that take a long time, 7 - not very important messages
3671 ;; on stuff, 9 - messages inside loops.
3672 (defun gnus-message (level &rest args)
3673 (if (<= level gnus-verbose)
3674 (apply 'message args)
3675 ;; We have to do this format thingy here even if the result isn't
3676 ;; shown - the return value has to be the same as the return value
3678 (apply 'format args)))
3680 ;; Generate a unique new group name.
3681 (defun gnus-generate-new-group-name (leaf)
3684 (while (gnus-gethash name gnus-newsrc-hashtb)
3685 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3688 (defsubst gnus-hide-text (b e props)
3689 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3690 (add-text-properties b e props)
3691 (when (memq 'intangible props)
3692 (put-text-property (max (1- b) (point-min))
3693 b 'intangible (cddr (memq 'intangible props)))))
3695 (defsubst gnus-unhide-text (b e)
3696 "Remove hidden text properties from region between B and E."
3697 (remove-text-properties b e gnus-hidden-properties)
3698 (when (memq 'intangible gnus-hidden-properties)
3699 (put-text-property (max (1- b) (point-min))
3700 b 'intangible nil)))
3702 (defun gnus-hide-text-type (b e type)
3703 "Hide text of TYPE between B and E."
3704 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3706 ;; Find out whether the gnus-visual TYPE is wanted.
3707 (defun gnus-visual-p (&optional type class)
3708 (and gnus-visual ; Has to be non-nil, at least.
3709 (if (not type) ; We don't care about type.
3711 (if (listp gnus-visual) ; It's a list, so we check it.
3712 (or (memq type gnus-visual)
3713 (memq class gnus-visual))
3716 (defun gnus-parent-id (references)
3717 "Return the last Message-ID in REFERENCES."
3718 (when (and references
3719 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3720 (substring references (match-beginning 1) (match-end 1))))
3722 (defun gnus-split-references (references)
3723 "Return a list of Message-IDs in REFERENCES."
3726 (while (string-match "<[^>]+>" references beg)
3727 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3731 (defun gnus-buffer-live-p (buffer)
3732 "Say whether BUFFER is alive or not."
3735 (buffer-name (get-buffer buffer))))
3737 (defun gnus-ephemeral-group-p (group)
3738 "Say whether GROUP is ephemeral or not."
3739 (gnus-group-get-parameter group 'quit-config))
3741 (defun gnus-group-quit-config (group)
3742 "Return the quit-config of GROUP."
3743 (gnus-group-get-parameter group 'quit-config))
3745 (defun gnus-simplify-mode-line ()
3746 "Make mode lines a bit simpler."
3747 (setq mode-line-modified "-- ")
3748 (when (listp mode-line-format)
3749 (make-local-variable 'mode-line-format)
3750 (setq mode-line-format (copy-sequence mode-line-format))
3751 (when (equal (nth 3 mode-line-format) " ")
3752 (setcar (nthcdr 3 mode-line-format) " "))))
3754 ;;; List and range functions
3756 (defun gnus-last-element (list)
3757 "Return last element of LIST."
3759 (setq list (cdr list)))
3762 (defun gnus-copy-sequence (list)
3763 "Do a complete, total copy of a list."
3764 (if (and (consp list) (not (consp (cdr list))))
3765 (cons (car list) (cdr list))
3766 (mapcar (lambda (elem) (if (consp elem)
3767 (if (consp (cdr elem))
3768 (gnus-copy-sequence elem)
3769 (cons (car elem) (cdr elem)))
3773 (defun gnus-set-difference (list1 list2)
3774 "Return a list of elements of LIST1 that do not appear in LIST2."
3775 (let ((list1 (copy-sequence list1)))
3777 (setq list1 (delq (car list2) list1))
3778 (setq list2 (cdr list2)))
3781 (defun gnus-sorted-complement (list1 list2)
3782 "Return a list of elements of LIST1 that do not appear in LIST2.
3783 Both lists have to be sorted over <."
3785 (if (or (null list1) (null list2))
3787 (while (and list1 list2)
3788 (cond ((= (car list1) (car list2))
3789 (setq list1 (cdr list1)
3791 ((< (car list1) (car list2))
3792 (setq out (cons (car list1) out))
3793 (setq list1 (cdr list1)))
3795 (setq out (cons (car list2) out))
3796 (setq list2 (cdr list2)))))
3797 (nconc (nreverse out) (or list1 list2)))))
3799 (defun gnus-intersection (list1 list2)
3802 (if (memq (car list2) list1)
3803 (setq result (cons (car list2) result)))
3804 (setq list2 (cdr list2)))
3807 (defun gnus-sorted-intersection (list1 list2)
3808 ;; LIST1 and LIST2 have to be sorted over <.
3810 (while (and list1 list2)
3811 (cond ((= (car list1) (car list2))
3812 (setq out (cons (car list1) out)
3815 ((< (car list1) (car list2))
3816 (setq list1 (cdr list1)))
3818 (setq list2 (cdr list2)))))
3821 (defun gnus-set-sorted-intersection (list1 list2)
3822 ;; LIST1 and LIST2 have to be sorted over <.
3823 ;; This function modifies LIST1.
3824 (let* ((top (cons nil list1))
3826 (while (and list1 list2)
3827 (cond ((= (car list1) (car list2))
3831 ((< (car list1) (car list2))
3832 (setcdr prev (cdr list1))
3833 (setq list1 (cdr list1)))
3835 (setq list2 (cdr list2)))))
3839 (defun gnus-compress-sequence (numbers &optional always-list)
3840 "Convert list of numbers to a list of ranges or a single range.
3841 If ALWAYS-LIST is non-nil, this function will always release a list of
3843 (let* ((first (car numbers))
3844 (last (car numbers))
3848 (if (not (listp (cdr numbers)))
3851 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3852 ((= (1+ last) (car numbers)) ;Still in sequence
3853 (setq last (car numbers)))
3854 (t ;End of one sequence
3856 (cons (if (= first last) first
3857 (cons first last)) result))
3858 (setq first (car numbers))
3859 (setq last (car numbers))))
3860 (setq numbers (cdr numbers)))
3861 (if (and (not always-list) (null result))
3862 (if (= first last) (list first) (cons first last))
3863 (nreverse (cons (if (= first last) first (cons first last))
3866 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3867 (defun gnus-uncompress-range (ranges)
3868 "Expand a list of ranges into a list of numbers.
3869 RANGES is either a single range on the form `(num . num)' or a list of
3871 (let (first last result)
3875 ((not (listp (cdr ranges)))
3876 (setq first (car ranges))
3877 (setq last (cdr ranges))
3878 (while (<= first last)
3879 (setq result (cons first result))
3880 (setq first (1+ first)))
3884 (if (atom (car ranges))
3885 (if (numberp (car ranges))
3886 (setq result (cons (car ranges) result)))
3887 (setq first (caar ranges))
3888 (setq last (cdar ranges))
3889 (while (<= first last)
3890 (setq result (cons first result))
3891 (setq first (1+ first))))
3892 (setq ranges (cdr ranges)))
3893 (nreverse result)))))
3895 (defun gnus-add-to-range (ranges list)
3896 "Return a list of ranges that has all articles from both RANGES and LIST.
3897 Note: LIST has to be sorted over `<'."
3899 (gnus-compress-sequence list t)
3900 (setq list (copy-sequence list))
3901 (or (listp (cdr ranges))
3902 (setq ranges (list ranges)))
3904 ilist lowest highest temp)
3905 (while (and ranges list)
3907 (setq lowest (or (and (atom (car ranges)) (car ranges))
3909 (while (and list (cdr list) (< (cadr list) lowest))
3910 (setq list (cdr list)))
3911 (if (< (car ilist) lowest)
3914 (setq list (cdr list))
3916 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3917 (setq highest (or (and (atom (car ranges)) (car ranges))
3919 (while (and list (<= (car list) highest))
3920 (setq list (cdr list)))
3921 (setq ranges (cdr ranges)))
3923 (setq out (nconc (gnus-compress-sequence list t) out)))
3924 (setq out (sort out (lambda (r1 r2)
3925 (< (or (and (atom r1) r1) (car r1))
3926 (or (and (atom r2) r2) (car r2))))))
3929 (if (atom (car ranges))
3931 (if (atom (cadr ranges))
3932 (if (= (1+ (car ranges)) (cadr ranges))
3934 (setcar ranges (cons (car ranges)
3936 (setcdr ranges (cddr ranges))))
3937 (if (= (1+ (car ranges)) (caadr ranges))
3939 (setcar (cadr ranges) (car ranges))
3940 (setcar ranges (cadr ranges))
3941 (setcdr ranges (cddr ranges))))))
3943 (if (atom (cadr ranges))
3944 (if (= (1+ (cdar ranges)) (cadr ranges))
3946 (setcdr (car ranges) (cadr ranges))
3947 (setcdr ranges (cddr ranges))))
3948 (if (= (1+ (cdar ranges)) (caadr ranges))
3950 (setcdr (car ranges) (cdadr ranges))
3951 (setcdr ranges (cddr ranges)))))))
3952 (setq ranges (cdr ranges)))
3955 (defun gnus-remove-from-range (ranges list)
3956 "Return a list of ranges that has all articles from LIST removed from RANGES.
3957 Note: LIST has to be sorted over `<'."
3958 ;; !!! This function shouldn't look like this, but I've got a headache.
3959 (gnus-compress-sequence
3960 (gnus-sorted-complement
3961 (gnus-uncompress-range ranges) list)))
3963 (defun gnus-member-of-range (number ranges)
3964 (if (not (listp (cdr ranges)))
3965 (and (>= number (car ranges))
3966 (<= number (cdr ranges)))
3969 (if (numberp (car ranges))
3970 (>= number (car ranges))
3971 (>= number (caar ranges)))
3973 (if (if (numberp (car ranges))
3974 (= number (car ranges))
3975 (and (>= number (caar ranges))
3976 (<= number (cdar ranges))))
3977 (setq not-stop nil))
3978 (setq ranges (cdr ranges)))
3981 (defun gnus-range-length (range)
3982 "Return the length RANGE would have if uncompressed."
3983 (length (gnus-uncompress-range range)))
3985 (defun gnus-sublist-p (list sublist)
3986 "Test whether all elements in SUBLIST are members of LIST."
3989 (unless (memq (pop sublist) list)
3999 (defvar gnus-group-mode-map nil)
4000 (put 'gnus-group-mode 'mode-class 'special)
4002 (unless gnus-group-mode-map
4003 (setq gnus-group-mode-map (make-keymap))
4004 (suppress-keymap gnus-group-mode-map)
4006 (gnus-define-keys gnus-group-mode-map
4007 " " gnus-group-read-group
4008 "=" gnus-group-select-group
4009 "\r" gnus-group-select-group
4010 "\M-\r" gnus-group-quick-select-group
4011 "j" gnus-group-jump-to-group
4012 "n" gnus-group-next-unread-group
4013 "p" gnus-group-prev-unread-group
4014 "\177" gnus-group-prev-unread-group
4015 [delete] gnus-group-prev-unread-group
4016 "N" gnus-group-next-group
4017 "P" gnus-group-prev-group
4018 "\M-n" gnus-group-next-unread-group-same-level
4019 "\M-p" gnus-group-prev-unread-group-same-level
4020 "," gnus-group-best-unread-group
4021 "." gnus-group-first-unread-group
4022 "u" gnus-group-unsubscribe-current-group
4023 "U" gnus-group-unsubscribe-group
4024 "c" gnus-group-catchup-current
4025 "C" gnus-group-catchup-current-all
4026 "l" gnus-group-list-groups
4027 "L" gnus-group-list-all-groups
4029 "g" gnus-group-get-new-news
4030 "\M-g" gnus-group-get-new-news-this-group
4031 "R" gnus-group-restart
4032 "r" gnus-group-read-init-file
4033 "B" gnus-group-browse-foreign-server
4034 "b" gnus-group-check-bogus-groups
4035 "F" gnus-find-new-newsgroups
4036 "\C-c\C-d" gnus-group-describe-group
4037 "\M-d" gnus-group-describe-all-groups
4038 "\C-c\C-a" gnus-group-apropos
4039 "\C-c\M-\C-a" gnus-group-description-apropos
4040 "a" gnus-group-post-news
4041 "\ek" gnus-group-edit-local-kill
4042 "\eK" gnus-group-edit-global-kill
4043 "\C-k" gnus-group-kill-group
4044 "\C-y" gnus-group-yank-group
4045 "\C-w" gnus-group-kill-region
4046 "\C-x\C-t" gnus-group-transpose-groups
4047 "\C-c\C-l" gnus-group-list-killed
4048 "\C-c\C-x" gnus-group-expire-articles
4049 "\C-c\M-\C-x" gnus-group-expire-all-groups
4051 "s" gnus-group-save-newsrc
4052 "z" gnus-group-suspend
4053 "Z" gnus-group-clear-dribble
4056 "?" gnus-group-describe-briefly
4057 "\C-c\C-i" gnus-info-find-node
4058 "\M-e" gnus-group-edit-group-method
4059 "^" gnus-group-enter-server-mode
4060 gnus-mouse-2 gnus-mouse-pick-group
4061 "<" beginning-of-buffer
4064 "\C-c\C-s" gnus-group-sort-groups
4066 "\C-c\M-g" gnus-activate-all-groups
4067 "\M-&" gnus-group-universal-argument
4068 "#" gnus-group-mark-group
4069 "\M-#" gnus-group-unmark-group)
4071 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4072 "m" gnus-group-mark-group
4073 "u" gnus-group-unmark-group
4074 "w" gnus-group-mark-region
4075 "m" gnus-group-mark-buffer
4076 "r" gnus-group-mark-regexp
4077 "U" gnus-group-unmark-all-groups)
4079 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4080 "d" gnus-group-make-directory-group
4081 "h" gnus-group-make-help-group
4082 "a" gnus-group-make-archive-group
4083 "k" gnus-group-make-kiboze-group
4084 "m" gnus-group-make-group
4085 "E" gnus-group-edit-group
4086 "e" gnus-group-edit-group-method
4087 "p" gnus-group-edit-group-parameters
4088 "v" gnus-group-add-to-virtual
4089 "V" gnus-group-make-empty-virtual
4090 "D" gnus-group-enter-directory
4091 "f" gnus-group-make-doc-group
4092 "r" gnus-group-rename-group
4093 "\177" gnus-group-delete-group
4094 [delete] gnus-group-delete-group)
4096 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4097 "b" gnus-group-brew-soup
4098 "w" gnus-soup-save-areas
4099 "s" gnus-soup-send-replies
4100 "p" gnus-soup-pack-packet
4101 "r" nnsoup-pack-replies)
4103 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4104 "s" gnus-group-sort-groups
4105 "a" gnus-group-sort-groups-by-alphabet
4106 "u" gnus-group-sort-groups-by-unread
4107 "l" gnus-group-sort-groups-by-level
4108 "v" gnus-group-sort-groups-by-score
4109 "r" gnus-group-sort-groups-by-rank
4110 "m" gnus-group-sort-groups-by-method)
4112 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4113 "k" gnus-group-list-killed
4114 "z" gnus-group-list-zombies
4115 "s" gnus-group-list-groups
4116 "u" gnus-group-list-all-groups
4117 "A" gnus-group-list-active
4118 "a" gnus-group-apropos
4119 "d" gnus-group-description-apropos
4120 "m" gnus-group-list-matching
4121 "M" gnus-group-list-all-matching
4122 "l" gnus-group-list-level)
4124 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4125 "f" gnus-score-flush-cache)
4127 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4128 "f" gnus-group-fetch-faq)
4130 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4131 "l" gnus-group-set-current-level
4132 "t" gnus-group-unsubscribe-current-group
4133 "s" gnus-group-unsubscribe-group
4134 "k" gnus-group-kill-group
4135 "y" gnus-group-yank-group
4136 "w" gnus-group-kill-region
4137 "\C-k" gnus-group-kill-level
4138 "z" gnus-group-kill-all-zombies))
4140 (defun gnus-group-mode ()
4141 "Major mode for reading news.
4143 All normal editing commands are switched off.
4144 \\<gnus-group-mode-map>
4145 The group buffer lists (some of) the groups available. For instance,
4146 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4147 lists all zombie groups.
4149 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4150 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4152 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4154 The following commands are available:
4156 \\{gnus-group-mode-map}"
4158 (when (and menu-bar-mode
4159 (gnus-visual-p 'group-menu 'menu))
4160 (gnus-group-make-menu-bar))
4161 (kill-all-local-variables)
4162 (gnus-simplify-mode-line)
4163 (setq major-mode 'gnus-group-mode)
4164 (setq mode-name "Group")
4165 (gnus-group-set-mode-line)
4166 (setq mode-line-process nil)
4167 (use-local-map gnus-group-mode-map)
4168 (buffer-disable-undo (current-buffer))
4169 (setq truncate-lines t)
4170 (setq buffer-read-only t)
4171 (run-hooks 'gnus-group-mode-hook))
4173 (defun gnus-mouse-pick-group (e)
4174 "Enter the group under the mouse pointer."
4177 (gnus-group-read-group nil))
4179 ;; Look at LEVEL and find out what the level is really supposed to be.
4180 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4181 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4182 (defun gnus-group-default-level (&optional level number-or-nil)
4184 (gnus-group-use-permanent-levels
4185 ; (setq gnus-group-default-list-level
4186 ; (or level gnus-group-default-list-level))
4187 (or level gnus-group-default-list-level gnus-level-subscribed))
4191 (or level gnus-group-default-list-level gnus-level-subscribed))))
4194 (defun gnus-slave-no-server (&optional arg)
4195 "Read network news as a slave, without connecting to local server"
4197 (gnus-no-server arg t))
4200 (defun gnus-no-server (&optional arg slave)
4202 If ARG is a positive number, Gnus will use that as the
4203 startup level. If ARG is nil, Gnus will be started at level 2.
4204 If ARG is non-nil and not a positive number, Gnus will
4205 prompt the user for the name of an NNTP server to use.
4206 As opposed to `gnus', this command will not connect to the local server."
4208 (let ((gnus-group-use-permanent-levels t))
4209 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4210 (make-local-variable 'gnus-group-use-permanent-levels)
4211 (setq gnus-group-use-permanent-levels t))
4214 (defun gnus-slave (&optional arg)
4215 "Read news as a slave."
4217 (gnus arg nil 'slave))
4220 (defun gnus-other-frame (&optional arg)
4221 "Pop up a frame to read news."
4223 (if (get-buffer gnus-group-buffer)
4224 (let ((pop-up-frames t))
4226 (select-frame (make-frame))
4230 (defun gnus (&optional arg dont-connect slave)
4232 If ARG is non-nil and a positive number, Gnus will use that as the
4233 startup level. If ARG is non-nil and not a positive number, Gnus will
4234 prompt the user for the name of an NNTP server to use."
4237 (if (get-buffer gnus-group-buffer)
4239 (switch-to-buffer gnus-group-buffer)
4240 (gnus-group-get-new-news))
4243 (nnheader-init-server-buffer)
4244 (gnus-read-init-file)
4245 (setq gnus-slave slave)
4247 (gnus-group-setup-buffer)
4248 (let ((buffer-read-only nil))
4250 (if (not gnus-inhibit-startup-message)
4252 (gnus-group-startup-message)
4255 (let ((level (and (numberp arg) (> arg 0) arg))
4261 (gnus-start-news-server (and arg (not level))))))
4262 (if (and (not dont-connect)
4265 (run-hooks 'gnus-startup-hook)
4266 ;; NNTP server is successfully open.
4268 ;; Find the current startup file name.
4269 (setq gnus-current-startup-file
4270 (gnus-make-newsrc-file gnus-startup-file))
4272 ;; Read the dribble file.
4273 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4275 ;; Allow using GroupLens predictions.
4276 (when gnus-use-grouplens
4278 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4280 (gnus-summary-make-display-table)
4281 ;; Do the actual startup.
4282 (gnus-setup-news nil level dont-connect)
4283 ;; Generate the group buffer.
4284 (gnus-group-list-groups level)
4285 (gnus-group-first-unread-group)
4286 (gnus-configure-windows 'group)
4287 (gnus-group-set-mode-line))))))
4289 (defun gnus-unload ()
4290 "Unload all Gnus features."
4292 (or (boundp 'load-history)
4293 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4294 (let ((history load-history)
4297 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4298 (setq feature (cdr (assq 'provide (car history))))
4299 (unload-feature feature 'force))
4300 (setq history (cdr history)))))
4302 (defun gnus-compile ()
4303 "Byte-compile the user-defined format specs."
4305 (let ((entries gnus-format-specs)
4306 entry gnus-tmp-func)
4308 (gnus-message 7 "Compiling format specs...")
4311 (setq entry (pop entries))
4312 (if (eq (car entry) 'version)
4313 (setq gnus-format-specs (delq entry gnus-format-specs))
4314 (when (and (listp (caddr entry))
4315 (not (eq 'byte-code (caaddr entry))))
4316 (fset 'gnus-tmp-func
4317 `(lambda () ,(caddr entry)))
4318 (byte-compile 'gnus-tmp-func)
4319 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4321 (push (cons 'version emacs-version) gnus-format-specs)
4323 (gnus-message 7 "Compiling user specs...done"))))
4325 (defun gnus-indent-rigidly (start end arg)
4326 "Indent rigidly using only spaces and no tabs."
4329 (narrow-to-region start end)
4330 (indent-rigidly start end arg)
4331 (goto-char (point-min))
4332 (while (search-forward "\t" nil t)
4333 (replace-match " " t t)))))
4335 (defun gnus-group-startup-message (&optional x y)
4336 "Insert startup message in current buffer."
4337 ;; Insert the message.
4342 _ ___ __ ___ __ _ ___
4361 ;; And then hack it.
4362 (gnus-indent-rigidly (point-min) (point-max)
4363 (/ (max (- (window-width) (or x 46)) 0) 2))
4364 (goto-char (point-min))
4366 (let* ((pheight (count-lines (point-min) (point-max)))
4367 (wheight (window-height))
4368 (rest (- wheight pheight)))
4369 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4371 (goto-char (point-min))
4372 (and (search-forward "Praxis" nil t)
4373 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4374 (goto-char (point-min))
4375 (let* ((mode-string (gnus-group-set-mode-line)))
4376 (setq mode-line-buffer-identification
4377 (list (concat gnus-version (substring (car mode-string) 4))))
4378 (set-buffer-modified-p t)))
4380 (defun gnus-group-setup-buffer ()
4381 (or (get-buffer gnus-group-buffer)
4383 (switch-to-buffer gnus-group-buffer)
4384 (gnus-add-current-to-buffer-list)
4386 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4388 (defun gnus-group-list-groups (&optional level unread lowest)
4389 "List newsgroups with level LEVEL or lower that have unread articles.
4390 Default is all subscribed groups.
4391 If argument UNREAD is non-nil, groups with no unread articles are also
4393 (interactive (list (if current-prefix-arg
4394 (prefix-numeric-value current-prefix-arg)
4396 (gnus-group-default-level nil t)
4397 gnus-group-default-list-level
4398 gnus-level-subscribed))))
4400 (setq level (car gnus-group-list-mode)
4401 unread (cdr gnus-group-list-mode)))
4402 (setq level (gnus-group-default-level level))
4403 (gnus-group-setup-buffer) ;May call from out of group buffer
4404 (gnus-update-format-specifications)
4405 (let ((case-fold-search nil)
4406 (props (text-properties-at (gnus-point-at-bol)))
4407 (group (gnus-group-group-name)))
4408 (set-buffer gnus-group-buffer)
4409 (funcall gnus-group-prepare-function level unread lowest)
4410 (if (zerop (buffer-size))
4411 (gnus-message 5 gnus-no-groups-message)
4412 (goto-char (point-max))
4413 (when (or (not gnus-group-goto-next-group-function)
4414 (not (funcall gnus-group-goto-next-group-function
4417 ;; Go to the first group with unread articles.
4418 (gnus-group-search-forward t)
4419 ;; Find the right group to put point on. If the current group
4420 ;; has disappeared in the new listing, try to find the next
4421 ;; one. If no next one can be found, just leave point at the
4422 ;; first newsgroup in the buffer.
4423 (if (not (gnus-goto-char
4425 (point-min) (point-max)
4426 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4427 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4429 (not (gnus-goto-char
4431 (point-min) (point-max) 'gnus-group
4433 (caar newsrc) gnus-active-hashtb)))))
4434 (setq newsrc (cdr newsrc)))
4435 (or newsrc (progn (goto-char (point-max))
4436 (forward-line -1)))))))
4437 ;; Adjust cursor point.
4438 (gnus-group-position-point))))
4440 (defun gnus-group-list-level (level &optional all)
4441 "List groups on LEVEL.
4442 If ALL (the prefix), also list groups that have no unread articles."
4443 (interactive "nList groups on level: \nP")
4444 (gnus-group-list-groups level all level))
4446 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4447 "List all newsgroups with unread articles of level LEVEL or lower.
4448 If ALL is non-nil, list groups that have no unread articles.
4449 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4450 If REGEXP, only list groups matching REGEXP."
4451 (set-buffer gnus-group-buffer)
4452 (let ((buffer-read-only nil)
4453 (newsrc (cdr gnus-newsrc-alist))
4454 (lowest (or lowest 1))
4455 info clevel unread group params)
4457 (if (< lowest gnus-level-zombie)
4458 ;; List living groups.
4460 (setq info (car newsrc)
4461 group (gnus-info-group info)
4462 params (gnus-info-params info)
4464 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4465 (and unread ; This group might be bogus
4467 (string-match regexp group))
4468 (<= (setq clevel (gnus-info-level info)) level)
4470 (or all ; We list all groups?
4471 (if (eq unread t) ; Unactivated?
4472 gnus-group-list-inactive-groups ; We list unactivated
4473 (> unread 0)) ; We list groups with unread articles
4474 (and gnus-list-groups-with-ticked-articles
4475 (cdr (assq 'tick (gnus-info-marks info))))
4476 ; And groups with tickeds
4477 ;; Check for permanent visibility.
4478 (and gnus-permanently-visible-groups
4479 (string-match gnus-permanently-visible-groups
4481 (memq 'visible params)
4482 (cdr (assq 'visible params)))
4483 (gnus-group-insert-group-line
4484 group (gnus-info-level info)
4485 (gnus-info-marks info) unread (gnus-info-method info)))))
4487 ;; List dead groups.
4488 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4489 (gnus-group-prepare-flat-list-dead
4490 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4491 gnus-level-zombie ?Z
4493 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4494 (gnus-group-prepare-flat-list-dead
4495 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4496 gnus-level-killed ?K regexp))
4498 (gnus-group-set-mode-line)
4499 (setq gnus-group-list-mode (cons level all))
4500 (run-hooks 'gnus-group-prepare-hook)))
4502 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4503 ;; List zombies and killed lists somewhat faster, which was
4504 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4505 ;; this by ignoring the group format specification altogether.
4508 ;; This loop is used when listing groups that match some
4511 (setq group (pop groups))
4512 (when (string-match regexp group)
4513 (add-text-properties
4514 (point) (prog1 (1+ (point))
4515 (insert " " mark " *: " group "\n"))
4516 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4518 'gnus-level level))))
4519 ;; This loop is used when listing all groups.
4521 (add-text-properties
4522 (point) (prog1 (1+ (point))
4523 (insert " " mark " *: "
4524 (setq group (pop groups)) "\n"))
4525 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4527 'gnus-level level))))))
4529 (defmacro gnus-group-real-name (group)
4530 "Find the real name of a foreign newsgroup."
4531 `(let ((gname ,group))
4532 (if (string-match ":[^:]+$" gname)
4533 (substring gname (1+ (match-beginning 0)))
4536 (defsubst gnus-server-add-address (method)
4537 (let ((method-name (symbol-name (car method))))
4538 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4539 (not (assq (intern (concat method-name "-address")) method)))
4540 (append method (list (list (intern (concat method-name "-address"))
4544 (defsubst gnus-server-get-method (group method)
4545 ;; Input either a server name, and extended server name, or a
4546 ;; select method, and return a select method.
4547 (cond ((stringp method)
4548 (gnus-server-to-method method))
4549 ((equal method gnus-select-method)
4551 ((and (stringp (car method)) group)
4552 (gnus-server-extend-method group method))
4553 ((and method (not group)
4554 (equal (cadr method) ""))
4557 (gnus-server-add-address method))))
4559 (defun gnus-server-to-method (server)
4560 "Map virtual server names to select methods."
4562 ;; Perhaps this is the native server?
4563 (and (equal server "native") gnus-select-method)
4564 ;; It should be in the server alist.
4565 (cdr (assoc server gnus-server-alist))
4566 ;; If not, we look through all the opened server
4567 ;; to see whether we can find it there.
4568 (let ((opened gnus-opened-servers))
4570 (not (equal server (format "%s:%s" (caaar opened)
4575 (defmacro gnus-method-equal (ss1 ss2)
4576 "Say whether two servers are equal."
4580 (and (= (length s1) (length s2))
4582 (while (and s1 (member (car s1) s2))
4586 (defun gnus-server-equal (m1 m2)
4587 "Say whether two methods are equal."
4588 (let ((m1 (cond ((null m1) gnus-select-method)
4589 ((stringp m1) (gnus-server-to-method m1))
4591 (m2 (cond ((null m2) gnus-select-method)
4592 ((stringp m2) (gnus-server-to-method m2))
4594 (gnus-method-equal m1 m2)))
4596 (defun gnus-servers-using-backend (backend)
4597 "Return a list of known servers using BACKEND."
4598 (let ((opened gnus-opened-servers)
4601 (when (eq backend (caaar opened))
4602 (push (caar opened) out))
4606 (defun gnus-group-prefixed-name (group method)
4607 "Return the whole name from GROUP and METHOD."
4608 (and (stringp method) (setq method (gnus-server-to-method method)))
4609 (concat (format "%s" (car method))
4611 (or (assoc (format "%s" (car method))
4612 (gnus-methods-using 'address))
4613 (gnus-server-equal method gnus-message-archive-method))
4615 (not (string= (nth 1 method) "")))
4616 (concat "+" (nth 1 method)))
4619 (defun gnus-group-real-prefix (group)
4620 "Return the prefix of the current group name."
4621 (if (string-match "^[^:]+:" group)
4622 (substring group 0 (match-end 0))
4625 (defun gnus-group-method (group)
4626 "Return the server or method used for selecting GROUP."
4627 (let ((prefix (gnus-group-real-prefix group)))
4628 (if (equal prefix "")
4630 (let ((servers gnus-opened-servers)
4632 backend possible found)
4633 (if (string-match "^[^\\+]+\\+" prefix)
4634 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4635 server (substring prefix (match-end 0) (1- (length prefix))))
4636 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4638 (when (eq (caaar servers) backend)
4639 (setq possible (caar servers))
4640 (when (equal (cadaar servers) server)
4641 (setq found (caar servers))))
4643 (or (car (rassoc found gnus-server-alist))
4645 (car (rassoc possible gnus-server-alist))
4647 (list backend server))))))
4649 (defsubst gnus-secondary-method-p (method)
4650 "Return whether METHOD is a secondary select method."
4651 (let ((methods gnus-secondary-select-methods)
4652 (gmethod (gnus-server-get-method nil method)))
4654 (not (equal (gnus-server-get-method nil (car methods))
4656 (setq methods (cdr methods)))
4659 (defun gnus-group-foreign-p (group)
4660 "Say whether a group is foreign or not."
4661 (and (not (gnus-group-native-p group))
4662 (not (gnus-group-secondary-p group))))
4664 (defun gnus-group-native-p (group)
4665 "Say whether the group is native or not."
4666 (not (string-match ":" group)))
4668 (defun gnus-group-secondary-p (group)
4669 "Say whether the group is secondary or not."
4670 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4672 (defun gnus-group-get-parameter (group &optional symbol)
4673 "Returns the group parameters for GROUP.
4674 If SYMBOL, return the value of that symbol in the group parameters."
4675 (let ((params (gnus-info-params (gnus-get-info group))))
4677 (gnus-group-parameter-value params symbol)
4680 (defun gnus-group-parameter-value (params symbol)
4681 "Return the value of SYMBOL in group PARAMS."
4682 (or (car (memq symbol params)) ; It's either a simple symbol
4683 (cdr (assq symbol params)))) ; or a cons.
4685 (defun gnus-group-add-parameter (group param)
4686 "Add parameter PARAM to GROUP."
4687 (let ((info (gnus-get-info group)))
4689 () ; This is a dead group. We just ignore it.
4690 ;; Cons the new param to the old one and update.
4691 (gnus-group-set-info (cons param (gnus-info-params info))
4694 (defun gnus-group-set-parameter (group name value)
4695 "Set parameter NAME to VALUE in GROUP."
4696 (let ((info (gnus-get-info group)))
4698 () ; This is a dead group. We just ignore it.
4699 (let ((old-params (gnus-info-params info))
4700 (new-params (list (cons name value))))
4702 (if (or (not (listp (car old-params)))
4703 (not (eq (caar old-params) name)))
4704 (setq new-params (append new-params (list (car old-params)))))
4705 (setq old-params (cdr old-params)))
4706 (gnus-group-set-info new-params group 'params)))))
4708 (defun gnus-group-add-score (group &optional score)
4709 "Add SCORE to the GROUP score.
4710 If SCORE is nil, add 1 to the score of GROUP."
4711 (let ((info (gnus-get-info group)))
4713 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4715 (defun gnus-summary-bubble-group ()
4716 "Increase the score of the current group.
4717 This is a handy function to add to `gnus-summary-exit-hook' to
4718 increase the score of each group you read."
4719 (gnus-group-add-score gnus-newsgroup-name))
4721 (defun gnus-group-set-info (info &optional method-only-group part)
4722 (let* ((entry (gnus-gethash
4723 (or method-only-group (gnus-info-group info))
4724 gnus-newsrc-hashtb))
4726 (info (if method-only-group (nth 2 entry) info))
4728 (when method-only-group
4730 (error "Trying to change non-existent group %s" method-only-group))
4731 ;; We have received parts of the actual group info - either the
4732 ;; select method or the group parameters. We first check
4733 ;; whether we have to extend the info, and if so, do that.
4734 (let ((len (length info))
4735 (total (if (eq part 'method) 5 6)))
4737 (setcdr (nthcdr (1- len) info)
4738 (make-list (- total len) nil)))
4739 ;; Then we enter the new info.
4740 (setcar (nthcdr (1- total) info) part-info)))
4742 ;; This is a new group, so we just create it.
4744 (set-buffer gnus-group-buffer)
4745 (setq method (gnus-info-method info))
4746 (when (gnus-server-equal method "native")
4749 ;; It's a foreign group...
4750 (gnus-group-make-group
4751 (gnus-group-real-name (gnus-info-group info))
4752 (if (stringp method) method
4753 (prin1-to-string (car method)))
4755 (nth 1 (gnus-info-method info))))
4756 ;; It's a native group.
4757 (gnus-group-make-group (gnus-info-group info)))
4758 (gnus-message 6 "Note: New group created")
4760 (gnus-gethash (gnus-group-prefixed-name
4761 (gnus-group-real-name (gnus-info-group info))
4762 (or (gnus-info-method info) gnus-select-method))
4763 gnus-newsrc-hashtb))))
4764 ;; Whether it was a new group or not, we now have the entry, so we
4765 ;; can do the update.
4768 (setcar (nthcdr 2 entry) info)
4769 (when (and (not (eq (car entry) t))
4770 (gnus-active (gnus-info-group info)))
4771 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4772 (error "No such group: %s" (gnus-info-group info)))))
4774 (defun gnus-group-set-method-info (group select-method)
4775 (gnus-group-set-info select-method group 'method))
4777 (defun gnus-group-set-params-info (group params)
4778 (gnus-group-set-info params group 'params))
4780 (defun gnus-group-update-group-line ()
4781 "Update the current line in the group buffer."
4782 (let* ((buffer-read-only nil)
4783 (group (gnus-group-group-name))
4784 (gnus-group-indentation (gnus-group-group-indentation))
4785 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4787 (not (gnus-ephemeral-group-p group))
4789 (concat "(gnus-group-set-info '"
4790 (prin1-to-string (nth 2 entry)) ")")))
4792 (gnus-group-insert-group-line-info group)
4794 (gnus-group-position-point)))
4796 (defun gnus-group-insert-group-line-info (group)
4797 "Insert GROUP on the current line."
4798 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4802 ;; (Un)subscribed group.
4803 (setq info (nth 2 entry))
4804 (gnus-group-insert-group-line
4805 group (gnus-info-level info) (gnus-info-marks info)
4806 (or (car entry) t) (gnus-info-method info)))
4807 ;; This group is dead.
4808 (gnus-group-insert-group-line
4810 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4812 (if (setq active (gnus-active group))
4813 (- (1+ (cdr active)) (car active)) 0)
4816 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4817 gnus-tmp-marked number
4819 "Insert a group line in the group buffer."
4820 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4821 (gnus-tmp-number-total
4823 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4825 (gnus-tmp-number-of-unread
4826 (if (numberp number) (int-to-string (max 0 number))
4828 (gnus-tmp-number-of-read
4829 (if (numberp number)
4830 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4832 (gnus-tmp-subscribed
4833 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4834 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4835 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4837 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4838 (gnus-tmp-newsgroup-description
4839 (if gnus-description-hashtb
4840 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4843 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4844 (gnus-tmp-moderated-string
4845 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4847 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4848 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4849 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4850 (gnus-tmp-news-method-string
4852 (format "(%s:%s)" (car gnus-tmp-method)
4853 (cadr gnus-tmp-method)) ""))
4854 (gnus-tmp-marked-mark
4855 (if (and (numberp number)
4857 (cdr (assq 'tick gnus-tmp-marked)))
4859 (gnus-tmp-process-marked
4860 (if (member gnus-tmp-group gnus-group-marked)
4861 gnus-process-mark ? ))
4863 (or (and gnus-use-grouplens
4864 (bbb-grouplens-group-p gnus-tmp-group))
4866 (buffer-read-only nil)
4867 header gnus-tmp-header) ; passed as parameter to user-funcs.
4869 (add-text-properties
4873 (eval gnus-group-line-format-spec))
4874 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4875 gnus-unread ,(if (numberp number)
4876 (string-to-int gnus-tmp-number-of-unread)
4878 gnus-marked ,gnus-tmp-marked-mark
4879 gnus-indentation ,gnus-group-indentation
4880 gnus-level ,gnus-tmp-level))
4881 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4883 (run-hooks 'gnus-group-update-hook)
4885 ;; Allow XEmacs to remove front-sticky text properties.
4886 (gnus-group-remove-excess-properties)))
4888 (defun gnus-group-update-group (group &optional visible-only)
4889 "Update all lines where GROUP appear.
4890 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4893 (set-buffer gnus-group-buffer)
4894 ;; The buffer may be narrowed.
4897 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4899 found buffer-read-only)
4900 ;; Enter the current status into the dribble buffer.
4901 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4902 (if (and entry (not (gnus-ephemeral-group-p group)))
4904 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4906 ;; Find all group instances. If topics are in use, each group
4907 ;; may be listed in more than once.
4908 (while (setq loc (text-property-any
4909 loc (point-max) 'gnus-group ident))
4912 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4914 (gnus-group-insert-group-line-info group))
4915 (setq loc (1+ loc)))
4916 (unless (or found visible-only)
4917 ;; No such line in the buffer, find out where it's supposed to
4918 ;; go, and insert it there (or at the end of the buffer).
4919 (if gnus-goto-missing-group-function
4920 (funcall gnus-goto-missing-group-function group)
4921 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4922 (while (and entry (car entry)
4926 (point-min) (point-max)
4927 'gnus-group (gnus-intern-safe
4928 (caar entry) gnus-active-hashtb)))))
4929 (setq entry (cdr entry)))
4930 (or entry (goto-char (point-max)))))
4931 ;; Finally insert the line.
4932 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4933 (gnus-group-insert-group-line-info group)))
4934 (gnus-group-set-mode-line)))))
4936 (defun gnus-group-set-mode-line ()
4937 (when (memq 'group gnus-updated-mode-lines)
4938 (let* ((gformat (or gnus-group-mode-line-format-spec
4939 (setq gnus-group-mode-line-format-spec
4941 gnus-group-mode-line-format
4942 gnus-group-mode-line-format-alist))))
4943 (gnus-tmp-news-server (cadr gnus-select-method))
4944 (gnus-tmp-news-method (car gnus-select-method))
4946 gnus-tmp-header ;Dummy binding for user-defined formats
4947 ;; Get the resulting string.
4948 (mode-string (eval gformat)))
4949 ;; If the line is too long, we chop it off.
4950 (when (> (length mode-string) max-len)
4951 (setq mode-string (substring mode-string 0 (- max-len 4))))
4953 (setq mode-line-buffer-identification (list mode-string))
4954 (set-buffer-modified-p t)))))
4956 (defun gnus-group-group-name ()
4957 "Get the name of the newsgroup on the current line."
4958 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4959 (and group (symbol-name group))))
4961 (defun gnus-group-group-level ()
4962 "Get the level of the newsgroup on the current line."
4963 (get-text-property (gnus-point-at-bol) 'gnus-level))
4965 (defun gnus-group-group-indentation ()
4966 "Get the indentation of the newsgroup on the current line."
4967 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
4968 (and gnus-group-indentation-function
4969 (funcall gnus-group-indentation-function))
4972 (defun gnus-group-group-unread ()
4973 "Get the number of unread articles of the newsgroup on the current line."
4974 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4976 (defun gnus-group-search-forward (&optional backward all level first-too)
4977 "Find the next newsgroup with unread articles.
4978 If BACKWARD is non-nil, find the previous newsgroup instead.
4979 If ALL is non-nil, just find any newsgroup.
4980 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4982 If FIRST-TOO, the current line is also eligible as a target."
4983 (let ((way (if backward -1 1))
4984 (low gnus-level-killed)
4987 (if (and backward (progn (beginning-of-line)) (bobp))
4989 (or first-too (forward-line way))
4997 (get-text-property (point) 'gnus-unread)))
4998 (and (numberp unread) (> unread 0)))
4999 (setq lev (get-text-property (point)
5001 (<= lev gnus-level-subscribed)))
5003 (and (setq lev (get-text-property (point)
5012 (zerop (forward-line way)))))
5014 (progn (gnus-group-position-point) t)
5015 (goto-char (or pos beg))
5018 ;;; Gnus group mode commands
5022 (defun gnus-group-mark-group (n &optional unmark no-advance)
5023 "Mark the current group."
5025 (let ((buffer-read-only nil)
5029 (setq group (gnus-group-group-name))
5033 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5038 (setq gnus-group-marked (delete group gnus-group-marked)))
5040 (setq gnus-group-marked
5041 (cons group (delete group gnus-group-marked))))
5043 (or no-advance (zerop (gnus-group-next-group 1))))
5045 (gnus-summary-position-point)
5048 (defun gnus-group-unmark-group (n)
5049 "Remove the mark from the current group."
5051 (gnus-group-mark-group n 'unmark)
5052 (gnus-group-position-point))
5054 (defun gnus-group-unmark-all-groups ()
5055 "Unmark all groups."
5057 (let ((groups gnus-group-marked))
5060 (gnus-group-remove-mark (pop groups)))))
5061 (gnus-group-position-point))
5063 (defun gnus-group-mark-region (unmark beg end)
5064 "Mark all groups between point and mark.
5065 If UNMARK, remove the mark instead."
5066 (interactive "P\nr")
5067 (let ((num (count-lines beg end)))
5070 (- num (gnus-group-mark-group num unmark)))))
5072 (defun gnus-group-mark-buffer (&optional unmark)
5073 "Mark all groups in the buffer.
5074 If UNMARK, remove the mark instead."
5076 (gnus-group-mark-region unmark (point-min) (point-max)))
5078 (defun gnus-group-mark-regexp (regexp)
5079 "Mark all groups that match some regexp."
5080 (interactive "sMark (regexp): ")
5081 (let ((alist (cdr gnus-newsrc-alist))
5084 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5085 (gnus-group-set-mark group))))
5086 (gnus-group-position-point))
5088 (defun gnus-group-remove-mark (group)
5089 "Remove the process mark from GROUP and move point there.
5090 Return nil if the group isn't displayed."
5091 (if (gnus-group-goto-group group)
5093 (gnus-group-mark-group 1 'unmark t)
5095 (setq gnus-group-marked
5096 (delete group gnus-group-marked))
5099 (defun gnus-group-set-mark (group)
5100 "Set the process mark on GROUP."
5101 (if (gnus-group-goto-group group)
5103 (gnus-group-mark-group 1 nil t))
5104 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5106 (defun gnus-group-universal-argument (arg &optional groups func)
5107 "Perform any command on all groups accoring to the process/prefix convention."
5109 (let ((groups (or groups (gnus-group-process-prefix arg)))
5111 (if (eq (setq func (or func
5114 (substitute-command-keys
5115 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5118 (message "Undefined key")
5121 (gnus-group-remove-mark (setq group (pop groups)))
5122 (command-execute func))))
5123 (gnus-group-position-point))
5125 (defun gnus-group-process-prefix (n)
5126 "Return a list of groups to work on.
5127 Take into consideration N (the prefix) and the list of marked groups."
5130 (setq n (prefix-numeric-value n))
5131 ;; There is a prefix, so we return a list of the N next
5133 (let ((way (if (< n 0) -1 1))
5138 (setq group (gnus-group-group-name)))
5139 (setq groups (cons group groups))
5141 (gnus-group-next-group way)))
5143 ((and (boundp 'transient-mark-mode)
5146 ;; Work on the region between point and mark.
5147 (let ((max (max (point) (mark)))
5150 (goto-char (min (point) (mark)))
5153 (push (gnus-group-group-name) groups)
5154 (zerop (gnus-group-next-group 1))
5156 (nreverse groups))))
5158 ;; No prefix, but a list of marked articles.
5159 (reverse gnus-group-marked))
5161 ;; Neither marked articles or a prefix, so we return the
5163 (let ((group (gnus-group-group-name)))
5164 (and group (list group))))))
5166 ;; Selecting groups.
5168 (defun gnus-group-read-group (&optional all no-article group)
5169 "Read news in this newsgroup.
5170 If the prefix argument ALL is non-nil, already read articles become
5171 readable. IF ALL is a number, fetch this number of articles. If the
5172 optional argument NO-ARTICLE is non-nil, no article will be
5173 auto-selected upon group entry. If GROUP is non-nil, fetch that
5176 (let ((group (or group (gnus-group-group-name)))
5177 number active marked entry)
5178 (or group (error "No group on current line"))
5179 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5180 group gnus-newsrc-hashtb)))))
5181 ;; This group might be a dead group. In that case we have to get
5182 ;; the number of unread articles from `gnus-active-hashtb'.
5184 (cond ((numberp all) all)
5186 ((setq active (gnus-active group))
5187 (- (1+ (cdr active)) (car active)))))
5188 (gnus-summary-read-group
5189 group (or all (and (numberp number)
5190 (zerop (+ number (length (cdr (assq 'tick marked)))
5191 (length (cdr (assq 'dormant marked)))))))
5194 (defun gnus-group-select-group (&optional all)
5195 "Select this newsgroup.
5196 No article is selected automatically.
5197 If ALL is non-nil, already read articles become readable.
5198 If ALL is a number, fetch this number of articles."
5200 (gnus-group-read-group all t))
5202 (defun gnus-group-quick-select-group (&optional all)
5203 "Select the current group \"quickly\".
5204 This means that no highlighting or scoring will be performed."
5207 gnus-score-find-score-files-function
5208 gnus-apply-kill-hook
5209 gnus-summary-expunge-below)
5210 (gnus-group-read-group all t)))
5212 (defun gnus-group-visible-select-group (&optional all)
5213 "Select the current group without hiding any articles."
5215 (let ((gnus-inhibit-limiting t))
5216 (gnus-group-read-group all t)))
5219 (defun gnus-fetch-group (group)
5220 "Start Gnus if necessary and enter GROUP.
5221 Returns whether the fetching was successful or not."
5222 (interactive "sGroup name: ")
5223 (or (get-buffer gnus-group-buffer)
5225 (gnus-group-read-group nil nil group))
5227 ;; Enter a group that is not in the group buffer. Non-nil is returned
5228 ;; if selection was successful.
5229 (defun gnus-group-read-ephemeral-group
5230 (group method &optional activate quit-config)
5231 (let ((group (if (gnus-group-foreign-p group) group
5232 (gnus-group-prefixed-name group method))))
5235 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5236 ((quit-config . ,(if quit-config quit-config
5237 (cons (current-buffer) 'summary))))))
5239 (set-buffer gnus-group-buffer)
5240 (or (gnus-check-server method)
5241 (error "Unable to contact server: %s" (gnus-status-message method)))
5242 (if activate (or (gnus-request-group group)
5243 (error "Couldn't request group")))
5245 (gnus-group-read-group t t group)
5249 (defun gnus-group-jump-to-group (group)
5250 "Jump to newsgroup GROUP."
5252 (list (completing-read
5253 "Group: " gnus-active-hashtb nil
5254 (memq gnus-select-method gnus-have-read-active-file))))
5256 (if (equal group "")
5257 (error "Empty group name"))
5259 (let ((b (text-property-any
5260 (point-min) (point-max)
5261 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5262 (unless (gnus-ephemeral-group-p group)
5264 ;; Either go to the line in the group buffer...
5266 ;; ... or insert the line.
5269 (gnus-activate-group group)
5270 (error "%s error: %s" group (gnus-status-message group)))
5272 (gnus-group-update-group group)
5273 (goto-char (text-property-any
5274 (point-min) (point-max)
5275 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5276 ;; Adjust cursor point.
5277 (gnus-group-position-point)))
5279 (defun gnus-group-goto-group (group)
5280 "Goto to newsgroup GROUP."
5282 (let ((b (text-property-any (point-min) (point-max)
5283 'gnus-group (gnus-intern-safe
5284 group gnus-active-hashtb))))
5285 (and b (goto-char b)))))
5287 (defun gnus-group-next-group (n)
5288 "Go to next N'th newsgroup.
5289 If N is negative, search backward instead.
5290 Returns the difference between N and the number of skips actually
5293 (gnus-group-next-unread-group n t))
5295 (defun gnus-group-next-unread-group (n &optional all level)
5296 "Go to next N'th unread newsgroup.
5297 If N is negative, search backward instead.
5298 If ALL is non-nil, choose any newsgroup, unread or not.
5299 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5300 such group can be found, the next group with a level higher than
5302 Returns the difference between N and the number of skips actually
5305 (let ((backward (< n 0))
5308 (gnus-group-search-forward
5309 backward (or (not gnus-group-goto-unread) all) level))
5311 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5312 (if level " on this level or higher" "")))
5315 (defun gnus-group-prev-group (n)
5316 "Go to previous N'th newsgroup.
5317 Returns the difference between N and the number of skips actually
5320 (gnus-group-next-unread-group (- n) t))
5322 (defun gnus-group-prev-unread-group (n)
5323 "Go to previous N'th unread newsgroup.
5324 Returns the difference between N and the number of skips actually
5327 (gnus-group-next-unread-group (- n)))
5329 (defun gnus-group-next-unread-group-same-level (n)
5330 "Go to next N'th unread newsgroup on the same level.
5331 If N is negative, search backward instead.
5332 Returns the difference between N and the number of skips actually
5335 (gnus-group-next-unread-group n t (gnus-group-group-level))
5336 (gnus-group-position-point))
5338 (defun gnus-group-prev-unread-group-same-level (n)
5339 "Go to next N'th unread newsgroup on the same level.
5340 Returns the difference between N and the number of skips actually
5343 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5344 (gnus-group-position-point))
5346 (defun gnus-group-best-unread-group (&optional exclude-group)
5347 "Go to the group with the highest level.
5348 If EXCLUDE-GROUP, do not go to that group."
5350 (goto-char (point-min))
5354 (setq unread (get-text-property (point) 'gnus-unread))
5355 (if (and (numberp unread) (> unread 0))
5357 (if (and (get-text-property (point) 'gnus-level)
5358 (< (get-text-property (point) 'gnus-level) best)
5359 (or (not exclude-group)
5360 (not (equal exclude-group (gnus-group-group-name)))))
5362 (setq best (get-text-property (point) 'gnus-level))
5363 (setq best-point (point))))))
5365 (if best-point (goto-char best-point))
5366 (gnus-summary-position-point)
5367 (and best-point (gnus-group-group-name))))
5369 (defun gnus-group-first-unread-group ()
5370 "Go to the first group with unread articles."
5373 (let ((opoint (point))
5375 (goto-char (point-min))
5376 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5377 (and (numberp unread) ; Not a topic.
5378 (not (zerop unread))) ; Has unread articles.
5379 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5382 nil)) ; Not success.
5383 (gnus-group-position-point)))
5385 (defun gnus-group-enter-server-mode ()
5386 "Jump to the server buffer."
5388 (gnus-enter-server-buffer))
5390 (defun gnus-group-make-group (name &optional method address)
5391 "Add a new newsgroup.
5392 The user will be prompted for a NAME, for a select METHOD, and an
5396 (read-string "Group name: ")
5399 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5401 (cond ((assoc method gnus-valid-select-methods)
5403 (if (memq 'prompt-address
5404 (assoc method gnus-valid-select-methods))
5405 (read-string "Address: ")
5407 ((assoc method gnus-server-alist)
5410 (list method ""))))))
5413 (set-buffer gnus-group-buffer)
5414 (let* ((meth (and method (if address (list (intern method) address)
5416 (nname (if method (gnus-group-prefixed-name name meth) name))
5418 (and (gnus-gethash nname gnus-newsrc-hashtb)
5419 (error "Group %s already exists" nname))
5420 (gnus-group-change-level
5421 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5422 gnus-level-default-subscribed gnus-level-killed
5423 (and (gnus-group-group-name)
5424 (gnus-gethash (gnus-group-group-name)
5425 gnus-newsrc-hashtb))
5427 (gnus-set-active nname (cons 1 0))
5428 (or (gnus-ephemeral-group-p name)
5430 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5431 (gnus-group-insert-group-line-info nname)
5433 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5435 gnus-valid-select-methods)
5437 (gnus-check-server meth)
5438 (and (gnus-check-backend-function 'request-create-group nname)
5439 (gnus-request-create-group nname))
5442 (defun gnus-group-delete-group (group &optional force)
5443 "Delete the current group.
5444 If FORCE (the prefix) is non-nil, all the articles in the group will
5445 be deleted. This is \"deleted\" as in \"removed forever from the face
5446 of the Earth\". There is no undo."
5448 (list (gnus-group-group-name)
5449 current-prefix-arg))
5450 (or group (error "No group to rename"))
5451 (or (gnus-check-backend-function 'request-delete-group group)
5452 (error "This backend does not support group deletion"))
5454 (if (not (gnus-yes-or-no-p
5456 "Do you really want to delete %s%s? "
5457 group (if force " and all its contents" ""))))
5459 (gnus-message 6 "Deleting group %s..." group)
5460 (if (not (gnus-request-delete-group group force))
5462 (gnus-message 3 "Couldn't delete group %s" group)
5464 (gnus-message 6 "Deleting group %s...done" group)
5465 (gnus-group-goto-group group)
5466 (gnus-group-kill-group 1 t)
5467 (gnus-sethash group nil gnus-active-hashtb)
5469 (gnus-group-position-point)))
5471 (defun gnus-group-rename-group (group new-name)
5474 (gnus-group-group-name)
5476 (or (gnus-check-backend-function
5477 'request-rename-group (gnus-group-group-name))
5478 (error "This backend does not support renaming groups"))
5479 (read-string "New group name: "))))
5481 (or (gnus-check-backend-function 'request-rename-group group)
5482 (error "This backend does not support renaming groups"))
5484 (or group (error "No group to rename"))
5485 (and (string-match "^[ \t]*$" new-name)
5486 (error "Not a valid group name"))
5488 ;; We find the proper prefixed name.
5490 (gnus-group-prefixed-name
5491 (gnus-group-real-name new-name)
5492 (gnus-info-method (gnus-get-info group))))
5494 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5496 (if (not (gnus-request-rename-group group new-name))
5498 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5500 ;; We rename the group internally by killing it...
5501 (gnus-group-goto-group group)
5502 (gnus-group-kill-group)
5503 ;; ... changing its name ...
5504 (setcar (cdar gnus-list-of-killed-groups) new-name)
5505 ;; ... and then yanking it. Magic!
5506 (gnus-group-yank-group)
5507 (gnus-set-active new-name (gnus-active group))
5508 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5510 (gnus-group-position-point)))
5512 (defun gnus-group-edit-group (group &optional part)
5513 "Edit the group on the current line."
5514 (interactive (list (gnus-group-group-name)))
5515 (let* ((part (or part 'info))
5516 (done-func `(lambda ()
5517 "Exit editing mode and update the information."
5519 (gnus-group-edit-group-done ',part ,group)))
5520 (winconf (current-window-configuration))
5522 (or group (error "No group on current line"))
5523 (or (setq info (gnus-get-info group))
5524 (error "Killed group; can't be edited"))
5525 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5526 (gnus-configure-windows 'edit-group)
5527 (gnus-add-current-to-buffer-list)
5529 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5530 (use-local-map (copy-keymap emacs-lisp-mode-map))
5531 (local-set-key "\C-c\C-c" done-func)
5532 (make-local-variable 'gnus-prev-winconf)
5533 (setq gnus-prev-winconf winconf)
5538 ";; Type `C-c C-c' after editing the select method.\n\n")
5540 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5542 ";; Type `C-c C-c' after editing the group info.\n\n")))
5545 (cond ((eq part 'method)
5546 (or (gnus-info-method info) "native"))
5548 (gnus-info-params info))
5552 (defun gnus-group-edit-group-method (group)
5553 "Edit the select method of GROUP."
5554 (interactive (list (gnus-group-group-name)))
5555 (gnus-group-edit-group group 'method))
5557 (defun gnus-group-edit-group-parameters (group)
5558 "Edit the group parameters of GROUP."
5559 (interactive (list (gnus-group-group-name)))
5560 (gnus-group-edit-group group 'params))
5562 (defun gnus-group-edit-group-done (part group)
5563 "Get info from buffer, update variables and jump to the group buffer."
5564 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5565 (goto-char (point-min))
5566 (let* ((form (read (current-buffer)))
5567 (winconf gnus-prev-winconf)
5568 (method (cond ((eq part 'info) (nth 4 form))
5569 ((eq part 'method) form)
5571 (info (cond ((eq part 'info) form)
5572 ((eq part 'method) (gnus-get-info group))
5575 (if (or (not method)
5577 gnus-select-method method))
5578 (gnus-group-real-name (car info))
5579 (gnus-group-prefixed-name
5580 (gnus-group-real-name (car info)) method))
5582 (when (and new-group
5583 (not (equal new-group group)))
5584 (when (gnus-group-goto-group group)
5585 (gnus-group-kill-group 1))
5586 (gnus-activate-group new-group))
5588 (if (and info new-group)
5590 (setq info (gnus-copy-sequence info))
5591 (setcar info new-group)
5592 (unless (gnus-server-equal method "native")
5593 (unless (nthcdr 3 info)
5594 (nconc info (list nil nil)))
5595 (unless (nthcdr 4 info)
5596 (nconc info (list nil)))
5597 (gnus-info-set-method info method))
5598 (gnus-group-set-info info))
5599 (gnus-group-set-info form (or new-group group) part))
5600 (kill-buffer (current-buffer))
5601 (and winconf (set-window-configuration winconf))
5602 (set-buffer gnus-group-buffer)
5603 (gnus-group-update-group (or new-group group))
5604 (gnus-group-position-point)))
5606 (defun gnus-group-make-help-group ()
5607 "Create the Gnus documentation group."
5609 (let ((path load-path)
5610 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5612 (and (gnus-gethash name gnus-newsrc-hashtb)
5613 (error "Documentation group already exists"))
5615 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5617 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5619 (setq file (concat (file-name-directory
5620 (directory-file-name dir))
5621 "etc/gnus-tut.txt"))))
5624 (message "Couldn't find doc group")
5625 (gnus-group-make-group
5626 (gnus-group-real-name name)
5627 (list 'nndoc "gnus-help"
5628 (list 'nndoc-address file)
5629 (list 'nndoc-article-type 'mbox)))))
5630 (gnus-group-position-point))
5632 (defun gnus-group-make-doc-group (file type)
5633 "Create a group that uses a single file as the source."
5635 (list (read-file-name "File name: ")
5636 (and current-prefix-arg 'ask)))
5637 (when (eq type 'ask)
5642 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5644 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5645 ((= char ?b) 'babyl)
5646 ((= char ?d) 'digest)
5647 ((= char ?f) 'forward)
5649 (t (setq err (format "%c unknown. " char))
5652 (let* ((file (expand-file-name file))
5653 (name (gnus-generate-new-group-name
5654 (gnus-group-prefixed-name
5655 (file-name-nondirectory file) '(nndoc "")))))
5656 (gnus-group-make-group
5657 (gnus-group-real-name name)
5658 (list 'nndoc (file-name-nondirectory file)
5659 (list 'nndoc-address file)
5660 (list 'nndoc-article-type (or type 'guess))))
5662 (gnus-group-position-point)))
5664 (defun gnus-group-make-archive-group (&optional all)
5665 "Create the (ding) Gnus archive group of the most recent articles.
5666 Given a prefix, create a full group."
5668 (let ((group (gnus-group-prefixed-name
5669 (if all "ding.archives" "ding.recent") '(nndir ""))))
5670 (and (gnus-gethash group gnus-newsrc-hashtb)
5671 (error "Archive group already exists"))
5672 (gnus-group-make-group
5673 (gnus-group-real-name group)
5674 (list 'nndir (if all "hpc" "edu")
5675 (list 'nndir-directory
5676 (if all gnus-group-archive-directory
5677 gnus-group-recent-archive-directory)))))
5679 (gnus-group-position-point))
5681 (defun gnus-group-make-directory-group (dir)
5682 "Create an nndir group.
5683 The user will be prompted for a directory. The contents of this
5684 directory will be used as a newsgroup. The directory should contain
5685 mail messages or news articles in files that have numeric names."
5687 (list (read-file-name "Create group from directory: ")))
5688 (or (file-exists-p dir) (error "No such directory"))
5689 (or (file-directory-p dir) (error "Not a directory"))
5693 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5695 (gnus-group-prefixed-name
5696 (concat (file-name-as-directory (directory-file-name dir))
5699 (setq ext (format "<%d>" (setq i (1+ i)))))
5700 (gnus-group-make-group
5701 (gnus-group-real-name group)
5702 (list 'nndir group (list 'nndir-directory dir))))
5704 (gnus-group-position-point))
5706 (defun gnus-group-make-kiboze-group (group address scores)
5707 "Create an nnkiboze group.
5708 The user will be prompted for a name, a regexp to match groups, and
5709 score file entries for articles to include in the group."
5712 (read-string "nnkiboze group name: ")
5713 (read-string "Source groups (regexp): ")
5714 (let ((headers (mapcar (lambda (group) (list group))
5715 '("subject" "from" "number" "date" "message-id"
5716 "references" "chars" "lines" "xref"
5717 "followup" "all" "body" "head")))
5718 scores header regexp regexps)
5719 (while (not (equal "" (setq header (completing-read
5720 "Match on header: " headers nil t))))
5722 (while (not (equal "" (setq regexp (read-string
5723 (format "Match on %s (string): "
5725 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5726 (setq scores (cons (cons header regexps) scores)))
5728 (gnus-group-make-group group "nnkiboze" address)
5730 (gnus-set-work-buffer)
5731 (let (emacs-lisp-mode-hook)
5732 (pp scores (current-buffer)))
5733 (write-region (point-min) (point-max)
5734 (gnus-score-file-name (concat "nnkiboze:" group))))
5736 (gnus-group-position-point))
5738 (defun gnus-group-add-to-virtual (n vgroup)
5739 "Add the current group to a virtual group."
5741 (list current-prefix-arg
5742 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5744 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5745 (error "%s is not an nnvirtual group" vgroup))
5746 (let* ((groups (gnus-group-process-prefix n))
5747 (method (gnus-info-method (gnus-get-info vgroup))))
5748 (setcar (cdr method)
5750 (nth 1 method) "\\|"
5753 (gnus-group-remove-mark s)
5754 (concat "\\(^" (regexp-quote s) "$\\)"))
5756 (gnus-group-position-point))
5758 (defun gnus-group-make-empty-virtual (group)
5759 "Create a new, fresh, empty virtual group."
5760 (interactive "sCreate new, empty virtual group: ")
5761 (let* ((method (list 'nnvirtual "^$"))
5762 (pgroup (gnus-group-prefixed-name group method)))
5763 ;; Check whether it exists already.
5764 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5765 (error "Group %s already exists." pgroup))
5766 ;; Subscribe the new group after the group on the current line.
5767 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5768 (gnus-group-update-group pgroup)
5770 (gnus-group-position-point)))
5772 (defun gnus-group-enter-directory (dir)
5773 "Enter an ephemeral nneething group."
5774 (interactive "DDirectory to read: ")
5775 (let* ((method (list 'nneething dir))
5776 (leaf (gnus-group-prefixed-name
5777 (file-name-nondirectory (directory-file-name dir))
5779 (name (gnus-generate-new-group-name leaf)))
5780 (let ((nneething-read-only t))
5781 (or (gnus-group-read-ephemeral-group
5783 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5785 (error "Couldn't enter %s" dir)))))
5787 ;; Group sorting commands
5788 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5790 (defun gnus-group-sort-groups (func &optional reverse)
5791 "Sort the group buffer according to FUNC.
5792 If REVERSE, reverse the sorting order."
5793 (interactive (list gnus-group-sort-function
5794 current-prefix-arg))
5796 ((not (listp func)) func)
5798 ((= 1 (length func)) (car func))
5800 ,(gnus-make-sort-function
5801 (reverse func)))))))
5802 ;; We peel off the dummy group from the alist.
5804 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5805 (pop gnus-newsrc-alist))
5807 (setq gnus-newsrc-alist
5808 (sort gnus-newsrc-alist func))
5810 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5811 ;; Regenerate the hash table.
5812 (gnus-make-hashtable-from-newsrc-alist)
5813 (gnus-group-list-groups))))
5815 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5816 "Sort the group buffer alphabetically by group name.
5817 If REVERSE, sort in reverse order."
5819 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5821 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5822 "Sort the group buffer by number of unread articles.
5823 If REVERSE, sort in reverse order."
5825 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5827 (defun gnus-group-sort-groups-by-level (&optional reverse)
5828 "Sort the group buffer by group level.
5829 If REVERSE, sort in reverse order."
5831 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5833 (defun gnus-group-sort-groups-by-score (&optional reverse)
5834 "Sort the group buffer by group score.
5835 If REVERSE, sort in reverse order."
5837 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5839 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5840 "Sort the group buffer by group rank.
5841 If REVERSE, sort in reverse order."
5843 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5845 (defun gnus-group-sort-groups-by-method (&optional reverse)
5846 "Sort the group buffer alphabetically by backend name.
5847 If REVERSE, sort in reverse order."
5849 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5851 (defun gnus-group-sort-by-alphabet (info1 info2)
5852 "Sort alphabetically."
5853 (string< (gnus-info-group info1) (gnus-info-group info2)))
5855 (defun gnus-group-sort-by-unread (info1 info2)
5856 "Sort by number of unread articles."
5857 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5858 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5859 (< (or (and (numberp n1) n1) 0)
5860 (or (and (numberp n2) n2) 0))))
5862 (defun gnus-group-sort-by-level (info1 info2)
5864 (< (gnus-info-level info1) (gnus-info-level info2)))
5866 (defun gnus-group-sort-by-method (info1 info2)
5867 "Sort alphabetically by backend name."
5868 (string< (symbol-name (car (gnus-find-method-for-group
5869 (gnus-info-group info1) info1)))
5870 (symbol-name (car (gnus-find-method-for-group
5871 (gnus-info-group info2) info2)))))
5873 (defun gnus-group-sort-by-score (info1 info2)
5874 "Sort by group score."
5875 (< (gnus-info-score info1) (gnus-info-score info2)))
5877 (defun gnus-group-sort-by-rank (info1 info2)
5878 "Sort by level and score."
5879 (let ((level1 (gnus-info-level info1))
5880 (level2 (gnus-info-level info2)))
5881 (or (< level1 level2)
5882 (and (= level1 level2)
5883 (< (gnus-info-score info1) (gnus-info-score info2))))))
5885 ;; Group catching up.
5887 (defun gnus-group-clear-data (n)
5888 "Clear all marks and read ranges from the current group."
5890 (let ((groups (gnus-group-process-prefix n))
5892 (while (setq group (pop groups))
5893 (setq info (gnus-get-info group))
5894 (gnus-info-set-read info nil)
5895 (when (gnus-info-marks info)
5896 (gnus-info-set-marks info nil))
5897 (gnus-get-unread-articles-in-group info (gnus-active group) t)
5898 (when (gnus-group-goto-group group)
5899 (gnus-group-remove-mark group)
5900 (gnus-group-update-group-line)))))
5902 (defun gnus-group-catchup-current (&optional n all)
5903 "Mark all articles not marked as unread in current newsgroup as read.
5904 If prefix argument N is numeric, the ARG next newsgroups will be
5905 caught up. If ALL is non-nil, marked articles will also be marked as
5906 read. Cross references (Xref: header) of articles are ignored.
5907 The difference between N and actual number of newsgroups that were
5908 caught up is returned."
5910 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5914 "Do you really want to mark all articles as read? "
5915 "Mark all unread articles as read? "))))
5917 (let ((groups (gnus-group-process-prefix n))
5920 ;; Virtual groups have to be given special treatment.
5921 (let ((method (gnus-find-method-for-group (car groups))))
5922 (if (eq 'nnvirtual (car method))
5923 (nnvirtual-catchup-group
5924 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5925 (gnus-group-remove-mark (car groups))
5927 (gnus-group-goto-group (car groups))
5928 (gnus-group-catchup (car groups) all))
5929 (gnus-group-update-group-line)
5930 (setq ret (1+ ret)))
5931 (setq groups (cdr groups)))
5932 (gnus-group-next-unread-group 1)
5935 (defun gnus-group-catchup-current-all (&optional n)
5936 "Mark all articles in current newsgroup as read.
5937 Cross references (Xref: header) of articles are ignored."
5939 (gnus-group-catchup-current n 'all))
5941 (defun gnus-group-catchup (group &optional all)
5942 "Mark all articles in GROUP as read.
5943 If ALL is non-nil, all articles are marked as read.
5944 The return value is the number of articles that were marked as read,
5945 or nil if no action could be taken."
5946 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5948 ;; Do the updating only if the newsgroup isn't killed.
5949 (if (not (numberp (car entry)))
5950 (gnus-message 1 "Can't catch up; non-active group")
5951 ;; Do auto-expirable marks if that's required.
5952 (when (gnus-group-auto-expirable-p group)
5953 (gnus-add-marked-articles
5954 group 'expire (gnus-list-of-unread-articles group))
5956 (let ((marks (nth 3 (nth 2 entry))))
5957 (gnus-add-marked-articles
5958 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5959 (gnus-add-marked-articles
5960 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5962 (gnus-update-read-articles group nil)
5963 ;; Also nix out the lists of marks and dormants.
5965 (gnus-add-marked-articles group 'tick nil nil 'force)
5966 (gnus-add-marked-articles group 'dormant nil nil 'force))
5967 (run-hooks 'gnus-group-catchup-group-hook)
5970 (defun gnus-group-expire-articles (&optional n)
5971 "Expire all expirable articles in the current newsgroup."
5973 (let ((groups (gnus-group-process-prefix n))
5976 (error "No groups to expire"))
5977 (while (setq group (pop groups))
5978 (gnus-group-remove-mark group)
5979 (when (gnus-check-backend-function 'request-expire-articles group)
5980 (gnus-message 6 "Expiring articles in %s..." group)
5981 (let* ((info (gnus-get-info group))
5982 (expirable (if (gnus-group-total-expirable-p group)
5983 (cons nil (gnus-list-of-read-articles group))
5984 (assq 'expire (gnus-info-marks info))))
5985 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5989 (gnus-compress-sequence
5991 ;; We set the expiry variables to the groupp
5993 (let ((nnmail-expiry-wait-function nil)
5994 (nnmail-expiry-wait expiry-wait))
5995 (gnus-request-expire-articles
5996 (gnus-uncompress-sequence (cdr expirable)) group))
5997 ;; Just expire using the normal expiry values.
5998 (gnus-request-expire-articles
5999 (gnus-uncompress-sequence (cdr expirable)) group)))))
6000 (gnus-message 6 "Expiring articles in %s...done" group)))
6001 (gnus-group-position-point))))
6003 (defun gnus-group-expire-all-groups ()
6004 "Expire all expirable articles in all newsgroups."
6007 (gnus-message 5 "Expiring...")
6008 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6009 (cdr gnus-newsrc-alist))))
6010 (gnus-group-expire-articles nil)))
6011 (gnus-group-position-point)
6012 (gnus-message 5 "Expiring...done"))
6014 (defun gnus-group-set-current-level (n level)
6015 "Set the level of the next N groups to LEVEL."
6020 (let ((s (read-string
6021 (format "Level (default %s): "
6022 (or (gnus-group-group-level)
6023 gnus-level-default-subscribed)))))
6024 (if (string-match "^\\s-*$" s)
6025 (int-to-string (or (gnus-group-group-level)
6026 gnus-level-default-subscribed))
6028 (or (and (>= level 1) (<= level gnus-level-killed))
6029 (error "Illegal level: %d" level))
6030 (let ((groups (gnus-group-process-prefix n))
6032 (while (setq group (pop groups))
6033 (gnus-group-remove-mark group)
6034 (gnus-message 6 "Changed level of %s from %d to %d"
6035 group (or (gnus-group-group-level) gnus-level-killed)
6037 (gnus-group-change-level
6038 group level (or (gnus-group-group-level) gnus-level-killed))
6039 (gnus-group-update-group-line)))
6040 (gnus-group-position-point))
6042 (defun gnus-group-unsubscribe-current-group (&optional n)
6043 "Toggle subscription of the current group.
6044 If given numerical prefix, toggle the N next groups."
6046 (let ((groups (gnus-group-process-prefix n))
6049 (setq group (car groups)
6050 groups (cdr groups))
6051 (gnus-group-remove-mark group)
6052 (gnus-group-unsubscribe-group
6053 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6054 gnus-level-default-unsubscribed
6055 gnus-level-default-subscribed) t)
6056 (gnus-group-update-group-line))
6057 (gnus-group-next-group 1)))
6059 (defun gnus-group-unsubscribe-group (group &optional level silent)
6060 "Toggle subscription to GROUP.
6061 Killed newsgroups are subscribed. If SILENT, don't try to update the
6064 (list (completing-read
6065 "Group: " gnus-active-hashtb nil
6066 (memq gnus-select-method gnus-have-read-active-file))))
6067 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6069 ((string-match "^[ \t]$" group)
6070 (error "Empty group name"))
6072 ;; Toggle subscription flag.
6073 (gnus-group-change-level
6074 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6075 gnus-level-subscribed)
6076 (1+ gnus-level-subscribed)
6077 gnus-level-default-subscribed)))
6079 (gnus-group-update-group group)))
6080 ((and (stringp group)
6081 (or (not (memq gnus-select-method gnus-have-read-active-file))
6082 (gnus-active group)))
6083 ;; Add new newsgroup.
6084 (gnus-group-change-level
6086 (if level level gnus-level-default-subscribed)
6087 (or (and (member group gnus-zombie-list)
6090 (and (gnus-group-group-name)
6091 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6093 (gnus-group-update-group group)))
6094 (t (error "No such newsgroup: %s" group)))
6095 (gnus-group-position-point)))
6097 (defun gnus-group-transpose-groups (n)
6098 "Move the current newsgroup up N places.
6099 If given a negative prefix, move down instead. The difference between
6100 N and the number of steps taken is returned."
6102 (or (gnus-group-group-name)
6103 (error "No group on current line"))
6104 (gnus-group-kill-group 1)
6106 (forward-line (- n))
6107 (gnus-group-yank-group)
6108 (gnus-group-position-point)))
6110 (defun gnus-group-kill-all-zombies ()
6111 "Kill all zombie newsgroups."
6113 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6114 (setq gnus-zombie-list nil)
6115 (gnus-group-list-groups))
6117 (defun gnus-group-kill-region (begin end)
6118 "Kill newsgroups in current region (excluding current point).
6119 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6134 (beginning-of-line) ;Important when LINES < 1
6135 (gnus-group-kill-group lines)))
6137 (defun gnus-group-kill-group (&optional n discard)
6138 "Kill the next N groups.
6139 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6140 However, only groups that were alive can be yanked; already killed
6141 groups or zombie groups can't be yanked.
6142 The return value is the name of the group that was killed, or a list
6145 (let ((buffer-read-only nil)
6146 (groups (gnus-group-process-prefix n))
6147 group entry level out)
6148 (if (< (length groups) 10)
6149 ;; This is faster when there are few groups.
6151 (push (setq group (pop groups)) out)
6152 (gnus-group-remove-mark group)
6153 (setq level (gnus-group-group-level))
6155 (when (and (not discard)
6156 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6157 (push (cons (car entry) (nth 2 entry))
6158 gnus-list-of-killed-groups))
6159 (gnus-group-change-level
6160 (if entry entry group) gnus-level-killed (if entry nil level)))
6161 ;; If there are lots and lots of groups to be killed, we use
6162 ;; this thing instead.
6164 (setq groups (nreverse groups))
6166 (gnus-group-remove-mark (setq group (pop groups)))
6169 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6170 (push (cons (car entry) (nth 2 entry))
6171 gnus-list-of-killed-groups)
6172 (setcdr (cdr entry) (cdddr entry)))
6173 ((member group gnus-zombie-list)
6174 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6175 (gnus-make-hashtable-from-newsrc-alist)))
6177 (gnus-group-position-point)
6178 (if (< (length out) 2) (car out) (nreverse out))))
6180 (defun gnus-group-yank-group (&optional arg)
6181 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6182 inserting it before the current newsgroup. The numeric ARG specifies
6183 how many newsgroups are to be yanked. The name of the newsgroup yanked
6184 is returned, or (if several groups are yanked) a list of yanked groups
6187 (setq arg (or arg 1))
6188 (let (info group prev out)
6189 (while (>= (decf arg) 0)
6190 (if (not (setq info (pop gnus-list-of-killed-groups)))
6191 (error "No more newsgroups to yank"))
6192 (push (setq group (nth 1 info)) out)
6193 ;; Find which newsgroup to insert this one before - search
6194 ;; backward until something suitable is found. If there are no
6195 ;; other newsgroups in this buffer, just make this newsgroup the
6197 (setq prev (gnus-group-group-name))
6198 (gnus-group-change-level
6199 info (gnus-info-level (cdr info)) gnus-level-killed
6200 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6202 (gnus-group-insert-group-line-info group))
6204 (gnus-group-position-point)
6205 (if (< (length out) 2) (car out) (nreverse out))))
6207 (defun gnus-group-kill-level (level)
6208 "Kill all groups that is on a certain LEVEL."
6209 (interactive "nKill all groups on level: ")
6211 ((= level gnus-level-zombie)
6212 (setq gnus-killed-list
6213 (nconc gnus-zombie-list gnus-killed-list))
6214 (setq gnus-zombie-list nil))
6215 ((and (< level gnus-level-zombie)
6217 (or gnus-expert-user
6220 "Do you really want to kill all groups on level %d? "
6222 (let* ((prev gnus-newsrc-alist)
6225 (if (= (gnus-info-level level) level)
6226 (setcdr prev (cdr alist))
6228 (setq alist (cdr alist)))
6229 (gnus-make-hashtable-from-newsrc-alist)
6230 (gnus-group-list-groups)))
6232 (error "Can't kill; illegal level: %d" level))))
6234 (defun gnus-group-list-all-groups (&optional arg)
6235 "List all newsgroups with level ARG or lower.
6236 Default is gnus-level-unsubscribed, which lists all subscribed and most
6237 unsubscribed groups."
6239 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6241 ;; Redefine this to list ALL killed groups if prefix arg used.
6242 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6243 (defun gnus-group-list-killed (&optional arg)
6244 "List all killed newsgroups in the group buffer.
6245 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6246 entail asking the server for the groups."
6248 ;; Find all possible killed newsgroups if arg.
6250 ;; First make sure active file has been read.
6251 (unless gnus-have-read-active-file
6252 (let ((gnus-read-active-file t))
6253 (gnus-read-active-file)))
6254 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6255 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6259 (group (symbol-name sym)))
6260 (if (or (null group)
6261 (gnus-gethash group gnus-killed-hashtb)
6262 (gnus-gethash group gnus-newsrc-hashtb))
6264 (let ((do-sub (gnus-matches-options-n group)))
6265 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6267 (setq groups (1+ groups))
6268 (setq gnus-killed-list
6269 (cons group gnus-killed-list))
6270 (gnus-sethash group group gnus-killed-hashtb))))))
6271 gnus-active-hashtb))
6272 (if (not gnus-killed-list)
6273 (gnus-message 6 "No killed groups")
6274 (let (gnus-group-list-mode)
6275 (funcall gnus-group-prepare-function
6276 gnus-level-killed t gnus-level-killed))
6277 (goto-char (point-min)))
6278 (gnus-group-position-point))
6280 (defun gnus-group-list-zombies ()
6281 "List all zombie newsgroups in the group buffer."
6283 (if (not gnus-zombie-list)
6284 (gnus-message 6 "No zombie groups")
6285 (let (gnus-group-list-mode)
6286 (funcall gnus-group-prepare-function
6287 gnus-level-zombie t gnus-level-zombie))
6288 (goto-char (point-min)))
6289 (gnus-group-position-point))
6291 (defun gnus-group-list-active ()
6292 "List all groups that are available from the server(s)."
6294 ;; First we make sure that we have really read the active file.
6295 (unless gnus-have-read-active-file
6296 (let ((gnus-read-active-file t))
6297 (gnus-read-active-file)))
6298 ;; Find all groups and sort them.
6304 (and (symbol-value sym)
6305 (setq list (cons (symbol-name sym) list))))
6309 (buffer-read-only nil))
6312 (gnus-group-insert-group-line-info (pop groups)))
6313 (goto-char (point-min))))
6315 (defun gnus-activate-all-groups (level)
6316 "Activate absolutely all groups."
6317 (interactive (list 7))
6318 (let ((gnus-activate-level level)
6319 (gnus-activate-foreign-newsgroups level))
6320 (gnus-group-get-new-news)))
6322 (defun gnus-group-get-new-news (&optional arg)
6323 "Get newly arrived articles.
6324 If ARG is a number, it specifies which levels you are interested in
6325 re-scanning. If ARG is non-nil and not a number, this will force
6326 \"hard\" re-reading of the active files from all servers."
6328 (run-hooks 'gnus-get-new-news-hook)
6329 ;; We might read in new NoCeM messages here.
6330 (when (and gnus-use-nocem
6332 (gnus-nocem-scan-groups))
6333 ;; If ARG is not a number, then we read the active file.
6334 (when (and arg (not (numberp arg)))
6335 (let ((gnus-read-active-file t))
6336 (gnus-read-active-file))
6339 (setq arg (gnus-group-default-level arg t))
6340 (if (and gnus-read-active-file (not arg))
6342 (gnus-read-active-file)
6343 (gnus-get-unread-articles arg))
6344 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6345 (gnus-get-unread-articles arg)))
6346 (run-hooks 'gnus-after-getting-new-news-hook)
6347 (gnus-group-list-groups))
6349 (defun gnus-group-get-new-news-this-group (&optional n)
6350 "Check for newly arrived news in the current group (and the N-1 next groups).
6351 The difference between N and the number of newsgroup checked is returned.
6352 If N is negative, this group and the N-1 previous groups will be checked."
6354 (let* ((groups (gnus-group-process-prefix n))
6355 (ret (if (numberp n) (- n (length groups)) 0))
6358 (setq group (car groups)
6359 groups (cdr groups))
6360 (gnus-group-remove-mark group)
6361 (if (and group (gnus-activate-group group 'scan))
6363 (gnus-get-unread-articles-in-group
6364 (gnus-get-info group) (gnus-active group) t)
6365 (gnus-close-group group)
6366 (gnus-group-update-group group))
6368 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6369 (when gnus-goto-next-group-when-activating
6370 (gnus-group-next-unread-group 1 t))
6371 (gnus-summary-position-point)
6374 (defun gnus-group-fetch-faq (group &optional faq-dir)
6375 "Fetch the FAQ for the current group."
6378 (gnus-group-real-name (gnus-group-group-name))
6379 (cond (current-prefix-arg
6381 "Faq dir: " (and (listp gnus-group-faq-directory)
6382 gnus-group-faq-directory))))))
6384 (setq faq-dir (if (listp gnus-group-faq-directory)
6385 (car gnus-group-faq-directory)
6386 gnus-group-faq-directory)))
6387 (or group (error "No group name given"))
6388 (let ((file (concat (file-name-as-directory faq-dir)
6389 (gnus-group-real-name group))))
6390 (if (not (file-exists-p file))
6391 (error "No such file: %s" file)
6394 (defun gnus-group-describe-group (force &optional group)
6395 "Display a description of the current newsgroup."
6396 (interactive (list current-prefix-arg (gnus-group-group-name)))
6397 (and force (setq gnus-description-hashtb nil))
6398 (let ((method (gnus-find-method-for-group group))
6400 (or group (error "No group name given"))
6401 (and (or (and gnus-description-hashtb
6402 ;; We check whether this group's method has been
6403 ;; queried for a description file.
6405 (gnus-group-prefixed-name "" method)
6406 gnus-description-hashtb))
6407 (setq desc (gnus-group-get-description group))
6408 (gnus-read-descriptions-file method))
6410 (or desc (gnus-gethash group gnus-description-hashtb)
6411 "No description available")))))
6413 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6414 (defun gnus-group-describe-all-groups (&optional force)
6415 "Pop up a buffer with descriptions of all newsgroups."
6417 (and force (setq gnus-description-hashtb nil))
6418 (if (not (or gnus-description-hashtb
6419 (gnus-read-all-descriptions-files)))
6420 (error "Couldn't request descriptions file"))
6421 (let ((buffer-read-only nil)
6427 (insert (format " *: %-20s %s\n" (symbol-name group)
6428 (symbol-value group)))
6429 (add-text-properties
6430 b (1+ b) (list 'gnus-group group
6431 'gnus-unread t 'gnus-marked nil
6432 'gnus-level (1+ gnus-level-subscribed))))
6433 gnus-description-hashtb)
6434 (goto-char (point-min))
6435 (gnus-group-position-point)))
6437 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6438 (defun gnus-group-apropos (regexp &optional search-description)
6439 "List all newsgroups that have names that match a regexp."
6440 (interactive "sGnus apropos (regexp): ")
6442 (obuf (current-buffer))
6444 ;; Go through all newsgroups that are known to Gnus.
6447 (and (symbol-name group)
6448 (string-match regexp (symbol-name group))
6449 (setq groups (cons (symbol-name group) groups))))
6451 ;; Also go through all descriptions that are known to Gnus.
6452 (when search-description
6455 (and (string-match regexp (symbol-value group))
6456 (gnus-active (symbol-name group))
6457 (setq groups (cons (symbol-name group) groups))))
6458 gnus-description-hashtb))
6460 (gnus-message 3 "No groups matched \"%s\"." regexp)
6461 ;; Print out all the groups.
6463 (pop-to-buffer "*Gnus Help*")
6464 (buffer-disable-undo (current-buffer))
6466 (setq groups (sort groups 'string<))
6468 ;; Groups may be entered twice into the list of groups.
6469 (if (not (string= (car groups) prev))
6471 (insert (setq prev (car groups)) "\n")
6472 (if (and gnus-description-hashtb
6473 (setq des (gnus-gethash (car groups)
6474 gnus-description-hashtb)))
6475 (insert " " des "\n"))))
6476 (setq groups (cdr groups)))
6477 (goto-char (point-min))))
6478 (pop-to-buffer obuf)))
6480 (defun gnus-group-description-apropos (regexp)
6481 "List all newsgroups that have names or descriptions that match a regexp."
6482 (interactive "sGnus description apropos (regexp): ")
6483 (if (not (or gnus-description-hashtb
6484 (gnus-read-all-descriptions-files)))
6485 (error "Couldn't request descriptions file"))
6486 (gnus-group-apropos regexp t))
6488 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6489 (defun gnus-group-list-matching (level regexp &optional all lowest)
6490 "List all groups with unread articles that match REGEXP.
6491 If the prefix LEVEL is non-nil, it should be a number that says which
6492 level to cut off listing groups.
6493 If ALL, also list groups with no unread articles.
6494 If LOWEST, don't list groups with level lower than LOWEST."
6495 (interactive "P\nsList newsgroups matching: ")
6496 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6497 all (or lowest 1) regexp)
6498 (goto-char (point-min))
6499 (gnus-group-position-point))
6501 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6502 "List all groups that match REGEXP.
6503 If the prefix LEVEL is non-nil, it should be a number that says which
6504 level to cut off listing groups.
6505 If LOWEST, don't list groups with level lower than LOWEST."
6506 (interactive "P\nsList newsgroups matching: ")
6507 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6509 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6510 (defun gnus-group-save-newsrc (&optional force)
6511 "Save the Gnus startup files.
6512 If FORCE, force saving whether it is necessary or not."
6514 (gnus-save-newsrc-file force))
6516 (defun gnus-group-restart (&optional arg)
6517 "Force Gnus to read the .newsrc file."
6519 (when (gnus-yes-or-no-p
6520 (format "Are you sure you want to read %s? "
6521 gnus-current-startup-file))
6522 (gnus-save-newsrc-file)
6523 (gnus-setup-news 'force)
6524 (gnus-group-list-groups arg)))
6526 (defun gnus-group-read-init-file ()
6527 "Read the Gnus elisp init file."
6529 (gnus-read-init-file))
6531 (defun gnus-group-check-bogus-groups (&optional silent)
6532 "Check bogus newsgroups.
6533 If given a prefix, don't ask for confirmation before removing a bogus
6536 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6537 (gnus-group-list-groups))
6539 (defun gnus-group-edit-global-kill (&optional article group)
6540 "Edit the global kill file.
6541 If GROUP, edit that local kill file instead."
6543 (setq gnus-current-kill-article article)
6544 (gnus-kill-file-edit-file group)
6547 (substitute-command-keys
6548 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6549 (if group "local" "global")))))
6551 (defun gnus-group-edit-local-kill (article group)
6552 "Edit a local kill file."
6553 (interactive (list nil (gnus-group-group-name)))
6554 (gnus-group-edit-global-kill article group))
6556 (defun gnus-group-force-update ()
6557 "Update `.newsrc' file."
6559 (gnus-save-newsrc-file))
6561 (defun gnus-group-suspend ()
6562 "Suspend the current Gnus session.
6563 In fact, cleanup buffers except for group mode buffer.
6564 The hook gnus-suspend-gnus-hook is called before actually suspending."
6566 (run-hooks 'gnus-suspend-gnus-hook)
6567 ;; Kill Gnus buffers except for group mode buffer.
6568 (let ((group-buf (get-buffer gnus-group-buffer)))
6569 ;; Do this on a separate list in case the user does a ^G before we finish
6570 (let ((gnus-buffer-list
6571 (delq group-buf (delq gnus-dribble-buffer
6572 (append gnus-buffer-list nil)))))
6573 (while gnus-buffer-list
6574 (gnus-kill-buffer (car gnus-buffer-list))
6575 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6578 (setq gnus-buffer-list (list group-buf))
6579 (bury-buffer group-buf)
6580 (delete-windows-on group-buf t)))))
6582 (defun gnus-group-clear-dribble ()
6583 "Clear all information from the dribble buffer."
6585 (gnus-dribble-clear)
6586 (gnus-message 7 "Cleared dribble buffer"))
6588 (defun gnus-group-exit ()
6589 "Quit reading news after updating .newsrc.eld and .newsrc.
6590 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6593 (or noninteractive ;For gnus-batch-kill
6594 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6595 (not gnus-interactive-exit) ;Without confirmation
6597 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6598 (run-hooks 'gnus-exit-gnus-hook)
6599 ;; Offer to save data from non-quitted summary buffers.
6600 (gnus-offer-save-summaries)
6601 ;; Save the newsrc file(s).
6602 (gnus-save-newsrc-file)
6604 (gnus-close-backends)
6605 ;; Reset everything.
6607 ;; Allow the user to do things after cleaning up.
6608 (run-hooks 'gnus-after-exiting-gnus-hook)))
6610 (defun gnus-close-backends ()
6611 ;; Send a close request to all backends that support such a request.
6612 (let ((methods gnus-valid-select-methods)
6615 (if (fboundp (setq func (intern (concat (caar methods)
6616 "-request-close"))))
6618 (setq methods (cdr methods)))))
6620 (defun gnus-group-quit ()
6621 "Quit reading news without updating .newsrc.eld or .newsrc.
6622 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6624 (when (or noninteractive ;For gnus-batch-kill
6625 (zerop (buffer-size))
6626 (not (gnus-server-opened gnus-select-method))
6628 (not gnus-current-startup-file)
6630 (format "Quit reading news without saving %s? "
6631 (file-name-nondirectory gnus-current-startup-file))))
6632 (run-hooks 'gnus-exit-gnus-hook)
6633 (if gnus-use-full-window
6634 (delete-other-windows)
6635 (gnus-remove-some-windows))
6637 (gnus-close-backends)
6639 ;; Allow the user to do things after cleaning up.
6640 (run-hooks 'gnus-after-exiting-gnus-hook)))
6642 (defun gnus-offer-save-summaries ()
6643 "Offer to save all active summary buffers."
6645 (let ((buflist (buffer-list))
6647 ;; Go through all buffers and find all summaries.
6649 (and (setq bufname (buffer-name (car buflist)))
6650 (string-match "Summary" bufname)
6652 (set-buffer bufname)
6653 ;; We check that this is, indeed, a summary buffer.
6654 (and (eq major-mode 'gnus-summary-mode)
6655 ;; Also make sure this isn't bogus.
6656 gnus-newsgroup-prepared))
6657 (push bufname buffers))
6658 (setq buflist (cdr buflist)))
6659 ;; Go through all these summary buffers and offer to save them.
6662 "Update summary buffer %s? "
6663 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6666 (defun gnus-group-describe-briefly ()
6667 "Give a one line description of the group mode commands."
6669 (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")))
6671 (defun gnus-group-browse-foreign-server (method)
6672 "Browse a foreign news server.
6673 If called interactively, this function will ask for a select method
6674 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6675 If not, METHOD should be a list where the first element is the method
6676 and the second element is the address."
6678 (list (let ((how (completing-read
6680 (append gnus-valid-select-methods gnus-server-alist)
6681 nil t (cons "nntp" 0))))
6682 ;; We either got a backend name or a virtual server name.
6683 ;; If the first, we also need an address.
6684 (if (assoc how gnus-valid-select-methods)
6686 ;; Suggested by mapjph@bath.ac.uk.
6689 (mapcar (lambda (server) (list server))
6690 gnus-secondary-servers)))
6691 ;; We got a server name, so we find the method.
6692 (gnus-server-to-method how)))))
6693 (gnus-browse-foreign-server method))
6697 ;;; Gnus summary mode
6700 (defvar gnus-summary-mode-map nil)
6702 (put 'gnus-summary-mode 'mode-class 'special)
6704 (unless gnus-summary-mode-map
6705 (setq gnus-summary-mode-map (make-keymap))
6706 (suppress-keymap gnus-summary-mode-map)
6708 ;; Non-orthogonal keys
6710 (gnus-define-keys gnus-summary-mode-map
6711 " " gnus-summary-next-page
6712 "\177" gnus-summary-prev-page
6713 [delete] gnus-summary-prev-page
6714 "\r" gnus-summary-scroll-up
6715 "n" gnus-summary-next-unread-article
6716 "p" gnus-summary-prev-unread-article
6717 "N" gnus-summary-next-article
6718 "P" gnus-summary-prev-article
6719 "\M-\C-n" gnus-summary-next-same-subject
6720 "\M-\C-p" gnus-summary-prev-same-subject
6721 "\M-n" gnus-summary-next-unread-subject
6722 "\M-p" gnus-summary-prev-unread-subject
6723 "." gnus-summary-first-unread-article
6724 "," gnus-summary-best-unread-article
6725 "\M-s" gnus-summary-search-article-forward
6726 "\M-r" gnus-summary-search-article-backward
6727 "<" gnus-summary-beginning-of-article
6728 ">" gnus-summary-end-of-article
6729 "j" gnus-summary-goto-article
6730 "^" gnus-summary-refer-parent-article
6731 "\M-^" gnus-summary-refer-article
6732 "u" gnus-summary-tick-article-forward
6733 "!" gnus-summary-tick-article-forward
6734 "U" gnus-summary-tick-article-backward
6735 "d" gnus-summary-mark-as-read-forward
6736 "D" gnus-summary-mark-as-read-backward
6737 "E" gnus-summary-mark-as-expirable
6738 "\M-u" gnus-summary-clear-mark-forward
6739 "\M-U" gnus-summary-clear-mark-backward
6740 "k" gnus-summary-kill-same-subject-and-select
6741 "\C-k" gnus-summary-kill-same-subject
6742 "\M-\C-k" gnus-summary-kill-thread
6743 "\M-\C-l" gnus-summary-lower-thread
6744 "e" gnus-summary-edit-article
6745 "#" gnus-summary-mark-as-processable
6746 "\M-#" gnus-summary-unmark-as-processable
6747 "\M-\C-t" gnus-summary-toggle-threads
6748 "\M-\C-s" gnus-summary-show-thread
6749 "\M-\C-h" gnus-summary-hide-thread
6750 "\M-\C-f" gnus-summary-next-thread
6751 "\M-\C-b" gnus-summary-prev-thread
6752 "\M-\C-u" gnus-summary-up-thread
6753 "\M-\C-d" gnus-summary-down-thread
6754 "&" gnus-summary-execute-command
6755 "c" gnus-summary-catchup-and-exit
6756 "\C-w" gnus-summary-mark-region-as-read
6757 "\C-t" gnus-summary-toggle-truncation
6758 "?" gnus-summary-mark-as-dormant
6759 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6760 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6761 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6762 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6763 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6764 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6765 "=" gnus-summary-expand-window
6766 "\C-x\C-s" gnus-summary-reselect-current-group
6767 "\M-g" gnus-summary-rescan-group
6768 "w" gnus-summary-stop-page-breaking
6769 "\C-c\C-r" gnus-summary-caesar-message
6770 "\M-t" gnus-summary-toggle-mime
6771 "f" gnus-summary-followup
6772 "F" gnus-summary-followup-with-original
6773 "C" gnus-summary-cancel-article
6774 "r" gnus-summary-reply
6775 "R" gnus-summary-reply-with-original
6776 "\C-c\C-f" gnus-summary-mail-forward
6777 "o" gnus-summary-save-article
6778 "\C-o" gnus-summary-save-article-mail
6779 "|" gnus-summary-pipe-output
6780 "\M-k" gnus-summary-edit-local-kill
6781 "\M-K" gnus-summary-edit-global-kill
6783 "\C-c\C-d" gnus-summary-describe-group
6784 "q" gnus-summary-exit
6785 "Q" gnus-summary-exit-no-update
6786 "\C-c\C-i" gnus-info-find-node
6787 gnus-mouse-2 gnus-mouse-pick-article
6788 "m" gnus-summary-mail-other-window
6789 "a" gnus-summary-post-news
6790 "x" gnus-summary-limit-to-unread
6791 "s" gnus-summary-isearch-article
6792 "t" gnus-article-hide-headers
6793 "g" gnus-summary-show-article
6794 "l" gnus-summary-goto-last-article
6795 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6796 "\C-d" gnus-summary-enter-digest-group
6798 "*" gnus-cache-enter-article
6799 "\M-*" gnus-cache-remove-article
6800 "\M-&" gnus-summary-universal-argument
6801 "\C-l" gnus-recenter
6802 "I" gnus-summary-increase-score
6803 "L" gnus-summary-lower-score
6805 "V" gnus-summary-score-map
6806 "X" gnus-uu-extract-map
6807 "S" gnus-summary-send-map)
6809 ;; Sort of orthogonal keymap
6810 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6811 "t" gnus-summary-tick-article-forward
6812 "!" gnus-summary-tick-article-forward
6813 "d" gnus-summary-mark-as-read-forward
6814 "r" gnus-summary-mark-as-read-forward
6815 "c" gnus-summary-clear-mark-forward
6816 " " gnus-summary-clear-mark-forward
6817 "e" gnus-summary-mark-as-expirable
6818 "x" gnus-summary-mark-as-expirable
6819 "?" gnus-summary-mark-as-dormant
6820 "b" gnus-summary-set-bookmark
6821 "B" gnus-summary-remove-bookmark
6822 "#" gnus-summary-mark-as-processable
6823 "\M-#" gnus-summary-unmark-as-processable
6824 "S" gnus-summary-limit-include-expunged
6825 "C" gnus-summary-catchup
6826 "H" gnus-summary-catchup-to-here
6827 "\C-c" gnus-summary-catchup-all
6828 "k" gnus-summary-kill-same-subject-and-select
6829 "K" gnus-summary-kill-same-subject
6830 "P" gnus-uu-mark-map)
6832 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6833 "c" gnus-summary-clear-above
6834 "u" gnus-summary-tick-above
6835 "m" gnus-summary-mark-above
6836 "k" gnus-summary-kill-below)
6838 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6839 "/" gnus-summary-limit-to-subject
6840 "n" gnus-summary-limit-to-articles
6841 "w" gnus-summary-pop-limit
6842 "s" gnus-summary-limit-to-subject
6843 "a" gnus-summary-limit-to-author
6844 "u" gnus-summary-limit-to-unread
6845 "m" gnus-summary-limit-to-marks
6846 "v" gnus-summary-limit-to-score
6847 "D" gnus-summary-limit-include-dormant
6848 "d" gnus-summary-limit-exclude-dormant
6849 ;; "t" gnus-summary-limit-exclude-thread
6850 "E" gnus-summary-limit-include-expunged
6851 "c" gnus-summary-limit-exclude-childless-dormant
6852 "C" gnus-summary-limit-mark-excluded-as-read)
6854 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6855 "n" gnus-summary-next-unread-article
6856 "p" gnus-summary-prev-unread-article
6857 "N" gnus-summary-next-article
6858 "P" gnus-summary-prev-article
6859 "\C-n" gnus-summary-next-same-subject
6860 "\C-p" gnus-summary-prev-same-subject
6861 "\M-n" gnus-summary-next-unread-subject
6862 "\M-p" gnus-summary-prev-unread-subject
6863 "f" gnus-summary-first-unread-article
6864 "b" gnus-summary-best-unread-article
6865 "j" gnus-summary-goto-article
6866 "g" gnus-summary-goto-subject
6867 "l" gnus-summary-goto-last-article
6868 "p" gnus-summary-pop-article)
6870 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6871 "k" gnus-summary-kill-thread
6872 "l" gnus-summary-lower-thread
6873 "i" gnus-summary-raise-thread
6874 "T" gnus-summary-toggle-threads
6875 "t" gnus-summary-rethread-current
6876 "^" gnus-summary-reparent-thread
6877 "s" gnus-summary-show-thread
6878 "S" gnus-summary-show-all-threads
6879 "h" gnus-summary-hide-thread
6880 "H" gnus-summary-hide-all-threads
6881 "n" gnus-summary-next-thread
6882 "p" gnus-summary-prev-thread
6883 "u" gnus-summary-up-thread
6884 "o" gnus-summary-top-thread
6885 "d" gnus-summary-down-thread
6886 "#" gnus-uu-mark-thread
6887 "\M-#" gnus-uu-unmark-thread)
6889 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6890 "c" gnus-summary-catchup-and-exit
6891 "C" gnus-summary-catchup-all-and-exit
6892 "E" gnus-summary-exit-no-update
6893 "Q" gnus-summary-exit
6894 "Z" gnus-summary-exit
6895 "n" gnus-summary-catchup-and-goto-next-group
6896 "R" gnus-summary-reselect-current-group
6897 "G" gnus-summary-rescan-group
6898 "N" gnus-summary-next-group
6899 "P" gnus-summary-prev-group)
6901 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6902 " " gnus-summary-next-page
6903 "n" gnus-summary-next-page
6904 "\177" gnus-summary-prev-page
6905 [delete] gnus-summary-prev-page
6906 "p" gnus-summary-prev-page
6907 "\r" gnus-summary-scroll-up
6908 "<" gnus-summary-beginning-of-article
6909 ">" gnus-summary-end-of-article
6910 "b" gnus-summary-beginning-of-article
6911 "e" gnus-summary-end-of-article
6912 "^" gnus-summary-refer-parent-article
6913 "r" gnus-summary-refer-parent-article
6914 "R" gnus-summary-refer-references
6915 "g" gnus-summary-show-article
6916 "s" gnus-summary-isearch-article)
6918 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6919 "b" gnus-article-add-buttons
6920 "B" gnus-article-add-buttons-to-head
6921 "o" gnus-article-treat-overstrike
6922 ;; "w" gnus-article-word-wrap
6923 "w" gnus-article-fill-cited-article
6924 "c" gnus-article-remove-cr
6925 "L" gnus-article-remove-trailing-blank-lines
6926 "q" gnus-article-de-quoted-unreadable
6927 "f" gnus-article-display-x-face
6928 "l" gnus-summary-stop-page-breaking
6929 "r" gnus-summary-caesar-message
6930 "t" gnus-article-hide-headers
6931 "v" gnus-summary-verbose-headers
6932 "m" gnus-summary-toggle-mime)
6934 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6935 "a" gnus-article-hide
6936 "h" gnus-article-hide-headers
6937 "b" gnus-article-hide-boring-headers
6938 "s" gnus-article-hide-signature
6939 "c" gnus-article-hide-citation
6940 "p" gnus-article-hide-pgp
6941 "\C-c" gnus-article-hide-citation-maybe)
6943 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6944 "a" gnus-article-highlight
6945 "h" gnus-article-highlight-headers
6946 "c" gnus-article-highlight-citation
6947 "s" gnus-article-highlight-signature)
6949 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6950 "z" gnus-article-date-ut
6951 "u" gnus-article-date-ut
6952 "l" gnus-article-date-local
6953 "e" gnus-article-date-lapsed
6954 "o" gnus-article-date-original)
6956 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6958 "f" gnus-summary-fetch-faq
6959 "d" gnus-summary-describe-group
6960 "h" gnus-summary-describe-briefly
6961 "i" gnus-info-find-node)
6963 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6964 "e" gnus-summary-expire-articles
6965 "\M-\C-e" gnus-summary-expire-articles-now
6966 "\177" gnus-summary-delete-article
6967 [delete] gnus-summary-delete-article
6968 "m" gnus-summary-move-article
6969 "r" gnus-summary-respool-article
6970 "w" gnus-summary-edit-article
6971 "c" gnus-summary-copy-article
6972 "B" gnus-summary-crosspost-article
6973 "q" gnus-summary-respool-query
6974 "i" gnus-summary-import-article)
6976 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6977 "o" gnus-summary-save-article
6978 "m" gnus-summary-save-article-mail
6979 "r" gnus-summary-save-article-rmail
6980 "f" gnus-summary-save-article-file
6981 "b" gnus-summary-save-article-body-file
6982 "h" gnus-summary-save-article-folder
6983 "v" gnus-summary-save-article-vm
6984 "p" gnus-summary-pipe-output
6985 "s" gnus-soup-add-article)
6990 (defun gnus-summary-mode (&optional group)
6991 "Major mode for reading articles.
6993 All normal editing commands are switched off.
6994 \\<gnus-summary-mode-map>
6995 Each line in this buffer represents one article. To read an
6996 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6997 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7000 You can also post articles and send mail from this buffer. To
7001 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7002 of an article, type `\\[gnus-summary-reply]'.
7004 There are approx. one gazillion commands you can execute in this
7005 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7007 The following commands are available:
7009 \\{gnus-summary-mode-map}"
7011 (when (and menu-bar-mode
7012 (gnus-visual-p 'summary-menu 'menu))
7013 (gnus-summary-make-menu-bar))
7014 (kill-all-local-variables)
7015 (let ((locals gnus-summary-local-variables))
7017 (if (consp (car locals))
7019 (make-local-variable (caar locals))
7020 (set (caar locals) (eval (cdar locals))))
7021 (make-local-variable (car locals))
7022 (set (car locals) nil))
7023 (setq locals (cdr locals))))
7024 (gnus-make-thread-indent-array)
7025 (gnus-simplify-mode-line)
7026 (setq major-mode 'gnus-summary-mode)
7027 (setq mode-name "Summary")
7028 (make-local-variable 'minor-mode-alist)
7029 (use-local-map gnus-summary-mode-map)
7030 (buffer-disable-undo (current-buffer))
7031 (setq buffer-read-only t) ;Disable modification
7032 (setq truncate-lines t)
7033 (setq selective-display t)
7034 (setq selective-display-ellipses t) ;Display `...'
7035 (setq buffer-display-table gnus-summary-display-table)
7036 (setq gnus-newsgroup-name group)
7037 (run-hooks 'gnus-summary-mode-hook))
7039 (defun gnus-summary-make-display-table ()
7040 ;; Change the display table. Odd characters have a tendency to mess
7041 ;; up nicely formatted displays - we make all possible glyphs
7042 ;; display only a single character.
7044 ;; We start from the standard display table, if any.
7045 (setq gnus-summary-display-table
7046 (or (copy-sequence standard-display-table)
7047 (make-display-table)))
7048 ;; Nix out all the control chars...
7050 (while (>= (setq i (1- i)) 0)
7051 (aset gnus-summary-display-table i [??])))
7052 ;; ... but not newline and cr, of course. (cr is necessary for the
7053 ;; selective display).
7054 (aset gnus-summary-display-table ?\n nil)
7055 (aset gnus-summary-display-table ?\r nil)
7056 ;; We nix out any glyphs over 126 that are not set already.
7058 (while (>= (setq i (1- i)) 127)
7059 ;; Only modify if the entry is nil.
7060 (or (aref gnus-summary-display-table i)
7061 (aset gnus-summary-display-table i [??])))))
7063 (defun gnus-summary-clear-local-variables ()
7064 (let ((locals gnus-summary-local-variables))
7066 (if (consp (car locals))
7067 (and (vectorp (caar locals))
7068 (set (caar locals) nil))
7069 (and (vectorp (car locals))
7070 (set (car locals) nil)))
7071 (setq locals (cdr locals)))))
7073 ;; Summary data functions.
7075 (defmacro gnus-data-number (data)
7078 (defmacro gnus-data-set-number (data number)
7079 `(setcar ,data ,number))
7081 (defmacro gnus-data-mark (data)
7084 (defmacro gnus-data-set-mark (data mark)
7085 `(setcar (nthcdr 1 ,data) ,mark))
7087 (defmacro gnus-data-pos (data)
7090 (defmacro gnus-data-set-pos (data pos)
7091 `(setcar (nthcdr 2 ,data) ,pos))
7093 (defmacro gnus-data-header (data)
7096 (defmacro gnus-data-level (data)
7099 (defmacro gnus-data-unread-p (data)
7100 `(= (nth 1 ,data) gnus-unread-mark))
7102 (defmacro gnus-data-pseudo-p (data)
7103 `(consp (nth 3 ,data)))
7105 (defmacro gnus-data-find (number)
7106 `(assq ,number gnus-newsgroup-data))
7108 (defmacro gnus-data-find-list (number &optional data)
7109 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7110 (memq (assq ,number bdata)
7113 (defmacro gnus-data-make (number mark pos header level)
7114 `(list ,number ,mark ,pos ,header ,level))
7116 (defun gnus-data-enter (after-article number mark pos header level offset)
7117 (let ((data (gnus-data-find-list after-article)))
7118 (or data (error "No such article: %d" after-article))
7119 (setcdr data (cons (gnus-data-make number mark pos header level)
7121 (setq gnus-newsgroup-data-reverse nil)
7122 (gnus-data-update-list (cddr data) offset)))
7124 (defun gnus-data-enter-list (after-article list &optional offset)
7126 (let ((data (and after-article (gnus-data-find-list after-article)))
7128 (or data (not after-article) (error "No such article: %d" after-article))
7129 ;; Find the last element in the list to be spliced into the main
7132 (setq list (cdr list)))
7135 (setcdr list gnus-newsgroup-data)
7136 (setq gnus-newsgroup-data ilist)
7137 (and offset (gnus-data-update-list (cdr list) offset)))
7138 (setcdr list (cdr data))
7140 (and offset (gnus-data-update-list (cdr data) offset)))
7141 (setq gnus-newsgroup-data-reverse nil))))
7143 (defun gnus-data-remove (article &optional offset)
7144 (let ((data gnus-newsgroup-data))
7145 (if (= (gnus-data-number (car data)) article)
7146 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7147 gnus-newsgroup-data-reverse nil)
7149 (and (= (gnus-data-number (cadr data)) article)
7151 (setcdr data (cddr data))
7152 (and offset (gnus-data-update-list (cdr data) offset))
7154 gnus-newsgroup-data-reverse nil)))
7155 (setq data (cdr data))))))
7157 (defmacro gnus-data-list (backward)
7159 (or gnus-newsgroup-data-reverse
7160 (setq gnus-newsgroup-data-reverse
7161 (reverse gnus-newsgroup-data)))
7162 gnus-newsgroup-data))
7164 (defun gnus-data-update-list (data offset)
7165 "Add OFFSET to the POS of all data entries in DATA."
7167 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7168 (setq data (cdr data))))
7170 (defun gnus-data-compute-positions ()
7171 "Compute the positions of all articles."
7172 (let ((data gnus-newsgroup-data)
7175 (when (setq pos (text-property-any
7176 (point-min) (point-max)
7177 'gnus-number (gnus-data-number (car data))))
7178 (gnus-data-set-pos (car data) (+ pos 3)))
7179 (setq data (cdr data)))))
7181 (defun gnus-summary-article-pseudo-p (article)
7182 "Say whether this article is a pseudo article or not."
7183 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7185 (defun gnus-article-parent-p (number)
7186 "Say whether this article is a parent or not."
7187 (let ((data (gnus-data-find-list number)))
7188 (and (cdr data) ; There has to be an article after...
7189 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7190 (gnus-data-level (nth 1 data))))))
7192 (defun gnus-article-children (number)
7193 "Return a list of all children to NUMBER."
7194 (let* ((data (gnus-data-find-list number))
7195 (level (gnus-data-level (car data)))
7197 (setq data (cdr data))
7199 (= (gnus-data-level (car data)) (1+ level)))
7200 (push (gnus-data-number (car data)) children)
7201 (setq data (cdr data)))
7204 (defmacro gnus-summary-skip-intangible ()
7205 "If the current article is intangible, then jump to a different article."
7206 '(let ((to (get-text-property (point) 'gnus-intangible)))
7207 (and to (gnus-summary-goto-subject to))))
7209 (defmacro gnus-summary-article-intangible-p ()
7210 "Say whether this article is intangible or not."
7211 '(get-text-property (point) 'gnus-intangible))
7213 ;; Some summary mode macros.
7215 (defmacro gnus-summary-article-number ()
7216 "The article number of the article on the current line.
7217 If there isn's an article number here, then we return the current
7220 (gnus-summary-skip-intangible)
7221 (or (get-text-property (point) 'gnus-number)
7222 (gnus-summary-last-subject))))
7224 (defmacro gnus-summary-article-header (&optional number)
7225 `(gnus-data-header (gnus-data-find
7226 ,(or number '(gnus-summary-article-number)))))
7228 (defmacro gnus-summary-thread-level (&optional number)
7229 `(if (and (eq gnus-summary-make-false-root 'dummy)
7230 (get-text-property (point) 'gnus-intangible))
7232 (gnus-data-level (gnus-data-find
7233 ,(or number '(gnus-summary-article-number))))))
7235 (defmacro gnus-summary-article-mark (&optional number)
7236 `(gnus-data-mark (gnus-data-find
7237 ,(or number '(gnus-summary-article-number)))))
7239 (defmacro gnus-summary-article-pos (&optional number)
7240 `(gnus-data-pos (gnus-data-find
7241 ,(or number '(gnus-summary-article-number)))))
7243 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7244 (defmacro gnus-summary-article-subject (&optional number)
7245 "Return current subject string or nil if nothing."
7248 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7249 '(gnus-data-header (assq (gnus-summary-article-number)
7250 gnus-newsgroup-data)))))
7253 (mail-header-subject headers))))
7255 (defmacro gnus-summary-article-score (&optional number)
7256 "Return current article score."
7257 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7258 gnus-newsgroup-scored))
7259 gnus-summary-default-score 0))
7261 (defun gnus-summary-article-children (&optional number)
7262 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7263 (level (gnus-data-level (car data)))
7265 (while (and (setq data (cdr data))
7266 (> (setq l (gnus-data-level (car data))) level))
7267 (and (= (1+ level) l)
7268 (setq children (cons (gnus-data-number (car data))
7270 (nreverse children)))
7272 (defun gnus-summary-article-parent (&optional number)
7273 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7274 (gnus-data-list t)))
7275 (level (gnus-data-level (car data))))
7277 () ; This is a root.
7278 ;; We search until we find an article with a level less than
7279 ;; this one. That function has to be the parent.
7280 (while (and (setq data (cdr data))
7281 (not (< (gnus-data-level (car data)) level))))
7282 (and data (gnus-data-number (car data))))))
7284 (defun gnus-unread-mark-p (mark)
7285 "Say whether MARK is the unread mark."
7286 (= mark gnus-unread-mark))
7288 (defun gnus-read-mark-p (mark)
7289 "Say whether MARK is one of the marks that mark as read.
7290 This is all marks except unread, ticked, dormant, and expirable."
7291 (not (or (= mark gnus-unread-mark)
7292 (= mark gnus-ticked-mark)
7293 (= mark gnus-dormant-mark)
7294 (= mark gnus-expirable-mark))))
7296 ;; Various summary mode internalish functions.
7298 (defun gnus-mouse-pick-article (e)
7301 (gnus-summary-next-page nil t))
7303 (defun gnus-summary-setup-buffer (group)
7304 "Initialize summary buffer."
7305 (let ((buffer (concat "*Summary " group "*")))
7306 (if (get-buffer buffer)
7309 (setq gnus-summary-buffer (current-buffer))
7310 (not gnus-newsgroup-prepared))
7311 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7312 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7313 (gnus-add-current-to-buffer-list)
7314 (gnus-summary-mode group)
7316 (gnus-carpal-setup-buffer 'summary))
7317 (unless gnus-single-article-buffer
7318 (make-local-variable 'gnus-article-buffer)
7319 (make-local-variable 'gnus-article-current)
7320 (make-local-variable 'gnus-original-article-buffer))
7321 (setq gnus-newsgroup-name group)
7324 (defun gnus-set-global-variables ()
7325 ;; Set the global equivalents of the summary buffer-local variables
7326 ;; to the latest values they had. These reflect the summary buffer
7327 ;; that was in action when the last article was fetched.
7328 (when (eq major-mode 'gnus-summary-mode)
7329 (setq gnus-summary-buffer (current-buffer))
7330 (let ((name gnus-newsgroup-name)
7331 (marked gnus-newsgroup-marked)
7332 (unread gnus-newsgroup-unreads)
7333 (headers gnus-current-headers)
7334 (data gnus-newsgroup-data)
7335 (summary gnus-summary-buffer)
7336 (article-buffer gnus-article-buffer)
7337 (original gnus-original-article-buffer)
7338 (gac gnus-article-current)
7339 (score-file gnus-current-score-file))
7341 (set-buffer gnus-group-buffer)
7342 (setq gnus-newsgroup-name name)
7343 (setq gnus-newsgroup-marked marked)
7344 (setq gnus-newsgroup-unreads unread)
7345 (setq gnus-current-headers headers)
7346 (setq gnus-newsgroup-data data)
7347 (setq gnus-article-current gac)
7348 (setq gnus-summary-buffer summary)
7349 (setq gnus-article-buffer article-buffer)
7350 (setq gnus-original-article-buffer original)
7351 (setq gnus-current-score-file score-file)))))
7353 (defun gnus-summary-last-article-p (&optional article)
7354 "Return whether ARTICLE is the last article in the buffer."
7355 (if (not (setq article (or article (gnus-summary-article-number))))
7356 t ; All non-existant numbers are the last article. :-)
7357 (not (cdr (gnus-data-find-list article)))))
7359 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7360 "Insert a dummy root in the summary buffer."
7362 (add-text-properties
7363 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7364 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7366 (defvar gnus-thread-indent-array nil)
7367 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7368 (defun gnus-make-thread-indent-array ()
7370 (unless (and gnus-thread-indent-array
7371 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7372 (setq gnus-thread-indent-array (make-vector 201 "")
7373 gnus-thread-indent-array-level gnus-thread-indent-level)
7375 (aset gnus-thread-indent-array n
7376 (make-string (* n gnus-thread-indent-level) ? ))
7379 (defun gnus-summary-insert-line
7380 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7381 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7382 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7383 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7384 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7385 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7386 (gnus-tmp-score-char
7387 (if (or (null gnus-summary-default-score)
7388 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7389 gnus-summary-zcore-fuzz)) ?
7390 (if (< gnus-tmp-score gnus-summary-default-score)
7391 gnus-score-below-mark gnus-score-over-mark)))
7392 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7393 ((memq gnus-tmp-current gnus-newsgroup-cached)
7395 (gnus-tmp-replied gnus-replied-mark)
7396 ((memq gnus-tmp-current gnus-newsgroup-saved)
7398 (t gnus-unread-mark)))
7399 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7402 ((string-match "(.+)" gnus-tmp-from)
7403 (substring gnus-tmp-from
7404 (1+ (match-beginning 0)) (1- (match-end 0))))
7405 ((string-match "<[^>]+> *$" gnus-tmp-from)
7406 (let ((beg (match-beginning 0)))
7407 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7408 (substring gnus-tmp-from (1+ (match-beginning 0))
7409 (1- (match-end 0))))
7410 (substring gnus-tmp-from 0 beg))))
7412 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7413 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7414 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7415 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7416 (buffer-read-only nil))
7417 (when (string= gnus-tmp-name "")
7418 (setq gnus-tmp-name gnus-tmp-from))
7419 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7422 (progn (eval gnus-summary-line-format-spec) (point))
7423 'gnus-number gnus-tmp-number)
7424 (when (gnus-visual-p 'summary-highlight 'highlight)
7426 (run-hooks 'gnus-summary-update-hook)
7429 (defun gnus-summary-update-line (&optional dont-update)
7430 ;; Update summary line after change.
7431 (when (and gnus-summary-default-score
7432 (not gnus-summary-inhibit-highlight))
7433 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7434 (article (gnus-summary-article-number))
7435 (score (gnus-summary-article-score article)))
7437 (if (and gnus-summary-mark-below
7438 (< (gnus-summary-article-score)
7439 gnus-summary-mark-below))
7440 ;; This article has a low score, so we mark it as read.
7441 (when (memq article gnus-newsgroup-unreads)
7442 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7443 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7444 ;; This article was previously marked as read on account
7445 ;; of a low score, but now it has risen, so we mark it as
7447 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7448 (gnus-summary-update-mark
7449 (if (or (null gnus-summary-default-score)
7450 (<= (abs (- score gnus-summary-default-score))
7451 gnus-summary-zcore-fuzz)) ?
7452 (if (< score gnus-summary-default-score)
7453 gnus-score-below-mark gnus-score-over-mark)) 'score))
7454 ;; Do visual highlighting.
7455 (when (gnus-visual-p 'summary-highlight 'highlight)
7456 (run-hooks 'gnus-summary-update-hook)))))
7458 (defvar gnus-tmp-new-adopts nil)
7460 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7461 ;; Sum up all elements (and sub-elements) in a list.
7463 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7465 ((and (consp thread) (cdr thread))
7468 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7471 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7474 (when (and level (zerop level) gnus-tmp-new-adopts)
7477 'gnus-summary-number-of-articles-in-thread
7478 gnus-tmp-new-adopts))))
7480 (if (> number 1) gnus-not-empty-thread-mark
7481 gnus-empty-thread-mark)
7484 (defun gnus-summary-set-local-parameters (group)
7485 "Go through the local params of GROUP and set all variable specs in that list."
7486 (let ((params (gnus-info-params (gnus-get-info group)))
7489 (setq elem (car params)
7490 params (cdr params))
7491 (and (consp elem) ; Has to be a cons.
7492 (consp (cdr elem)) ; The cdr has to be a list.
7493 (symbolp (car elem)) ; Has to be a symbol in there.
7494 (not (memq (car elem)
7495 '(quit-config to-address to-list to-group)))
7496 (progn ; So we set it.
7497 (make-local-variable (car elem))
7498 (set (car elem) (eval (nth 1 elem))))))))
7500 (defun gnus-summary-read-group (group &optional show-all no-article
7501 kill-buffer no-display)
7502 "Start reading news in newsgroup GROUP.
7503 If SHOW-ALL is non-nil, already read articles are also listed.
7504 If NO-ARTICLE is non-nil, no article is selected initially.
7505 If NO-DISPLAY, don't generate a summary buffer."
7506 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7507 (let* ((new-group (gnus-summary-setup-buffer group))
7508 (quit-config (gnus-group-quit-config group))
7509 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7511 ;; This summary buffer exists already, so we just select it.
7513 (gnus-set-global-variables)
7515 (gnus-kill-or-deaden-summary kill-buffer))
7516 (gnus-configure-windows 'summary 'force)
7517 (gnus-set-mode-line 'summary)
7518 (gnus-summary-position-point)
7521 ;; We couldn't select this group.
7523 (when (and (eq major-mode 'gnus-summary-mode)
7524 (not (equal (current-buffer) kill-buffer)))
7525 (kill-buffer (current-buffer))
7526 (if (not quit-config)
7528 (set-buffer gnus-group-buffer)
7529 (gnus-group-jump-to-group group)
7530 (gnus-group-next-unread-group 1))
7531 (if (not (buffer-name (car quit-config)))
7532 (gnus-configure-windows 'group 'force)
7533 (set-buffer (car quit-config))
7534 (and (eq major-mode 'gnus-summary-mode)
7535 (gnus-set-global-variables))
7536 (gnus-configure-windows (cdr quit-config)))))
7537 (gnus-message 3 "Can't select group")
7539 ;; The user did a `C-g' while prompting for number of articles,
7540 ;; so we exit this group.
7541 ((eq did-select 'quit)
7542 (and (eq major-mode 'gnus-summary-mode)
7543 (not (equal (current-buffer) kill-buffer))
7544 (kill-buffer (current-buffer)))
7546 (gnus-kill-or-deaden-summary kill-buffer))
7547 (if (not quit-config)
7549 (set-buffer gnus-group-buffer)
7550 (gnus-group-jump-to-group group)
7551 (gnus-group-next-unread-group 1)
7552 (gnus-configure-windows 'group 'force))
7553 (if (not (buffer-name (car quit-config)))
7554 (gnus-configure-windows 'group 'force)
7555 (set-buffer (car quit-config))
7556 (and (eq major-mode 'gnus-summary-mode)
7557 (gnus-set-global-variables))
7558 (gnus-configure-windows (cdr quit-config))))
7559 ;; Finally signal the quit.
7561 ;; The group was successfully selected.
7563 (gnus-set-global-variables)
7564 ;; Save the active value in effect when the group was entered.
7565 (setq gnus-newsgroup-active
7567 (gnus-active gnus-newsgroup-name)))
7568 ;; You can change the summary buffer in some way with this hook.
7569 (run-hooks 'gnus-select-group-hook)
7570 ;; Set any local variables in the group parameters.
7571 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7572 (gnus-update-format-specifications)
7573 ;; Do score processing.
7574 (when gnus-use-scoring
7575 (gnus-possibly-score-headers))
7576 ;; Check whether to fill in the gaps in the threads.
7577 (when gnus-build-sparse-threads
7578 (gnus-build-sparse-threads))
7579 ;; Find the initial limit.
7581 (let ((gnus-newsgroup-dormant nil))
7582 (gnus-summary-initial-limit show-all))
7583 (gnus-summary-initial-limit show-all))
7584 ;; Generate the summary buffer.
7586 (gnus-summary-prepare))
7587 (when gnus-use-trees
7588 (gnus-tree-open group)
7589 (setq gnus-summary-highlight-line-function
7590 'gnus-tree-highlight-article))
7591 ;; If the summary buffer is empty, but there are some low-scored
7592 ;; articles or some excluded dormants, we include these in the
7594 (when (and (zerop (buffer-size))
7596 (cond (gnus-newsgroup-dormant
7597 (gnus-summary-limit-include-dormant))
7598 ((and gnus-newsgroup-scored show-all)
7599 (gnus-summary-limit-include-expunged))))
7600 ;; Function `gnus-apply-kill-file' must be called in this hook.
7601 (run-hooks 'gnus-apply-kill-hook)
7602 (if (and (zerop (buffer-size))
7605 ;; This newsgroup is empty.
7606 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7607 (gnus-message 6 "No unread news")
7609 (gnus-kill-or-deaden-summary kill-buffer))
7610 ;; Return nil from this function.
7612 ;; Hide conversation thread subtrees. We cannot do this in
7613 ;; gnus-summary-prepare-hook since kill processing may not
7614 ;; work with hidden articles.
7615 (and gnus-show-threads
7616 gnus-thread-hide-subtree
7617 (gnus-summary-hide-all-threads))
7618 ;; Show first unread article if requested.
7619 (if (and (not no-article)
7621 gnus-newsgroup-unreads
7622 gnus-auto-select-first)
7623 (unless (if (eq gnus-auto-select-first 'best)
7624 (gnus-summary-best-unread-article)
7625 (gnus-summary-first-unread-article))
7626 (gnus-configure-windows 'summary))
7627 ;; Don't select any articles, just move point to the first
7628 ;; article in the group.
7629 (goto-char (point-min))
7630 (gnus-summary-position-point)
7631 (gnus-set-mode-line 'summary)
7632 (gnus-configure-windows 'summary 'force))
7633 ;; If we are in async mode, we send some info to the backend.
7634 (when gnus-newsgroup-async
7635 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7637 (gnus-kill-or-deaden-summary kill-buffer))
7638 (when (get-buffer-window gnus-group-buffer t)
7639 ;; Gotta use windows, because recenter does wierd stuff if
7640 ;; the current buffer ain't the displayed window.
7641 (let ((owin (selected-window)))
7642 (select-window (get-buffer-window gnus-group-buffer t))
7643 (when (gnus-group-goto-group group)
7645 (select-window owin))))
7646 ;; Mark this buffer as "prepared".
7647 (setq gnus-newsgroup-prepared t)
7650 (defun gnus-summary-prepare ()
7651 "Generate the summary buffer."
7652 (let ((buffer-read-only nil))
7654 (setq gnus-newsgroup-data nil
7655 gnus-newsgroup-data-reverse nil)
7656 (run-hooks 'gnus-summary-generate-hook)
7657 ;; Generate the buffer, either with threads or without.
7658 (when gnus-newsgroup-headers
7659 (gnus-summary-prepare-threads
7660 (if gnus-show-threads
7661 (gnus-sort-gathered-threads
7662 (funcall gnus-summary-thread-gathering-function
7664 (gnus-cut-threads (gnus-make-threads)))))
7665 ;; Unthreaded display.
7666 (gnus-sort-articles gnus-newsgroup-headers))))
7667 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7668 ;; Call hooks for modifying summary buffer.
7669 (goto-char (point-min))
7670 (run-hooks 'gnus-summary-prepare-hook)))
7672 (defun gnus-gather-threads-by-subject (threads)
7673 "Gather threads by looking at Subject headers."
7674 (if (not gnus-summary-make-false-root)
7676 (let ((hashtb (gnus-make-hashtable 1023))
7679 subject hthread whole-subject)
7681 (setq whole-subject (mail-header-subject (caar threads)))
7684 ;; Truncate the subject.
7685 ((numberp gnus-summary-gather-subject-limit)
7686 (setq subject (gnus-simplify-subject-re whole-subject))
7687 (if (> (length subject) gnus-summary-gather-subject-limit)
7688 (substring subject 0 gnus-summary-gather-subject-limit)
7690 ;; Fuzzily simplify it.
7691 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7692 (gnus-simplify-subject-fuzzy whole-subject))
7693 ;; Just remove the leading "Re:".
7695 (gnus-simplify-subject-re whole-subject))))
7697 (if (and gnus-summary-gather-exclude-subject
7698 (string-match gnus-summary-gather-exclude-subject
7700 () ; We don't want to do anything with this article.
7701 ;; We simplify the subject before looking it up in the
7704 (if (setq hthread (gnus-gethash subject hashtb))
7706 ;; We enter a dummy root into the thread, if we
7707 ;; haven't done that already.
7708 (unless (stringp (caar hthread))
7709 (setcar hthread (list whole-subject (car hthread))))
7710 ;; We add this new gathered thread to this gathered
7712 (setcdr (car hthread)
7713 (nconc (cdar hthread) (list (car threads))))
7714 ;; Remove it from the list of threads.
7715 (setcdr prev (cdr threads))
7716 (setq threads prev))
7717 ;; Enter this thread into the hash table.
7718 (gnus-sethash subject threads hashtb)))
7720 (setq threads (cdr threads)))
7723 (defun gnus-gather-threads-by-references (threads)
7724 "Gather threads by looking at References headers."
7725 (let ((idhashtb (gnus-make-hashtable 1023))
7726 (thhashtb (gnus-make-hashtable 1023))
7729 ids references id gthread gid entered)
7731 (when (setq references (mail-header-references (caar threads)))
7732 (setq id (mail-header-id (caar threads)))
7733 (setq ids (gnus-split-references references))
7736 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7738 (gnus-sethash (car ids) id idhashtb)
7739 (gnus-sethash id threads thhashtb))
7740 (setq gthread (gnus-gethash gid thhashtb))
7742 ;; We enter a dummy root into the thread, if we
7743 ;; haven't done that already.
7744 (unless (stringp (caar gthread))
7745 (setcar gthread (list (mail-header-subject (caar gthread))
7747 ;; We add this new gathered thread to this gathered
7749 (setcdr (car gthread)
7750 (nconc (cdar gthread) (list (car threads)))))
7751 ;; Add it into the thread hash table.
7752 (gnus-sethash id gthread thhashtb)
7754 ;; Remove it from the list of threads.
7755 (setcdr prev (cdr threads))
7756 (setq threads prev))
7757 (setq ids (cdr ids))))
7759 (setq threads (cdr threads)))
7762 (defun gnus-sort-gathered-threads (threads)
7763 "Sort subtreads inside each gathered thread by article number."
7764 (let ((result threads))
7766 (when (stringp (caar threads))
7767 (setcdr (car threads)
7768 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7769 (setq threads (cdr threads)))
7772 (defun gnus-make-threads ()
7773 "Go through the dependency hashtb and find the roots. Return all threads."
7777 (unless (car (symbol-value refs))
7778 ;; These threads do not refer back to any other articles,
7779 ;; so they're roots.
7780 (setq threads (append (cdr (symbol-value refs)) threads))))
7781 gnus-newsgroup-dependencies)
7784 (defun gnus-build-sparse-threads ()
7785 (let ((headers gnus-newsgroup-headers)
7786 (deps gnus-newsgroup-dependencies)
7787 header references generation relations
7788 cthread subject child end pthread relation)
7789 ;; First we create an alist of generations/relations, where
7790 ;; generations is how much we trust the ralation, and the relation
7792 (gnus-message 7 "Making sparse threads...")
7794 (nnheader-set-temp-buffer " *gnus sparse threads*")
7795 (while (setq header (pop headers))
7796 (when (and (setq references (mail-header-references header))
7797 (not (string= references "")))
7799 (setq child (mail-header-id header)
7800 subject (mail-header-subject header))
7802 (while (search-backward ">" nil t)
7803 (setq end (1+ (point)))
7804 (when (search-backward "<" nil t)
7805 (push (list (incf generation)
7806 child (setq child (buffer-substring (point) end))
7809 (push (list (1+ generation) child nil subject) relations)
7811 (kill-buffer (current-buffer)))
7812 ;; Sort over trustworthiness.
7813 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7814 (while (setq relation (pop relations))
7815 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7816 (unless (car (symbol-value cthread))
7817 ;; Make this article the parent of these threads.
7818 (setcar (symbol-value cthread)
7819 (vector gnus-reffed-article-number
7823 (or (caddr relation) "") 0 0 "")))
7824 (set cthread (list (vector gnus-reffed-article-number
7826 "" "" (cadr relation)
7827 (or (caddr relation) "") 0 0 ""))))
7828 (push gnus-reffed-article-number gnus-newsgroup-limit)
7829 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7830 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7831 gnus-newsgroup-reads)
7832 (decf gnus-reffed-article-number)
7833 ;; Make this new thread the child of its parent.
7834 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7835 (setcdr (symbol-value pthread)
7836 (nconc (cdr (symbol-value pthread))
7837 (list (symbol-value cthread))))
7838 (set pthread (list nil (symbol-value cthread))))))
7839 (gnus-message 7 "Making sparse threads...done")))
7841 (defun gnus-build-old-threads ()
7842 ;; Look at all the articles that refer back to old articles, and
7843 ;; fetch the headers for the articles that aren't there. This will
7844 ;; build complete threads - if the roots haven't been expired by the
7849 (when (not (car (symbol-value refs)))
7850 (setq heads (cdr (symbol-value refs)))
7852 (if (memq (mail-header-number (caar heads))
7853 gnus-newsgroup-dormant)
7854 (setq heads (cdr heads))
7855 (setq id (symbol-name refs))
7856 (while (and (setq id (gnus-build-get-header id))
7857 (not (car (gnus-gethash
7858 id gnus-newsgroup-dependencies)))))
7859 (setq heads nil)))))
7860 gnus-newsgroup-dependencies)))
7862 (defun gnus-build-get-header (id)
7863 ;; Look through the buffer of NOV lines and find the header to
7864 ;; ID. Enter this line into the dependencies hash table, and return
7865 ;; the id of the parent article (if any).
7866 (let ((deps gnus-newsgroup-dependencies)
7870 (set-buffer nntp-server-buffer)
7871 (goto-char (point-min))
7872 (while (and (not found) (search-forward id nil t))
7874 (setq found (looking-at
7875 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7876 (regexp-quote id))))
7877 (or found (beginning-of-line 2)))
7881 (setq header (gnus-nov-parse-line
7882 (read (current-buffer)) deps))
7883 (gnus-parent-id (mail-header-references header)))))
7885 (let ((number (mail-header-number header)))
7886 (push number gnus-newsgroup-limit)
7887 (push header gnus-newsgroup-headers)
7888 (if (memq number gnus-newsgroup-unselected)
7890 (push number gnus-newsgroup-unreads)
7891 (setq gnus-newsgroup-unselected
7892 (delq number gnus-newsgroup-unselected)))
7893 (push number gnus-newsgroup-ancient)))))))
7895 (defun gnus-summary-update-article (article &optional header)
7896 "Update ARTICLE in the summary buffer."
7897 (set-buffer gnus-summary-buffer)
7898 (let* ((header (or header (gnus-summary-article-header article)))
7899 (id (mail-header-id header))
7900 (data (gnus-data-find article))
7901 (thread (gnus-id-to-thread id))
7903 (gnus-id-to-thread (or (gnus-parent-id
7904 (mail-header-references header))
7906 (buffer-read-only nil)
7908 (number (mail-header-number header))
7913 (delq thread parent))
7914 (if (gnus-summary-insert-subject id header)
7915 ;; Set the (possibly) new article number in the data structure.
7916 (gnus-data-set-number data (gnus-id-to-article id))
7920 (defun gnus-rebuild-thread (id)
7921 "Rebuild the thread containing ID."
7922 (let ((buffer-read-only nil)
7923 current thread data)
7924 (if (not gnus-show-threads)
7925 (setq thread (list (car (gnus-id-to-thread id))))
7926 ;; Get the thread this article is part of.
7927 (setq thread (gnus-remove-thread id)))
7928 (setq current (save-excursion
7929 (and (zerop (forward-line -1))
7930 (gnus-summary-article-number))))
7931 ;; If this is a gathered thread, we have to go some re-gathering.
7932 (when (stringp (car thread))
7933 (let ((subject (car thread))
7935 (setq thread (cdr thread))
7937 (unless (memq (setq thr (gnus-id-to-thread
7939 (mail-header-id (caar thread)))))
7942 (setq thread (cdr thread)))
7943 ;; We now have all (unique) roots.
7944 (if (= (length roots) 1)
7945 ;; All the loose roots are now one solid root.
7946 (setq thread (car roots))
7947 (setq thread (cons subject (gnus-sort-threads roots))))))
7949 ;; We then insert this thread into the summary buffer.
7950 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7951 (gnus-summary-prepare-threads (list thread))
7952 (setq data (nreverse gnus-newsgroup-data))
7953 (setq threads gnus-newsgroup-threads))
7954 ;; We splice the new data into the data structure.
7955 (gnus-data-enter-list current data)
7956 (gnus-data-compute-positions)
7957 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7959 (defun gnus-id-to-thread (id)
7960 "Return the (sub-)thread where ID appears."
7961 (gnus-gethash id gnus-newsgroup-dependencies))
7963 (defun gnus-id-to-article (id)
7964 "Return the article number of ID."
7965 (let ((thread (gnus-id-to-thread id)))
7967 (mail-header-number (car thread)))))
7969 (defun gnus-id-to-header (id)
7970 "Return the article headers of ID."
7971 (car (gnus-id-to-thread id)))
7973 (defun gnus-article-displayed-root-p (article)
7974 "Say whether ARTICLE is a root(ish) article."
7975 (let ((level (gnus-summary-thread-level article))
7981 (null (setq particle (gnus-id-to-article
7983 (mail-header-references
7984 (gnus-summary-article-header article))))))
7985 (null (gnus-summary-thread-level particle)))))))
7987 (defun gnus-root-id (id)
7988 "Return the id of the root of the thread where ID appears."
7990 (while (and id (setq prev (car (gnus-gethash
7991 id gnus-newsgroup-dependencies))))
7993 id (gnus-parent-id (mail-header-references prev))))
7996 (defun gnus-remove-thread (id &optional dont-remove)
7997 "Remove the thread that has ID in it."
7998 (let ((dep gnus-newsgroup-dependencies)
7999 headers thread last-id)
8000 ;; First go up in this thread until we find the root.
8001 (setq last-id (gnus-root-id id))
8002 (setq headers (list (car (gnus-id-to-thread last-id))
8003 (caadr (gnus-id-to-thread last-id))))
8004 ;; We have now found the real root of this thread. It might have
8005 ;; been gathered into some loose thread, so we have to search
8006 ;; through the threads to find the thread we wanted.
8007 (let ((threads gnus-newsgroup-threads)
8010 (setq sub (car threads))
8011 (if (stringp (car sub))
8012 ;; This is a gathered threads, so we look at the roots
8013 ;; below it to find whether this article in in this
8016 (setq sub (cdr sub))
8018 (when (member (caar sub) headers)
8019 (setq thread (car threads)
8022 (setq sub (cdr sub))))
8023 ;; It's an ordinary thread, so we check it.
8024 (when (eq (car sub) (car headers))
8027 (setq threads (cdr threads)))
8028 ;; If this article is in no thread, then it's a root.
8031 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8032 (setq thread (gnus-gethash last-id dep)))
8035 thread ; We return this thread.
8037 (if (stringp (car thread))
8039 ;; If we use dummy roots, then we have to remove the
8040 ;; dummy root as well.
8041 (when (eq gnus-summary-make-false-root 'dummy)
8044 (setq thread (cdr thread))
8046 (gnus-remove-thread-1 (car thread))
8047 (setq thread (cdr thread))))
8048 (gnus-remove-thread-1 thread))))))))
8050 (defun gnus-remove-thread-1 (thread)
8051 "Remove the thread THREAD recursively."
8052 (let ((number (mail-header-number (car thread)))
8054 (when (setq pos (text-property-any
8055 (point-min) (point-max) 'gnus-number number))
8058 (gnus-data-remove number))
8059 (setq thread (cdr thread))
8061 (gnus-remove-thread-1 (pop thread)))))
8063 (defun gnus-sort-threads (threads)
8065 (if (not gnus-thread-sort-functions)
8067 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8068 (car gnus-thread-sort-functions)
8070 ,(gnus-make-sort-function
8071 (reverse gnus-thread-sort-functions))))))
8072 (gnus-message 7 "Sorting threads...")
8075 (gnus-message 7 "Sorting threads...done")))))
8077 (defun gnus-sort-articles (articles)
8079 (when gnus-article-sort-functions
8080 (let ((func (if (= 1 (length gnus-article-sort-functions))
8081 (car gnus-article-sort-functions)
8083 ,(gnus-make-sort-function
8084 (reverse gnus-article-sort-functions))))))
8085 (gnus-message 7 "Sorting articles...")
8087 (setq gnus-newsgroup-headers (sort articles func))
8088 (gnus-message 7 "Sorting articles...done")))))
8090 (defun gnus-make-sort-function (funs)
8091 "Return a composite sort condition based on the functions in FUNC."
8093 `(or (,(car funs) t1 t2)
8094 (and (not (,(car funs) t2 t1))
8095 ,(gnus-make-sort-function (cdr funs))))
8096 `(,(car funs) t1 t2)))
8098 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8099 (defmacro gnus-thread-header (thread)
8100 ;; Return header of first article in THREAD.
8101 ;; Note that THREAD must never, ever be anything else than a variable -
8102 ;; using some other form will lead to serious barfage.
8103 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8104 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8105 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8108 (defsubst gnus-article-sort-by-number (h1 h2)
8109 "Sort articles by article number."
8110 (< (mail-header-number h1)
8111 (mail-header-number h2)))
8113 (defun gnus-thread-sort-by-number (h1 h2)
8114 "Sort threads by root article number."
8115 (gnus-article-sort-by-number
8116 (gnus-thread-header h1) (gnus-thread-header h2)))
8118 (defsubst gnus-article-sort-by-author (h1 h2)
8119 "Sort articles by root author."
8121 (let ((extract (funcall
8122 gnus-extract-address-components
8123 (mail-header-from h1))))
8124 (or (car extract) (cdr extract)))
8125 (let ((extract (funcall
8126 gnus-extract-address-components
8127 (mail-header-from h2))))
8128 (or (car extract) (cdr extract)))))
8130 (defun gnus-thread-sort-by-author (h1 h2)
8131 "Sort threads by root author."
8132 (gnus-article-sort-by-author
8133 (gnus-thread-header h1) (gnus-thread-header h2)))
8135 (defsubst gnus-article-sort-by-subject (h1 h2)
8136 "Sort articles by root subject."
8138 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8139 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8141 (defun gnus-thread-sort-by-subject (h1 h2)
8142 "Sort threads by root subject."
8143 (gnus-article-sort-by-subject
8144 (gnus-thread-header h1) (gnus-thread-header h2)))
8146 (defsubst gnus-article-sort-by-date (h1 h2)
8147 "Sort articles by root article date."
8149 (gnus-sortable-date (mail-header-date h1))
8150 (gnus-sortable-date (mail-header-date h2))))
8152 (defun gnus-thread-sort-by-date (h1 h2)
8153 "Sort threads by root article date."
8154 (gnus-article-sort-by-date
8155 (gnus-thread-header h1) (gnus-thread-header h2)))
8157 (defsubst gnus-article-sort-by-score (h1 h2)
8158 "Sort articles by root article score.
8159 Unscored articles will be counted as having a score of zero."
8160 (> (or (cdr (assq (mail-header-number h1)
8161 gnus-newsgroup-scored))
8162 gnus-summary-default-score 0)
8163 (or (cdr (assq (mail-header-number h2)
8164 gnus-newsgroup-scored))
8165 gnus-summary-default-score 0)))
8167 (defun gnus-thread-sort-by-score (h1 h2)
8168 "Sort threads by root article score."
8169 (gnus-article-sort-by-score
8170 (gnus-thread-header h1) (gnus-thread-header h2)))
8172 (defun gnus-thread-sort-by-total-score (h1 h2)
8173 "Sort threads by the sum of all scores in the thread.
8174 Unscored articles will be counted as having a score of zero."
8175 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8177 (defun gnus-thread-total-score (thread)
8178 ;; This function find the total score of THREAD.
8180 (if (stringp (car thread))
8181 (apply gnus-thread-score-function 0
8182 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8183 (gnus-thread-total-score-1 thread))
8184 (gnus-thread-total-score-1 (list thread))))
8186 (defun gnus-thread-total-score-1 (root)
8187 ;; This function find the total score of the thread below ROOT.
8188 (setq root (car root))
8189 (apply gnus-thread-score-function
8190 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8191 gnus-summary-default-score 0)
8192 (mapcar 'gnus-thread-total-score
8193 (cdr (gnus-gethash (mail-header-id root)
8194 gnus-newsgroup-dependencies)))))
8196 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8197 (defvar gnus-tmp-prev-subject nil)
8198 (defvar gnus-tmp-false-parent nil)
8199 (defvar gnus-tmp-root-expunged nil)
8200 (defvar gnus-tmp-dummy-line nil)
8202 (defun gnus-summary-prepare-threads (threads)
8203 "Prepare summary buffer from THREADS and indentation LEVEL.
8204 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8205 or a straight list of headers."
8206 (gnus-message 7 "Generating summary...")
8208 (setq gnus-newsgroup-threads threads)
8211 (let ((gnus-tmp-level 0)
8212 (default-score (or gnus-summary-default-score 0))
8213 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8214 thread number subject stack state gnus-tmp-gathered beg-match
8215 new-roots gnus-tmp-new-adopts thread-end
8216 gnus-tmp-header gnus-tmp-unread
8217 gnus-tmp-replied gnus-tmp-subject-or-nil
8218 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8219 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8220 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8222 (setq gnus-tmp-prev-subject nil)
8224 (if (vectorp (car threads))
8225 ;; If this is a straight (sic) list of headers, then a
8226 ;; threaded summary display isn't required, so we just create
8227 ;; an unthreaded one.
8228 (gnus-summary-prepare-unthreaded threads)
8230 ;; Do the threaded display.
8232 (while (or threads stack gnus-tmp-new-adopts new-roots)
8234 (if (and (= gnus-tmp-level 0)
8235 (not (setq gnus-tmp-dummy-line nil))
8238 (not gnus-tmp-false-parent)
8239 (or gnus-tmp-new-adopts new-roots))
8240 (if gnus-tmp-new-adopts
8241 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8242 thread (list (car gnus-tmp-new-adopts))
8243 gnus-tmp-header (caar thread)
8244 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8246 (setq thread (list (car new-roots))
8247 gnus-tmp-header (caar thread)
8248 new-roots (cdr new-roots))))
8251 ;; If there are some threads, we do them before the
8252 ;; threads on the stack.
8253 (setq thread threads
8254 gnus-tmp-header (caar thread))
8255 ;; There were no current threads, so we pop something off
8257 (setq state (car stack)
8258 gnus-tmp-level (car state)
8261 gnus-tmp-header (caar thread))))
8263 (setq gnus-tmp-false-parent nil)
8264 (setq gnus-tmp-root-expunged nil)
8265 (setq thread-end nil)
8267 (if (stringp gnus-tmp-header)
8268 ;; The header is a dummy root.
8270 ((eq gnus-summary-make-false-root 'adopt)
8271 ;; We let the first article adopt the rest.
8272 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8274 (setq gnus-tmp-gathered
8276 (lambda (h) (mail-header-number (car h)))
8279 (setq thread (cons (list (caar thread)
8282 (setq gnus-tmp-level -1
8283 gnus-tmp-false-parent t))
8284 ((eq gnus-summary-make-false-root 'empty)
8285 ;; We print adopted articles with empty subject fields.
8286 (setq gnus-tmp-gathered
8288 (lambda (h) (mail-header-number (car h)))
8291 (setq gnus-tmp-level -1))
8292 ((eq gnus-summary-make-false-root 'dummy)
8293 ;; We remember that we probably want to output a dummy
8295 (setq gnus-tmp-dummy-line gnus-tmp-header)
8296 (setq gnus-tmp-prev-subject gnus-tmp-header))
8298 ;; We do not make a root for the gathered
8299 ;; sub-threads at all.
8300 (setq gnus-tmp-level -1)))
8302 (setq number (mail-header-number gnus-tmp-header)
8303 subject (mail-header-subject gnus-tmp-header))
8306 ;; If the thread has changed subject, we might want to make
8307 ;; this subthread into a root.
8308 ((and (null gnus-thread-ignore-subject)
8309 (not (zerop gnus-tmp-level))
8310 gnus-tmp-prev-subject
8312 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8313 (setq new-roots (nconc new-roots (list (car thread)))
8315 gnus-tmp-header nil))
8316 ;; If the article lies outside the current limit,
8317 ;; then we do not display it.
8318 ((and (not (memq number gnus-newsgroup-limit))
8319 (not gnus-tmp-dummy-line))
8320 (setq gnus-tmp-gathered
8322 (lambda (h) (mail-header-number (car h)))
8325 (setq gnus-tmp-new-adopts (if (cdar thread)
8326 (append gnus-tmp-new-adopts
8328 gnus-tmp-new-adopts)
8330 gnus-tmp-header nil)
8331 (when (zerop gnus-tmp-level)
8332 (setq gnus-tmp-root-expunged t)))
8333 ;; Perhaps this article is to be marked as read?
8334 ((and gnus-summary-mark-below
8335 (< (or (cdr (assq number gnus-newsgroup-scored))
8337 gnus-summary-mark-below)
8338 ;; Don't touch sparse articles.
8339 (not (memq number gnus-newsgroup-sparse)))
8340 (setq gnus-newsgroup-unreads
8341 (delq number gnus-newsgroup-unreads))
8342 (if gnus-newsgroup-auto-expire
8343 (push number gnus-newsgroup-expirable)
8344 (push (cons number gnus-low-score-mark)
8345 gnus-newsgroup-reads))))
8347 (when gnus-tmp-header
8348 ;; We may have an old dummy line to output before this
8350 (when gnus-tmp-dummy-line
8351 (gnus-summary-insert-dummy-line
8352 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8353 (setq gnus-tmp-dummy-line nil))
8355 ;; Compute the mark.
8359 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8360 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8361 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8362 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8363 (t (or (cdr (assq number gnus-newsgroup-reads))
8364 gnus-ancient-mark))))
8366 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8367 gnus-tmp-header gnus-tmp-level)
8368 gnus-newsgroup-data)
8370 ;; Actually insert the line.
8372 gnus-tmp-subject-or-nil
8374 ((and gnus-thread-ignore-subject
8375 gnus-tmp-prev-subject
8376 (not (inline (gnus-subject-equal
8377 gnus-tmp-prev-subject subject))))
8379 ((zerop gnus-tmp-level)
8380 (if (and (eq gnus-summary-make-false-root 'empty)
8381 (memq number gnus-tmp-gathered)
8382 gnus-tmp-prev-subject
8383 (inline (gnus-subject-equal
8384 gnus-tmp-prev-subject subject)))
8385 gnus-summary-same-subject
8387 (t gnus-summary-same-subject)))
8388 (if (and (eq gnus-summary-make-false-root 'adopt)
8389 (= gnus-tmp-level 1)
8390 (memq number gnus-tmp-gathered))
8391 (setq gnus-tmp-opening-bracket ?\<
8392 gnus-tmp-closing-bracket ?\>)
8393 (setq gnus-tmp-opening-bracket ?\[
8394 gnus-tmp-closing-bracket ?\]))
8396 gnus-tmp-indentation
8397 (aref gnus-thread-indent-array gnus-tmp-level)
8398 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8399 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8400 gnus-summary-default-score 0)
8402 (if (or (null gnus-summary-default-score)
8403 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8404 gnus-summary-zcore-fuzz)) ?
8405 (if (< gnus-tmp-score gnus-summary-default-score)
8406 gnus-score-below-mark gnus-score-over-mark))
8408 (cond ((memq number gnus-newsgroup-processable)
8410 ((memq number gnus-newsgroup-cached)
8412 ((memq number gnus-newsgroup-replied)
8414 (t gnus-unread-mark))
8415 gnus-tmp-from (mail-header-from gnus-tmp-header)
8418 ((string-match "(.+)" gnus-tmp-from)
8419 (substring gnus-tmp-from
8420 (1+ (match-beginning 0)) (1- (match-end 0))))
8421 ((string-match "<[^>]+> *$" gnus-tmp-from)
8422 (setq beg-match (match-beginning 0))
8423 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8424 (substring gnus-tmp-from (1+ (match-beginning 0))
8425 (1- (match-end 0))))
8426 (substring gnus-tmp-from 0 beg-match)))
8428 (when (string= gnus-tmp-name "")
8429 (setq gnus-tmp-name gnus-tmp-from))
8430 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8433 (progn (eval gnus-summary-line-format-spec) (point))
8434 'gnus-number number)
8437 (run-hooks 'gnus-summary-update-hook)
8440 (setq gnus-tmp-prev-subject subject)))
8442 (when (nth 1 thread)
8443 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8444 (incf gnus-tmp-level)
8445 (setq threads (if thread-end nil (cdar thread)))
8447 (setq gnus-tmp-level 0)))))
8448 (gnus-message 7 "Generating summary...done"))
8450 (defun gnus-summary-prepare-unthreaded (headers)
8451 "Generate an unthreaded summary buffer based on HEADERS."
8452 (let (header number mark)
8455 (setq header (car headers)
8456 headers (cdr headers)
8457 number (mail-header-number header))
8459 ;; We may have to root out some bad articles...
8460 (when (memq number gnus-newsgroup-limit)
8461 (when (and gnus-summary-mark-below
8462 (< (or (cdr (assq number gnus-newsgroup-scored))
8463 gnus-summary-default-score 0)
8464 gnus-summary-mark-below))
8465 (setq gnus-newsgroup-unreads
8466 (delq number gnus-newsgroup-unreads))
8467 (if gnus-newsgroup-auto-expire
8468 (push number gnus-newsgroup-expirable)
8469 (push (cons number gnus-low-score-mark)
8470 gnus-newsgroup-reads)))
8474 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8475 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8476 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8477 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8478 (t (or (cdr (assq number gnus-newsgroup-reads))
8479 gnus-ancient-mark))))
8480 (setq gnus-newsgroup-data
8481 (cons (gnus-data-make number mark (1+ (point)) header 0)
8482 gnus-newsgroup-data))
8483 (gnus-summary-insert-line
8484 header 0 nil mark (memq number gnus-newsgroup-replied)
8485 (memq number gnus-newsgroup-expirable)
8486 (mail-header-subject header) nil
8487 (cdr (assq number gnus-newsgroup-scored))
8488 (memq number gnus-newsgroup-processable))))))
8490 (defun gnus-select-newsgroup (group &optional read-all)
8491 "Select newsgroup GROUP.
8492 If READ-ALL is non-nil, all articles in the group are selected."
8493 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8494 (info (nth 2 entry))
8495 articles fetched-articles cached)
8497 (or (gnus-check-server
8498 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8499 (error "Couldn't open server"))
8501 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8502 (gnus-activate-group group) ; Or we can activate it...
8503 (progn ; Or we bug out.
8504 (when (equal major-mode 'gnus-summary-mode)
8505 (kill-buffer (current-buffer)))
8506 (error "Couldn't request group %s: %s"
8507 group (gnus-status-message group))))
8509 (setq gnus-newsgroup-name group)
8510 (setq gnus-newsgroup-unselected nil)
8511 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8513 (and gnus-asynchronous
8514 (gnus-check-backend-function
8515 'request-asynchronous gnus-newsgroup-name)
8516 (setq gnus-newsgroup-async
8517 (gnus-request-asynchronous gnus-newsgroup-name)))
8519 ;; Adjust and set lists of article marks.
8521 (gnus-adjust-marked-articles info))
8523 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8524 (when (gnus-virtual-group-p group)
8525 (setq cached gnus-newsgroup-cached))
8527 (setq gnus-newsgroup-unreads
8528 (gnus-set-difference
8529 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8530 gnus-newsgroup-dormant))
8532 (setq gnus-newsgroup-processable nil)
8534 (setq articles (gnus-articles-to-read group read-all))
8538 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8540 ((eq articles 0) nil)
8542 ;; Init the dependencies hash table.
8543 (setq gnus-newsgroup-dependencies
8544 (gnus-make-hashtable (length articles)))
8545 ;; Retrieve the headers and read them in.
8546 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8547 (setq gnus-newsgroup-headers
8549 (setq gnus-headers-retrieved-by
8550 (gnus-retrieve-headers
8551 articles gnus-newsgroup-name
8552 ;; We might want to fetch old headers, but
8553 ;; not if there is only 1 article.
8554 (and gnus-fetch-old-headers
8556 (not (eq gnus-fetch-old-headers 'some))
8557 (not (numberp gnus-fetch-old-headers)))
8558 (> (length articles) 1))))))
8559 (gnus-get-newsgroup-headers-xover articles)
8560 (gnus-get-newsgroup-headers)))
8561 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8563 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8565 (setq gnus-newsgroup-cached cached))
8567 ;; Set the initial limit.
8568 (setq gnus-newsgroup-limit (copy-sequence articles))
8569 ;; Remove canceled articles from the list of unread articles.
8570 (setq gnus-newsgroup-unreads
8571 (gnus-set-sorted-intersection
8572 gnus-newsgroup-unreads
8573 (setq fetched-articles
8574 (mapcar (lambda (headers) (mail-header-number headers))
8575 gnus-newsgroup-headers))))
8576 ;; Removed marked articles that do not exist.
8577 (gnus-update-missing-marks
8578 (gnus-sorted-complement fetched-articles articles))
8579 ;; We might want to build some more threads first.
8580 (and gnus-fetch-old-headers
8581 (eq gnus-headers-retrieved-by 'nov)
8582 (gnus-build-old-threads))
8583 ;; Check whether auto-expire is to be done in this group.
8584 (setq gnus-newsgroup-auto-expire
8585 (gnus-group-auto-expirable-p group))
8586 ;; Set up the article buffer now, if necessary.
8587 (unless gnus-single-article-buffer
8588 (gnus-article-setup-buffer))
8589 ;; First and last article in this newsgroup.
8590 (and gnus-newsgroup-headers
8591 (setq gnus-newsgroup-begin
8592 (mail-header-number (car gnus-newsgroup-headers)))
8593 (setq gnus-newsgroup-end
8595 (gnus-last-element gnus-newsgroup-headers))))
8596 (setq gnus-reffed-article-number -1)
8597 ;; GROUP is successfully selected.
8598 (or gnus-newsgroup-headers t)))))
8600 (defun gnus-articles-to-read (group read-all)
8601 ;; Find out what articles the user wants to read.
8603 ;; Select all articles if `read-all' is non-nil, or if there
8604 ;; are no unread articles.
8606 (and (zerop (length gnus-newsgroup-marked))
8607 (zerop (length gnus-newsgroup-unreads))))
8608 (gnus-uncompress-range (gnus-active group))
8609 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8610 (copy-sequence gnus-newsgroup-unreads))
8612 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8613 (scored (length scored-list))
8614 (number (length articles))
8615 (marked (+ (length gnus-newsgroup-marked)
8616 (length gnus-newsgroup-dormant)))
8624 ((and (or (<= scored marked) (= scored number))
8625 (numberp gnus-large-newsgroup)
8626 (> number gnus-large-newsgroup))
8630 "How many articles from %s (default %d): "
8631 gnus-newsgroup-name number))))
8632 (if (string-match "^[ \t]*$" input) number input)))
8633 ((and (> scored marked) (< scored number))
8636 (format "%s %s (%d scored, %d total): "
8637 "How many articles from"
8638 group scored number))))
8639 (if (string-match "^[ \t]*$" input)
8643 (setq select (if (stringp select) (string-to-number select) select))
8644 (if (or (null select) (zerop select))
8646 (if (and (not (zerop scored)) (<= (abs select) scored))
8648 (setq articles (sort scored-list '<))
8649 (setq number (length articles)))
8650 (setq articles (copy-sequence articles)))
8652 (if (< (abs select) number)
8654 ;; Select the N oldest articles.
8655 (setcdr (nthcdr (1- (abs select)) articles) nil)
8656 ;; Select the N most recent articles.
8657 (setq articles (nthcdr (- number select) articles))))
8658 (setq gnus-newsgroup-unselected
8659 (gnus-sorted-intersection
8660 gnus-newsgroup-unreads
8661 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8664 (defun gnus-killed-articles (killed articles)
8667 (if (inline (gnus-member-of-range (car articles) killed))
8668 (setq out (cons (car articles) out)))
8669 (setq articles (cdr articles)))
8672 (defun gnus-uncompress-marks (marks)
8673 "Uncompress the mark ranges in MARKS."
8674 (let ((uncompressed '(score bookmark))
8677 (if (memq (caar marks) uncompressed)
8678 (push (car marks) out)
8679 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8680 (setq marks (cdr marks)))
8683 (defun gnus-adjust-marked-articles (info)
8684 "Set all article lists and remove all marks that are no longer legal."
8685 (let* ((marked-lists (gnus-info-marks info))
8686 (active (gnus-active (gnus-info-group info)))
8689 (types gnus-article-mark-lists)
8690 (uncompressed '(score bookmark))
8691 marks var articles article mark)
8694 (setq marks (pop marked-lists))
8695 (set (setq var (intern (format "gnus-newsgroup-%s"
8696 (car (rassq (setq mark (car marks))
8698 (if (memq (car marks) uncompressed) (cdr marks)
8699 (gnus-uncompress-range (cdr marks))))
8701 (setq articles (symbol-value var))
8703 ;; All articles have to be subsets of the active articles.
8705 ;; Adjust "simple" lists.
8706 ((memq mark '(tick dormant expirable reply killed save))
8708 (when (or (< (setq article (pop articles)) min) (> article max))
8709 (set var (delq article (symbol-value var))))))
8711 ((memq mark '(score bookmark))
8713 (when (or (< (car (setq article (pop articles))) min)
8714 (> (car article) max))
8715 (set var (delq article (symbol-value var))))))))))
8717 (defun gnus-update-missing-marks (missing)
8718 "Go through the list of MISSING articles and remove them mark lists."
8720 (let ((types gnus-article-mark-lists)
8722 ;; Go through all types.
8724 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8725 (when (symbol-value var)
8726 ;; This list has articles. So we delete all missing articles
8730 (set var (delq (pop m) (symbol-value var)))))))))
8732 (defun gnus-update-marks ()
8733 "Enter the various lists of marked articles into the newsgroup info list."
8734 (let ((types gnus-article-mark-lists)
8735 (info (gnus-get-info gnus-newsgroup-name))
8736 (uncompressed '(score bookmark killed))
8737 type list newmarked symbol)
8739 ;; Add all marks lists that are non-nil to the list of marks lists.
8741 (setq type (pop types))
8742 (when (setq list (symbol-value
8744 (intern (format "gnus-newsgroup-%s"
8746 (push (cons (cdr type)
8747 (if (memq (cdr type) uncompressed) list
8748 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8751 ;; Enter these new marks into the info of the group.
8753 (setcar (nthcdr 3 info) newmarked)
8754 ;; Add the marks lists to the end of the info.
8756 (setcdr (nthcdr 2 info) (list newmarked))))
8758 ;; Cut off the end of the info if there's nothing else there.
8762 (when (nthcdr (decf i) info)
8763 (setcdr (nthcdr i info) nil)))))))
8765 (defun gnus-add-marked-articles (group type articles &optional info force)
8766 ;; Add ARTICLES of TYPE to the info of GROUP.
8767 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8768 ;; add, but replace marked articles of TYPE with ARTICLES.
8769 (let ((info (or info (gnus-get-info group)))
8770 (uncompressed '(score bookmark killed))
8773 (and (not (setq marked (nthcdr 3 info)))
8775 (setcdr (nthcdr 2 info)
8776 (list (list (cons type (gnus-compress-sequence
8778 (and (not (setq m (assq type (car marked))))
8781 (cons (cons type (gnus-compress-sequence articles t) )
8785 (setcar (nthcdr 3 info)
8786 (delq (assq type (car marked)) (car marked)))
8787 (setcdr m (gnus-compress-sequence articles t)))
8788 (setcdr m (gnus-compress-sequence
8789 (sort (nconc (gnus-uncompress-range (cdr m))
8790 (copy-sequence articles)) '<) t))))))
8792 (defun gnus-set-mode-line (where)
8793 "This function sets the mode line of the article or summary buffers.
8794 If WHERE is `summary', the summary mode line format will be used."
8795 ;; Is this mode line one we keep updated?
8796 (when (memq where gnus-updated-mode-lines)
8799 ;; We evaluate this in the summary buffer since these
8800 ;; variables are buffer-local to that buffer.
8801 (set-buffer gnus-summary-buffer)
8802 ;; We bind all these variables that are used in the `eval' form
8804 (let* ((mformat (symbol-value
8806 (format "gnus-%s-mode-line-format-spec" where))))
8807 (gnus-tmp-group-name gnus-newsgroup-name)
8808 (gnus-tmp-article-number (or gnus-current-article 0))
8809 (gnus-tmp-unread gnus-newsgroup-unreads)
8810 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8811 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8812 (gnus-tmp-unread-and-unselected
8813 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8814 (zerop gnus-tmp-unselected)) "")
8815 ((zerop gnus-tmp-unselected)
8816 (format "{%d more}" gnus-tmp-unread-and-unticked))
8817 (t (format "{%d(+%d) more}"
8818 gnus-tmp-unread-and-unticked
8819 gnus-tmp-unselected))))
8821 (if (and gnus-current-headers
8822 (vectorp gnus-current-headers))
8823 (mail-header-subject gnus-current-headers) ""))
8825 gnus-tmp-header);; passed as argument to any user-format-funcs
8826 (setq mode-string (eval mformat))
8827 (setq max-len (max 4 (if gnus-mode-non-string-length
8829 gnus-mode-non-string-length)
8830 (length mode-string))))
8831 ;; We might have to chop a bit of the string off...
8832 (when (> (length mode-string) max-len)
8834 (concat (gnus-truncate-string mode-string (- max-len 3))
8836 ;; Pad the mode string a bit.
8837 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8838 ;; Update the mode line.
8839 (setq mode-line-buffer-identification (list mode-string))
8840 (set-buffer-modified-p t))))
8842 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8843 "Go through the HEADERS list and add all Xrefs to a hash table.
8844 The resulting hash table is returned, or nil if no Xrefs were found."
8845 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8846 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8847 (xref-hashtb (make-vector 63 0))
8848 start group entry number xrefs header)
8850 (setq header (pop headers))
8851 (when (and (setq xrefs (mail-header-xref header))
8852 (not (memq (setq number (mail-header-number header))
8855 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8856 (setq start (match-end 0))
8857 (setq group (if prefix
8858 (concat prefix (substring xrefs (match-beginning 1)
8860 (substring xrefs (match-beginning 1) (match-end 1))))
8862 (string-to-int (substring xrefs (match-beginning 2)
8864 (if (setq entry (gnus-gethash group xref-hashtb))
8865 (setcdr entry (cons number (cdr entry)))
8866 (gnus-sethash group (cons number nil) xref-hashtb)))))
8867 (and start xref-hashtb)))
8869 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8870 "Look through all the headers and mark the Xrefs as read."
8871 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8872 name entry info xref-hashtb idlist method nth4)
8874 (set-buffer gnus-group-buffer)
8875 (when (setq xref-hashtb
8876 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8879 (unless (string= from-newsgroup (setq name (symbol-name group)))
8880 (setq idlist (symbol-value group))
8881 ;; Dead groups are not updated.
8883 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8885 (if (stringp (setq nth4 (gnus-info-method info)))
8886 (setq nth4 (gnus-server-to-method nth4))))
8887 ;; Only do the xrefs if the group has the same
8888 ;; select method as the group we have just read.
8889 (or (gnus-methods-equal-p
8890 nth4 (gnus-find-method-for-group from-newsgroup))
8892 (equal nth4 (setq method (gnus-find-method-for-group
8894 (and (equal (car nth4) (car method))
8895 (equal (nth 1 nth4) (nth 1 method))))
8896 gnus-use-cross-reference
8897 (or (not (eq gnus-use-cross-reference t))
8899 ;; Only do cross-references on subscribed
8900 ;; groups, if that is what is wanted.
8901 (<= (gnus-info-level info) gnus-level-subscribed))
8902 (gnus-group-make-articles-read name idlist))))
8905 (defun gnus-group-make-articles-read (group articles)
8907 (entry (gnus-gethash group gnus-newsrc-hashtb))
8908 (info (nth 2 entry))
8909 (active (gnus-active group))
8911 ;; First peel off all illegal article numbers.
8913 (let ((ids articles)
8917 (if (and first (> id (cdr active)))
8919 ;; We'll end up in this situation in one particular
8920 ;; obscure situation. If you re-scan a group and get
8921 ;; a new article that is cross-posted to a different
8922 ;; group that has not been re-scanned, you might get
8923 ;; crossposted article that has a higher number than
8924 ;; Gnus believes possible. So we re-activate this
8925 ;; group as well. This might mean doing the
8926 ;; crossposting thingy will *increase* the number
8927 ;; of articles in some groups. Tsk, tsk.
8928 (setq active (or (gnus-activate-group group) active))))
8929 (if (or (> id (cdr active))
8930 (< id (car active)))
8931 (setq articles (delq id articles)))
8932 (setq ids (cdr ids)))))
8933 ;; If the read list is nil, we init it.
8935 (null (gnus-info-read info))
8937 (gnus-info-set-read info (cons 1 (1- (car active)))))
8938 ;; Then we add the read articles to the range.
8943 (gnus-info-read info) (setq articles (sort articles '<)))))
8944 ;; Then we have to re-compute how many unread
8945 ;; articles there are in this group.
8950 (setq num (- (1+ (cdr active)) (car active))))
8951 ((not (listp (cdr range)))
8952 (setq num (- (cdr active) (- (1+ (cdr range))
8956 (if (numberp (car range))
8958 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8959 (setq range (cdr range)))
8960 (setq num (- (cdr active) num))))
8961 ;; Update the number of unread articles.
8963 ;; Update the group buffer.
8964 (gnus-group-update-group group t)))))
8966 (defun gnus-methods-equal-p (m1 m2)
8967 (let ((m1 (or m1 gnus-select-method))
8968 (m2 (or m2 gnus-select-method)))
8970 (and (eq (car m1) (car m2))
8971 (or (not (memq 'address (assoc (symbol-name (car m1))
8972 gnus-valid-select-methods)))
8973 (equal (nth 1 m1) (nth 1 m2)))))))
8975 (defsubst gnus-header-value ()
8976 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8978 (defvar gnus-newsgroup-none-id 0)
8980 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8981 (let ((cur nntp-server-buffer)
8984 (save-excursion (set-buffer gnus-summary-buffer)
8985 gnus-newsgroup-dependencies)))
8986 headers id id-dep ref-dep end ref)
8988 (set-buffer nntp-server-buffer)
8989 (let ((case-fold-search t)
8990 in-reply-to header p lines)
8991 (goto-char (point-min))
8992 ;; Search to the beginning of the next header. Error messages
8993 ;; do not begin with 2 or 3.
8994 (while (re-search-forward "^[23][0-9]+ " nil t)
8997 ;; This implementation of this function, with nine
8998 ;; search-forwards instead of the one re-search-forward and
8999 ;; a case (which basically was the old function) is actually
9000 ;; about twice as fast, even though it looks messier. You
9001 ;; can't have everything, I guess. Speed and elegance
9002 ;; doesn't always go hand in hand.
9011 (narrow-to-region (point)
9012 (or (and (search-forward "\n.\n" nil t)
9018 (if (search-forward "\nsubject: " nil t)
9019 (gnus-header-value) "(none)"))
9023 (if (search-forward "\nfrom: " nil t)
9024 (gnus-header-value) "(nobody)"))
9028 (if (search-forward "\ndate: " nil t)
9029 (gnus-header-value) ""))
9033 (if (search-forward "\nmessage-id: " nil t)
9034 (setq id (gnus-header-value))
9035 ;; If there was no message-id, we just fake one to make
9036 ;; subsequent routines simpler.
9037 (setq id (concat "none+"
9039 (setq gnus-newsgroup-none-id
9040 (1+ gnus-newsgroup-none-id)))))))
9044 (if (search-forward "\nreferences: " nil t)
9047 (setq end (match-end 0))
9053 (search-backward ">" end t)
9056 (search-backward "<" end t)
9058 ;; Get the references from the in-reply-to header if there
9059 ;; were no references and the in-reply-to header looks
9061 (if (and (search-forward "\nin-reply-to: " nil t)
9062 (setq in-reply-to (gnus-header-value))
9063 (string-match "<[^>]+>" in-reply-to))
9064 (setq ref (substring in-reply-to (match-beginning 0)
9072 (if (search-forward "\nlines: " nil t)
9073 (if (numberp (setq lines (read cur)))
9079 (and (search-forward "\nxref: " nil t)
9080 (gnus-header-value)))))
9081 ;; We do the threading while we read the headers. The
9082 ;; message-id and the last reference are both entered into
9083 ;; the same hash table. Some tippy-toeing around has to be
9084 ;; done in case an article has arrived before the article
9085 ;; which it refers to.
9086 (if (boundp (setq id-dep (intern id dependencies)))
9087 (if (and (car (symbol-value id-dep))
9089 ;; An article with this Message-ID has already
9090 ;; been seen, so we ignore this one, except we add
9091 ;; any additional Xrefs (in case the two articles
9092 ;; came from different servers).
9094 (mail-header-set-xref
9095 (car (symbol-value id-dep))
9096 (concat (or (mail-header-xref
9097 (car (symbol-value id-dep))) "")
9098 (or (mail-header-xref header) "")))
9100 (setcar (symbol-value id-dep) header))
9101 (set id-dep (list header)))
9103 (if (boundp (setq ref-dep (intern ref dependencies)))
9104 (setcdr (symbol-value ref-dep)
9105 (nconc (cdr (symbol-value ref-dep))
9106 (list (symbol-value id-dep))))
9107 (set ref-dep (list nil (symbol-value id-dep))))
9108 (setq headers (cons header headers)))
9109 (goto-char (point-max))
9111 (nreverse headers)))))
9113 ;; The following macros and functions were written by Felix Lee
9114 ;; <flee@cse.psu.edu>.
9116 (defmacro gnus-nov-read-integer ()
9118 (if (= (following-char) ?\t)
9120 (let ((num (condition-case nil (read buffer) (error nil))))
9121 (if (numberp num) num 0)))
9122 (or (eobp) (forward-char 1))))
9124 (defmacro gnus-nov-skip-field ()
9125 '(search-forward "\t" eol 'move))
9127 (defmacro gnus-nov-field ()
9128 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9130 ;; Goes through the xover lines and returns a list of vectors
9131 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9132 force-new dependencies)
9133 "Parse the news overview data in the server buffer, and return a
9134 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9135 ;; Get the Xref when the users reads the articles since most/some
9136 ;; NNTP servers do not include Xrefs when using XOVER.
9137 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9138 (let ((cur nntp-server-buffer)
9139 (dependencies (or dependencies gnus-newsgroup-dependencies))
9140 number headers header)
9142 (set-buffer nntp-server-buffer)
9143 ;; Allow the user to mangle the headers before parsing them.
9144 (run-hooks 'gnus-parse-headers-hook)
9145 ;; Allow the user to mangle the headers before parsing them.
9146 (run-hooks 'gnus-parse-headers-hook)
9147 (goto-char (point-min))
9148 (while (and sequence (not (eobp)))
9149 (setq number (read cur))
9150 (while (and sequence (< (car sequence) number))
9151 (setq sequence (cdr sequence)))
9153 (eq number (car sequence))
9155 (setq sequence (cdr sequence))
9157 (inline (gnus-nov-parse-line
9158 number dependencies force-new)))
9159 (setq headers (cons header headers)))))
9161 (setq headers (nreverse headers)))
9164 ;; This function has to be called with point after the article number
9165 ;; on the beginning of the line.
9166 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9168 (eol (gnus-point-at-eol))
9169 (buffer (current-buffer))
9170 header ref id id-dep ref-dep)
9172 ;; overview: [num subject from date id refs chars lines misc]
9173 (narrow-to-region (point) eol)
9174 (or (eobp) (forward-char))
9180 (gnus-nov-field) ; subject
9181 (gnus-nov-field) ; from
9182 (gnus-nov-field) ; date
9183 (setq id (or (gnus-nov-field)
9186 (setq none (1+ none)))))) ; id
9189 (let ((beg (point)))
9190 (search-forward "\t" eol)
9191 (if (search-backward ">" beg t)
9195 (search-backward "<" beg t)))
9197 (gnus-nov-field)) ; refs
9198 (gnus-nov-read-integer) ; chars
9199 (gnus-nov-read-integer) ; lines
9200 (if (= (following-char) ?\n)
9202 (gnus-nov-field)) ; misc
9206 (gnus-message 4 "Strange nov line")
9212 ;; We build the thread tree.
9214 (if (boundp (setq id-dep (intern id dependencies)))
9215 (if (and (car (symbol-value id-dep))
9217 ;; An article with this Message-ID has already been seen,
9218 ;; so we ignore this one, except we add any additional
9219 ;; Xrefs (in case the two articles came from different
9222 (mail-header-set-xref
9223 (car (symbol-value id-dep))
9224 (concat (or (mail-header-xref
9225 (car (symbol-value id-dep))) "")
9226 (or (mail-header-xref header) "")))
9228 (setcar (symbol-value id-dep) header))
9229 (set id-dep (list header))))
9232 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9233 (setcdr (symbol-value ref-dep)
9234 (nconc (cdr (symbol-value ref-dep))
9235 (list (symbol-value id-dep))))
9236 (set ref-dep (list nil (symbol-value id-dep))))))
9239 (defun gnus-article-get-xrefs ()
9240 "Fill in the Xref value in `gnus-current-headers', if necessary.
9241 This is meant to be called in `gnus-article-internal-prepare-hook'."
9242 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9243 gnus-current-headers)))
9244 (or (not gnus-use-cross-reference)
9246 (and (mail-header-xref headers)
9247 (not (string= (mail-header-xref headers) "")))
9248 (let ((case-fold-search t)
9251 (nnheader-narrow-to-headers)
9252 (goto-char (point-min))
9253 (if (or (and (eq (downcase (following-char)) ?x)
9254 (looking-at "Xref:"))
9255 (search-forward "\nXref:" nil t))
9257 (goto-char (1+ (match-end 0)))
9258 (setq xref (buffer-substring (point)
9259 (progn (end-of-line) (point))))
9260 (mail-header-set-xref headers xref))))))))
9262 (defun gnus-summary-insert-subject (id &optional old-header)
9263 "Find article ID and insert the summary line for that article."
9264 (let ((header (gnus-read-header id))
9265 (number (and (numberp id) id))
9268 ;; Rebuild the thread that this article is part of and go to the
9269 ;; article we have fetched.
9271 (when (setq pos (text-property-any
9272 (point-min) (point-max) 'gnus-number
9273 (mail-header-number old-header)))
9276 (gnus-data-remove (mail-header-number old-header))))
9277 (gnus-rebuild-thread (mail-header-id header))
9278 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9279 (when (and (numberp number)
9281 ;; We have to update the boundaries even if we can't fetch the
9282 ;; article if ID is a number -- so that the next `P' or `N'
9283 ;; command will fetch the previous (or next) article even
9284 ;; if the one we tried to fetch this time has been canceled.
9285 (and (> number gnus-newsgroup-end)
9286 (setq gnus-newsgroup-end number))
9287 (and (< number gnus-newsgroup-begin)
9288 (setq gnus-newsgroup-begin number))
9289 (setq gnus-newsgroup-unselected
9290 (delq number gnus-newsgroup-unselected)))
9291 ;; Report back a success?
9292 (and header (mail-header-number header))))
9294 (defun gnus-summary-work-articles (n)
9295 "Return a list of articles to be worked upon. The prefix argument,
9296 the list of process marked articles, and the current article will be
9297 taken into consideration."
9299 ((and n (numberp n))
9300 ;; A numerical prefix has been given.
9301 (let ((backward (< n 0))
9307 (push (setq article (gnus-summary-article-number))
9310 (gnus-summary-find-prev nil article)
9311 (gnus-summary-find-next nil article)))
9313 (nreverse articles)))
9314 ((and (boundp 'transient-mark-mode)
9317 ;; Work on the region between point and mark.
9318 (let ((max (max (point) (mark)))
9321 (goto-char (min (point) (mark)))
9324 (push (setq article (gnus-summary-article-number)) articles)
9325 (gnus-summary-find-next nil article)
9327 (nreverse articles))))
9328 (gnus-newsgroup-processable
9329 ;; There are process-marked articles present.
9330 (reverse gnus-newsgroup-processable))
9332 ;; Just return the current article.
9333 (list (gnus-summary-article-number)))))
9335 (defun gnus-summary-search-group (&optional backward use-level)
9336 "Search for next unread newsgroup.
9337 If optional argument BACKWARD is non-nil, search backward instead."
9339 (set-buffer gnus-group-buffer)
9340 (if (gnus-group-search-forward
9341 backward nil (if use-level (gnus-group-group-level) nil))
9342 (gnus-group-group-name))))
9344 (defun gnus-summary-best-group (&optional exclude-group)
9345 "Find the name of the best unread group.
9346 If EXCLUDE-GROUP, do not go to this group."
9348 (set-buffer gnus-group-buffer)
9350 (gnus-group-best-unread-group exclude-group))))
9352 (defun gnus-summary-find-next (&optional unread article backward)
9353 (if backward (gnus-summary-find-prev)
9354 (let* ((article (or article (gnus-summary-article-number)))
9355 (arts (gnus-data-find-list article))
9357 (when (or (not gnus-summary-check-current)
9359 (not (gnus-data-unread-p (car arts))))
9360 (setq arts (cdr arts)))
9365 (when (gnus-data-unread-p (car arts))
9366 (setq result (car arts)
9368 (setq arts (cdr arts)))
9371 (goto-char (gnus-data-pos result))
9372 (gnus-data-number result)))))
9374 (defun gnus-summary-find-prev (&optional unread article)
9375 (let* ((article (or article (gnus-summary-article-number)))
9376 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9378 (when (or (not gnus-summary-check-current)
9380 (not (gnus-data-unread-p (car arts))))
9381 (setq arts (cdr arts)))
9386 (and (gnus-data-unread-p (car arts))
9387 (setq result (car arts)
9389 (setq arts (cdr arts)))
9393 (goto-char (gnus-data-pos result))
9394 (gnus-data-number result)))))
9396 (defun gnus-summary-find-subject (subject &optional unread backward article)
9397 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9398 (article (or article (gnus-summary-article-number)))
9399 (articles (gnus-data-list backward))
9400 (arts (gnus-data-find-list article articles))
9402 (when (or (not gnus-summary-check-current)
9404 (not (gnus-data-unread-p (car arts))))
9405 (setq arts (cdr arts)))
9407 (and (or (not unread)
9408 (gnus-data-unread-p (car arts)))
9409 (vectorp (gnus-data-header (car arts)))
9411 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9412 (setq result (car arts)
9414 (setq arts (cdr arts)))
9416 (goto-char (gnus-data-pos result))
9417 (gnus-data-number result))))
9419 (defun gnus-summary-search-forward (&optional unread subject backward)
9420 "Search forward for an article.
9421 If UNREAD, look for unread articles. If SUBJECT, look for
9422 articles with that subject. If BACKWARD, search backward instead."
9423 (cond (subject (gnus-summary-find-subject subject unread backward))
9424 (backward (gnus-summary-find-prev unread))
9425 (t (gnus-summary-find-next unread))))
9427 (defun gnus-recenter (&optional n)
9428 "Center point in window and redisplay frame.
9429 Also do horizontal recentering."
9431 (when (and gnus-auto-center-summary
9432 (not (eq gnus-auto-center-summary 'vertical)))
9433 (gnus-horizontal-recenter))
9436 (defun gnus-summary-recenter ()
9437 "Center point in the summary window.
9438 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9439 displayed, no centering will be performed."
9440 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9441 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9442 (let* ((top (cond ((< (window-height) 4) 0)
9443 ((< (window-height) 7) 1)
9445 (height (1- (window-height)))
9446 (bottom (save-excursion (goto-char (point-max))
9447 (forward-line (- height))
9449 (window (get-buffer-window (current-buffer))))
9450 ;; The user has to want it.
9451 (when gnus-auto-center-summary
9452 (when (get-buffer-window gnus-article-buffer)
9453 ;; Only do recentering when the article buffer is displayed,
9454 ;; Set the window start to either `bottom', which is the biggest
9455 ;; possible valid number, or the second line from the top,
9456 ;; whichever is the least.
9458 window (min bottom (save-excursion
9459 (forward-line (- top)) (point)))))
9460 ;; Do horizontal recentering while we're at it.
9461 (when (and (get-buffer-window (current-buffer) t)
9462 (not (eq gnus-auto-center-summary 'vertical)))
9463 (let ((selected (selected-window)))
9464 (select-window (get-buffer-window (current-buffer) t))
9465 (gnus-summary-position-point)
9466 (gnus-horizontal-recenter)
9467 (select-window selected))))))
9469 (defun gnus-horizontal-recenter ()
9470 "Recenter the current buffer horizontally."
9471 (if (< (current-column) (/ (window-width) 2))
9472 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9473 (let* ((orig (point))
9474 (end (window-end (get-buffer-window (current-buffer) t)))
9476 ;; Find the longest line currently displayed in the window.
9477 (goto-char (window-start))
9478 (while (and (not (eobp))
9481 (setq max (max max (current-column)))
9484 ;; Scroll horizontally to center (sort of) the point.
9485 (if (> max (window-width))
9487 (get-buffer-window (current-buffer) t)
9488 (min (- (current-column) (/ (window-width) 3))
9489 (+ 2 (- max (window-width)))))
9490 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9493 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9494 (defun gnus-short-group-name (group &optional levels)
9495 "Collapse GROUP name LEVELS."
9502 (while (string-match "\\." group skip)
9503 (setq skip (match-end 0)
9506 (if (string-match ":" group)
9507 (setq foreign (substring group 0 (match-end 0))
9508 group (substring group (match-end 0))))
9510 (if (and (string-match "\\." group)
9511 (> levels (- gnus-group-uncollapsed-levels 1)))
9512 (setq name (concat name (substring group 0 1))
9513 group (substring group (match-end 0))
9515 name (concat name "."))
9516 (setq name (concat foreign name group)
9520 (defun gnus-summary-jump-to-group (newsgroup)
9521 "Move point to NEWSGROUP in group mode buffer."
9522 ;; Keep update point of group mode buffer if visible.
9523 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9524 (save-window-excursion
9525 ;; Take care of tree window mode.
9526 (if (get-buffer-window gnus-group-buffer)
9527 (pop-to-buffer gnus-group-buffer))
9528 (gnus-group-jump-to-group newsgroup))
9530 ;; Take care of tree window mode.
9531 (if (get-buffer-window gnus-group-buffer)
9532 (pop-to-buffer gnus-group-buffer)
9533 (set-buffer gnus-group-buffer))
9534 (gnus-group-jump-to-group newsgroup))))
9536 ;; This function returns a list of article numbers based on the
9537 ;; difference between the ranges of read articles in this group and
9538 ;; the range of active articles.
9539 (defun gnus-list-of-unread-articles (group)
9540 (let* ((read (gnus-info-read (gnus-get-info group)))
9541 (active (gnus-active group))
9544 ;; If none are read, then all are unread.
9546 (setq first (car active))
9547 ;; If the range of read articles is a single range, then the
9548 ;; first unread article is the article after the last read
9549 ;; article. Sounds logical, doesn't it?
9550 (if (not (listp (cdr read)))
9551 (setq first (1+ (cdr read)))
9552 ;; `read' is a list of ranges.
9553 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9558 (while (< first nlast)
9559 (setq unread (cons first unread))
9560 (setq first (1+ first))))
9561 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9562 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9563 (setq read (cdr read)))))
9564 ;; And add the last unread articles.
9565 (while (<= first last)
9566 (setq unread (cons first unread))
9567 (setq first (1+ first)))
9568 ;; Return the list of unread articles.
9571 (defun gnus-list-of-read-articles (group)
9572 "Return a list of unread, unticked and non-dormant articles."
9573 (let* ((info (gnus-get-info group))
9574 (marked (gnus-info-marks info))
9575 (active (gnus-active group)))
9577 (gnus-set-difference
9578 (gnus-sorted-complement
9579 (gnus-uncompress-range active)
9580 (gnus-list-of-unread-articles group))
9582 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9583 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9585 ;; Various summary commands
9587 (defun gnus-summary-universal-argument (arg)
9588 "Perform any operation on all articles that are process/prefixed."
9590 (gnus-set-global-variables)
9591 (let ((articles (gnus-summary-work-articles arg))
9598 (substitute-command-keys
9599 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9603 (message "Undefined key")
9607 (gnus-summary-goto-subject (setq article (pop articles)))
9608 (command-execute func)
9609 (gnus-summary-remove-process-mark article)))))
9610 (gnus-summary-position-point))
9612 (defun gnus-summary-toggle-truncation (&optional arg)
9613 "Toggle truncation of summary lines.
9614 With arg, turn line truncation on iff arg is positive."
9616 (setq truncate-lines
9617 (if (null arg) (not truncate-lines)
9618 (> (prefix-numeric-value arg) 0)))
9621 (defun gnus-summary-reselect-current-group (&optional all rescan)
9622 "Exit and then reselect the current newsgroup.
9623 The prefix argument ALL means to select all articles."
9625 (gnus-set-global-variables)
9626 (let ((current-subject (gnus-summary-article-number))
9627 (group gnus-newsgroup-name))
9628 (setq gnus-newsgroup-begin nil)
9630 ;; We have to adjust the point of group mode buffer because the
9631 ;; current point was moved to the next unread newsgroup by
9633 (gnus-summary-jump-to-group group)
9636 (gnus-group-get-new-news-this-group 1)))
9637 (gnus-group-read-group all t)
9638 (gnus-summary-goto-subject current-subject)))
9640 (defun gnus-summary-rescan-group (&optional all)
9641 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9643 (gnus-summary-reselect-current-group all t))
9645 (defun gnus-summary-update-info ()
9646 (let* ((group gnus-newsgroup-name))
9647 (when gnus-newsgroup-kill-headers
9648 (setq gnus-newsgroup-killed
9649 (gnus-compress-sequence
9651 (gnus-set-sorted-intersection
9652 (gnus-uncompress-range gnus-newsgroup-killed)
9653 (setq gnus-newsgroup-unselected
9654 (sort gnus-newsgroup-unselected '<)))
9655 (setq gnus-newsgroup-unreads
9656 (sort gnus-newsgroup-unreads '<))) t)))
9657 (unless (listp (cdr gnus-newsgroup-killed))
9658 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9659 (let ((headers gnus-newsgroup-headers))
9660 (run-hooks 'gnus-exit-group-hook)
9661 (unless gnus-save-score
9662 (setq gnus-newsgroup-scored nil))
9663 ;; Set the new ranges of read articles.
9664 (gnus-update-read-articles
9665 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9666 ;; Set the current article marks.
9668 ;; Do the cross-ref thing.
9669 (when gnus-use-cross-reference
9670 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9671 ;; Do adaptive scoring, and possibly save score files.
9672 (when gnus-newsgroup-adaptive
9673 (gnus-score-adaptive))
9674 (when gnus-use-scoring
9676 ;; Do not switch windows but change the buffer to work.
9677 (set-buffer gnus-group-buffer)
9678 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9679 (gnus-group-update-group group)))))
9681 (defun gnus-summary-exit (&optional temporary)
9682 "Exit reading current newsgroup, and then return to group selection mode.
9683 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9685 (gnus-set-global-variables)
9686 (gnus-kill-save-kill-buffer)
9687 (let* ((group gnus-newsgroup-name)
9688 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9690 (buf (current-buffer)))
9692 (run-hooks 'gnus-summary-prepare-exit-hook))
9693 ;; If we have several article buffers, we kill them at exit.
9694 (unless gnus-single-article-buffer
9695 (gnus-kill-buffer gnus-article-buffer)
9696 (gnus-kill-buffer gnus-original-article-buffer)
9697 (setq gnus-article-current nil))
9698 (when gnus-use-cache
9699 (gnus-cache-possibly-remove-articles)
9700 (gnus-cache-save-buffers))
9701 (when gnus-use-trees
9702 (gnus-tree-close group))
9703 ;; Make all changes in this group permanent.
9705 (gnus-summary-update-info))
9706 (gnus-close-group group)
9707 ;; Make sure where I was, and go to next newsgroup.
9708 (set-buffer gnus-group-buffer)
9710 (gnus-group-jump-to-group group)
9711 (gnus-group-next-unread-group 1))
9712 (run-hooks 'gnus-summary-exit-hook)
9713 (unless gnus-single-article-buffer
9714 (setq gnus-article-current nil))
9717 ;; If we have several article buffers, we kill them at exit.
9718 (unless gnus-single-article-buffer
9719 (gnus-kill-buffer gnus-article-buffer)
9720 (gnus-kill-buffer gnus-original-article-buffer)
9721 (setq gnus-article-current nil))
9723 (if (not gnus-kill-summary-on-exit)
9724 (gnus-deaden-summary)
9725 ;; We set all buffer-local variables to nil. It is unclear why
9726 ;; this is needed, but if we don't, buffer-local variables are
9727 ;; not garbage-collected, it seems. This would the lead to en
9728 ;; ever-growing Emacs.
9729 (gnus-summary-clear-local-variables)
9730 (when (get-buffer gnus-article-buffer)
9731 (bury-buffer gnus-article-buffer))
9732 ;; We clear the global counterparts of the buffer-local
9733 ;; variables as well, just to be on the safe side.
9734 (gnus-configure-windows 'group 'force)
9735 (gnus-summary-clear-local-variables)
9736 ;; Return to group mode buffer.
9737 (if (eq mode 'gnus-summary-mode)
9738 (gnus-kill-buffer buf)))
9739 (setq gnus-current-select-method gnus-select-method)
9740 (pop-to-buffer gnus-group-buffer)
9741 ;; Clear the current group name.
9742 (if (not quit-config)
9744 (gnus-group-jump-to-group group)
9745 (gnus-group-next-unread-group 1)
9746 (gnus-configure-windows 'group 'force))
9747 (if (not (buffer-name (car quit-config)))
9748 (gnus-configure-windows 'group 'force)
9749 (set-buffer (car quit-config))
9750 (and (eq major-mode 'gnus-summary-mode)
9751 (gnus-set-global-variables))
9752 (gnus-configure-windows (cdr quit-config))))
9754 (setq gnus-newsgroup-name nil)))))
9756 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9757 (defun gnus-summary-exit-no-update (&optional no-questions)
9758 "Quit reading current newsgroup without updating read article info."
9760 (gnus-set-global-variables)
9761 (let* ((group gnus-newsgroup-name)
9762 (quit-config (gnus-group-quit-config group)))
9763 (when (or no-questions
9765 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9766 ;; If we have several article buffers, we kill them at exit.
9767 (unless gnus-single-article-buffer
9768 (gnus-kill-buffer gnus-article-buffer)
9769 (gnus-kill-buffer gnus-original-article-buffer)
9770 (setq gnus-article-current nil))
9771 (if (not gnus-kill-summary-on-exit)
9772 (gnus-deaden-summary)
9773 (gnus-close-group group)
9774 (gnus-summary-clear-local-variables)
9775 (set-buffer gnus-group-buffer)
9776 (gnus-summary-clear-local-variables)
9777 (when (get-buffer gnus-summary-buffer)
9778 (kill-buffer gnus-summary-buffer)))
9779 (unless gnus-single-article-buffer
9780 (setq gnus-article-current nil))
9781 (when gnus-use-trees
9782 (gnus-tree-close group))
9783 (when (get-buffer gnus-article-buffer)
9784 (bury-buffer gnus-article-buffer))
9785 ;; Return to the group buffer.
9786 (gnus-configure-windows 'group 'force)
9787 ;; Clear the current group name.
9788 (setq gnus-newsgroup-name nil)
9789 (when (equal (gnus-group-group-name) group)
9790 (gnus-group-next-unread-group 1))
9792 (if (not (buffer-name (car quit-config)))
9793 (gnus-configure-windows 'group 'force)
9794 (set-buffer (car quit-config))
9795 (when (eq major-mode 'gnus-summary-mode)
9796 (gnus-set-global-variables))
9797 (gnus-configure-windows (cdr quit-config)))))))
9801 (defvar gnus-dead-summary-mode-map nil)
9803 (if gnus-dead-summary-mode-map
9805 (setq gnus-dead-summary-mode-map (make-keymap))
9806 (suppress-keymap gnus-dead-summary-mode-map)
9807 (substitute-key-definition
9808 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9809 (let ((keys '("\C-d" "\r" "\177")))
9811 (define-key gnus-dead-summary-mode-map
9812 (pop keys) 'gnus-summary-wake-up-the-dead))))
9814 (defvar gnus-dead-summary-mode nil
9815 "Minor mode for Gnus summary buffers.")
9817 (defun gnus-dead-summary-mode (&optional arg)
9818 "Minor mode for Gnus summary buffers."
9820 (when (eq major-mode 'gnus-summary-mode)
9821 (make-local-variable 'gnus-dead-summary-mode)
9822 (setq gnus-dead-summary-mode
9823 (if (null arg) (not gnus-dead-summary-mode)
9824 (> (prefix-numeric-value arg) 0)))
9825 (when gnus-dead-summary-mode
9826 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9827 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9828 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9829 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9830 minor-mode-map-alist)))))
9832 (defun gnus-deaden-summary ()
9833 "Make the current summary buffer into a dead summary buffer."
9834 ;; Kill any previous dead summary buffer.
9835 (when (and gnus-dead-summary
9836 (buffer-name gnus-dead-summary))
9838 (set-buffer gnus-dead-summary)
9839 (when gnus-dead-summary-mode
9840 (kill-buffer (current-buffer)))))
9841 ;; Make this the current dead summary.
9842 (setq gnus-dead-summary (current-buffer))
9843 (gnus-dead-summary-mode 1)
9844 (let ((name (buffer-name)))
9845 (when (string-match "Summary" name)
9847 (concat (substring name 0 (match-beginning 0)) "Dead "
9848 (substring name (match-beginning 0))) t))))
9850 (defun gnus-kill-or-deaden-summary (buffer)
9851 "Kill or deaden the summary BUFFER."
9852 (cond (gnus-kill-summary-on-exit
9853 (when (and gnus-use-trees
9854 (and (get-buffer buffer)
9855 (buffer-name (get-buffer buffer))))
9857 (set-buffer (get-buffer buffer))
9858 (gnus-tree-close gnus-newsgroup-name)))
9859 (gnus-kill-buffer buffer))
9860 ((and (get-buffer buffer)
9861 (buffer-name (get-buffer buffer)))
9864 (gnus-deaden-summary)))))
9866 (defun gnus-summary-wake-up-the-dead (&rest args)
9867 "Wake up the dead summary buffer."
9869 (gnus-dead-summary-mode -1)
9870 (let ((name (buffer-name)))
9871 (when (string-match "Dead " name)
9873 (concat (substring name 0 (match-beginning 0))
9874 (substring name (match-end 0))) t)))
9875 (gnus-message 3 "This dead summary is now alive again"))
9877 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9878 (defun gnus-summary-fetch-faq (&optional faq-dir)
9879 "Fetch the FAQ for the current group.
9880 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9884 (if current-prefix-arg
9886 "Faq dir: " (and (listp gnus-group-faq-directory)
9887 gnus-group-faq-directory)))))
9888 (let (gnus-faq-buffer)
9889 (and (setq gnus-faq-buffer
9890 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9891 (gnus-configure-windows 'summary-faq))))
9893 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9894 (defun gnus-summary-describe-group (&optional force)
9895 "Describe the current newsgroup."
9897 (gnus-group-describe-group force gnus-newsgroup-name))
9899 (defun gnus-summary-describe-briefly ()
9900 "Describe summary mode commands briefly."
9903 (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")))
9905 ;; Walking around group mode buffer from summary mode.
9907 (defun gnus-summary-next-group (&optional no-article target-group backward)
9908 "Exit current newsgroup and then select next unread newsgroup.
9909 If prefix argument NO-ARTICLE is non-nil, no article is selected
9910 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9911 previous group instead."
9913 (gnus-set-global-variables)
9914 (let ((current-group gnus-newsgroup-name)
9915 (current-buffer (current-buffer))
9917 ;; First we semi-exit this group to update Xrefs and all variables.
9918 ;; We can't do a real exit, because the window conf must remain
9919 ;; the same in case the user is prompted for info, and we don't
9920 ;; want the window conf to change before that...
9921 (gnus-summary-exit t)
9922 (while (not entered)
9923 ;; Then we find what group we are supposed to enter.
9924 (set-buffer gnus-group-buffer)
9925 (gnus-group-jump-to-group current-group)
9928 (if (eq gnus-keep-same-level 'best)
9929 (gnus-summary-best-group gnus-newsgroup-name)
9930 (gnus-summary-search-group backward gnus-keep-same-level))))
9931 (if (not target-group)
9932 ;; There are no further groups, so we return to the group
9935 (gnus-message 5 "Returning to the group buffer")
9937 (set-buffer current-buffer)
9938 (gnus-summary-exit))
9939 ;; We try to enter the target group.
9940 (gnus-group-jump-to-group target-group)
9941 (let ((unreads (gnus-group-group-unread)))
9942 (if (and (or (eq t unreads)
9943 (and unreads (not (zerop unreads))))
9944 (gnus-summary-read-group
9945 target-group nil no-article current-buffer))
9947 (setq current-group target-group
9948 target-group nil)))))))
9950 (defun gnus-summary-prev-group (&optional no-article)
9951 "Exit current newsgroup and then select previous unread newsgroup.
9952 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9954 (gnus-summary-next-group no-article nil t))
9956 ;; Walking around summary lines.
9958 (defun gnus-summary-first-subject (&optional unread)
9959 "Go to the first unread subject.
9960 If UNREAD is non-nil, go to the first unread article.
9961 Returns the article selected or nil if there are no unread articles."
9966 ((null gnus-newsgroup-data)
9967 (gnus-message 3 "No articles in the group")
9969 ;; Pick the first article.
9971 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9972 (gnus-data-number (car gnus-newsgroup-data)))
9973 ;; No unread articles.
9974 ((null gnus-newsgroup-unreads)
9975 (gnus-message 3 "No more unread articles")
9977 ;; Find the first unread article.
9979 (let ((data gnus-newsgroup-data))
9981 (not (gnus-data-unread-p (car data))))
9982 (setq data (cdr data)))
9985 (goto-char (gnus-data-pos (car data)))
9986 (gnus-data-number (car data)))))))
9987 (gnus-summary-position-point)))
9989 (defun gnus-summary-next-subject (n &optional unread dont-display)
9990 "Go to next N'th summary line.
9991 If N is negative, go to the previous N'th subject line.
9992 If UNREAD is non-nil, only unread articles are selected.
9993 The difference between N and the actual number of steps taken is
9996 (let ((backward (< n 0))
10000 (gnus-summary-find-prev unread)
10001 (gnus-summary-find-next unread)))
10003 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10004 (if unread " unread" "")))
10005 (unless dont-display
10006 (gnus-summary-recenter)
10007 (gnus-summary-position-point))
10010 (defun gnus-summary-next-unread-subject (n)
10011 "Go to next N'th unread summary line."
10013 (gnus-summary-next-subject n t))
10015 (defun gnus-summary-prev-subject (n &optional unread)
10016 "Go to previous N'th summary line.
10017 If optional argument UNREAD is non-nil, only unread article is selected."
10019 (gnus-summary-next-subject (- n) unread))
10021 (defun gnus-summary-prev-unread-subject (n)
10022 "Go to previous N'th unread summary line."
10024 (gnus-summary-next-subject (- n) t))
10026 (defun gnus-summary-goto-subject (article &optional force silent)
10027 "Go the subject line of ARTICLE.
10028 If FORCE, also allow jumping to articles not currently shown."
10030 (data (gnus-data-find article)))
10031 ;; We read in the article if we have to.
10034 (gnus-summary-insert-subject article)
10035 (setq data (gnus-data-find article)))
10040 (gnus-message 3 "Can't find article %d" article))
10042 (goto-char (gnus-data-pos data))
10045 ;; Walking around summary lines with displaying articles.
10047 (defun gnus-summary-expand-window (&optional arg)
10048 "Make the summary buffer take up the entire Emacs frame.
10049 Given a prefix, will force an `article' buffer configuration."
10051 (gnus-set-global-variables)
10053 (gnus-configure-windows 'article 'force)
10054 (gnus-configure-windows 'summary 'force)))
10056 (defun gnus-summary-display-article (article &optional all-header)
10057 "Display ARTICLE in article buffer."
10058 (gnus-set-global-variables)
10062 (if gnus-summary-display-article-function
10063 (funcall gnus-summary-display-article-function article all-header)
10064 (gnus-article-prepare article all-header))
10065 (run-hooks 'gnus-select-article-hook)
10066 (gnus-summary-recenter)
10067 (gnus-summary-goto-subject article)
10068 (when gnus-use-trees
10069 (gnus-possibly-generate-tree article)
10070 (gnus-highlight-selected-tree article))
10071 ;; Successfully display article.
10072 (gnus-article-set-window-start
10073 (cdr (assq article gnus-newsgroup-bookmarks)))
10076 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10077 "Select the current article.
10078 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10079 non-nil, the article will be re-fetched even if it already present in
10080 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10082 (let ((article (or article (gnus-summary-article-number)))
10083 (all-headers (not (not all-headers))) ;Must be T or NIL.
10084 gnus-summary-display-article-function
10087 (gnus-summary-article-pseudo-p article)
10088 (error "This is a pseudo-article."))
10091 (set-buffer gnus-summary-buffer)
10092 (if (or (and gnus-single-article-buffer
10093 (or (null gnus-current-article)
10094 (null gnus-article-current)
10095 (null (get-buffer gnus-article-buffer))
10096 (not (eq article (cdr gnus-article-current)))
10097 (not (equal (car gnus-article-current)
10098 gnus-newsgroup-name))))
10099 (and (not gnus-single-article-buffer)
10100 (or (null gnus-current-article)
10101 (not (eq gnus-current-article article))))
10103 ;; The requested article is different from the current article.
10105 (gnus-summary-display-article article all-headers)
10106 (setq did article))
10107 (if (or all-headers gnus-show-all-headers)
10108 (gnus-article-show-all-headers))
10111 (gnus-article-set-window-start
10112 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10114 (defun gnus-summary-set-current-mark (&optional current-mark)
10115 "Obsolete function."
10118 (defun gnus-summary-next-article (&optional unread subject backward push)
10119 "Select the next article.
10120 If UNREAD, only unread articles are selected.
10121 If SUBJECT, only articles with SUBJECT are selected.
10122 If BACKWARD, the previous article is selected instead of the next."
10124 (gnus-set-global-variables)
10126 ;; Is there such an article?
10127 ((and (gnus-summary-search-forward unread subject backward)
10128 (or (gnus-summary-display-article (gnus-summary-article-number))
10129 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10130 (gnus-summary-position-point))
10131 ;; If not, we try the first unread, if that is wanted.
10133 gnus-auto-select-same
10134 (or (gnus-summary-first-unread-article)
10135 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10136 (gnus-summary-position-point)
10137 (gnus-message 6 "Wrapped"))
10138 ;; Try to get next/previous article not displayed in this group.
10139 ((and gnus-auto-extend-newsgroup
10140 (not unread) (not subject))
10141 (gnus-summary-goto-article
10142 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10144 ;; Go to next/previous group.
10146 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10147 (gnus-summary-jump-to-group gnus-newsgroup-name))
10148 (let ((cmd last-command-char)
10150 (if (eq gnus-keep-same-level 'best)
10151 (gnus-summary-best-group gnus-newsgroup-name)
10152 (gnus-summary-search-group backward gnus-keep-same-level))))
10153 ;; For some reason, the group window gets selected. We change
10155 (select-window (get-buffer-window (current-buffer)))
10156 ;; Select next unread newsgroup automagically.
10158 ((not gnus-auto-select-next)
10159 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10160 ((or (eq gnus-auto-select-next 'quietly)
10161 (and (eq gnus-auto-select-next 'slightly-quietly)
10163 (and (eq gnus-auto-select-next 'almost-quietly)
10164 (gnus-summary-last-article-p)))
10166 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10167 (gnus-summary-exit)
10168 (gnus-message 7 "No more%s articles (%s)..."
10169 (if unread " unread" "")
10170 (if group (concat "selecting " group)
10172 (gnus-summary-next-group nil group backward)))
10174 (gnus-summary-walk-group-buffer
10175 gnus-newsgroup-name cmd unread backward)))))))
10177 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10178 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10179 (?\C-p (gnus-group-prev-unread-group 1))))
10180 keve key group ended)
10182 (set-buffer gnus-group-buffer)
10183 (gnus-summary-jump-to-group from-group)
10185 (if (eq gnus-keep-same-level 'best)
10186 (gnus-summary-best-group gnus-newsgroup-name)
10187 (gnus-summary-search-group backward gnus-keep-same-level))))
10190 5 "No more%s articles%s" (if unread " unread" "")
10192 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10193 (format " (Type %s for %s [%s])"
10194 (single-key-description cmd) group
10195 (car (gnus-gethash group gnus-newsrc-hashtb)))
10196 (format " (Type %s to exit %s)"
10197 (single-key-description cmd)
10198 gnus-newsgroup-name)))
10199 ;; Confirm auto selection.
10200 (setq key (car (setq keve (gnus-read-event-char))))
10203 ((assq key keystrokes)
10204 (let ((obuf (current-buffer)))
10205 (switch-to-buffer gnus-group-buffer)
10207 (gnus-group-jump-to-group group))
10208 (eval (cadr (assq key keystrokes)))
10209 (setq group (gnus-group-group-name))
10210 (switch-to-buffer obuf))
10213 (if (or (not group)
10214 (gnus-ephemeral-group-p gnus-newsgroup-name))
10215 (gnus-summary-exit)
10216 (gnus-summary-next-group nil group backward)))
10218 (push (cdr keve) unread-command-events))))))
10220 (defun gnus-read-event-char ()
10221 "Get the next event."
10222 (let ((event (read-event)))
10223 (cons (and (numberp event) event) event)))
10225 (defun gnus-summary-next-unread-article ()
10226 "Select unread article after current one."
10228 (gnus-summary-next-article t (and gnus-auto-select-same
10229 (gnus-summary-article-subject))))
10231 (defun gnus-summary-prev-article (&optional unread subject)
10232 "Select the article after the current one.
10233 If UNREAD is non-nil, only unread articles are selected."
10235 (gnus-summary-next-article unread subject t))
10237 (defun gnus-summary-prev-unread-article ()
10238 "Select unred article before current one."
10240 (gnus-summary-prev-article t (and gnus-auto-select-same
10241 (gnus-summary-article-subject))))
10243 (defun gnus-summary-next-page (&optional lines circular)
10244 "Show next page of the selected article.
10245 If at the end of the current article, select the next article.
10246 LINES says how many lines should be scrolled up.
10248 If CIRCULAR is non-nil, go to the start of the article instead of
10249 selecting the next article when reaching the end of the current
10252 (setq gnus-summary-buffer (current-buffer))
10253 (gnus-set-global-variables)
10254 (let ((article (gnus-summary-article-number))
10256 (gnus-configure-windows 'article)
10257 (if (or (null gnus-current-article)
10258 (null gnus-article-current)
10259 (/= article (cdr gnus-article-current))
10260 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10261 ;; Selected subject is different from current article's.
10262 (gnus-summary-display-article article)
10263 (gnus-eval-in-buffer-window
10264 gnus-article-buffer
10265 (setq endp (gnus-article-next-page lines)))
10268 (gnus-summary-beginning-of-article))
10270 (gnus-message 3 "End of message"))
10272 (if (and (eq gnus-summary-goto-unread 'never)
10273 (not (gnus-summary-last-article-p article)))
10274 (gnus-summary-next-article)
10275 (gnus-summary-next-unread-article))))))
10276 (gnus-summary-recenter)
10277 (gnus-summary-position-point)))
10279 (defun gnus-summary-prev-page (&optional lines)
10280 "Show previous page of selected article.
10281 Argument LINES specifies lines to be scrolled down."
10283 (gnus-set-global-variables)
10284 (let ((article (gnus-summary-article-number)))
10285 (gnus-configure-windows 'article)
10286 (if (or (null gnus-current-article)
10287 (null gnus-article-current)
10288 (/= article (cdr gnus-article-current))
10289 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10290 ;; Selected subject is different from current article's.
10291 (gnus-summary-display-article article)
10292 (gnus-summary-recenter)
10293 (gnus-eval-in-buffer-window gnus-article-buffer
10294 (gnus-article-prev-page lines))))
10295 (gnus-summary-position-point))
10297 (defun gnus-summary-scroll-up (lines)
10298 "Scroll up (or down) one line current article.
10299 Argument LINES specifies lines to be scrolled up (or down if negative)."
10301 (gnus-set-global-variables)
10302 (gnus-configure-windows 'article)
10303 (gnus-summary-show-thread)
10304 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10305 (gnus-eval-in-buffer-window
10306 gnus-article-buffer
10308 (if (gnus-article-next-page lines)
10309 (gnus-message 3 "End of message")))
10311 (gnus-article-prev-page (- lines))))))
10312 (gnus-summary-recenter)
10313 (gnus-summary-position-point))
10315 (defun gnus-summary-next-same-subject ()
10316 "Select next article which has the same subject as current one."
10318 (gnus-set-global-variables)
10319 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10321 (defun gnus-summary-prev-same-subject ()
10322 "Select previous article which has the same subject as current one."
10324 (gnus-set-global-variables)
10325 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10327 (defun gnus-summary-next-unread-same-subject ()
10328 "Select next unread article which has the same subject as current one."
10330 (gnus-set-global-variables)
10331 (gnus-summary-next-article t (gnus-summary-article-subject)))
10333 (defun gnus-summary-prev-unread-same-subject ()
10334 "Select previous unread article which has the same subject as current one."
10336 (gnus-set-global-variables)
10337 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10339 (defun gnus-summary-first-unread-article ()
10340 "Select the first unread article.
10341 Return nil if there are no unread articles."
10343 (gnus-set-global-variables)
10345 (if (gnus-summary-first-subject t)
10347 (gnus-summary-show-thread)
10348 (gnus-summary-first-subject t)
10349 (gnus-summary-display-article (gnus-summary-article-number))))
10350 (gnus-summary-position-point)))
10352 (defun gnus-summary-best-unread-article ()
10353 "Select the unread article with the highest score."
10355 (gnus-set-global-variables)
10356 (let ((best -1000000)
10357 (data gnus-newsgroup-data)
10360 (and (gnus-data-unread-p (car data))
10362 (gnus-summary-article-score (gnus-data-number (car data))))
10365 article (gnus-data-number (car data))))
10366 (setq data (cdr data)))
10369 (gnus-summary-goto-article article)
10370 (error "No unread articles"))
10371 (gnus-summary-position-point))))
10373 (defun gnus-summary-last-subject ()
10374 "Go to the last displayed subject line in the group."
10375 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10377 (gnus-summary-goto-subject article))))
10379 (defun gnus-summary-goto-article (article &optional all-headers force)
10380 "Fetch ARTICLE and display it if it exists.
10381 If ALL-HEADERS is non-nil, no header lines are hidden."
10387 (mapcar (lambda (number) (list (int-to-string number)))
10388 gnus-newsgroup-limit)))
10392 (if (gnus-summary-goto-subject article force)
10393 (gnus-summary-display-article article all-headers)
10394 (gnus-message 4 "Couldn't go to article %s" article) nil)
10395 (gnus-summary-position-point)))
10397 (defun gnus-summary-goto-last-article ()
10398 "Go to the previously read article."
10401 (and gnus-last-article
10402 (gnus-summary-goto-article gnus-last-article))
10403 (gnus-summary-position-point)))
10405 (defun gnus-summary-pop-article (number)
10406 "Pop one article off the history and go to the previous.
10407 NUMBER articles will be popped off."
10410 (setq gnus-newsgroup-history
10411 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10413 (gnus-summary-goto-article (car to))
10414 (error "Article history empty")))
10415 (gnus-summary-position-point))
10417 ;; Summary commands and functions for limiting the summary buffer.
10419 (defun gnus-summary-limit-to-articles (n)
10420 "Limit the summary buffer to the next N articles.
10421 If not given a prefix, use the process marked articles instead."
10423 (gnus-set-global-variables)
10425 (let ((articles (gnus-summary-work-articles n)))
10426 (setq gnus-newsgroup-processable nil)
10427 (gnus-summary-limit articles))
10428 (gnus-summary-position-point)))
10430 (defun gnus-summary-pop-limit (&optional total)
10431 "Restore the previous limit.
10432 If given a prefix, remove all limits."
10434 (gnus-set-global-variables)
10436 (setq gnus-newsgroup-limits
10437 (list (mapcar (lambda (h) (mail-header-number h))
10438 gnus-newsgroup-headers))))
10439 (unless gnus-newsgroup-limits
10440 (error "No limit to pop"))
10442 (gnus-summary-limit nil 'pop)
10443 (gnus-summary-position-point)))
10445 (defun gnus-summary-limit-to-subject (subject &optional header)
10446 "Limit the summary buffer to articles that have subjects that match a regexp."
10447 (interactive "sRegexp: ")
10449 (setq header "subject"))
10450 (when (not (equal "" subject))
10452 (let ((articles (gnus-summary-find-matching
10453 (or header "subject") subject 'all)))
10454 (or articles (error "Found no matches for \"%s\"" subject))
10455 (gnus-summary-limit articles))
10456 (gnus-summary-position-point))))
10458 (defun gnus-summary-limit-to-author (from)
10459 "Limit the summary buffer to articles that have authors that match a regexp."
10460 (interactive "sRegexp: ")
10461 (gnus-summary-limit-to-subject from "from"))
10463 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10465 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10467 (defun gnus-summary-limit-to-unread (&optional all)
10468 "Limit the summary buffer to articles that are not marked as read.
10469 If ALL is non-nil, limit strictly to unread articles."
10472 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10473 (gnus-summary-limit-to-marks
10474 ;; Concat all the marks that say that an article is read and have
10476 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10477 gnus-killed-mark gnus-kill-file-mark
10478 gnus-low-score-mark gnus-expirable-mark
10479 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10482 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10483 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10485 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10486 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10487 If REVERSE, limit the summary buffer to articles that are not marked
10488 with MARKS. MARKS can either be a string of marks or a list of marks.
10489 Returns how many articles were removed."
10490 (interactive "sMarks: ")
10491 (gnus-set-global-variables)
10493 (let ((data gnus-newsgroup-data)
10494 (marks (if (listp marks) marks
10495 (append marks nil))) ; Transform to list.
10498 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10499 (memq (gnus-data-mark (car data)) marks))
10500 (setq articles (cons (gnus-data-number (car data)) articles)))
10501 (setq data (cdr data)))
10502 (gnus-summary-limit articles))
10503 (gnus-summary-position-point)))
10505 (defun gnus-summary-limit-to-score (&optional score)
10506 "Limit to articles with score at or above SCORE."
10508 (gnus-set-global-variables)
10509 (setq score (if score
10510 (prefix-numeric-value score)
10511 (or gnus-summary-default-score 0)))
10512 (let ((data gnus-newsgroup-data)
10515 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10517 (push (gnus-data-number (car data)) articles))
10518 (setq data (cdr data)))
10520 (gnus-summary-limit articles)
10521 (gnus-summary-position-point))))
10523 (defun gnus-summary-limit-include-dormant ()
10524 "Display all the hidden articles that are marked as dormant."
10526 (gnus-set-global-variables)
10527 (or gnus-newsgroup-dormant
10528 (error "There are no dormant articles in this group"))
10530 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10531 (gnus-summary-position-point)))
10533 (defun gnus-summary-limit-exclude-dormant ()
10534 "Hide all dormant articles."
10536 (gnus-set-global-variables)
10538 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10539 (gnus-summary-position-point)))
10541 (defun gnus-summary-limit-exclude-childless-dormant ()
10542 "Hide all dormant articles that have no children."
10544 (gnus-set-global-variables)
10545 (let ((data (gnus-data-list t))
10546 articles d children)
10547 ;; Find all articles that are either not dormant or have
10549 (while (setq d (pop data))
10550 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10551 (and (setq children
10552 (gnus-article-children (gnus-data-number d)))
10555 (when (memq (car children) articles)
10560 (push (gnus-data-number d) articles)))
10561 ;; Do the limiting.
10563 (gnus-summary-limit articles)
10564 (gnus-summary-position-point))))
10566 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10567 "Mark all unread excluded articles as read.
10568 If ALL, mark even excluded ticked and dormants as read."
10570 (let ((articles (gnus-sorted-complement
10572 (mapcar (lambda (h) (mail-header-number h))
10573 gnus-newsgroup-headers)
10575 (sort gnus-newsgroup-limit '<)))
10577 (setq gnus-newsgroup-unreads nil)
10579 (setq gnus-newsgroup-dormant nil
10580 gnus-newsgroup-marked nil
10581 gnus-newsgroup-reads
10583 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10584 gnus-newsgroup-reads))
10585 (while (setq article (pop articles))
10586 (unless (or (memq article gnus-newsgroup-dormant)
10587 (memq article gnus-newsgroup-marked))
10588 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10590 (defun gnus-summary-limit (articles &optional pop)
10592 ;; We pop the previous limit off the stack and use that.
10593 (setq articles (car gnus-newsgroup-limits)
10594 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10595 ;; We use the new limit, so we push the old limit on the stack.
10596 (setq gnus-newsgroup-limits
10597 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10599 (setq gnus-newsgroup-limit articles)
10600 (let ((total (length gnus-newsgroup-data))
10601 (data (gnus-data-find-list (gnus-summary-article-number)))
10603 ;; This will do all the work of generating the new summary buffer
10604 ;; according to the new limit.
10605 (gnus-summary-prepare)
10606 ;; Hide any threads, possibly.
10607 (and gnus-show-threads
10608 gnus-thread-hide-subtree
10609 (gnus-summary-hide-all-threads))
10610 ;; Try to return to the article you were at, or one in the
10613 ;; We try to find some article after the current one.
10615 (and (gnus-summary-goto-subject
10616 (gnus-data-number (car data)) nil t)
10619 (setq data (cdr data))))
10621 ;; If there is no data, that means that we were after the last
10622 ;; article. The same goes when we can't find any articles
10623 ;; after the current one.
10625 (goto-char (point-max))
10626 (gnus-summary-find-prev)))
10627 ;; We return how many articles were removed from the summary
10628 ;; buffer as a result of the new limit.
10629 (- total (length gnus-newsgroup-data))))
10631 (defsubst gnus-cut-thread (thread)
10632 "Go forwards in the thread until we find an article that we want to display."
10633 (when (eq gnus-fetch-old-headers 'some)
10634 ;; Deal with old-fetched headers.
10636 (memq (mail-header-number (car thread))
10637 gnus-newsgroup-ancient)
10638 (<= (length (cdr thread)) 1))
10639 (setq thread (cadr thread))))
10640 ;; Deal with sparse threads.
10641 (when (or (eq gnus-build-sparse-threads 'some)
10642 (eq gnus-build-sparse-threads 'more))
10644 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10645 (= (length (cdr thread)) 1))
10646 (setq thread (cadr thread))))
10649 (defun gnus-cut-threads (threads)
10650 "Cut off all uninteresting articles from the beginning of threads."
10651 (when (or (eq gnus-fetch-old-headers 'some)
10652 (eq gnus-build-sparse-threads 'some)
10653 (eq gnus-build-sparse-threads 'more))
10654 (let ((th threads))
10656 (setcar th (gnus-cut-thread (car th)))
10657 (setq th (cdr th)))))
10658 ;; Remove nixed out threads.
10659 (delq nil threads))
10661 (defun gnus-summary-initial-limit (&optional show-if-empty)
10662 "Figure out what the initial limit is supposed to be on group entry.
10663 This entails weeding out unwanted dormants, low-scored articles,
10664 fetch-old-headers verbiage, and so on."
10665 ;; Most groups have nothing to remove.
10666 (if (or gnus-inhibit-limiting
10667 (and (null gnus-newsgroup-dormant)
10668 (not (eq gnus-fetch-old-headers 'some))
10669 (null gnus-summary-expunge-below)
10670 (not (eq gnus-build-sparse-threads 'some))
10671 (not (eq gnus-build-sparse-threads 'more))
10672 (null gnus-thread-expunge-below)
10673 (not gnus-use-nocem)))
10675 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10676 (setq gnus-newsgroup-limit nil)
10679 (unless (car (symbol-value node))
10680 ;; These threads have no parents -- they are roots.
10681 (let ((nodes (cdr (symbol-value node)))
10684 (if (and gnus-thread-expunge-below
10685 (< (gnus-thread-total-score (car nodes))
10686 gnus-thread-expunge-below))
10687 (gnus-expunge-thread (pop nodes))
10688 (setq thread (pop nodes))
10689 (gnus-summary-limit-children thread))))))
10690 gnus-newsgroup-dependencies)
10691 ;; If this limitation resulted in an empty group, we might
10692 ;; pop the previous limit and use it instead.
10693 (when (and (not gnus-newsgroup-limit)
10695 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10696 gnus-newsgroup-limit))
10698 (defun gnus-summary-limit-children (thread)
10699 "Return 1 if this subthread is visible and 0 if it is not."
10700 ;; First we get the number of visible children to this thread. This
10701 ;; is done by recursing down the thread using this function, so this
10702 ;; will really go down to a leaf article first, before slowly
10703 ;; working its way up towards the root.
10707 (apply '+ (mapcar 'gnus-summary-limit-children
10710 (number (mail-header-number (car thread)))
10713 ;; If this article is dormant and has absolutely no visible
10714 ;; children, then this article isn't visible.
10715 (and (memq number gnus-newsgroup-dormant)
10717 ;; If this is a "fetch-old-headered" and there is only one
10718 ;; visible child (or less), then we don't want this article.
10719 (and (eq gnus-fetch-old-headers 'some)
10720 (memq number gnus-newsgroup-ancient)
10722 ;; If this is a sparsely inserted article with no children,
10723 ;; we don't want it.
10724 (and (eq gnus-build-sparse-threads 'some)
10725 (memq number gnus-newsgroup-sparse)
10727 ;; If we use expunging, and this article is really
10728 ;; low-scored, then we don't want this article.
10729 (when (and gnus-summary-expunge-below
10731 (or (cdr (assq number gnus-newsgroup-scored))
10732 gnus-summary-default-score))
10733 gnus-summary-expunge-below))
10734 ;; We increase the expunge-tally here, but that has
10735 ;; nothing to do with the limits, really.
10736 (incf gnus-newsgroup-expunged-tally)
10737 ;; We also mark as read here, if that's wanted.
10738 (when (and gnus-summary-mark-below
10739 (< score gnus-summary-mark-below))
10740 (setq gnus-newsgroup-unreads
10741 (delq number gnus-newsgroup-unreads))
10742 (if gnus-newsgroup-auto-expire
10743 (push number gnus-newsgroup-expirable)
10744 (push (cons number gnus-low-score-mark)
10745 gnus-newsgroup-reads)))
10747 (and gnus-use-nocem
10748 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10749 ;; Nope, invisible article.
10751 ;; Ok, this article is to be visible, so we add it to the limit
10753 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10756 (defun gnus-expunge-thread (thread)
10757 "Mark all articles in THREAD as read."
10758 (let* ((number (mail-header-number (car thread))))
10759 (incf gnus-newsgroup-expunged-tally)
10760 ;; We also mark as read here, if that's wanted.
10761 (setq gnus-newsgroup-unreads
10762 (delq number gnus-newsgroup-unreads))
10763 (if gnus-newsgroup-auto-expire
10764 (push number gnus-newsgroup-expirable)
10765 (push (cons number gnus-low-score-mark)
10766 gnus-newsgroup-reads)))
10767 ;; Go recursively through all subthreads.
10768 (mapcar 'gnus-expunge-thread (cdr thread)))
10770 ;; Summary article oriented commands
10772 (defun gnus-summary-refer-parent-article (n)
10773 "Refer parent article N times.
10774 The difference between N and the number of articles fetched is returned."
10776 (gnus-set-global-variables)
10780 (let* ((header (gnus-summary-article-header))
10782 ;; If we try to find the parent of the currently
10783 ;; displayed article, then we take a look at the actual
10784 ;; References header, since this is slightly more
10785 ;; reliable than the References field we got from the
10787 (if (and (eq (mail-header-number header)
10788 (cdr gnus-article-current))
10789 (equal gnus-newsgroup-name
10790 (car gnus-article-current)))
10792 (set-buffer gnus-original-article-buffer)
10793 (nnheader-narrow-to-headers)
10795 (mail-fetch-field "references")
10797 ;; It's not the current article, so we take a bet on
10798 ;; the value we got from the server.
10799 (mail-header-references header))))
10800 (if (setq ref (or ref (mail-header-references header)))
10801 (or (gnus-summary-refer-article (gnus-parent-id ref))
10802 (gnus-message 1 "Couldn't find parent"))
10803 (gnus-message 1 "No references in article %d"
10804 (gnus-summary-article-number))
10807 (gnus-summary-position-point)
10810 (defun gnus-summary-refer-references ()
10811 "Fetch all articles mentioned in the References header.
10812 Return how many articles were fetched."
10814 (gnus-set-global-variables)
10815 (let ((ref (mail-header-references (gnus-summary-article-header)))
10816 (current (gnus-summary-article-number))
10818 ;; For each Message-ID in the References header...
10819 (while (string-match "<[^>]*>" ref)
10821 ;; ... fetch that article.
10822 (gnus-summary-refer-article
10823 (prog1 (match-string 0 ref)
10824 (setq ref (substring ref (match-end 0))))))
10825 (gnus-summary-goto-subject current)
10826 (gnus-summary-position-point)
10829 (defun gnus-summary-refer-article (message-id)
10830 "Fetch an article specified by MESSAGE-ID."
10831 (interactive "sMessage-ID: ")
10832 (when (and (stringp message-id)
10833 (not (zerop (length message-id))))
10834 ;; Construct the correct Message-ID if necessary.
10835 ;; Suggested by tale@pawl.rpi.edu.
10836 (unless (string-match "^<" message-id)
10837 (setq message-id (concat "<" message-id)))
10838 (unless (string-match ">$" message-id)
10839 (setq message-id (concat message-id ">")))
10840 (let ((header (car (gnus-gethash message-id
10841 gnus-newsgroup-dependencies))))
10843 ;; The article is present in the buffer, to we just go to it.
10844 (gnus-summary-goto-article (mail-header-number header) nil t)
10845 ;; We fetch the article
10846 (let ((gnus-override-method
10847 (and (gnus-news-group-p gnus-newsgroup-name)
10848 gnus-refer-article-method))
10850 ;; Start the special refer-article method, if necessary.
10851 (when gnus-refer-article-method
10852 (gnus-check-server gnus-refer-article-method))
10853 ;; Fetch the header, and display the article.
10854 (if (setq number (gnus-summary-insert-subject message-id))
10855 (gnus-summary-select-article nil nil nil number)
10856 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10858 (defun gnus-summary-enter-digest-group (&optional force)
10859 "Enter a digest group based on the current article."
10861 (gnus-set-global-variables)
10862 (gnus-summary-select-article)
10863 (let ((name (format "%s-%d"
10864 (gnus-group-prefixed-name
10865 gnus-newsgroup-name (list 'nndoc ""))
10866 gnus-current-article))
10867 (ogroup gnus-newsgroup-name)
10868 (case-fold-search t)
10869 (buf (current-buffer))
10872 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10873 (insert-buffer-substring gnus-original-article-buffer)
10875 (goto-char (point-min))
10876 (or (search-forward "\n\n" nil t) (point)))
10877 (goto-char (point-min))
10878 (delete-matching-lines "^\\(Path\\):\\|^From ")
10881 (if (gnus-group-read-ephemeral-group
10882 name `(nndoc ,name (nndoc-address
10884 (nndoc-article-type ,(if force 'digest 'guess))) t)
10885 ;; Make all postings to this group go to the parent group.
10886 (nconc (gnus-info-params (gnus-get-info name))
10887 (list (cons 'to-group ogroup)))
10888 ;; Couldn't select this doc group.
10889 (switch-to-buffer buf)
10890 (gnus-set-global-variables)
10891 (gnus-configure-windows 'summary)
10892 (gnus-message 3 "Article couldn't be entered?"))
10893 (kill-buffer dig))))
10895 (defun gnus-summary-isearch-article (&optional regexp-p)
10896 "Do incremental search forward on the current article.
10897 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10899 (gnus-set-global-variables)
10900 (gnus-summary-select-article)
10901 (gnus-configure-windows 'article)
10902 (gnus-eval-in-buffer-window
10903 gnus-article-buffer
10904 (goto-char (point-min))
10905 (isearch-forward regexp-p)))
10907 (defun gnus-summary-search-article-forward (regexp &optional backward)
10908 "Search for an article containing REGEXP forward.
10909 If BACKWARD, search backward instead."
10912 (format "Search article %s (regexp%s): "
10913 (if current-prefix-arg "backward" "forward")
10914 (if gnus-last-search-regexp
10915 (concat ", default " gnus-last-search-regexp)
10917 current-prefix-arg))
10918 (gnus-set-global-variables)
10919 (if (string-equal regexp "")
10920 (setq regexp (or gnus-last-search-regexp ""))
10921 (setq gnus-last-search-regexp regexp))
10922 (if (gnus-summary-search-article regexp backward)
10923 (gnus-article-set-window-start
10924 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10925 (error "Search failed: \"%s\"" regexp)))
10927 (defun gnus-summary-search-article-backward (regexp)
10928 "Search for an article containing REGEXP backward."
10931 (format "Search article backward (regexp%s): "
10932 (if gnus-last-search-regexp
10933 (concat ", default " gnus-last-search-regexp)
10935 (gnus-summary-search-article-forward regexp 'backward))
10937 (defun gnus-summary-search-article (regexp &optional backward)
10938 "Search for an article containing REGEXP.
10939 Optional argument BACKWARD means do search for backward.
10940 gnus-select-article-hook is not called during the search."
10941 (let ((gnus-select-article-hook nil) ;Disable hook.
10942 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10945 (function re-search-backward) (function re-search-forward)))
10948 ;; Hidden thread subtrees must be searched for ,too.
10949 (gnus-summary-show-all-threads)
10950 ;; First of all, search current article.
10951 ;; We don't want to read article again from NNTP server nor reset
10953 (gnus-summary-select-article)
10954 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10955 (setq last gnus-current-article)
10956 (gnus-eval-in-buffer-window
10957 gnus-article-buffer
10960 ;; Begin search from current point.
10961 (setq found (funcall re-search regexp nil t))))
10962 ;; Then search next articles.
10963 (while (and (not found)
10964 (gnus-summary-display-article
10965 (if backward (gnus-summary-find-prev)
10966 (gnus-summary-find-next))))
10967 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10968 (gnus-eval-in-buffer-window
10969 gnus-article-buffer
10972 (goto-char (if backward (point-max) (point-min)))
10973 (setq found (funcall re-search regexp nil t)))))
10975 ;; Adjust article pointer.
10976 (or (eq last gnus-current-article)
10977 (setq gnus-last-article last))
10978 ;; Return T if found such article.
10981 (defun gnus-summary-find-matching (header regexp &optional backward unread
10983 "Return a list of all articles that match REGEXP on HEADER.
10984 The search stars on the current article and goes forwards unless
10985 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10986 If UNREAD is non-nil, only unread articles will
10987 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10988 in the comparisons."
10989 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10990 (gnus-data-find-list
10991 (gnus-summary-article-number) (gnus-data-list backward))))
10992 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10993 (case-fold-search (not not-case-fold))
10995 (or (fboundp (intern (concat "mail-header-" header)))
10996 (error "%s is not a valid header" header))
10998 (setq d (car data))
10999 (and (or (not unread) ; We want all articles...
11000 (gnus-data-unread-p d)) ; Or just unreads.
11001 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11002 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11003 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11004 (setq data (cdr data)))
11005 (nreverse articles)))
11007 (defun gnus-summary-execute-command (header regexp command &optional backward)
11008 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11009 If HEADER is an empty string (or nil), the match is done on the entire
11010 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11012 (list (let ((completion-ignore-case t))
11015 (mapcar (lambda (string) (list string))
11016 '("Number" "Subject" "From" "Lines" "Date"
11017 "Message-ID" "Xref" "References" "Body"))
11018 nil 'require-match))
11019 (read-string "Regexp: ")
11020 (read-key-sequence "Command: ")
11021 current-prefix-arg))
11022 (when (equal header "Body")
11024 (gnus-set-global-variables)
11025 ;; Hidden thread subtrees must be searched as well.
11026 (gnus-summary-show-all-threads)
11027 ;; We don't want to change current point nor window configuration.
11029 (save-window-excursion
11030 (gnus-message 6 "Executing %s..." (key-description command))
11031 ;; We'd like to execute COMMAND interactively so as to give arguments.
11032 (gnus-execute header regexp
11033 `(lambda () (call-interactively ',(key-binding command)))
11035 (gnus-message 6 "Executing %s...done" (key-description command)))))
11037 (defun gnus-summary-beginning-of-article ()
11038 "Scroll the article back to the beginning."
11040 (gnus-set-global-variables)
11041 (gnus-summary-select-article)
11042 (gnus-configure-windows 'article)
11043 (gnus-eval-in-buffer-window
11044 gnus-article-buffer
11046 (goto-char (point-min))
11047 (and gnus-break-pages (gnus-narrow-to-page))))
11049 (defun gnus-summary-end-of-article ()
11050 "Scroll to the end of the article."
11052 (gnus-set-global-variables)
11053 (gnus-summary-select-article)
11054 (gnus-configure-windows 'article)
11055 (gnus-eval-in-buffer-window
11056 gnus-article-buffer
11058 (goto-char (point-max))
11060 (and gnus-break-pages (gnus-narrow-to-page))))
11062 (defun gnus-summary-show-article (&optional arg)
11063 "Force re-fetching of the current article.
11064 If ARG (the prefix) is non-nil, show the raw article without any
11065 article massaging functions being run."
11067 (gnus-set-global-variables)
11069 ;; Select the article the normal way.
11070 (gnus-summary-select-article nil 'force)
11071 ;; Bind the article treatment functions to nil.
11072 (let ((gnus-have-all-headers t)
11073 gnus-article-display-hook
11074 gnus-article-prepare-hook
11076 (gnus-summary-select-article nil 'force)))
11077 ; (gnus-configure-windows 'article)
11078 (gnus-summary-position-point))
11080 (defun gnus-summary-verbose-headers (&optional arg)
11081 "Toggle permanent full header display.
11082 If ARG is a positive number, turn header display on.
11083 If ARG is a negative number, turn header display off."
11085 (gnus-set-global-variables)
11086 (gnus-summary-toggle-header arg)
11087 (setq gnus-show-all-headers
11088 (cond ((or (not (numberp arg))
11090 (not gnus-show-all-headers))
11094 (defun gnus-summary-toggle-header (&optional arg)
11095 "Show the headers if they are hidden, or hide them if they are shown.
11096 If ARG is a positive number, show the entire header.
11097 If ARG is a negative number, hide the unwanted header lines."
11099 (gnus-set-global-variables)
11101 (set-buffer gnus-article-buffer)
11102 (let* ((buffer-read-only nil)
11103 (inhibit-point-motion-hooks t)
11104 (hidden (text-property-any
11105 (goto-char (point-min)) (search-forward "\n\n")
11108 (goto-char (point-min))
11109 (when (search-forward "\n\n" nil t)
11110 (delete-region (point-min) (1- (point))))
11111 (goto-char (point-min))
11113 (set-buffer gnus-original-article-buffer)
11114 (goto-char (point-min))
11115 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11116 (insert-buffer-substring gnus-original-article-buffer 1 e)
11117 (let ((gnus-inhibit-hiding t))
11118 (run-hooks 'gnus-article-display-hook))
11119 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11120 (gnus-article-hide-headers)))))
11122 (defun gnus-summary-show-all-headers ()
11123 "Make all header lines visible."
11125 (gnus-set-global-variables)
11126 (gnus-article-show-all-headers))
11128 (defun gnus-summary-toggle-mime (&optional arg)
11129 "Toggle MIME processing.
11130 If ARG is a positive number, turn MIME processing on."
11132 (gnus-set-global-variables)
11133 (setq gnus-show-mime
11134 (if (null arg) (not gnus-show-mime)
11135 (> (prefix-numeric-value arg) 0)))
11136 (gnus-summary-select-article t 'force))
11138 (defun gnus-summary-caesar-message (&optional arg)
11139 "Caesar rotate the current article by 13.
11140 The numerical prefix specifies how manu places to rotate each letter
11143 (gnus-set-global-variables)
11144 (gnus-summary-select-article)
11145 (let ((mail-header-separator ""))
11146 (gnus-eval-in-buffer-window
11147 gnus-article-buffer
11150 (let ((start (window-start)))
11151 (news-caesar-buffer-body arg)
11152 (set-window-start (get-buffer-window (current-buffer)) start))))))
11154 (defun gnus-summary-stop-page-breaking ()
11155 "Stop page breaking in the current article."
11157 (gnus-set-global-variables)
11158 (gnus-summary-select-article)
11159 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11161 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11162 "Move the current article to a different newsgroup.
11163 If N is a positive number, move the N next articles.
11164 If N is a negative number, move the N previous articles.
11165 If N is nil and any articles have been marked with the process mark,
11166 move those articles instead.
11167 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11168 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11169 re-spool using this method.
11171 For this function to work, both the current newsgroup and the
11172 newsgroup that you want to move to have to support the `request-move'
11173 and `request-accept' functions."
11175 (unless action (setq action 'move))
11176 (gnus-set-global-variables)
11177 ;; Check whether the source group supports the required functions.
11178 (cond ((and (eq action 'move)
11179 (not (gnus-check-backend-function
11180 'request-move-article gnus-newsgroup-name)))
11181 (error "The current group does not support article moving"))
11182 ((and (eq action 'crosspost)
11183 (not (gnus-check-backend-function
11184 'request-replace-article gnus-newsgroup-name)))
11185 (error "The current group does not support article editing")))
11186 (let ((articles (gnus-summary-work-articles n))
11187 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11188 (names '((move "move" "Moving")
11189 (copy "copy" "Copying")
11190 (crosspost "crosspost" "Crossposting")))
11191 (copy-buf (save-excursion
11192 (nnheader-set-temp-buffer " *copy article*")))
11193 art-group to-method new-xref article to-groups)
11194 (unless (assq action names)
11195 (error "Unknown action %s" action))
11196 ;; Read the newsgroup name.
11197 (when (and (not to-newsgroup)
11198 (not select-method))
11200 (gnus-read-move-group-name
11201 (cadr (assq action names))
11202 gnus-current-move-group articles prefix))
11203 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11204 (setq to-method (or select-method
11205 (gnus-find-method-for-group to-newsgroup)))
11206 ;; Check the method we are to move this article to...
11207 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11208 (error "%s does not support article copying" (car to-method)))
11209 (or (gnus-check-server to-method)
11210 (error "Can't open server %s" (car to-method)))
11211 (gnus-message 6 "%s to %s: %s..."
11212 (caddr (assq action names))
11213 (or (car select-method) to-newsgroup) articles)
11215 (setq article (pop articles))
11219 ;; Move the article.
11221 (gnus-request-move-article
11222 article ; Article to move
11223 gnus-newsgroup-name ; From newsgrouo
11224 (nth 1 (gnus-find-method-for-group
11225 gnus-newsgroup-name)) ; Server
11226 (list 'gnus-request-accept-article
11227 to-newsgroup (list 'quote select-method)
11228 (not articles)) ; Accept form
11229 (not articles))) ; Only save nov last time
11230 ;; Copy the article.
11233 (set-buffer copy-buf)
11234 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11235 (gnus-request-accept-article
11236 to-newsgroup select-method (not articles))))
11237 ;; Crosspost the article.
11238 ((eq action 'crosspost)
11239 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11240 (setq new-xref (concat gnus-newsgroup-name ":" article))
11241 (if (and xref (not (string= xref "")))
11243 (when (string-match "^Xref: " xref)
11244 (setq xref (substring xref (match-end 0))))
11245 (setq new-xref (concat xref " " new-xref)))
11246 (setq new-xref (concat (system-name) " " new-xref)))
11248 (set-buffer copy-buf)
11249 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11250 (nnheader-replace-header "xref" new-xref)
11251 (gnus-request-accept-article
11252 to-newsgroup select-method (not articles)))))))
11253 (if (not art-group)
11254 (gnus-message 1 "Couldn't %s article %s"
11255 (cadr (assq action names)) article)
11258 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11260 (gnus-group-prefixed-name
11263 (gnus-find-method-for-group to-newsgroup)))
11264 gnus-newsrc-hashtb)))
11265 (info (nth 2 entry))
11266 (to-group (gnus-info-group info)))
11267 ;; Update the group that has been moved to.
11269 (memq action '(move copy)))
11270 (unless (member to-group to-groups)
11271 (push to-group to-groups))
11273 (unless (memq article gnus-newsgroup-unreads)
11274 (gnus-info-set-read
11275 info (gnus-add-to-range (gnus-info-read info)
11276 (list (cdr art-group)))))
11278 ;; Copy any marks over to the new group.
11279 (let ((marks gnus-article-mark-lists)
11280 (to-article (cdr art-group)))
11282 ;; See whether the article is to be put in the cache.
11283 (when gnus-use-cache
11284 (gnus-cache-possibly-enter-article
11285 to-group to-article
11286 (let ((header (copy-sequence
11287 (gnus-summary-article-header article))))
11288 (mail-header-set-number header to-article)
11290 (memq article gnus-newsgroup-marked)
11291 (memq article gnus-newsgroup-dormant)
11292 (memq article gnus-newsgroup-unreads)))
11295 (when (memq article (symbol-value
11296 (intern (format "gnus-newsgroup-%s"
11298 ;; If the other group is the same as this group,
11299 ;; then we have to add the mark to the list.
11300 (when (equal to-group gnus-newsgroup-name)
11301 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11304 (intern (format "gnus-newsgroup-%s"
11306 ;; Copy mark to other group.
11307 (gnus-add-marked-articles
11308 to-group (cdar marks) (list to-article) info))
11309 (setq marks (cdr marks)))))
11311 ;; Update the Xref header in this article to point to
11312 ;; the new crossposted article we have just created.
11313 (when (eq action 'crosspost)
11315 (set-buffer copy-buf)
11316 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11317 (nnheader-replace-header
11318 "xref" (concat new-xref " " (gnus-group-prefixed-name
11319 (car art-group) to-method)
11320 ":" (cdr art-group)))
11321 (gnus-request-replace-article
11322 article gnus-newsgroup-name (current-buffer)))))
11324 (gnus-summary-goto-subject article)
11325 (when (eq action 'move)
11326 (gnus-summary-mark-article article gnus-canceled-mark)))
11327 (gnus-summary-remove-process-mark article))
11328 ;; Re-activate all groups that have been moved to.
11330 (gnus-activate-group (pop to-groups)))
11332 (gnus-kill-buffer copy-buf)
11333 (gnus-summary-position-point)
11334 (gnus-set-mode-line 'summary)))
11336 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11337 "Move the current article to a different newsgroup.
11338 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11339 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11340 re-spool using this method."
11342 (gnus-summary-move-article n nil select-method 'copy))
11344 (defun gnus-summary-crosspost-article (&optional n)
11345 "Crosspost the current article to some other group."
11347 (gnus-summary-move-article n nil nil 'crosspost))
11349 (defun gnus-summary-respool-article (&optional n method)
11350 "Respool the current article.
11351 The article will be squeezed through the mail spooling process again,
11352 which means that it will be put in some mail newsgroup or other
11353 depending on `nnmail-split-methods'.
11354 If N is a positive number, respool the N next articles.
11355 If N is a negative number, respool the N previous articles.
11356 If N is nil and any articles have been marked with the process mark,
11357 respool those articles instead.
11359 Respooling can be done both from mail groups and \"real\" newsgroups.
11360 In the former case, the articles in question will be moved from the
11361 current group into whatever groups they are destined to. In the
11362 latter case, they will be copied into the relevant groups."
11364 (list current-prefix-arg
11365 (let* ((methods (gnus-methods-using 'respool))
11367 (symbol-name (car (gnus-find-method-for-group
11368 gnus-newsgroup-name))))
11371 "What backend do you want to use when respooling? "
11372 methods nil t (cons methname 0)))
11375 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11376 (list (intern method) ""))
11380 (cdr (completing-read
11382 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11383 (gnus-set-global-variables)
11385 (error "No method given for respooling"))
11386 (if (assoc (symbol-name
11387 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11388 (gnus-methods-using 'respool))
11389 (gnus-summary-move-article n nil method)
11390 (gnus-summary-copy-article n nil method)))
11392 (defun gnus-summary-import-article (file)
11393 "Import a random file into a mail newsgroup."
11394 (interactive "fImport file: ")
11395 (gnus-set-global-variables)
11396 (let ((group gnus-newsgroup-name)
11397 (now (current-time))
11399 (or (gnus-check-backend-function 'request-accept-article group)
11400 (error "%s does not support article importing" group))
11401 (or (file-readable-p file)
11402 (not (file-regular-p file))
11403 (error "Can't read %s" file))
11405 (set-buffer (get-buffer-create " *import file*"))
11406 (buffer-disable-undo (current-buffer))
11408 (insert-file-contents file)
11409 (goto-char (point-min))
11410 (unless (nnheader-article-p)
11411 ;; This doesn't look like an article, so we fudge some headers.
11412 (setq atts (file-attributes file)
11413 lines (count-lines (point-min) (point-max)))
11414 (insert "From: " (read-string "From: ") "\n"
11415 "Subject: " (read-string "Subject: ") "\n"
11416 "Date: " (timezone-make-date-arpa-standard
11417 (current-time-string (nth 5 atts))
11418 (current-time-zone now)
11419 (current-time-zone now)) "\n"
11420 "Message-ID: " (gnus-inews-message-id) "\n"
11421 "Lines: " (int-to-string lines) "\n"
11422 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11423 (gnus-request-accept-article group nil t)
11424 (kill-buffer (current-buffer)))))
11426 (defun gnus-summary-expire-articles ()
11427 "Expire all articles that are marked as expirable in the current group."
11429 (gnus-set-global-variables)
11430 (when (gnus-check-backend-function
11431 'request-expire-articles gnus-newsgroup-name)
11432 ;; This backend supports expiry.
11433 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11434 (expirable (if total
11435 (gnus-list-of-read-articles gnus-newsgroup-name)
11436 (setq gnus-newsgroup-expirable
11437 (sort gnus-newsgroup-expirable '<))))
11438 (expiry-wait (gnus-group-get-parameter
11439 gnus-newsgroup-name 'expiry-wait))
11442 ;; There are expirable articles in this group, so we run them
11443 ;; through the expiry process.
11444 (gnus-message 6 "Expiring articles...")
11445 ;; The list of articles that weren't expired is returned.
11447 (let ((nnmail-expiry-wait-function nil)
11448 (nnmail-expiry-wait expiry-wait))
11449 (setq es (gnus-request-expire-articles
11450 expirable gnus-newsgroup-name)))
11451 (setq es (gnus-request-expire-articles
11452 expirable gnus-newsgroup-name)))
11453 (or total (setq gnus-newsgroup-expirable es))
11454 ;; We go through the old list of expirable, and mark all
11455 ;; really expired articles as nonexistent.
11456 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11457 (let ((gnus-use-cache nil))
11459 (unless (memq (car expirable) es)
11460 (when (gnus-data-find (car expirable))
11461 (gnus-summary-mark-article
11462 (car expirable) gnus-canceled-mark)))
11463 (setq expirable (cdr expirable)))))
11464 (gnus-message 6 "Expiring articles...done")))))
11466 (defun gnus-summary-expire-articles-now ()
11467 "Expunge all expirable articles in the current group.
11468 This means that *all* articles that are marked as expirable will be
11469 deleted forever, right now."
11471 (gnus-set-global-variables)
11472 (or gnus-expert-user
11474 "Are you really, really, really sure you want to expunge? ")
11476 (let ((nnmail-expiry-wait 'immediate)
11477 (nnmail-expiry-wait-function nil))
11478 (gnus-summary-expire-articles)))
11480 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11481 (defun gnus-summary-delete-article (&optional n)
11482 "Delete the N next (mail) articles.
11483 This command actually deletes articles. This is not a marking
11484 command. The article will disappear forever from your life, never to
11486 If N is negative, delete backwards.
11487 If N is nil and articles have been marked with the process mark,
11488 delete these instead."
11490 (gnus-set-global-variables)
11491 (or (gnus-check-backend-function 'request-expire-articles
11492 gnus-newsgroup-name)
11493 (error "The current newsgroup does not support article deletion."))
11494 ;; Compute the list of articles to delete.
11495 (let ((articles (gnus-summary-work-articles n))
11497 (if (and gnus-novice-user
11498 (not (gnus-y-or-n-p
11499 (format "Do you really want to delete %s forever? "
11500 (if (> (length articles) 1) "these articles"
11501 "this article")))))
11503 ;; Delete the articles.
11504 (setq not-deleted (gnus-request-expire-articles
11505 articles gnus-newsgroup-name 'force))
11507 (gnus-summary-remove-process-mark (car articles))
11508 ;; The backend might not have been able to delete the article
11510 (or (memq (car articles) not-deleted)
11511 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11512 (setq articles (cdr articles))))
11513 (gnus-summary-position-point)
11514 (gnus-set-mode-line 'summary)
11517 (defun gnus-summary-edit-article (&optional force)
11518 "Enter into a buffer and edit the current article.
11519 This will have permanent effect only in mail groups.
11520 If FORCE is non-nil, allow editing of articles even in read-only
11524 (set-buffer gnus-summary-buffer)
11525 (gnus-set-global-variables)
11526 (when (and (not force)
11527 (gnus-group-read-only-p))
11528 (error "The current newsgroup does not support article editing."))
11529 (gnus-summary-select-article t nil t)
11530 (gnus-configure-windows 'article)
11531 (select-window (get-buffer-window gnus-article-buffer))
11532 (gnus-message 6 "C-c C-c to end edits")
11533 (setq buffer-read-only nil)
11535 (use-local-map (copy-keymap (current-local-map)))
11536 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11537 (buffer-enable-undo)
11539 (goto-char (point-min))
11540 (search-forward "\n\n" nil t)))
11542 (defun gnus-summary-edit-article-done ()
11543 "Make edits to the current article permanent."
11545 (if (gnus-group-read-only-p)
11547 (gnus-summary-edit-article-postpone)
11549 1 "The current newsgroup does not support article editing.")
11551 (let ((buf (format "%s" (buffer-string))))
11554 (if (not (gnus-request-replace-article
11555 (cdr gnus-article-current) (car gnus-article-current)
11557 (error "Couldn't replace article.")
11558 (gnus-article-mode)
11559 (use-local-map gnus-article-mode-map)
11560 (setq buffer-read-only t)
11561 (buffer-disable-undo (current-buffer))
11562 (gnus-configure-windows 'summary)
11563 (gnus-summary-update-article (cdr gnus-article-current))
11564 (when gnus-use-cache
11565 (gnus-cache-update-article
11566 (cdr gnus-article-current) (car gnus-article-current))))
11567 (run-hooks 'gnus-article-display-hook)
11568 (and (gnus-visual-p 'summary-highlight 'highlight)
11569 (run-hooks 'gnus-visual-mark-article-hook)))))
11571 (defun gnus-summary-edit-article-postpone ()
11572 "Postpone changes to the current article."
11574 (gnus-article-mode)
11575 (use-local-map gnus-article-mode-map)
11576 (setq buffer-read-only t)
11577 (buffer-disable-undo (current-buffer))
11578 (gnus-configure-windows 'summary)
11579 (and (gnus-visual-p 'summary-highlight 'highlight)
11580 (run-hooks 'gnus-visual-mark-article-hook)))
11582 (defun gnus-summary-respool-query ()
11583 "Query where the respool algorithm would put this article."
11585 (gnus-set-global-variables)
11586 (gnus-summary-select-article)
11588 (set-buffer gnus-article-buffer)
11590 (goto-char (point-min))
11591 (search-forward "\n\n")
11592 (narrow-to-region (point-min) (point))
11593 (pp-eval-expression
11594 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11596 ;; Summary score commands.
11598 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11600 (defun gnus-summary-raise-score (n)
11601 "Raise the score of the current article by N."
11603 (gnus-set-global-variables)
11604 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11606 (defun gnus-summary-set-score (n)
11607 "Set the score of the current article to N."
11609 (gnus-set-global-variables)
11611 (gnus-summary-show-thread)
11612 (let ((buffer-read-only nil))
11614 (gnus-summary-update-mark
11615 (if (= n (or gnus-summary-default-score 0)) ?
11616 (if (< n (or gnus-summary-default-score 0))
11617 gnus-score-below-mark gnus-score-over-mark)) 'score))
11618 (let* ((article (gnus-summary-article-number))
11619 (score (assq article gnus-newsgroup-scored)))
11620 (if score (setcdr score n)
11621 (setq gnus-newsgroup-scored
11622 (cons (cons article n) gnus-newsgroup-scored))))
11623 (gnus-summary-update-line)))
11625 (defun gnus-summary-current-score ()
11626 "Return the score of the current article."
11628 (gnus-set-global-variables)
11629 (message "%s" (gnus-summary-article-score)))
11631 ;; Summary marking commands.
11633 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11634 "Mark articles which has the same subject as read, and then select the next.
11635 If UNMARK is positive, remove any kind of mark.
11636 If UNMARK is negative, tick articles."
11638 (gnus-set-global-variables)
11640 (setq unmark (prefix-numeric-value unmark)))
11642 (gnus-summary-mark-same-subject
11643 (gnus-summary-article-subject) unmark)))
11644 ;; Select next unread article. If auto-select-same mode, should
11645 ;; select the first unread article.
11646 (gnus-summary-next-article t (and gnus-auto-select-same
11647 (gnus-summary-article-subject)))
11648 (gnus-message 7 "%d article%s marked as %s"
11649 count (if (= count 1) " is" "s are")
11650 (if unmark "unread" "read"))))
11652 (defun gnus-summary-kill-same-subject (&optional unmark)
11653 "Mark articles which has the same subject as read.
11654 If UNMARK is positive, remove any kind of mark.
11655 If UNMARK is negative, tick articles."
11657 (gnus-set-global-variables)
11659 (setq unmark (prefix-numeric-value unmark)))
11661 (gnus-summary-mark-same-subject
11662 (gnus-summary-article-subject) unmark)))
11663 ;; If marked as read, go to next unread subject.
11665 ;; Go to next unread subject.
11666 (gnus-summary-next-subject 1 t))
11667 (gnus-message 7 "%d articles are marked as %s"
11668 count (if unmark "unread" "read"))))
11670 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11671 "Mark articles with same SUBJECT as read, and return marked number.
11672 If optional argument UNMARK is positive, remove any kinds of marks.
11673 If optional argument UNMARK is negative, mark articles as unread instead."
11677 ((null unmark) ; Mark as read.
11680 (gnus-summary-mark-article-as-read gnus-killed-mark)
11681 (gnus-summary-show-thread) t)
11682 (gnus-summary-find-subject subject))
11683 (setq count (1+ count))))
11684 ((> unmark 0) ; Tick.
11687 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11688 (gnus-summary-show-thread) t)
11689 (gnus-summary-find-subject subject))
11690 (setq count (1+ count))))
11691 (t ; Mark as unread.
11694 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11695 (gnus-summary-show-thread) t)
11696 (gnus-summary-find-subject subject))
11697 (setq count (1+ count)))))
11698 (gnus-set-mode-line 'summary)
11699 ;; Return the number of marked articles.
11702 (defun gnus-summary-mark-as-processable (n &optional unmark)
11703 "Set the process mark on the next N articles.
11704 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11705 the process mark instead. The difference between N and the actual
11706 number of articles marked is returned."
11708 (gnus-set-global-variables)
11709 (let ((backward (< n 0))
11714 (gnus-summary-remove-process-mark
11715 (gnus-summary-article-number))
11716 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11717 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11719 (if (/= 0 n) (gnus-message 7 "No more articles"))
11720 (gnus-summary-recenter)
11721 (gnus-summary-position-point)
11724 (defun gnus-summary-unmark-as-processable (n)
11725 "Remove the process mark from the next N articles.
11726 If N is negative, mark backward instead. The difference between N and
11727 the actual number of articles marked is returned."
11729 (gnus-set-global-variables)
11730 (gnus-summary-mark-as-processable n t))
11732 (defun gnus-summary-unmark-all-processable ()
11733 "Remove the process mark from all articles."
11735 (gnus-set-global-variables)
11737 (while gnus-newsgroup-processable
11738 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11739 (gnus-summary-position-point))
11741 (defun gnus-summary-mark-as-expirable (n)
11742 "Mark N articles forward as expirable.
11743 If N is negative, mark backward instead. The difference between N and
11744 the actual number of articles marked is returned."
11746 (gnus-set-global-variables)
11747 (gnus-summary-mark-forward n gnus-expirable-mark))
11749 (defun gnus-summary-mark-article-as-replied (article)
11750 "Mark ARTICLE replied and update the summary line."
11751 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11752 (let ((buffer-read-only nil))
11753 (when (gnus-summary-goto-subject article)
11754 (gnus-summary-update-secondary-mark article))))
11756 (defun gnus-summary-set-bookmark (article)
11757 "Set a bookmark in current article."
11758 (interactive (list (gnus-summary-article-number)))
11759 (gnus-set-global-variables)
11760 (if (or (not (get-buffer gnus-article-buffer))
11761 (not gnus-current-article)
11762 (not gnus-article-current)
11763 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11764 (error "No current article selected"))
11765 ;; Remove old bookmark, if one exists.
11766 (let ((old (assq article gnus-newsgroup-bookmarks)))
11767 (if old (setq gnus-newsgroup-bookmarks
11768 (delq old gnus-newsgroup-bookmarks))))
11769 ;; Set the new bookmark, which is on the form
11770 ;; (article-number . line-number-in-body).
11771 (setq gnus-newsgroup-bookmarks
11775 (set-buffer gnus-article-buffer)
11779 (goto-char (point-min))
11780 (search-forward "\n\n" nil t)
11783 gnus-newsgroup-bookmarks))
11784 (gnus-message 6 "A bookmark has been added to the current article."))
11786 (defun gnus-summary-remove-bookmark (article)
11787 "Remove the bookmark from the current article."
11788 (interactive (list (gnus-summary-article-number)))
11789 (gnus-set-global-variables)
11790 ;; Remove old bookmark, if one exists.
11791 (let ((old (assq article gnus-newsgroup-bookmarks)))
11794 (setq gnus-newsgroup-bookmarks
11795 (delq old gnus-newsgroup-bookmarks))
11796 (gnus-message 6 "Removed bookmark."))
11797 (gnus-message 6 "No bookmark in current article."))))
11799 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11800 (defun gnus-summary-mark-as-dormant (n)
11801 "Mark N articles forward as dormant.
11802 If N is negative, mark backward instead. The difference between N and
11803 the actual number of articles marked is returned."
11805 (gnus-set-global-variables)
11806 (gnus-summary-mark-forward n gnus-dormant-mark))
11808 (defun gnus-summary-set-process-mark (article)
11809 "Set the process mark on ARTICLE and update the summary line."
11810 (setq gnus-newsgroup-processable
11812 (delq article gnus-newsgroup-processable)))
11813 (when (gnus-summary-goto-subject article)
11814 (gnus-summary-show-thread)
11815 (gnus-summary-update-secondary-mark article)))
11817 (defun gnus-summary-remove-process-mark (article)
11818 "Remove the process mark from ARTICLE and update the summary line."
11819 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11820 (when (gnus-summary-goto-subject article)
11821 (gnus-summary-show-thread)
11822 (gnus-summary-update-secondary-mark article)))
11824 (defun gnus-summary-set-saved-mark (article)
11825 "Set the process mark on ARTICLE and update the summary line."
11826 (push article gnus-newsgroup-saved)
11827 (when (gnus-summary-goto-subject article)
11828 (gnus-summary-update-secondary-mark article)))
11830 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11831 "Mark N articles as read forwards.
11832 If N is negative, mark backwards instead.
11833 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11835 The difference between N and the actual number of articles marked is
11838 (gnus-set-global-variables)
11839 (let ((backward (< n 0))
11840 (gnus-summary-goto-unread
11841 (and gnus-summary-goto-unread
11842 (not (eq gnus-summary-goto-unread 'never))
11843 (not (memq mark (list gnus-unread-mark
11844 gnus-ticked-mark gnus-dormant-mark)))))
11846 (mark (or mark gnus-del-mark)))
11847 (while (and (> n 0)
11848 (gnus-summary-mark-article nil mark no-expire)
11849 (zerop (gnus-summary-next-subject
11851 (and gnus-summary-goto-unread
11852 (not (eq gnus-summary-goto-unread 'never)))
11855 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11856 (gnus-summary-recenter)
11857 (gnus-summary-position-point)
11858 (gnus-set-mode-line 'summary)
11861 (defun gnus-summary-mark-article-as-read (mark)
11862 "Mark the current article quickly as read with MARK."
11863 (let ((article (gnus-summary-article-number)))
11864 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11865 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11866 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11867 (setq gnus-newsgroup-reads
11868 (cons (cons article mark) gnus-newsgroup-reads))
11869 ;; Possibly remove from cache, if that is used.
11870 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11871 ;; Allow the backend to change the mark.
11872 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11873 ;; Check for auto-expiry.
11874 (when (and gnus-newsgroup-auto-expire
11875 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11876 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11877 (= mark gnus-ancient-mark)
11878 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11879 (setq mark gnus-expirable-mark)
11880 (push article gnus-newsgroup-expirable))
11881 ;; Set the mark in the buffer.
11882 (gnus-summary-update-mark mark 'unread)
11885 (defun gnus-summary-mark-article-as-unread (mark)
11886 "Mark the current article quickly as unread with MARK."
11887 (let ((article (gnus-summary-article-number)))
11888 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11889 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11890 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11891 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11892 (cond ((= mark gnus-ticked-mark)
11893 (push article gnus-newsgroup-marked))
11894 ((= mark gnus-dormant-mark)
11895 (push article gnus-newsgroup-dormant))
11897 (push article gnus-newsgroup-unreads)))
11898 (setq gnus-newsgroup-reads
11899 (delq (assq article gnus-newsgroup-reads)
11900 gnus-newsgroup-reads))
11902 ;; See whether the article is to be put in the cache.
11903 (and gnus-use-cache
11904 (vectorp (gnus-summary-article-header article))
11906 (gnus-cache-possibly-enter-article
11907 gnus-newsgroup-name article
11908 (gnus-summary-article-header article)
11909 (= mark gnus-ticked-mark)
11910 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11913 (gnus-summary-update-mark mark 'unread)
11916 (defun gnus-summary-mark-article (&optional article mark no-expire)
11917 "Mark ARTICLE with MARK. MARK can be any character.
11918 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11919 `??' (dormant) and `?E' (expirable).
11920 If MARK is nil, then the default character `?D' is used.
11921 If ARTICLE is nil, then the article on the current line will be
11923 ;; The mark might be a string.
11924 (and (stringp mark)
11925 (setq mark (aref mark 0)))
11926 ;; If no mark is given, then we check auto-expiring.
11927 (and (not no-expire)
11928 gnus-newsgroup-auto-expire
11930 (and (numberp mark)
11931 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11932 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11933 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11934 (setq mark gnus-expirable-mark))
11935 (let* ((mark (or mark gnus-del-mark))
11936 (article (or article (gnus-summary-article-number))))
11937 (or article (error "No article on current line"))
11938 (if (or (= mark gnus-unread-mark)
11939 (= mark gnus-ticked-mark)
11940 (= mark gnus-dormant-mark))
11941 (gnus-mark-article-as-unread article mark)
11942 (gnus-mark-article-as-read article mark))
11944 ;; See whether the article is to be put in the cache.
11945 (and gnus-use-cache
11946 (not (= mark gnus-canceled-mark))
11947 (vectorp (gnus-summary-article-header article))
11949 (gnus-cache-possibly-enter-article
11950 gnus-newsgroup-name article
11951 (gnus-summary-article-header article)
11952 (= mark gnus-ticked-mark)
11953 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11955 (if (gnus-summary-goto-subject article nil t)
11956 (let ((buffer-read-only nil))
11957 (gnus-summary-show-thread)
11959 (gnus-summary-update-mark mark 'unread)
11962 (defun gnus-summary-update-secondary-mark (article)
11963 "Update the secondary (read, process, cache) mark."
11964 (gnus-summary-update-mark
11965 (cond ((memq article gnus-newsgroup-processable)
11967 ((memq article gnus-newsgroup-cached)
11969 ((memq article gnus-newsgroup-replied)
11971 ((memq article gnus-newsgroup-saved)
11973 (t gnus-unread-mark))
11975 (when (gnus-visual-p 'summary-highlight 'highlight)
11976 (run-hooks 'gnus-summary-update-hook))
11979 (defun gnus-summary-update-mark (mark type)
11980 (beginning-of-line)
11981 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11982 (buffer-read-only nil))
11984 ;; Go to the right position on the line.
11985 (forward-char forward)
11986 ;; Replace the old mark with the new mark.
11987 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11988 ;; Optionally update the marks by some user rule.
11989 (when (eq type 'unread)
11990 (gnus-data-set-mark
11991 (gnus-data-find (gnus-summary-article-number)) mark)
11992 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11994 (defun gnus-mark-article-as-read (article &optional mark)
11995 "Enter ARTICLE in the pertinent lists and remove it from others."
11996 ;; Make the article expirable.
11997 (let ((mark (or mark gnus-del-mark)))
11998 (if (= mark gnus-expirable-mark)
11999 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12000 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12001 ;; Remove from unread and marked lists.
12002 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12003 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12004 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12005 (push (cons article mark) gnus-newsgroup-reads)
12006 ;; Possibly remove from cache, if that is used.
12007 (when gnus-use-cache
12008 (gnus-cache-enter-remove-article article))))
12010 (defun gnus-mark-article-as-unread (article &optional mark)
12011 "Enter ARTICLE in the pertinent lists and remove it from others."
12012 (let ((mark (or mark gnus-ticked-mark)))
12013 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12014 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12015 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12016 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12017 (cond ((= mark gnus-ticked-mark)
12018 (push article gnus-newsgroup-marked))
12019 ((= mark gnus-dormant-mark)
12020 (push article gnus-newsgroup-dormant))
12022 (push article gnus-newsgroup-unreads)))
12023 (setq gnus-newsgroup-reads
12024 (delq (assq article gnus-newsgroup-reads)
12025 gnus-newsgroup-reads))))
12027 (defalias 'gnus-summary-mark-as-unread-forward
12028 'gnus-summary-tick-article-forward)
12029 (make-obsolete 'gnus-summary-mark-as-unread-forward
12030 'gnus-summary-tick-article-forward)
12031 (defun gnus-summary-tick-article-forward (n)
12032 "Tick N articles forwards.
12033 If N is negative, tick backwards instead.
12034 The difference between N and the number of articles ticked is returned."
12036 (gnus-summary-mark-forward n gnus-ticked-mark))
12038 (defalias 'gnus-summary-mark-as-unread-backward
12039 'gnus-summary-tick-article-backward)
12040 (make-obsolete 'gnus-summary-mark-as-unread-backward
12041 'gnus-summary-tick-article-backward)
12042 (defun gnus-summary-tick-article-backward (n)
12043 "Tick N articles backwards.
12044 The difference between N and the number of articles ticked is returned."
12046 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12048 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12049 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12050 (defun gnus-summary-tick-article (&optional article clear-mark)
12051 "Mark current article as unread.
12052 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12053 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12055 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12056 gnus-ticked-mark)))
12058 (defun gnus-summary-mark-as-read-forward (n)
12059 "Mark N articles as read forwards.
12060 If N is negative, mark backwards instead.
12061 The difference between N and the actual number of articles marked is
12064 (gnus-summary-mark-forward n gnus-del-mark t))
12066 (defun gnus-summary-mark-as-read-backward (n)
12067 "Mark the N articles as read backwards.
12068 The difference between N and the actual number of articles marked is
12071 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12073 (defun gnus-summary-mark-as-read (&optional article mark)
12074 "Mark current article as read.
12075 ARTICLE specifies the article to be marked as read.
12076 MARK specifies a string to be inserted at the beginning of the line."
12077 (gnus-summary-mark-article article mark))
12079 (defun gnus-summary-clear-mark-forward (n)
12080 "Clear marks from N articles forward.
12081 If N is negative, clear backward instead.
12082 The difference between N and the number of marks cleared is returned."
12084 (gnus-summary-mark-forward n gnus-unread-mark))
12086 (defun gnus-summary-clear-mark-backward (n)
12087 "Clear marks from N articles backward.
12088 The difference between N and the number of marks cleared is returned."
12090 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12092 (defun gnus-summary-mark-unread-as-read ()
12093 "Intended to be used by `gnus-summary-mark-article-hook'."
12094 (when (memq gnus-current-article gnus-newsgroup-unreads)
12095 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12097 (defun gnus-summary-mark-read-and-unread-as-read ()
12098 "Intended to be used by `gnus-summary-mark-article-hook'."
12099 (let ((mark (gnus-summary-article-mark)))
12100 (when (or (gnus-unread-mark-p mark)
12101 (gnus-read-mark-p mark))
12102 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12104 (defun gnus-summary-mark-region-as-read (point mark all)
12105 "Mark all unread articles between point and mark as read.
12106 If given a prefix, mark all articles between point and mark as read,
12107 even ticked and dormant ones."
12108 (interactive "r\nP")
12112 (beginning-of-line)
12117 (memq (setq article (gnus-summary-article-number))
12118 gnus-newsgroup-unreads))
12119 (gnus-summary-mark-article article gnus-del-mark))
12121 (gnus-summary-find-next))))))
12123 (defun gnus-summary-mark-below (score mark)
12124 "Mark articles with score less than SCORE with MARK."
12125 (interactive "P\ncMark: ")
12126 (gnus-set-global-variables)
12127 (setq score (if score
12128 (prefix-numeric-value score)
12129 (or gnus-summary-default-score 0)))
12131 (set-buffer gnus-summary-buffer)
12132 (goto-char (point-min))
12135 (and (< (gnus-summary-article-score) score)
12136 (gnus-summary-mark-article nil mark))
12137 (gnus-summary-find-next)))))
12139 (defun gnus-summary-kill-below (&optional score)
12140 "Mark articles with score below SCORE as read."
12142 (gnus-set-global-variables)
12143 (gnus-summary-mark-below score gnus-killed-mark))
12145 (defun gnus-summary-clear-above (&optional score)
12146 "Clear all marks from articles with score above SCORE."
12148 (gnus-set-global-variables)
12149 (gnus-summary-mark-above score gnus-unread-mark))
12151 (defun gnus-summary-tick-above (&optional score)
12152 "Tick all articles with score above SCORE."
12154 (gnus-set-global-variables)
12155 (gnus-summary-mark-above score gnus-ticked-mark))
12157 (defun gnus-summary-mark-above (score mark)
12158 "Mark articles with score over SCORE with MARK."
12159 (interactive "P\ncMark: ")
12160 (gnus-set-global-variables)
12161 (setq score (if score
12162 (prefix-numeric-value score)
12163 (or gnus-summary-default-score 0)))
12165 (set-buffer gnus-summary-buffer)
12166 (goto-char (point-min))
12168 (if (> (gnus-summary-article-score) score)
12169 (gnus-summary-mark-article nil mark))
12171 (gnus-summary-find-next)))))
12173 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12174 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12175 (defun gnus-summary-limit-include-expunged ()
12176 "Display all the hidden articles that were expunged for low scores."
12178 (gnus-set-global-variables)
12179 (let ((buffer-read-only nil))
12180 (let ((scored gnus-newsgroup-scored)
12183 (or (gnus-summary-goto-subject (caar scored))
12184 (and (setq h (gnus-summary-article-header (caar scored)))
12185 (< (cdar scored) gnus-summary-expunge-below)
12186 (setq headers (cons h headers))))
12187 (setq scored (cdr scored)))
12188 (or headers (error "No expunged articles hidden."))
12189 (goto-char (point-min))
12190 (gnus-summary-prepare-unthreaded (nreverse headers)))
12191 (goto-char (point-min))
12192 (gnus-summary-position-point)))
12194 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12195 "Mark all articles not marked as unread in this newsgroup as read.
12196 If prefix argument ALL is non-nil, all articles are marked as read.
12197 If QUIETLY is non-nil, no questions will be asked.
12198 If TO-HERE is non-nil, it should be a point in the buffer. All
12199 articles before this point will be marked as read.
12200 The number of articles marked as read is returned."
12202 (gnus-set-global-variables)
12205 (not gnus-interactive-catchup) ;Without confirmation?
12209 "Mark absolutely all articles as read? "
12210 "Mark all unread articles as read? ")))
12212 (not gnus-newsgroup-adaptive)
12213 (not gnus-newsgroup-auto-expire))
12216 (setq gnus-newsgroup-marked nil
12217 gnus-newsgroup-dormant nil))
12218 (setq gnus-newsgroup-unreads nil))
12219 ;; We actually mark all articles as canceled, which we
12220 ;; have to do when using auto-expiry or adaptive scoring.
12221 (gnus-summary-show-all-threads)
12222 (if (gnus-summary-first-subject (not all))
12224 (if to-here (< (point) to-here) t)
12225 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12226 (gnus-summary-find-next (not all)))))
12228 (setq gnus-newsgroup-unreads nil))
12229 (gnus-set-mode-line 'summary)))
12230 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12231 (if (and (not to-here) (eq 'nnvirtual (car method)))
12232 (nnvirtual-catchup-group
12233 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12234 (gnus-summary-position-point)))
12236 (defun gnus-summary-catchup-to-here (&optional all)
12237 "Mark all unticked articles before the current one as read.
12238 If ALL is non-nil, also mark ticked and dormant articles as read."
12240 (gnus-set-global-variables)
12242 (let ((beg (point)))
12243 ;; We check that there are unread articles.
12244 (when (or all (gnus-summary-find-prev))
12245 (gnus-summary-catchup all t beg))))
12246 (gnus-summary-position-point))
12248 (defun gnus-summary-catchup-all (&optional quietly)
12249 "Mark all articles in this newsgroup as read."
12251 (gnus-set-global-variables)
12252 (gnus-summary-catchup t quietly))
12254 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12255 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12256 If prefix argument ALL is non-nil, all articles are marked as read."
12258 (gnus-set-global-variables)
12259 (gnus-summary-catchup all quietly nil 'fast)
12260 ;; Select next newsgroup or exit.
12261 (if (eq gnus-auto-select-next 'quietly)
12262 (gnus-summary-next-group nil)
12263 (gnus-summary-exit)))
12265 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12266 "Mark all articles in this newsgroup as read, and then exit."
12268 (gnus-set-global-variables)
12269 (gnus-summary-catchup-and-exit t quietly))
12271 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12272 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12273 "Mark all articles in this group as read and select the next group.
12274 If given a prefix, mark all articles, unread as well as ticked, as
12277 (gnus-set-global-variables)
12279 (gnus-summary-catchup all))
12280 (gnus-summary-next-article t nil nil t))
12282 ;; Thread-based commands.
12284 (defun gnus-summary-articles-in-thread (&optional article)
12285 "Return a list of all articles in the current thread.
12286 If ARTICLE is non-nil, return all articles in the thread that starts
12287 with that article."
12288 (let* ((article (or article (gnus-summary-article-number)))
12289 (data (gnus-data-find-list article))
12290 (top-level (gnus-data-level (car data)))
12292 (cond ((null gnus-thread-operation-ignore-subject)
12293 (gnus-simplify-subject-re
12294 (mail-header-subject (gnus-data-header (car data)))))
12295 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12296 (gnus-simplify-subject-fuzzy
12297 (mail-header-subject (gnus-data-header (car data)))))
12301 () ; This article doesn't exist.
12303 (and (or (not top-subject)
12304 (string= top-subject
12305 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12306 (gnus-simplify-subject-fuzzy
12307 (mail-header-subject
12308 (gnus-data-header (car data))))
12309 (gnus-simplify-subject-re
12310 (mail-header-subject
12311 (gnus-data-header (car data)))))))
12312 (setq articles (cons (gnus-data-number (car data)) articles)))
12313 (if (and (setq data (cdr data))
12314 (> (gnus-data-level (car data)) top-level))
12317 ;; Return the list of articles.
12318 (nreverse articles))))
12320 (defun gnus-summary-rethread-current ()
12321 "Rethread the thread the current article is part of."
12323 (gnus-set-global-variables)
12324 (let* ((gnus-show-threads t)
12325 (article (gnus-summary-article-number))
12326 (id (mail-header-id (gnus-summary-article-header)))
12327 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12329 (error "No article on the current line"))
12330 (gnus-rebuild-thread id)
12331 (gnus-summary-goto-subject article)))
12333 (defun gnus-summary-reparent-thread ()
12334 "Make current article child of the marked (or previous) article.
12336 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12337 is non-nil or the Subject: of both articles are the same."
12339 (or (not (gnus-group-read-only-p))
12340 (error "The current newsgroup does not support article editing."))
12341 (or (<= (length gnus-newsgroup-processable) 1)
12342 (error "No more than one article may be marked."))
12343 (save-window-excursion
12344 (let ((gnus-article-buffer " *reparent*")
12345 (current-article (gnus-summary-article-number))
12346 ; first grab the marked article, otherwise one line up.
12347 (parent-article (if (not (null gnus-newsgroup-processable))
12348 (car gnus-newsgroup-processable)
12350 (if (eq (forward-line -1) 0)
12351 (gnus-summary-article-number)
12352 (error "Beginning of summary buffer."))))))
12353 (or (not (eq current-article parent-article))
12354 (error "An article may not be self-referential."))
12355 (let ((message-id (mail-header-id
12356 (gnus-summary-article-header parent-article))))
12357 (or (and message-id (not (equal message-id "")))
12358 (error "No message-id in desired parent."))
12359 (gnus-summary-select-article t t nil current-article)
12360 (set-buffer gnus-article-buffer)
12361 (setq buffer-read-only nil)
12362 (let ((buf (format "%s" (buffer-string))))
12365 (goto-char (point-min))
12366 (if (search-forward-regexp "^References: " nil t)
12367 (insert message-id " " )
12368 (insert "References: " message-id "\n"))
12369 (or (gnus-request-replace-article current-article
12370 (car gnus-article-current)
12371 gnus-article-buffer)
12372 (error "Couldn't replace article."))
12373 (set-buffer gnus-summary-buffer)
12374 (gnus-summary-unmark-all-processable)
12375 (gnus-summary-rethread-current)
12376 (message "Article %d is now the child of article %d."
12377 current-article parent-article)))))
12379 (defun gnus-summary-toggle-threads (&optional arg)
12380 "Toggle showing conversation threads.
12381 If ARG is positive number, turn showing conversation threads on."
12383 (gnus-set-global-variables)
12384 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12385 (setq gnus-show-threads
12386 (if (null arg) (not gnus-show-threads)
12387 (> (prefix-numeric-value arg) 0)))
12388 (gnus-summary-prepare)
12389 (gnus-summary-goto-subject current)
12390 (gnus-summary-position-point)))
12392 (defun gnus-summary-show-all-threads ()
12393 "Show all threads."
12395 (gnus-set-global-variables)
12397 (let ((buffer-read-only nil))
12398 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12399 (gnus-summary-position-point))
12401 (defun gnus-summary-show-thread ()
12402 "Show thread subtrees.
12403 Returns nil if no thread was there to be shown."
12405 (gnus-set-global-variables)
12406 (let ((buffer-read-only nil)
12408 ;; first goto end then to beg, to have point at beg after let
12409 (end (progn (end-of-line) (point)))
12410 (beg (progn (beginning-of-line) (point))))
12412 ;; Any hidden lines here?
12413 (search-forward "\r" end t)
12414 (subst-char-in-region beg end ?\^M ?\n t)
12416 (gnus-summary-position-point))))
12418 (defun gnus-summary-hide-all-threads ()
12419 "Hide all thread subtrees."
12421 (gnus-set-global-variables)
12423 (goto-char (point-min))
12424 (gnus-summary-hide-thread)
12425 (while (zerop (gnus-summary-next-thread 1 t))
12426 (gnus-summary-hide-thread)))
12427 (gnus-summary-position-point))
12429 (defun gnus-summary-hide-thread ()
12430 "Hide thread subtrees.
12431 Returns nil if no threads were there to be hidden."
12433 (gnus-set-global-variables)
12434 (let ((buffer-read-only nil)
12436 (article (gnus-summary-article-number)))
12438 ;; Go forward until either the buffer ends or the subthread
12440 (when (and (not (eobp))
12441 (or (zerop (gnus-summary-next-thread 1 t))
12442 (goto-char (point-max))))
12444 (if (and (> (point) start)
12445 (search-backward "\n" start t))
12447 (subst-char-in-region start (point) ?\n ?\^M)
12448 (gnus-summary-goto-subject article))
12451 ;;(gnus-summary-position-point)
12454 (defun gnus-summary-go-to-next-thread (&optional previous)
12455 "Go to the same level (or less) next thread.
12456 If PREVIOUS is non-nil, go to previous thread instead.
12457 Return the article number moved to, or nil if moving was impossible."
12458 (let ((level (gnus-summary-thread-level))
12459 (way (if previous -1 1))
12462 (while (and (not (eobp))
12463 (< level (gnus-summary-thread-level)))
12464 (forward-line way))
12471 (gnus-summary-article-number)
12472 (goto-char beg)))))
12474 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12475 "Go to the same level (or less) next thread.
12476 If PREVIOUS is non-nil, go to previous thread instead.
12477 Return the article number moved to, or nil if moving was impossible."
12478 (if (and (eq gnus-summary-make-false-root 'dummy)
12479 (gnus-summary-article-intangible-p))
12480 (let ((beg (point)))
12481 (while (and (zerop (forward-line 1))
12482 (not (gnus-summary-article-intangible-p))
12483 (not (zerop (save-excursion
12484 (gnus-summary-thread-level))))))
12490 (let* ((level (gnus-summary-thread-level))
12491 (article (gnus-summary-article-number))
12492 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12495 (if (<= (gnus-data-level (car data)) level)
12496 (setq oart (gnus-data-number (car data))
12498 (setq data (cdr data))))
12500 (gnus-summary-goto-subject oart)))))
12502 (defun gnus-summary-next-thread (n &optional silent)
12503 "Go to the same level next N'th thread.
12504 If N is negative, search backward instead.
12505 Returns the difference between N and the number of skips actually
12508 If SILENT, don't output messages."
12510 (gnus-set-global-variables)
12511 (let ((backward (< n 0))
12514 (while (and (> n 0)
12515 (gnus-summary-go-to-next-thread backward))
12518 (gnus-summary-position-point))
12519 (when (and (not silent) (/= 0 n))
12520 (gnus-message 7 "No more threads"))
12523 (defun gnus-summary-prev-thread (n)
12524 "Go to the same level previous N'th thread.
12525 Returns the difference between N and the number of skips actually
12528 (gnus-set-global-variables)
12529 (gnus-summary-next-thread (- n)))
12531 (defun gnus-summary-go-down-thread ()
12532 "Go down one level in the current thread."
12533 (let ((children (gnus-summary-article-children)))
12535 (gnus-summary-goto-subject (car children)))))
12537 (defun gnus-summary-go-up-thread ()
12538 "Go up one level in the current thread."
12539 (let ((parent (gnus-summary-article-parent)))
12541 (gnus-summary-goto-subject parent))))
12543 (defun gnus-summary-down-thread (n)
12544 "Go down thread N steps.
12545 If N is negative, go up instead.
12546 Returns the difference between N and how many steps down that were
12549 (gnus-set-global-variables)
12552 (while (and (> n 0)
12553 (if up (gnus-summary-go-up-thread)
12554 (gnus-summary-go-down-thread)))
12556 (gnus-summary-position-point)
12557 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12560 (defun gnus-summary-up-thread (n)
12561 "Go up thread N steps.
12562 If N is negative, go up instead.
12563 Returns the difference between N and how many steps down that were
12566 (gnus-set-global-variables)
12567 (gnus-summary-down-thread (- n)))
12569 (defun gnus-summary-top-thread ()
12570 "Go to the top of the thread."
12572 (gnus-set-global-variables)
12573 (while (gnus-summary-go-up-thread))
12574 (gnus-summary-article-number))
12576 (defun gnus-summary-kill-thread (&optional unmark)
12577 "Mark articles under current thread as read.
12578 If the prefix argument is positive, remove any kinds of marks.
12579 If the prefix argument is negative, tick articles instead."
12581 (gnus-set-global-variables)
12583 (setq unmark (prefix-numeric-value unmark)))
12584 (let ((articles (gnus-summary-articles-in-thread)))
12586 ;; Expand the thread.
12587 (gnus-summary-show-thread)
12588 ;; Mark all the articles.
12590 (gnus-summary-goto-subject (car articles))
12591 (cond ((null unmark)
12592 (gnus-summary-mark-article-as-read gnus-killed-mark))
12594 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12596 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12597 (setq articles (cdr articles))))
12598 ;; Hide killed subtrees.
12600 gnus-thread-hide-killed
12601 (gnus-summary-hide-thread))
12602 ;; If marked as read, go to next unread subject.
12604 ;; Go to next unread subject.
12605 (gnus-summary-next-subject 1 t)))
12606 (gnus-set-mode-line 'summary))
12608 ;; Summary sorting commands
12610 (defun gnus-summary-sort-by-number (&optional reverse)
12611 "Sort summary buffer by article number.
12612 Argument REVERSE means reverse order."
12614 (gnus-summary-sort 'number reverse))
12616 (defun gnus-summary-sort-by-author (&optional reverse)
12617 "Sort summary buffer by author name alphabetically.
12618 If case-fold-search is non-nil, case of letters is ignored.
12619 Argument REVERSE means reverse order."
12621 (gnus-summary-sort 'author reverse))
12623 (defun gnus-summary-sort-by-subject (&optional reverse)
12624 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12625 If case-fold-search is non-nil, case of letters is ignored.
12626 Argument REVERSE means reverse order."
12628 (gnus-summary-sort 'subject reverse))
12630 (defun gnus-summary-sort-by-date (&optional reverse)
12631 "Sort summary buffer by date.
12632 Argument REVERSE means reverse order."
12634 (gnus-summary-sort 'date reverse))
12636 (defun gnus-summary-sort-by-score (&optional reverse)
12637 "Sort summary buffer by score.
12638 Argument REVERSE means reverse order."
12640 (gnus-summary-sort 'score reverse))
12642 (defun gnus-summary-sort (predicate reverse)
12643 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12644 (gnus-set-global-variables)
12645 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12646 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12647 (gnus-thread-sort-functions
12652 (,thread t2 t1)))))
12653 (gnus-article-sort-functions
12658 (,article t2 t1)))))
12660 (gnus-summary-prepare-hook nil))
12661 ;; We do the sorting by regenerating the threads.
12662 (gnus-summary-prepare)
12663 ;; Hide subthreads if needed.
12664 (when (and gnus-show-threads gnus-thread-hide-subtree)
12665 (gnus-summary-hide-all-threads)))
12666 ;; If in async mode, we send some info to the backend.
12667 (when gnus-newsgroup-async
12668 (gnus-request-asynchronous
12669 gnus-newsgroup-name gnus-newsgroup-data)))
12671 (defun gnus-sortable-date (date)
12672 "Make sortable string by string-lessp from DATE.
12673 Timezone package is used."
12674 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12675 (year (aref date 0))
12676 (month (aref date 1))
12677 (day (aref date 2)))
12678 (timezone-make-sortable-date
12680 (timezone-make-time-string
12681 (aref date 3) (aref date 4) (aref date 5)))))
12683 ;; Summary saving commands.
12685 (defun gnus-summary-save-article (&optional n not-saved)
12686 "Save the current article using the default saver function.
12687 If N is a positive number, save the N next articles.
12688 If N is a negative number, save the N previous articles.
12689 If N is nil and any articles have been marked with the process mark,
12690 save those articles instead.
12691 The variable `gnus-default-article-saver' specifies the saver function."
12693 (gnus-set-global-variables)
12694 (let ((articles (gnus-summary-work-articles n))
12695 file header article)
12697 (setq header (gnus-summary-article-header
12698 (setq article (pop articles))))
12699 (if (not (vectorp header))
12700 ;; This is a pseudo-article.
12701 (if (assq 'name header)
12702 (gnus-copy-file (cdr (assq 'name header)))
12703 (gnus-message 1 "Article %d is unsaveable" article))
12704 ;; This is a real article.
12705 (save-window-excursion
12706 (gnus-summary-select-article t nil nil article))
12707 (unless gnus-save-all-headers
12708 ;; Remove headers accoring to `gnus-saved-headers'.
12709 (let ((gnus-visible-headers
12710 (or gnus-saved-headers gnus-visible-headers)))
12711 (gnus-article-hide-headers nil t)))
12712 ;; Remove any X-Gnus lines.
12714 (set-buffer gnus-article-buffer)
12716 (let ((buffer-read-only nil))
12717 (nnheader-narrow-to-headers)
12718 (while (re-search-forward "^X-Gnus" nil t)
12719 (gnus-delete-line)))))
12720 (save-window-excursion
12721 (if (not gnus-default-article-saver)
12722 (error "No default saver is defined.")
12723 (setq file (funcall
12724 gnus-default-article-saver
12726 ((not gnus-prompt-before-saving)
12728 ((eq gnus-prompt-before-saving 'always)
12731 (gnus-summary-remove-process-mark article)
12733 (gnus-summary-set-saved-mark article))))
12734 (gnus-summary-position-point)
12737 (defun gnus-summary-pipe-output (&optional arg)
12738 "Pipe the current article to a subprocess.
12739 If N is a positive number, pipe the N next articles.
12740 If N is a negative number, pipe the N previous articles.
12741 If N is nil and any articles have been marked with the process mark,
12742 pipe those articles instead."
12744 (gnus-set-global-variables)
12745 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12746 (gnus-summary-save-article arg t))
12747 (gnus-configure-windows 'pipe))
12749 (defun gnus-summary-save-article-mail (&optional arg)
12750 "Append the current article to an mail file.
12751 If N is a positive number, save the N next articles.
12752 If N is a negative number, save the N previous articles.
12753 If N is nil and any articles have been marked with the process mark,
12754 save those articles instead."
12756 (gnus-set-global-variables)
12757 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12758 (gnus-summary-save-article arg)))
12760 (defun gnus-summary-save-article-rmail (&optional arg)
12761 "Append the current article to an rmail file.
12762 If N is a positive number, save the N next articles.
12763 If N is a negative number, save the N previous articles.
12764 If N is nil and any articles have been marked with the process mark,
12765 save those articles instead."
12767 (gnus-set-global-variables)
12768 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12769 (gnus-summary-save-article arg)))
12771 (defun gnus-summary-save-article-file (&optional arg)
12772 "Append the current article to a file.
12773 If N is a positive number, save the N next articles.
12774 If N is a negative number, save the N previous articles.
12775 If N is nil and any articles have been marked with the process mark,
12776 save those articles instead."
12778 (gnus-set-global-variables)
12779 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12780 (gnus-summary-save-article arg)))
12782 (defun gnus-summary-save-article-body-file (&optional arg)
12783 "Append the current article body to a file.
12784 If N is a positive number, save the N next articles.
12785 If N is a negative number, save the N previous articles.
12786 If N is nil and any articles have been marked with the process mark,
12787 save those articles instead."
12789 (gnus-set-global-variables)
12790 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12791 (gnus-summary-save-article arg)))
12793 (defun gnus-get-split-value (methods)
12794 "Return a value based on the split METHODS."
12795 (let (split-name method result match)
12798 (set-buffer gnus-original-article-buffer)
12800 (nnheader-narrow-to-headers)
12802 (goto-char (point-min))
12803 (setq method (pop methods))
12804 (setq match (car method))
12807 ;; Regular expression.
12809 (re-search-forward match nil t)
12811 ((gnus-functionp match)
12815 (setq result (funcall match gnus-newsgroup-name))))
12820 (setq result (eval match)))))
12821 (setq split-name (append (cdr method) split-name))
12822 (cond ((stringp result)
12823 (push result split-name))
12825 (setq split-name (append result split-name)))))))))
12828 (defun gnus-read-move-group-name (prompt default articles prefix)
12829 "Read a group name."
12830 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12832 (format "Where do you want to %s %s? "
12834 (if (> (length articles) 1)
12835 (format "these %d articles" (length articles))
12843 (format "(default %s) " default)
12845 gnus-active-hashtb nil nil prefix))
12846 ((= 1 (length split-name))
12847 (completing-read prom gnus-active-hashtb
12848 nil nil (cons (car split-name) 0)))
12851 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12854 (if (or (string= to-newsgroup "")
12855 (string= to-newsgroup prefix))
12856 (setq to-newsgroup (or default "")))
12857 (or (gnus-active to-newsgroup)
12858 (gnus-activate-group to-newsgroup)
12859 (error "No such group: %s" to-newsgroup)))
12862 (defun gnus-read-save-file-name (prompt default-name)
12863 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12865 ;; Let the split methods have their say.
12867 ;; No split name was found.
12870 (concat prompt " (default "
12871 (file-name-nondirectory default-name) ") ")
12872 (file-name-directory default-name)
12874 ;; A single split name was found
12875 ((= 1 (length split-name))
12877 (concat prompt " (default " (car split-name) ") ")
12878 gnus-article-save-directory
12879 (concat gnus-article-save-directory (car split-name))))
12880 ;; A list of splits was found.
12882 (setq split-name (mapcar (lambda (el) (list el))
12883 (nreverse split-name)))
12884 (let ((result (completing-read
12885 (concat prompt " ") split-name nil nil)))
12886 (concat gnus-article-save-directory
12887 (if (string= result "")
12890 ;; If we have read a directory, we append the default file name.
12891 (when (file-directory-p file)
12892 (setq file (concat (file-name-as-directory file)
12893 (file-name-nondirectory default-name))))
12894 ;; Possibly translate some charaters.
12895 (nnheader-translate-file-chars file)))
12897 (defun gnus-article-archive-name (group)
12898 "Return the first instance of an \"Archive-name\" in the current buffer."
12899 (let ((case-fold-search t))
12900 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12901 (match-string 1))))
12903 (defun gnus-summary-save-in-rmail (&optional filename)
12904 "Append this article to Rmail file.
12905 Optional argument FILENAME specifies file name.
12906 Directory to save to is default to `gnus-article-save-directory' which
12907 is initialized from the SAVEDIR environment variable."
12909 (gnus-set-global-variables)
12910 (let ((default-name
12911 (funcall gnus-rmail-save-name gnus-newsgroup-name
12912 gnus-current-headers gnus-newsgroup-last-rmail)))
12914 (cond ((eq filename 'default)
12916 (filename filename)
12917 (t (gnus-read-save-file-name
12918 "Save in rmail file:" default-name))))
12919 (gnus-make-directory (file-name-directory filename))
12920 (gnus-eval-in-buffer-window
12921 gnus-original-article-buffer
12925 (gnus-output-to-rmail filename))))
12926 ;; Remember the directory name to save articles
12927 (setq gnus-newsgroup-last-rmail filename)))
12929 (defun gnus-summary-save-in-mail (&optional filename)
12930 "Append this article to Unix mail file.
12931 Optional argument FILENAME specifies file name.
12932 Directory to save to is default to `gnus-article-save-directory' which
12933 is initialized from the SAVEDIR environment variable."
12935 (gnus-set-global-variables)
12936 (let ((default-name
12937 (funcall gnus-mail-save-name gnus-newsgroup-name
12938 gnus-current-headers gnus-newsgroup-last-mail)))
12940 (cond ((eq filename 'default)
12942 (filename filename)
12943 (t (gnus-read-save-file-name
12944 "Save in Unix mail file:" default-name))))
12946 (expand-file-name filename
12948 (file-name-directory default-name))))
12949 (gnus-make-directory (file-name-directory filename))
12950 (gnus-eval-in-buffer-window
12951 gnus-original-article-buffer
12955 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12956 (gnus-output-to-rmail filename)
12957 (let ((mail-use-rfc822 t))
12958 (rmail-output filename 1 t t))))))
12959 ;; Remember the directory name to save articles.
12960 (setq gnus-newsgroup-last-mail filename)))
12962 (defun gnus-summary-save-in-file (&optional filename)
12963 "Append this article to file.
12964 Optional argument FILENAME specifies file name.
12965 Directory to save to is default to `gnus-article-save-directory' which
12966 is initialized from the SAVEDIR environment variable."
12968 (gnus-set-global-variables)
12969 (let ((default-name
12970 (funcall gnus-file-save-name gnus-newsgroup-name
12971 gnus-current-headers gnus-newsgroup-last-file)))
12973 (cond ((eq filename 'default)
12975 (filename filename)
12976 (t (gnus-read-save-file-name
12977 "Save in file:" default-name))))
12978 (gnus-make-directory (file-name-directory filename))
12979 (gnus-eval-in-buffer-window
12980 gnus-original-article-buffer
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-body-in-file (&optional filename)
12989 "Append this article body to a file.
12990 Optional argument FILENAME specifies file name.
12991 The directory to save in defaults to `gnus-article-save-directory' which
12992 is initialized from the SAVEDIR environment variable."
12994 (gnus-set-global-variables)
12995 (let ((default-name
12996 (funcall gnus-file-save-name gnus-newsgroup-name
12997 gnus-current-headers gnus-newsgroup-last-file)))
12999 (cond ((eq filename 'default)
13001 (filename filename)
13002 (t (gnus-read-save-file-name
13003 "Save body in file:" default-name))))
13004 (gnus-make-directory (file-name-directory filename))
13005 (gnus-eval-in-buffer-window
13006 gnus-article-buffer
13010 (goto-char (point-min))
13011 (and (search-forward "\n\n" nil t)
13012 (narrow-to-region (point) (point-max)))
13013 (gnus-output-to-file filename))))
13014 ;; Remember the directory name to save articles.
13015 (setq gnus-newsgroup-last-file filename)))
13017 (defun gnus-summary-save-in-pipe (&optional command)
13018 "Pipe this article to subprocess."
13020 (gnus-set-global-variables)
13022 (cond ((eq command 'default)
13023 gnus-last-shell-command)
13025 (t (read-string "Shell command on article: "
13026 gnus-last-shell-command))))
13027 (if (string-equal command "")
13028 (setq command gnus-last-shell-command))
13029 (gnus-eval-in-buffer-window
13030 gnus-article-buffer
13033 (shell-command-on-region (point-min) (point-max) command nil)))
13034 (setq gnus-last-shell-command command))
13036 ;; Summary extract commands
13038 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13039 (let ((buffer-read-only nil)
13040 (article (gnus-summary-article-number))
13042 (or (gnus-summary-goto-subject article)
13043 (error (format "No such article: %d" article)))
13044 (gnus-summary-position-point)
13045 ;; If all commands are to be bunched up on one line, we collect
13047 (if gnus-view-pseudos-separately
13049 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13052 (setq action (cdr (assq 'action (car ps))))
13053 (setq files (list (cdr (assq 'name (car ps)))))
13054 (while (and ps (cdr ps)
13055 (string= (or action "1")
13056 (or (cdr (assq 'action (cadr ps))) "2")))
13057 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13058 (setcdr ps (cddr ps)))
13061 (if (not (string-match "%s" action))
13062 (setq files (cons " " files)))
13063 (setq files (cons " " files))
13064 (and (assq 'execute (car ps))
13065 (setcdr (assq 'execute (car ps))
13066 (funcall (if (string-match "%s" action)
13069 (mapconcat (lambda (f) f) files " ")))))
13070 (setq ps (cdr ps)))))
13071 (if (and gnus-view-pseudos (not not-view))
13073 (and (assq 'execute (car pslist))
13074 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13075 (eq gnus-view-pseudos 'not-confirm)))
13076 (setq pslist (cdr pslist)))
13079 (setq after-article (or (cdr (assq 'article (car pslist)))
13080 (gnus-summary-article-number)))
13081 (gnus-summary-goto-subject after-article)
13084 (insert " " (file-name-nondirectory
13085 (cdr (assq 'name (car pslist))))
13086 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13088 (forward-line -1) ; back to `b'
13089 (add-text-properties
13090 b e (list 'gnus-number gnus-reffed-article-number
13091 gnus-mouse-face-prop gnus-mouse-face))
13093 after-article gnus-reffed-article-number
13094 gnus-unread-mark b (car pslist) 0 (- e b))
13095 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13096 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13097 (setq pslist (cdr pslist)))))))
13099 (defun gnus-pseudos< (p1 p2)
13100 (let ((c1 (cdr (assq 'action p1)))
13101 (c2 (cdr (assq 'action p2))))
13102 (and c1 c2 (string< c1 c2))))
13104 (defun gnus-request-pseudo-article (props)
13105 (cond ((assq 'execute props)
13106 (gnus-execute-command (cdr (assq 'execute props)))))
13107 (let ((gnus-current-article (gnus-summary-article-number)))
13108 (run-hooks 'gnus-mark-article-hook)))
13110 (defun gnus-execute-command (command &optional automatic)
13112 (gnus-article-setup-buffer)
13113 (set-buffer gnus-article-buffer)
13114 (let ((command (if automatic command (read-string "Command: " command)))
13115 (buffer-read-only nil))
13117 (insert "$ " command "\n\n")
13118 (if gnus-view-pseudo-asynchronously
13119 (start-process "gnus-execute" nil "sh" "-c" command)
13120 (call-process "sh" nil t nil "-c" command)))))
13122 (defun gnus-copy-file (file &optional to)
13125 (list (read-file-name "Copy file: " default-directory)
13126 (read-file-name "Copy file to: " default-directory)))
13127 (gnus-set-global-variables)
13128 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13129 (and (file-directory-p to)
13130 (setq to (concat (file-name-as-directory to)
13131 (file-name-nondirectory file))))
13132 (copy-file file to))
13134 ;; Summary kill commands.
13136 (defun gnus-summary-edit-global-kill (article)
13137 "Edit the \"global\" kill file."
13138 (interactive (list (gnus-summary-article-number)))
13139 (gnus-set-global-variables)
13140 (gnus-group-edit-global-kill article))
13142 (defun gnus-summary-edit-local-kill ()
13143 "Edit a local kill file applied to the current newsgroup."
13145 (gnus-set-global-variables)
13146 (setq gnus-current-headers (gnus-summary-article-header))
13147 (gnus-set-global-variables)
13148 (gnus-group-edit-local-kill
13149 (gnus-summary-article-number) gnus-newsgroup-name))
13153 ;;; Gnus article mode
13156 (put 'gnus-article-mode 'mode-class 'special)
13158 (if gnus-article-mode-map
13160 (setq gnus-article-mode-map (make-keymap))
13161 (suppress-keymap gnus-article-mode-map)
13163 (gnus-define-keys gnus-article-mode-map
13164 " " gnus-article-goto-next-page
13165 "\177" gnus-article-goto-prev-page
13166 [delete] gnus-article-goto-prev-page
13167 "\C-c^" gnus-article-refer-article
13168 "h" gnus-article-show-summary
13169 "s" gnus-article-show-summary
13170 "\C-c\C-m" gnus-article-mail
13171 "?" gnus-article-describe-briefly
13172 gnus-mouse-2 gnus-article-push-button
13173 "\r" gnus-article-press-button
13174 "\t" gnus-article-next-button
13175 "\M-\t" gnus-article-prev-button
13176 "\C-c\C-b" gnus-bug)
13178 (substitute-key-definition
13179 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13181 (defun gnus-article-mode ()
13182 "Major mode for displaying an article.
13184 All normal editing commands are switched off.
13186 The following commands are available:
13188 \\<gnus-article-mode-map>
13189 \\[gnus-article-next-page]\t Scroll the article one page forwards
13190 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13191 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13192 \\[gnus-article-show-summary]\t Display the summary buffer
13193 \\[gnus-article-mail]\t Send a reply to the address near point
13194 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13195 \\[gnus-info-find-node]\t Go to the Gnus info node"
13197 (when (and menu-bar-mode
13198 (gnus-visual-p 'article-menu 'menu))
13199 (gnus-article-make-menu-bar))
13200 (kill-all-local-variables)
13201 (gnus-simplify-mode-line)
13202 (setq mode-name "Article")
13203 (setq major-mode 'gnus-article-mode)
13204 (make-local-variable 'minor-mode-alist)
13205 (or (assq 'gnus-show-mime minor-mode-alist)
13206 (setq minor-mode-alist
13207 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13208 (use-local-map gnus-article-mode-map)
13209 (make-local-variable 'page-delimiter)
13210 (setq page-delimiter gnus-page-delimiter)
13211 (buffer-disable-undo (current-buffer))
13212 (setq buffer-read-only t) ;Disable modification
13213 (run-hooks 'gnus-article-mode-hook))
13215 (defun gnus-article-setup-buffer ()
13216 "Initialize the article buffer."
13217 (let* ((name (if gnus-single-article-buffer "*Article*"
13218 (concat "*Article " gnus-newsgroup-name "*")))
13220 (progn (string-match "\\*Article" name)
13221 (concat " *Original Article"
13222 (substring name (match-end 0))))))
13223 (setq gnus-article-buffer name)
13224 (setq gnus-original-article-buffer original)
13225 ;; This might be a variable local to the summary buffer.
13226 (unless gnus-single-article-buffer
13228 (set-buffer gnus-summary-buffer)
13229 (setq gnus-article-buffer name)
13230 (setq gnus-original-article-buffer original)
13231 (gnus-set-global-variables))
13232 (make-local-variable 'gnus-summary-buffer))
13233 ;; Init original article buffer.
13235 (set-buffer (get-buffer-create gnus-original-article-buffer))
13236 (buffer-disable-undo (current-buffer))
13237 (setq major-mode 'gnus-original-article-mode)
13238 (make-local-variable 'gnus-original-article))
13239 (if (get-buffer name)
13242 (buffer-disable-undo (current-buffer))
13243 (setq buffer-read-only t)
13244 (gnus-add-current-to-buffer-list)
13245 (or (eq major-mode 'gnus-article-mode)
13246 (gnus-article-mode))
13249 (set-buffer (get-buffer-create name))
13250 (gnus-add-current-to-buffer-list)
13251 (gnus-article-mode)
13252 (current-buffer)))))
13254 ;; Set article window start at LINE, where LINE is the number of lines
13255 ;; from the head of the article.
13256 (defun gnus-article-set-window-start (&optional line)
13258 (get-buffer-window gnus-article-buffer)
13260 (set-buffer gnus-article-buffer)
13261 (goto-char (point-min))
13264 (gnus-message 6 "Moved to bookmark")
13265 (search-forward "\n\n" nil t)
13266 (forward-line line)
13269 (defun gnus-kill-all-overlays ()
13270 "Delete all overlays in the current buffer."
13271 (when (fboundp 'overlay-lists)
13272 (let* ((overlayss (overlay-lists))
13273 (buffer-read-only nil)
13274 (overlays (nconc (car overlayss) (cdr overlayss))))
13276 (delete-overlay (pop overlays))))))
13278 (defun gnus-request-article-this-buffer (article group)
13279 "Get an article and insert it into this buffer."
13280 (let (do-update-line)
13284 (gnus-kill-all-overlays)
13285 (setq group (or group gnus-newsgroup-name))
13287 ;; Open server if it has closed.
13288 (gnus-check-server (gnus-find-method-for-group group))
13290 ;; Using `gnus-request-article' directly will insert the article into
13291 ;; `nntp-server-buffer' - so we'll save some time by not having to
13292 ;; copy it from the server buffer into the article buffer.
13294 ;; We only request an article by message-id when we do not have the
13295 ;; headers for it, so we'll have to get those.
13296 (when (stringp article)
13297 (let ((gnus-override-method gnus-refer-article-method))
13298 (gnus-read-header article)))
13300 ;; If the article number is negative, that means that this article
13301 ;; doesn't belong in this newsgroup (possibly), so we find its
13302 ;; message-id and request it by id instead of number.
13303 (when (and (numberp article)
13304 gnus-summary-buffer
13305 (get-buffer gnus-summary-buffer)
13306 (buffer-name (get-buffer gnus-summary-buffer)))
13308 (set-buffer gnus-summary-buffer)
13309 (let ((header (gnus-summary-article-header article)))
13312 ((memq article gnus-newsgroup-sparse)
13313 ;; This is a sparse gap article.
13314 (setq do-update-line article)
13315 (setq article (mail-header-id header))
13316 (let ((gnus-override-method gnus-refer-article-method))
13317 (gnus-read-header article)))
13319 ;; It's a real article.
13320 (setq article (mail-header-id header)))
13322 ;; It is an extracted pseudo-article.
13323 (setq article 'pseudo)
13324 (gnus-request-pseudo-article header))))
13326 (let ((method (gnus-find-method-for-group
13327 gnus-newsgroup-name)))
13328 (if (not (eq (car method) 'nneething))
13330 (let ((dir (concat (file-name-as-directory (nth 1 method))
13331 (mail-header-subject header))))
13332 (if (file-directory-p dir)
13334 (setq article 'nneething)
13335 (gnus-group-enter-directory dir)))))))))
13338 ;; We first check `gnus-original-article-buffer'.
13339 ((and (get-buffer gnus-original-article-buffer)
13341 (set-buffer gnus-original-article-buffer)
13342 (and (equal (car gnus-original-article) group)
13343 (eq (cdr gnus-original-article) article))))
13344 (insert-buffer-substring gnus-original-article-buffer)
13346 ;; Check the backlog.
13347 ((and gnus-keep-backlog
13348 (gnus-backlog-request-article group article (current-buffer)))
13350 ;; Check the cache.
13351 ((and gnus-use-cache
13353 (gnus-cache-request-article article group))
13355 ;; Get the article and put into the article buffer.
13356 ((or (stringp article) (numberp article))
13357 (let ((gnus-override-method
13358 (and (stringp article) gnus-refer-article-method))
13359 (buffer-read-only nil))
13361 (gnus-kill-all-overlays)
13362 (if (gnus-request-article article group (current-buffer))
13364 (and gnus-keep-backlog
13366 (gnus-backlog-enter-article
13367 group article (current-buffer)))
13369 ;; It was a pseudo.
13372 ;; Take the article from the original article buffer
13373 ;; and place it in the buffer it's supposed to be in.
13374 (when (and (get-buffer gnus-article-buffer)
13375 (equal (buffer-name (current-buffer))
13376 (buffer-name (get-buffer gnus-article-buffer))))
13378 (if (get-buffer gnus-original-article-buffer)
13379 (set-buffer (get-buffer gnus-original-article-buffer))
13380 (set-buffer (get-buffer-create gnus-original-article-buffer))
13381 (buffer-disable-undo (current-buffer))
13382 (setq major-mode 'gnus-original-article-mode)
13383 (setq buffer-read-only t)
13384 (gnus-add-current-to-buffer-list))
13385 (let (buffer-read-only)
13387 (insert-buffer-substring gnus-article-buffer))
13388 (setq gnus-original-article (cons group article))))
13390 ;; Update sparse articles.
13391 (when do-update-line
13393 (set-buffer gnus-summary-buffer)
13394 (gnus-summary-update-article do-update-line)
13395 (gnus-summary-goto-subject do-update-line)
13396 (set-window-point (get-buffer-window (current-buffer) t)
13399 (defun gnus-read-header (id &optional header)
13400 "Read the headers of article ID and enter them into the Gnus system."
13401 (let ((group gnus-newsgroup-name)
13403 ;; First we check to see whether the header in question is already
13406 ;; This is a Message-ID.
13407 (setq header (or header (gnus-id-to-header id)))
13408 ;; This is an article number.
13409 (setq header (or header (gnus-summary-article-header id))))
13411 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13412 ;; We have found the header.
13414 ;; We have to really fetch the header to this article.
13416 (if (gnus-check-backend-function 'request-head group)
13417 (gnus-request-head id group)
13418 (gnus-request-article id group)))
13420 (set-buffer nntp-server-buffer)
13421 (and (search-forward "\n\n" nil t)
13422 (delete-region (1- (point)) (point-max)))
13423 (goto-char (point-max))
13425 (goto-char (point-min))
13429 ((cdr where) (cdr where))
13430 (header (mail-header-number header))
13431 (t gnus-reffed-article-number))
13433 (insert " Article retrieved.\n"))
13435 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13436 ; (setcar (gnus-id-to-thread id) nil))
13437 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13438 () ; Malformed head.
13439 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13440 (if (and (stringp id)
13441 (not (string= (gnus-group-real-name group)
13443 ;; If we fetched by Message-ID and the article came
13444 ;; from a different group, we fudge some bogus article
13445 ;; numbers for this article.
13446 (mail-header-set-number header gnus-reffed-article-number))
13447 (decf gnus-reffed-article-number)
13448 (push header gnus-newsgroup-headers)
13449 (setq gnus-current-headers header)
13450 (push (mail-header-number header) gnus-newsgroup-limit))
13453 (defun gnus-article-prepare (article &optional all-headers header)
13454 "Prepare ARTICLE in article mode buffer.
13455 ARTICLE should either be an article number or a Message-ID.
13456 If ARTICLE is an id, HEADER should be the article headers.
13457 If ALL-HEADERS is non-nil, no headers are hidden."
13459 ;; Make sure we start in a summary buffer.
13460 (unless (eq major-mode 'gnus-summary-mode)
13461 (set-buffer gnus-summary-buffer))
13462 (setq gnus-summary-buffer (current-buffer))
13463 ;; Make sure the connection to the server is alive.
13464 (unless (gnus-server-opened
13465 (gnus-find-method-for-group gnus-newsgroup-name))
13466 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13467 (gnus-request-group gnus-newsgroup-name t))
13468 (let* ((article (if header (mail-header-number header) article))
13469 (summary-buffer (current-buffer))
13470 (internal-hook gnus-article-internal-prepare-hook)
13471 (group gnus-newsgroup-name)
13474 (gnus-article-setup-buffer)
13475 (set-buffer gnus-article-buffer)
13476 ;; Deactivate active regions.
13477 (when (and (boundp 'transient-mark-mode)
13478 transient-mark-mode)
13479 (setq mark-active nil))
13480 (if (not (setq result (let ((buffer-read-only nil))
13481 (gnus-request-article-this-buffer
13483 ;; There is no such article.
13485 (when (and (numberp article)
13486 (not (memq article gnus-newsgroup-sparse)))
13487 (setq gnus-article-current
13488 (cons gnus-newsgroup-name article))
13489 (set-buffer gnus-summary-buffer)
13490 (setq gnus-current-article article)
13491 (gnus-summary-mark-article article gnus-canceled-mark))
13492 (unless (memq article gnus-newsgroup-sparse)
13494 1 "No such article (may have expired or been canceled)")
13497 (if (or (eq result 'pseudo) (eq result 'nneething))
13500 (set-buffer summary-buffer)
13501 (setq gnus-last-article gnus-current-article
13502 gnus-newsgroup-history (cons gnus-current-article
13503 gnus-newsgroup-history)
13504 gnus-current-article 0
13505 gnus-current-headers nil
13506 gnus-article-current nil)
13507 (if (eq result 'nneething)
13508 (gnus-configure-windows 'summary)
13509 (gnus-configure-windows 'article))
13510 (gnus-set-global-variables))
13511 (gnus-set-mode-line 'article))
13512 ;; The result from the `request' was an actual article -
13513 ;; or at least some text that is now displayed in the
13515 (if (and (numberp article)
13516 (not (eq article gnus-current-article)))
13517 ;; Seems like a new article has been selected.
13518 ;; `gnus-current-article' must be an article number.
13520 (set-buffer summary-buffer)
13521 (setq gnus-last-article gnus-current-article
13522 gnus-newsgroup-history (cons gnus-current-article
13523 gnus-newsgroup-history)
13524 gnus-current-article article
13525 gnus-current-headers
13526 (gnus-summary-article-header gnus-current-article)
13527 gnus-article-current
13528 (cons gnus-newsgroup-name gnus-current-article))
13529 (unless (vectorp gnus-current-headers)
13530 (setq gnus-current-headers nil))
13531 (gnus-summary-show-thread)
13532 (run-hooks 'gnus-mark-article-hook)
13533 (gnus-set-mode-line 'summary)
13534 (and (gnus-visual-p 'article-highlight 'highlight)
13535 (run-hooks 'gnus-visual-mark-article-hook))
13536 ;; Set the global newsgroup variables here.
13537 ;; Suggested by Jim Sisolak
13538 ;; <sisolak@trans4.neep.wisc.edu>.
13539 (gnus-set-global-variables)
13540 (setq gnus-have-all-headers
13541 (or all-headers gnus-show-all-headers))
13542 (and gnus-use-cache
13543 (vectorp (gnus-summary-article-header article))
13544 (gnus-cache-possibly-enter-article
13546 (gnus-summary-article-header article)
13547 (memq article gnus-newsgroup-marked)
13548 (memq article gnus-newsgroup-dormant)
13549 (memq article gnus-newsgroup-unreads)))))
13550 ;; Hooks for getting information from the article.
13551 ;; This hook must be called before being narrowed.
13552 (let (buffer-read-only)
13553 (run-hooks 'internal-hook)
13554 (run-hooks 'gnus-article-prepare-hook)
13555 ;; Decode MIME message.
13557 (if (or (not gnus-strict-mime)
13558 (gnus-fetch-field "Mime-Version"))
13559 (funcall gnus-show-mime-method)
13560 (funcall gnus-decode-encoded-word-method)))
13561 ;; Perform the article display hooks.
13562 (run-hooks 'gnus-article-display-hook))
13564 (goto-char (point-min))
13565 (and gnus-break-pages (gnus-narrow-to-page))
13566 (gnus-set-mode-line 'article)
13567 (gnus-configure-windows 'article)
13568 (goto-char (point-min))
13571 (defun gnus-article-show-all-headers ()
13572 "Show all article headers in article mode buffer."
13574 (gnus-article-setup-buffer)
13575 (set-buffer gnus-article-buffer)
13576 (let ((buffer-read-only nil))
13577 (gnus-unhide-text (point-min) (point-max)))))
13579 (defun gnus-article-hide-headers-if-wanted ()
13580 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13581 Provided for backwards compatibility."
13582 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13583 gnus-inhibit-hiding
13584 (gnus-article-hide-headers)))
13586 (defun gnus-article-hide-headers (&optional arg delete)
13587 "Toggle whether to hide unwanted headers and possibly sort them as well.
13588 If given a negative prefix, always show; if given a positive prefix,
13591 (unless (gnus-article-check-hidden-text 'headers arg)
13592 ;; This function might be inhibited.
13593 (unless gnus-inhibit-hiding
13595 (set-buffer gnus-article-buffer)
13597 (let ((buffer-read-only nil)
13598 (props (nconc (list 'gnus-type 'headers)
13599 gnus-hidden-properties))
13600 (ignored (when (not (stringp gnus-visible-headers))
13601 (cond ((stringp gnus-ignored-headers)
13602 gnus-ignored-headers)
13603 ((listp gnus-ignored-headers)
13604 (mapconcat 'identity gnus-ignored-headers
13607 (cond ((stringp gnus-visible-headers)
13608 gnus-visible-headers)
13609 ((and gnus-visible-headers
13610 (listp gnus-visible-headers))
13611 (mapconcat 'identity gnus-visible-headers "\\|"))))
13613 ;; First we narrow to just the headers.
13615 (goto-char (point-min))
13616 ;; Hide any "From " lines at the beginning of (mail) articles.
13617 (while (looking-at "From ")
13620 (gnus-hide-text (point-min) (point) props))
13621 ;; Then treat the rest of the header lines.
13624 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13625 ;; Then we use the two regular expressions
13626 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13627 ;; select which header lines is to remain visible in the
13629 (goto-char (point-min))
13630 (while (re-search-forward "^[^ \t]*:" nil t)
13631 (beginning-of-line)
13632 ;; We add the headers we want to keep to a list and delete
13633 ;; them from the buffer.
13634 (if (or (and visible (looking-at visible))
13635 (and ignored (not (looking-at ignored))))
13637 (push (buffer-substring
13641 ;; Be sure to get multi-line headers...
13642 (re-search-forward "^[^ \t]*:" nil t)
13643 (beginning-of-line)
13646 (delete-region beg (point)))
13648 ;; Sort the headers that we want to display.
13649 (setq want-list (sort want-list 'gnus-article-header-less))
13650 (goto-char (point-min))
13652 (insert (pop want-list)))
13653 ;; We make the unwanted headers invisible.
13655 (delete-region (point-min) (point-max))
13656 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13657 (gnus-hide-text-type (point) (point-max) 'headers))))))))
13659 (defsubst gnus-article-header-rank (header)
13660 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13661 (let ((list gnus-sorted-header-list)
13664 (when (string-match (car list) header)
13666 (setq list (cdr list))
13670 (defun gnus-article-header-less (h1 h2)
13671 "Say whether string H1 is \"less\" than string H2."
13672 (< (gnus-article-header-rank h1)
13673 (gnus-article-header-rank h2)))
13675 (defun gnus-article-hide-boring-headers (&optional arg)
13676 "Toggle hiding of headers that aren't very interesting.
13677 If given a negative prefix, always show; if given a positive prefix,
13680 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13682 (set-buffer gnus-article-buffer)
13684 (let ((buffer-read-only nil)
13685 (list gnus-boring-article-headers)
13686 (inhibit-point-motion-hooks t)
13688 (nnheader-narrow-to-headers)
13690 (setq elem (pop list))
13691 (goto-char (point-min))
13693 ;; Hide empty headers.
13695 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13697 (gnus-hide-text-type
13698 (progn (beginning-of-line) (point))
13701 (if (re-search-forward "^[^ \t]" nil t)
13702 (match-beginning 0)
13705 ;; Hide boring Newsgroups header.
13706 ((eq elem 'newsgroups)
13707 (when (equal (mail-fetch-field "newsgroups")
13708 (gnus-group-real-name gnus-newsgroup-name))
13709 (gnus-article-hide-header "newsgroups")))
13710 ((eq elem 'followup-to)
13711 (when (equal (mail-fetch-field "followup-to")
13712 (mail-fetch-field "newsgroups"))
13713 (gnus-article-hide-header "followup-to")))
13714 ((eq elem 'reply-to)
13715 (let ((from (mail-fetch-field "from"))
13716 (reply-to (mail-fetch-field "reply-to")))
13720 (nth 1 (funcall gnus-extract-address-components from))
13721 (nth 1 (funcall gnus-extract-address-components
13723 (gnus-article-hide-header "reply-to"))))
13725 (let ((date (mail-fetch-field "date")))
13727 (< (gnus-days-between date (current-time-string))
13729 (gnus-article-hide-header "date")))))))))))
13731 (defun gnus-article-hide-header (header)
13733 (goto-char (point-min))
13734 (when (re-search-forward (concat "^" header ":") nil t)
13735 (gnus-hide-text-type
13736 (progn (beginning-of-line) (point))
13739 (if (re-search-forward "^[^ \t]" nil t)
13740 (match-beginning 0)
13742 'boring-headers))))
13744 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13745 (defun gnus-article-treat-overstrike ()
13746 "Translate overstrikes into bold text."
13749 (set-buffer gnus-article-buffer)
13750 (let ((buffer-read-only nil))
13751 (while (search-forward "\b" nil t)
13752 (let ((next (following-char))
13753 (previous (char-after (- (point) 2))))
13754 (cond ((eq next previous)
13755 (put-text-property (- (point) 2) (point) 'invisible t)
13756 (put-text-property (point) (1+ (point)) 'face 'bold))
13758 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13760 (- (point) 2) (1- (point)) 'face 'underline))
13762 (put-text-property (- (point) 2) (point) 'invisible t)
13764 (point) (1+ (point)) 'face 'underline))))))))
13766 (defun gnus-article-word-wrap ()
13767 "Format too long lines."
13770 (set-buffer gnus-article-buffer)
13771 (let ((buffer-read-only nil))
13773 (goto-char (point-min))
13774 (search-forward "\n\n" nil t)
13776 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13777 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13778 (adaptive-fill-mode t))
13779 (while (not (eobp))
13780 (and (>= (current-column) (min fill-column (window-width)))
13781 (/= (preceding-char) ?:)
13782 (fill-paragraph nil))
13783 (end-of-line 2))))))
13785 (defun gnus-article-remove-cr ()
13786 "Remove carriage returns from an article."
13789 (set-buffer gnus-article-buffer)
13790 (let ((buffer-read-only nil))
13791 (goto-char (point-min))
13792 (while (search-forward "\r" nil t)
13793 (replace-match "" t t)))))
13795 (defun gnus-article-remove-trailing-blank-lines ()
13796 "Remove all trailing blank lines from the article."
13799 (set-buffer gnus-article-buffer)
13800 (let ((buffer-read-only nil))
13801 (goto-char (point-max))
13805 (while (looking-at "^[ \t]*$")
13810 (defun gnus-article-display-x-face (&optional force)
13811 "Look for an X-Face header and display it if present."
13812 (interactive (list 'force))
13814 (set-buffer gnus-article-buffer)
13815 ;; Delete the old process, if any.
13816 (when (process-status "gnus-x-face")
13817 (delete-process "gnus-x-face"))
13818 (let ((inhibit-point-motion-hooks t)
13819 (case-fold-search nil)
13822 (nnheader-narrow-to-headers)
13823 (setq from (mail-fetch-field "from"))
13824 (goto-char (point-min))
13825 (when (and gnus-article-x-face-command
13827 ;; Check whether this face is censored.
13828 (not gnus-article-x-face-too-ugly)
13829 (and gnus-article-x-face-too-ugly from
13830 (not (string-match gnus-article-x-face-too-ugly
13832 ;; Has to be present.
13833 (re-search-forward "^X-Face: " nil t))
13834 ;; We now have the area of the buffer where the X-Face is stored.
13835 (let ((beg (point))
13836 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13837 ;; We display the face.
13838 (if (symbolp gnus-article-x-face-command)
13839 ;; The command is a lisp function, so we call it.
13840 (if (gnus-functionp gnus-article-x-face-command)
13841 (funcall gnus-article-x-face-command beg end)
13842 (error "%s is not a function" gnus-article-x-face-command))
13843 ;; The command is a string, so we interpret the command
13844 ;; as a, well, command, and fork it off.
13845 (let ((process-connection-type nil))
13846 (process-kill-without-query
13848 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13849 (process-send-region "gnus-x-face" beg end)
13850 (process-send-eof "gnus-x-face")))))))))
13852 (defun gnus-headers-decode-quoted-printable ()
13853 "Hack to remove QP encoding from headers."
13854 (let ((case-fold-search t)
13855 (inhibit-point-motion-hooks t)
13857 (goto-char (point-min))
13858 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13859 (setq string (match-string 1))
13860 (narrow-to-region (match-beginning 0) (match-end 0))
13861 (delete-region (point-min) (point-max))
13863 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13864 (subst-char-in-region (point-min) (point-max) ?_ ? )
13866 (goto-char (point-min)))))
13868 (defun gnus-article-de-quoted-unreadable (&optional force)
13869 "Do a naive translation of a quoted-printable-encoded article.
13870 This is in no way, shape or form meant as a replacement for real MIME
13871 processing, but is simply a stop-gap measure until MIME support is
13873 If FORCE, decode the article whether it is marked as quoted-printable
13875 (interactive (list 'force))
13877 (set-buffer gnus-article-buffer)
13878 (let ((case-fold-search t)
13879 (buffer-read-only nil)
13880 (type (gnus-fetch-field "content-transfer-encoding")))
13882 (and type (string-match "quoted-printable" (downcase type))))
13883 (gnus-headers-decode-quoted-printable)
13884 (goto-char (point-min))
13885 (search-forward "\n\n" nil 'move)
13886 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13888 (defun gnus-mime-decode-quoted-printable (from to)
13889 "Decode Quoted-Printable in the region between FROM and TO."
13891 (while (search-forward "=" to t)
13892 (cond ((eq (following-char) ?\n)
13895 ((looking-at "[0-9A-F][0-9A-F]")
13897 (insert (hexl-hex-string-to-integer
13898 (buffer-substring (point) (+ 2 (point)))))
13902 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13904 (defun gnus-article-hide-pgp (&optional arg)
13905 "Toggle hiding of any PGP headers and signatures in the current article.
13906 If given a negative prefix, always show; if given a positive prefix,
13909 (unless (gnus-article-check-hidden-text 'pgp arg)
13911 (set-buffer gnus-article-buffer)
13912 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13913 buffer-read-only beg end)
13915 (goto-char (point-min))
13916 ;; Hide the "header".
13917 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13918 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13920 ;; Hide the actual signature.
13921 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13922 (setq end (1+ (match-beginning 0)))
13925 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13927 ;; Perhaps we shouldn't hide to the end of the buffer
13928 ;; if there is no end to the signature?
13931 ;; Hide "- " PGP quotation markers.
13932 (when (and beg end)
13933 (narrow-to-region beg end)
13934 (goto-char (point-min))
13935 (while (re-search-forward "^- " nil t)
13936 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13939 (defun gnus-article-hide-signature (&optional arg)
13940 "Hide the signature in the current article.
13941 If given a negative prefix, always show; if given a positive prefix,
13944 (unless (gnus-article-check-hidden-text 'signature arg)
13946 (set-buffer gnus-article-buffer)
13948 (let ((buffer-read-only nil))
13949 (when (gnus-narrow-to-signature)
13950 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
13952 (defun gnus-article-strip-leading-blank-lines ()
13953 "Remove all blank lines from the beginning of the article."
13956 (set-buffer gnus-article-buffer)
13957 (let (buffer-read-only)
13958 (goto-char (point-min))
13959 (when (search-forward "\n\n" nil t)
13960 (while (looking-at "[ \t]$")
13961 (gnus-delete-line))))))
13963 (defun gnus-narrow-to-signature ()
13964 "Narrow to the signature."
13966 (goto-char (point-max))
13967 (when (re-search-backward gnus-signature-separator nil t)
13969 (when (or (null gnus-signature-limit)
13970 (and (numberp gnus-signature-limit)
13971 (< (- (point-max) (point)) gnus-signature-limit))
13972 (and (gnus-functionp gnus-signature-limit)
13973 (funcall gnus-signature-limit))
13974 (and (stringp gnus-signature-limit)
13975 (not (re-search-forward gnus-signature-limit nil t))))
13976 (narrow-to-region (point) (point-max))
13979 (defun gnus-article-check-hidden-text (type arg)
13980 "Return nil if hiding is necessary."
13982 (set-buffer gnus-article-buffer)
13983 (let ((hide (gnus-article-hidden-text-p type)))
13984 (cond ((or (and (null arg) (eq hide 'hidden))
13985 (and arg (< 0 (prefix-numeric-value arg))))
13986 (gnus-article-show-hidden-text type))
13988 (gnus-article-show-hidden-text type t))
13991 (defun gnus-article-hidden-text-p (type)
13992 "Say whether the current buffer contains hidden text of type TYPE."
13993 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
13995 (if (get-text-property pos 'invisible)
13999 (defun gnus-article-hide (&optional arg force)
14000 "Hide all the gruft in the current article.
14001 This means that PGP stuff, signatures, cited text and (some)
14002 headers will be hidden.
14003 If given a prefix, show the hidden text instead."
14004 (interactive (list current-prefix-arg 'force))
14005 (gnus-article-hide-headers arg)
14006 (gnus-article-hide-pgp arg)
14007 (gnus-article-hide-citation-maybe arg force)
14008 (gnus-article-hide-signature arg))
14010 (defun gnus-article-show-hidden-text (type &optional hide)
14011 "Show all hidden text of type TYPE.
14012 If HIDE, hide the text instead."
14014 (set-buffer gnus-article-buffer)
14015 (let ((buffer-read-only nil)
14016 (inhibit-point-motion-hooks t)
14018 (while (gnus-goto-char (text-property-any
14019 beg (point-max) 'gnus-type type))
14023 (gnus-hide-text beg (point) gnus-hidden-properties)
14024 (gnus-unhide-text beg (point)))
14025 (setq beg (point)))
14028 (defvar gnus-article-time-units
14029 `((year . ,(* 365.25 24 60 60))
14030 (week . ,(* 7 24 60 60))
14031 (day . ,(* 24 60 60))
14032 (hour . ,(* 60 60))
14035 "Mapping from time units to seconds.")
14037 (defun gnus-article-date-ut (&optional type highlight)
14038 "Convert DATE date to universal time in the current article.
14039 If TYPE is `local', convert to local time; if it is `lapsed', output
14040 how much time has lapsed since DATE."
14041 (interactive (list 'ut t))
14042 (let* ((header (or gnus-current-headers
14043 (gnus-summary-article-header) ""))
14044 (date (and (vectorp header) (mail-header-date header)))
14045 (date-regexp "^Date: \\|^X-Sent: ")
14046 (now (current-time))
14047 (inhibit-point-motion-hooks t)
14049 (when (and date (not (string= date "")))
14051 (set-buffer gnus-article-buffer)
14053 (nnheader-narrow-to-headers)
14054 (let ((buffer-read-only nil))
14055 ;; Delete any old Date headers.
14056 (if (re-search-forward date-regexp nil t)
14058 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14059 eface (get-text-property (gnus-point-at-eol) 'face))
14060 (message-remove-header date-regexp t)
14061 (beginning-of-line))
14062 (goto-char (point-max)))
14065 ;; Convert to the local timezone. We have to slap a
14066 ;; `condition-case' round the calls to the timezone
14067 ;; functions since they aren't particularly resistant to
14070 (concat "Date: " (condition-case ()
14071 (timezone-make-date-arpa-standard date)
14074 ;; Convert to Universal Time.
14078 (timezone-make-date-arpa-standard date nil "UT")
14081 ;; Get the original date from the article.
14082 ((eq type 'original)
14083 (concat "Date: " date "\n"))
14084 ;; Do an X-Sent lapsed format.
14086 ;; If the date is seriously mangled, the timezone
14087 ;; functions are liable to bug out, so we condition-case
14088 ;; the entire thing.
14093 (timezone-make-date-arpa-standard
14094 (current-time-string now)
14095 (current-time-zone now) "UT"))
14097 (timezone-make-date-arpa-standard
14100 (real-sec (+ (* (float (car real-time)) 65536)
14102 (sec (abs real-sec))
14108 ;; This is a bit convoluted, but basically we go
14109 ;; through the time units for years, weeks, etc,
14110 ;; and divide things to see whether that results
14111 ;; in positive answers.
14114 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14115 ;; The (remaining) seconds are too few to
14116 ;; be divided into this time unit.
14118 ;; It's big enough, so we output it.
14119 (setq sec (- sec (* num (cdr unit))))
14121 (concat (if prev ", " "") (int-to-string
14123 " " (symbol-name (car unit))
14124 (if (> num 1) "s" ""))
14126 gnus-article-time-units "")
14127 ;; If dates are odd, then it might appear like the
14128 ;; article was sent in the future.
14131 " in the future\n")))))
14133 (error "Unknown conversion type: %s" type)))))
14134 ;; Do highlighting.
14135 (beginning-of-line)
14136 (when (and highlight (gnus-visual-p 'article-highlight 'highlight)
14137 (looking-at "\\([^:]\\): *\\(.*\\)$"))
14138 (put-text-property (match-beginning 1) (match-end 1)
14140 (put-text-property (match-beginning 2) (match-end 2)
14143 (defun gnus-article-date-local (&optional highlight)
14144 "Convert the current article date to the local timezone."
14145 (interactive (list t))
14146 (gnus-article-date-ut 'local highlight))
14148 (defun gnus-article-date-original (&optional highlight)
14149 "Convert the current article date to what it was originally.
14150 This is only useful if you have used some other date conversion
14151 function and want to see what the date was before converting."
14152 (interactive (list t))
14153 (gnus-article-date-ut 'original highlight))
14155 (defun gnus-article-date-lapsed (&optional highlight)
14156 "Convert the current article date to time lapsed since it was sent."
14157 (interactive (list t))
14158 (gnus-article-date-ut 'lapsed highlight))
14160 (defun gnus-article-maybe-highlight ()
14161 "Do some article highlighting if `gnus-visual' is non-nil."
14162 (if (gnus-visual-p 'article-highlight 'highlight)
14163 (gnus-article-highlight-some)))
14167 (defun gnus-output-to-rmail (file-name)
14168 "Append the current article to an Rmail file named FILE-NAME."
14170 ;; Most of these codes are borrowed from rmailout.el.
14171 (setq file-name (expand-file-name file-name))
14172 (setq rmail-default-rmail-file file-name)
14173 (let ((artbuf (current-buffer))
14174 (tmpbuf (get-buffer-create " *Gnus-output*")))
14176 (or (get-file-buffer file-name)
14177 (file-exists-p file-name)
14178 (if (gnus-yes-or-no-p
14179 (concat "\"" file-name "\" does not exist, create it? "))
14180 (let ((file-buffer (create-file-buffer file-name)))
14182 (set-buffer file-buffer)
14183 (rmail-insert-rmail-file-header)
14184 (let ((require-final-newline nil))
14185 (write-region (point-min) (point-max) file-name t 1)))
14186 (kill-buffer file-buffer))
14187 (error "Output file does not exist")))
14188 (set-buffer tmpbuf)
14189 (buffer-disable-undo (current-buffer))
14191 (insert-buffer-substring artbuf)
14192 (gnus-convert-article-to-rmail)
14193 ;; Decide whether to append to a file or to an Emacs buffer.
14194 (let ((outbuf (get-file-buffer file-name)))
14196 (append-to-file (point-min) (point-max) file-name)
14197 ;; File has been visited, in buffer OUTBUF.
14198 (set-buffer outbuf)
14199 (let ((buffer-read-only nil)
14200 (msg (and (boundp 'rmail-current-message)
14201 (symbol-value 'rmail-current-message))))
14202 ;; If MSG is non-nil, buffer is in RMAIL mode.
14205 (narrow-to-region (point-max) (point-max))))
14206 (insert-buffer-substring tmpbuf)
14209 (goto-char (point-min))
14211 (search-backward "\^_")
14212 (narrow-to-region (point) (point-max))
14213 (goto-char (1+ (point-min)))
14214 (rmail-count-new-messages t)
14215 (rmail-show-message msg)))))))
14216 (kill-buffer tmpbuf)))
14218 (defun gnus-output-to-file (file-name)
14219 "Append the current article to a file named FILE-NAME."
14220 (setq file-name (expand-file-name file-name))
14221 (let ((artbuf (current-buffer))
14222 (tmpbuf (get-buffer-create " *Gnus-output*")))
14224 (set-buffer tmpbuf)
14225 (buffer-disable-undo (current-buffer))
14227 (insert-buffer-substring artbuf)
14228 ;; Append newline at end of the buffer as separator, and then
14229 ;; save it to file.
14230 (goto-char (point-max))
14232 (append-to-file (point-min) (point-max) file-name))
14233 (kill-buffer tmpbuf)))
14235 (defun gnus-convert-article-to-rmail ()
14236 "Convert article in current buffer to Rmail message format."
14237 (let ((buffer-read-only nil))
14238 ;; Convert article directly into Babyl format.
14239 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14240 (goto-char (point-min))
14241 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14242 (while (search-forward "\n\^_" nil t) ;single char
14243 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14244 (goto-char (point-max))
14247 (defun gnus-narrow-to-page (&optional arg)
14248 "Narrow the article buffer to a page.
14249 If given a numerical ARG, move forward ARG pages."
14251 (setq arg (if arg (prefix-numeric-value arg) 0))
14253 (set-buffer gnus-article-buffer)
14254 (goto-char (point-min))
14256 (when (gnus-visual-p 'page-marker)
14257 (let ((buffer-read-only nil))
14258 (gnus-remove-text-with-property 'gnus-prev)
14259 (gnus-remove-text-with-property 'gnus-next)))
14262 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14264 (re-search-forward page-delimiter nil 'move arg)))
14265 (goto-char (match-end 0)))
14268 (if (re-search-forward page-delimiter nil 'move)
14269 (match-beginning 0)
14271 (when (and (gnus-visual-p 'page-marker)
14272 (not (= (point-min) 1)))
14274 (goto-char (point-min))
14275 (gnus-insert-prev-page-button)))
14276 (when (and (gnus-visual-p 'page-marker)
14277 (not (= (1- (point-max)) (buffer-size))))
14279 (goto-char (point-max))
14280 (gnus-insert-next-page-button)))))
14282 ;; Article mode commands
14284 (defun gnus-article-goto-next-page ()
14285 "Show the next page of the article."
14287 (when (gnus-article-next-page)
14288 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14290 (defun gnus-article-goto-prev-page ()
14291 "Show the next page of the article."
14293 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14294 (gnus-article-prev-page nil)))
14296 (defun gnus-article-next-page (&optional lines)
14297 "Show the next page of the current article.
14298 If end of article, return non-nil. Otherwise return nil.
14299 Argument LINES specifies lines to be scrolled up."
14301 (move-to-window-line -1)
14302 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14303 (if (save-excursion
14305 (and (pos-visible-in-window-p) ;Not continuation line.
14307 ;; Nothing in this page.
14308 (if (or (not gnus-break-pages)
14311 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14313 (gnus-narrow-to-page 1) ;Go to next page.
14315 ;; More in this page.
14319 ;; Long lines may cause an end-of-buffer error.
14320 (goto-char (point-max))))
14321 (move-to-window-line 0)
14324 (defun gnus-article-prev-page (&optional lines)
14325 "Show previous page of current article.
14326 Argument LINES specifies lines to be scrolled down."
14328 (move-to-window-line 0)
14329 (if (and gnus-break-pages
14331 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14333 (gnus-narrow-to-page -1) ;Go to previous page.
14334 (goto-char (point-max))
14338 (scroll-down lines)
14340 (move-to-window-line 0))))
14342 (defun gnus-article-refer-article ()
14343 "Read article specified by message-id around point."
14345 (let ((point (point)))
14346 (search-forward ">" nil t) ;Move point to end of "<....>".
14347 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14348 (let ((message-id (match-string 1)))
14350 (set-buffer gnus-summary-buffer)
14351 (gnus-summary-refer-article message-id))
14352 (goto-char (point))
14353 (error "No references around point"))))
14355 (defun gnus-article-show-summary ()
14356 "Reconfigure windows to show summary buffer."
14358 (gnus-configure-windows 'article)
14359 (gnus-summary-goto-subject gnus-current-article))
14361 (defun gnus-article-describe-briefly ()
14362 "Describe article mode commands briefly."
14365 (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")))
14367 (defun gnus-article-summary-command ()
14368 "Execute the last keystroke in the summary buffer."
14370 (let ((obuf (current-buffer))
14371 (owin (current-window-configuration))
14373 (switch-to-buffer gnus-summary-buffer 'norecord)
14374 (setq func (lookup-key (current-local-map) (this-command-keys)))
14375 (call-interactively func)
14377 (set-window-configuration owin)
14378 (set-window-point (get-buffer-window (current-buffer)) (point))))
14380 (defun gnus-article-summary-command-nosave ()
14381 "Execute the last keystroke in the summary buffer."
14384 (pop-to-buffer gnus-summary-buffer 'norecord)
14385 (setq func (lookup-key (current-local-map) (this-command-keys)))
14386 (call-interactively func)))
14388 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14389 "Read a summary buffer key sequence and execute it from the article buffer."
14392 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14393 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14397 (set-buffer gnus-summary-buffer)
14398 (push (or key last-command-event) unread-command-events)
14399 (setq keys (read-key-sequence nil)))
14402 (if (member keys nosaves)
14404 (pop-to-buffer gnus-summary-buffer 'norecord)
14405 (if (setq func (lookup-key (current-local-map) keys))
14406 (call-interactively func)
14408 (let ((obuf (current-buffer))
14409 (owin (current-window-configuration))
14412 (if not-restore-window
14413 (pop-to-buffer gnus-summary-buffer 'norecord)
14414 (switch-to-buffer gnus-summary-buffer 'norecord))
14415 (setq in-buffer (current-buffer))
14416 (if (setq func (lookup-key (current-local-map) keys))
14417 (call-interactively func)
14419 (when (eq in-buffer (current-buffer))
14421 (unless not-restore-window
14422 (set-window-configuration owin))
14423 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14427 ;;; Kill file handling.
14431 (defalias 'gnus-batch-kill 'gnus-batch-score)
14433 (defun gnus-batch-score ()
14434 "Run batched scoring.
14435 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14436 Newsgroups is a list of strings in Bnews format. If you want to score
14437 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14438 score the alt hierarchy, you'd say \"!alt.all\"."
14441 (gnus-newsrc-parse-options
14442 (apply (function concat)
14443 (mapcar (lambda (g) (concat g " "))
14444 command-line-args-left))))
14445 (gnus-expert-user t)
14446 (nnmail-spool-file nil)
14447 (gnus-use-dribble-file nil)
14448 (yes (car yes-and-no))
14449 (no (cdr yes-and-no))
14451 ;; Disable verbose message.
14452 gnus-novice-user gnus-large-newsgroup)
14453 ;; Eat all arguments.
14454 (setq command-line-args-left nil)
14457 ;; Apply kills to specified newsgroups in command line arguments.
14458 (setq newsrc (cdr gnus-newsrc-alist))
14460 (setq group (caar newsrc))
14461 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14462 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14464 (or (eq (car entry) t)
14465 (not (zerop (car entry)))))
14466 (if yes (string-match yes group) t)
14467 (or (null no) (not (string-match no group))))
14469 (gnus-summary-read-group group nil t nil t)
14470 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14471 (gnus-summary-exit))))
14472 (setq newsrc (cdr newsrc)))
14474 (switch-to-buffer gnus-group-buffer)
14475 (gnus-group-save-newsrc)))
14477 (defun gnus-apply-kill-file ()
14478 "Apply a kill file to the current newsgroup.
14479 Returns the number of articles marked as read."
14480 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14481 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14482 (gnus-apply-kill-file-internal)
14485 (defun gnus-kill-save-kill-buffer ()
14486 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14487 (when (get-file-buffer file)
14489 (set-buffer (get-file-buffer file))
14490 (and (buffer-modified-p) (save-buffer))
14491 (kill-buffer (current-buffer))))))
14493 (defvar gnus-kill-file-name "KILL"
14494 "Suffix of the kill files.")
14496 (defun gnus-newsgroup-kill-file (newsgroup)
14497 "Return the name of a kill file name for NEWSGROUP.
14498 If NEWSGROUP is nil, return the global kill file name instead."
14500 ;; The global KILL file is placed at top of the directory.
14501 ((or (null newsgroup)
14502 (string-equal newsgroup ""))
14503 (expand-file-name gnus-kill-file-name
14504 (or gnus-kill-files-directory "~/News")))
14505 ;; Append ".KILL" to newsgroup name.
14506 ((gnus-use-long-file-name 'not-kill)
14507 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14508 "." gnus-kill-file-name)
14509 (or gnus-kill-files-directory "~/News")))
14510 ;; Place "KILL" under the hierarchical directory.
14512 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14513 "/" gnus-kill-file-name)
14514 (or gnus-kill-files-directory "~/News")))))
14521 (defvar gnus-dribble-ignore nil)
14522 (defvar gnus-dribble-eval-file nil)
14524 (defun gnus-dribble-file-name ()
14525 "Return the dribble file for the current .newsrc."
14527 (if gnus-dribble-directory
14528 (concat (file-name-as-directory gnus-dribble-directory)
14529 (file-name-nondirectory gnus-current-startup-file))
14530 gnus-current-startup-file)
14533 (defun gnus-dribble-enter (string)
14534 "Enter STRING into the dribble buffer."
14535 (if (and (not gnus-dribble-ignore)
14536 gnus-dribble-buffer
14537 (buffer-name gnus-dribble-buffer))
14538 (let ((obuf (current-buffer)))
14539 (set-buffer gnus-dribble-buffer)
14540 (insert string "\n")
14541 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14542 (set-buffer obuf))))
14544 (defun gnus-dribble-read-file ()
14545 "Read the dribble file from disk."
14546 (let ((dribble-file (gnus-dribble-file-name)))
14548 (set-buffer (setq gnus-dribble-buffer
14550 (file-name-nondirectory dribble-file))))
14551 (gnus-add-current-to-buffer-list)
14553 (setq buffer-file-name dribble-file)
14555 (buffer-disable-undo (current-buffer))
14556 (bury-buffer (current-buffer))
14557 (set-buffer-modified-p nil)
14558 (let ((auto (make-auto-save-file-name))
14559 (gnus-dribble-ignore t))
14560 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14561 ;; Load whichever file is newest -- the auto save file
14562 ;; or the "real" file.
14563 (if (file-newer-than-file-p auto dribble-file)
14564 (insert-file-contents auto)
14565 (insert-file-contents dribble-file))
14566 (unless (zerop (buffer-size))
14567 (set-buffer-modified-p t))
14568 ;; Set the file modes to reflect the .newsrc file modes.
14570 (when (file-exists-p gnus-current-startup-file)
14571 (set-file-modes dribble-file
14572 (file-modes gnus-current-startup-file)))
14573 ;; Possibly eval the file later.
14574 (when (gnus-y-or-n-p
14575 "Auto-save file exists. Do you want to read it? ")
14576 (setq gnus-dribble-eval-file t)))))))
14578 (defun gnus-dribble-eval-file ()
14579 (if (not gnus-dribble-eval-file)
14581 (setq gnus-dribble-eval-file nil)
14583 (let ((gnus-dribble-ignore t))
14584 (set-buffer gnus-dribble-buffer)
14585 (eval-buffer (current-buffer))))))
14587 (defun gnus-dribble-delete-file ()
14588 (if (file-exists-p (gnus-dribble-file-name))
14589 (delete-file (gnus-dribble-file-name)))
14590 (if gnus-dribble-buffer
14592 (set-buffer gnus-dribble-buffer)
14593 (let ((auto (make-auto-save-file-name)))
14594 (if (file-exists-p auto)
14595 (delete-file auto))
14597 (set-buffer-modified-p nil)))))
14599 (defun gnus-dribble-save ()
14600 (if (and gnus-dribble-buffer
14601 (buffer-name gnus-dribble-buffer))
14603 (set-buffer gnus-dribble-buffer)
14606 (defun gnus-dribble-clear ()
14608 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14610 (set-buffer gnus-dribble-buffer)
14612 (set-buffer-modified-p nil)
14613 (setq buffer-saved-size (buffer-size))))))
14617 ;;; Server Communication
14620 (defun gnus-start-news-server (&optional confirm)
14621 "Open a method for getting news.
14622 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14624 (if gnus-current-select-method
14625 ;; Stream is already opened.
14627 ;; Open NNTP server.
14628 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14631 ;; Read server name with completion.
14632 (setq gnus-nntp-server
14633 (completing-read "NNTP server: "
14634 (mapcar (lambda (server) (list server))
14635 (cons (list gnus-nntp-server)
14636 gnus-secondary-servers))
14637 nil nil gnus-nntp-server))))
14639 (if (and gnus-nntp-server
14640 (stringp gnus-nntp-server)
14641 (not (string= gnus-nntp-server "")))
14642 (setq gnus-select-method
14643 (cond ((or (string= gnus-nntp-server "")
14644 (string= gnus-nntp-server "::"))
14645 (list 'nnspool (system-name)))
14646 ((string-match "^:" gnus-nntp-server)
14647 (list 'nnmh gnus-nntp-server
14648 (list 'nnmh-directory
14649 (file-name-as-directory
14651 (concat "~/" (substring
14652 gnus-nntp-server 1)))))
14653 (list 'nnmh-get-new-mail nil)))
14655 (list 'nntp gnus-nntp-server)))))
14657 (setq how (car gnus-select-method))
14658 (cond ((eq how 'nnspool)
14660 (gnus-message 5 "Looking up local news spool..."))
14663 (gnus-message 5 "Looking up mh spool..."))
14666 (setq gnus-current-select-method gnus-select-method)
14667 (run-hooks 'gnus-open-server-hook)
14669 ;; gnus-open-server-hook might have opened it
14670 (gnus-server-opened gnus-select-method)
14671 (gnus-open-server gnus-select-method)
14674 "%s (%s) open error: '%s'. Continue? "
14675 (car gnus-select-method) (cadr gnus-select-method)
14676 (gnus-status-message gnus-select-method)))
14678 (gnus-message 1 "Couldn't open server on %s"
14679 (nth 1 gnus-select-method))
14683 (defun gnus-check-group (group)
14684 "Try to make sure that the server where GROUP exists is alive."
14685 (let ((method (gnus-find-method-for-group group)))
14686 (or (gnus-server-opened method)
14687 (gnus-open-server method))))
14689 (defun gnus-check-server (&optional method silent)
14690 "Check whether the connection to METHOD is down.
14691 If METHOD is nil, use `gnus-select-method'.
14692 If it is down, start it up (again)."
14693 (let ((method (or method gnus-select-method)))
14694 ;; Transform virtual server names into select methods.
14695 (when (stringp method)
14696 (setq method (gnus-server-to-method method)))
14697 (if (gnus-server-opened method)
14698 ;; The stream is already opened.
14700 ;; Open the server.
14702 (gnus-message 5 "Opening %s server%s..." (car method)
14703 (if (equal (nth 1 method) "") ""
14704 (format " on %s" (nth 1 method)))))
14705 (run-hooks 'gnus-open-server-hook)
14707 (gnus-open-server method)
14711 (defun gnus-get-function (method function)
14712 "Return a function symbol based on METHOD and FUNCTION."
14713 ;; Translate server names into methods.
14715 (error "Attempted use of a nil select method"))
14716 (when (stringp method)
14717 (setq method (gnus-server-to-method method)))
14718 (let ((func (intern (format "%s-%s" (car method) function))))
14719 ;; If the functions isn't bound, we require the backend in
14721 (unless (fboundp func)
14722 (require (car method))
14723 (unless (fboundp func)
14724 ;; This backend doesn't implement this function.
14725 (error "No such function: %s" func)))
14730 ;;; Interface functions to the backends.
14733 (defun gnus-open-server (method)
14734 "Open a connection to METHOD."
14735 (when (stringp method)
14736 (setq method (gnus-server-to-method method)))
14737 (let ((elem (assoc method gnus-opened-servers)))
14738 ;; If this method was previously denied, we just return nil.
14739 (if (eq (nth 1 elem) 'denied)
14741 (gnus-message 1 "Denied server")
14743 ;; Open the server.
14745 (funcall (gnus-get-function method 'open-server)
14746 (nth 1 method) (nthcdr 2 method))))
14747 ;; If this hasn't been opened before, we add it to the list.
14749 (setq elem (list method nil)
14750 gnus-opened-servers (cons elem gnus-opened-servers)))
14751 ;; Set the status of this server.
14752 (setcar (cdr elem) (if result 'ok 'denied))
14753 ;; Return the result from the "open" call.
14756 (defun gnus-close-server (method)
14757 "Close the connection to METHOD."
14758 (when (stringp method)
14759 (setq method (gnus-server-to-method method)))
14760 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14762 (defun gnus-request-list (method)
14763 "Request the active file from METHOD."
14764 (when (stringp method)
14765 (setq method (gnus-server-to-method method)))
14766 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14768 (defun gnus-request-list-newsgroups (method)
14769 "Request the newsgroups file from METHOD."
14770 (when (stringp method)
14771 (setq method (gnus-server-to-method method)))
14772 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14774 (defun gnus-request-newgroups (date method)
14775 "Request all new groups since DATE from METHOD."
14776 (when (stringp method)
14777 (setq method (gnus-server-to-method method)))
14778 (funcall (gnus-get-function method 'request-newgroups)
14779 date (nth 1 method)))
14781 (defun gnus-server-opened (method)
14782 "Check whether a connection to METHOD has been opened."
14783 (when (stringp method)
14784 (setq method (gnus-server-to-method method)))
14785 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14787 (defun gnus-status-message (method)
14788 "Return the status message from METHOD.
14789 If METHOD is a string, it is interpreted as a group name. The method
14790 this group uses will be queried."
14791 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14793 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14795 (defun gnus-request-group (group &optional dont-check method)
14796 "Request GROUP. If DONT-CHECK, no information is required."
14797 (let ((method (or method (gnus-find-method-for-group group))))
14798 (when (stringp method)
14799 (setq method (gnus-server-to-method method)))
14800 (funcall (gnus-get-function method 'request-group)
14801 (gnus-group-real-name group) (nth 1 method) dont-check)))
14803 (defun gnus-request-asynchronous (group &optional articles)
14804 "Request that GROUP behave asynchronously.
14805 ARTICLES is the `data' of the group."
14806 (let ((method (gnus-find-method-for-group group)))
14807 (funcall (gnus-get-function method 'request-asynchronous)
14808 (gnus-group-real-name group) (nth 1 method) articles)))
14810 (defun gnus-list-active-group (group)
14811 "Request active information on GROUP."
14812 (let ((method (gnus-find-method-for-group group))
14813 (func 'list-active-group))
14814 (when (gnus-check-backend-function func group)
14815 (funcall (gnus-get-function method func)
14816 (gnus-group-real-name group) (nth 1 method)))))
14818 (defun gnus-request-group-description (group)
14819 "Request a description of GROUP."
14820 (let ((method (gnus-find-method-for-group group))
14821 (func 'request-group-description))
14822 (when (gnus-check-backend-function func group)
14823 (funcall (gnus-get-function method func)
14824 (gnus-group-real-name group) (nth 1 method)))))
14826 (defun gnus-close-group (group)
14827 "Request the GROUP be closed."
14828 (let ((method (gnus-find-method-for-group group)))
14829 (funcall (gnus-get-function method 'close-group)
14830 (gnus-group-real-name group) (nth 1 method))))
14832 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14833 "Request headers for ARTICLES in GROUP.
14834 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14835 (let ((method (gnus-find-method-for-group group)))
14836 (if (and gnus-use-cache (numberp (car articles)))
14837 (gnus-cache-retrieve-headers articles group fetch-old)
14838 (funcall (gnus-get-function method 'retrieve-headers)
14839 articles (gnus-group-real-name group) (nth 1 method)
14842 (defun gnus-retrieve-groups (groups method)
14843 "Request active information on GROUPS from METHOD."
14844 (when (stringp method)
14845 (setq method (gnus-server-to-method method)))
14846 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14848 (defun gnus-request-type (group &optional article)
14849 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14850 (let ((method (gnus-find-method-for-group group)))
14851 (if (not (gnus-check-backend-function 'request-type (car method)))
14853 (funcall (gnus-get-function method 'request-type)
14854 (gnus-group-real-name group) article))))
14856 (defun gnus-request-update-mark (group article mark)
14857 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14858 (let ((method (gnus-find-method-for-group group)))
14859 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14861 (funcall (gnus-get-function method 'request-update-mark)
14862 (gnus-group-real-name group) article mark))))
14864 (defun gnus-request-article (article group &optional buffer)
14865 "Request the ARTICLE in GROUP.
14866 ARTICLE can either be an article number or an article Message-ID.
14867 If BUFFER, insert the article in that group."
14868 (let ((method (gnus-find-method-for-group group)))
14869 (funcall (gnus-get-function method 'request-article)
14870 article (gnus-group-real-name group) (nth 1 method) buffer)))
14872 (defun gnus-request-head (article group)
14873 "Request the head of ARTICLE in GROUP."
14874 (let ((method (gnus-find-method-for-group group)))
14875 (funcall (gnus-get-function method 'request-head)
14876 article (gnus-group-real-name group) (nth 1 method))))
14878 (defun gnus-request-body (article group)
14879 "Request the body of ARTICLE in GROUP."
14880 (let ((method (gnus-find-method-for-group group)))
14881 (funcall (gnus-get-function method 'request-body)
14882 article (gnus-group-real-name group) (nth 1 method))))
14884 (defun gnus-request-post (method)
14885 "Post the current buffer using METHOD."
14886 (when (stringp method)
14887 (setq method (gnus-server-to-method method)))
14888 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14890 (defun gnus-request-scan (group method)
14891 "Request a SCAN being performed in GROUP from METHOD.
14892 If GROUP is nil, all groups on METHOD are scanned."
14893 (let ((method (if group (gnus-find-method-for-group group) method)))
14894 (funcall (gnus-get-function method 'request-scan)
14895 (and group (gnus-group-real-name group)) (nth 1 method))))
14897 (defsubst gnus-request-update-info (info method)
14898 "Request that METHOD update INFO."
14899 (when (stringp method)
14900 (setq method (gnus-server-to-method method)))
14901 (when (gnus-check-backend-function 'request-update-info (car method))
14902 (funcall (gnus-get-function method 'request-update-info)
14903 (gnus-group-real-name (gnus-info-group info))
14904 info (nth 1 method))))
14906 (defun gnus-request-expire-articles (articles group &optional force)
14907 (let ((method (gnus-find-method-for-group group)))
14908 (funcall (gnus-get-function method 'request-expire-articles)
14909 articles (gnus-group-real-name group) (nth 1 method)
14912 (defun gnus-request-move-article
14913 (article group server accept-function &optional last)
14914 (let ((method (gnus-find-method-for-group group)))
14915 (funcall (gnus-get-function method 'request-move-article)
14916 article (gnus-group-real-name group)
14917 (nth 1 method) accept-function last)))
14919 (defun gnus-request-accept-article (group method &optional last)
14920 ;; Make sure there's a newline at the end of the article.
14921 (when (stringp method)
14922 (setq method (gnus-server-to-method method)))
14923 (when (and (not method)
14925 (setq method (gnus-find-method-for-group group)))
14926 (goto-char (point-max))
14929 (let ((func (car (or method (gnus-find-method-for-group group)))))
14930 (funcall (intern (format "%s-request-accept-article" func))
14931 (if (stringp group) (gnus-group-real-name group) group)
14935 (defun gnus-request-replace-article (article group buffer)
14936 (let ((func (car (gnus-find-method-for-group group))))
14937 (funcall (intern (format "%s-request-replace-article" func))
14938 article (gnus-group-real-name group) buffer)))
14940 (defun gnus-request-associate-buffer (group)
14941 (let ((method (gnus-find-method-for-group group)))
14942 (funcall (gnus-get-function method 'request-associate-buffer)
14943 (gnus-group-real-name group))))
14945 (defun gnus-request-restore-buffer (article group)
14946 "Request a new buffer restored to the state of ARTICLE."
14947 (let ((method (gnus-find-method-for-group group)))
14948 (funcall (gnus-get-function method 'request-restore-buffer)
14949 article (gnus-group-real-name group) (nth 1 method))))
14951 (defun gnus-request-create-group (group &optional method)
14952 (when (stringp method)
14953 (setq method (gnus-server-to-method method)))
14954 (let ((method (or method (gnus-find-method-for-group group))))
14955 (funcall (gnus-get-function method 'request-create-group)
14956 (gnus-group-real-name group) (nth 1 method))))
14958 (defun gnus-request-delete-group (group &optional force)
14959 (let ((method (gnus-find-method-for-group group)))
14960 (funcall (gnus-get-function method 'request-delete-group)
14961 (gnus-group-real-name group) force (nth 1 method))))
14963 (defun gnus-request-rename-group (group new-name)
14964 (let ((method (gnus-find-method-for-group group)))
14965 (funcall (gnus-get-function method 'request-rename-group)
14966 (gnus-group-real-name group)
14967 (gnus-group-real-name new-name) (nth 1 method))))
14969 (defun gnus-member-of-valid (symbol group)
14970 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14971 (memq symbol (assoc
14972 (symbol-name (car (gnus-find-method-for-group group)))
14973 gnus-valid-select-methods)))
14975 (defun gnus-method-option-p (method option)
14976 "Return non-nil if select METHOD has OPTION as a parameter."
14977 (when (stringp method)
14978 (setq method (gnus-server-to-method method)))
14979 (memq option (assoc (format "%s" (car method))
14980 gnus-valid-select-methods)))
14982 (defun gnus-server-extend-method (group method)
14983 ;; This function "extends" a virtual server. If the server is
14984 ;; "hello", and the select method is ("hello" (my-var "something"))
14985 ;; in the group "alt.alt", this will result in a new virtual server
14986 ;; called "hello+alt.alt".
14988 (gnus-copy-sequence
14989 (if (equal (car method) "native") gnus-select-method
14990 (cdr (assoc (car method) gnus-server-alist))))))
14991 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14992 (nconc entry (cdr method))))
14994 (defun gnus-find-method-for-group (group &optional info)
14995 "Find the select method that GROUP uses."
14996 (or gnus-override-method
14998 gnus-select-method)
14999 (let ((info (or info (gnus-get-info group)))
15002 (not (setq method (gnus-info-method info)))
15003 (equal method "native"))
15006 (cond ((stringp method)
15007 (gnus-server-to-method method))
15008 ((stringp (car method))
15009 (gnus-server-extend-method group method))
15012 (if (equal (cadr method) "")
15014 (gnus-server-add-address method))))))
15016 (defun gnus-check-backend-function (func group)
15017 "Check whether GROUP supports function FUNC."
15018 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15020 (fboundp (intern (format "%s-%s" method func)))))
15022 (defun gnus-methods-using (feature)
15023 "Find all methods that have FEATURE."
15024 (let ((valids gnus-valid-select-methods)
15027 (if (memq feature (car valids))
15028 (setq outs (cons (car valids) outs)))
15029 (setq valids (cdr valids)))
15034 ;;; Active & Newsrc File Handling
15037 (defun gnus-setup-news (&optional rawfile level dont-connect)
15038 "Setup news information.
15039 If RAWFILE is non-nil, the .newsrc file will also be read.
15040 If LEVEL is non-nil, the news will be set up at level LEVEL."
15041 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15044 ;; Clear some variables to re-initialize news information.
15045 (setq gnus-newsrc-alist nil
15046 gnus-active-hashtb nil)
15047 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15048 (gnus-read-newsrc-file rawfile))
15050 (when (and (not (assoc "archive" gnus-server-alist))
15051 gnus-message-archive-method)
15052 (push (cons "archive" gnus-message-archive-method)
15053 gnus-server-alist))
15055 ;; If we don't read the complete active file, we fill in the
15057 (if (or (null gnus-read-active-file)
15058 (eq gnus-read-active-file 'some))
15059 (gnus-update-active-hashtb-from-killed))
15061 ;; Read the active file and create `gnus-active-hashtb'.
15062 ;; If `gnus-read-active-file' is nil, then we just create an empty
15063 ;; hash table. The partial filling out of the hash table will be
15064 ;; done in `gnus-get-unread-articles'.
15065 (and gnus-read-active-file
15067 (gnus-read-active-file))
15069 (or gnus-active-hashtb
15070 (setq gnus-active-hashtb (make-vector 4095 0)))
15072 ;; Initialize the cache.
15073 (when gnus-use-cache
15076 ;; Possibly eval the dribble file.
15077 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15079 (gnus-update-format-specifications)
15081 ;; See whether we need to read the description file.
15082 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15083 (not gnus-description-hashtb)
15085 gnus-read-active-file)
15086 (gnus-read-all-descriptions-files))
15088 ;; Find new newsgroups and treat them.
15089 (if (and init gnus-check-new-newsgroups (not level)
15090 (gnus-check-server gnus-select-method))
15091 (gnus-find-new-newsgroups))
15093 ;; We might read in new NoCeM messages here.
15094 (when gnus-use-nocem
15095 (gnus-nocem-scan-groups))
15097 ;; Find the number of unread articles in each non-dead group.
15098 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15099 (gnus-get-unread-articles level))
15101 (if (and init gnus-check-bogus-newsgroups
15102 gnus-read-active-file (not level)
15103 (gnus-server-opened gnus-select-method))
15104 (gnus-check-bogus-newsgroups))))
15106 (defun gnus-find-new-newsgroups (&optional arg)
15107 "Search for new newsgroups and add them.
15108 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15109 The `-n' option line from .newsrc is respected.
15110 If ARG (the prefix), use the `ask-server' method to query
15111 the server for new groups."
15113 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15114 (null gnus-read-active-file)
15115 (eq gnus-read-active-file 'some))
15116 'ask-server gnus-check-new-newsgroups)))
15117 (unless (gnus-check-first-time-used)
15118 (if (or (consp check)
15119 (eq check 'ask-server))
15120 ;; Ask the server for new groups.
15121 (gnus-ask-server-for-new-groups)
15122 ;; Go through the active hashtb and look for new groups.
15124 group new-newsgroups)
15125 (gnus-message 5 "Looking for new newsgroups...")
15126 (unless gnus-have-read-active-file
15127 (gnus-read-active-file))
15128 (setq gnus-newsrc-last-checked-date (current-time-string))
15129 (unless gnus-killed-hashtb
15130 (gnus-make-hashtable-from-killed))
15131 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15132 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15135 (if (or (null (setq group (symbol-name sym)))
15137 (null (symbol-value sym))
15138 (gnus-gethash group gnus-killed-hashtb)
15139 (gnus-gethash group gnus-newsrc-hashtb))
15141 (let ((do-sub (gnus-matches-options-n group)))
15143 ((eq do-sub 'subscribe)
15144 (setq groups (1+ groups))
15145 (gnus-sethash group group gnus-killed-hashtb)
15146 (funcall gnus-subscribe-options-newsgroup-method group))
15147 ((eq do-sub 'ignore)
15150 (setq groups (1+ groups))
15151 (gnus-sethash group group gnus-killed-hashtb)
15152 (if gnus-subscribe-hierarchical-interactive
15153 (setq new-newsgroups (cons group new-newsgroups))
15154 (funcall gnus-subscribe-newsgroup-method group)))))))
15155 gnus-active-hashtb)
15156 (when new-newsgroups
15157 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15158 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15160 (gnus-message 6 "%d new newsgroup%s arrived."
15161 groups (if (> groups 1) "s have" " has"))
15162 (gnus-message 6 "No new newsgroups.")))))))
15164 (defun gnus-matches-options-n (group)
15165 ;; Returns `subscribe' if the group is to be unconditionally
15166 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15167 ;; no match for the group.
15169 ;; First we check the two user variables.
15171 ((and gnus-options-subscribe
15172 (string-match gnus-options-subscribe group))
15174 ((and gnus-auto-subscribed-groups
15175 (string-match gnus-auto-subscribed-groups group))
15177 ((and gnus-options-not-subscribe
15178 (string-match gnus-options-not-subscribe group))
15180 ;; Then we go through the list that was retrieved from the .newsrc
15181 ;; file. This list has elements on the form
15182 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15183 ;; is in the reverse order of the options line) is returned.
15185 (let ((regs gnus-newsrc-options-n))
15187 (not (string-match (caar regs) group)))
15188 (setq regs (cdr regs)))
15189 (and regs (cdar regs))))))
15191 (defun gnus-ask-server-for-new-groups ()
15192 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15193 (methods (cons gnus-select-method
15195 (when gnus-message-archive-method
15198 (and (consp gnus-check-new-newsgroups)
15199 gnus-check-new-newsgroups)
15200 gnus-secondary-select-methods))))
15202 (new-date (current-time-string))
15203 group new-newsgroups got-new method hashtb
15204 gnus-override-subscribe-method)
15205 ;; Go through both primary and secondary select methods and
15206 ;; request new newsgroups.
15207 (while (setq method (gnus-server-get-method nil (pop methods)))
15208 (setq new-newsgroups nil)
15209 (setq gnus-override-subscribe-method method)
15210 (when (and (gnus-check-server method)
15211 (gnus-request-newgroups date method))
15214 (setq hashtb (gnus-make-hashtable 100))
15215 (set-buffer nntp-server-buffer)
15216 ;; Enter all the new groups into a hashtable.
15217 (gnus-active-to-gnus-format method hashtb 'ignore)))
15218 ;; Now all new groups from `method' are in `hashtb'.
15220 (lambda (group-sym)
15221 (if (or (null (setq group (symbol-name group-sym)))
15222 (null (symbol-value group-sym))
15223 (gnus-gethash group gnus-newsrc-hashtb)
15224 (member group gnus-zombie-list)
15225 (member group gnus-killed-list))
15226 ;; The group is already known.
15228 ;; Make this group active.
15229 (when (symbol-value group-sym)
15230 (gnus-set-active group (symbol-value group-sym)))
15231 ;; Check whether we want it or not.
15232 (let ((do-sub (gnus-matches-options-n group)))
15234 ((eq do-sub 'subscribe)
15236 (gnus-sethash group group gnus-killed-hashtb)
15237 (funcall gnus-subscribe-options-newsgroup-method group))
15238 ((eq do-sub 'ignore)
15242 (gnus-sethash group group gnus-killed-hashtb)
15243 (if gnus-subscribe-hierarchical-interactive
15244 (push group new-newsgroups)
15245 (funcall gnus-subscribe-newsgroup-method group)))))))
15247 (when new-newsgroups
15248 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15249 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15251 (gnus-message 6 "%d new newsgroup%s arrived."
15252 groups (if (> groups 1) "s have" " has")))
15253 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15256 (defun gnus-check-first-time-used ()
15257 (if (or (> (length gnus-newsrc-alist) 1)
15258 (file-exists-p gnus-startup-file)
15259 (file-exists-p (concat gnus-startup-file ".el"))
15260 (file-exists-p (concat gnus-startup-file ".eld")))
15262 (gnus-message 6 "First time user; subscribing you to default groups")
15263 (unless gnus-have-read-active-file
15264 (gnus-read-active-file))
15265 (setq gnus-newsrc-last-checked-date (current-time-string))
15266 (let ((groups gnus-default-subscribed-newsgroups)
15270 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15273 (if (null (setq group (symbol-name sym)))
15275 (let ((do-sub (gnus-matches-options-n group)))
15277 ((eq do-sub 'subscribe)
15278 (gnus-sethash group group gnus-killed-hashtb)
15279 (funcall gnus-subscribe-options-newsgroup-method group))
15280 ((eq do-sub 'ignore)
15283 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15284 gnus-active-hashtb)
15286 (if (gnus-active (car groups))
15287 (gnus-group-change-level
15288 (car groups) gnus-level-default-subscribed gnus-level-killed))
15289 (setq groups (cdr groups)))
15290 (gnus-group-make-help-group)
15291 (and gnus-novice-user
15292 (gnus-message 7 "`A k' to list killed groups"))))))
15294 (defun gnus-subscribe-group (group previous &optional method)
15295 (gnus-group-change-level
15297 (list t group gnus-level-default-subscribed nil nil method)
15299 gnus-level-default-subscribed gnus-level-killed previous t))
15301 ;; `gnus-group-change-level' is the fundamental function for changing
15302 ;; subscription levels of newsgroups. This might mean just changing
15303 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15304 ;; again, which subscribes/unsubscribes a group, which is equally
15305 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15306 ;; from 8-9 to 1-7 means that you remove the group from the list of
15307 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15308 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15309 ;; which is trivial.
15310 ;; ENTRY can either be a string (newsgroup name) or a list (if
15311 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15312 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15314 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15315 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15317 (defun gnus-group-change-level (entry level &optional oldlevel
15318 previous fromkilled)
15319 (let (group info active num)
15320 ;; Glean what info we can from the arguments
15322 (if fromkilled (setq group (nth 1 entry))
15323 (setq group (car (nth 2 entry))))
15324 (setq group entry))
15325 (if (and (stringp entry)
15327 (< oldlevel gnus-level-zombie))
15328 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15329 (if (and (not oldlevel)
15331 (setq oldlevel (gnus-info-level (nth 2 entry)))
15332 (setq oldlevel (or oldlevel 9)))
15333 (if (stringp previous)
15334 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15336 (if (and (>= oldlevel gnus-level-zombie)
15337 (gnus-gethash group gnus-newsrc-hashtb))
15338 ;; We are trying to subscribe a group that is already
15342 (or (gnus-ephemeral-group-p group)
15343 (gnus-dribble-enter
15344 (format "(gnus-group-change-level %S %S %S %S %S)"
15345 group level oldlevel (car (nth 2 previous)) fromkilled)))
15347 ;; Then we remove the newgroup from any old structures, if needed.
15348 ;; If the group was killed, we remove it from the killed or zombie
15349 ;; list. If not, and it is in fact going to be killed, we remove
15350 ;; it from the newsrc hash table and assoc.
15352 ((>= oldlevel gnus-level-zombie)
15353 (if (= oldlevel gnus-level-zombie)
15354 (setq gnus-zombie-list (delete group gnus-zombie-list))
15355 (setq gnus-killed-list (delete group gnus-killed-list))))
15357 (if (and (>= level gnus-level-zombie)
15360 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15362 (setcdr (gnus-gethash (car (nth 3 entry))
15363 gnus-newsrc-hashtb)
15365 (setcdr (cdr entry) (cdddr entry))))))
15367 ;; Finally we enter (if needed) the list where it is supposed to
15368 ;; go, and change the subscription level. If it is to be killed,
15369 ;; we enter it into the killed or zombie list.
15371 ((>= level gnus-level-zombie)
15372 ;; Remove from the hash table.
15373 (gnus-sethash group nil gnus-newsrc-hashtb)
15374 ;; We do not enter foreign groups into the list of dead
15376 (unless (gnus-group-foreign-p group)
15377 (if (= level gnus-level-zombie)
15378 (setq gnus-zombie-list (cons group gnus-zombie-list))
15379 (setq gnus-killed-list (cons group gnus-killed-list)))))
15381 ;; If the list is to be entered into the newsrc assoc, and
15382 ;; it was killed, we have to create an entry in the newsrc
15383 ;; hashtb format and fix the pointers in the newsrc assoc.
15384 (if (< oldlevel gnus-level-zombie)
15385 ;; It was alive, and it is going to stay alive, so we
15386 ;; just change the level and don't change any pointers or
15387 ;; hash table entries.
15388 (setcar (cdaddr entry) level)
15390 (setq info (cdr entry)
15392 (setq active (gnus-active group))
15394 (if active (- (1+ (cdr active)) (car active)) t))
15395 ;; Check whether the group is foreign. If so, the
15396 ;; foreign select method has to be entered into the
15398 (let ((method (or gnus-override-subscribe-method
15399 (gnus-group-method group))))
15400 (if (eq method gnus-select-method)
15401 (setq info (list group level nil))
15402 (setq info (list group level nil nil method)))))
15405 (let ((p gnus-newsrc-alist))
15409 (setq entry (cons info (cddr previous)))
15412 (setcdr (cdr previous) entry)
15413 (gnus-sethash group (cons num (cdr previous))
15414 gnus-newsrc-hashtb))
15415 (setcdr previous entry)
15416 (gnus-sethash group (cons num previous)
15417 gnus-newsrc-hashtb))
15419 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15420 (when gnus-group-change-level-function
15421 (funcall gnus-group-change-level-function group level oldlevel)))))
15423 (defun gnus-kill-newsgroup (newsgroup)
15424 "Obsolete function. Kills a newsgroup."
15425 (gnus-group-change-level
15426 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15428 (defun gnus-check-bogus-newsgroups (&optional confirm)
15429 "Remove bogus newsgroups.
15430 If CONFIRM is non-nil, the user has to confirm the deletion of every
15432 (let ((newsrc (cdr gnus-newsrc-alist))
15433 bogus group entry info)
15434 (gnus-message 5 "Checking bogus newsgroups...")
15435 (unless gnus-have-read-active-file
15436 (gnus-read-active-file))
15437 (when (member gnus-select-method gnus-have-read-active-file)
15438 ;; Find all bogus newsgroup that are subscribed.
15440 (setq info (pop newsrc)
15441 group (gnus-info-group info))
15442 (unless (or (gnus-active group) ; Active
15443 (gnus-info-method info) ; Foreign
15445 (not (gnus-y-or-n-p
15446 (format "Remove bogus newsgroup: %s " group)))))
15447 ;; Found a bogus newsgroup.
15448 (push group bogus)))
15449 ;; Remove all bogus subscribed groups by first killing them, and
15450 ;; then removing them from the list of killed groups.
15452 (when (setq entry (gnus-gethash (setq group (pop bogus))
15453 gnus-newsrc-hashtb))
15454 (gnus-group-change-level entry gnus-level-killed)
15455 (setq gnus-killed-list (delete group gnus-killed-list))))
15456 ;; Then we remove all bogus groups from the list of killed and
15457 ;; zombie groups. They are are removed without confirmation.
15458 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15461 (setq killed (symbol-value (car dead-lists)))
15463 (unless (gnus-active (setq group (pop killed)))
15464 ;; The group is bogus.
15465 ;; !!!Slow as hell.
15466 (set (car dead-lists)
15467 (delete group (symbol-value (car dead-lists))))))
15468 (setq dead-lists (cdr dead-lists))))
15469 (gnus-message 5 "Checking bogus newsgroups...done"))))
15471 (defun gnus-check-duplicate-killed-groups ()
15472 "Remove duplicates from the list of killed groups."
15474 (let ((killed gnus-killed-list))
15476 (gnus-message 9 "%d" (length killed))
15477 (setcdr killed (delete (car killed) (cdr killed)))
15478 (setq killed (cdr killed)))))
15480 ;; We want to inline a function from gnus-cache, so we cheat here:
15483 (require 'gnus-cache))
15485 (defun gnus-get-unread-articles-in-group (info active &optional update)
15487 ;; Allow the backend to update the info in the group.
15489 (gnus-request-update-info
15490 info (gnus-find-method-for-group (gnus-info-group info))))
15491 (gnus-activate-group (gnus-info-group info) nil t))
15492 (let* ((range (gnus-info-read info))
15494 ;; If a cache is present, we may have to alter the active info.
15495 (when (and gnus-use-cache info)
15496 (inline (gnus-cache-possibly-alter-active
15497 (gnus-info-group info) active)))
15498 ;; Modify the list of read articles according to what articles
15499 ;; are available; then tally the unread articles and add the
15500 ;; number to the group hash table entry.
15502 ((zerop (cdr active))
15505 (setq num (- (1+ (cdr active)) (car active))))
15506 ((not (listp (cdr range)))
15507 ;; Fix a single (num . num) range according to the
15508 ;; active hash table.
15509 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15510 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15511 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15512 ;; Compute number of unread articles.
15513 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15515 ;; The read list is a list of ranges. Fix them according to
15516 ;; the active hash table.
15517 ;; First peel off any elements that are below the lower
15519 (while (and (cdr range)
15521 (or (and (atom (cadr range)) (cadr range))
15523 (if (numberp (car range))
15526 (or (and (numberp (cadr range))
15529 (setcdr (car range)
15530 (or (and (numberp (nth 1 range)) (nth 1 range))
15532 (setcdr range (cddr range)))
15533 ;; Adjust the first element to be the same as the lower limit.
15534 (if (and (not (atom (car range)))
15535 (< (cdar range) (car active)))
15536 (setcdr (car range) (1- (car active))))
15537 ;; Then we want to peel off any elements that are higher
15538 ;; than the upper active limit.
15539 (let ((srange range))
15540 ;; Go past all legal elements.
15541 (while (and (cdr srange)
15542 (<= (or (and (atom (cadr srange))
15544 (caadr srange)) (cdr active)))
15545 (setq srange (cdr srange)))
15547 ;; Nuke all remaining illegal elements.
15548 (setcdr srange nil))
15550 ;; Adjust the final element.
15551 (if (and (not (atom (car srange)))
15552 (> (cdar srange) (cdr active)))
15553 (setcdr (car srange) (cdr active))))
15554 ;; Compute the number of unread articles.
15556 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15558 (or (and (atom (car range)) (car range))
15560 (setq range (cdr range)))
15561 (setq num (max 0 (- (cdr active) num)))))
15562 ;; Set the number of unread articles.
15564 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15567 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15568 ;; and compute how many unread articles there are in each group.
15569 (defun gnus-get-unread-articles (&optional level)
15570 (let* ((newsrc (cdr gnus-newsrc-alist))
15571 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15574 (cond ((and gnus-activate-foreign-newsgroups
15575 (not (numberp gnus-activate-foreign-newsgroups)))
15576 (1+ gnus-level-subscribed))
15577 ((numberp gnus-activate-foreign-newsgroups)
15578 gnus-activate-foreign-newsgroups)
15581 info group active method)
15582 (gnus-message 5 "Checking new news...")
15585 (setq active (gnus-active (setq group (gnus-info-group
15586 (setq info (pop newsrc))))))
15588 ;; Check newsgroups. If the user doesn't want to check them, or
15589 ;; they can't be checked (for instance, if the news server can't
15590 ;; be reached) we just set the number of unread articles in this
15591 ;; newsgroup to t. This means that Gnus thinks that there are
15592 ;; unread articles, but it has no idea how many.
15593 (if (and (setq method (gnus-info-method info))
15594 (not (gnus-server-equal
15596 (setq method (gnus-server-get-method nil method))))
15597 (not (gnus-secondary-method-p method)))
15598 ;; These groups are foreign. Check the level.
15599 (when (<= (gnus-info-level info) foreign-level)
15600 (setq active (gnus-activate-group group 'scan))
15601 (unless (inline (gnus-virtual-group-p group))
15602 (inline (gnus-close-group group))))
15604 ;; These groups are native or secondary.
15605 (when (and (<= (gnus-info-level info) level)
15606 (not gnus-read-active-file))
15607 (setq active (gnus-activate-group group 'scan))
15608 (inline (gnus-close-group group))))
15611 (inline (gnus-get-unread-articles-in-group
15614 (fboundp (intern (concat (symbol-name (car method))
15615 "-request-update-info"))))))
15616 ;; The group couldn't be reached, so we nix out the number of
15617 ;; unread articles and stuff.
15618 (gnus-set-active group nil)
15619 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15621 (gnus-message 5 "Checking new news...done")))
15623 ;; Create a hash table out of the newsrc alist. The `car's of the
15624 ;; alist elements are used as keys.
15625 (defun gnus-make-hashtable-from-newsrc-alist ()
15626 (let ((alist gnus-newsrc-alist)
15627 (ohashtb gnus-newsrc-hashtb)
15629 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15631 (setq prev (setq gnus-newsrc-alist
15632 (if (equal (caar gnus-newsrc-alist)
15635 (cons (list "dummy.group" 0 nil) alist)))))
15639 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15641 gnus-newsrc-hashtb)
15643 alist (cdr alist)))))
15645 (defun gnus-make-hashtable-from-killed ()
15646 "Create a hash table from the killed and zombie lists."
15647 (let ((lists '(gnus-killed-list gnus-zombie-list))
15649 (setq gnus-killed-hashtb
15650 (gnus-make-hashtable
15651 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15652 (while (setq list (pop lists))
15653 (setq list (symbol-value list))
15655 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15657 (defun gnus-activate-group (group &optional scan dont-check)
15658 ;; Check whether a group has been activated or not.
15659 ;; If SCAN, request a scan of that group as well.
15660 (let ((method (gnus-find-method-for-group group))
15662 (and (gnus-check-server method)
15663 ;; We escape all bugs and quit here to make it possible to
15664 ;; continue if a group is so out-there that it reports bugs
15668 (gnus-check-backend-function 'request-scan (car method))
15669 (gnus-request-scan group method))
15672 (gnus-request-group group dont-check)
15676 (set-buffer nntp-server-buffer)
15677 (goto-char (point-min))
15678 ;; Parse the result we got from `gnus-request-group'.
15679 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15681 (goto-char (match-beginning 1))
15683 group (setq active (cons (read (current-buffer))
15684 (read (current-buffer)))))
15685 ;; Return the new active info.
15688 (defun gnus-update-read-articles (group unread)
15689 "Update the list of read and ticked articles in GROUP using the
15690 UNREAD and TICKED lists.
15691 Note: UNSELECTED has to be sorted over `<'.
15692 Returns whether the updating was successful."
15693 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15694 (entry (gnus-gethash group gnus-newsrc-hashtb))
15695 (info (nth 2 entry))
15697 (unread (sort (copy-sequence unread) '<))
15699 (if (or (not info) (not active))
15700 ;; There is no info on this group if it was, in fact,
15701 ;; killed. Gnus stores no information on killed groups, so
15702 ;; there's nothing to be done.
15703 ;; One could store the information somewhere temporarily,
15704 ;; perhaps... Hmmm...
15706 ;; Remove any negative articles numbers.
15707 (while (and unread (< (car unread) 0))
15708 (setq unread (cdr unread)))
15709 ;; Remove any expired article numbers
15710 (while (and unread (< (car unread) (car active)))
15711 (setq unread (cdr unread)))
15712 ;; Compute the ranges of read articles by looking at the list of
15713 ;; unread articles.
15715 (if (/= (car unread) prev)
15716 (setq read (cons (if (= prev (1- (car unread))) prev
15717 (cons prev (1- (car unread)))) read)))
15718 (setq prev (1+ (car unread)))
15719 (setq unread (cdr unread)))
15720 (when (<= prev (cdr active))
15721 (setq read (cons (cons prev (cdr active)) read)))
15722 ;; Enter this list into the group info.
15723 (gnus-info-set-read
15724 info (if (> (length read) 1) (nreverse read) read))
15725 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15726 (gnus-get-unread-articles-in-group info (gnus-active group))
15729 (defun gnus-make-articles-unread (group articles)
15730 "Mark ARTICLES in GROUP as unread."
15731 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15732 (gnus-gethash (gnus-group-real-name group)
15733 gnus-newsrc-hashtb))))
15734 (ranges (gnus-info-read info))
15737 (when (gnus-member-of-range
15738 (setq article (pop articles)) ranges)
15739 (setq news (cons article news))))
15741 (gnus-info-set-read
15742 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15743 (gnus-group-update-group group t))))
15745 ;; Enter all dead groups into the hashtb.
15746 (defun gnus-update-active-hashtb-from-killed ()
15747 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15748 (lists (list gnus-killed-list gnus-zombie-list))
15751 (setq killed (car lists))
15753 (gnus-sethash (car killed) nil hashtb)
15754 (setq killed (cdr killed)))
15755 (setq lists (cdr lists)))))
15757 ;; Get the active file(s) from the backend(s).
15758 (defun gnus-read-active-file ()
15759 (gnus-group-set-mode-line)
15762 (if (gnus-check-server gnus-select-method)
15763 ;; The native server is available.
15764 (cons gnus-select-method gnus-secondary-select-methods)
15765 ;; The native server is down, so we just do the
15767 gnus-secondary-select-methods)
15768 ;; Also read from the archive server.
15769 (when gnus-message-archive-method
15770 (list "archive"))))
15772 (setq gnus-have-read-active-file nil)
15774 (set-buffer nntp-server-buffer)
15776 (let* ((method (if (stringp (car methods))
15777 (gnus-server-get-method nil (car methods))
15779 (where (nth 1 method))
15780 (mesg (format "Reading active file%s via %s..."
15781 (if (and where (not (zerop (length where))))
15782 (concat " from " where) "")
15784 (gnus-message 5 mesg)
15785 (when (gnus-check-server method)
15786 ;; Request that the backend scan its incoming messages.
15787 (and (gnus-check-backend-function 'request-scan (car method))
15788 (gnus-request-scan nil method))
15790 ((and (eq gnus-read-active-file 'some)
15791 (gnus-check-backend-function 'retrieve-groups (car method)))
15792 (let ((newsrc (cdr gnus-newsrc-alist))
15793 (gmethod (gnus-server-get-method nil method))
15795 (while (setq info (pop newsrc))
15796 (when (gnus-server-equal
15797 (gnus-find-method-for-group
15798 (gnus-info-group info) info)
15800 (push (gnus-group-real-name (gnus-info-group info))
15803 (gnus-check-server method)
15804 (setq list-type (gnus-retrieve-groups groups method))
15808 1 "Cannot read partial active file from %s server."
15812 ((eq list-type 'active)
15813 (gnus-active-to-gnus-format method gnus-active-hashtb))
15815 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15817 (if (not (gnus-request-list method))
15819 (unless (equal method gnus-message-archive-method)
15820 (gnus-message 1 "Cannot read active file from %s server."
15823 (gnus-active-to-gnus-format method)
15824 ;; We mark this active file as read.
15825 (push method gnus-have-read-active-file)
15826 (gnus-message 5 "%sdone" mesg))))))
15827 (setq methods (cdr methods))))))
15829 ;; Read an active file and place the results in `gnus-active-hashtb'.
15830 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15832 (setq method gnus-select-method))
15833 (let ((cur (current-buffer))
15835 (if (and gnus-active-hashtb
15836 (not (equal method gnus-select-method)))
15838 (setq gnus-active-hashtb
15839 (if (equal method gnus-select-method)
15840 (gnus-make-hashtable
15841 (count-lines (point-min) (point-max)))
15842 (gnus-make-hashtable 4096)))))))
15843 ;; Delete unnecessary lines.
15844 (goto-char (point-min))
15845 (while (search-forward "\nto." nil t)
15846 (delete-region (1+ (match-beginning 0))
15847 (progn (forward-line 1) (point))))
15848 (or (string= gnus-ignored-newsgroups "")
15850 (goto-char (point-min))
15851 (delete-matching-lines gnus-ignored-newsgroups)))
15852 ;; Make the group names readable as a lisp expression even if they
15853 ;; contain special characters.
15854 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15855 (goto-char (point-max))
15856 (while (re-search-backward "[][';?()#]" nil t)
15858 ;; If these are groups from a foreign select method, we insert the
15859 ;; group prefix in front of the group names.
15860 (and method (not (gnus-server-equal
15861 (gnus-server-get-method nil method)
15862 (gnus-server-get-method nil gnus-select-method)))
15863 (let ((prefix (gnus-group-prefixed-name "" method)))
15864 (goto-char (point-min))
15865 (while (and (not (eobp))
15866 (progn (insert prefix)
15867 (zerop (forward-line 1)))))))
15868 ;; Store the active file in a hash table.
15869 (goto-char (point-min))
15870 (if (string-match "%[oO]" gnus-group-line-format)
15871 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15872 ;; If we want information on moderated groups, we use this
15874 (let* ((mod-hashtb (make-vector 7 0))
15875 (m (intern "m" mod-hashtb))
15877 (while (not (eobp))
15878 (condition-case nil
15880 (narrow-to-region (point) (gnus-point-at-eol))
15881 (setq group (let ((obarray hashtb)) (read cur)))
15882 (if (and (numberp (setq max (read cur)))
15883 (numberp (setq min (read cur)))
15885 (skip-chars-forward " \t")
15887 (or (= (following-char) ?=)
15888 (= (following-char) ?x)
15889 (= (following-char) ?j)))))
15890 (set group (cons min max))
15892 ;; Enter moderated groups into a list.
15893 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15894 (setq gnus-moderated-list
15895 (cons (symbol-name group) gnus-moderated-list))))
15902 ;; And if we do not care about moderation, we use this loop,
15903 ;; which is faster.
15904 (let (group max min)
15905 (while (not (eobp))
15908 (narrow-to-region (point) (gnus-point-at-eol))
15909 ;; group gets set to a symbol interned in the hash table
15910 ;; (what a hack!!) - jwz
15911 (setq group (let ((obarray hashtb)) (read cur)))
15912 (if (and (numberp (setq max (read cur)))
15913 (numberp (setq min (read cur)))
15915 (skip-chars-forward " \t")
15917 (or (= (following-char) ?=)
15918 (= (following-char) ?x)
15919 (= (following-char) ?j)))))
15920 (set group (cons min max))
15928 (gnus-message 3 "Warning - illegal active: %s"
15930 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15932 (forward-line 1))))))
15934 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15935 ;; Parse a "groups" active file.
15936 (let ((cur (current-buffer))
15938 (if (and method gnus-active-hashtb)
15940 (setq gnus-active-hashtb
15941 (gnus-make-hashtable
15942 (count-lines (point-min) (point-max)))))))
15943 (prefix (and method
15944 (not (gnus-server-equal
15945 (gnus-server-get-method nil method)
15946 (gnus-server-get-method nil gnus-select-method)))
15947 (gnus-group-prefixed-name "" method))))
15949 (goto-char (point-min))
15950 ;; We split this into to separate loops, one with the prefix
15951 ;; and one without to speed the reading up somewhat.
15953 (let (min max opoint group)
15954 (while (not (eobp))
15957 (read cur) (read cur)
15958 (setq min (read cur)
15961 (skip-chars-forward " \t")
15964 (set (let ((obarray hashtb)) (read cur))
15966 (error (and group (symbolp group) (set group nil))))
15968 (let (min max group)
15969 (while (not (eobp))
15971 (if (= (following-char) ?2)
15973 (read cur) (read cur)
15974 (setq min (read cur)
15976 (set (setq group (let ((obarray hashtb)) (read cur)))
15978 (error (and group (symbolp group) (set group nil))))
15979 (forward-line 1))))))
15981 (defun gnus-read-newsrc-file (&optional force)
15982 "Read startup file.
15983 If FORCE is non-nil, the .newsrc file is read."
15984 ;; Reset variables that might be defined in the .newsrc.eld file.
15985 (let ((variables gnus-variable-list))
15987 (set (car variables) nil)
15988 (setq variables (cdr variables))))
15989 (let* ((newsrc-file gnus-current-startup-file)
15990 (quick-file (concat newsrc-file ".el")))
15992 ;; We always load the .newsrc.eld file. If always contains
15993 ;; much information that can not be gotten from the .newsrc
15994 ;; file (ticked articles, killed groups, foreign methods, etc.)
15995 (gnus-read-newsrc-el-file quick-file)
15997 (if (and (file-exists-p gnus-current-startup-file)
15999 (and (file-newer-than-file-p newsrc-file quick-file)
16000 (file-newer-than-file-p newsrc-file
16001 (concat quick-file "d")))
16002 (not gnus-newsrc-alist)))
16003 ;; We read the .newsrc file. Note that if there if a
16004 ;; .newsrc.eld file exists, it has already been read, and
16005 ;; the `gnus-newsrc-hashtb' has been created. While reading
16006 ;; the .newsrc file, Gnus will only use the information it
16007 ;; can find there for changing the data already read -
16008 ;; ie. reading the .newsrc file will not trash the data
16009 ;; already read (except for read articles).
16011 (gnus-message 5 "Reading %s..." newsrc-file)
16012 (set-buffer (find-file-noselect newsrc-file))
16013 (buffer-disable-undo (current-buffer))
16014 (gnus-newsrc-to-gnus-format)
16015 (kill-buffer (current-buffer))
16016 (gnus-message 5 "Reading %s...done" newsrc-file)))
16018 ;; Read any slave files.
16020 (gnus-master-read-slave-newsrc)))))
16022 (defun gnus-read-newsrc-el-file (file)
16023 (let ((ding-file (concat file "d")))
16024 ;; We always, always read the .eld file.
16025 (gnus-message 5 "Reading %s..." ding-file)
16026 (let (gnus-newsrc-assoc)
16027 (condition-case nil
16028 (load ding-file t t t)
16030 (gnus-message 1 "Error in %s" ding-file)
16032 (when gnus-newsrc-assoc
16033 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16034 (gnus-make-hashtable-from-newsrc-alist)
16035 (when (file-newer-than-file-p file ding-file)
16036 ;; Old format quick file
16037 (gnus-message 5 "Reading %s..." file)
16038 ;; The .el file is newer than the .eld file, so we read that one
16040 (gnus-read-old-newsrc-el-file file))))
16042 ;; Parse the old-style quick startup file
16043 (defun gnus-read-old-newsrc-el-file (file)
16044 (let (newsrc killed marked group m info)
16046 (let ((gnus-killed-assoc nil)
16047 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16049 (condition-case nil
16052 (setq newsrc gnus-newsrc-assoc
16053 killed gnus-killed-assoc
16054 marked gnus-marked-assoc)))
16055 (setq gnus-newsrc-alist nil)
16056 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16059 (gnus-info-set-read info (cddr group))
16060 (gnus-info-set-level
16061 info (if (nth 1 group) gnus-level-default-subscribed
16062 gnus-level-default-unsubscribed))
16063 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16066 (if (nth 1 group) gnus-level-default-subscribed
16067 gnus-level-default-unsubscribed)
16069 gnus-newsrc-alist))
16070 ;; Copy marks into info.
16071 (when (setq m (assoc (car group) marked))
16072 (unless (nthcdr 3 info)
16073 (nconc info (list nil)))
16074 (gnus-info-set-marks
16075 info (list (cons 'tick (gnus-compress-sequence
16076 (sort (cdr m) '<) t))))))
16077 (setq newsrc killed)
16079 (setcar newsrc (caar newsrc))
16080 (setq newsrc (cdr newsrc)))
16081 (setq gnus-killed-list killed))
16082 ;; The .el file version of this variable does not begin with
16083 ;; "options", while the .eld version does, so we just add it if it
16086 gnus-newsrc-options
16088 (and (not (string-match "^ *options" gnus-newsrc-options))
16089 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16090 (and (not (string-match "\n$" gnus-newsrc-options))
16091 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16092 ;; Finally, if we read some options lines, we parse them.
16093 (or (string= gnus-newsrc-options "")
16094 (gnus-newsrc-parse-options gnus-newsrc-options))))
16096 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16097 (gnus-make-hashtable-from-newsrc-alist)))
16099 (defun gnus-make-newsrc-file (file)
16100 "Make server dependent file name by catenating FILE and server host name."
16101 (let* ((file (expand-file-name file nil))
16102 (real-file (concat file "-" (nth 1 gnus-select-method))))
16103 (if (or (file-exists-p real-file)
16104 (file-exists-p (concat real-file ".el"))
16105 (file-exists-p (concat real-file ".eld")))
16108 (defun gnus-newsrc-to-gnus-format ()
16109 (setq gnus-newsrc-options "")
16110 (setq gnus-newsrc-options-n nil)
16112 (or gnus-active-hashtb
16113 (setq gnus-active-hashtb (make-vector 4095 0)))
16114 (let ((buf (current-buffer))
16115 (already-read (> (length gnus-newsrc-alist) 1))
16116 group subscribed options-symbol newsrc Options-symbol
16118 (goto-char (point-min))
16119 ;; We intern the symbol `options' in the active hashtb so that we
16120 ;; can `eq' against it later.
16121 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16122 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16124 (while (not (eobp))
16125 ;; We first read the first word on the line by narrowing and
16126 ;; then reading into `gnus-active-hashtb'. Most groups will
16127 ;; already exist in that hashtb, so this will save some string
16131 (progn (skip-chars-forward "^ \t!:\n") (point)))
16132 (goto-char (point-min))
16134 (and (/= (point-min) (point-max))
16135 (let ((obarray gnus-active-hashtb)) (read buf))))
16137 ;; Now, the symbol we have read is either `options' or a group
16138 ;; name. If it is an options line, we just add it to a string.
16140 ((or (eq symbol options-symbol)
16141 (eq symbol Options-symbol))
16142 (setq gnus-newsrc-options
16143 ;; This concating is quite inefficient, but since our
16144 ;; thorough studies show that approx 99.37% of all
16145 ;; .newsrc files only contain a single options line, we
16146 ;; don't give a damn, frankly, my dear.
16147 (concat gnus-newsrc-options
16149 (gnus-point-at-bol)
16150 ;; Options may continue on the next line.
16151 (or (and (re-search-forward "^[^ \t]" nil 'move)
16152 (progn (beginning-of-line) (point)))
16156 ;; Group names can be just numbers.
16157 (when (numberp symbol)
16158 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16159 (or (boundp symbol) (set symbol nil))
16160 ;; It was a group name.
16161 (setq subscribed (= (following-char) ?:)
16162 group (symbol-name symbol)
16165 ;; If the line ends here, this is clearly a buggy line, so
16166 ;; we put point a the beginning of line and let the cond
16167 ;; below do the error handling.
16168 (beginning-of-line)
16169 ;; We skip to the beginning of the ranges.
16170 (skip-chars-forward "!: \t"))
16171 ;; We are now at the beginning of the list of read articles.
16172 ;; We read them range by range.
16175 ((looking-at "[0-9]+")
16176 ;; We narrow and read a number instead of buffer-substring/
16177 ;; string-to-int because it's faster. narrow/widen is
16178 ;; faster than save-restriction/narrow, and save-restriction
16179 ;; produces a garbage object.
16181 (narrow-to-region (match-beginning 0) (match-end 0))
16184 ;; If the next character is a dash, then this is a range.
16185 (if (= (following-char) ?-)
16187 ;; We read the upper bound of the range.
16189 (if (not (looking-at "[0-9]+"))
16190 ;; This is a buggy line, by we pretend that
16191 ;; it's kinda OK. Perhaps the user should be
16193 (setq reads (cons num1 reads))
16198 (narrow-to-region (match-beginning 0)
16203 ;; It was just a simple number, so we add it to the
16205 (setq reads (cons num1 reads)))
16206 ;; If the next char in ?\n, then we have reached the end
16207 ;; of the line and return nil.
16208 (/= (following-char) ?\n))
16209 ((= (following-char) ?\n)
16210 ;; End of line, so we end.
16213 ;; Not numbers and not eol, so this might be a buggy
16216 ;; If it was eob instead of ?\n, we allow it.
16218 ;; The line was buggy.
16220 (gnus-message 3 "Mangled line: %s"
16221 (buffer-substring (gnus-point-at-bol)
16222 (gnus-point-at-eol)))
16226 ;; Skip past ", ". Spaces are illegal in these ranges, but
16227 ;; we allow them, because it's a common mistake to put a
16228 ;; space after the comma.
16229 (skip-chars-forward ", "))
16231 ;; We have already read .newsrc.eld, so we gently update the
16232 ;; data in the hash table with the information we have just
16235 (let ((info (gnus-get-info group))
16238 ;; There is an entry for this file in the alist.
16240 (gnus-info-set-read info (nreverse reads))
16241 ;; We update the level very gently. In fact, we
16242 ;; only change it if there's been a status change
16243 ;; from subscribed to unsubscribed, or vice versa.
16244 (setq level (gnus-info-level info))
16245 (cond ((and (<= level gnus-level-subscribed)
16247 (setq level (if reads
16248 gnus-level-default-unsubscribed
16249 (1+ gnus-level-default-unsubscribed))))
16250 ((and (> level gnus-level-subscribed) subscribed)
16251 (setq level gnus-level-default-subscribed)))
16252 (gnus-info-set-level info level))
16253 ;; This is a new group.
16254 (setq info (list group
16256 gnus-level-default-subscribed
16258 (1+ gnus-level-subscribed)
16259 gnus-level-default-unsubscribed))
16260 (nreverse reads))))
16261 (setq newsrc (cons info newsrc))))))
16264 (setq newsrc (nreverse newsrc))
16266 (if (not already-read)
16268 ;; We now have two newsrc lists - `newsrc', which is what we
16269 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16270 ;; what we've read from .newsrc.eld. We have to merge these
16271 ;; lists. We do this by "attaching" any (foreign) groups in the
16272 ;; gnus-newsrc-alist to the (native) group that precedes them.
16273 (let ((rc (cdr gnus-newsrc-alist))
16274 (prev gnus-newsrc-alist)
16277 (or (null (nth 4 (car rc))) ; It's a native group.
16278 (assoc (caar rc) newsrc) ; It's already in the alist.
16279 (if (setq entry (assoc (caar prev) newsrc))
16280 (setcdr (setq mentry (memq entry newsrc))
16281 (cons (car rc) (cdr mentry)))
16282 (setq newsrc (cons (car rc) newsrc))))
16286 (setq gnus-newsrc-alist newsrc)
16287 ;; We make the newsrc hashtb.
16288 (gnus-make-hashtable-from-newsrc-alist)
16290 ;; Finally, if we read some options lines, we parse them.
16291 (or (string= gnus-newsrc-options "")
16292 (gnus-newsrc-parse-options gnus-newsrc-options))))
16294 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16295 ;; The return value will be a list on the form
16296 ;; ((regexp1 . ignore)
16297 ;; (regexp2 . subscribe)...)
16298 ;; When handling new newsgroups, groups that match a `ignore' regexp
16299 ;; will be ignored, and groups that match a `subscribe' regexp will be
16300 ;; subscribed. A line like
16301 ;; options -n !all rec.all
16302 ;; will lead to a list that looks like
16303 ;; (("^rec\\..+" . subscribe)
16304 ;; ("^.+" . ignore))
16305 ;; So all "rec.*" groups will be subscribed, while all the other
16306 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16307 ;; different from "options -n rec.all !all".
16308 (defun gnus-newsrc-parse-options (options)
16311 (gnus-set-work-buffer)
16312 (insert (regexp-quote options))
16313 ;; First we treat all continuation lines.
16314 (goto-char (point-min))
16315 (while (re-search-forward "\n[ \t]+" nil t)
16316 (replace-match " " t t))
16317 ;; Then we transform all "all"s into ".+"s.
16318 (goto-char (point-min))
16319 (while (re-search-forward "\\ball\\b" nil t)
16320 (replace-match ".+" t t))
16321 (goto-char (point-min))
16322 ;; We remove all other options than the "-n" ones.
16323 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16324 (replace-match " ")
16326 (goto-char (point-min))
16328 ;; We are only interested in "options -n" lines - we
16329 ;; ignore the other option lines.
16330 (while (re-search-forward "[ \t]-n" nil t)
16332 (or (save-excursion
16333 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16335 (gnus-point-at-eol)))
16336 ;; Search for all "words"...
16337 (while (re-search-forward "[^ \t,\n]+" eol t)
16338 (if (= (char-after (match-beginning 0)) ?!)
16339 ;; If the word begins with a bang (!), this is a "not"
16340 ;; spec. We put this spec (minus the bang) and the
16341 ;; symbol `ignore' into the list.
16342 (setq out (cons (cons (concat
16343 "^" (buffer-substring
16344 (1+ (match-beginning 0))
16347 ;; There was no bang, so this is a "yes" spec.
16348 (setq out (cons (cons (concat "^" (match-string 0))
16349 'subscribe) out)))))
16351 (setq gnus-newsrc-options-n out))))
16353 (defun gnus-save-newsrc-file (&optional force)
16354 "Save .newsrc file."
16355 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16356 ;; from the variable gnus-newsrc-alist.
16357 (when (and (or gnus-newsrc-alist gnus-killed-list)
16358 gnus-current-startup-file)
16360 (if (and (or gnus-use-dribble-file gnus-slave)
16362 (or (not gnus-dribble-buffer)
16363 (not (buffer-name gnus-dribble-buffer))
16364 (zerop (save-excursion
16365 (set-buffer gnus-dribble-buffer)
16367 (gnus-message 4 "(No changes need to be saved)")
16368 (run-hooks 'gnus-save-newsrc-hook)
16370 (gnus-slave-save-newsrc)
16372 (when gnus-save-newsrc-file
16373 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16374 (gnus-gnus-to-newsrc-format)
16375 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16376 ;; Save .newsrc.eld.
16377 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16378 (make-local-variable 'version-control)
16379 (setq version-control 'never)
16380 (setq buffer-file-name
16381 (concat gnus-current-startup-file ".eld"))
16382 (gnus-add-current-to-buffer-list)
16383 (buffer-disable-undo (current-buffer))
16385 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16386 (gnus-gnus-to-quick-newsrc-format)
16387 (run-hooks 'gnus-save-quick-newsrc-hook)
16389 (kill-buffer (current-buffer))
16391 5 "Saving %s.eld...done" gnus-current-startup-file))
16392 (gnus-dribble-delete-file)))))
16394 (defun gnus-gnus-to-quick-newsrc-format ()
16395 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16396 (insert ";; Gnus startup file.\n")
16397 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16398 (insert ";; to read .newsrc.\n")
16399 (insert "(setq gnus-newsrc-file-version "
16400 (prin1-to-string gnus-version) ")\n")
16402 (if gnus-save-killed-list gnus-variable-list
16403 ;; Remove the `gnus-killed-list' from the list of variables
16404 ;; to be saved, if required.
16405 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16406 ;; Peel off the "dummy" group.
16407 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16409 ;; Insert the variables into the file.
16411 (when (and (boundp (setq variable (pop variables)))
16412 (symbol-value variable))
16413 (insert "(setq " (symbol-name variable) " '")
16414 (prin1 (symbol-value variable) (current-buffer))
16417 (defun gnus-gnus-to-newsrc-format ()
16418 ;; Generate and save the .newsrc file.
16420 (set-buffer (create-file-buffer gnus-current-startup-file))
16421 (let ((newsrc (cdr gnus-newsrc-alist))
16422 (standard-output (current-buffer))
16423 info ranges range method)
16424 (setq buffer-file-name gnus-current-startup-file)
16425 (buffer-disable-undo (current-buffer))
16428 (if gnus-newsrc-options (insert gnus-newsrc-options))
16429 ;; Write subscribed and unsubscribed.
16430 (while (setq info (pop newsrc))
16431 ;; Don't write foreign groups to .newsrc.
16432 (when (or (null (setq method (gnus-info-method info)))
16433 (equal method "native")
16434 (gnus-server-equal method gnus-select-method))
16435 (insert (gnus-info-group info)
16436 (if (> (gnus-info-level info) gnus-level-subscribed)
16438 (when (setq ranges (gnus-info-read info))
16440 (if (not (listp (cdr ranges)))
16441 (if (= (car ranges) (cdr ranges))
16442 (princ (car ranges))
16443 (princ (car ranges))
16445 (princ (cdr ranges)))
16446 (while (setq range (pop ranges))
16447 (if (or (atom range) (= (car range) (cdr range)))
16448 (princ (or (and (atom range) range) (car range)))
16449 (princ (car range))
16451 (princ (cdr range)))
16452 (if ranges (insert ",")))))
16454 (make-local-variable 'version-control)
16455 (setq version-control 'never)
16456 ;; It has been reported that sometime the modtime on the .newsrc
16457 ;; file seems to be off. We really do want to overwrite it, so
16458 ;; we clear the modtime here before saving. It's a bit odd,
16460 ;; sometimes the modtime clear isn't sufficient. most brute force:
16461 ;; delete the silly thing entirely first. but this fails to provide
16462 ;; such niceties as .newsrc~ creation.
16463 (if gnus-modtime-botch
16464 (delete-file gnus-startup-file)
16465 (clear-visited-file-modtime))
16466 (run-hooks 'gnus-save-standard-newsrc-hook)
16468 (kill-buffer (current-buffer)))))
16472 ;;; Slave functions.
16475 (defun gnus-slave-save-newsrc ()
16477 (set-buffer gnus-dribble-buffer)
16479 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16480 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16482 (defun gnus-master-read-slave-newsrc ()
16485 (file-name-directory gnus-current-startup-file)
16489 (file-name-nondirectory gnus-current-startup-file)
16493 (if (not slave-files)
16494 () ; There are no slave files to read.
16495 (gnus-message 7 "Reading slave newsrcs...")
16497 (set-buffer (get-buffer-create " *gnus slave*"))
16498 (buffer-disable-undo (current-buffer))
16500 (sort (mapcar (lambda (file)
16501 (list (nth 5 (file-attributes file)) file))
16504 (or (< (caar f1) (caar f2))
16505 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16508 (setq file (nth 1 (car slave-files)))
16509 (insert-file-contents file)
16510 (if (condition-case ()
16512 (eval-buffer (current-buffer))
16515 (gnus-message 3 "Possible error in %s" file)
16519 (or gnus-slave ; Slaves shouldn't delete these files.
16523 (setq slave-files (cdr slave-files))))
16524 (gnus-message 7 "Reading slave newsrcs...done"))))
16528 ;;; Group description.
16531 (defun gnus-read-all-descriptions-files ()
16532 (let ((methods (cons gnus-select-method
16534 (when gnus-message-archive-method
16536 gnus-secondary-select-methods))))
16538 (gnus-read-descriptions-file (car methods))
16539 (setq methods (cdr methods)))
16542 (defun gnus-read-descriptions-file (&optional method)
16543 (let ((method (or method gnus-select-method)))
16544 (when (stringp method)
16545 (setq method (gnus-server-to-method method)))
16546 ;; We create the hashtable whether we manage to read the desc file
16547 ;; to avoid trying to re-read after a failed read.
16548 (or gnus-description-hashtb
16549 (setq gnus-description-hashtb
16550 (gnus-make-hashtable (length gnus-active-hashtb))))
16551 ;; Mark this method's desc file as read.
16552 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16553 gnus-description-hashtb)
16555 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16557 ((not (gnus-check-server method))
16558 (gnus-message 1 "Couldn't open server")
16560 ((not (gnus-request-list-newsgroups method))
16561 (gnus-message 1 "Couldn't read newsgroups descriptions")
16567 (set-buffer nntp-server-buffer)
16568 (goto-char (point-min))
16569 (if (or (search-forward "\n.\n" nil t)
16570 (goto-char (point-max)))
16572 (beginning-of-line)
16573 (narrow-to-region (point-min) (point))))
16574 (goto-char (point-min))
16575 (while (not (eobp))
16576 ;; If we get an error, we set group to 0, which is not a
16580 (let ((obarray gnus-description-hashtb))
16581 ;; Group is set to a symbol interned in this
16583 (read nntp-server-buffer))
16585 (skip-chars-forward " \t")
16586 ;; ... which leads to this line being effectively ignored.
16587 (and (symbolp group)
16588 (set group (buffer-substring
16589 (point) (progn (end-of-line) (point)))))
16590 (forward-line 1))))
16591 (gnus-message 5 "Reading descriptions file...done")
16594 (defun gnus-group-get-description (group)
16595 "Get the description of a group by sending XGTITLE to the server."
16596 (when (gnus-request-group-description group)
16598 (set-buffer nntp-server-buffer)
16599 (goto-char (point-min))
16600 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16601 (match-string 1)))))
16605 ;;; Buffering of read articles.
16608 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16609 (defvar gnus-backlog-articles nil)
16610 (defvar gnus-backlog-hashtb nil)
16612 (defun gnus-backlog-buffer ()
16613 "Return the backlog buffer."
16614 (or (get-buffer gnus-backlog-buffer)
16616 (set-buffer (get-buffer-create gnus-backlog-buffer))
16617 (buffer-disable-undo (current-buffer))
16618 (setq buffer-read-only t)
16619 (gnus-add-current-to-buffer-list)
16620 (get-buffer gnus-backlog-buffer))))
16622 (defun gnus-backlog-setup ()
16623 "Initialize backlog variables."
16624 (unless gnus-backlog-hashtb
16625 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16627 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16629 (defun gnus-backlog-shutdown ()
16630 "Clear all backlog variables and buffers."
16631 (when (get-buffer gnus-backlog-buffer)
16632 (kill-buffer gnus-backlog-buffer))
16633 (setq gnus-backlog-hashtb nil
16634 gnus-backlog-articles nil))
16636 (defun gnus-backlog-enter-article (group number buffer)
16637 (gnus-backlog-setup)
16638 (let ((ident (intern (concat group ":" (int-to-string number))
16639 gnus-backlog-hashtb))
16641 (if (memq ident gnus-backlog-articles)
16642 () ; It's already kept.
16643 ;; Remove the oldest article, if necessary.
16644 (and (numberp gnus-keep-backlog)
16645 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16646 (gnus-backlog-remove-oldest-article))
16647 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16648 ;; Insert the new article.
16650 (set-buffer (gnus-backlog-buffer))
16651 (let (buffer-read-only)
16652 (goto-char (point-max))
16653 (or (bolp) (insert "\n"))
16655 (insert-buffer-substring buffer)
16656 ;; Tag the beginning of the article with the ident.
16657 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16659 (defun gnus-backlog-remove-oldest-article ()
16661 (set-buffer (gnus-backlog-buffer))
16662 (goto-char (point-min))
16663 (if (zerop (buffer-size))
16664 () ; The buffer is empty.
16665 (let ((ident (get-text-property (point) 'gnus-backlog))
16667 ;; Remove the ident from the list of articles.
16669 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16670 ;; Delete the article itself.
16672 (point) (next-single-property-change
16673 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16675 (defun gnus-backlog-request-article (group number buffer)
16676 (when (numberp number)
16677 (gnus-backlog-setup)
16678 (let ((ident (intern (concat group ":" (int-to-string number))
16679 gnus-backlog-hashtb))
16681 (when (memq ident gnus-backlog-articles)
16682 ;; It was in the backlog.
16684 (set-buffer (gnus-backlog-buffer))
16685 (if (not (setq beg (text-property-any
16686 (point-min) (point-max) 'gnus-backlog
16688 ;; It wasn't in the backlog after all.
16690 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16691 ;; Find the end (i. e., the beginning of the next article).
16693 (next-single-property-change
16694 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16695 (let ((buffer-read-only nil))
16697 (insert-buffer-substring gnus-backlog-buffer beg end)
16700 ;; Allow redefinition of Gnus functions.
16702 (gnus-ems-redefine)
16706 ;;; gnus.el ends here