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 (number)
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.65"
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 (nnheader-narrow-to-headers)
2426 (mail-fetch-field field)))))
2428 (defun gnus-goto-colon ()
2430 (search-forward ":" (gnus-point-at-eol) t))
2433 (defun gnus-update-format (var)
2434 "Update the format specification near point."
2439 ;; Find the end of the current word.
2440 (re-search-forward "[ \t\n]" nil t)
2442 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2443 (match-string 1)))))
2444 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2445 (match-string 1 var))))
2446 (entry (assq type gnus-format-specs))
2449 (setq gnus-format-specs (delq entry gnus-format-specs)))
2451 (intern (format "%s-spec" var))
2452 (gnus-parse-format (setq value (symbol-value (intern var)))
2453 (symbol-value (intern (format "%s-alist" var)))
2454 (not (string-match "mode" var))))
2455 (setq spec (symbol-value (intern (format "%s-spec" var))))
2456 (push (list type value spec) gnus-format-specs)
2458 (pop-to-buffer "*Gnus Format*")
2460 (lisp-interaction-mode)
2461 (insert (pp-to-string spec))))
2463 (defun gnus-update-format-specifications (&optional force)
2464 "Update all (necessary) format specifications."
2465 ;; Make the indentation array.
2466 (gnus-make-thread-indent-array)
2468 ;; See whether all the stored info needs to be flushed.
2470 (not (equal emacs-version
2471 (cdr (assq 'version gnus-format-specs)))))
2472 (setq gnus-format-specs nil))
2474 ;; Go through all the formats and see whether they need updating.
2475 (let ((types '(summary summary-dummy group
2476 summary-mode group-mode article-mode))
2477 new-format entry type val)
2478 (while (setq type (pop types))
2479 ;; Jump to the proper buffer to find out the value of
2480 ;; the variable, if possible. (It may be buffer-local.)
2482 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2484 (when (and (boundp buffer)
2485 (setq val (symbol-value buffer))
2487 (buffer-name (get-buffer val)))
2488 (set-buffer (get-buffer val)))
2489 (setq new-format (symbol-value
2490 (intern (format "gnus-%s-line-format" type))))))
2491 (setq entry (cdr (assq type gnus-format-specs)))
2493 (equal (car entry) new-format))
2494 ;; Use the old format.
2495 (set (intern (format "gnus-%s-line-format-spec" type))
2497 ;; This is a new format.
2499 (if (not (stringp new-format))
2500 ;; This is a function call or something.
2502 ;; This is a "real" format.
2506 (intern (format "gnus-%s-line-format-alist"
2507 (if (eq type 'article-mode)
2508 'summary-mode type))))
2509 (not (string-match "mode$" (symbol-name type))))))
2510 ;; Enter the new format spec into the list.
2513 (setcar (cdr entry) val)
2514 (setcar entry new-format))
2515 (push (list type new-format val) gnus-format-specs))
2516 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2518 (unless (assq 'version gnus-format-specs)
2519 (push (cons 'version emacs-version) gnus-format-specs))
2521 (gnus-update-group-mark-positions)
2522 (gnus-update-summary-mark-positions))
2524 (defun gnus-update-summary-mark-positions ()
2525 "Compute where the summary marks are to go."
2527 (let ((gnus-replied-mark 129)
2528 (gnus-score-below-mark 130)
2529 (gnus-score-over-mark 130)
2533 (gnus-set-work-buffer)
2534 (gnus-summary-insert-line
2535 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2536 (goto-char (point-min))
2537 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2539 (goto-char (point-min))
2540 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2542 (goto-char (point-min))
2543 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2545 (setq gnus-summary-mark-positions pos))))
2547 (defun gnus-update-group-mark-positions ()
2549 (let ((gnus-process-mark 128)
2550 (gnus-group-marked '("dummy.group")))
2551 (gnus-set-active "dummy.group" '(0 . 0))
2552 (gnus-set-work-buffer)
2553 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2554 (goto-char (point-min))
2555 (setq gnus-group-mark-positions
2556 (list (cons 'process (and (search-forward "\200" nil t)
2557 (- (point) 2))))))))
2559 (defvar gnus-mouse-face-0 'highlight)
2560 (defvar gnus-mouse-face-1 'highlight)
2561 (defvar gnus-mouse-face-2 'highlight)
2562 (defvar gnus-mouse-face-3 'highlight)
2563 (defvar gnus-mouse-face-4 'highlight)
2565 (defun gnus-mouse-face-function (form type)
2567 (point) (progn ,@form (point))
2568 gnus-mouse-face-prop
2571 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2573 (defvar gnus-face-0 'bold)
2574 (defvar gnus-face-1 'italic)
2575 (defvar gnus-face-2 'bold-italic)
2576 (defvar gnus-face-3 'bold)
2577 (defvar gnus-face-4 'bold)
2579 (defun gnus-face-face-function (form type)
2581 (point) (progn ,@form (point))
2582 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2584 (defun gnus-max-width-function (el max-width)
2585 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2587 `(if (> (length ,el) ,max-width)
2588 (substring ,el 0 ,max-width)
2590 `(let ((val (eval ,el)))
2592 (setq val (int-to-string val)))
2593 (if (> (length val) ,max-width)
2594 (substring val 0 ,max-width)
2597 (defun gnus-parse-format (format spec-alist &optional insert)
2598 ;; This function parses the FORMAT string with the help of the
2599 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2600 ;; string. If the FORMAT string contains the specifiers %( and %)
2601 ;; the text between them will have the mouse-face text property.
2603 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2605 (gnus-parse-complex-format format spec-alist)
2606 ;; This is a simple format.
2607 (gnus-parse-simple-format format spec-alist insert)))
2609 (defun gnus-parse-complex-format (format spec-alist)
2611 (gnus-set-work-buffer)
2613 (goto-char (point-min))
2614 (while (re-search-forward "\"" nil t)
2615 (replace-match "\\\"" nil t))
2616 (goto-char (point-min))
2618 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2619 (let ((number (if (match-beginning 1)
2620 (match-string 1) "0"))
2621 (delim (aref (match-string 2) 0)))
2622 (if (or (= delim ?\() (= delim ?\{))
2623 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2625 (replace-match "\")\""))))
2626 (goto-char (point-max))
2628 (goto-char (point-min))
2629 (let ((form (read (current-buffer))))
2630 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2632 (defun gnus-complex-form-to-spec (form spec-alist)
2637 (gnus-parse-simple-format sform spec-alist t)
2638 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2639 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2643 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2644 ;; This function parses the FORMAT string with the help of the
2645 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2648 spec flist fstring newspec elem beg result dontinsert)
2650 (gnus-set-work-buffer)
2652 (goto-char (point-min))
2653 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2655 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2657 beg (1+ (match-beginning 0)))
2658 ;; First check if there are any specs that look anything like
2659 ;; "%12,12A", ie. with a "max width specification". These have
2660 ;; to be treated specially.
2661 (if (setq beg (match-beginning 1))
2665 (1+ (match-beginning 1)) (match-end 1))))
2667 (setq beg (match-beginning 2)))
2668 ;; Find the specification from `spec-alist'.
2669 (unless (setq elem (cdr (assq spec spec-alist)))
2670 (setq elem '("*" ?s)))
2671 ;; Treat user defined format specifiers specially.
2672 (when (eq (car elem) 'gnus-tmp-user-defined)
2675 (list (intern (concat "gnus-user-format-function-"
2677 'gnus-tmp-header) ?s))
2678 (delete-region (match-beginning 3) (match-end 3)))
2679 (if (not (zerop max-width))
2680 (let ((el (car elem)))
2681 (cond ((= (cadr elem) ?c)
2682 (setq el (list 'char-to-string el)))
2684 (setq el (list 'int-to-string el))))
2685 (setq flist (cons (gnus-max-width-function el max-width)
2689 (setq flist (cons (car elem) flist))
2690 (setq newspec (cadr elem)))))
2691 ;; Remove the old specification (and possibly a ",12" string).
2692 (delete-region beg (match-end 2))
2693 ;; Insert the new specification.
2696 (setq fstring (buffer-substring 1 (point-max))))
2697 ;; Do some postprocessing to increase efficiency.
2702 ((string= fstring "")
2704 ;; Not a format string.
2705 ((not (string-match "%" fstring))
2707 ;; A format string with just a single string spec.
2708 ((string= fstring "%s")
2710 ;; A single character.
2711 ((string= fstring "%c")
2714 ((string= fstring "%d")
2717 (list `(princ ,(car flist)))
2718 (list `(int-to-string ,(car flist)))))
2719 ;; Just lots of chars and strings.
2720 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2722 ;; A single string spec at the beginning of the spec.
2723 ((string-match "\\`%[sc][^%]+\\'" fstring)
2724 (list (car flist) (substring fstring 2)))
2725 ;; A single string spec in the middle of the spec.
2726 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2727 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2728 ;; A single string spec in the end of the spec.
2729 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2730 (list (match-string 1 fstring) (car flist)))
2731 ;; A more complex spec.
2733 (list (cons 'format (cons fstring (nreverse flist)))))))
2739 (cons 'insert result)))
2740 (cond ((stringp result)
2743 (cons 'concat result))
2746 (defun gnus-eval-format (format &optional alist props)
2747 "Eval the format variable FORMAT, using ALIST.
2748 If PROPS, insert the result."
2749 (let ((form (gnus-parse-format format alist props)))
2751 (add-text-properties (point) (progn (eval form) (point)) props)
2754 (defun gnus-remove-text-with-property (prop)
2755 "Delete all text in the current buffer with text property PROP."
2757 (goto-char (point-min))
2759 (while (get-text-property (point) prop)
2761 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2763 (defun gnus-set-work-buffer ()
2764 (if (get-buffer gnus-work-buffer)
2766 (set-buffer gnus-work-buffer)
2768 (set-buffer (get-buffer-create gnus-work-buffer))
2769 (kill-all-local-variables)
2770 (buffer-disable-undo (current-buffer))
2771 (gnus-add-current-to-buffer-list)))
2773 ;; Article file names when saving.
2775 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2776 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2777 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2778 Otherwise, it is like ~/News/news/group/num."
2781 (concat (if (gnus-use-long-file-name 'not-save)
2782 (gnus-capitalize-newsgroup newsgroup)
2783 (gnus-newsgroup-directory-form newsgroup))
2784 "/" (int-to-string (mail-header-number headers)))
2785 (or gnus-article-save-directory "~/News"))))
2787 (string-equal (file-name-directory default)
2788 (file-name-directory last-file))
2789 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2791 (or last-file default))))
2793 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2794 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2795 If variable `gnus-use-long-file-name' is non-nil, it is
2796 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2799 (concat (if (gnus-use-long-file-name 'not-save)
2801 (gnus-newsgroup-directory-form newsgroup))
2802 "/" (int-to-string (mail-header-number headers)))
2803 (or gnus-article-save-directory "~/News"))))
2805 (string-equal (file-name-directory default)
2806 (file-name-directory last-file))
2807 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2809 (or last-file default))))
2811 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2812 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2813 If variable `gnus-use-long-file-name' is non-nil, it is
2814 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2817 (if (gnus-use-long-file-name 'not-save)
2818 (gnus-capitalize-newsgroup newsgroup)
2819 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2820 (or gnus-article-save-directory "~/News"))))
2822 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2823 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2824 If variable `gnus-use-long-file-name' is non-nil, it is
2825 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2828 (if (gnus-use-long-file-name 'not-save)
2830 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2831 (or gnus-article-save-directory "~/News"))))
2833 ;; For subscribing new newsgroup
2835 (defun gnus-subscribe-hierarchical-interactive (groups)
2836 (let ((groups (sort groups 'string<))
2837 prefixes prefix start ans group starts)
2839 (setq prefixes (list "^"))
2840 (while (and groups prefixes)
2841 (while (not (string-match (car prefixes) (car groups)))
2842 (setq prefixes (cdr prefixes)))
2843 (setq prefix (car prefixes))
2844 (setq start (1- (length prefix)))
2845 (if (and (string-match "[^\\.]\\." (car groups) start)
2848 (concat "^" (substring (car groups) 0 (match-end 0))))
2849 (string-match prefix (cadr groups)))
2851 (setq prefixes (cons prefix prefixes))
2852 (message "Descend hierarchy %s? ([y]nsq): "
2853 (substring prefix 1 (1- (length prefix))))
2854 (setq ans (read-char))
2857 (string-match prefix
2858 (setq group (car groups))))
2859 (setq gnus-killed-list
2860 (cons group gnus-killed-list))
2861 (gnus-sethash group group gnus-killed-hashtb)
2862 (setq groups (cdr groups)))
2863 (setq starts (cdr starts)))
2866 (string-match prefix
2867 (setq group (car groups))))
2868 (gnus-sethash group group gnus-killed-hashtb)
2869 (gnus-subscribe-alphabetically (car groups))
2870 (setq groups (cdr groups)))
2871 (setq starts (cdr starts)))
2874 (setq group (car groups))
2875 (setq gnus-killed-list (cons group gnus-killed-list))
2876 (gnus-sethash group group gnus-killed-hashtb)
2877 (setq groups (cdr groups))))
2879 (message "Subscribe %s? ([n]yq)" (car groups))
2880 (setq ans (read-char))
2881 (setq group (car groups))
2883 (gnus-subscribe-alphabetically (car groups))
2884 (gnus-sethash group group gnus-killed-hashtb))
2887 (setq group (car groups))
2888 (setq gnus-killed-list (cons group gnus-killed-list))
2889 (gnus-sethash group group gnus-killed-hashtb)
2890 (setq groups (cdr groups))))
2892 (setq gnus-killed-list (cons group gnus-killed-list))
2893 (gnus-sethash group group gnus-killed-hashtb)))
2894 (setq groups (cdr groups)))))))
2896 (defun gnus-subscribe-randomly (newsgroup)
2897 "Subscribe new NEWSGROUP by making it the first newsgroup."
2898 (gnus-subscribe-newsgroup newsgroup))
2900 (defun gnus-subscribe-alphabetically (newgroup)
2901 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2902 (let ((groups (cdr gnus-newsrc-alist))
2904 (while (and (not before) groups)
2905 (if (string< newgroup (caar groups))
2906 (setq before (caar groups))
2907 (setq groups (cdr groups))))
2908 (gnus-subscribe-newsgroup newgroup before)))
2910 (defun gnus-subscribe-hierarchically (newgroup)
2911 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2912 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2914 (set-buffer (find-file-noselect gnus-current-startup-file))
2915 (let ((groupkey newgroup)
2917 (while (and (not before) groupkey)
2918 (goto-char (point-min))
2920 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2921 (while (and (re-search-forward groupkey-re nil t)
2923 (setq before (match-string 1))
2924 (string< before newgroup)))))
2925 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2927 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2928 (substring groupkey (match-beginning 1) (match-end 1)))))
2929 (gnus-subscribe-newsgroup newgroup before))))
2931 (defun gnus-subscribe-interactively (group)
2932 "Subscribe the new GROUP interactively.
2933 It is inserted in hierarchical newsgroup order if subscribed. If not,
2935 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2936 (gnus-subscribe-hierarchically group)
2937 (push group gnus-killed-list)))
2939 (defun gnus-subscribe-zombies (group)
2940 "Make the new GROUP into a zombie group."
2941 (push group gnus-zombie-list))
2943 (defun gnus-subscribe-killed (group)
2944 "Make the new GROUP a killed group."
2945 (push group gnus-killed-list))
2947 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2948 "Subscribe new NEWSGROUP.
2949 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2950 the first newsgroup."
2951 ;; We subscribe the group by changing its level to `subscribed'.
2952 (gnus-group-change-level
2953 newsgroup gnus-level-default-subscribed
2954 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2955 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2959 (defun gnus-newsgroup-directory-form (newsgroup)
2960 "Make hierarchical directory name from NEWSGROUP name."
2961 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2962 (len (length newsgroup))
2964 ;; If this is a foreign group, we don't want to translate the
2966 (if (setq idx (string-match ":" newsgroup))
2967 (aset newsgroup idx ?/)
2969 ;; Replace all occurrences of `.' with `/'.
2971 (if (= (aref newsgroup idx) ?.)
2972 (aset newsgroup idx ?/))
2973 (setq idx (1+ idx)))
2976 (defun gnus-newsgroup-savable-name (group)
2977 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2979 (nnheader-replace-chars-in-string group ?/ ?.))
2981 (defun gnus-make-directory (dir)
2982 "Make DIRECTORY recursively."
2983 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2984 ;; of the many mysteries of the universe.
2985 (let* ((dir (expand-file-name dir default-directory))
2987 (if (string-match "/$" dir)
2988 (setq dir (substring dir 0 (match-beginning 0))))
2989 ;; First go down the path until we find a directory that exists.
2990 (while (not (file-exists-p dir))
2991 (setq dirs (cons dir dirs))
2992 (string-match "/[^/]+$" dir)
2993 (setq dir (substring dir 0 (match-beginning 0))))
2994 ;; Then create all the subdirs.
2995 (while (and dirs (not err))
2997 (make-directory (car dirs))
2998 (error (setq err t)))
2999 (setq dirs (cdr dirs)))
3000 ;; We return whether we were successful or not.
3003 (defun gnus-capitalize-newsgroup (newsgroup)
3004 "Capitalize NEWSGROUP name."
3005 (and (not (zerop (length newsgroup)))
3006 (concat (char-to-string (upcase (aref newsgroup 0)))
3007 (substring newsgroup 1))))
3009 ;; Various... things.
3011 (defun gnus-simplify-subject (subject &optional re-only)
3012 "Remove `Re:' and words in parentheses.
3013 If RE-ONLY is non-nil, strip leading `Re:'s only."
3014 (let ((case-fold-search t)) ;Ignore case.
3015 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3016 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3017 (setq subject (substring subject (match-end 0))))
3018 ;; Remove uninteresting prefixes.
3019 (if (and (not re-only)
3020 gnus-simplify-ignored-prefixes
3021 (string-match gnus-simplify-ignored-prefixes subject))
3022 (setq subject (substring subject (match-end 0))))
3023 ;; Remove words in parentheses from end.
3025 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3026 (setq subject (substring subject 0 (match-beginning 0)))))
3027 ;; Return subject string.
3030 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3032 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3033 (defun gnus-simplify-buffer-fuzzy ()
3034 (goto-char (point-min))
3035 (while (search-forward "\t" nil t)
3036 (replace-match " " t t))
3037 (goto-char (point-min))
3038 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3039 (goto-char (match-beginning 0))
3041 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3042 (looking-at "^[[].*: .*[]]$"))
3043 (goto-char (point-min))
3044 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3046 (replace-match "" t t))
3047 (goto-char (point-min))
3048 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3049 (goto-char (match-end 0))
3052 (progn (goto-char (match-beginning 0)))
3053 (re-search-forward ":"))))
3054 (goto-char (point-min))
3055 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3056 (replace-match "" t t))
3057 (goto-char (point-min))
3058 (while (re-search-forward " +" nil t)
3059 (replace-match " " t t))
3060 (goto-char (point-min))
3061 (while (re-search-forward " $" nil t)
3062 (replace-match "" t t))
3063 (goto-char (point-min))
3064 (while (re-search-forward "^ +" nil t)
3065 (replace-match "" t t))
3066 (goto-char (point-min))
3067 (when gnus-simplify-subject-fuzzy-regexp
3068 (if (listp gnus-simplify-subject-fuzzy-regexp)
3069 (let ((list gnus-simplify-subject-fuzzy-regexp))
3071 (goto-char (point-min))
3072 (while (re-search-forward (car list) nil t)
3073 (replace-match "" t t))
3074 (setq list (cdr list))))
3075 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3076 (replace-match "" t t)))))
3078 (defun gnus-simplify-subject-fuzzy (subject)
3079 "Siplify a subject string fuzzily."
3081 (gnus-set-work-buffer)
3082 (let ((case-fold-search t))
3084 (inline (gnus-simplify-buffer-fuzzy))
3087 ;; Add the current buffer to the list of buffers to be killed on exit.
3088 (defun gnus-add-current-to-buffer-list ()
3089 (or (memq (current-buffer) gnus-buffer-list)
3090 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3092 (defun gnus-string> (s1 s2)
3093 (not (or (string< s1 s2)
3096 ;;; General various misc type functions.
3098 (defun gnus-clear-system ()
3099 "Clear all variables and buffers."
3100 ;; Clear Gnus variables.
3101 (let ((variables gnus-variable-list))
3103 (set (car variables) nil)
3104 (setq variables (cdr variables))))
3105 ;; Clear other internal variables.
3106 (setq gnus-list-of-killed-groups nil
3107 gnus-have-read-active-file nil
3108 gnus-newsrc-alist nil
3109 gnus-newsrc-hashtb nil
3110 gnus-killed-list nil
3111 gnus-zombie-list nil
3112 gnus-killed-hashtb nil
3113 gnus-active-hashtb nil
3114 gnus-moderated-list nil
3115 gnus-description-hashtb nil
3116 gnus-current-headers nil
3117 gnus-thread-indent-array nil
3118 gnus-newsgroup-headers nil
3119 gnus-newsgroup-name nil
3120 gnus-server-alist nil
3121 gnus-group-list-mode nil
3122 gnus-opened-servers nil
3123 gnus-current-select-method nil)
3124 (gnus-shutdown 'gnus)
3125 ;; Kill the startup file.
3126 (and gnus-current-startup-file
3127 (get-file-buffer gnus-current-startup-file)
3128 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3129 ;; Clear the dribble buffer.
3130 (gnus-dribble-clear)
3131 ;; Kill global KILL file buffer.
3132 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3133 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3134 (gnus-kill-buffer nntp-server-buffer)
3135 ;; Kill Gnus buffers.
3136 (while gnus-buffer-list
3137 (gnus-kill-buffer (pop gnus-buffer-list)))
3138 ;; Remove Gnus frames.
3139 (while gnus-created-frames
3140 (when (frame-live-p (car gnus-created-frames))
3141 ;; We slap a condition-case around this `delete-frame' to ensure
3142 ;; agains errors if we try do delete the single frame that's left.
3144 (delete-frame (car gnus-created-frames))
3146 (pop gnus-created-frames)))
3148 (defun gnus-windows-old-to-new (setting)
3149 ;; First we take care of the really, really old Gnus 3 actions.
3150 (when (symbolp setting)
3152 ;; Take care of ooold GNUS 3.x values.
3153 (cond ((eq setting 'SelectArticle) 'article)
3154 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3155 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3157 (if (or (listp setting)
3158 (not (and gnus-window-configuration
3159 (memq setting '(group summary article)))))
3161 (let* ((setting (if (eq setting 'group)
3162 (if (assq 'newsgroup gnus-window-configuration)
3164 'newsgroups) setting))
3165 (elem (cadr (assq setting gnus-window-configuration)))
3166 (total (apply '+ elem))
3167 (types '(group summary article))
3168 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3173 (or (not (numberp (nth i elem)))
3174 (zerop (nth i elem))
3176 (setq perc (/ (float (nth 0 elem)) total))
3177 (setq out (cons (if (eq pbuf (nth i types))
3178 (vector (nth i types) perc 'point)
3179 (vector (nth i types) perc))
3182 (list (nreverse out)))))
3185 (defun gnus-add-configuration (conf)
3186 "Add the window configuration CONF to `gnus-buffer-configuration'."
3187 (setq gnus-buffer-configuration
3188 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3189 gnus-buffer-configuration))))
3191 (defvar gnus-frame-list nil)
3193 (defun gnus-configure-frame (split &optional window)
3194 "Split WINDOW according to SPLIT."
3196 (setq window (get-buffer-window (current-buffer))))
3197 (select-window window)
3198 ;; This might be an old-stylee buffer config.
3199 (when (vectorp split)
3200 (setq split (append split nil)))
3201 (when (or (consp (car split))
3202 (vectorp (car split)))
3204 (push 'vertical split))
3205 ;; The SPLIT might be something that is to be evaled to
3206 ;; return a new SPLIT.
3207 (while (and (not (assq (car split) gnus-window-to-buffer))
3208 (gnus-functionp (car split)))
3209 (setq split (eval split)))
3210 (let* ((type (car split))
3212 (len (if (eq type 'horizontal) (window-width) (window-height)))
3214 (window-min-width (or gnus-window-min-width window-min-width))
3215 (window-min-height (or gnus-window-min-height window-min-height))
3216 s result new-win rest comp-subs size sub)
3218 ;; Nothing to do here.
3220 ;; Don't switch buffers.
3222 (and (memq 'point split) window))
3223 ;; This is a buffer to be selected.
3224 ((not (memq type '(frame horizontal vertical)))
3225 (let ((buffer (cond ((stringp type) type)
3226 (t (cdr (assq type gnus-window-to-buffer)))))
3229 (error "Illegal buffer type: %s" type))
3230 (unless (setq buf (get-buffer (if (symbolp buffer)
3231 (symbol-value buffer) buffer)))
3232 (setq buf (get-buffer-create (if (symbolp buffer)
3233 (symbol-value buffer) buffer))))
3234 (switch-to-buffer buf)
3235 ;; We return the window if it has the `point' spec.
3236 (and (memq 'point split) window)))
3237 ;; This is a frame split.
3239 (unless gnus-frame-list
3240 (setq gnus-frame-list (list (window-frame
3241 (get-buffer-window (current-buffer))))))
3243 params frame fresult)
3244 (while (< i (length subs))
3245 ;; Frame parameter is gotten from the sub-split.
3246 (setq params (cadr (elt subs i)))
3247 ;; It should be a list.
3248 (unless (listp params)
3250 ;; Create a new frame?
3251 (unless (setq frame (elt gnus-frame-list i))
3252 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3253 (push frame gnus-created-frames))
3254 ;; Is the old frame still alive?
3255 (unless (frame-live-p frame)
3256 (setcar (nthcdr i gnus-frame-list)
3257 (setq frame (make-frame params))))
3258 ;; Select the frame in question and do more splits there.
3259 (select-frame frame)
3260 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3262 ;; Select the frame that has the selected buffer.
3264 (select-frame (window-frame fresult)))))
3265 ;; This is a normal split.
3267 (when (> (length subs) 0)
3268 ;; First we have to compute the sizes of all new windows.
3270 (setq sub (append (pop subs) nil))
3271 (while (and (not (assq (car sub) gnus-window-to-buffer))
3272 (gnus-functionp (car sub)))
3273 (setq sub (eval sub)))
3275 (push sub comp-subs)
3276 (setq size (cadar comp-subs))
3277 (cond ((equal size 1.0)
3278 (setq rest (car comp-subs))
3281 (setq s (floor (* size len))))
3285 (error "Illegal size: %s" size)))
3286 ;; Try to make sure that we are inside the safe limits.
3288 ((eq type 'horizontal)
3289 (setq s (max s window-min-width)))
3290 ((eq type 'vertical)
3291 (setq s (max s window-min-height))))
3292 (setcar (cdar comp-subs) s)
3294 ;; Take care of the "1.0" spec.
3296 (setcar (cdr rest) (- len total))
3297 (error "No 1.0 specs in %s" split))
3298 ;; The we do the actual splitting in a nice recursive
3300 (setq comp-subs (nreverse comp-subs))
3302 (if (null (cdr comp-subs))
3303 (setq new-win window)
3305 (split-window window (cadar comp-subs)
3306 (eq type 'horizontal))))
3307 (setq result (or (gnus-configure-frame
3308 (car comp-subs) window) result))
3309 (select-window new-win)
3310 (setq window new-win)
3311 (setq comp-subs (cdr comp-subs))))
3312 ;; Return the proper window, if any.
3314 (select-window result))))))
3316 (defvar gnus-frame-split-p nil)
3318 (defun gnus-configure-windows (setting &optional force)
3319 (setq setting (gnus-windows-old-to-new setting))
3320 (let ((split (if (symbolp setting)
3321 (cadr (assq setting gnus-buffer-configuration))
3325 (setq gnus-frame-split-p nil)
3328 (error "No such setting: %s" setting))
3330 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3332 ;; All the windows mentioned are already visible, so we just
3333 ;; put point in the assigned buffer, and do not touch the
3335 (select-window all-visible)
3337 ;; Either remove all windows or just remove all Gnus windows.
3338 (let ((frame (selected-frame)))
3340 (if gnus-use-full-window
3341 ;; We want to remove all other windows.
3342 (if (not gnus-frame-split-p)
3343 ;; This is not a `frame' split, so we ignore the
3345 (delete-other-windows)
3346 ;; This is a `frame' split, so we delete all windows
3350 (unless (eq (cdr (assq 'minibuffer
3351 (frame-parameters frame)))
3353 (select-frame frame)
3354 (delete-other-windows)))
3356 ;; Just remove some windows.
3357 (gnus-remove-some-windows)
3358 (switch-to-buffer nntp-server-buffer))
3359 (select-frame frame)))
3361 (switch-to-buffer nntp-server-buffer)
3362 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3364 (defun gnus-all-windows-visible-p (split)
3365 "Say whether all buffers in SPLIT are currently visible.
3366 In particular, the value returned will be the window that
3368 (let ((stack (list split))
3370 type buffer win buf)
3371 (while (and (setq split (pop stack))
3373 ;; Be backwards compatible.
3374 (when (vectorp split)
3375 (setq split (append split nil)))
3376 (when (or (consp (car split))
3377 (vectorp (car split)))
3379 (push 'vertical split))
3380 ;; The SPLIT might be something that is to be evaled to
3381 ;; return a new SPLIT.
3382 (while (and (not (assq (car split) gnus-window-to-buffer))
3383 (gnus-functionp (car split)))
3384 (setq split (eval split)))
3386 (setq type (elt split 0))
3391 ((not (memq type '(horizontal vertical frame)))
3392 (setq buffer (cond ((stringp type) type)
3393 (t (cdr (assq type gnus-window-to-buffer)))))
3395 (error "Illegal buffer type: %s" type))
3396 (when (setq buf (get-buffer (if (symbolp buffer)
3397 (symbol-value buffer)
3399 (setq win (get-buffer-window buf t)))
3401 (when (memq 'point split)
3402 (setq all-visible win))
3403 (setq all-visible nil)))
3405 (when (eq type 'frame)
3406 (setq gnus-frame-split-p t))
3407 (setq stack (append (cddr split) stack)))))
3408 (unless (eq all-visible t)
3411 (defun gnus-window-top-edge (&optional window)
3412 (nth 1 (window-edges window)))
3414 (defun gnus-remove-some-windows ()
3415 (let ((buffers gnus-window-to-buffer)
3416 buf bufs lowest-buf lowest)
3418 ;; Remove windows on all known Gnus buffers.
3420 (setq buf (cdar buffers))
3422 (setq buf (and (boundp buf) (symbol-value buf))))
3424 (get-buffer-window buf)
3426 (setq bufs (cons buf bufs))
3428 (if (or (not lowest)
3429 (< (gnus-window-top-edge) lowest))
3431 (setq lowest (gnus-window-top-edge))
3432 (setq lowest-buf buf)))))
3433 (setq buffers (cdr buffers)))
3434 ;; Remove windows on *all* summary buffers.
3437 (let ((buf (window-buffer win)))
3438 (if (string-match "^\\*Summary" (buffer-name buf))
3440 (setq bufs (cons buf bufs))
3442 (if (or (not lowest)
3443 (< (gnus-window-top-edge) lowest))
3445 (setq lowest-buf buf)
3446 (setq lowest (gnus-window-top-edge)))))))))
3449 (pop-to-buffer lowest-buf)
3450 (switch-to-buffer nntp-server-buffer)))
3452 (and (not (eq (car bufs) lowest-buf))
3453 (delete-windows-on (car bufs)))
3454 (setq bufs (cdr bufs))))))
3456 (defun gnus-version ()
3457 "Version numbers of this version of Gnus."
3459 (let ((methods gnus-valid-select-methods)
3462 ;; Go through all the legal select methods and add their version
3463 ;; numbers to the total version string. Only the backends that are
3464 ;; currently in use will have their message numbers taken into
3467 (setq meth (intern (concat (caar methods) "-version")))
3469 (stringp (symbol-value meth))
3470 (setq mess (concat mess "; " (symbol-value meth))))
3471 (setq methods (cdr methods)))
3472 (gnus-message 2 mess)))
3474 (defun gnus-info-find-node ()
3475 "Find Info documentation of Gnus."
3477 ;; Enlarge info window if needed.
3478 (let ((mode major-mode)
3480 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3481 (setq gnus-info-buffer (current-buffer))
3482 (gnus-configure-windows 'info)))
3484 (defun gnus-days-between (date1 date2)
3485 ;; Return the number of days between date1 and date2.
3486 (- (gnus-day-number date1) (gnus-day-number date2)))
3488 (defun gnus-day-number (date)
3489 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3490 (timezone-parse-date date))))
3491 (timezone-absolute-from-gregorian
3492 (nth 1 dat) (nth 2 dat) (car dat))))
3494 (defun gnus-encode-date (date)
3495 "Convert DATE to internal time."
3496 (let* ((parse (timezone-parse-date date))
3497 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3498 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3499 (encode-time (caddr time) (cadr time) (car time)
3500 (caddr date) (cadr date) (car date) (nth 4 date))))
3502 (defun gnus-time-minus (t1 t2)
3503 "Subtract two internal times."
3504 (let ((borrow (< (cadr t1) (cadr t2))))
3505 (list (- (car t1) (car t2) (if borrow 1 0))
3506 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3508 (defun gnus-file-newer-than (file date)
3509 (let ((fdate (nth 5 (file-attributes file))))
3510 (or (> (car fdate) (car date))
3511 (and (= (car fdate) (car date))
3512 (> (nth 1 fdate) (nth 1 date))))))
3514 (defmacro gnus-local-set-keys (&rest plist)
3515 "Set the keys in PLIST in the current keymap."
3516 `(gnus-define-keys-1 (current-local-map) ',plist))
3518 (defmacro gnus-define-keys (keymap &rest plist)
3519 "Define all keys in PLIST in KEYMAP."
3520 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3522 (put 'gnus-define-keys 'lisp-indent-function 1)
3523 (put 'gnus-define-keys 'lisp-indent-hook 1)
3524 (put 'gnus-define-keymap 'lisp-indent-function 1)
3525 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3527 (defmacro gnus-define-keymap (keymap &rest plist)
3528 "Define all keys in PLIST in KEYMAP."
3529 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3531 (defun gnus-define-keys-1 (keymap plist)
3533 (error "Can't set keys in a null keymap"))
3534 (cond ((symbolp keymap)
3535 (setq keymap (symbol-value keymap)))
3538 (set (car keymap) nil)
3539 (define-prefix-command (car keymap))
3540 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3541 (setq keymap (symbol-value (car keymap)))))
3544 (when (symbolp (setq key (pop plist)))
3545 (setq key (symbol-value key)))
3546 (define-key keymap key (pop plist)))))
3548 (defun gnus-group-read-only-p (&optional group)
3549 "Check whether GROUP supports editing or not.
3550 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3551 that that variable is buffer-local to the summary buffers."
3552 (let ((group (or group gnus-newsgroup-name)))
3553 (not (gnus-check-backend-function 'request-replace-article group))))
3555 (defun gnus-group-total-expirable-p (group)
3556 "Check whether GROUP is total-expirable or not."
3557 (let ((params (gnus-info-params (gnus-get-info group))))
3558 (or (memq 'total-expire params)
3559 (cdr (assq 'total-expire params)) ; (total-expire . t)
3560 (and gnus-total-expirable-newsgroups ; Check var.
3561 (string-match gnus-total-expirable-newsgroups group)))))
3563 (defun gnus-group-auto-expirable-p (group)
3564 "Check whether GROUP is total-expirable or not."
3565 (let ((params (gnus-info-params (gnus-get-info group))))
3566 (or (memq 'auto-expire params)
3567 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3568 (and gnus-auto-expirable-newsgroups ; Check var.
3569 (string-match gnus-auto-expirable-newsgroups group)))))
3571 (defun gnus-virtual-group-p (group)
3572 "Say whether GROUP is virtual or not."
3573 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3574 gnus-valid-select-methods)))
3576 (defun gnus-news-group-p (group &optional article)
3577 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3578 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3579 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3580 (eq (gnus-request-type group article) 'news))))
3582 (defsubst gnus-simplify-subject-fully (subject)
3583 "Simplify a subject string according to the user's wishes."
3585 ((null gnus-summary-gather-subject-limit)
3586 (gnus-simplify-subject-re subject))
3587 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3588 (gnus-simplify-subject-fuzzy subject))
3589 ((numberp gnus-summary-gather-subject-limit)
3590 (gnus-limit-string (gnus-simplify-subject-re subject)
3591 gnus-summary-gather-subject-limit))
3595 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3596 "Check whether two subjects are equal. If optional argument
3597 simple-first is t, first argument is already simplified."
3599 ((null simple-first)
3600 (equal (gnus-simplify-subject-fully s1)
3601 (gnus-simplify-subject-fully s2)))
3604 (gnus-simplify-subject-fully s2)))))
3606 ;; Returns a list of writable groups.
3607 (defun gnus-writable-groups ()
3608 (let ((alist gnus-newsrc-alist)
3610 (while (setq group (car (pop alist)))
3611 (unless (gnus-group-read-only-p group)
3612 (push group groups)))
3615 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3617 (defun gnus-y-or-n-p (prompt)
3622 (defun gnus-yes-or-no-p (prompt)
3624 (yes-or-no-p prompt)
3627 ;; Check whether to use long file names.
3628 (defun gnus-use-long-file-name (symbol)
3629 ;; The variable has to be set...
3630 (and gnus-use-long-file-name
3631 ;; If it isn't a list, then we return t.
3632 (or (not (listp gnus-use-long-file-name))
3633 ;; If it is a list, and the list contains `symbol', we
3635 (not (memq symbol gnus-use-long-file-name)))))
3637 ;; I suspect there's a better way, but I haven't taken the time to do
3638 ;; it yet. -erik selberg@cs.washington.edu
3639 (defun gnus-dd-mmm (messy-date)
3640 "Return a string like DD-MMM from a big messy string"
3641 (let ((datevec (timezone-parse-date messy-date)))
3644 ;; Make sure leading zeroes are stripped.
3645 (number-to-string (string-to-number (aref datevec 2)))
3649 (nth (1- (string-to-number (aref datevec 1)))
3650 timezone-months-assoc))
3653 ;; Make a hash table (default and minimum size is 255).
3654 ;; Optional argument HASHSIZE specifies the table size.
3655 (defun gnus-make-hashtable (&optional hashsize)
3656 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3658 ;; Make a number that is suitable for hashing; bigger than MIN and one
3660 (defun gnus-create-hash-size (min)
3666 ;; Show message if message has a lower level than `gnus-verbose'.
3667 ;; Guideline for numbers:
3668 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3669 ;; for things that take a long time, 7 - not very important messages
3670 ;; on stuff, 9 - messages inside loops.
3671 (defun gnus-message (level &rest args)
3672 (if (<= level gnus-verbose)
3673 (apply 'message args)
3674 ;; We have to do this format thingy here even if the result isn't
3675 ;; shown - the return value has to be the same as the return value
3677 (apply 'format args)))
3679 ;; Generate a unique new group name.
3680 (defun gnus-generate-new-group-name (leaf)
3683 (while (gnus-gethash name gnus-newsrc-hashtb)
3684 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3687 (defsubst gnus-hide-text (b e props)
3688 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3689 (add-text-properties b e props)
3690 (when (memq 'intangible props)
3691 (put-text-property (max (1- b) (point-min))
3692 b 'intangible (cddr (memq 'intangible props)))))
3694 (defsubst gnus-unhide-text (b e)
3695 "Remove hidden text properties from region between B and E."
3696 (remove-text-properties b e gnus-hidden-properties)
3697 (when (memq 'intangible gnus-hidden-properties)
3698 (put-text-property (max (1- b) (point-min))
3699 b 'intangible nil)))
3701 (defun gnus-hide-text-type (b e type)
3702 "Hide text of TYPE between B and E."
3703 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3705 ;; Find out whether the gnus-visual TYPE is wanted.
3706 (defun gnus-visual-p (&optional type class)
3707 (and gnus-visual ; Has to be non-nil, at least.
3708 (if (not type) ; We don't care about type.
3710 (if (listp gnus-visual) ; It's a list, so we check it.
3711 (or (memq type gnus-visual)
3712 (memq class gnus-visual))
3715 (defun gnus-parent-id (references)
3716 "Return the last Message-ID in REFERENCES."
3717 (when (and references
3718 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3719 (substring references (match-beginning 1) (match-end 1))))
3721 (defun gnus-split-references (references)
3722 "Return a list of Message-IDs in REFERENCES."
3725 (while (string-match "<[^>]+>" references beg)
3726 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3730 (defun gnus-buffer-live-p (buffer)
3731 "Say whether BUFFER is alive or not."
3734 (buffer-name (get-buffer buffer))))
3736 (defun gnus-ephemeral-group-p (group)
3737 "Say whether GROUP is ephemeral or not."
3738 (gnus-group-get-parameter group 'quit-config))
3740 (defun gnus-group-quit-config (group)
3741 "Return the quit-config of GROUP."
3742 (gnus-group-get-parameter group 'quit-config))
3744 (defun gnus-simplify-mode-line ()
3745 "Make mode lines a bit simpler."
3746 (setq mode-line-modified "-- ")
3747 (when (listp mode-line-format)
3748 (make-local-variable 'mode-line-format)
3749 (setq mode-line-format (copy-sequence mode-line-format))
3750 (when (equal (nth 3 mode-line-format) " ")
3751 (setcar (nthcdr 3 mode-line-format) " "))))
3753 ;;; List and range functions
3755 (defun gnus-last-element (list)
3756 "Return last element of LIST."
3758 (setq list (cdr list)))
3761 (defun gnus-copy-sequence (list)
3762 "Do a complete, total copy of a list."
3763 (if (and (consp list) (not (consp (cdr list))))
3764 (cons (car list) (cdr list))
3765 (mapcar (lambda (elem) (if (consp elem)
3766 (if (consp (cdr elem))
3767 (gnus-copy-sequence elem)
3768 (cons (car elem) (cdr elem)))
3772 (defun gnus-set-difference (list1 list2)
3773 "Return a list of elements of LIST1 that do not appear in LIST2."
3774 (let ((list1 (copy-sequence list1)))
3776 (setq list1 (delq (car list2) list1))
3777 (setq list2 (cdr list2)))
3780 (defun gnus-sorted-complement (list1 list2)
3781 "Return a list of elements of LIST1 that do not appear in LIST2.
3782 Both lists have to be sorted over <."
3784 (if (or (null list1) (null list2))
3786 (while (and list1 list2)
3787 (cond ((= (car list1) (car list2))
3788 (setq list1 (cdr list1)
3790 ((< (car list1) (car list2))
3791 (setq out (cons (car list1) out))
3792 (setq list1 (cdr list1)))
3794 (setq out (cons (car list2) out))
3795 (setq list2 (cdr list2)))))
3796 (nconc (nreverse out) (or list1 list2)))))
3798 (defun gnus-intersection (list1 list2)
3801 (if (memq (car list2) list1)
3802 (setq result (cons (car list2) result)))
3803 (setq list2 (cdr list2)))
3806 (defun gnus-sorted-intersection (list1 list2)
3807 ;; LIST1 and LIST2 have to be sorted over <.
3809 (while (and list1 list2)
3810 (cond ((= (car list1) (car list2))
3811 (setq out (cons (car list1) out)
3814 ((< (car list1) (car list2))
3815 (setq list1 (cdr list1)))
3817 (setq list2 (cdr list2)))))
3820 (defun gnus-set-sorted-intersection (list1 list2)
3821 ;; LIST1 and LIST2 have to be sorted over <.
3822 ;; This function modifies LIST1.
3823 (let* ((top (cons nil list1))
3825 (while (and list1 list2)
3826 (cond ((= (car list1) (car list2))
3830 ((< (car list1) (car list2))
3831 (setcdr prev (cdr list1))
3832 (setq list1 (cdr list1)))
3834 (setq list2 (cdr list2)))))
3838 (defun gnus-compress-sequence (numbers &optional always-list)
3839 "Convert list of numbers to a list of ranges or a single range.
3840 If ALWAYS-LIST is non-nil, this function will always release a list of
3842 (let* ((first (car numbers))
3843 (last (car numbers))
3847 (if (not (listp (cdr numbers)))
3850 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3851 ((= (1+ last) (car numbers)) ;Still in sequence
3852 (setq last (car numbers)))
3853 (t ;End of one sequence
3855 (cons (if (= first last) first
3856 (cons first last)) result))
3857 (setq first (car numbers))
3858 (setq last (car numbers))))
3859 (setq numbers (cdr numbers)))
3860 (if (and (not always-list) (null result))
3861 (if (= first last) (list first) (cons first last))
3862 (nreverse (cons (if (= first last) first (cons first last))
3865 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3866 (defun gnus-uncompress-range (ranges)
3867 "Expand a list of ranges into a list of numbers.
3868 RANGES is either a single range on the form `(num . num)' or a list of
3870 (let (first last result)
3874 ((not (listp (cdr ranges)))
3875 (setq first (car ranges))
3876 (setq last (cdr ranges))
3877 (while (<= first last)
3878 (setq result (cons first result))
3879 (setq first (1+ first)))
3883 (if (atom (car ranges))
3884 (if (numberp (car ranges))
3885 (setq result (cons (car ranges) result)))
3886 (setq first (caar ranges))
3887 (setq last (cdar ranges))
3888 (while (<= first last)
3889 (setq result (cons first result))
3890 (setq first (1+ first))))
3891 (setq ranges (cdr ranges)))
3892 (nreverse result)))))
3894 (defun gnus-add-to-range (ranges list)
3895 "Return a list of ranges that has all articles from both RANGES and LIST.
3896 Note: LIST has to be sorted over `<'."
3898 (gnus-compress-sequence list t)
3899 (setq list (copy-sequence list))
3900 (or (listp (cdr ranges))
3901 (setq ranges (list ranges)))
3903 ilist lowest highest temp)
3904 (while (and ranges list)
3906 (setq lowest (or (and (atom (car ranges)) (car ranges))
3908 (while (and list (cdr list) (< (cadr list) lowest))
3909 (setq list (cdr list)))
3910 (if (< (car ilist) lowest)
3913 (setq list (cdr list))
3915 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3916 (setq highest (or (and (atom (car ranges)) (car ranges))
3918 (while (and list (<= (car list) highest))
3919 (setq list (cdr list)))
3920 (setq ranges (cdr ranges)))
3922 (setq out (nconc (gnus-compress-sequence list t) out)))
3923 (setq out (sort out (lambda (r1 r2)
3924 (< (or (and (atom r1) r1) (car r1))
3925 (or (and (atom r2) r2) (car r2))))))
3928 (if (atom (car ranges))
3930 (if (atom (cadr ranges))
3931 (if (= (1+ (car ranges)) (cadr ranges))
3933 (setcar ranges (cons (car ranges)
3935 (setcdr ranges (cddr ranges))))
3936 (if (= (1+ (car ranges)) (caadr ranges))
3938 (setcar (cadr ranges) (car ranges))
3939 (setcar ranges (cadr ranges))
3940 (setcdr ranges (cddr ranges))))))
3942 (if (atom (cadr ranges))
3943 (if (= (1+ (cdar ranges)) (cadr ranges))
3945 (setcdr (car ranges) (cadr ranges))
3946 (setcdr ranges (cddr ranges))))
3947 (if (= (1+ (cdar ranges)) (caadr ranges))
3949 (setcdr (car ranges) (cdadr ranges))
3950 (setcdr ranges (cddr ranges)))))))
3951 (setq ranges (cdr ranges)))
3954 (defun gnus-remove-from-range (ranges list)
3955 "Return a list of ranges that has all articles from LIST removed from RANGES.
3956 Note: LIST has to be sorted over `<'."
3957 ;; !!! This function shouldn't look like this, but I've got a headache.
3958 (gnus-compress-sequence
3959 (gnus-sorted-complement
3960 (gnus-uncompress-range ranges) list)))
3962 (defun gnus-member-of-range (number ranges)
3963 (if (not (listp (cdr ranges)))
3964 (and (>= number (car ranges))
3965 (<= number (cdr ranges)))
3968 (if (numberp (car ranges))
3969 (>= number (car ranges))
3970 (>= number (caar ranges)))
3972 (if (if (numberp (car ranges))
3973 (= number (car ranges))
3974 (and (>= number (caar ranges))
3975 (<= number (cdar ranges))))
3976 (setq not-stop nil))
3977 (setq ranges (cdr ranges)))
3980 (defun gnus-range-length (range)
3981 "Return the length RANGE would have if uncompressed."
3982 (length (gnus-uncompress-range range)))
3984 (defun gnus-sublist-p (list sublist)
3985 "Test whether all elements in SUBLIST are members of LIST."
3988 (unless (memq (pop sublist) list)
3998 (defvar gnus-group-mode-map nil)
3999 (put 'gnus-group-mode 'mode-class 'special)
4001 (unless gnus-group-mode-map
4002 (setq gnus-group-mode-map (make-keymap))
4003 (suppress-keymap gnus-group-mode-map)
4005 (gnus-define-keys gnus-group-mode-map
4006 " " gnus-group-read-group
4007 "=" gnus-group-select-group
4008 "\r" gnus-group-select-group
4009 "\M-\r" gnus-group-quick-select-group
4010 "j" gnus-group-jump-to-group
4011 "n" gnus-group-next-unread-group
4012 "p" gnus-group-prev-unread-group
4013 "\177" gnus-group-prev-unread-group
4014 [delete] gnus-group-prev-unread-group
4015 "N" gnus-group-next-group
4016 "P" gnus-group-prev-group
4017 "\M-n" gnus-group-next-unread-group-same-level
4018 "\M-p" gnus-group-prev-unread-group-same-level
4019 "," gnus-group-best-unread-group
4020 "." gnus-group-first-unread-group
4021 "u" gnus-group-unsubscribe-current-group
4022 "U" gnus-group-unsubscribe-group
4023 "c" gnus-group-catchup-current
4024 "C" gnus-group-catchup-current-all
4025 "l" gnus-group-list-groups
4026 "L" gnus-group-list-all-groups
4028 "g" gnus-group-get-new-news
4029 "\M-g" gnus-group-get-new-news-this-group
4030 "R" gnus-group-restart
4031 "r" gnus-group-read-init-file
4032 "B" gnus-group-browse-foreign-server
4033 "b" gnus-group-check-bogus-groups
4034 "F" gnus-find-new-newsgroups
4035 "\C-c\C-d" gnus-group-describe-group
4036 "\M-d" gnus-group-describe-all-groups
4037 "\C-c\C-a" gnus-group-apropos
4038 "\C-c\M-\C-a" gnus-group-description-apropos
4039 "a" gnus-group-post-news
4040 "\ek" gnus-group-edit-local-kill
4041 "\eK" gnus-group-edit-global-kill
4042 "\C-k" gnus-group-kill-group
4043 "\C-y" gnus-group-yank-group
4044 "\C-w" gnus-group-kill-region
4045 "\C-x\C-t" gnus-group-transpose-groups
4046 "\C-c\C-l" gnus-group-list-killed
4047 "\C-c\C-x" gnus-group-expire-articles
4048 "\C-c\M-\C-x" gnus-group-expire-all-groups
4050 "s" gnus-group-save-newsrc
4051 "z" gnus-group-suspend
4052 "Z" gnus-group-clear-dribble
4055 "?" gnus-group-describe-briefly
4056 "\C-c\C-i" gnus-info-find-node
4057 "\M-e" gnus-group-edit-group-method
4058 "^" gnus-group-enter-server-mode
4059 gnus-mouse-2 gnus-mouse-pick-group
4060 "<" beginning-of-buffer
4063 "\C-c\C-s" gnus-group-sort-groups
4065 "\C-c\M-g" gnus-activate-all-groups
4066 "\M-&" gnus-group-universal-argument
4067 "#" gnus-group-mark-group
4068 "\M-#" gnus-group-unmark-group)
4070 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4071 "m" gnus-group-mark-group
4072 "u" gnus-group-unmark-group
4073 "w" gnus-group-mark-region
4074 "m" gnus-group-mark-buffer
4075 "r" gnus-group-mark-regexp
4076 "U" gnus-group-unmark-all-groups)
4078 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4079 "d" gnus-group-make-directory-group
4080 "h" gnus-group-make-help-group
4081 "a" gnus-group-make-archive-group
4082 "k" gnus-group-make-kiboze-group
4083 "m" gnus-group-make-group
4084 "E" gnus-group-edit-group
4085 "e" gnus-group-edit-group-method
4086 "p" gnus-group-edit-group-parameters
4087 "v" gnus-group-add-to-virtual
4088 "V" gnus-group-make-empty-virtual
4089 "D" gnus-group-enter-directory
4090 "f" gnus-group-make-doc-group
4091 "r" gnus-group-rename-group
4092 "\177" gnus-group-delete-group
4093 [delete] gnus-group-delete-group)
4095 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4096 "b" gnus-group-brew-soup
4097 "w" gnus-soup-save-areas
4098 "s" gnus-soup-send-replies
4099 "p" gnus-soup-pack-packet
4100 "r" nnsoup-pack-replies)
4102 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4103 "s" gnus-group-sort-groups
4104 "a" gnus-group-sort-groups-by-alphabet
4105 "u" gnus-group-sort-groups-by-unread
4106 "l" gnus-group-sort-groups-by-level
4107 "v" gnus-group-sort-groups-by-score
4108 "r" gnus-group-sort-groups-by-rank
4109 "m" gnus-group-sort-groups-by-method)
4111 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4112 "k" gnus-group-list-killed
4113 "z" gnus-group-list-zombies
4114 "s" gnus-group-list-groups
4115 "u" gnus-group-list-all-groups
4116 "A" gnus-group-list-active
4117 "a" gnus-group-apropos
4118 "d" gnus-group-description-apropos
4119 "m" gnus-group-list-matching
4120 "M" gnus-group-list-all-matching
4121 "l" gnus-group-list-level)
4123 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4124 "f" gnus-score-flush-cache)
4126 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4127 "f" gnus-group-fetch-faq)
4129 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4130 "l" gnus-group-set-current-level
4131 "t" gnus-group-unsubscribe-current-group
4132 "s" gnus-group-unsubscribe-group
4133 "k" gnus-group-kill-group
4134 "y" gnus-group-yank-group
4135 "w" gnus-group-kill-region
4136 "\C-k" gnus-group-kill-level
4137 "z" gnus-group-kill-all-zombies))
4139 (defun gnus-group-mode ()
4140 "Major mode for reading news.
4142 All normal editing commands are switched off.
4143 \\<gnus-group-mode-map>
4144 The group buffer lists (some of) the groups available. For instance,
4145 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4146 lists all zombie groups.
4148 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4149 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4151 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4153 The following commands are available:
4155 \\{gnus-group-mode-map}"
4157 (when (and menu-bar-mode
4158 (gnus-visual-p 'group-menu 'menu))
4159 (gnus-group-make-menu-bar))
4160 (kill-all-local-variables)
4161 (gnus-simplify-mode-line)
4162 (setq major-mode 'gnus-group-mode)
4163 (setq mode-name "Group")
4164 (gnus-group-set-mode-line)
4165 (setq mode-line-process nil)
4166 (use-local-map gnus-group-mode-map)
4167 (buffer-disable-undo (current-buffer))
4168 (setq truncate-lines t)
4169 (setq buffer-read-only t)
4170 (run-hooks 'gnus-group-mode-hook))
4172 (defun gnus-mouse-pick-group (e)
4173 "Enter the group under the mouse pointer."
4176 (gnus-group-read-group nil))
4178 ;; Look at LEVEL and find out what the level is really supposed to be.
4179 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4180 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4181 (defun gnus-group-default-level (&optional level number-or-nil)
4183 (gnus-group-use-permanent-levels
4184 ; (setq gnus-group-default-list-level
4185 ; (or level gnus-group-default-list-level))
4186 (or level gnus-group-default-list-level gnus-level-subscribed))
4190 (or level gnus-group-default-list-level gnus-level-subscribed))))
4193 (defun gnus-slave-no-server (&optional arg)
4194 "Read network news as a slave, without connecting to local server"
4196 (gnus-no-server arg t))
4199 (defun gnus-no-server (&optional arg slave)
4201 If ARG is a positive number, Gnus will use that as the
4202 startup level. If ARG is nil, Gnus will be started at level 2.
4203 If ARG is non-nil and not a positive number, Gnus will
4204 prompt the user for the name of an NNTP server to use.
4205 As opposed to `gnus', this command will not connect to the local server."
4207 (let ((gnus-group-use-permanent-levels t))
4208 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4209 (make-local-variable 'gnus-group-use-permanent-levels)
4210 (setq gnus-group-use-permanent-levels t))
4213 (defun gnus-slave (&optional arg)
4214 "Read news as a slave."
4216 (gnus arg nil 'slave))
4219 (defun gnus-other-frame (&optional arg)
4220 "Pop up a frame to read news."
4222 (if (get-buffer gnus-group-buffer)
4223 (let ((pop-up-frames t))
4225 (select-frame (make-frame))
4229 (defun gnus (&optional arg dont-connect slave)
4231 If ARG is non-nil and a positive number, Gnus will use that as the
4232 startup level. If ARG is non-nil and not a positive number, Gnus will
4233 prompt the user for the name of an NNTP server to use."
4236 (if (get-buffer gnus-group-buffer)
4238 (switch-to-buffer gnus-group-buffer)
4239 (gnus-group-get-new-news))
4242 (nnheader-init-server-buffer)
4243 (gnus-read-init-file)
4244 (setq gnus-slave slave)
4246 (gnus-group-setup-buffer)
4247 (let ((buffer-read-only nil))
4249 (if (not gnus-inhibit-startup-message)
4251 (gnus-group-startup-message)
4254 (let ((level (and (numberp arg) (> arg 0) arg))
4260 (gnus-start-news-server (and arg (not level))))))
4261 (if (and (not dont-connect)
4264 (run-hooks 'gnus-startup-hook)
4265 ;; NNTP server is successfully open.
4267 ;; Find the current startup file name.
4268 (setq gnus-current-startup-file
4269 (gnus-make-newsrc-file gnus-startup-file))
4271 ;; Read the dribble file.
4272 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4274 ;; Allow using GroupLens predictions.
4275 (when gnus-use-grouplens
4277 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4279 (gnus-summary-make-display-table)
4280 ;; Do the actual startup.
4281 (gnus-setup-news nil level dont-connect)
4282 ;; Generate the group buffer.
4283 (gnus-group-list-groups level)
4284 (gnus-group-first-unread-group)
4285 (gnus-configure-windows 'group)
4286 (gnus-group-set-mode-line))))))
4288 (defun gnus-unload ()
4289 "Unload all Gnus features."
4291 (or (boundp 'load-history)
4292 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4293 (let ((history load-history)
4296 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4297 (setq feature (cdr (assq 'provide (car history))))
4298 (unload-feature feature 'force))
4299 (setq history (cdr history)))))
4301 (defun gnus-compile ()
4302 "Byte-compile the user-defined format specs."
4304 (let ((entries gnus-format-specs)
4305 entry gnus-tmp-func)
4307 (gnus-message 7 "Compiling format specs...")
4310 (setq entry (pop entries))
4311 (if (eq (car entry) 'version)
4312 (setq gnus-format-specs (delq entry gnus-format-specs))
4313 (when (and (listp (caddr entry))
4314 (not (eq 'byte-code (caaddr entry))))
4315 (fset 'gnus-tmp-func
4316 `(lambda () ,(caddr entry)))
4317 (byte-compile 'gnus-tmp-func)
4318 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4320 (push (cons 'version emacs-version) gnus-format-specs)
4322 (gnus-message 7 "Compiling user specs...done"))))
4324 (defun gnus-indent-rigidly (start end arg)
4325 "Indent rigidly using only spaces and no tabs."
4328 (narrow-to-region start end)
4329 (indent-rigidly start end arg)
4330 (goto-char (point-min))
4331 (while (search-forward "\t" nil t)
4332 (replace-match " " t t)))))
4334 (defun gnus-group-startup-message (&optional x y)
4335 "Insert startup message in current buffer."
4336 ;; Insert the message.
4341 _ ___ __ ___ __ _ ___
4360 ;; And then hack it.
4361 (gnus-indent-rigidly (point-min) (point-max)
4362 (/ (max (- (window-width) (or x 46)) 0) 2))
4363 (goto-char (point-min))
4365 (let* ((pheight (count-lines (point-min) (point-max)))
4366 (wheight (window-height))
4367 (rest (- wheight pheight)))
4368 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4370 (goto-char (point-min))
4371 (and (search-forward "Praxis" nil t)
4372 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4373 (goto-char (point-min))
4374 (let* ((mode-string (gnus-group-set-mode-line)))
4375 (setq mode-line-buffer-identification
4376 (list (concat gnus-version (substring (car mode-string) 4))))
4377 (set-buffer-modified-p t)))
4379 (defun gnus-group-setup-buffer ()
4380 (or (get-buffer gnus-group-buffer)
4382 (switch-to-buffer gnus-group-buffer)
4383 (gnus-add-current-to-buffer-list)
4385 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4387 (defun gnus-group-list-groups (&optional level unread lowest)
4388 "List newsgroups with level LEVEL or lower that have unread articles.
4389 Default is all subscribed groups.
4390 If argument UNREAD is non-nil, groups with no unread articles are also
4392 (interactive (list (if current-prefix-arg
4393 (prefix-numeric-value current-prefix-arg)
4395 (gnus-group-default-level nil t)
4396 gnus-group-default-list-level
4397 gnus-level-subscribed))))
4399 (setq level (car gnus-group-list-mode)
4400 unread (cdr gnus-group-list-mode)))
4401 (setq level (gnus-group-default-level level))
4402 (gnus-group-setup-buffer) ;May call from out of group buffer
4403 (gnus-update-format-specifications)
4404 (let ((case-fold-search nil)
4405 (props (text-properties-at (gnus-point-at-bol)))
4406 (group (gnus-group-group-name)))
4407 (set-buffer gnus-group-buffer)
4408 (funcall gnus-group-prepare-function level unread lowest)
4409 (if (zerop (buffer-size))
4410 (gnus-message 5 gnus-no-groups-message)
4411 (goto-char (point-max))
4412 (when (or (not gnus-group-goto-next-group-function)
4413 (not (funcall gnus-group-goto-next-group-function
4416 ;; Go to the first group with unread articles.
4417 (gnus-group-search-forward t)
4418 ;; Find the right group to put point on. If the current group
4419 ;; has disappeared in the new listing, try to find the next
4420 ;; one. If no next one can be found, just leave point at the
4421 ;; first newsgroup in the buffer.
4422 (if (not (gnus-goto-char
4424 (point-min) (point-max)
4425 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4426 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4428 (not (gnus-goto-char
4430 (point-min) (point-max) 'gnus-group
4432 (caar newsrc) gnus-active-hashtb)))))
4433 (setq newsrc (cdr newsrc)))
4434 (or newsrc (progn (goto-char (point-max))
4435 (forward-line -1)))))))
4436 ;; Adjust cursor point.
4437 (gnus-group-position-point))))
4439 (defun gnus-group-list-level (level &optional all)
4440 "List groups on LEVEL.
4441 If ALL (the prefix), also list groups that have no unread articles."
4442 (interactive "nList groups on level: \nP")
4443 (gnus-group-list-groups level all level))
4445 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4446 "List all newsgroups with unread articles of level LEVEL or lower.
4447 If ALL is non-nil, list groups that have no unread articles.
4448 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4449 If REGEXP, only list groups matching REGEXP."
4450 (set-buffer gnus-group-buffer)
4451 (let ((buffer-read-only nil)
4452 (newsrc (cdr gnus-newsrc-alist))
4453 (lowest (or lowest 1))
4454 info clevel unread group params)
4456 (if (< lowest gnus-level-zombie)
4457 ;; List living groups.
4459 (setq info (car newsrc)
4460 group (gnus-info-group info)
4461 params (gnus-info-params info)
4463 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4464 (and unread ; This group might be bogus
4466 (string-match regexp group))
4467 (<= (setq clevel (gnus-info-level info)) level)
4469 (or all ; We list all groups?
4470 (if (eq unread t) ; Unactivated?
4471 gnus-group-list-inactive-groups ; We list unactivated
4472 (> unread 0)) ; We list groups with unread articles
4473 (and gnus-list-groups-with-ticked-articles
4474 (cdr (assq 'tick (gnus-info-marks info))))
4475 ; And groups with tickeds
4476 ;; Check for permanent visibility.
4477 (and gnus-permanently-visible-groups
4478 (string-match gnus-permanently-visible-groups
4480 (memq 'visible params)
4481 (cdr (assq 'visible params)))
4482 (gnus-group-insert-group-line
4483 group (gnus-info-level info)
4484 (gnus-info-marks info) unread (gnus-info-method info)))))
4486 ;; List dead groups.
4487 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4488 (gnus-group-prepare-flat-list-dead
4489 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4490 gnus-level-zombie ?Z
4492 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4493 (gnus-group-prepare-flat-list-dead
4494 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4495 gnus-level-killed ?K regexp))
4497 (gnus-group-set-mode-line)
4498 (setq gnus-group-list-mode (cons level all))
4499 (run-hooks 'gnus-group-prepare-hook)))
4501 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4502 ;; List zombies and killed lists somewhat faster, which was
4503 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4504 ;; this by ignoring the group format specification altogether.
4507 ;; This loop is used when listing groups that match some
4510 (setq group (pop groups))
4511 (when (string-match regexp group)
4512 (add-text-properties
4513 (point) (prog1 (1+ (point))
4514 (insert " " mark " *: " group "\n"))
4515 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4517 'gnus-level level))))
4518 ;; This loop is used when listing all groups.
4520 (add-text-properties
4521 (point) (prog1 (1+ (point))
4522 (insert " " mark " *: "
4523 (setq group (pop groups)) "\n"))
4524 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4526 'gnus-level level))))))
4528 (defmacro gnus-group-real-name (group)
4529 "Find the real name of a foreign newsgroup."
4530 `(let ((gname ,group))
4531 (if (string-match ":[^:]+$" gname)
4532 (substring gname (1+ (match-beginning 0)))
4535 (defsubst gnus-server-add-address (method)
4536 (let ((method-name (symbol-name (car method))))
4537 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4538 (not (assq (intern (concat method-name "-address")) method)))
4539 (append method (list (list (intern (concat method-name "-address"))
4543 (defsubst gnus-server-get-method (group method)
4544 ;; Input either a server name, and extended server name, or a
4545 ;; select method, and return a select method.
4546 (cond ((stringp method)
4547 (gnus-server-to-method method))
4548 ((equal method gnus-select-method)
4550 ((and (stringp (car method)) group)
4551 (gnus-server-extend-method group method))
4552 ((and method (not group)
4553 (equal (cadr method) ""))
4556 (gnus-server-add-address method))))
4558 (defun gnus-server-to-method (server)
4559 "Map virtual server names to select methods."
4561 ;; Perhaps this is the native server?
4562 (and (equal server "native") gnus-select-method)
4563 ;; It should be in the server alist.
4564 (cdr (assoc server gnus-server-alist))
4565 ;; If not, we look through all the opened server
4566 ;; to see whether we can find it there.
4567 (let ((opened gnus-opened-servers))
4569 (not (equal server (format "%s:%s" (caaar opened)
4574 (defmacro gnus-method-equal (ss1 ss2)
4575 "Say whether two servers are equal."
4579 (and (= (length s1) (length s2))
4581 (while (and s1 (member (car s1) s2))
4585 (defun gnus-server-equal (m1 m2)
4586 "Say whether two methods are equal."
4587 (let ((m1 (cond ((null m1) gnus-select-method)
4588 ((stringp m1) (gnus-server-to-method m1))
4590 (m2 (cond ((null m2) gnus-select-method)
4591 ((stringp m2) (gnus-server-to-method m2))
4593 (gnus-method-equal m1 m2)))
4595 (defun gnus-servers-using-backend (backend)
4596 "Return a list of known servers using BACKEND."
4597 (let ((opened gnus-opened-servers)
4600 (when (eq backend (caaar opened))
4601 (push (caar opened) out))
4605 (defun gnus-group-prefixed-name (group method)
4606 "Return the whole name from GROUP and METHOD."
4607 (and (stringp method) (setq method (gnus-server-to-method method)))
4608 (concat (format "%s" (car method))
4610 (or (assoc (format "%s" (car method))
4611 (gnus-methods-using 'address))
4612 (gnus-server-equal method gnus-message-archive-method))
4614 (not (string= (nth 1 method) "")))
4615 (concat "+" (nth 1 method)))
4618 (defun gnus-group-real-prefix (group)
4619 "Return the prefix of the current group name."
4620 (if (string-match "^[^:]+:" group)
4621 (substring group 0 (match-end 0))
4624 (defun gnus-group-method (group)
4625 "Return the server or method used for selecting GROUP."
4626 (let ((prefix (gnus-group-real-prefix group)))
4627 (if (equal prefix "")
4629 (let ((servers gnus-opened-servers)
4631 backend possible found)
4632 (if (string-match "^[^\\+]+\\+" prefix)
4633 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4634 server (substring prefix (match-end 0) (1- (length prefix))))
4635 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4637 (when (eq (caaar servers) backend)
4638 (setq possible (caar servers))
4639 (when (equal (cadaar servers) server)
4640 (setq found (caar servers))))
4642 (or (car (rassoc found gnus-server-alist))
4644 (car (rassoc possible gnus-server-alist))
4646 (list backend server))))))
4648 (defsubst gnus-secondary-method-p (method)
4649 "Return whether METHOD is a secondary select method."
4650 (let ((methods gnus-secondary-select-methods)
4651 (gmethod (gnus-server-get-method nil method)))
4653 (not (equal (gnus-server-get-method nil (car methods))
4655 (setq methods (cdr methods)))
4658 (defun gnus-group-foreign-p (group)
4659 "Say whether a group is foreign or not."
4660 (and (not (gnus-group-native-p group))
4661 (not (gnus-group-secondary-p group))))
4663 (defun gnus-group-native-p (group)
4664 "Say whether the group is native or not."
4665 (not (string-match ":" group)))
4667 (defun gnus-group-secondary-p (group)
4668 "Say whether the group is secondary or not."
4669 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4671 (defun gnus-group-get-parameter (group &optional symbol)
4672 "Returns the group parameters for GROUP.
4673 If SYMBOL, return the value of that symbol in the group parameters."
4674 (let ((params (gnus-info-params (gnus-get-info group))))
4676 (gnus-group-parameter-value params symbol)
4679 (defun gnus-group-parameter-value (params symbol)
4680 "Return the value of SYMBOL in group PARAMS."
4681 (or (car (memq symbol params)) ; It's either a simple symbol
4682 (cdr (assq symbol params)))) ; or a cons.
4684 (defun gnus-group-add-parameter (group param)
4685 "Add parameter PARAM to GROUP."
4686 (let ((info (gnus-get-info group)))
4688 () ; This is a dead group. We just ignore it.
4689 ;; Cons the new param to the old one and update.
4690 (gnus-group-set-info (cons param (gnus-info-params info))
4693 (defun gnus-group-set-parameter (group name value)
4694 "Set parameter NAME to VALUE in GROUP."
4695 (let ((info (gnus-get-info group)))
4697 () ; This is a dead group. We just ignore it.
4698 (let ((old-params (gnus-info-params info))
4699 (new-params (list (cons name value))))
4701 (if (or (not (listp (car old-params)))
4702 (not (eq (caar old-params) name)))
4703 (setq new-params (append new-params (list (car old-params)))))
4704 (setq old-params (cdr old-params)))
4705 (gnus-group-set-info new-params group 'params)))))
4707 (defun gnus-group-add-score (group &optional score)
4708 "Add SCORE to the GROUP score.
4709 If SCORE is nil, add 1 to the score of GROUP."
4710 (let ((info (gnus-get-info group)))
4712 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4714 (defun gnus-summary-bubble-group ()
4715 "Increase the score of the current group.
4716 This is a handy function to add to `gnus-summary-exit-hook' to
4717 increase the score of each group you read."
4718 (gnus-group-add-score gnus-newsgroup-name))
4720 (defun gnus-group-set-info (info &optional method-only-group part)
4721 (let* ((entry (gnus-gethash
4722 (or method-only-group (gnus-info-group info))
4723 gnus-newsrc-hashtb))
4725 (info (if method-only-group (nth 2 entry) info))
4727 (when method-only-group
4729 (error "Trying to change non-existent group %s" method-only-group))
4730 ;; We have received parts of the actual group info - either the
4731 ;; select method or the group parameters. We first check
4732 ;; whether we have to extend the info, and if so, do that.
4733 (let ((len (length info))
4734 (total (if (eq part 'method) 5 6)))
4736 (setcdr (nthcdr (1- len) info)
4737 (make-list (- total len) nil)))
4738 ;; Then we enter the new info.
4739 (setcar (nthcdr (1- total) info) part-info)))
4741 ;; This is a new group, so we just create it.
4743 (set-buffer gnus-group-buffer)
4744 (setq method (gnus-info-method info))
4745 (when (gnus-server-equal method "native")
4748 ;; It's a foreign group...
4749 (gnus-group-make-group
4750 (gnus-group-real-name (gnus-info-group info))
4751 (if (stringp method) method
4752 (prin1-to-string (car method)))
4754 (nth 1 (gnus-info-method info))))
4755 ;; It's a native group.
4756 (gnus-group-make-group (gnus-info-group info)))
4757 (gnus-message 6 "Note: New group created")
4759 (gnus-gethash (gnus-group-prefixed-name
4760 (gnus-group-real-name (gnus-info-group info))
4761 (or (gnus-info-method info) gnus-select-method))
4762 gnus-newsrc-hashtb))))
4763 ;; Whether it was a new group or not, we now have the entry, so we
4764 ;; can do the update.
4767 (setcar (nthcdr 2 entry) info)
4768 (when (and (not (eq (car entry) t))
4769 (gnus-active (gnus-info-group info)))
4770 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4771 (error "No such group: %s" (gnus-info-group info)))))
4773 (defun gnus-group-set-method-info (group select-method)
4774 (gnus-group-set-info select-method group 'method))
4776 (defun gnus-group-set-params-info (group params)
4777 (gnus-group-set-info params group 'params))
4779 (defun gnus-group-update-group-line ()
4780 "Update the current line in the group buffer."
4781 (let* ((buffer-read-only nil)
4782 (group (gnus-group-group-name))
4783 (gnus-group-indentation (gnus-group-group-indentation))
4784 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4786 (not (gnus-ephemeral-group-p group))
4788 (concat "(gnus-group-set-info '"
4789 (prin1-to-string (nth 2 entry)) ")")))
4791 (gnus-group-insert-group-line-info group)
4793 (gnus-group-position-point)))
4795 (defun gnus-group-insert-group-line-info (group)
4796 "Insert GROUP on the current line."
4797 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4801 ;; (Un)subscribed group.
4802 (setq info (nth 2 entry))
4803 (gnus-group-insert-group-line
4804 group (gnus-info-level info) (gnus-info-marks info)
4805 (or (car entry) t) (gnus-info-method info)))
4806 ;; This group is dead.
4807 (gnus-group-insert-group-line
4809 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4811 (if (setq active (gnus-active group))
4812 (- (1+ (cdr active)) (car active)) 0)
4815 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4816 gnus-tmp-marked number
4818 "Insert a group line in the group buffer."
4819 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4820 (gnus-tmp-number-total
4822 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4824 (gnus-tmp-number-of-unread
4825 (if (numberp number) (int-to-string (max 0 number))
4827 (gnus-tmp-number-of-read
4828 (if (numberp number)
4829 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4831 (gnus-tmp-subscribed
4832 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4833 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4834 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4836 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4837 (gnus-tmp-newsgroup-description
4838 (if gnus-description-hashtb
4839 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4842 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4843 (gnus-tmp-moderated-string
4844 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4846 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4847 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4848 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4849 (gnus-tmp-news-method-string
4851 (format "(%s:%s)" (car gnus-tmp-method)
4852 (cadr gnus-tmp-method)) ""))
4853 (gnus-tmp-marked-mark
4854 (if (and (numberp number)
4856 (cdr (assq 'tick gnus-tmp-marked)))
4858 (gnus-tmp-process-marked
4859 (if (member gnus-tmp-group gnus-group-marked)
4860 gnus-process-mark ? ))
4862 (or (and gnus-use-grouplens
4863 (bbb-grouplens-group-p gnus-tmp-group))
4865 (buffer-read-only nil)
4866 header gnus-tmp-header) ; passed as parameter to user-funcs.
4868 (add-text-properties
4872 (eval gnus-group-line-format-spec))
4873 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4874 gnus-unread ,(if (numberp number)
4875 (string-to-int gnus-tmp-number-of-unread)
4877 gnus-marked ,gnus-tmp-marked-mark
4878 gnus-indentation ,gnus-group-indentation
4879 gnus-level ,gnus-tmp-level))
4880 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4882 (run-hooks 'gnus-group-update-hook)
4884 ;; Allow XEmacs to remove front-sticky text properties.
4885 (gnus-group-remove-excess-properties)))
4887 (defun gnus-group-update-group (group &optional visible-only)
4888 "Update all lines where GROUP appear.
4889 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4892 (set-buffer gnus-group-buffer)
4893 ;; The buffer may be narrowed.
4896 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4898 found buffer-read-only)
4899 ;; Enter the current status into the dribble buffer.
4900 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4901 (if (and entry (not (gnus-ephemeral-group-p group)))
4903 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4905 ;; Find all group instances. If topics are in use, each group
4906 ;; may be listed in more than once.
4907 (while (setq loc (text-property-any
4908 loc (point-max) 'gnus-group ident))
4911 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4913 (gnus-group-insert-group-line-info group))
4914 (setq loc (1+ loc)))
4915 (unless (or found visible-only)
4916 ;; No such line in the buffer, find out where it's supposed to
4917 ;; go, and insert it there (or at the end of the buffer).
4918 (if gnus-goto-missing-group-function
4919 (funcall gnus-goto-missing-group-function group)
4920 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4921 (while (and entry (car entry)
4925 (point-min) (point-max)
4926 'gnus-group (gnus-intern-safe
4927 (caar entry) gnus-active-hashtb)))))
4928 (setq entry (cdr entry)))
4929 (or entry (goto-char (point-max)))))
4930 ;; Finally insert the line.
4931 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4932 (gnus-group-insert-group-line-info group)))
4933 (gnus-group-set-mode-line)))))
4935 (defun gnus-group-set-mode-line ()
4936 (when (memq 'group gnus-updated-mode-lines)
4937 (let* ((gformat (or gnus-group-mode-line-format-spec
4938 (setq gnus-group-mode-line-format-spec
4940 gnus-group-mode-line-format
4941 gnus-group-mode-line-format-alist))))
4942 (gnus-tmp-news-server (cadr gnus-select-method))
4943 (gnus-tmp-news-method (car gnus-select-method))
4945 gnus-tmp-header ;Dummy binding for user-defined formats
4946 ;; Get the resulting string.
4947 (mode-string (eval gformat)))
4948 ;; If the line is too long, we chop it off.
4949 (when (> (length mode-string) max-len)
4950 (setq mode-string (substring mode-string 0 (- max-len 4))))
4952 (setq mode-line-buffer-identification (list mode-string))
4953 (set-buffer-modified-p t)))))
4955 (defun gnus-group-group-name ()
4956 "Get the name of the newsgroup on the current line."
4957 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4958 (and group (symbol-name group))))
4960 (defun gnus-group-group-level ()
4961 "Get the level of the newsgroup on the current line."
4962 (get-text-property (gnus-point-at-bol) 'gnus-level))
4964 (defun gnus-group-group-indentation ()
4965 "Get the indentation of the newsgroup on the current line."
4966 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
4967 (and gnus-group-indentation-function
4968 (funcall gnus-group-indentation-function))
4971 (defun gnus-group-group-unread ()
4972 "Get the number of unread articles of the newsgroup on the current line."
4973 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4975 (defun gnus-group-search-forward (&optional backward all level first-too)
4976 "Find the next newsgroup with unread articles.
4977 If BACKWARD is non-nil, find the previous newsgroup instead.
4978 If ALL is non-nil, just find any newsgroup.
4979 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4981 If FIRST-TOO, the current line is also eligible as a target."
4982 (let ((way (if backward -1 1))
4983 (low gnus-level-killed)
4986 (if (and backward (progn (beginning-of-line)) (bobp))
4988 (or first-too (forward-line way))
4996 (get-text-property (point) 'gnus-unread)))
4997 (and (numberp unread) (> unread 0)))
4998 (setq lev (get-text-property (point)
5000 (<= lev gnus-level-subscribed)))
5002 (and (setq lev (get-text-property (point)
5011 (zerop (forward-line way)))))
5013 (progn (gnus-group-position-point) t)
5014 (goto-char (or pos beg))
5017 ;;; Gnus group mode commands
5021 (defun gnus-group-mark-group (n &optional unmark no-advance)
5022 "Mark the current group."
5024 (let ((buffer-read-only nil)
5028 (setq group (gnus-group-group-name))
5032 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5037 (setq gnus-group-marked (delete group gnus-group-marked)))
5039 (setq gnus-group-marked
5040 (cons group (delete group gnus-group-marked))))
5042 (or no-advance (zerop (gnus-group-next-group 1))))
5044 (gnus-summary-position-point)
5047 (defun gnus-group-unmark-group (n)
5048 "Remove the mark from the current group."
5050 (gnus-group-mark-group n 'unmark)
5051 (gnus-group-position-point))
5053 (defun gnus-group-unmark-all-groups ()
5054 "Unmark all groups."
5056 (let ((groups gnus-group-marked))
5059 (gnus-group-remove-mark (pop groups)))))
5060 (gnus-group-position-point))
5062 (defun gnus-group-mark-region (unmark beg end)
5063 "Mark all groups between point and mark.
5064 If UNMARK, remove the mark instead."
5065 (interactive "P\nr")
5066 (let ((num (count-lines beg end)))
5069 (- num (gnus-group-mark-group num unmark)))))
5071 (defun gnus-group-mark-buffer (&optional unmark)
5072 "Mark all groups in the buffer.
5073 If UNMARK, remove the mark instead."
5075 (gnus-group-mark-region unmark (point-min) (point-max)))
5077 (defun gnus-group-mark-regexp (regexp)
5078 "Mark all groups that match some regexp."
5079 (interactive "sMark (regexp): ")
5080 (let ((alist (cdr gnus-newsrc-alist))
5083 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5084 (gnus-group-set-mark group))))
5085 (gnus-group-position-point))
5087 (defun gnus-group-remove-mark (group)
5088 "Remove the process mark from GROUP and move point there.
5089 Return nil if the group isn't displayed."
5090 (if (gnus-group-goto-group group)
5092 (gnus-group-mark-group 1 'unmark t)
5094 (setq gnus-group-marked
5095 (delete group gnus-group-marked))
5098 (defun gnus-group-set-mark (group)
5099 "Set the process mark on GROUP."
5100 (if (gnus-group-goto-group group)
5102 (gnus-group-mark-group 1 nil t))
5103 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5105 (defun gnus-group-universal-argument (arg &optional groups func)
5106 "Perform any command on all groups accoring to the process/prefix convention."
5108 (let ((groups (or groups (gnus-group-process-prefix arg)))
5110 (if (eq (setq func (or func
5113 (substitute-command-keys
5114 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5117 (message "Undefined key")
5120 (gnus-group-remove-mark (setq group (pop groups)))
5121 (command-execute func))))
5122 (gnus-group-position-point))
5124 (defun gnus-group-process-prefix (n)
5125 "Return a list of groups to work on.
5126 Take into consideration N (the prefix) and the list of marked groups."
5129 (setq n (prefix-numeric-value n))
5130 ;; There is a prefix, so we return a list of the N next
5132 (let ((way (if (< n 0) -1 1))
5137 (setq group (gnus-group-group-name)))
5138 (setq groups (cons group groups))
5140 (gnus-group-next-group way)))
5142 ((and (boundp 'transient-mark-mode)
5145 ;; Work on the region between point and mark.
5146 (let ((max (max (point) (mark)))
5149 (goto-char (min (point) (mark)))
5152 (push (gnus-group-group-name) groups)
5153 (zerop (gnus-group-next-group 1))
5155 (nreverse groups))))
5157 ;; No prefix, but a list of marked articles.
5158 (reverse gnus-group-marked))
5160 ;; Neither marked articles or a prefix, so we return the
5162 (let ((group (gnus-group-group-name)))
5163 (and group (list group))))))
5165 ;; Selecting groups.
5167 (defun gnus-group-read-group (&optional all no-article group)
5168 "Read news in this newsgroup.
5169 If the prefix argument ALL is non-nil, already read articles become
5170 readable. IF ALL is a number, fetch this number of articles. If the
5171 optional argument NO-ARTICLE is non-nil, no article will be
5172 auto-selected upon group entry. If GROUP is non-nil, fetch that
5175 (let ((group (or group (gnus-group-group-name)))
5176 number active marked entry)
5177 (or group (error "No group on current line"))
5178 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5179 group gnus-newsrc-hashtb)))))
5180 ;; This group might be a dead group. In that case we have to get
5181 ;; the number of unread articles from `gnus-active-hashtb'.
5183 (cond ((numberp all) all)
5185 ((setq active (gnus-active group))
5186 (- (1+ (cdr active)) (car active)))))
5187 (gnus-summary-read-group
5188 group (or all (and (numberp number)
5189 (zerop (+ number (length (cdr (assq 'tick marked)))
5190 (length (cdr (assq 'dormant marked)))))))
5193 (defun gnus-group-select-group (&optional all)
5194 "Select this newsgroup.
5195 No article is selected automatically.
5196 If ALL is non-nil, already read articles become readable.
5197 If ALL is a number, fetch this number of articles."
5199 (gnus-group-read-group all t))
5201 (defun gnus-group-quick-select-group (&optional all)
5202 "Select the current group \"quickly\".
5203 This means that no highlighting or scoring will be performed."
5206 gnus-score-find-score-files-function
5207 gnus-apply-kill-hook
5208 gnus-summary-expunge-below)
5209 (gnus-group-read-group all t)))
5211 (defun gnus-group-visible-select-group (&optional all)
5212 "Select the current group without hiding any articles."
5214 (let ((gnus-inhibit-limiting t))
5215 (gnus-group-read-group all t)))
5218 (defun gnus-fetch-group (group)
5219 "Start Gnus if necessary and enter GROUP.
5220 Returns whether the fetching was successful or not."
5221 (interactive "sGroup name: ")
5222 (or (get-buffer gnus-group-buffer)
5224 (gnus-group-read-group nil nil group))
5226 ;; Enter a group that is not in the group buffer. Non-nil is returned
5227 ;; if selection was successful.
5228 (defun gnus-group-read-ephemeral-group
5229 (group method &optional activate quit-config)
5230 (let ((group (if (gnus-group-foreign-p group) group
5231 (gnus-group-prefixed-name group method))))
5234 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5235 ((quit-config . ,(if quit-config quit-config
5236 (cons (current-buffer) 'summary))))))
5238 (set-buffer gnus-group-buffer)
5239 (or (gnus-check-server method)
5240 (error "Unable to contact server: %s" (gnus-status-message method)))
5241 (if activate (or (gnus-request-group group)
5242 (error "Couldn't request group")))
5244 (gnus-group-read-group t t group)
5248 (defun gnus-group-jump-to-group (group)
5249 "Jump to newsgroup GROUP."
5251 (list (completing-read
5252 "Group: " gnus-active-hashtb nil
5253 (memq gnus-select-method gnus-have-read-active-file))))
5255 (if (equal group "")
5256 (error "Empty group name"))
5258 (let ((b (text-property-any
5259 (point-min) (point-max)
5260 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5261 (unless (gnus-ephemeral-group-p group)
5263 ;; Either go to the line in the group buffer...
5265 ;; ... or insert the line.
5268 (gnus-activate-group group)
5269 (error "%s error: %s" group (gnus-status-message group)))
5271 (gnus-group-update-group group)
5272 (goto-char (text-property-any
5273 (point-min) (point-max)
5274 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5275 ;; Adjust cursor point.
5276 (gnus-group-position-point)))
5278 (defun gnus-group-goto-group (group)
5279 "Goto to newsgroup GROUP."
5281 (let ((b (text-property-any (point-min) (point-max)
5282 'gnus-group (gnus-intern-safe
5283 group gnus-active-hashtb))))
5284 (and b (goto-char b)))))
5286 (defun gnus-group-next-group (n)
5287 "Go to next N'th newsgroup.
5288 If N is negative, search backward instead.
5289 Returns the difference between N and the number of skips actually
5292 (gnus-group-next-unread-group n t))
5294 (defun gnus-group-next-unread-group (n &optional all level)
5295 "Go to next N'th unread newsgroup.
5296 If N is negative, search backward instead.
5297 If ALL is non-nil, choose any newsgroup, unread or not.
5298 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5299 such group can be found, the next group with a level higher than
5301 Returns the difference between N and the number of skips actually
5304 (let ((backward (< n 0))
5307 (gnus-group-search-forward
5308 backward (or (not gnus-group-goto-unread) all) level))
5310 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5311 (if level " on this level or higher" "")))
5314 (defun gnus-group-prev-group (n)
5315 "Go to previous N'th newsgroup.
5316 Returns the difference between N and the number of skips actually
5319 (gnus-group-next-unread-group (- n) t))
5321 (defun gnus-group-prev-unread-group (n)
5322 "Go to previous N'th unread newsgroup.
5323 Returns the difference between N and the number of skips actually
5326 (gnus-group-next-unread-group (- n)))
5328 (defun gnus-group-next-unread-group-same-level (n)
5329 "Go to next N'th unread newsgroup on the same level.
5330 If N is negative, search backward instead.
5331 Returns the difference between N and the number of skips actually
5334 (gnus-group-next-unread-group n t (gnus-group-group-level))
5335 (gnus-group-position-point))
5337 (defun gnus-group-prev-unread-group-same-level (n)
5338 "Go to next N'th unread newsgroup on the same level.
5339 Returns the difference between N and the number of skips actually
5342 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5343 (gnus-group-position-point))
5345 (defun gnus-group-best-unread-group (&optional exclude-group)
5346 "Go to the group with the highest level.
5347 If EXCLUDE-GROUP, do not go to that group."
5349 (goto-char (point-min))
5353 (setq unread (get-text-property (point) 'gnus-unread))
5354 (if (and (numberp unread) (> unread 0))
5356 (if (and (get-text-property (point) 'gnus-level)
5357 (< (get-text-property (point) 'gnus-level) best)
5358 (or (not exclude-group)
5359 (not (equal exclude-group (gnus-group-group-name)))))
5361 (setq best (get-text-property (point) 'gnus-level))
5362 (setq best-point (point))))))
5364 (if best-point (goto-char best-point))
5365 (gnus-summary-position-point)
5366 (and best-point (gnus-group-group-name))))
5368 (defun gnus-group-first-unread-group ()
5369 "Go to the first group with unread articles."
5372 (let ((opoint (point))
5374 (goto-char (point-min))
5375 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5376 (and (numberp unread) ; Not a topic.
5377 (not (zerop unread))) ; Has unread articles.
5378 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5381 nil)) ; Not success.
5382 (gnus-group-position-point)))
5384 (defun gnus-group-enter-server-mode ()
5385 "Jump to the server buffer."
5387 (gnus-enter-server-buffer))
5389 (defun gnus-group-make-group (name &optional method address)
5390 "Add a new newsgroup.
5391 The user will be prompted for a NAME, for a select METHOD, and an
5395 (read-string "Group name: ")
5398 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5400 (cond ((assoc method gnus-valid-select-methods)
5402 (if (memq 'prompt-address
5403 (assoc method gnus-valid-select-methods))
5404 (read-string "Address: ")
5406 ((assoc method gnus-server-alist)
5409 (list method ""))))))
5412 (set-buffer gnus-group-buffer)
5413 (let* ((meth (and method (if address (list (intern method) address)
5415 (nname (if method (gnus-group-prefixed-name name meth) name))
5417 (and (gnus-gethash nname gnus-newsrc-hashtb)
5418 (error "Group %s already exists" nname))
5419 (gnus-group-change-level
5420 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5421 gnus-level-default-subscribed gnus-level-killed
5422 (and (gnus-group-group-name)
5423 (gnus-gethash (gnus-group-group-name)
5424 gnus-newsrc-hashtb))
5426 (gnus-set-active nname (cons 1 0))
5427 (or (gnus-ephemeral-group-p name)
5429 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5430 (gnus-group-insert-group-line-info nname)
5432 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5434 gnus-valid-select-methods)
5436 (gnus-check-server meth)
5437 (and (gnus-check-backend-function 'request-create-group nname)
5438 (gnus-request-create-group nname))
5441 (defun gnus-group-delete-group (group &optional force)
5442 "Delete the current group.
5443 If FORCE (the prefix) is non-nil, all the articles in the group will
5444 be deleted. This is \"deleted\" as in \"removed forever from the face
5445 of the Earth\". There is no undo."
5447 (list (gnus-group-group-name)
5448 current-prefix-arg))
5449 (or group (error "No group to rename"))
5450 (or (gnus-check-backend-function 'request-delete-group group)
5451 (error "This backend does not support group deletion"))
5453 (if (not (gnus-yes-or-no-p
5455 "Do you really want to delete %s%s? "
5456 group (if force " and all its contents" ""))))
5458 (gnus-message 6 "Deleting group %s..." group)
5459 (if (not (gnus-request-delete-group group force))
5461 (gnus-message 3 "Couldn't delete group %s" group)
5463 (gnus-message 6 "Deleting group %s...done" group)
5464 (gnus-group-goto-group group)
5465 (gnus-group-kill-group 1 t)
5466 (gnus-sethash group nil gnus-active-hashtb)
5468 (gnus-group-position-point)))
5470 (defun gnus-group-rename-group (group new-name)
5473 (gnus-group-group-name)
5475 (or (gnus-check-backend-function
5476 'request-rename-group (gnus-group-group-name))
5477 (error "This backend does not support renaming groups"))
5478 (read-string "New group name: "))))
5480 (or (gnus-check-backend-function 'request-rename-group group)
5481 (error "This backend does not support renaming groups"))
5483 (or group (error "No group to rename"))
5484 (and (string-match "^[ \t]*$" new-name)
5485 (error "Not a valid group name"))
5487 ;; We find the proper prefixed name.
5489 (gnus-group-prefixed-name
5490 (gnus-group-real-name new-name)
5491 (gnus-info-method (gnus-get-info group))))
5493 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5495 (if (not (gnus-request-rename-group group new-name))
5497 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5499 ;; We rename the group internally by killing it...
5500 (gnus-group-goto-group group)
5501 (gnus-group-kill-group)
5502 ;; ... changing its name ...
5503 (setcar (cdar gnus-list-of-killed-groups) new-name)
5504 ;; ... and then yanking it. Magic!
5505 (gnus-group-yank-group)
5506 (gnus-set-active new-name (gnus-active group))
5507 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5509 (gnus-group-position-point)))
5511 (defun gnus-group-edit-group (group &optional part)
5512 "Edit the group on the current line."
5513 (interactive (list (gnus-group-group-name)))
5514 (let* ((part (or part 'info))
5515 (done-func `(lambda ()
5516 "Exit editing mode and update the information."
5518 (gnus-group-edit-group-done ',part ,group)))
5519 (winconf (current-window-configuration))
5521 (or group (error "No group on current line"))
5522 (or (setq info (gnus-get-info group))
5523 (error "Killed group; can't be edited"))
5524 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5525 (gnus-configure-windows 'edit-group)
5526 (gnus-add-current-to-buffer-list)
5528 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5529 (use-local-map (copy-keymap emacs-lisp-mode-map))
5530 (local-set-key "\C-c\C-c" done-func)
5531 (make-local-variable 'gnus-prev-winconf)
5532 (setq gnus-prev-winconf winconf)
5537 ";; Type `C-c C-c' after editing the select method.\n\n")
5539 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5541 ";; Type `C-c C-c' after editing the group info.\n\n")))
5544 (cond ((eq part 'method)
5545 (or (gnus-info-method info) "native"))
5547 (gnus-info-params info))
5551 (defun gnus-group-edit-group-method (group)
5552 "Edit the select method of GROUP."
5553 (interactive (list (gnus-group-group-name)))
5554 (gnus-group-edit-group group 'method))
5556 (defun gnus-group-edit-group-parameters (group)
5557 "Edit the group parameters of GROUP."
5558 (interactive (list (gnus-group-group-name)))
5559 (gnus-group-edit-group group 'params))
5561 (defun gnus-group-edit-group-done (part group)
5562 "Get info from buffer, update variables and jump to the group buffer."
5563 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5564 (goto-char (point-min))
5565 (let* ((form (read (current-buffer)))
5566 (winconf gnus-prev-winconf)
5567 (method (cond ((eq part 'info) (nth 4 form))
5568 ((eq part 'method) form)
5570 (info (cond ((eq part 'info) form)
5571 ((eq part 'method) (gnus-get-info group))
5574 (if (or (not method)
5576 gnus-select-method method))
5577 (gnus-group-real-name (car info))
5578 (gnus-group-prefixed-name
5579 (gnus-group-real-name (car info)) method))
5581 (when (and new-group
5582 (not (equal new-group group)))
5583 (when (gnus-group-goto-group group)
5584 (gnus-group-kill-group 1))
5585 (gnus-activate-group new-group))
5587 (if (and info new-group)
5589 (setq info (gnus-copy-sequence info))
5590 (setcar info new-group)
5591 (unless (gnus-server-equal method "native")
5592 (unless (nthcdr 3 info)
5593 (nconc info (list nil nil)))
5594 (unless (nthcdr 4 info)
5595 (nconc info (list nil)))
5596 (gnus-info-set-method info method))
5597 (gnus-group-set-info info))
5598 (gnus-group-set-info form (or new-group group) part))
5599 (kill-buffer (current-buffer))
5600 (and winconf (set-window-configuration winconf))
5601 (set-buffer gnus-group-buffer)
5602 (gnus-group-update-group (or new-group group))
5603 (gnus-group-position-point)))
5605 (defun gnus-group-make-help-group ()
5606 "Create the Gnus documentation group."
5608 (let ((path load-path)
5609 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5611 (and (gnus-gethash name gnus-newsrc-hashtb)
5612 (error "Documentation group already exists"))
5614 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5616 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5618 (setq file (concat (file-name-directory
5619 (directory-file-name dir))
5620 "etc/gnus-tut.txt"))))
5623 (message "Couldn't find doc group")
5624 (gnus-group-make-group
5625 (gnus-group-real-name name)
5626 (list 'nndoc "gnus-help"
5627 (list 'nndoc-address file)
5628 (list 'nndoc-article-type 'mbox)))))
5629 (gnus-group-position-point))
5631 (defun gnus-group-make-doc-group (file type)
5632 "Create a group that uses a single file as the source."
5634 (list (read-file-name "File name: ")
5635 (and current-prefix-arg 'ask)))
5636 (when (eq type 'ask)
5641 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5643 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5644 ((= char ?b) 'babyl)
5645 ((= char ?d) 'digest)
5646 ((= char ?f) 'forward)
5648 (t (setq err (format "%c unknown. " char))
5651 (let* ((file (expand-file-name file))
5652 (name (gnus-generate-new-group-name
5653 (gnus-group-prefixed-name
5654 (file-name-nondirectory file) '(nndoc "")))))
5655 (gnus-group-make-group
5656 (gnus-group-real-name name)
5657 (list 'nndoc (file-name-nondirectory file)
5658 (list 'nndoc-address file)
5659 (list 'nndoc-article-type (or type 'guess))))
5661 (gnus-group-position-point)))
5663 (defun gnus-group-make-archive-group (&optional all)
5664 "Create the (ding) Gnus archive group of the most recent articles.
5665 Given a prefix, create a full group."
5667 (let ((group (gnus-group-prefixed-name
5668 (if all "ding.archives" "ding.recent") '(nndir ""))))
5669 (and (gnus-gethash group gnus-newsrc-hashtb)
5670 (error "Archive group already exists"))
5671 (gnus-group-make-group
5672 (gnus-group-real-name group)
5673 (list 'nndir (if all "hpc" "edu")
5674 (list 'nndir-directory
5675 (if all gnus-group-archive-directory
5676 gnus-group-recent-archive-directory)))))
5678 (gnus-group-position-point))
5680 (defun gnus-group-make-directory-group (dir)
5681 "Create an nndir group.
5682 The user will be prompted for a directory. The contents of this
5683 directory will be used as a newsgroup. The directory should contain
5684 mail messages or news articles in files that have numeric names."
5686 (list (read-file-name "Create group from directory: ")))
5687 (or (file-exists-p dir) (error "No such directory"))
5688 (or (file-directory-p dir) (error "Not a directory"))
5692 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5694 (gnus-group-prefixed-name
5695 (concat (file-name-as-directory (directory-file-name dir))
5698 (setq ext (format "<%d>" (setq i (1+ i)))))
5699 (gnus-group-make-group
5700 (gnus-group-real-name group)
5701 (list 'nndir group (list 'nndir-directory dir))))
5703 (gnus-group-position-point))
5705 (defun gnus-group-make-kiboze-group (group address scores)
5706 "Create an nnkiboze group.
5707 The user will be prompted for a name, a regexp to match groups, and
5708 score file entries for articles to include in the group."
5711 (read-string "nnkiboze group name: ")
5712 (read-string "Source groups (regexp): ")
5713 (let ((headers (mapcar (lambda (group) (list group))
5714 '("subject" "from" "number" "date" "message-id"
5715 "references" "chars" "lines" "xref"
5716 "followup" "all" "body" "head")))
5717 scores header regexp regexps)
5718 (while (not (equal "" (setq header (completing-read
5719 "Match on header: " headers nil t))))
5721 (while (not (equal "" (setq regexp (read-string
5722 (format "Match on %s (string): "
5724 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5725 (setq scores (cons (cons header regexps) scores)))
5727 (gnus-group-make-group group "nnkiboze" address)
5729 (gnus-set-work-buffer)
5730 (let (emacs-lisp-mode-hook)
5731 (pp scores (current-buffer)))
5732 (write-region (point-min) (point-max)
5733 (gnus-score-file-name (concat "nnkiboze:" group))))
5735 (gnus-group-position-point))
5737 (defun gnus-group-add-to-virtual (n vgroup)
5738 "Add the current group to a virtual group."
5740 (list current-prefix-arg
5741 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5743 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5744 (error "%s is not an nnvirtual group" vgroup))
5745 (let* ((groups (gnus-group-process-prefix n))
5746 (method (gnus-info-method (gnus-get-info vgroup))))
5747 (setcar (cdr method)
5749 (nth 1 method) "\\|"
5752 (gnus-group-remove-mark s)
5753 (concat "\\(^" (regexp-quote s) "$\\)"))
5755 (gnus-group-position-point))
5757 (defun gnus-group-make-empty-virtual (group)
5758 "Create a new, fresh, empty virtual group."
5759 (interactive "sCreate new, empty virtual group: ")
5760 (let* ((method (list 'nnvirtual "^$"))
5761 (pgroup (gnus-group-prefixed-name group method)))
5762 ;; Check whether it exists already.
5763 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5764 (error "Group %s already exists." pgroup))
5765 ;; Subscribe the new group after the group on the current line.
5766 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5767 (gnus-group-update-group pgroup)
5769 (gnus-group-position-point)))
5771 (defun gnus-group-enter-directory (dir)
5772 "Enter an ephemeral nneething group."
5773 (interactive "DDirectory to read: ")
5774 (let* ((method (list 'nneething dir))
5775 (leaf (gnus-group-prefixed-name
5776 (file-name-nondirectory (directory-file-name dir))
5778 (name (gnus-generate-new-group-name leaf)))
5779 (let ((nneething-read-only t))
5780 (or (gnus-group-read-ephemeral-group
5782 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5784 (error "Couldn't enter %s" dir)))))
5786 ;; Group sorting commands
5787 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5789 (defun gnus-group-sort-groups (func &optional reverse)
5790 "Sort the group buffer according to FUNC.
5791 If REVERSE, reverse the sorting order."
5792 (interactive (list gnus-group-sort-function
5793 current-prefix-arg))
5795 ((not (listp func)) func)
5797 ((= 1 (length func)) (car func))
5799 ,(gnus-make-sort-function
5800 (reverse func)))))))
5801 ;; We peel off the dummy group from the alist.
5803 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5804 (pop gnus-newsrc-alist))
5806 (setq gnus-newsrc-alist
5807 (sort gnus-newsrc-alist func))
5809 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5810 ;; Regenerate the hash table.
5811 (gnus-make-hashtable-from-newsrc-alist)
5812 (gnus-group-list-groups))))
5814 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5815 "Sort the group buffer alphabetically by group name.
5816 If REVERSE, sort in reverse order."
5818 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5820 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5821 "Sort the group buffer by number of unread articles.
5822 If REVERSE, sort in reverse order."
5824 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5826 (defun gnus-group-sort-groups-by-level (&optional reverse)
5827 "Sort the group buffer by group level.
5828 If REVERSE, sort in reverse order."
5830 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5832 (defun gnus-group-sort-groups-by-score (&optional reverse)
5833 "Sort the group buffer by group score.
5834 If REVERSE, sort in reverse order."
5836 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5838 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5839 "Sort the group buffer by group rank.
5840 If REVERSE, sort in reverse order."
5842 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5844 (defun gnus-group-sort-groups-by-method (&optional reverse)
5845 "Sort the group buffer alphabetically by backend name.
5846 If REVERSE, sort in reverse order."
5848 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5850 (defun gnus-group-sort-by-alphabet (info1 info2)
5851 "Sort alphabetically."
5852 (string< (gnus-info-group info1) (gnus-info-group info2)))
5854 (defun gnus-group-sort-by-unread (info1 info2)
5855 "Sort by number of unread articles."
5856 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5857 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5858 (< (or (and (numberp n1) n1) 0)
5859 (or (and (numberp n2) n2) 0))))
5861 (defun gnus-group-sort-by-level (info1 info2)
5863 (< (gnus-info-level info1) (gnus-info-level info2)))
5865 (defun gnus-group-sort-by-method (info1 info2)
5866 "Sort alphabetically by backend name."
5867 (string< (symbol-name (car (gnus-find-method-for-group
5868 (gnus-info-group info1) info1)))
5869 (symbol-name (car (gnus-find-method-for-group
5870 (gnus-info-group info2) info2)))))
5872 (defun gnus-group-sort-by-score (info1 info2)
5873 "Sort by group score."
5874 (< (gnus-info-score info1) (gnus-info-score info2)))
5876 (defun gnus-group-sort-by-rank (info1 info2)
5877 "Sort by level and score."
5878 (let ((level1 (gnus-info-level info1))
5879 (level2 (gnus-info-level info2)))
5880 (or (< level1 level2)
5881 (and (= level1 level2)
5882 (< (gnus-info-score info1) (gnus-info-score info2))))))
5884 ;; Group catching up.
5886 (defun gnus-group-clear-data (n)
5887 "Clear all marks and read ranges from the current group."
5889 (let ((groups (gnus-group-process-prefix n))
5891 (while (setq group (pop groups))
5892 (setq info (gnus-get-info group))
5893 (gnus-info-set-read info nil)
5894 (when (gnus-info-marks info)
5895 (gnus-info-set-marks info nil))
5896 (gnus-get-unread-articles-in-group info (gnus-active group) t)
5897 (when (gnus-group-goto-group group)
5898 (gnus-group-remove-mark group)
5899 (gnus-group-update-group-line)))))
5901 (defun gnus-group-catchup-current (&optional n all)
5902 "Mark all articles not marked as unread in current newsgroup as read.
5903 If prefix argument N is numeric, the ARG next newsgroups will be
5904 caught up. If ALL is non-nil, marked articles will also be marked as
5905 read. Cross references (Xref: header) of articles are ignored.
5906 The difference between N and actual number of newsgroups that were
5907 caught up is returned."
5909 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5913 "Do you really want to mark all articles as read? "
5914 "Mark all unread articles as read? "))))
5916 (let ((groups (gnus-group-process-prefix n))
5919 ;; Virtual groups have to be given special treatment.
5920 (let ((method (gnus-find-method-for-group (car groups))))
5921 (if (eq 'nnvirtual (car method))
5922 (nnvirtual-catchup-group
5923 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5924 (gnus-group-remove-mark (car groups))
5926 (gnus-group-goto-group (car groups))
5927 (gnus-group-catchup (car groups) all))
5928 (gnus-group-update-group-line)
5929 (setq ret (1+ ret)))
5930 (setq groups (cdr groups)))
5931 (gnus-group-next-unread-group 1)
5934 (defun gnus-group-catchup-current-all (&optional n)
5935 "Mark all articles in current newsgroup as read.
5936 Cross references (Xref: header) of articles are ignored."
5938 (gnus-group-catchup-current n 'all))
5940 (defun gnus-group-catchup (group &optional all)
5941 "Mark all articles in GROUP as read.
5942 If ALL is non-nil, all articles are marked as read.
5943 The return value is the number of articles that were marked as read,
5944 or nil if no action could be taken."
5945 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5947 ;; Do the updating only if the newsgroup isn't killed.
5948 (if (not (numberp (car entry)))
5949 (gnus-message 1 "Can't catch up; non-active group")
5950 ;; Do auto-expirable marks if that's required.
5951 (when (gnus-group-auto-expirable-p group)
5952 (gnus-add-marked-articles
5953 group 'expire (gnus-list-of-unread-articles group))
5955 (let ((marks (nth 3 (nth 2 entry))))
5956 (gnus-add-marked-articles
5957 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5958 (gnus-add-marked-articles
5959 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5961 (gnus-update-read-articles group nil)
5962 ;; Also nix out the lists of marks and dormants.
5964 (gnus-add-marked-articles group 'tick nil nil 'force)
5965 (gnus-add-marked-articles group 'dormant nil nil 'force))
5966 (run-hooks 'gnus-group-catchup-group-hook)
5969 (defun gnus-group-expire-articles (&optional n)
5970 "Expire all expirable articles in the current newsgroup."
5972 (let ((groups (gnus-group-process-prefix n))
5975 (error "No groups to expire"))
5976 (while (setq group (pop groups))
5977 (gnus-group-remove-mark group)
5978 (when (gnus-check-backend-function 'request-expire-articles group)
5979 (gnus-message 6 "Expiring articles in %s..." group)
5980 (let* ((info (gnus-get-info group))
5981 (expirable (if (gnus-group-total-expirable-p group)
5982 (cons nil (gnus-list-of-read-articles group))
5983 (assq 'expire (gnus-info-marks info))))
5984 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5988 (gnus-compress-sequence
5990 ;; We set the expiry variables to the groupp
5992 (let ((nnmail-expiry-wait-function nil)
5993 (nnmail-expiry-wait expiry-wait))
5994 (gnus-request-expire-articles
5995 (gnus-uncompress-sequence (cdr expirable)) group))
5996 ;; Just expire using the normal expiry values.
5997 (gnus-request-expire-articles
5998 (gnus-uncompress-sequence (cdr expirable)) group)))))
5999 (gnus-message 6 "Expiring articles in %s...done" group)))
6000 (gnus-group-position-point))))
6002 (defun gnus-group-expire-all-groups ()
6003 "Expire all expirable articles in all newsgroups."
6006 (gnus-message 5 "Expiring...")
6007 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6008 (cdr gnus-newsrc-alist))))
6009 (gnus-group-expire-articles nil)))
6010 (gnus-group-position-point)
6011 (gnus-message 5 "Expiring...done"))
6013 (defun gnus-group-set-current-level (n level)
6014 "Set the level of the next N groups to LEVEL."
6019 (let ((s (read-string
6020 (format "Level (default %s): "
6021 (or (gnus-group-group-level)
6022 gnus-level-default-subscribed)))))
6023 (if (string-match "^\\s-*$" s)
6024 (int-to-string (or (gnus-group-group-level)
6025 gnus-level-default-subscribed))
6027 (or (and (>= level 1) (<= level gnus-level-killed))
6028 (error "Illegal level: %d" level))
6029 (let ((groups (gnus-group-process-prefix n))
6031 (while (setq group (pop groups))
6032 (gnus-group-remove-mark group)
6033 (gnus-message 6 "Changed level of %s from %d to %d"
6034 group (or (gnus-group-group-level) gnus-level-killed)
6036 (gnus-group-change-level
6037 group level (or (gnus-group-group-level) gnus-level-killed))
6038 (gnus-group-update-group-line)))
6039 (gnus-group-position-point))
6041 (defun gnus-group-unsubscribe-current-group (&optional n)
6042 "Toggle subscription of the current group.
6043 If given numerical prefix, toggle the N next groups."
6045 (let ((groups (gnus-group-process-prefix n))
6048 (setq group (car groups)
6049 groups (cdr groups))
6050 (gnus-group-remove-mark group)
6051 (gnus-group-unsubscribe-group
6052 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6053 gnus-level-default-unsubscribed
6054 gnus-level-default-subscribed) t)
6055 (gnus-group-update-group-line))
6056 (gnus-group-next-group 1)))
6058 (defun gnus-group-unsubscribe-group (group &optional level silent)
6059 "Toggle subscription to GROUP.
6060 Killed newsgroups are subscribed. If SILENT, don't try to update the
6063 (list (completing-read
6064 "Group: " gnus-active-hashtb nil
6065 (memq gnus-select-method gnus-have-read-active-file))))
6066 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6068 ((string-match "^[ \t]$" group)
6069 (error "Empty group name"))
6071 ;; Toggle subscription flag.
6072 (gnus-group-change-level
6073 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6074 gnus-level-subscribed)
6075 (1+ gnus-level-subscribed)
6076 gnus-level-default-subscribed)))
6078 (gnus-group-update-group group)))
6079 ((and (stringp group)
6080 (or (not (memq gnus-select-method gnus-have-read-active-file))
6081 (gnus-active group)))
6082 ;; Add new newsgroup.
6083 (gnus-group-change-level
6085 (if level level gnus-level-default-subscribed)
6086 (or (and (member group gnus-zombie-list)
6089 (and (gnus-group-group-name)
6090 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6092 (gnus-group-update-group group)))
6093 (t (error "No such newsgroup: %s" group)))
6094 (gnus-group-position-point)))
6096 (defun gnus-group-transpose-groups (n)
6097 "Move the current newsgroup up N places.
6098 If given a negative prefix, move down instead. The difference between
6099 N and the number of steps taken is returned."
6101 (or (gnus-group-group-name)
6102 (error "No group on current line"))
6103 (gnus-group-kill-group 1)
6105 (forward-line (- n))
6106 (gnus-group-yank-group)
6107 (gnus-group-position-point)))
6109 (defun gnus-group-kill-all-zombies ()
6110 "Kill all zombie newsgroups."
6112 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6113 (setq gnus-zombie-list nil)
6114 (gnus-group-list-groups))
6116 (defun gnus-group-kill-region (begin end)
6117 "Kill newsgroups in current region (excluding current point).
6118 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6133 (beginning-of-line) ;Important when LINES < 1
6134 (gnus-group-kill-group lines)))
6136 (defun gnus-group-kill-group (&optional n discard)
6137 "Kill the next N groups.
6138 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6139 However, only groups that were alive can be yanked; already killed
6140 groups or zombie groups can't be yanked.
6141 The return value is the name of the group that was killed, or a list
6144 (let ((buffer-read-only nil)
6145 (groups (gnus-group-process-prefix n))
6146 group entry level out)
6147 (if (< (length groups) 10)
6148 ;; This is faster when there are few groups.
6150 (push (setq group (pop groups)) out)
6151 (gnus-group-remove-mark group)
6152 (setq level (gnus-group-group-level))
6154 (when (and (not discard)
6155 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6156 (push (cons (car entry) (nth 2 entry))
6157 gnus-list-of-killed-groups))
6158 (gnus-group-change-level
6159 (if entry entry group) gnus-level-killed (if entry nil level)))
6160 ;; If there are lots and lots of groups to be killed, we use
6161 ;; this thing instead.
6163 (setq groups (nreverse groups))
6165 (gnus-group-remove-mark (setq group (pop groups)))
6168 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6169 (push (cons (car entry) (nth 2 entry))
6170 gnus-list-of-killed-groups)
6171 (setcdr (cdr entry) (cdddr entry)))
6172 ((member group gnus-zombie-list)
6173 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6174 (gnus-make-hashtable-from-newsrc-alist)))
6176 (gnus-group-position-point)
6177 (if (< (length out) 2) (car out) (nreverse out))))
6179 (defun gnus-group-yank-group (&optional arg)
6180 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6181 inserting it before the current newsgroup. The numeric ARG specifies
6182 how many newsgroups are to be yanked. The name of the newsgroup yanked
6183 is returned, or (if several groups are yanked) a list of yanked groups
6186 (setq arg (or arg 1))
6187 (let (info group prev out)
6188 (while (>= (decf arg) 0)
6189 (if (not (setq info (pop gnus-list-of-killed-groups)))
6190 (error "No more newsgroups to yank"))
6191 (push (setq group (nth 1 info)) out)
6192 ;; Find which newsgroup to insert this one before - search
6193 ;; backward until something suitable is found. If there are no
6194 ;; other newsgroups in this buffer, just make this newsgroup the
6196 (setq prev (gnus-group-group-name))
6197 (gnus-group-change-level
6198 info (gnus-info-level (cdr info)) gnus-level-killed
6199 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6201 (gnus-group-insert-group-line-info group))
6203 (gnus-group-position-point)
6204 (if (< (length out) 2) (car out) (nreverse out))))
6206 (defun gnus-group-kill-level (level)
6207 "Kill all groups that is on a certain LEVEL."
6208 (interactive "nKill all groups on level: ")
6210 ((= level gnus-level-zombie)
6211 (setq gnus-killed-list
6212 (nconc gnus-zombie-list gnus-killed-list))
6213 (setq gnus-zombie-list nil))
6214 ((and (< level gnus-level-zombie)
6216 (or gnus-expert-user
6219 "Do you really want to kill all groups on level %d? "
6221 (let* ((prev gnus-newsrc-alist)
6224 (if (= (gnus-info-level level) level)
6225 (setcdr prev (cdr alist))
6227 (setq alist (cdr alist)))
6228 (gnus-make-hashtable-from-newsrc-alist)
6229 (gnus-group-list-groups)))
6231 (error "Can't kill; illegal level: %d" level))))
6233 (defun gnus-group-list-all-groups (&optional arg)
6234 "List all newsgroups with level ARG or lower.
6235 Default is gnus-level-unsubscribed, which lists all subscribed and most
6236 unsubscribed groups."
6238 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6240 ;; Redefine this to list ALL killed groups if prefix arg used.
6241 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6242 (defun gnus-group-list-killed (&optional arg)
6243 "List all killed newsgroups in the group buffer.
6244 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6245 entail asking the server for the groups."
6247 ;; Find all possible killed newsgroups if arg.
6249 ;; First make sure active file has been read.
6250 (unless gnus-have-read-active-file
6251 (let ((gnus-read-active-file t))
6252 (gnus-read-active-file)))
6253 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6254 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6258 (group (symbol-name sym)))
6259 (if (or (null group)
6260 (gnus-gethash group gnus-killed-hashtb)
6261 (gnus-gethash group gnus-newsrc-hashtb))
6263 (let ((do-sub (gnus-matches-options-n group)))
6264 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6266 (setq groups (1+ groups))
6267 (setq gnus-killed-list
6268 (cons group gnus-killed-list))
6269 (gnus-sethash group group gnus-killed-hashtb))))))
6270 gnus-active-hashtb))
6271 (if (not gnus-killed-list)
6272 (gnus-message 6 "No killed groups")
6273 (let (gnus-group-list-mode)
6274 (funcall gnus-group-prepare-function
6275 gnus-level-killed t gnus-level-killed))
6276 (goto-char (point-min)))
6277 (gnus-group-position-point))
6279 (defun gnus-group-list-zombies ()
6280 "List all zombie newsgroups in the group buffer."
6282 (if (not gnus-zombie-list)
6283 (gnus-message 6 "No zombie groups")
6284 (let (gnus-group-list-mode)
6285 (funcall gnus-group-prepare-function
6286 gnus-level-zombie t gnus-level-zombie))
6287 (goto-char (point-min)))
6288 (gnus-group-position-point))
6290 (defun gnus-group-list-active ()
6291 "List all groups that are available from the server(s)."
6293 ;; First we make sure that we have really read the active file.
6294 (unless gnus-have-read-active-file
6295 (let ((gnus-read-active-file t))
6296 (gnus-read-active-file)))
6297 ;; Find all groups and sort them.
6303 (and (symbol-value sym)
6304 (setq list (cons (symbol-name sym) list))))
6308 (buffer-read-only nil))
6311 (gnus-group-insert-group-line-info (pop groups)))
6312 (goto-char (point-min))))
6314 (defun gnus-activate-all-groups (level)
6315 "Activate absolutely all groups."
6316 (interactive (list 7))
6317 (let ((gnus-activate-level level)
6318 (gnus-activate-foreign-newsgroups level))
6319 (gnus-group-get-new-news)))
6321 (defun gnus-group-get-new-news (&optional arg)
6322 "Get newly arrived articles.
6323 If ARG is a number, it specifies which levels you are interested in
6324 re-scanning. If ARG is non-nil and not a number, this will force
6325 \"hard\" re-reading of the active files from all servers."
6327 (run-hooks 'gnus-get-new-news-hook)
6328 ;; We might read in new NoCeM messages here.
6329 (when (and gnus-use-nocem
6331 (gnus-nocem-scan-groups))
6332 ;; If ARG is not a number, then we read the active file.
6333 (when (and arg (not (numberp arg)))
6334 (let ((gnus-read-active-file t))
6335 (gnus-read-active-file))
6338 (setq arg (gnus-group-default-level arg t))
6339 (if (and gnus-read-active-file (not arg))
6341 (gnus-read-active-file)
6342 (gnus-get-unread-articles arg))
6343 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6344 (gnus-get-unread-articles arg)))
6345 (run-hooks 'gnus-after-getting-new-news-hook)
6346 (gnus-group-list-groups))
6348 (defun gnus-group-get-new-news-this-group (&optional n)
6349 "Check for newly arrived news in the current group (and the N-1 next groups).
6350 The difference between N and the number of newsgroup checked is returned.
6351 If N is negative, this group and the N-1 previous groups will be checked."
6353 (let* ((groups (gnus-group-process-prefix n))
6354 (ret (if (numberp n) (- n (length groups)) 0))
6357 (setq group (car groups)
6358 groups (cdr groups))
6359 (gnus-group-remove-mark group)
6360 (if (and group (gnus-activate-group group 'scan))
6362 (gnus-get-unread-articles-in-group
6363 (gnus-get-info group) (gnus-active group) t)
6364 (gnus-close-group group)
6365 (gnus-group-update-group group))
6367 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6368 (when gnus-goto-next-group-when-activating
6369 (gnus-group-next-unread-group 1 t))
6370 (gnus-summary-position-point)
6373 (defun gnus-group-fetch-faq (group &optional faq-dir)
6374 "Fetch the FAQ for the current group."
6377 (gnus-group-real-name (gnus-group-group-name))
6378 (cond (current-prefix-arg
6380 "Faq dir: " (and (listp gnus-group-faq-directory)
6381 gnus-group-faq-directory))))))
6383 (setq faq-dir (if (listp gnus-group-faq-directory)
6384 (car gnus-group-faq-directory)
6385 gnus-group-faq-directory)))
6386 (or group (error "No group name given"))
6387 (let ((file (concat (file-name-as-directory faq-dir)
6388 (gnus-group-real-name group))))
6389 (if (not (file-exists-p file))
6390 (error "No such file: %s" file)
6393 (defun gnus-group-describe-group (force &optional group)
6394 "Display a description of the current newsgroup."
6395 (interactive (list current-prefix-arg (gnus-group-group-name)))
6396 (and force (setq gnus-description-hashtb nil))
6397 (let ((method (gnus-find-method-for-group group))
6399 (or group (error "No group name given"))
6400 (and (or (and gnus-description-hashtb
6401 ;; We check whether this group's method has been
6402 ;; queried for a description file.
6404 (gnus-group-prefixed-name "" method)
6405 gnus-description-hashtb))
6406 (setq desc (gnus-group-get-description group))
6407 (gnus-read-descriptions-file method))
6409 (or desc (gnus-gethash group gnus-description-hashtb)
6410 "No description available")))))
6412 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6413 (defun gnus-group-describe-all-groups (&optional force)
6414 "Pop up a buffer with descriptions of all newsgroups."
6416 (and force (setq gnus-description-hashtb nil))
6417 (if (not (or gnus-description-hashtb
6418 (gnus-read-all-descriptions-files)))
6419 (error "Couldn't request descriptions file"))
6420 (let ((buffer-read-only nil)
6426 (insert (format " *: %-20s %s\n" (symbol-name group)
6427 (symbol-value group)))
6428 (add-text-properties
6429 b (1+ b) (list 'gnus-group group
6430 'gnus-unread t 'gnus-marked nil
6431 'gnus-level (1+ gnus-level-subscribed))))
6432 gnus-description-hashtb)
6433 (goto-char (point-min))
6434 (gnus-group-position-point)))
6436 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6437 (defun gnus-group-apropos (regexp &optional search-description)
6438 "List all newsgroups that have names that match a regexp."
6439 (interactive "sGnus apropos (regexp): ")
6441 (obuf (current-buffer))
6443 ;; Go through all newsgroups that are known to Gnus.
6446 (and (symbol-name group)
6447 (string-match regexp (symbol-name group))
6448 (setq groups (cons (symbol-name group) groups))))
6450 ;; Also go through all descriptions that are known to Gnus.
6451 (when search-description
6454 (and (string-match regexp (symbol-value group))
6455 (gnus-active (symbol-name group))
6456 (setq groups (cons (symbol-name group) groups))))
6457 gnus-description-hashtb))
6459 (gnus-message 3 "No groups matched \"%s\"." regexp)
6460 ;; Print out all the groups.
6462 (pop-to-buffer "*Gnus Help*")
6463 (buffer-disable-undo (current-buffer))
6465 (setq groups (sort groups 'string<))
6467 ;; Groups may be entered twice into the list of groups.
6468 (if (not (string= (car groups) prev))
6470 (insert (setq prev (car groups)) "\n")
6471 (if (and gnus-description-hashtb
6472 (setq des (gnus-gethash (car groups)
6473 gnus-description-hashtb)))
6474 (insert " " des "\n"))))
6475 (setq groups (cdr groups)))
6476 (goto-char (point-min))))
6477 (pop-to-buffer obuf)))
6479 (defun gnus-group-description-apropos (regexp)
6480 "List all newsgroups that have names or descriptions that match a regexp."
6481 (interactive "sGnus description apropos (regexp): ")
6482 (if (not (or gnus-description-hashtb
6483 (gnus-read-all-descriptions-files)))
6484 (error "Couldn't request descriptions file"))
6485 (gnus-group-apropos regexp t))
6487 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6488 (defun gnus-group-list-matching (level regexp &optional all lowest)
6489 "List all groups with unread articles that match REGEXP.
6490 If the prefix LEVEL is non-nil, it should be a number that says which
6491 level to cut off listing groups.
6492 If ALL, also list groups with no unread articles.
6493 If LOWEST, don't list groups with level lower than LOWEST."
6494 (interactive "P\nsList newsgroups matching: ")
6495 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6496 all (or lowest 1) regexp)
6497 (goto-char (point-min))
6498 (gnus-group-position-point))
6500 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6501 "List all groups that match REGEXP.
6502 If the prefix LEVEL is non-nil, it should be a number that says which
6503 level to cut off listing groups.
6504 If LOWEST, don't list groups with level lower than LOWEST."
6505 (interactive "P\nsList newsgroups matching: ")
6506 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6508 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6509 (defun gnus-group-save-newsrc (&optional force)
6510 "Save the Gnus startup files.
6511 If FORCE, force saving whether it is necessary or not."
6513 (gnus-save-newsrc-file force))
6515 (defun gnus-group-restart (&optional arg)
6516 "Force Gnus to read the .newsrc file."
6518 (when (gnus-yes-or-no-p
6519 (format "Are you sure you want to read %s? "
6520 gnus-current-startup-file))
6521 (gnus-save-newsrc-file)
6522 (gnus-setup-news 'force)
6523 (gnus-group-list-groups arg)))
6525 (defun gnus-group-read-init-file ()
6526 "Read the Gnus elisp init file."
6528 (gnus-read-init-file))
6530 (defun gnus-group-check-bogus-groups (&optional silent)
6531 "Check bogus newsgroups.
6532 If given a prefix, don't ask for confirmation before removing a bogus
6535 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6536 (gnus-group-list-groups))
6538 (defun gnus-group-edit-global-kill (&optional article group)
6539 "Edit the global kill file.
6540 If GROUP, edit that local kill file instead."
6542 (setq gnus-current-kill-article article)
6543 (gnus-kill-file-edit-file group)
6546 (substitute-command-keys
6547 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6548 (if group "local" "global")))))
6550 (defun gnus-group-edit-local-kill (article group)
6551 "Edit a local kill file."
6552 (interactive (list nil (gnus-group-group-name)))
6553 (gnus-group-edit-global-kill article group))
6555 (defun gnus-group-force-update ()
6556 "Update `.newsrc' file."
6558 (gnus-save-newsrc-file))
6560 (defun gnus-group-suspend ()
6561 "Suspend the current Gnus session.
6562 In fact, cleanup buffers except for group mode buffer.
6563 The hook gnus-suspend-gnus-hook is called before actually suspending."
6565 (run-hooks 'gnus-suspend-gnus-hook)
6566 ;; Kill Gnus buffers except for group mode buffer.
6567 (let ((group-buf (get-buffer gnus-group-buffer)))
6568 ;; Do this on a separate list in case the user does a ^G before we finish
6569 (let ((gnus-buffer-list
6570 (delq group-buf (delq gnus-dribble-buffer
6571 (append gnus-buffer-list nil)))))
6572 (while gnus-buffer-list
6573 (gnus-kill-buffer (car gnus-buffer-list))
6574 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6577 (setq gnus-buffer-list (list group-buf))
6578 (bury-buffer group-buf)
6579 (delete-windows-on group-buf t)))))
6581 (defun gnus-group-clear-dribble ()
6582 "Clear all information from the dribble buffer."
6584 (gnus-dribble-clear)
6585 (gnus-message 7 "Cleared dribble buffer"))
6587 (defun gnus-group-exit ()
6588 "Quit reading news after updating .newsrc.eld and .newsrc.
6589 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6592 (or noninteractive ;For gnus-batch-kill
6593 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6594 (not gnus-interactive-exit) ;Without confirmation
6596 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6597 (run-hooks 'gnus-exit-gnus-hook)
6598 ;; Offer to save data from non-quitted summary buffers.
6599 (gnus-offer-save-summaries)
6600 ;; Save the newsrc file(s).
6601 (gnus-save-newsrc-file)
6603 (gnus-close-backends)
6604 ;; Reset everything.
6606 ;; Allow the user to do things after cleaning up.
6607 (run-hooks 'gnus-after-exiting-gnus-hook)))
6609 (defun gnus-close-backends ()
6610 ;; Send a close request to all backends that support such a request.
6611 (let ((methods gnus-valid-select-methods)
6614 (if (fboundp (setq func (intern (concat (caar methods)
6615 "-request-close"))))
6617 (setq methods (cdr methods)))))
6619 (defun gnus-group-quit ()
6620 "Quit reading news without updating .newsrc.eld or .newsrc.
6621 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6623 (when (or noninteractive ;For gnus-batch-kill
6624 (zerop (buffer-size))
6625 (not (gnus-server-opened gnus-select-method))
6627 (not gnus-current-startup-file)
6629 (format "Quit reading news without saving %s? "
6630 (file-name-nondirectory gnus-current-startup-file))))
6631 (run-hooks 'gnus-exit-gnus-hook)
6632 (if gnus-use-full-window
6633 (delete-other-windows)
6634 (gnus-remove-some-windows))
6636 (gnus-close-backends)
6638 ;; Allow the user to do things after cleaning up.
6639 (run-hooks 'gnus-after-exiting-gnus-hook)))
6641 (defun gnus-offer-save-summaries ()
6642 "Offer to save all active summary buffers."
6644 (let ((buflist (buffer-list))
6646 ;; Go through all buffers and find all summaries.
6648 (and (setq bufname (buffer-name (car buflist)))
6649 (string-match "Summary" bufname)
6651 (set-buffer bufname)
6652 ;; We check that this is, indeed, a summary buffer.
6653 (and (eq major-mode 'gnus-summary-mode)
6654 ;; Also make sure this isn't bogus.
6655 gnus-newsgroup-prepared))
6656 (push bufname buffers))
6657 (setq buflist (cdr buflist)))
6658 ;; Go through all these summary buffers and offer to save them.
6661 "Update summary buffer %s? "
6662 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6665 (defun gnus-group-describe-briefly ()
6666 "Give a one line description of the group mode commands."
6668 (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")))
6670 (defun gnus-group-browse-foreign-server (method)
6671 "Browse a foreign news server.
6672 If called interactively, this function will ask for a select method
6673 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6674 If not, METHOD should be a list where the first element is the method
6675 and the second element is the address."
6677 (list (let ((how (completing-read
6679 (append gnus-valid-select-methods gnus-server-alist)
6680 nil t (cons "nntp" 0))))
6681 ;; We either got a backend name or a virtual server name.
6682 ;; If the first, we also need an address.
6683 (if (assoc how gnus-valid-select-methods)
6685 ;; Suggested by mapjph@bath.ac.uk.
6688 (mapcar (lambda (server) (list server))
6689 gnus-secondary-servers)))
6690 ;; We got a server name, so we find the method.
6691 (gnus-server-to-method how)))))
6692 (gnus-browse-foreign-server method))
6696 ;;; Gnus summary mode
6699 (defvar gnus-summary-mode-map nil)
6701 (put 'gnus-summary-mode 'mode-class 'special)
6703 (unless gnus-summary-mode-map
6704 (setq gnus-summary-mode-map (make-keymap))
6705 (suppress-keymap gnus-summary-mode-map)
6707 ;; Non-orthogonal keys
6709 (gnus-define-keys gnus-summary-mode-map
6710 " " gnus-summary-next-page
6711 "\177" gnus-summary-prev-page
6712 [delete] gnus-summary-prev-page
6713 "\r" gnus-summary-scroll-up
6714 "n" gnus-summary-next-unread-article
6715 "p" gnus-summary-prev-unread-article
6716 "N" gnus-summary-next-article
6717 "P" gnus-summary-prev-article
6718 "\M-\C-n" gnus-summary-next-same-subject
6719 "\M-\C-p" gnus-summary-prev-same-subject
6720 "\M-n" gnus-summary-next-unread-subject
6721 "\M-p" gnus-summary-prev-unread-subject
6722 "." gnus-summary-first-unread-article
6723 "," gnus-summary-best-unread-article
6724 "\M-s" gnus-summary-search-article-forward
6725 "\M-r" gnus-summary-search-article-backward
6726 "<" gnus-summary-beginning-of-article
6727 ">" gnus-summary-end-of-article
6728 "j" gnus-summary-goto-article
6729 "^" gnus-summary-refer-parent-article
6730 "\M-^" gnus-summary-refer-article
6731 "u" gnus-summary-tick-article-forward
6732 "!" gnus-summary-tick-article-forward
6733 "U" gnus-summary-tick-article-backward
6734 "d" gnus-summary-mark-as-read-forward
6735 "D" gnus-summary-mark-as-read-backward
6736 "E" gnus-summary-mark-as-expirable
6737 "\M-u" gnus-summary-clear-mark-forward
6738 "\M-U" gnus-summary-clear-mark-backward
6739 "k" gnus-summary-kill-same-subject-and-select
6740 "\C-k" gnus-summary-kill-same-subject
6741 "\M-\C-k" gnus-summary-kill-thread
6742 "\M-\C-l" gnus-summary-lower-thread
6743 "e" gnus-summary-edit-article
6744 "#" gnus-summary-mark-as-processable
6745 "\M-#" gnus-summary-unmark-as-processable
6746 "\M-\C-t" gnus-summary-toggle-threads
6747 "\M-\C-s" gnus-summary-show-thread
6748 "\M-\C-h" gnus-summary-hide-thread
6749 "\M-\C-f" gnus-summary-next-thread
6750 "\M-\C-b" gnus-summary-prev-thread
6751 "\M-\C-u" gnus-summary-up-thread
6752 "\M-\C-d" gnus-summary-down-thread
6753 "&" gnus-summary-execute-command
6754 "c" gnus-summary-catchup-and-exit
6755 "\C-w" gnus-summary-mark-region-as-read
6756 "\C-t" gnus-summary-toggle-truncation
6757 "?" gnus-summary-mark-as-dormant
6758 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6759 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6760 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6761 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6762 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6763 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6764 "=" gnus-summary-expand-window
6765 "\C-x\C-s" gnus-summary-reselect-current-group
6766 "\M-g" gnus-summary-rescan-group
6767 "w" gnus-summary-stop-page-breaking
6768 "\C-c\C-r" gnus-summary-caesar-message
6769 "\M-t" gnus-summary-toggle-mime
6770 "f" gnus-summary-followup
6771 "F" gnus-summary-followup-with-original
6772 "C" gnus-summary-cancel-article
6773 "r" gnus-summary-reply
6774 "R" gnus-summary-reply-with-original
6775 "\C-c\C-f" gnus-summary-mail-forward
6776 "o" gnus-summary-save-article
6777 "\C-o" gnus-summary-save-article-mail
6778 "|" gnus-summary-pipe-output
6779 "\M-k" gnus-summary-edit-local-kill
6780 "\M-K" gnus-summary-edit-global-kill
6782 "\C-c\C-d" gnus-summary-describe-group
6783 "q" gnus-summary-exit
6784 "Q" gnus-summary-exit-no-update
6785 "\C-c\C-i" gnus-info-find-node
6786 gnus-mouse-2 gnus-mouse-pick-article
6787 "m" gnus-summary-mail-other-window
6788 "a" gnus-summary-post-news
6789 "x" gnus-summary-limit-to-unread
6790 "s" gnus-summary-isearch-article
6791 "t" gnus-article-hide-headers
6792 "g" gnus-summary-show-article
6793 "l" gnus-summary-goto-last-article
6794 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6795 "\C-d" gnus-summary-enter-digest-group
6797 "*" gnus-cache-enter-article
6798 "\M-*" gnus-cache-remove-article
6799 "\M-&" gnus-summary-universal-argument
6800 "\C-l" gnus-recenter
6801 "I" gnus-summary-increase-score
6802 "L" gnus-summary-lower-score
6804 "V" gnus-summary-score-map
6805 "X" gnus-uu-extract-map
6806 "S" gnus-summary-send-map)
6808 ;; Sort of orthogonal keymap
6809 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6810 "t" gnus-summary-tick-article-forward
6811 "!" gnus-summary-tick-article-forward
6812 "d" gnus-summary-mark-as-read-forward
6813 "r" gnus-summary-mark-as-read-forward
6814 "c" gnus-summary-clear-mark-forward
6815 " " gnus-summary-clear-mark-forward
6816 "e" gnus-summary-mark-as-expirable
6817 "x" gnus-summary-mark-as-expirable
6818 "?" gnus-summary-mark-as-dormant
6819 "b" gnus-summary-set-bookmark
6820 "B" gnus-summary-remove-bookmark
6821 "#" gnus-summary-mark-as-processable
6822 "\M-#" gnus-summary-unmark-as-processable
6823 "S" gnus-summary-limit-include-expunged
6824 "C" gnus-summary-catchup
6825 "H" gnus-summary-catchup-to-here
6826 "\C-c" gnus-summary-catchup-all
6827 "k" gnus-summary-kill-same-subject-and-select
6828 "K" gnus-summary-kill-same-subject
6829 "P" gnus-uu-mark-map)
6831 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6832 "c" gnus-summary-clear-above
6833 "u" gnus-summary-tick-above
6834 "m" gnus-summary-mark-above
6835 "k" gnus-summary-kill-below)
6837 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6838 "/" gnus-summary-limit-to-subject
6839 "n" gnus-summary-limit-to-articles
6840 "w" gnus-summary-pop-limit
6841 "s" gnus-summary-limit-to-subject
6842 "a" gnus-summary-limit-to-author
6843 "u" gnus-summary-limit-to-unread
6844 "m" gnus-summary-limit-to-marks
6845 "v" gnus-summary-limit-to-score
6846 "D" gnus-summary-limit-include-dormant
6847 "d" gnus-summary-limit-exclude-dormant
6848 ;; "t" gnus-summary-limit-exclude-thread
6849 "E" gnus-summary-limit-include-expunged
6850 "c" gnus-summary-limit-exclude-childless-dormant
6851 "C" gnus-summary-limit-mark-excluded-as-read)
6853 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6854 "n" gnus-summary-next-unread-article
6855 "p" gnus-summary-prev-unread-article
6856 "N" gnus-summary-next-article
6857 "P" gnus-summary-prev-article
6858 "\C-n" gnus-summary-next-same-subject
6859 "\C-p" gnus-summary-prev-same-subject
6860 "\M-n" gnus-summary-next-unread-subject
6861 "\M-p" gnus-summary-prev-unread-subject
6862 "f" gnus-summary-first-unread-article
6863 "b" gnus-summary-best-unread-article
6864 "j" gnus-summary-goto-article
6865 "g" gnus-summary-goto-subject
6866 "l" gnus-summary-goto-last-article
6867 "p" gnus-summary-pop-article)
6869 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6870 "k" gnus-summary-kill-thread
6871 "l" gnus-summary-lower-thread
6872 "i" gnus-summary-raise-thread
6873 "T" gnus-summary-toggle-threads
6874 "t" gnus-summary-rethread-current
6875 "^" gnus-summary-reparent-thread
6876 "s" gnus-summary-show-thread
6877 "S" gnus-summary-show-all-threads
6878 "h" gnus-summary-hide-thread
6879 "H" gnus-summary-hide-all-threads
6880 "n" gnus-summary-next-thread
6881 "p" gnus-summary-prev-thread
6882 "u" gnus-summary-up-thread
6883 "o" gnus-summary-top-thread
6884 "d" gnus-summary-down-thread
6885 "#" gnus-uu-mark-thread
6886 "\M-#" gnus-uu-unmark-thread)
6888 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6889 "c" gnus-summary-catchup-and-exit
6890 "C" gnus-summary-catchup-all-and-exit
6891 "E" gnus-summary-exit-no-update
6892 "Q" gnus-summary-exit
6893 "Z" gnus-summary-exit
6894 "n" gnus-summary-catchup-and-goto-next-group
6895 "R" gnus-summary-reselect-current-group
6896 "G" gnus-summary-rescan-group
6897 "N" gnus-summary-next-group
6898 "P" gnus-summary-prev-group)
6900 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6901 " " gnus-summary-next-page
6902 "n" gnus-summary-next-page
6903 "\177" gnus-summary-prev-page
6904 [delete] gnus-summary-prev-page
6905 "p" gnus-summary-prev-page
6906 "\r" gnus-summary-scroll-up
6907 "<" gnus-summary-beginning-of-article
6908 ">" gnus-summary-end-of-article
6909 "b" gnus-summary-beginning-of-article
6910 "e" gnus-summary-end-of-article
6911 "^" gnus-summary-refer-parent-article
6912 "r" gnus-summary-refer-parent-article
6913 "R" gnus-summary-refer-references
6914 "g" gnus-summary-show-article
6915 "s" gnus-summary-isearch-article)
6917 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6918 "b" gnus-article-add-buttons
6919 "B" gnus-article-add-buttons-to-head
6920 "o" gnus-article-treat-overstrike
6921 ;; "w" gnus-article-word-wrap
6922 "w" gnus-article-fill-cited-article
6923 "c" gnus-article-remove-cr
6924 "L" gnus-article-remove-trailing-blank-lines
6925 "q" gnus-article-de-quoted-unreadable
6926 "f" gnus-article-display-x-face
6927 "l" gnus-summary-stop-page-breaking
6928 "r" gnus-summary-caesar-message
6929 "t" gnus-article-hide-headers
6930 "v" gnus-summary-verbose-headers
6931 "m" gnus-summary-toggle-mime)
6933 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6934 "a" gnus-article-hide
6935 "h" gnus-article-hide-headers
6936 "b" gnus-article-hide-boring-headers
6937 "s" gnus-article-hide-signature
6938 "c" gnus-article-hide-citation
6939 "p" gnus-article-hide-pgp
6940 "\C-c" gnus-article-hide-citation-maybe)
6942 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6943 "a" gnus-article-highlight
6944 "h" gnus-article-highlight-headers
6945 "c" gnus-article-highlight-citation
6946 "s" gnus-article-highlight-signature)
6948 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6949 "z" gnus-article-date-ut
6950 "u" gnus-article-date-ut
6951 "l" gnus-article-date-local
6952 "e" gnus-article-date-lapsed
6953 "o" gnus-article-date-original)
6955 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6957 "f" gnus-summary-fetch-faq
6958 "d" gnus-summary-describe-group
6959 "h" gnus-summary-describe-briefly
6960 "i" gnus-info-find-node)
6962 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6963 "e" gnus-summary-expire-articles
6964 "\M-\C-e" gnus-summary-expire-articles-now
6965 "\177" gnus-summary-delete-article
6966 [delete] gnus-summary-delete-article
6967 "m" gnus-summary-move-article
6968 "r" gnus-summary-respool-article
6969 "w" gnus-summary-edit-article
6970 "c" gnus-summary-copy-article
6971 "B" gnus-summary-crosspost-article
6972 "q" gnus-summary-respool-query
6973 "i" gnus-summary-import-article)
6975 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6976 "o" gnus-summary-save-article
6977 "m" gnus-summary-save-article-mail
6978 "r" gnus-summary-save-article-rmail
6979 "f" gnus-summary-save-article-file
6980 "b" gnus-summary-save-article-body-file
6981 "h" gnus-summary-save-article-folder
6982 "v" gnus-summary-save-article-vm
6983 "p" gnus-summary-pipe-output
6984 "s" gnus-soup-add-article)
6989 (defun gnus-summary-mode (&optional group)
6990 "Major mode for reading articles.
6992 All normal editing commands are switched off.
6993 \\<gnus-summary-mode-map>
6994 Each line in this buffer represents one article. To read an
6995 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6996 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6999 You can also post articles and send mail from this buffer. To
7000 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7001 of an article, type `\\[gnus-summary-reply]'.
7003 There are approx. one gazillion commands you can execute in this
7004 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7006 The following commands are available:
7008 \\{gnus-summary-mode-map}"
7010 (when (and menu-bar-mode
7011 (gnus-visual-p 'summary-menu 'menu))
7012 (gnus-summary-make-menu-bar))
7013 (kill-all-local-variables)
7014 (let ((locals gnus-summary-local-variables))
7016 (if (consp (car locals))
7018 (make-local-variable (caar locals))
7019 (set (caar locals) (eval (cdar locals))))
7020 (make-local-variable (car locals))
7021 (set (car locals) nil))
7022 (setq locals (cdr locals))))
7023 (gnus-make-thread-indent-array)
7024 (gnus-simplify-mode-line)
7025 (setq major-mode 'gnus-summary-mode)
7026 (setq mode-name "Summary")
7027 (make-local-variable 'minor-mode-alist)
7028 (use-local-map gnus-summary-mode-map)
7029 (buffer-disable-undo (current-buffer))
7030 (setq buffer-read-only t) ;Disable modification
7031 (setq truncate-lines t)
7032 (setq selective-display t)
7033 (setq selective-display-ellipses t) ;Display `...'
7034 (setq buffer-display-table gnus-summary-display-table)
7035 (setq gnus-newsgroup-name group)
7036 (run-hooks 'gnus-summary-mode-hook))
7038 (defun gnus-summary-make-display-table ()
7039 ;; Change the display table. Odd characters have a tendency to mess
7040 ;; up nicely formatted displays - we make all possible glyphs
7041 ;; display only a single character.
7043 ;; We start from the standard display table, if any.
7044 (setq gnus-summary-display-table
7045 (or (copy-sequence standard-display-table)
7046 (make-display-table)))
7047 ;; Nix out all the control chars...
7049 (while (>= (setq i (1- i)) 0)
7050 (aset gnus-summary-display-table i [??])))
7051 ;; ... but not newline and cr, of course. (cr is necessary for the
7052 ;; selective display).
7053 (aset gnus-summary-display-table ?\n nil)
7054 (aset gnus-summary-display-table ?\r nil)
7055 ;; We nix out any glyphs over 126 that are not set already.
7057 (while (>= (setq i (1- i)) 127)
7058 ;; Only modify if the entry is nil.
7059 (or (aref gnus-summary-display-table i)
7060 (aset gnus-summary-display-table i [??])))))
7062 (defun gnus-summary-clear-local-variables ()
7063 (let ((locals gnus-summary-local-variables))
7065 (if (consp (car locals))
7066 (and (vectorp (caar locals))
7067 (set (caar locals) nil))
7068 (and (vectorp (car locals))
7069 (set (car locals) nil)))
7070 (setq locals (cdr locals)))))
7072 ;; Summary data functions.
7074 (defmacro gnus-data-number (data)
7077 (defmacro gnus-data-set-number (data number)
7078 `(setcar ,data ,number))
7080 (defmacro gnus-data-mark (data)
7083 (defmacro gnus-data-set-mark (data mark)
7084 `(setcar (nthcdr 1 ,data) ,mark))
7086 (defmacro gnus-data-pos (data)
7089 (defmacro gnus-data-set-pos (data pos)
7090 `(setcar (nthcdr 2 ,data) ,pos))
7092 (defmacro gnus-data-header (data)
7095 (defmacro gnus-data-level (data)
7098 (defmacro gnus-data-unread-p (data)
7099 `(= (nth 1 ,data) gnus-unread-mark))
7101 (defmacro gnus-data-pseudo-p (data)
7102 `(consp (nth 3 ,data)))
7104 (defmacro gnus-data-find (number)
7105 `(assq ,number gnus-newsgroup-data))
7107 (defmacro gnus-data-find-list (number &optional data)
7108 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7109 (memq (assq ,number bdata)
7112 (defmacro gnus-data-make (number mark pos header level)
7113 `(list ,number ,mark ,pos ,header ,level))
7115 (defun gnus-data-enter (after-article number mark pos header level offset)
7116 (let ((data (gnus-data-find-list after-article)))
7117 (or data (error "No such article: %d" after-article))
7118 (setcdr data (cons (gnus-data-make number mark pos header level)
7120 (setq gnus-newsgroup-data-reverse nil)
7121 (gnus-data-update-list (cddr data) offset)))
7123 (defun gnus-data-enter-list (after-article list &optional offset)
7125 (let ((data (and after-article (gnus-data-find-list after-article)))
7127 (or data (not after-article) (error "No such article: %d" after-article))
7128 ;; Find the last element in the list to be spliced into the main
7131 (setq list (cdr list)))
7134 (setcdr list gnus-newsgroup-data)
7135 (setq gnus-newsgroup-data ilist)
7136 (and offset (gnus-data-update-list (cdr list) offset)))
7137 (setcdr list (cdr data))
7139 (and offset (gnus-data-update-list (cdr data) offset)))
7140 (setq gnus-newsgroup-data-reverse nil))))
7142 (defun gnus-data-remove (article &optional offset)
7143 (let ((data gnus-newsgroup-data))
7144 (if (= (gnus-data-number (car data)) article)
7145 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7146 gnus-newsgroup-data-reverse nil)
7148 (and (= (gnus-data-number (cadr data)) article)
7150 (setcdr data (cddr data))
7151 (and offset (gnus-data-update-list (cdr data) offset))
7153 gnus-newsgroup-data-reverse nil)))
7154 (setq data (cdr data))))))
7156 (defmacro gnus-data-list (backward)
7158 (or gnus-newsgroup-data-reverse
7159 (setq gnus-newsgroup-data-reverse
7160 (reverse gnus-newsgroup-data)))
7161 gnus-newsgroup-data))
7163 (defun gnus-data-update-list (data offset)
7164 "Add OFFSET to the POS of all data entries in DATA."
7166 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7167 (setq data (cdr data))))
7169 (defun gnus-data-compute-positions ()
7170 "Compute the positions of all articles."
7171 (let ((data gnus-newsgroup-data)
7174 (when (setq pos (text-property-any
7175 (point-min) (point-max)
7176 'gnus-number (gnus-data-number (car data))))
7177 (gnus-data-set-pos (car data) (+ pos 3)))
7178 (setq data (cdr data)))))
7180 (defun gnus-summary-article-pseudo-p (article)
7181 "Say whether this article is a pseudo article or not."
7182 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7184 (defun gnus-article-parent-p (number)
7185 "Say whether this article is a parent or not."
7186 (let ((data (gnus-data-find-list number)))
7187 (and (cdr data) ; There has to be an article after...
7188 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7189 (gnus-data-level (nth 1 data))))))
7191 (defun gnus-article-children (number)
7192 "Return a list of all children to NUMBER."
7193 (let* ((data (gnus-data-find-list number))
7194 (level (gnus-data-level (car data)))
7196 (setq data (cdr data))
7198 (= (gnus-data-level (car data)) (1+ level)))
7199 (push (gnus-data-number (car data)) children)
7200 (setq data (cdr data)))
7203 (defmacro gnus-summary-skip-intangible ()
7204 "If the current article is intangible, then jump to a different article."
7205 '(let ((to (get-text-property (point) 'gnus-intangible)))
7206 (and to (gnus-summary-goto-subject to))))
7208 (defmacro gnus-summary-article-intangible-p ()
7209 "Say whether this article is intangible or not."
7210 '(get-text-property (point) 'gnus-intangible))
7212 ;; Some summary mode macros.
7214 (defmacro gnus-summary-article-number ()
7215 "The article number of the article on the current line.
7216 If there isn's an article number here, then we return the current
7219 (gnus-summary-skip-intangible)
7220 (or (get-text-property (point) 'gnus-number)
7221 (gnus-summary-last-subject))))
7223 (defmacro gnus-summary-article-header (&optional number)
7224 `(gnus-data-header (gnus-data-find
7225 ,(or number '(gnus-summary-article-number)))))
7227 (defmacro gnus-summary-thread-level (&optional number)
7228 `(if (and (eq gnus-summary-make-false-root 'dummy)
7229 (get-text-property (point) 'gnus-intangible))
7231 (gnus-data-level (gnus-data-find
7232 ,(or number '(gnus-summary-article-number))))))
7234 (defmacro gnus-summary-article-mark (&optional number)
7235 `(gnus-data-mark (gnus-data-find
7236 ,(or number '(gnus-summary-article-number)))))
7238 (defmacro gnus-summary-article-pos (&optional number)
7239 `(gnus-data-pos (gnus-data-find
7240 ,(or number '(gnus-summary-article-number)))))
7242 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7243 (defmacro gnus-summary-article-subject (&optional number)
7244 "Return current subject string or nil if nothing."
7247 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7248 '(gnus-data-header (assq (gnus-summary-article-number)
7249 gnus-newsgroup-data)))))
7252 (mail-header-subject headers))))
7254 (defmacro gnus-summary-article-score (&optional number)
7255 "Return current article score."
7256 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7257 gnus-newsgroup-scored))
7258 gnus-summary-default-score 0))
7260 (defun gnus-summary-article-children (&optional number)
7261 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7262 (level (gnus-data-level (car data)))
7264 (while (and (setq data (cdr data))
7265 (> (setq l (gnus-data-level (car data))) level))
7266 (and (= (1+ level) l)
7267 (setq children (cons (gnus-data-number (car data))
7269 (nreverse children)))
7271 (defun gnus-summary-article-parent (&optional number)
7272 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7273 (gnus-data-list t)))
7274 (level (gnus-data-level (car data))))
7276 () ; This is a root.
7277 ;; We search until we find an article with a level less than
7278 ;; this one. That function has to be the parent.
7279 (while (and (setq data (cdr data))
7280 (not (< (gnus-data-level (car data)) level))))
7281 (and data (gnus-data-number (car data))))))
7283 (defun gnus-unread-mark-p (mark)
7284 "Say whether MARK is the unread mark."
7285 (= mark gnus-unread-mark))
7287 (defun gnus-read-mark-p (mark)
7288 "Say whether MARK is one of the marks that mark as read.
7289 This is all marks except unread, ticked, dormant, and expirable."
7290 (not (or (= mark gnus-unread-mark)
7291 (= mark gnus-ticked-mark)
7292 (= mark gnus-dormant-mark)
7293 (= mark gnus-expirable-mark))))
7295 ;; Various summary mode internalish functions.
7297 (defun gnus-mouse-pick-article (e)
7300 (gnus-summary-next-page nil t))
7302 (defun gnus-summary-setup-buffer (group)
7303 "Initialize summary buffer."
7304 (let ((buffer (concat "*Summary " group "*")))
7305 (if (get-buffer buffer)
7308 (setq gnus-summary-buffer (current-buffer))
7309 (not gnus-newsgroup-prepared))
7310 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7311 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7312 (gnus-add-current-to-buffer-list)
7313 (gnus-summary-mode group)
7315 (gnus-carpal-setup-buffer 'summary))
7316 (unless gnus-single-article-buffer
7317 (make-local-variable 'gnus-article-buffer)
7318 (make-local-variable 'gnus-article-current)
7319 (make-local-variable 'gnus-original-article-buffer))
7320 (setq gnus-newsgroup-name group)
7323 (defun gnus-set-global-variables ()
7324 ;; Set the global equivalents of the summary buffer-local variables
7325 ;; to the latest values they had. These reflect the summary buffer
7326 ;; that was in action when the last article was fetched.
7327 (when (eq major-mode 'gnus-summary-mode)
7328 (setq gnus-summary-buffer (current-buffer))
7329 (let ((name gnus-newsgroup-name)
7330 (marked gnus-newsgroup-marked)
7331 (unread gnus-newsgroup-unreads)
7332 (headers gnus-current-headers)
7333 (data gnus-newsgroup-data)
7334 (summary gnus-summary-buffer)
7335 (article-buffer gnus-article-buffer)
7336 (original gnus-original-article-buffer)
7337 (gac gnus-article-current)
7338 (score-file gnus-current-score-file))
7340 (set-buffer gnus-group-buffer)
7341 (setq gnus-newsgroup-name name)
7342 (setq gnus-newsgroup-marked marked)
7343 (setq gnus-newsgroup-unreads unread)
7344 (setq gnus-current-headers headers)
7345 (setq gnus-newsgroup-data data)
7346 (setq gnus-article-current gac)
7347 (setq gnus-summary-buffer summary)
7348 (setq gnus-article-buffer article-buffer)
7349 (setq gnus-original-article-buffer original)
7350 (setq gnus-current-score-file score-file)))))
7352 (defun gnus-summary-last-article-p (&optional article)
7353 "Return whether ARTICLE is the last article in the buffer."
7354 (if (not (setq article (or article (gnus-summary-article-number))))
7355 t ; All non-existant numbers are the last article. :-)
7356 (not (cdr (gnus-data-find-list article)))))
7358 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7359 "Insert a dummy root in the summary buffer."
7361 (add-text-properties
7362 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7363 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7365 (defvar gnus-thread-indent-array nil)
7366 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7367 (defun gnus-make-thread-indent-array ()
7369 (unless (and gnus-thread-indent-array
7370 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7371 (setq gnus-thread-indent-array (make-vector 201 "")
7372 gnus-thread-indent-array-level gnus-thread-indent-level)
7374 (aset gnus-thread-indent-array n
7375 (make-string (* n gnus-thread-indent-level) ? ))
7378 (defun gnus-summary-insert-line
7379 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7380 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7381 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7382 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7383 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7384 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7385 (gnus-tmp-score-char
7386 (if (or (null gnus-summary-default-score)
7387 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7388 gnus-summary-zcore-fuzz)) ?
7389 (if (< gnus-tmp-score gnus-summary-default-score)
7390 gnus-score-below-mark gnus-score-over-mark)))
7391 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7392 ((memq gnus-tmp-current gnus-newsgroup-cached)
7394 (gnus-tmp-replied gnus-replied-mark)
7395 ((memq gnus-tmp-current gnus-newsgroup-saved)
7397 (t gnus-unread-mark)))
7398 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7401 ((string-match "(.+)" gnus-tmp-from)
7402 (substring gnus-tmp-from
7403 (1+ (match-beginning 0)) (1- (match-end 0))))
7404 ((string-match "<[^>]+> *$" gnus-tmp-from)
7405 (let ((beg (match-beginning 0)))
7406 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7407 (substring gnus-tmp-from (1+ (match-beginning 0))
7408 (1- (match-end 0))))
7409 (substring gnus-tmp-from 0 beg))))
7411 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7412 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7413 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7414 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7415 (buffer-read-only nil))
7416 (when (string= gnus-tmp-name "")
7417 (setq gnus-tmp-name gnus-tmp-from))
7418 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7421 (progn (eval gnus-summary-line-format-spec) (point))
7422 'gnus-number gnus-tmp-number)
7423 (when (gnus-visual-p 'summary-highlight 'highlight)
7425 (run-hooks 'gnus-summary-update-hook)
7428 (defun gnus-summary-update-line (&optional dont-update)
7429 ;; Update summary line after change.
7430 (when (and gnus-summary-default-score
7431 (not gnus-summary-inhibit-highlight))
7432 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7433 (article (gnus-summary-article-number))
7434 (score (gnus-summary-article-score article)))
7436 (if (and gnus-summary-mark-below
7437 (< (gnus-summary-article-score)
7438 gnus-summary-mark-below))
7439 ;; This article has a low score, so we mark it as read.
7440 (when (memq article gnus-newsgroup-unreads)
7441 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7442 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7443 ;; This article was previously marked as read on account
7444 ;; of a low score, but now it has risen, so we mark it as
7446 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7447 (gnus-summary-update-mark
7448 (if (or (null gnus-summary-default-score)
7449 (<= (abs (- score gnus-summary-default-score))
7450 gnus-summary-zcore-fuzz)) ?
7451 (if (< score gnus-summary-default-score)
7452 gnus-score-below-mark gnus-score-over-mark)) 'score))
7453 ;; Do visual highlighting.
7454 (when (gnus-visual-p 'summary-highlight 'highlight)
7455 (run-hooks 'gnus-summary-update-hook)))))
7457 (defvar gnus-tmp-new-adopts nil)
7459 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7460 ;; Sum up all elements (and sub-elements) in a list.
7462 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7464 ((and (consp thread) (cdr thread))
7467 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7470 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7473 (when (and level (zerop level) gnus-tmp-new-adopts)
7476 'gnus-summary-number-of-articles-in-thread
7477 gnus-tmp-new-adopts))))
7479 (if (> number 1) gnus-not-empty-thread-mark
7480 gnus-empty-thread-mark)
7483 (defun gnus-summary-set-local-parameters (group)
7484 "Go through the local params of GROUP and set all variable specs in that list."
7485 (let ((params (gnus-info-params (gnus-get-info group)))
7488 (setq elem (car params)
7489 params (cdr params))
7490 (and (consp elem) ; Has to be a cons.
7491 (consp (cdr elem)) ; The cdr has to be a list.
7492 (symbolp (car elem)) ; Has to be a symbol in there.
7493 (not (memq (car elem)
7494 '(quit-config to-address to-list to-group)))
7495 (progn ; So we set it.
7496 (make-local-variable (car elem))
7497 (set (car elem) (eval (nth 1 elem))))))))
7499 (defun gnus-summary-read-group (group &optional show-all no-article
7500 kill-buffer no-display)
7501 "Start reading news in newsgroup GROUP.
7502 If SHOW-ALL is non-nil, already read articles are also listed.
7503 If NO-ARTICLE is non-nil, no article is selected initially.
7504 If NO-DISPLAY, don't generate a summary buffer."
7505 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7506 (let* ((new-group (gnus-summary-setup-buffer group))
7507 (quit-config (gnus-group-quit-config group))
7508 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7510 ;; This summary buffer exists already, so we just select it.
7512 (gnus-set-global-variables)
7514 (gnus-kill-or-deaden-summary kill-buffer))
7515 (gnus-configure-windows 'summary 'force)
7516 (gnus-set-mode-line 'summary)
7517 (gnus-summary-position-point)
7520 ;; We couldn't select this group.
7522 (when (and (eq major-mode 'gnus-summary-mode)
7523 (not (equal (current-buffer) kill-buffer)))
7524 (kill-buffer (current-buffer))
7525 (if (not quit-config)
7527 (set-buffer gnus-group-buffer)
7528 (gnus-group-jump-to-group group)
7529 (gnus-group-next-unread-group 1))
7530 (if (not (buffer-name (car quit-config)))
7531 (gnus-configure-windows 'group 'force)
7532 (set-buffer (car quit-config))
7533 (and (eq major-mode 'gnus-summary-mode)
7534 (gnus-set-global-variables))
7535 (gnus-configure-windows (cdr quit-config)))))
7536 (gnus-message 3 "Can't select group")
7538 ;; The user did a `C-g' while prompting for number of articles,
7539 ;; so we exit this group.
7540 ((eq did-select 'quit)
7541 (and (eq major-mode 'gnus-summary-mode)
7542 (not (equal (current-buffer) kill-buffer))
7543 (kill-buffer (current-buffer)))
7545 (gnus-kill-or-deaden-summary kill-buffer))
7546 (if (not quit-config)
7548 (set-buffer gnus-group-buffer)
7549 (gnus-group-jump-to-group group)
7550 (gnus-group-next-unread-group 1)
7551 (gnus-configure-windows 'group 'force))
7552 (if (not (buffer-name (car quit-config)))
7553 (gnus-configure-windows 'group 'force)
7554 (set-buffer (car quit-config))
7555 (and (eq major-mode 'gnus-summary-mode)
7556 (gnus-set-global-variables))
7557 (gnus-configure-windows (cdr quit-config))))
7558 ;; Finally signal the quit.
7560 ;; The group was successfully selected.
7562 (gnus-set-global-variables)
7563 ;; Save the active value in effect when the group was entered.
7564 (setq gnus-newsgroup-active
7566 (gnus-active gnus-newsgroup-name)))
7567 ;; You can change the summary buffer in some way with this hook.
7568 (run-hooks 'gnus-select-group-hook)
7569 ;; Set any local variables in the group parameters.
7570 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7571 (gnus-update-format-specifications)
7572 ;; Do score processing.
7573 (when gnus-use-scoring
7574 (gnus-possibly-score-headers))
7575 ;; Check whether to fill in the gaps in the threads.
7576 (when gnus-build-sparse-threads
7577 (gnus-build-sparse-threads))
7578 ;; Find the initial limit.
7580 (let ((gnus-newsgroup-dormant nil))
7581 (gnus-summary-initial-limit show-all))
7582 (gnus-summary-initial-limit show-all))
7583 ;; Generate the summary buffer.
7585 (gnus-summary-prepare))
7586 (when gnus-use-trees
7587 (gnus-tree-open group)
7588 (setq gnus-summary-highlight-line-function
7589 'gnus-tree-highlight-article))
7590 ;; If the summary buffer is empty, but there are some low-scored
7591 ;; articles or some excluded dormants, we include these in the
7593 (when (and (zerop (buffer-size))
7595 (cond (gnus-newsgroup-dormant
7596 (gnus-summary-limit-include-dormant))
7597 ((and gnus-newsgroup-scored show-all)
7598 (gnus-summary-limit-include-expunged))))
7599 ;; Function `gnus-apply-kill-file' must be called in this hook.
7600 (run-hooks 'gnus-apply-kill-hook)
7601 (if (and (zerop (buffer-size))
7604 ;; This newsgroup is empty.
7605 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7606 (gnus-message 6 "No unread news")
7608 (gnus-kill-or-deaden-summary kill-buffer))
7609 ;; Return nil from this function.
7611 ;; Hide conversation thread subtrees. We cannot do this in
7612 ;; gnus-summary-prepare-hook since kill processing may not
7613 ;; work with hidden articles.
7614 (and gnus-show-threads
7615 gnus-thread-hide-subtree
7616 (gnus-summary-hide-all-threads))
7617 ;; Show first unread article if requested.
7618 (if (and (not no-article)
7620 gnus-newsgroup-unreads
7621 gnus-auto-select-first)
7622 (unless (if (eq gnus-auto-select-first 'best)
7623 (gnus-summary-best-unread-article)
7624 (gnus-summary-first-unread-article))
7625 (gnus-configure-windows 'summary))
7626 ;; Don't select any articles, just move point to the first
7627 ;; article in the group.
7628 (goto-char (point-min))
7629 (gnus-summary-position-point)
7630 (gnus-set-mode-line 'summary)
7631 (gnus-configure-windows 'summary 'force))
7632 ;; If we are in async mode, we send some info to the backend.
7633 (when gnus-newsgroup-async
7634 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7636 (gnus-kill-or-deaden-summary kill-buffer))
7637 (when (get-buffer-window gnus-group-buffer t)
7638 ;; Gotta use windows, because recenter does wierd stuff if
7639 ;; the current buffer ain't the displayed window.
7640 (let ((owin (selected-window)))
7641 (select-window (get-buffer-window gnus-group-buffer t))
7642 (when (gnus-group-goto-group group)
7644 (select-window owin))))
7645 ;; Mark this buffer as "prepared".
7646 (setq gnus-newsgroup-prepared t)
7649 (defun gnus-summary-prepare ()
7650 "Generate the summary buffer."
7651 (let ((buffer-read-only nil))
7653 (setq gnus-newsgroup-data nil
7654 gnus-newsgroup-data-reverse nil)
7655 (run-hooks 'gnus-summary-generate-hook)
7656 ;; Generate the buffer, either with threads or without.
7657 (when gnus-newsgroup-headers
7658 (gnus-summary-prepare-threads
7659 (if gnus-show-threads
7660 (gnus-sort-gathered-threads
7661 (funcall gnus-summary-thread-gathering-function
7663 (gnus-cut-threads (gnus-make-threads)))))
7664 ;; Unthreaded display.
7665 (gnus-sort-articles gnus-newsgroup-headers))))
7666 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7667 ;; Call hooks for modifying summary buffer.
7668 (goto-char (point-min))
7669 (run-hooks 'gnus-summary-prepare-hook)))
7671 (defun gnus-gather-threads-by-subject (threads)
7672 "Gather threads by looking at Subject headers."
7673 (if (not gnus-summary-make-false-root)
7675 (let ((hashtb (gnus-make-hashtable 1023))
7678 subject hthread whole-subject)
7680 (setq whole-subject (mail-header-subject (caar threads)))
7683 ;; Truncate the subject.
7684 ((numberp gnus-summary-gather-subject-limit)
7685 (setq subject (gnus-simplify-subject-re whole-subject))
7686 (if (> (length subject) gnus-summary-gather-subject-limit)
7687 (substring subject 0 gnus-summary-gather-subject-limit)
7689 ;; Fuzzily simplify it.
7690 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7691 (gnus-simplify-subject-fuzzy whole-subject))
7692 ;; Just remove the leading "Re:".
7694 (gnus-simplify-subject-re whole-subject))))
7696 (if (and gnus-summary-gather-exclude-subject
7697 (string-match gnus-summary-gather-exclude-subject
7699 () ; We don't want to do anything with this article.
7700 ;; We simplify the subject before looking it up in the
7703 (if (setq hthread (gnus-gethash subject hashtb))
7705 ;; We enter a dummy root into the thread, if we
7706 ;; haven't done that already.
7707 (unless (stringp (caar hthread))
7708 (setcar hthread (list whole-subject (car hthread))))
7709 ;; We add this new gathered thread to this gathered
7711 (setcdr (car hthread)
7712 (nconc (cdar hthread) (list (car threads))))
7713 ;; Remove it from the list of threads.
7714 (setcdr prev (cdr threads))
7715 (setq threads prev))
7716 ;; Enter this thread into the hash table.
7717 (gnus-sethash subject threads hashtb)))
7719 (setq threads (cdr threads)))
7722 (defun gnus-gather-threads-by-references (threads)
7723 "Gather threads by looking at References headers."
7724 (let ((idhashtb (gnus-make-hashtable 1023))
7725 (thhashtb (gnus-make-hashtable 1023))
7728 ids references id gthread gid entered)
7730 (when (setq references (mail-header-references (caar threads)))
7731 (setq id (mail-header-id (caar threads)))
7732 (setq ids (gnus-split-references references))
7735 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7737 (gnus-sethash (car ids) id idhashtb)
7738 (gnus-sethash id threads thhashtb))
7739 (setq gthread (gnus-gethash gid thhashtb))
7741 ;; We enter a dummy root into the thread, if we
7742 ;; haven't done that already.
7743 (unless (stringp (caar gthread))
7744 (setcar gthread (list (mail-header-subject (caar gthread))
7746 ;; We add this new gathered thread to this gathered
7748 (setcdr (car gthread)
7749 (nconc (cdar gthread) (list (car threads)))))
7750 ;; Add it into the thread hash table.
7751 (gnus-sethash id gthread thhashtb)
7753 ;; Remove it from the list of threads.
7754 (setcdr prev (cdr threads))
7755 (setq threads prev))
7756 (setq ids (cdr ids))))
7758 (setq threads (cdr threads)))
7761 (defun gnus-sort-gathered-threads (threads)
7762 "Sort subtreads inside each gathered thread by article number."
7763 (let ((result threads))
7765 (when (stringp (caar threads))
7766 (setcdr (car threads)
7767 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7768 (setq threads (cdr threads)))
7771 (defun gnus-make-threads ()
7772 "Go through the dependency hashtb and find the roots. Return all threads."
7776 (unless (car (symbol-value refs))
7777 ;; These threads do not refer back to any other articles,
7778 ;; so they're roots.
7779 (setq threads (append (cdr (symbol-value refs)) threads))))
7780 gnus-newsgroup-dependencies)
7783 (defun gnus-build-sparse-threads ()
7784 (let ((headers gnus-newsgroup-headers)
7785 (deps gnus-newsgroup-dependencies)
7786 header references generation relations
7787 cthread subject child end pthread relation)
7788 ;; First we create an alist of generations/relations, where
7789 ;; generations is how much we trust the ralation, and the relation
7791 (gnus-message 7 "Making sparse threads...")
7793 (nnheader-set-temp-buffer " *gnus sparse threads*")
7794 (while (setq header (pop headers))
7795 (when (and (setq references (mail-header-references header))
7796 (not (string= references "")))
7798 (setq child (mail-header-id header)
7799 subject (mail-header-subject header))
7801 (while (search-backward ">" nil t)
7802 (setq end (1+ (point)))
7803 (when (search-backward "<" nil t)
7804 (push (list (incf generation)
7805 child (setq child (buffer-substring (point) end))
7808 (push (list (1+ generation) child nil subject) relations)
7810 (kill-buffer (current-buffer)))
7811 ;; Sort over trustworthiness.
7812 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7813 (while (setq relation (pop relations))
7814 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7815 (unless (car (symbol-value cthread))
7816 ;; Make this article the parent of these threads.
7817 (setcar (symbol-value cthread)
7818 (vector gnus-reffed-article-number
7822 (or (caddr relation) "") 0 0 "")))
7823 (set cthread (list (vector gnus-reffed-article-number
7825 "" "" (cadr relation)
7826 (or (caddr relation) "") 0 0 ""))))
7827 (push gnus-reffed-article-number gnus-newsgroup-limit)
7828 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7829 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7830 gnus-newsgroup-reads)
7831 (decf gnus-reffed-article-number)
7832 ;; Make this new thread the child of its parent.
7833 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7834 (setcdr (symbol-value pthread)
7835 (nconc (cdr (symbol-value pthread))
7836 (list (symbol-value cthread))))
7837 (set pthread (list nil (symbol-value cthread))))))
7838 (gnus-message 7 "Making sparse threads...done")))
7840 (defun gnus-build-old-threads ()
7841 ;; Look at all the articles that refer back to old articles, and
7842 ;; fetch the headers for the articles that aren't there. This will
7843 ;; build complete threads - if the roots haven't been expired by the
7848 (when (not (car (symbol-value refs)))
7849 (setq heads (cdr (symbol-value refs)))
7851 (if (memq (mail-header-number (caar heads))
7852 gnus-newsgroup-dormant)
7853 (setq heads (cdr heads))
7854 (setq id (symbol-name refs))
7855 (while (and (setq id (gnus-build-get-header id))
7856 (not (car (gnus-gethash
7857 id gnus-newsgroup-dependencies)))))
7858 (setq heads nil)))))
7859 gnus-newsgroup-dependencies)))
7861 (defun gnus-build-get-header (id)
7862 ;; Look through the buffer of NOV lines and find the header to
7863 ;; ID. Enter this line into the dependencies hash table, and return
7864 ;; the id of the parent article (if any).
7865 (let ((deps gnus-newsgroup-dependencies)
7869 (set-buffer nntp-server-buffer)
7870 (goto-char (point-min))
7871 (while (and (not found) (search-forward id nil t))
7873 (setq found (looking-at
7874 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7875 (regexp-quote id))))
7876 (or found (beginning-of-line 2)))
7880 (setq header (gnus-nov-parse-line
7881 (read (current-buffer)) deps))
7882 (gnus-parent-id (mail-header-references header)))))
7884 (let ((number (mail-header-number header)))
7885 (push number gnus-newsgroup-limit)
7886 (push header gnus-newsgroup-headers)
7887 (if (memq number gnus-newsgroup-unselected)
7889 (push number gnus-newsgroup-unreads)
7890 (setq gnus-newsgroup-unselected
7891 (delq number gnus-newsgroup-unselected)))
7892 (push number gnus-newsgroup-ancient)))))))
7894 (defun gnus-summary-update-article (article &optional header)
7895 "Update ARTICLE in the summary buffer."
7896 (set-buffer gnus-summary-buffer)
7897 (let* ((header (or header (gnus-summary-article-header article)))
7898 (id (mail-header-id header))
7899 (data (gnus-data-find article))
7900 (thread (gnus-id-to-thread id))
7902 (gnus-id-to-thread (or (gnus-parent-id
7903 (mail-header-references header))
7905 (buffer-read-only nil)
7907 (number (mail-header-number header))
7912 (delq thread parent))
7913 (if (gnus-summary-insert-subject id header)
7914 ;; Set the (possibly) new article number in the data structure.
7915 (gnus-data-set-number data (gnus-id-to-article id))
7919 (defun gnus-rebuild-thread (id)
7920 "Rebuild the thread containing ID."
7921 (let ((buffer-read-only nil)
7922 current thread data)
7923 (if (not gnus-show-threads)
7924 (setq thread (list (car (gnus-id-to-thread id))))
7925 ;; Get the thread this article is part of.
7926 (setq thread (gnus-remove-thread id)))
7927 (setq current (save-excursion
7928 (and (zerop (forward-line -1))
7929 (gnus-summary-article-number))))
7930 ;; If this is a gathered thread, we have to go some re-gathering.
7931 (when (stringp (car thread))
7932 (let ((subject (car thread))
7934 (setq thread (cdr thread))
7936 (unless (memq (setq thr (gnus-id-to-thread
7938 (mail-header-id (caar thread)))))
7941 (setq thread (cdr thread)))
7942 ;; We now have all (unique) roots.
7943 (if (= (length roots) 1)
7944 ;; All the loose roots are now one solid root.
7945 (setq thread (car roots))
7946 (setq thread (cons subject (gnus-sort-threads roots))))))
7948 ;; We then insert this thread into the summary buffer.
7949 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7950 (gnus-summary-prepare-threads (list thread))
7951 (setq data (nreverse gnus-newsgroup-data))
7952 (setq threads gnus-newsgroup-threads))
7953 ;; We splice the new data into the data structure.
7954 (gnus-data-enter-list current data)
7955 (gnus-data-compute-positions)
7956 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7958 (defun gnus-id-to-thread (id)
7959 "Return the (sub-)thread where ID appears."
7960 (gnus-gethash id gnus-newsgroup-dependencies))
7962 (defun gnus-id-to-article (id)
7963 "Return the article number of ID."
7964 (let ((thread (gnus-id-to-thread id)))
7966 (mail-header-number (car thread)))))
7968 (defun gnus-id-to-header (id)
7969 "Return the article headers of ID."
7970 (car (gnus-id-to-thread id)))
7972 (defun gnus-article-displayed-root-p (article)
7973 "Say whether ARTICLE is a root(ish) article."
7974 (let ((level (gnus-summary-thread-level article))
7980 (null (setq particle (gnus-id-to-article
7982 (mail-header-references
7983 (gnus-summary-article-header article))))))
7984 (null (gnus-summary-thread-level particle)))))))
7986 (defun gnus-root-id (id)
7987 "Return the id of the root of the thread where ID appears."
7989 (while (and id (setq prev (car (gnus-gethash
7990 id gnus-newsgroup-dependencies))))
7992 id (gnus-parent-id (mail-header-references prev))))
7995 (defun gnus-remove-thread (id &optional dont-remove)
7996 "Remove the thread that has ID in it."
7997 (let ((dep gnus-newsgroup-dependencies)
7998 headers thread last-id)
7999 ;; First go up in this thread until we find the root.
8000 (setq last-id (gnus-root-id id))
8001 (setq headers (list (car (gnus-id-to-thread last-id))
8002 (caadr (gnus-id-to-thread last-id))))
8003 ;; We have now found the real root of this thread. It might have
8004 ;; been gathered into some loose thread, so we have to search
8005 ;; through the threads to find the thread we wanted.
8006 (let ((threads gnus-newsgroup-threads)
8009 (setq sub (car threads))
8010 (if (stringp (car sub))
8011 ;; This is a gathered threads, so we look at the roots
8012 ;; below it to find whether this article in in this
8015 (setq sub (cdr sub))
8017 (when (member (caar sub) headers)
8018 (setq thread (car threads)
8021 (setq sub (cdr sub))))
8022 ;; It's an ordinary thread, so we check it.
8023 (when (eq (car sub) (car headers))
8026 (setq threads (cdr threads)))
8027 ;; If this article is in no thread, then it's a root.
8030 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8031 (setq thread (gnus-gethash last-id dep)))
8034 thread ; We return this thread.
8036 (if (stringp (car thread))
8038 ;; If we use dummy roots, then we have to remove the
8039 ;; dummy root as well.
8040 (when (eq gnus-summary-make-false-root 'dummy)
8043 (setq thread (cdr thread))
8045 (gnus-remove-thread-1 (car thread))
8046 (setq thread (cdr thread))))
8047 (gnus-remove-thread-1 thread))))))))
8049 (defun gnus-remove-thread-1 (thread)
8050 "Remove the thread THREAD recursively."
8051 (let ((number (mail-header-number (car thread)))
8053 (when (setq pos (text-property-any
8054 (point-min) (point-max) 'gnus-number number))
8057 (gnus-data-remove number))
8058 (setq thread (cdr thread))
8060 (gnus-remove-thread-1 (pop thread)))))
8062 (defun gnus-sort-threads (threads)
8064 (if (not gnus-thread-sort-functions)
8066 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8067 (car gnus-thread-sort-functions)
8069 ,(gnus-make-sort-function
8070 (reverse gnus-thread-sort-functions))))))
8071 (gnus-message 7 "Sorting threads...")
8074 (gnus-message 7 "Sorting threads...done")))))
8076 (defun gnus-sort-articles (articles)
8078 (when gnus-article-sort-functions
8079 (let ((func (if (= 1 (length gnus-article-sort-functions))
8080 (car gnus-article-sort-functions)
8082 ,(gnus-make-sort-function
8083 (reverse gnus-article-sort-functions))))))
8084 (gnus-message 7 "Sorting articles...")
8086 (setq gnus-newsgroup-headers (sort articles func))
8087 (gnus-message 7 "Sorting articles...done")))))
8089 (defun gnus-make-sort-function (funs)
8090 "Return a composite sort condition based on the functions in FUNC."
8092 `(or (,(car funs) t1 t2)
8093 (and (not (,(car funs) t2 t1))
8094 ,(gnus-make-sort-function (cdr funs))))
8095 `(,(car funs) t1 t2)))
8097 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8098 (defmacro gnus-thread-header (thread)
8099 ;; Return header of first article in THREAD.
8100 ;; Note that THREAD must never, ever be anything else than a variable -
8101 ;; using some other form will lead to serious barfage.
8102 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8103 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8104 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8107 (defsubst gnus-article-sort-by-number (h1 h2)
8108 "Sort articles by article number."
8109 (< (mail-header-number h1)
8110 (mail-header-number h2)))
8112 (defun gnus-thread-sort-by-number (h1 h2)
8113 "Sort threads by root article number."
8114 (gnus-article-sort-by-number
8115 (gnus-thread-header h1) (gnus-thread-header h2)))
8117 (defsubst gnus-article-sort-by-author (h1 h2)
8118 "Sort articles by root author."
8120 (let ((extract (funcall
8121 gnus-extract-address-components
8122 (mail-header-from h1))))
8123 (or (car extract) (cdr extract)))
8124 (let ((extract (funcall
8125 gnus-extract-address-components
8126 (mail-header-from h2))))
8127 (or (car extract) (cdr extract)))))
8129 (defun gnus-thread-sort-by-author (h1 h2)
8130 "Sort threads by root author."
8131 (gnus-article-sort-by-author
8132 (gnus-thread-header h1) (gnus-thread-header h2)))
8134 (defsubst gnus-article-sort-by-subject (h1 h2)
8135 "Sort articles by root subject."
8137 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8138 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8140 (defun gnus-thread-sort-by-subject (h1 h2)
8141 "Sort threads by root subject."
8142 (gnus-article-sort-by-subject
8143 (gnus-thread-header h1) (gnus-thread-header h2)))
8145 (defsubst gnus-article-sort-by-date (h1 h2)
8146 "Sort articles by root article date."
8148 (gnus-sortable-date (mail-header-date h1))
8149 (gnus-sortable-date (mail-header-date h2))))
8151 (defun gnus-thread-sort-by-date (h1 h2)
8152 "Sort threads by root article date."
8153 (gnus-article-sort-by-date
8154 (gnus-thread-header h1) (gnus-thread-header h2)))
8156 (defsubst gnus-article-sort-by-score (h1 h2)
8157 "Sort articles by root article score.
8158 Unscored articles will be counted as having a score of zero."
8159 (> (or (cdr (assq (mail-header-number h1)
8160 gnus-newsgroup-scored))
8161 gnus-summary-default-score 0)
8162 (or (cdr (assq (mail-header-number h2)
8163 gnus-newsgroup-scored))
8164 gnus-summary-default-score 0)))
8166 (defun gnus-thread-sort-by-score (h1 h2)
8167 "Sort threads by root article score."
8168 (gnus-article-sort-by-score
8169 (gnus-thread-header h1) (gnus-thread-header h2)))
8171 (defun gnus-thread-sort-by-total-score (h1 h2)
8172 "Sort threads by the sum of all scores in the thread.
8173 Unscored articles will be counted as having a score of zero."
8174 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8176 (defun gnus-thread-total-score (thread)
8177 ;; This function find the total score of THREAD.
8179 (if (stringp (car thread))
8180 (apply gnus-thread-score-function 0
8181 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8182 (gnus-thread-total-score-1 thread))
8183 (gnus-thread-total-score-1 (list thread))))
8185 (defun gnus-thread-total-score-1 (root)
8186 ;; This function find the total score of the thread below ROOT.
8187 (setq root (car root))
8188 (apply gnus-thread-score-function
8189 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8190 gnus-summary-default-score 0)
8191 (mapcar 'gnus-thread-total-score
8192 (cdr (gnus-gethash (mail-header-id root)
8193 gnus-newsgroup-dependencies)))))
8195 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8196 (defvar gnus-tmp-prev-subject nil)
8197 (defvar gnus-tmp-false-parent nil)
8198 (defvar gnus-tmp-root-expunged nil)
8199 (defvar gnus-tmp-dummy-line nil)
8201 (defun gnus-summary-prepare-threads (threads)
8202 "Prepare summary buffer from THREADS and indentation LEVEL.
8203 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8204 or a straight list of headers."
8205 (gnus-message 7 "Generating summary...")
8207 (setq gnus-newsgroup-threads threads)
8210 (let ((gnus-tmp-level 0)
8211 (default-score (or gnus-summary-default-score 0))
8212 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8213 thread number subject stack state gnus-tmp-gathered beg-match
8214 new-roots gnus-tmp-new-adopts thread-end
8215 gnus-tmp-header gnus-tmp-unread
8216 gnus-tmp-replied gnus-tmp-subject-or-nil
8217 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8218 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8219 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8221 (setq gnus-tmp-prev-subject nil)
8223 (if (vectorp (car threads))
8224 ;; If this is a straight (sic) list of headers, then a
8225 ;; threaded summary display isn't required, so we just create
8226 ;; an unthreaded one.
8227 (gnus-summary-prepare-unthreaded threads)
8229 ;; Do the threaded display.
8231 (while (or threads stack gnus-tmp-new-adopts new-roots)
8233 (if (and (= gnus-tmp-level 0)
8234 (not (setq gnus-tmp-dummy-line nil))
8237 (not gnus-tmp-false-parent)
8238 (or gnus-tmp-new-adopts new-roots))
8239 (if gnus-tmp-new-adopts
8240 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8241 thread (list (car gnus-tmp-new-adopts))
8242 gnus-tmp-header (caar thread)
8243 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8245 (setq thread (list (car new-roots))
8246 gnus-tmp-header (caar thread)
8247 new-roots (cdr new-roots))))
8250 ;; If there are some threads, we do them before the
8251 ;; threads on the stack.
8252 (setq thread threads
8253 gnus-tmp-header (caar thread))
8254 ;; There were no current threads, so we pop something off
8256 (setq state (car stack)
8257 gnus-tmp-level (car state)
8260 gnus-tmp-header (caar thread))))
8262 (setq gnus-tmp-false-parent nil)
8263 (setq gnus-tmp-root-expunged nil)
8264 (setq thread-end nil)
8266 (if (stringp gnus-tmp-header)
8267 ;; The header is a dummy root.
8269 ((eq gnus-summary-make-false-root 'adopt)
8270 ;; We let the first article adopt the rest.
8271 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8273 (setq gnus-tmp-gathered
8275 (lambda (h) (mail-header-number (car h)))
8278 (setq thread (cons (list (caar thread)
8281 (setq gnus-tmp-level -1
8282 gnus-tmp-false-parent t))
8283 ((eq gnus-summary-make-false-root 'empty)
8284 ;; We print adopted articles with empty subject fields.
8285 (setq gnus-tmp-gathered
8287 (lambda (h) (mail-header-number (car h)))
8290 (setq gnus-tmp-level -1))
8291 ((eq gnus-summary-make-false-root 'dummy)
8292 ;; We remember that we probably want to output a dummy
8294 (setq gnus-tmp-dummy-line gnus-tmp-header)
8295 (setq gnus-tmp-prev-subject gnus-tmp-header))
8297 ;; We do not make a root for the gathered
8298 ;; sub-threads at all.
8299 (setq gnus-tmp-level -1)))
8301 (setq number (mail-header-number gnus-tmp-header)
8302 subject (mail-header-subject gnus-tmp-header))
8305 ;; If the thread has changed subject, we might want to make
8306 ;; this subthread into a root.
8307 ((and (null gnus-thread-ignore-subject)
8308 (not (zerop gnus-tmp-level))
8309 gnus-tmp-prev-subject
8311 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8312 (setq new-roots (nconc new-roots (list (car thread)))
8314 gnus-tmp-header nil))
8315 ;; If the article lies outside the current limit,
8316 ;; then we do not display it.
8317 ((and (not (memq number gnus-newsgroup-limit))
8318 (not gnus-tmp-dummy-line))
8319 (setq gnus-tmp-gathered
8321 (lambda (h) (mail-header-number (car h)))
8324 (setq gnus-tmp-new-adopts (if (cdar thread)
8325 (append gnus-tmp-new-adopts
8327 gnus-tmp-new-adopts)
8329 gnus-tmp-header nil)
8330 (when (zerop gnus-tmp-level)
8331 (setq gnus-tmp-root-expunged t)))
8332 ;; Perhaps this article is to be marked as read?
8333 ((and gnus-summary-mark-below
8334 (< (or (cdr (assq number gnus-newsgroup-scored))
8336 gnus-summary-mark-below)
8337 ;; Don't touch sparse articles.
8338 (not (memq number gnus-newsgroup-sparse)))
8339 (setq gnus-newsgroup-unreads
8340 (delq number gnus-newsgroup-unreads))
8341 (if gnus-newsgroup-auto-expire
8342 (push number gnus-newsgroup-expirable)
8343 (push (cons number gnus-low-score-mark)
8344 gnus-newsgroup-reads))))
8346 (when gnus-tmp-header
8347 ;; We may have an old dummy line to output before this
8349 (when gnus-tmp-dummy-line
8350 (gnus-summary-insert-dummy-line
8351 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8352 (setq gnus-tmp-dummy-line nil))
8354 ;; Compute the mark.
8358 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8359 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8360 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8361 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8362 (t (or (cdr (assq number gnus-newsgroup-reads))
8363 gnus-ancient-mark))))
8365 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8366 gnus-tmp-header gnus-tmp-level)
8367 gnus-newsgroup-data)
8369 ;; Actually insert the line.
8371 gnus-tmp-subject-or-nil
8373 ((and gnus-thread-ignore-subject
8374 gnus-tmp-prev-subject
8375 (not (inline (gnus-subject-equal
8376 gnus-tmp-prev-subject subject))))
8378 ((zerop gnus-tmp-level)
8379 (if (and (eq gnus-summary-make-false-root 'empty)
8380 (memq number gnus-tmp-gathered)
8381 gnus-tmp-prev-subject
8382 (inline (gnus-subject-equal
8383 gnus-tmp-prev-subject subject)))
8384 gnus-summary-same-subject
8386 (t gnus-summary-same-subject)))
8387 (if (and (eq gnus-summary-make-false-root 'adopt)
8388 (= gnus-tmp-level 1)
8389 (memq number gnus-tmp-gathered))
8390 (setq gnus-tmp-opening-bracket ?\<
8391 gnus-tmp-closing-bracket ?\>)
8392 (setq gnus-tmp-opening-bracket ?\[
8393 gnus-tmp-closing-bracket ?\]))
8395 gnus-tmp-indentation
8396 (aref gnus-thread-indent-array gnus-tmp-level)
8397 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8398 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8399 gnus-summary-default-score 0)
8401 (if (or (null gnus-summary-default-score)
8402 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8403 gnus-summary-zcore-fuzz)) ?
8404 (if (< gnus-tmp-score gnus-summary-default-score)
8405 gnus-score-below-mark gnus-score-over-mark))
8407 (cond ((memq number gnus-newsgroup-processable)
8409 ((memq number gnus-newsgroup-cached)
8411 ((memq number gnus-newsgroup-replied)
8413 (t gnus-unread-mark))
8414 gnus-tmp-from (mail-header-from gnus-tmp-header)
8417 ((string-match "(.+)" gnus-tmp-from)
8418 (substring gnus-tmp-from
8419 (1+ (match-beginning 0)) (1- (match-end 0))))
8420 ((string-match "<[^>]+> *$" gnus-tmp-from)
8421 (setq beg-match (match-beginning 0))
8422 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8423 (substring gnus-tmp-from (1+ (match-beginning 0))
8424 (1- (match-end 0))))
8425 (substring gnus-tmp-from 0 beg-match)))
8427 (when (string= gnus-tmp-name "")
8428 (setq gnus-tmp-name gnus-tmp-from))
8429 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8432 (progn (eval gnus-summary-line-format-spec) (point))
8433 'gnus-number number)
8436 (run-hooks 'gnus-summary-update-hook)
8439 (setq gnus-tmp-prev-subject subject)))
8441 (when (nth 1 thread)
8442 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8443 (incf gnus-tmp-level)
8444 (setq threads (if thread-end nil (cdar thread)))
8446 (setq gnus-tmp-level 0)))))
8447 (gnus-message 7 "Generating summary...done"))
8449 (defun gnus-summary-prepare-unthreaded (headers)
8450 "Generate an unthreaded summary buffer based on HEADERS."
8451 (let (header number mark)
8454 (setq header (car headers)
8455 headers (cdr headers)
8456 number (mail-header-number header))
8458 ;; We may have to root out some bad articles...
8459 (when (memq number gnus-newsgroup-limit)
8460 (when (and gnus-summary-mark-below
8461 (< (or (cdr (assq number gnus-newsgroup-scored))
8462 gnus-summary-default-score 0)
8463 gnus-summary-mark-below))
8464 (setq gnus-newsgroup-unreads
8465 (delq number gnus-newsgroup-unreads))
8466 (if gnus-newsgroup-auto-expire
8467 (push number gnus-newsgroup-expirable)
8468 (push (cons number gnus-low-score-mark)
8469 gnus-newsgroup-reads)))
8473 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8474 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8475 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8476 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8477 (t (or (cdr (assq number gnus-newsgroup-reads))
8478 gnus-ancient-mark))))
8479 (setq gnus-newsgroup-data
8480 (cons (gnus-data-make number mark (1+ (point)) header 0)
8481 gnus-newsgroup-data))
8482 (gnus-summary-insert-line
8483 header 0 nil mark (memq number gnus-newsgroup-replied)
8484 (memq number gnus-newsgroup-expirable)
8485 (mail-header-subject header) nil
8486 (cdr (assq number gnus-newsgroup-scored))
8487 (memq number gnus-newsgroup-processable))))))
8489 (defun gnus-select-newsgroup (group &optional read-all)
8490 "Select newsgroup GROUP.
8491 If READ-ALL is non-nil, all articles in the group are selected."
8492 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8493 (info (nth 2 entry))
8494 articles fetched-articles cached)
8496 (or (gnus-check-server
8497 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8498 (error "Couldn't open server"))
8500 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8501 (gnus-activate-group group) ; Or we can activate it...
8502 (progn ; Or we bug out.
8503 (when (equal major-mode 'gnus-summary-mode)
8504 (kill-buffer (current-buffer)))
8505 (error "Couldn't request group %s: %s"
8506 group (gnus-status-message group))))
8508 (setq gnus-newsgroup-name group)
8509 (setq gnus-newsgroup-unselected nil)
8510 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8512 (and gnus-asynchronous
8513 (gnus-check-backend-function
8514 'request-asynchronous gnus-newsgroup-name)
8515 (setq gnus-newsgroup-async
8516 (gnus-request-asynchronous gnus-newsgroup-name)))
8518 ;; Adjust and set lists of article marks.
8520 (gnus-adjust-marked-articles info))
8522 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8523 (when (gnus-virtual-group-p group)
8524 (setq cached gnus-newsgroup-cached))
8526 (setq gnus-newsgroup-unreads
8527 (gnus-set-difference
8528 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8529 gnus-newsgroup-dormant))
8531 (setq gnus-newsgroup-processable nil)
8533 (setq articles (gnus-articles-to-read group read-all))
8537 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8539 ((eq articles 0) nil)
8541 ;; Init the dependencies hash table.
8542 (setq gnus-newsgroup-dependencies
8543 (gnus-make-hashtable (length articles)))
8544 ;; Retrieve the headers and read them in.
8545 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8546 (setq gnus-newsgroup-headers
8548 (setq gnus-headers-retrieved-by
8549 (gnus-retrieve-headers
8550 articles gnus-newsgroup-name
8551 ;; We might want to fetch old headers, but
8552 ;; not if there is only 1 article.
8553 (and gnus-fetch-old-headers
8555 (not (eq gnus-fetch-old-headers 'some))
8556 (not (numberp gnus-fetch-old-headers)))
8557 (> (length articles) 1))))))
8558 (gnus-get-newsgroup-headers-xover articles)
8559 (gnus-get-newsgroup-headers)))
8560 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8562 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8564 (setq gnus-newsgroup-cached cached))
8566 ;; Set the initial limit.
8567 (setq gnus-newsgroup-limit (copy-sequence articles))
8568 ;; Remove canceled articles from the list of unread articles.
8569 (setq gnus-newsgroup-unreads
8570 (gnus-set-sorted-intersection
8571 gnus-newsgroup-unreads
8572 (setq fetched-articles
8573 (mapcar (lambda (headers) (mail-header-number headers))
8574 gnus-newsgroup-headers))))
8575 ;; Removed marked articles that do not exist.
8576 (gnus-update-missing-marks
8577 (gnus-sorted-complement fetched-articles articles))
8578 ;; We might want to build some more threads first.
8579 (and gnus-fetch-old-headers
8580 (eq gnus-headers-retrieved-by 'nov)
8581 (gnus-build-old-threads))
8582 ;; Check whether auto-expire is to be done in this group.
8583 (setq gnus-newsgroup-auto-expire
8584 (gnus-group-auto-expirable-p group))
8585 ;; Set up the article buffer now, if necessary.
8586 (unless gnus-single-article-buffer
8587 (gnus-article-setup-buffer))
8588 ;; First and last article in this newsgroup.
8589 (and gnus-newsgroup-headers
8590 (setq gnus-newsgroup-begin
8591 (mail-header-number (car gnus-newsgroup-headers)))
8592 (setq gnus-newsgroup-end
8594 (gnus-last-element gnus-newsgroup-headers))))
8595 (setq gnus-reffed-article-number -1)
8596 ;; GROUP is successfully selected.
8597 (or gnus-newsgroup-headers t)))))
8599 (defun gnus-articles-to-read (group read-all)
8600 ;; Find out what articles the user wants to read.
8602 ;; Select all articles if `read-all' is non-nil, or if there
8603 ;; are no unread articles.
8605 (and (zerop (length gnus-newsgroup-marked))
8606 (zerop (length gnus-newsgroup-unreads))))
8607 (gnus-uncompress-range (gnus-active group))
8608 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8609 (copy-sequence gnus-newsgroup-unreads))
8611 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8612 (scored (length scored-list))
8613 (number (length articles))
8614 (marked (+ (length gnus-newsgroup-marked)
8615 (length gnus-newsgroup-dormant)))
8623 ((and (or (<= scored marked) (= scored number))
8624 (numberp gnus-large-newsgroup)
8625 (> number gnus-large-newsgroup))
8629 "How many articles from %s (default %d): "
8630 gnus-newsgroup-name number))))
8631 (if (string-match "^[ \t]*$" input) number input)))
8632 ((and (> scored marked) (< scored number))
8635 (format "%s %s (%d scored, %d total): "
8636 "How many articles from"
8637 group scored number))))
8638 (if (string-match "^[ \t]*$" input)
8642 (setq select (if (stringp select) (string-to-number select) select))
8643 (if (or (null select) (zerop select))
8645 (if (and (not (zerop scored)) (<= (abs select) scored))
8647 (setq articles (sort scored-list '<))
8648 (setq number (length articles)))
8649 (setq articles (copy-sequence articles)))
8651 (if (< (abs select) number)
8653 ;; Select the N oldest articles.
8654 (setcdr (nthcdr (1- (abs select)) articles) nil)
8655 ;; Select the N most recent articles.
8656 (setq articles (nthcdr (- number select) articles))))
8657 (setq gnus-newsgroup-unselected
8658 (gnus-sorted-intersection
8659 gnus-newsgroup-unreads
8660 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8663 (defun gnus-killed-articles (killed articles)
8666 (if (inline (gnus-member-of-range (car articles) killed))
8667 (setq out (cons (car articles) out)))
8668 (setq articles (cdr articles)))
8671 (defun gnus-uncompress-marks (marks)
8672 "Uncompress the mark ranges in MARKS."
8673 (let ((uncompressed '(score bookmark))
8676 (if (memq (caar marks) uncompressed)
8677 (push (car marks) out)
8678 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8679 (setq marks (cdr marks)))
8682 (defun gnus-adjust-marked-articles (info)
8683 "Set all article lists and remove all marks that are no longer legal."
8684 (let* ((marked-lists (gnus-info-marks info))
8685 (active (gnus-active (gnus-info-group info)))
8688 (types gnus-article-mark-lists)
8689 (uncompressed '(score bookmark))
8690 marks var articles article mark)
8693 (setq marks (pop marked-lists))
8694 (set (setq var (intern (format "gnus-newsgroup-%s"
8695 (car (rassq (setq mark (car marks))
8697 (if (memq (car marks) uncompressed) (cdr marks)
8698 (gnus-uncompress-range (cdr marks))))
8700 (setq articles (symbol-value var))
8702 ;; All articles have to be subsets of the active articles.
8704 ;; Adjust "simple" lists.
8705 ((memq mark '(tick dormant expirable reply killed save))
8707 (when (or (< (setq article (pop articles)) min) (> article max))
8708 (set var (delq article (symbol-value var))))))
8710 ((memq mark '(score bookmark))
8712 (when (or (< (car (setq article (pop articles))) min)
8713 (> (car article) max))
8714 (set var (delq article (symbol-value var))))))))))
8716 (defun gnus-update-missing-marks (missing)
8717 "Go through the list of MISSING articles and remove them mark lists."
8719 (let ((types gnus-article-mark-lists)
8721 ;; Go through all types.
8723 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8724 (when (symbol-value var)
8725 ;; This list has articles. So we delete all missing articles
8729 (set var (delq (pop m) (symbol-value var)))))))))
8731 (defun gnus-update-marks ()
8732 "Enter the various lists of marked articles into the newsgroup info list."
8733 (let ((types gnus-article-mark-lists)
8734 (info (gnus-get-info gnus-newsgroup-name))
8735 (uncompressed '(score bookmark killed))
8736 type list newmarked symbol)
8738 ;; Add all marks lists that are non-nil to the list of marks lists.
8740 (setq type (pop types))
8741 (when (setq list (symbol-value
8743 (intern (format "gnus-newsgroup-%s"
8745 (push (cons (cdr type)
8746 (if (memq (cdr type) uncompressed) list
8747 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8750 ;; Enter these new marks into the info of the group.
8752 (setcar (nthcdr 3 info) newmarked)
8753 ;; Add the marks lists to the end of the info.
8755 (setcdr (nthcdr 2 info) (list newmarked))))
8757 ;; Cut off the end of the info if there's nothing else there.
8761 (when (nthcdr (decf i) info)
8762 (setcdr (nthcdr i info) nil)))))))
8764 (defun gnus-add-marked-articles (group type articles &optional info force)
8765 ;; Add ARTICLES of TYPE to the info of GROUP.
8766 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8767 ;; add, but replace marked articles of TYPE with ARTICLES.
8768 (let ((info (or info (gnus-get-info group)))
8769 (uncompressed '(score bookmark killed))
8772 (and (not (setq marked (nthcdr 3 info)))
8774 (setcdr (nthcdr 2 info)
8775 (list (list (cons type (gnus-compress-sequence
8777 (and (not (setq m (assq type (car marked))))
8780 (cons (cons type (gnus-compress-sequence articles t) )
8784 (setcar (nthcdr 3 info)
8785 (delq (assq type (car marked)) (car marked)))
8786 (setcdr m (gnus-compress-sequence articles t)))
8787 (setcdr m (gnus-compress-sequence
8788 (sort (nconc (gnus-uncompress-range (cdr m))
8789 (copy-sequence articles)) '<) t))))))
8791 (defun gnus-set-mode-line (where)
8792 "This function sets the mode line of the article or summary buffers.
8793 If WHERE is `summary', the summary mode line format will be used."
8794 ;; Is this mode line one we keep updated?
8795 (when (memq where gnus-updated-mode-lines)
8798 ;; We evaluate this in the summary buffer since these
8799 ;; variables are buffer-local to that buffer.
8800 (set-buffer gnus-summary-buffer)
8801 ;; We bind all these variables that are used in the `eval' form
8803 (let* ((mformat (symbol-value
8805 (format "gnus-%s-mode-line-format-spec" where))))
8806 (gnus-tmp-group-name gnus-newsgroup-name)
8807 (gnus-tmp-article-number (or gnus-current-article 0))
8808 (gnus-tmp-unread gnus-newsgroup-unreads)
8809 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8810 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8811 (gnus-tmp-unread-and-unselected
8812 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8813 (zerop gnus-tmp-unselected)) "")
8814 ((zerop gnus-tmp-unselected)
8815 (format "{%d more}" gnus-tmp-unread-and-unticked))
8816 (t (format "{%d(+%d) more}"
8817 gnus-tmp-unread-and-unticked
8818 gnus-tmp-unselected))))
8820 (if (and gnus-current-headers
8821 (vectorp gnus-current-headers))
8822 (mail-header-subject gnus-current-headers) ""))
8824 gnus-tmp-header);; passed as argument to any user-format-funcs
8825 (setq mode-string (eval mformat))
8826 (setq max-len (max 4 (if gnus-mode-non-string-length
8828 gnus-mode-non-string-length)
8829 (length mode-string))))
8830 ;; We might have to chop a bit of the string off...
8831 (when (> (length mode-string) max-len)
8833 (concat (gnus-truncate-string mode-string (- max-len 3))
8835 ;; Pad the mode string a bit.
8836 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8837 ;; Update the mode line.
8838 (setq mode-line-buffer-identification (list mode-string))
8839 (set-buffer-modified-p t))))
8841 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8842 "Go through the HEADERS list and add all Xrefs to a hash table.
8843 The resulting hash table is returned, or nil if no Xrefs were found."
8844 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8845 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8846 (xref-hashtb (make-vector 63 0))
8847 start group entry number xrefs header)
8849 (setq header (pop headers))
8850 (when (and (setq xrefs (mail-header-xref header))
8851 (not (memq (setq number (mail-header-number header))
8854 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8855 (setq start (match-end 0))
8856 (setq group (if prefix
8857 (concat prefix (substring xrefs (match-beginning 1)
8859 (substring xrefs (match-beginning 1) (match-end 1))))
8861 (string-to-int (substring xrefs (match-beginning 2)
8863 (if (setq entry (gnus-gethash group xref-hashtb))
8864 (setcdr entry (cons number (cdr entry)))
8865 (gnus-sethash group (cons number nil) xref-hashtb)))))
8866 (and start xref-hashtb)))
8868 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8869 "Look through all the headers and mark the Xrefs as read."
8870 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8871 name entry info xref-hashtb idlist method nth4)
8873 (set-buffer gnus-group-buffer)
8874 (when (setq xref-hashtb
8875 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8878 (unless (string= from-newsgroup (setq name (symbol-name group)))
8879 (setq idlist (symbol-value group))
8880 ;; Dead groups are not updated.
8882 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8884 (if (stringp (setq nth4 (gnus-info-method info)))
8885 (setq nth4 (gnus-server-to-method nth4))))
8886 ;; Only do the xrefs if the group has the same
8887 ;; select method as the group we have just read.
8888 (or (gnus-methods-equal-p
8889 nth4 (gnus-find-method-for-group from-newsgroup))
8891 (equal nth4 (setq method (gnus-find-method-for-group
8893 (and (equal (car nth4) (car method))
8894 (equal (nth 1 nth4) (nth 1 method))))
8895 gnus-use-cross-reference
8896 (or (not (eq gnus-use-cross-reference t))
8898 ;; Only do cross-references on subscribed
8899 ;; groups, if that is what is wanted.
8900 (<= (gnus-info-level info) gnus-level-subscribed))
8901 (gnus-group-make-articles-read name idlist))))
8904 (defun gnus-group-make-articles-read (group articles)
8906 (entry (gnus-gethash group gnus-newsrc-hashtb))
8907 (info (nth 2 entry))
8908 (active (gnus-active group))
8910 ;; First peel off all illegal article numbers.
8912 (let ((ids articles)
8916 (if (and first (> id (cdr active)))
8918 ;; We'll end up in this situation in one particular
8919 ;; obscure situation. If you re-scan a group and get
8920 ;; a new article that is cross-posted to a different
8921 ;; group that has not been re-scanned, you might get
8922 ;; crossposted article that has a higher number than
8923 ;; Gnus believes possible. So we re-activate this
8924 ;; group as well. This might mean doing the
8925 ;; crossposting thingy will *increase* the number
8926 ;; of articles in some groups. Tsk, tsk.
8927 (setq active (or (gnus-activate-group group) active))))
8928 (if (or (> id (cdr active))
8929 (< id (car active)))
8930 (setq articles (delq id articles)))
8931 (setq ids (cdr ids)))))
8932 ;; If the read list is nil, we init it.
8934 (null (gnus-info-read info))
8936 (gnus-info-set-read info (cons 1 (1- (car active)))))
8937 ;; Then we add the read articles to the range.
8942 (gnus-info-read info) (setq articles (sort articles '<)))))
8943 ;; Then we have to re-compute how many unread
8944 ;; articles there are in this group.
8949 (setq num (- (1+ (cdr active)) (car active))))
8950 ((not (listp (cdr range)))
8951 (setq num (- (cdr active) (- (1+ (cdr range))
8955 (if (numberp (car range))
8957 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8958 (setq range (cdr range)))
8959 (setq num (- (cdr active) num))))
8960 ;; Update the number of unread articles.
8962 ;; Update the group buffer.
8963 (gnus-group-update-group group t)))))
8965 (defun gnus-methods-equal-p (m1 m2)
8966 (let ((m1 (or m1 gnus-select-method))
8967 (m2 (or m2 gnus-select-method)))
8969 (and (eq (car m1) (car m2))
8970 (or (not (memq 'address (assoc (symbol-name (car m1))
8971 gnus-valid-select-methods)))
8972 (equal (nth 1 m1) (nth 1 m2)))))))
8974 (defsubst gnus-header-value ()
8975 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8977 (defvar gnus-newsgroup-none-id 0)
8979 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8980 (let ((cur nntp-server-buffer)
8983 (save-excursion (set-buffer gnus-summary-buffer)
8984 gnus-newsgroup-dependencies)))
8985 headers id id-dep ref-dep end ref)
8987 (set-buffer nntp-server-buffer)
8988 (let ((case-fold-search t)
8989 in-reply-to header p lines)
8990 (goto-char (point-min))
8991 ;; Search to the beginning of the next header. Error messages
8992 ;; do not begin with 2 or 3.
8993 (while (re-search-forward "^[23][0-9]+ " nil t)
8996 ;; This implementation of this function, with nine
8997 ;; search-forwards instead of the one re-search-forward and
8998 ;; a case (which basically was the old function) is actually
8999 ;; about twice as fast, even though it looks messier. You
9000 ;; can't have everything, I guess. Speed and elegance
9001 ;; doesn't always go hand in hand.
9010 (narrow-to-region (point)
9011 (or (and (search-forward "\n.\n" nil t)
9017 (if (search-forward "\nsubject: " nil t)
9018 (gnus-header-value) "(none)"))
9022 (if (search-forward "\nfrom: " nil t)
9023 (gnus-header-value) "(nobody)"))
9027 (if (search-forward "\ndate: " nil t)
9028 (gnus-header-value) ""))
9032 (if (search-forward "\nmessage-id: " nil t)
9033 (setq id (gnus-header-value))
9034 ;; If there was no message-id, we just fake one to make
9035 ;; subsequent routines simpler.
9036 (setq id (concat "none+"
9038 (setq gnus-newsgroup-none-id
9039 (1+ gnus-newsgroup-none-id)))))))
9043 (if (search-forward "\nreferences: " nil t)
9046 (setq end (match-end 0))
9052 (search-backward ">" end t)
9055 (search-backward "<" end t)
9057 ;; Get the references from the in-reply-to header if there
9058 ;; were no references and the in-reply-to header looks
9060 (if (and (search-forward "\nin-reply-to: " nil t)
9061 (setq in-reply-to (gnus-header-value))
9062 (string-match "<[^>]+>" in-reply-to))
9063 (setq ref (substring in-reply-to (match-beginning 0)
9071 (if (search-forward "\nlines: " nil t)
9072 (if (numberp (setq lines (read cur)))
9078 (and (search-forward "\nxref: " nil t)
9079 (gnus-header-value)))))
9080 ;; We do the threading while we read the headers. The
9081 ;; message-id and the last reference are both entered into
9082 ;; the same hash table. Some tippy-toeing around has to be
9083 ;; done in case an article has arrived before the article
9084 ;; which it refers to.
9085 (if (boundp (setq id-dep (intern id dependencies)))
9086 (if (and (car (symbol-value id-dep))
9088 ;; An article with this Message-ID has already
9089 ;; been seen, so we ignore this one, except we add
9090 ;; any additional Xrefs (in case the two articles
9091 ;; came from different servers).
9093 (mail-header-set-xref
9094 (car (symbol-value id-dep))
9095 (concat (or (mail-header-xref
9096 (car (symbol-value id-dep))) "")
9097 (or (mail-header-xref header) "")))
9099 (setcar (symbol-value id-dep) header))
9100 (set id-dep (list header)))
9102 (if (boundp (setq ref-dep (intern ref dependencies)))
9103 (setcdr (symbol-value ref-dep)
9104 (nconc (cdr (symbol-value ref-dep))
9105 (list (symbol-value id-dep))))
9106 (set ref-dep (list nil (symbol-value id-dep))))
9107 (setq headers (cons header headers)))
9108 (goto-char (point-max))
9110 (nreverse headers)))))
9112 ;; The following macros and functions were written by Felix Lee
9113 ;; <flee@cse.psu.edu>.
9115 (defmacro gnus-nov-read-integer ()
9117 (if (= (following-char) ?\t)
9119 (let ((num (condition-case nil (read buffer) (error nil))))
9120 (if (numberp num) num 0)))
9121 (or (eobp) (forward-char 1))))
9123 (defmacro gnus-nov-skip-field ()
9124 '(search-forward "\t" eol 'move))
9126 (defmacro gnus-nov-field ()
9127 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9129 ;; Goes through the xover lines and returns a list of vectors
9130 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9131 "Parse the news overview data in the server buffer, and return a
9132 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9133 ;; Get the Xref when the users reads the articles since most/some
9134 ;; NNTP servers do not include Xrefs when using XOVER.
9135 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9136 (let ((cur nntp-server-buffer)
9137 (dependencies gnus-newsgroup-dependencies)
9138 number headers header)
9140 (set-buffer nntp-server-buffer)
9141 ;; Allow the user to mangle the headers before parsing them.
9142 (run-hooks 'gnus-parse-headers-hook)
9143 ;; Allow the user to mangle the headers before parsing them.
9144 (run-hooks 'gnus-parse-headers-hook)
9145 (goto-char (point-min))
9146 (while (and sequence (not (eobp)))
9147 (setq number (read cur))
9148 (while (and sequence (< (car sequence) number))
9149 (setq sequence (cdr sequence)))
9151 (eq number (car sequence))
9153 (setq sequence (cdr sequence))
9155 (inline (gnus-nov-parse-line
9156 number dependencies force-new)))
9157 (setq headers (cons header headers)))))
9159 (setq headers (nreverse headers)))
9162 ;; This function has to be called with point after the article number
9163 ;; on the beginning of the line.
9164 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9166 (eol (gnus-point-at-eol))
9167 (buffer (current-buffer))
9168 header ref id id-dep ref-dep)
9170 ;; overview: [num subject from date id refs chars lines misc]
9171 (narrow-to-region (point) eol)
9172 (or (eobp) (forward-char))
9178 (gnus-nov-field) ; subject
9179 (gnus-nov-field) ; from
9180 (gnus-nov-field) ; date
9181 (setq id (or (gnus-nov-field)
9184 (setq none (1+ none)))))) ; id
9187 (let ((beg (point)))
9188 (search-forward "\t" eol)
9189 (if (search-backward ">" beg t)
9193 (search-backward "<" beg t)))
9195 (gnus-nov-field)) ; refs
9196 (gnus-nov-read-integer) ; chars
9197 (gnus-nov-read-integer) ; lines
9198 (if (= (following-char) ?\n)
9200 (gnus-nov-field)) ; misc
9204 (gnus-message 4 "Strange nov line")
9210 ;; We build the thread tree.
9212 (if (boundp (setq id-dep (intern id dependencies)))
9213 (if (and (car (symbol-value id-dep))
9215 ;; An article with this Message-ID has already been seen,
9216 ;; so we ignore this one, except we add any additional
9217 ;; Xrefs (in case the two articles came from different
9220 (mail-header-set-xref
9221 (car (symbol-value id-dep))
9222 (concat (or (mail-header-xref
9223 (car (symbol-value id-dep))) "")
9224 (or (mail-header-xref header) "")))
9226 (setcar (symbol-value id-dep) header))
9227 (set id-dep (list header))))
9230 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9231 (setcdr (symbol-value ref-dep)
9232 (nconc (cdr (symbol-value ref-dep))
9233 (list (symbol-value id-dep))))
9234 (set ref-dep (list nil (symbol-value id-dep))))))
9237 (defun gnus-article-get-xrefs ()
9238 "Fill in the Xref value in `gnus-current-headers', if necessary.
9239 This is meant to be called in `gnus-article-internal-prepare-hook'."
9240 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9241 gnus-current-headers)))
9242 (or (not gnus-use-cross-reference)
9244 (and (mail-header-xref headers)
9245 (not (string= (mail-header-xref headers) "")))
9246 (let ((case-fold-search t)
9249 (nnheader-narrow-to-headers)
9250 (goto-char (point-min))
9251 (if (or (and (eq (downcase (following-char)) ?x)
9252 (looking-at "Xref:"))
9253 (search-forward "\nXref:" nil t))
9255 (goto-char (1+ (match-end 0)))
9256 (setq xref (buffer-substring (point)
9257 (progn (end-of-line) (point))))
9258 (mail-header-set-xref headers xref))))))))
9260 (defun gnus-summary-insert-subject (id &optional old-header)
9261 "Find article ID and insert the summary line for that article."
9262 (let ((header (gnus-read-header id))
9263 (number (and (numberp id) id))
9266 ;; Rebuild the thread that this article is part of and go to the
9267 ;; article we have fetched.
9269 (when (setq pos (text-property-any
9270 (point-min) (point-max) 'gnus-number
9271 (mail-header-number old-header)))
9274 (gnus-data-remove (mail-header-number old-header))))
9275 (gnus-rebuild-thread (mail-header-id header))
9276 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9277 (when (and (numberp number)
9279 ;; We have to update the boundaries even if we can't fetch the
9280 ;; article if ID is a number -- so that the next `P' or `N'
9281 ;; command will fetch the previous (or next) article even
9282 ;; if the one we tried to fetch this time has been canceled.
9283 (and (> number gnus-newsgroup-end)
9284 (setq gnus-newsgroup-end number))
9285 (and (< number gnus-newsgroup-begin)
9286 (setq gnus-newsgroup-begin number))
9287 (setq gnus-newsgroup-unselected
9288 (delq number gnus-newsgroup-unselected)))
9289 ;; Report back a success?
9290 (and header (mail-header-number header))))
9292 (defun gnus-summary-work-articles (n)
9293 "Return a list of articles to be worked upon. The prefix argument,
9294 the list of process marked articles, and the current article will be
9295 taken into consideration."
9297 ((and n (numberp n))
9298 ;; A numerical prefix has been given.
9299 (let ((backward (< n 0))
9305 (push (setq article (gnus-summary-article-number))
9308 (gnus-summary-find-prev nil article)
9309 (gnus-summary-find-next nil article)))
9311 (nreverse articles)))
9312 ((and (boundp 'transient-mark-mode)
9315 ;; Work on the region between point and mark.
9316 (let ((max (max (point) (mark)))
9319 (goto-char (min (point) (mark)))
9322 (push (setq article (gnus-summary-article-number)) articles)
9323 (gnus-summary-find-next nil article)
9325 (nreverse articles))))
9326 (gnus-newsgroup-processable
9327 ;; There are process-marked articles present.
9328 (reverse gnus-newsgroup-processable))
9330 ;; Just return the current article.
9331 (list (gnus-summary-article-number)))))
9333 (defun gnus-summary-search-group (&optional backward use-level)
9334 "Search for next unread newsgroup.
9335 If optional argument BACKWARD is non-nil, search backward instead."
9337 (set-buffer gnus-group-buffer)
9338 (if (gnus-group-search-forward
9339 backward nil (if use-level (gnus-group-group-level) nil))
9340 (gnus-group-group-name))))
9342 (defun gnus-summary-best-group (&optional exclude-group)
9343 "Find the name of the best unread group.
9344 If EXCLUDE-GROUP, do not go to this group."
9346 (set-buffer gnus-group-buffer)
9348 (gnus-group-best-unread-group exclude-group))))
9350 (defun gnus-summary-find-next (&optional unread article backward)
9351 (if backward (gnus-summary-find-prev)
9352 (let* ((article (or article (gnus-summary-article-number)))
9353 (arts (gnus-data-find-list article))
9355 (when (or (not gnus-summary-check-current)
9357 (not (gnus-data-unread-p (car arts))))
9358 (setq arts (cdr arts)))
9363 (when (gnus-data-unread-p (car arts))
9364 (setq result (car arts)
9366 (setq arts (cdr arts)))
9369 (goto-char (gnus-data-pos result))
9370 (gnus-data-number result)))))
9372 (defun gnus-summary-find-prev (&optional unread article)
9373 (let* ((article (or article (gnus-summary-article-number)))
9374 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9376 (when (or (not gnus-summary-check-current)
9378 (not (gnus-data-unread-p (car arts))))
9379 (setq arts (cdr arts)))
9384 (and (gnus-data-unread-p (car arts))
9385 (setq result (car arts)
9387 (setq arts (cdr arts)))
9391 (goto-char (gnus-data-pos result))
9392 (gnus-data-number result)))))
9394 (defun gnus-summary-find-subject (subject &optional unread backward article)
9395 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9396 (article (or article (gnus-summary-article-number)))
9397 (articles (gnus-data-list backward))
9398 (arts (gnus-data-find-list article articles))
9400 (when (or (not gnus-summary-check-current)
9402 (not (gnus-data-unread-p (car arts))))
9403 (setq arts (cdr arts)))
9405 (and (or (not unread)
9406 (gnus-data-unread-p (car arts)))
9407 (vectorp (gnus-data-header (car arts)))
9409 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9410 (setq result (car arts)
9412 (setq arts (cdr arts)))
9414 (goto-char (gnus-data-pos result))
9415 (gnus-data-number result))))
9417 (defun gnus-summary-search-forward (&optional unread subject backward)
9418 "Search forward for an article.
9419 If UNREAD, look for unread articles. If SUBJECT, look for
9420 articles with that subject. If BACKWARD, search backward instead."
9421 (cond (subject (gnus-summary-find-subject subject unread backward))
9422 (backward (gnus-summary-find-prev unread))
9423 (t (gnus-summary-find-next unread))))
9425 (defun gnus-recenter (&optional n)
9426 "Center point in window and redisplay frame.
9427 Also do horizontal recentering."
9429 (when (and gnus-auto-center-summary
9430 (not (eq gnus-auto-center-summary 'vertical)))
9431 (gnus-horizontal-recenter))
9434 (defun gnus-summary-recenter ()
9435 "Center point in the summary window.
9436 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9437 displayed, no centering will be performed."
9438 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9439 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9440 (let* ((top (cond ((< (window-height) 4) 0)
9441 ((< (window-height) 7) 1)
9443 (height (1- (window-height)))
9444 (bottom (save-excursion (goto-char (point-max))
9445 (forward-line (- height))
9447 (window (get-buffer-window (current-buffer))))
9448 ;; The user has to want it.
9449 (when gnus-auto-center-summary
9450 (when (get-buffer-window gnus-article-buffer)
9451 ;; Only do recentering when the article buffer is displayed,
9452 ;; Set the window start to either `bottom', which is the biggest
9453 ;; possible valid number, or the second line from the top,
9454 ;; whichever is the least.
9456 window (min bottom (save-excursion
9457 (forward-line (- top)) (point)))))
9458 ;; Do horizontal recentering while we're at it.
9459 (when (and (get-buffer-window (current-buffer) t)
9460 (not (eq gnus-auto-center-summary 'vertical)))
9461 (let ((selected (selected-window)))
9462 (select-window (get-buffer-window (current-buffer) t))
9463 (gnus-summary-position-point)
9464 (gnus-horizontal-recenter)
9465 (select-window selected))))))
9467 (defun gnus-horizontal-recenter ()
9468 "Recenter the current buffer horizontally."
9469 (if (< (current-column) (/ (window-width) 2))
9470 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9471 (let* ((orig (point))
9472 (end (window-end (get-buffer-window (current-buffer) t)))
9474 ;; Find the longest line currently displayed in the window.
9475 (goto-char (window-start))
9476 (while (and (not (eobp))
9479 (setq max (max max (current-column)))
9482 ;; Scroll horizontally to center (sort of) the point.
9483 (if (> max (window-width))
9485 (get-buffer-window (current-buffer) t)
9486 (min (- (current-column) (/ (window-width) 3))
9487 (+ 2 (- max (window-width)))))
9488 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9491 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9492 (defun gnus-short-group-name (group &optional levels)
9493 "Collapse GROUP name LEVELS."
9500 (while (string-match "\\." group skip)
9501 (setq skip (match-end 0)
9504 (if (string-match ":" group)
9505 (setq foreign (substring group 0 (match-end 0))
9506 group (substring group (match-end 0))))
9508 (if (and (string-match "\\." group)
9509 (> levels (- gnus-group-uncollapsed-levels 1)))
9510 (setq name (concat name (substring group 0 1))
9511 group (substring group (match-end 0))
9513 name (concat name "."))
9514 (setq name (concat foreign name group)
9518 (defun gnus-summary-jump-to-group (newsgroup)
9519 "Move point to NEWSGROUP in group mode buffer."
9520 ;; Keep update point of group mode buffer if visible.
9521 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9522 (save-window-excursion
9523 ;; Take care of tree window mode.
9524 (if (get-buffer-window gnus-group-buffer)
9525 (pop-to-buffer gnus-group-buffer))
9526 (gnus-group-jump-to-group newsgroup))
9528 ;; Take care of tree window mode.
9529 (if (get-buffer-window gnus-group-buffer)
9530 (pop-to-buffer gnus-group-buffer)
9531 (set-buffer gnus-group-buffer))
9532 (gnus-group-jump-to-group newsgroup))))
9534 ;; This function returns a list of article numbers based on the
9535 ;; difference between the ranges of read articles in this group and
9536 ;; the range of active articles.
9537 (defun gnus-list-of-unread-articles (group)
9538 (let* ((read (gnus-info-read (gnus-get-info group)))
9539 (active (gnus-active group))
9542 ;; If none are read, then all are unread.
9544 (setq first (car active))
9545 ;; If the range of read articles is a single range, then the
9546 ;; first unread article is the article after the last read
9547 ;; article. Sounds logical, doesn't it?
9548 (if (not (listp (cdr read)))
9549 (setq first (1+ (cdr read)))
9550 ;; `read' is a list of ranges.
9551 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9556 (while (< first nlast)
9557 (setq unread (cons first unread))
9558 (setq first (1+ first))))
9559 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9560 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9561 (setq read (cdr read)))))
9562 ;; And add the last unread articles.
9563 (while (<= first last)
9564 (setq unread (cons first unread))
9565 (setq first (1+ first)))
9566 ;; Return the list of unread articles.
9569 (defun gnus-list-of-read-articles (group)
9570 "Return a list of unread, unticked and non-dormant articles."
9571 (let* ((info (gnus-get-info group))
9572 (marked (gnus-info-marks info))
9573 (active (gnus-active group)))
9575 (gnus-set-difference
9576 (gnus-sorted-complement
9577 (gnus-uncompress-range active)
9578 (gnus-list-of-unread-articles group))
9580 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9581 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9583 ;; Various summary commands
9585 (defun gnus-summary-universal-argument (arg)
9586 "Perform any operation on all articles that are process/prefixed."
9588 (gnus-set-global-variables)
9589 (let ((articles (gnus-summary-work-articles arg))
9596 (substitute-command-keys
9597 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9601 (message "Undefined key")
9605 (gnus-summary-goto-subject (setq article (pop articles)))
9606 (command-execute func)
9607 (gnus-summary-remove-process-mark article)))))
9608 (gnus-summary-position-point))
9610 (defun gnus-summary-toggle-truncation (&optional arg)
9611 "Toggle truncation of summary lines.
9612 With arg, turn line truncation on iff arg is positive."
9614 (setq truncate-lines
9615 (if (null arg) (not truncate-lines)
9616 (> (prefix-numeric-value arg) 0)))
9619 (defun gnus-summary-reselect-current-group (&optional all rescan)
9620 "Exit and then reselect the current newsgroup.
9621 The prefix argument ALL means to select all articles."
9623 (gnus-set-global-variables)
9624 (let ((current-subject (gnus-summary-article-number))
9625 (group gnus-newsgroup-name))
9626 (setq gnus-newsgroup-begin nil)
9628 ;; We have to adjust the point of group mode buffer because the
9629 ;; current point was moved to the next unread newsgroup by
9631 (gnus-summary-jump-to-group group)
9634 (gnus-group-get-new-news-this-group 1)))
9635 (gnus-group-read-group all t)
9636 (gnus-summary-goto-subject current-subject)))
9638 (defun gnus-summary-rescan-group (&optional all)
9639 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9641 (gnus-summary-reselect-current-group all t))
9643 (defun gnus-summary-update-info ()
9644 (let* ((group gnus-newsgroup-name))
9645 (when gnus-newsgroup-kill-headers
9646 (setq gnus-newsgroup-killed
9647 (gnus-compress-sequence
9649 (gnus-set-sorted-intersection
9650 (gnus-uncompress-range gnus-newsgroup-killed)
9651 (setq gnus-newsgroup-unselected
9652 (sort gnus-newsgroup-unselected '<)))
9653 (setq gnus-newsgroup-unreads
9654 (sort gnus-newsgroup-unreads '<))) t)))
9655 (unless (listp (cdr gnus-newsgroup-killed))
9656 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9657 (let ((headers gnus-newsgroup-headers))
9658 (run-hooks 'gnus-exit-group-hook)
9659 (unless gnus-save-score
9660 (setq gnus-newsgroup-scored nil))
9661 ;; Set the new ranges of read articles.
9662 (gnus-update-read-articles
9663 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9664 ;; Set the current article marks.
9666 ;; Do the cross-ref thing.
9667 (when gnus-use-cross-reference
9668 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9669 ;; Do adaptive scoring, and possibly save score files.
9670 (when gnus-newsgroup-adaptive
9671 (gnus-score-adaptive))
9672 (when gnus-use-scoring
9674 ;; Do not switch windows but change the buffer to work.
9675 (set-buffer gnus-group-buffer)
9676 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9677 (gnus-group-update-group group)))))
9679 (defun gnus-summary-exit (&optional temporary)
9680 "Exit reading current newsgroup, and then return to group selection mode.
9681 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9683 (gnus-set-global-variables)
9684 (gnus-kill-save-kill-buffer)
9685 (let* ((group gnus-newsgroup-name)
9686 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9688 (buf (current-buffer)))
9690 (run-hooks 'gnus-summary-prepare-exit-hook))
9691 ;; If we have several article buffers, we kill them at exit.
9692 (unless gnus-single-article-buffer
9693 (gnus-kill-buffer gnus-article-buffer)
9694 (gnus-kill-buffer gnus-original-article-buffer)
9695 (setq gnus-article-current nil))
9696 (when gnus-use-cache
9697 (gnus-cache-possibly-remove-articles)
9698 (gnus-cache-save-buffers))
9699 (when gnus-use-trees
9700 (gnus-tree-close group))
9701 ;; Make all changes in this group permanent.
9703 (gnus-summary-update-info))
9704 (gnus-close-group group)
9705 ;; Make sure where I was, and go to next newsgroup.
9706 (set-buffer gnus-group-buffer)
9708 (gnus-group-jump-to-group group)
9709 (gnus-group-next-unread-group 1))
9710 (run-hooks 'gnus-summary-exit-hook)
9711 (unless gnus-single-article-buffer
9712 (setq gnus-article-current nil))
9715 ;; If we have several article buffers, we kill them at exit.
9716 (unless gnus-single-article-buffer
9717 (gnus-kill-buffer gnus-article-buffer)
9718 (gnus-kill-buffer gnus-original-article-buffer)
9719 (setq gnus-article-current nil))
9721 (if (not gnus-kill-summary-on-exit)
9722 (gnus-deaden-summary)
9723 ;; We set all buffer-local variables to nil. It is unclear why
9724 ;; this is needed, but if we don't, buffer-local variables are
9725 ;; not garbage-collected, it seems. This would the lead to en
9726 ;; ever-growing Emacs.
9727 (gnus-summary-clear-local-variables)
9728 (when (get-buffer gnus-article-buffer)
9729 (bury-buffer gnus-article-buffer))
9730 ;; We clear the global counterparts of the buffer-local
9731 ;; variables as well, just to be on the safe side.
9732 (gnus-configure-windows 'group 'force)
9733 (gnus-summary-clear-local-variables)
9734 ;; Return to group mode buffer.
9735 (if (eq mode 'gnus-summary-mode)
9736 (gnus-kill-buffer buf)))
9737 (setq gnus-current-select-method gnus-select-method)
9738 (pop-to-buffer gnus-group-buffer)
9739 ;; Clear the current group name.
9740 (if (not quit-config)
9742 (gnus-group-jump-to-group group)
9743 (gnus-group-next-unread-group 1)
9744 (gnus-configure-windows 'group 'force))
9745 (if (not (buffer-name (car quit-config)))
9746 (gnus-configure-windows 'group 'force)
9747 (set-buffer (car quit-config))
9748 (and (eq major-mode 'gnus-summary-mode)
9749 (gnus-set-global-variables))
9750 (gnus-configure-windows (cdr quit-config))))
9752 (setq gnus-newsgroup-name nil)))))
9754 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9755 (defun gnus-summary-exit-no-update (&optional no-questions)
9756 "Quit reading current newsgroup without updating read article info."
9758 (gnus-set-global-variables)
9759 (let* ((group gnus-newsgroup-name)
9760 (quit-config (gnus-group-quit-config group)))
9761 (when (or no-questions
9763 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9764 ;; If we have several article buffers, we kill them at exit.
9765 (unless gnus-single-article-buffer
9766 (gnus-kill-buffer gnus-article-buffer)
9767 (gnus-kill-buffer gnus-original-article-buffer)
9768 (setq gnus-article-current nil))
9769 (if (not gnus-kill-summary-on-exit)
9770 (gnus-deaden-summary)
9771 (gnus-close-group group)
9772 (gnus-summary-clear-local-variables)
9773 (set-buffer gnus-group-buffer)
9774 (gnus-summary-clear-local-variables)
9775 (when (get-buffer gnus-summary-buffer)
9776 (kill-buffer gnus-summary-buffer)))
9777 (unless gnus-single-article-buffer
9778 (setq gnus-article-current nil))
9779 (when gnus-use-trees
9780 (gnus-tree-close group))
9781 (when (get-buffer gnus-article-buffer)
9782 (bury-buffer gnus-article-buffer))
9783 ;; Return to the group buffer.
9784 (gnus-configure-windows 'group 'force)
9785 ;; Clear the current group name.
9786 (setq gnus-newsgroup-name nil)
9787 (when (equal (gnus-group-group-name) group)
9788 (gnus-group-next-unread-group 1))
9790 (if (not (buffer-name (car quit-config)))
9791 (gnus-configure-windows 'group 'force)
9792 (set-buffer (car quit-config))
9793 (when (eq major-mode 'gnus-summary-mode)
9794 (gnus-set-global-variables))
9795 (gnus-configure-windows (cdr quit-config)))))))
9799 (defvar gnus-dead-summary-mode-map nil)
9801 (if gnus-dead-summary-mode-map
9803 (setq gnus-dead-summary-mode-map (make-keymap))
9804 (suppress-keymap gnus-dead-summary-mode-map)
9805 (substitute-key-definition
9806 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9807 (let ((keys '("\C-d" "\r" "\177")))
9809 (define-key gnus-dead-summary-mode-map
9810 (pop keys) 'gnus-summary-wake-up-the-dead))))
9812 (defvar gnus-dead-summary-mode nil
9813 "Minor mode for Gnus summary buffers.")
9815 (defun gnus-dead-summary-mode (&optional arg)
9816 "Minor mode for Gnus summary buffers."
9818 (when (eq major-mode 'gnus-summary-mode)
9819 (make-local-variable 'gnus-dead-summary-mode)
9820 (setq gnus-dead-summary-mode
9821 (if (null arg) (not gnus-dead-summary-mode)
9822 (> (prefix-numeric-value arg) 0)))
9823 (when gnus-dead-summary-mode
9824 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9825 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9826 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9827 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9828 minor-mode-map-alist)))))
9830 (defun gnus-deaden-summary ()
9831 "Make the current summary buffer into a dead summary buffer."
9832 ;; Kill any previous dead summary buffer.
9833 (when (and gnus-dead-summary
9834 (buffer-name gnus-dead-summary))
9836 (set-buffer gnus-dead-summary)
9837 (when gnus-dead-summary-mode
9838 (kill-buffer (current-buffer)))))
9839 ;; Make this the current dead summary.
9840 (setq gnus-dead-summary (current-buffer))
9841 (gnus-dead-summary-mode 1)
9842 (let ((name (buffer-name)))
9843 (when (string-match "Summary" name)
9845 (concat (substring name 0 (match-beginning 0)) "Dead "
9846 (substring name (match-beginning 0))) t))))
9848 (defun gnus-kill-or-deaden-summary (buffer)
9849 "Kill or deaden the summary BUFFER."
9850 (cond (gnus-kill-summary-on-exit
9851 (when (and gnus-use-trees
9852 (and (get-buffer buffer)
9853 (buffer-name (get-buffer buffer))))
9855 (set-buffer (get-buffer buffer))
9856 (gnus-tree-close gnus-newsgroup-name)))
9857 (gnus-kill-buffer buffer))
9858 ((and (get-buffer buffer)
9859 (buffer-name (get-buffer buffer)))
9862 (gnus-deaden-summary)))))
9864 (defun gnus-summary-wake-up-the-dead (&rest args)
9865 "Wake up the dead summary buffer."
9867 (gnus-dead-summary-mode -1)
9868 (let ((name (buffer-name)))
9869 (when (string-match "Dead " name)
9871 (concat (substring name 0 (match-beginning 0))
9872 (substring name (match-end 0))) t)))
9873 (gnus-message 3 "This dead summary is now alive again"))
9875 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9876 (defun gnus-summary-fetch-faq (&optional faq-dir)
9877 "Fetch the FAQ for the current group.
9878 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9882 (if current-prefix-arg
9884 "Faq dir: " (and (listp gnus-group-faq-directory)
9885 gnus-group-faq-directory)))))
9886 (let (gnus-faq-buffer)
9887 (and (setq gnus-faq-buffer
9888 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9889 (gnus-configure-windows 'summary-faq))))
9891 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9892 (defun gnus-summary-describe-group (&optional force)
9893 "Describe the current newsgroup."
9895 (gnus-group-describe-group force gnus-newsgroup-name))
9897 (defun gnus-summary-describe-briefly ()
9898 "Describe summary mode commands briefly."
9901 (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")))
9903 ;; Walking around group mode buffer from summary mode.
9905 (defun gnus-summary-next-group (&optional no-article target-group backward)
9906 "Exit current newsgroup and then select next unread newsgroup.
9907 If prefix argument NO-ARTICLE is non-nil, no article is selected
9908 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9909 previous group instead."
9911 (gnus-set-global-variables)
9912 (let ((current-group gnus-newsgroup-name)
9913 (current-buffer (current-buffer))
9915 ;; First we semi-exit this group to update Xrefs and all variables.
9916 ;; We can't do a real exit, because the window conf must remain
9917 ;; the same in case the user is prompted for info, and we don't
9918 ;; want the window conf to change before that...
9919 (gnus-summary-exit t)
9920 (while (not entered)
9921 ;; Then we find what group we are supposed to enter.
9922 (set-buffer gnus-group-buffer)
9923 (gnus-group-jump-to-group current-group)
9926 (if (eq gnus-keep-same-level 'best)
9927 (gnus-summary-best-group gnus-newsgroup-name)
9928 (gnus-summary-search-group backward gnus-keep-same-level))))
9929 (if (not target-group)
9930 ;; There are no further groups, so we return to the group
9933 (gnus-message 5 "Returning to the group buffer")
9935 (set-buffer current-buffer)
9936 (gnus-summary-exit))
9937 ;; We try to enter the target group.
9938 (gnus-group-jump-to-group target-group)
9939 (let ((unreads (gnus-group-group-unread)))
9940 (if (and (or (eq t unreads)
9941 (and unreads (not (zerop unreads))))
9942 (gnus-summary-read-group
9943 target-group nil no-article current-buffer))
9945 (setq current-group target-group
9946 target-group nil)))))))
9948 (defun gnus-summary-prev-group (&optional no-article)
9949 "Exit current newsgroup and then select previous unread newsgroup.
9950 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9952 (gnus-summary-next-group no-article nil t))
9954 ;; Walking around summary lines.
9956 (defun gnus-summary-first-subject (&optional unread)
9957 "Go to the first unread subject.
9958 If UNREAD is non-nil, go to the first unread article.
9959 Returns the article selected or nil if there are no unread articles."
9964 ((null gnus-newsgroup-data)
9965 (gnus-message 3 "No articles in the group")
9967 ;; Pick the first article.
9969 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9970 (gnus-data-number (car gnus-newsgroup-data)))
9971 ;; No unread articles.
9972 ((null gnus-newsgroup-unreads)
9973 (gnus-message 3 "No more unread articles")
9975 ;; Find the first unread article.
9977 (let ((data gnus-newsgroup-data))
9979 (not (gnus-data-unread-p (car data))))
9980 (setq data (cdr data)))
9983 (goto-char (gnus-data-pos (car data)))
9984 (gnus-data-number (car data)))))))
9985 (gnus-summary-position-point)))
9987 (defun gnus-summary-next-subject (n &optional unread dont-display)
9988 "Go to next N'th summary line.
9989 If N is negative, go to the previous N'th subject line.
9990 If UNREAD is non-nil, only unread articles are selected.
9991 The difference between N and the actual number of steps taken is
9994 (let ((backward (< n 0))
9998 (gnus-summary-find-prev unread)
9999 (gnus-summary-find-next unread)))
10001 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10002 (if unread " unread" "")))
10003 (unless dont-display
10004 (gnus-summary-recenter)
10005 (gnus-summary-position-point))
10008 (defun gnus-summary-next-unread-subject (n)
10009 "Go to next N'th unread summary line."
10011 (gnus-summary-next-subject n t))
10013 (defun gnus-summary-prev-subject (n &optional unread)
10014 "Go to previous N'th summary line.
10015 If optional argument UNREAD is non-nil, only unread article is selected."
10017 (gnus-summary-next-subject (- n) unread))
10019 (defun gnus-summary-prev-unread-subject (n)
10020 "Go to previous N'th unread summary line."
10022 (gnus-summary-next-subject (- n) t))
10024 (defun gnus-summary-goto-subject (article &optional force silent)
10025 "Go the subject line of ARTICLE.
10026 If FORCE, also allow jumping to articles not currently shown."
10028 (data (gnus-data-find article)))
10029 ;; We read in the article if we have to.
10032 (gnus-summary-insert-subject article)
10033 (setq data (gnus-data-find article)))
10038 (gnus-message 3 "Can't find article %d" article))
10040 (goto-char (gnus-data-pos data))
10043 ;; Walking around summary lines with displaying articles.
10045 (defun gnus-summary-expand-window (&optional arg)
10046 "Make the summary buffer take up the entire Emacs frame.
10047 Given a prefix, will force an `article' buffer configuration."
10049 (gnus-set-global-variables)
10051 (gnus-configure-windows 'article 'force)
10052 (gnus-configure-windows 'summary 'force)))
10054 (defun gnus-summary-display-article (article &optional all-header)
10055 "Display ARTICLE in article buffer."
10056 (gnus-set-global-variables)
10060 (if gnus-summary-display-article-function
10061 (funcall gnus-summary-display-article-function article all-header)
10062 (gnus-article-prepare article all-header))
10063 (run-hooks 'gnus-select-article-hook)
10064 (gnus-summary-recenter)
10065 (gnus-summary-goto-subject article)
10066 (when gnus-use-trees
10067 (gnus-possibly-generate-tree article)
10068 (gnus-highlight-selected-tree article))
10069 ;; Successfully display article.
10070 (gnus-article-set-window-start
10071 (cdr (assq article gnus-newsgroup-bookmarks)))
10074 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10075 "Select the current article.
10076 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10077 non-nil, the article will be re-fetched even if it already present in
10078 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10080 (let ((article (or article (gnus-summary-article-number)))
10081 (all-headers (not (not all-headers))) ;Must be T or NIL.
10082 gnus-summary-display-article-function
10085 (gnus-summary-article-pseudo-p article)
10086 (error "This is a pseudo-article."))
10089 (set-buffer gnus-summary-buffer)
10090 (if (or (and gnus-single-article-buffer
10091 (or (null gnus-current-article)
10092 (null gnus-article-current)
10093 (null (get-buffer gnus-article-buffer))
10094 (not (eq article (cdr gnus-article-current)))
10095 (not (equal (car gnus-article-current)
10096 gnus-newsgroup-name))))
10097 (and (not gnus-single-article-buffer)
10098 (or (null gnus-current-article)
10099 (not (eq gnus-current-article article))))
10101 ;; The requested article is different from the current article.
10103 (gnus-summary-display-article article all-headers)
10104 (setq did article))
10105 (if (or all-headers gnus-show-all-headers)
10106 (gnus-article-show-all-headers))
10109 (gnus-article-set-window-start
10110 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10112 (defun gnus-summary-set-current-mark (&optional current-mark)
10113 "Obsolete function."
10116 (defun gnus-summary-next-article (&optional unread subject backward push)
10117 "Select the next article.
10118 If UNREAD, only unread articles are selected.
10119 If SUBJECT, only articles with SUBJECT are selected.
10120 If BACKWARD, the previous article is selected instead of the next."
10122 (gnus-set-global-variables)
10124 ;; Is there such an article?
10125 ((and (gnus-summary-search-forward unread subject backward)
10126 (or (gnus-summary-display-article (gnus-summary-article-number))
10127 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10128 (gnus-summary-position-point))
10129 ;; If not, we try the first unread, if that is wanted.
10131 gnus-auto-select-same
10132 (or (gnus-summary-first-unread-article)
10133 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10134 (gnus-summary-position-point)
10135 (gnus-message 6 "Wrapped"))
10136 ;; Try to get next/previous article not displayed in this group.
10137 ((and gnus-auto-extend-newsgroup
10138 (not unread) (not subject))
10139 (gnus-summary-goto-article
10140 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10142 ;; Go to next/previous group.
10144 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10145 (gnus-summary-jump-to-group gnus-newsgroup-name))
10146 (let ((cmd last-command-char)
10148 (if (eq gnus-keep-same-level 'best)
10149 (gnus-summary-best-group gnus-newsgroup-name)
10150 (gnus-summary-search-group backward gnus-keep-same-level))))
10151 ;; For some reason, the group window gets selected. We change
10153 (select-window (get-buffer-window (current-buffer)))
10154 ;; Select next unread newsgroup automagically.
10156 ((not gnus-auto-select-next)
10157 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10158 ((or (eq gnus-auto-select-next 'quietly)
10159 (and (eq gnus-auto-select-next 'slightly-quietly)
10161 (and (eq gnus-auto-select-next 'almost-quietly)
10162 (gnus-summary-last-article-p)))
10164 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10165 (gnus-summary-exit)
10166 (gnus-message 7 "No more%s articles (%s)..."
10167 (if unread " unread" "")
10168 (if group (concat "selecting " group)
10170 (gnus-summary-next-group nil group backward)))
10172 (gnus-summary-walk-group-buffer
10173 gnus-newsgroup-name cmd unread backward)))))))
10175 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10176 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10177 (?\C-p (gnus-group-prev-unread-group 1))))
10178 keve key group ended)
10180 (set-buffer gnus-group-buffer)
10181 (gnus-summary-jump-to-group from-group)
10183 (if (eq gnus-keep-same-level 'best)
10184 (gnus-summary-best-group gnus-newsgroup-name)
10185 (gnus-summary-search-group backward gnus-keep-same-level))))
10188 5 "No more%s articles%s" (if unread " unread" "")
10190 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10191 (format " (Type %s for %s [%s])"
10192 (single-key-description cmd) group
10193 (car (gnus-gethash group gnus-newsrc-hashtb)))
10194 (format " (Type %s to exit %s)"
10195 (single-key-description cmd)
10196 gnus-newsgroup-name)))
10197 ;; Confirm auto selection.
10198 (setq key (car (setq keve (gnus-read-event-char))))
10201 ((assq key keystrokes)
10202 (let ((obuf (current-buffer)))
10203 (switch-to-buffer gnus-group-buffer)
10205 (gnus-group-jump-to-group group))
10206 (eval (cadr (assq key keystrokes)))
10207 (setq group (gnus-group-group-name))
10208 (switch-to-buffer obuf))
10211 (if (or (not group)
10212 (gnus-ephemeral-group-p gnus-newsgroup-name))
10213 (gnus-summary-exit)
10214 (gnus-summary-next-group nil group backward)))
10216 (push (cdr keve) unread-command-events))))))
10218 (defun gnus-read-event-char ()
10219 "Get the next event."
10220 (let ((event (read-event)))
10221 (cons (and (numberp event) event) event)))
10223 (defun gnus-summary-next-unread-article ()
10224 "Select unread article after current one."
10226 (gnus-summary-next-article t (and gnus-auto-select-same
10227 (gnus-summary-article-subject))))
10229 (defun gnus-summary-prev-article (&optional unread subject)
10230 "Select the article after the current one.
10231 If UNREAD is non-nil, only unread articles are selected."
10233 (gnus-summary-next-article unread subject t))
10235 (defun gnus-summary-prev-unread-article ()
10236 "Select unred article before current one."
10238 (gnus-summary-prev-article t (and gnus-auto-select-same
10239 (gnus-summary-article-subject))))
10241 (defun gnus-summary-next-page (&optional lines circular)
10242 "Show next page of the selected article.
10243 If at the end of the current article, select the next article.
10244 LINES says how many lines should be scrolled up.
10246 If CIRCULAR is non-nil, go to the start of the article instead of
10247 selecting the next article when reaching the end of the current
10250 (setq gnus-summary-buffer (current-buffer))
10251 (gnus-set-global-variables)
10252 (let ((article (gnus-summary-article-number))
10254 (gnus-configure-windows 'article)
10255 (if (or (null gnus-current-article)
10256 (null gnus-article-current)
10257 (/= article (cdr gnus-article-current))
10258 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10259 ;; Selected subject is different from current article's.
10260 (gnus-summary-display-article article)
10261 (gnus-eval-in-buffer-window
10262 gnus-article-buffer
10263 (setq endp (gnus-article-next-page lines)))
10266 (gnus-summary-beginning-of-article))
10268 (gnus-message 3 "End of message"))
10270 (if (and (eq gnus-summary-goto-unread 'never)
10271 (not (gnus-summary-last-article-p article)))
10272 (gnus-summary-next-article)
10273 (gnus-summary-next-unread-article))))))
10274 (gnus-summary-recenter)
10275 (gnus-summary-position-point)))
10277 (defun gnus-summary-prev-page (&optional lines)
10278 "Show previous page of selected article.
10279 Argument LINES specifies lines to be scrolled down."
10281 (gnus-set-global-variables)
10282 (let ((article (gnus-summary-article-number)))
10283 (gnus-configure-windows 'article)
10284 (if (or (null gnus-current-article)
10285 (null gnus-article-current)
10286 (/= article (cdr gnus-article-current))
10287 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10288 ;; Selected subject is different from current article's.
10289 (gnus-summary-display-article article)
10290 (gnus-summary-recenter)
10291 (gnus-eval-in-buffer-window gnus-article-buffer
10292 (gnus-article-prev-page lines))))
10293 (gnus-summary-position-point))
10295 (defun gnus-summary-scroll-up (lines)
10296 "Scroll up (or down) one line current article.
10297 Argument LINES specifies lines to be scrolled up (or down if negative)."
10299 (gnus-set-global-variables)
10300 (gnus-configure-windows 'article)
10301 (gnus-summary-show-thread)
10302 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10303 (gnus-eval-in-buffer-window
10304 gnus-article-buffer
10306 (if (gnus-article-next-page lines)
10307 (gnus-message 3 "End of message")))
10309 (gnus-article-prev-page (- lines))))))
10310 (gnus-summary-recenter)
10311 (gnus-summary-position-point))
10313 (defun gnus-summary-next-same-subject ()
10314 "Select next article which has the same subject as current one."
10316 (gnus-set-global-variables)
10317 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10319 (defun gnus-summary-prev-same-subject ()
10320 "Select previous article which has the same subject as current one."
10322 (gnus-set-global-variables)
10323 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10325 (defun gnus-summary-next-unread-same-subject ()
10326 "Select next unread article which has the same subject as current one."
10328 (gnus-set-global-variables)
10329 (gnus-summary-next-article t (gnus-summary-article-subject)))
10331 (defun gnus-summary-prev-unread-same-subject ()
10332 "Select previous unread article which has the same subject as current one."
10334 (gnus-set-global-variables)
10335 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10337 (defun gnus-summary-first-unread-article ()
10338 "Select the first unread article.
10339 Return nil if there are no unread articles."
10341 (gnus-set-global-variables)
10343 (if (gnus-summary-first-subject t)
10345 (gnus-summary-show-thread)
10346 (gnus-summary-first-subject t)
10347 (gnus-summary-display-article (gnus-summary-article-number))))
10348 (gnus-summary-position-point)))
10350 (defun gnus-summary-best-unread-article ()
10351 "Select the unread article with the highest score."
10353 (gnus-set-global-variables)
10354 (let ((best -1000000)
10355 (data gnus-newsgroup-data)
10358 (and (gnus-data-unread-p (car data))
10360 (gnus-summary-article-score (gnus-data-number (car data))))
10363 article (gnus-data-number (car data))))
10364 (setq data (cdr data)))
10367 (gnus-summary-goto-article article)
10368 (error "No unread articles"))
10369 (gnus-summary-position-point))))
10371 (defun gnus-summary-last-subject ()
10372 "Go to the last displayed subject line in the group."
10373 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10375 (gnus-summary-goto-subject article))))
10377 (defun gnus-summary-goto-article (article &optional all-headers force)
10378 "Fetch ARTICLE and display it if it exists.
10379 If ALL-HEADERS is non-nil, no header lines are hidden."
10385 (mapcar (lambda (number) (list (int-to-string number)))
10386 gnus-newsgroup-limit)))
10390 (if (gnus-summary-goto-subject article force)
10391 (gnus-summary-display-article article all-headers)
10392 (gnus-message 4 "Couldn't go to article %s" article) nil)
10393 (gnus-summary-position-point)))
10395 (defun gnus-summary-goto-last-article ()
10396 "Go to the previously read article."
10399 (and gnus-last-article
10400 (gnus-summary-goto-article gnus-last-article))
10401 (gnus-summary-position-point)))
10403 (defun gnus-summary-pop-article (number)
10404 "Pop one article off the history and go to the previous.
10405 NUMBER articles will be popped off."
10408 (setq gnus-newsgroup-history
10409 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10411 (gnus-summary-goto-article (car to))
10412 (error "Article history empty")))
10413 (gnus-summary-position-point))
10415 ;; Summary commands and functions for limiting the summary buffer.
10417 (defun gnus-summary-limit-to-articles (n)
10418 "Limit the summary buffer to the next N articles.
10419 If not given a prefix, use the process marked articles instead."
10421 (gnus-set-global-variables)
10423 (let ((articles (gnus-summary-work-articles n)))
10424 (setq gnus-newsgroup-processable nil)
10425 (gnus-summary-limit articles))
10426 (gnus-summary-position-point)))
10428 (defun gnus-summary-pop-limit (&optional total)
10429 "Restore the previous limit.
10430 If given a prefix, remove all limits."
10432 (gnus-set-global-variables)
10434 (setq gnus-newsgroup-limits
10435 (list (mapcar (lambda (h) (mail-header-number h))
10436 gnus-newsgroup-headers))))
10437 (unless gnus-newsgroup-limits
10438 (error "No limit to pop"))
10440 (gnus-summary-limit nil 'pop)
10441 (gnus-summary-position-point)))
10443 (defun gnus-summary-limit-to-subject (subject &optional header)
10444 "Limit the summary buffer to articles that have subjects that match a regexp."
10445 (interactive "sRegexp: ")
10447 (setq header "subject"))
10448 (when (not (equal "" subject))
10450 (let ((articles (gnus-summary-find-matching
10451 (or header "subject") subject 'all)))
10452 (or articles (error "Found no matches for \"%s\"" subject))
10453 (gnus-summary-limit articles))
10454 (gnus-summary-position-point))))
10456 (defun gnus-summary-limit-to-author (from)
10457 "Limit the summary buffer to articles that have authors that match a regexp."
10458 (interactive "sRegexp: ")
10459 (gnus-summary-limit-to-subject from "from"))
10461 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10463 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10465 (defun gnus-summary-limit-to-unread (&optional all)
10466 "Limit the summary buffer to articles that are not marked as read.
10467 If ALL is non-nil, limit strictly to unread articles."
10470 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10471 (gnus-summary-limit-to-marks
10472 ;; Concat all the marks that say that an article is read and have
10474 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10475 gnus-killed-mark gnus-kill-file-mark
10476 gnus-low-score-mark gnus-expirable-mark
10477 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10480 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10481 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10483 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10484 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10485 If REVERSE, limit the summary buffer to articles that are not marked
10486 with MARKS. MARKS can either be a string of marks or a list of marks.
10487 Returns how many articles were removed."
10488 (interactive "sMarks: ")
10489 (gnus-set-global-variables)
10491 (let ((data gnus-newsgroup-data)
10492 (marks (if (listp marks) marks
10493 (append marks nil))) ; Transform to list.
10496 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10497 (memq (gnus-data-mark (car data)) marks))
10498 (setq articles (cons (gnus-data-number (car data)) articles)))
10499 (setq data (cdr data)))
10500 (gnus-summary-limit articles))
10501 (gnus-summary-position-point)))
10503 (defun gnus-summary-limit-to-score (&optional score)
10504 "Limit to articles with score at or above SCORE."
10506 (gnus-set-global-variables)
10507 (setq score (if score
10508 (prefix-numeric-value score)
10509 (or gnus-summary-default-score 0)))
10510 (let ((data gnus-newsgroup-data)
10513 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10515 (push (gnus-data-number (car data)) articles))
10516 (setq data (cdr data)))
10518 (gnus-summary-limit articles)
10519 (gnus-summary-position-point))))
10521 (defun gnus-summary-limit-include-dormant ()
10522 "Display all the hidden articles that are marked as dormant."
10524 (gnus-set-global-variables)
10525 (or gnus-newsgroup-dormant
10526 (error "There are no dormant articles in this group"))
10528 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10529 (gnus-summary-position-point)))
10531 (defun gnus-summary-limit-exclude-dormant ()
10532 "Hide all dormant articles."
10534 (gnus-set-global-variables)
10536 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10537 (gnus-summary-position-point)))
10539 (defun gnus-summary-limit-exclude-childless-dormant ()
10540 "Hide all dormant articles that have no children."
10542 (gnus-set-global-variables)
10543 (let ((data (gnus-data-list t))
10544 articles d children)
10545 ;; Find all articles that are either not dormant or have
10547 (while (setq d (pop data))
10548 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10549 (and (setq children
10550 (gnus-article-children (gnus-data-number d)))
10553 (when (memq (car children) articles)
10558 (push (gnus-data-number d) articles)))
10559 ;; Do the limiting.
10561 (gnus-summary-limit articles)
10562 (gnus-summary-position-point))))
10564 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10565 "Mark all unread excluded articles as read.
10566 If ALL, mark even excluded ticked and dormants as read."
10568 (let ((articles (gnus-sorted-complement
10570 (mapcar (lambda (h) (mail-header-number h))
10571 gnus-newsgroup-headers)
10573 (sort gnus-newsgroup-limit '<)))
10575 (setq gnus-newsgroup-unreads nil)
10577 (setq gnus-newsgroup-dormant nil
10578 gnus-newsgroup-marked nil
10579 gnus-newsgroup-reads
10581 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10582 gnus-newsgroup-reads))
10583 (while (setq article (pop articles))
10584 (unless (or (memq article gnus-newsgroup-dormant)
10585 (memq article gnus-newsgroup-marked))
10586 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10588 (defun gnus-summary-limit (articles &optional pop)
10590 ;; We pop the previous limit off the stack and use that.
10591 (setq articles (car gnus-newsgroup-limits)
10592 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10593 ;; We use the new limit, so we push the old limit on the stack.
10594 (setq gnus-newsgroup-limits
10595 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10597 (setq gnus-newsgroup-limit articles)
10598 (let ((total (length gnus-newsgroup-data))
10599 (data (gnus-data-find-list (gnus-summary-article-number)))
10601 ;; This will do all the work of generating the new summary buffer
10602 ;; according to the new limit.
10603 (gnus-summary-prepare)
10604 ;; Hide any threads, possibly.
10605 (and gnus-show-threads
10606 gnus-thread-hide-subtree
10607 (gnus-summary-hide-all-threads))
10608 ;; Try to return to the article you were at, or one in the
10611 ;; We try to find some article after the current one.
10613 (and (gnus-summary-goto-subject
10614 (gnus-data-number (car data)) nil t)
10617 (setq data (cdr data))))
10619 ;; If there is no data, that means that we were after the last
10620 ;; article. The same goes when we can't find any articles
10621 ;; after the current one.
10623 (goto-char (point-max))
10624 (gnus-summary-find-prev)))
10625 ;; We return how many articles were removed from the summary
10626 ;; buffer as a result of the new limit.
10627 (- total (length gnus-newsgroup-data))))
10629 (defsubst gnus-cut-thread (thread)
10630 "Go forwards in the thread until we find an article that we want to display."
10631 (when (eq gnus-fetch-old-headers 'some)
10632 ;; Deal with old-fetched headers.
10634 (memq (mail-header-number (car thread))
10635 gnus-newsgroup-ancient)
10636 (<= (length (cdr thread)) 1))
10637 (setq thread (cadr thread))))
10638 ;; Deal with sparse threads.
10639 (when (or (eq gnus-build-sparse-threads 'some)
10640 (eq gnus-build-sparse-threads 'more))
10642 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10643 (= (length (cdr thread)) 1))
10644 (setq thread (cadr thread))))
10647 (defun gnus-cut-threads (threads)
10648 "Cut off all uninteresting articles from the beginning of threads."
10649 (when (or (eq gnus-fetch-old-headers 'some)
10650 (eq gnus-build-sparse-threads 'some)
10651 (eq gnus-build-sparse-threads 'more))
10652 (let ((th threads))
10654 (setcar th (gnus-cut-thread (car th)))
10655 (setq th (cdr th)))))
10656 ;; Remove nixed out threads.
10657 (delq nil threads))
10659 (defun gnus-summary-initial-limit (&optional show-if-empty)
10660 "Figure out what the initial limit is supposed to be on group entry.
10661 This entails weeding out unwanted dormants, low-scored articles,
10662 fetch-old-headers verbiage, and so on."
10663 ;; Most groups have nothing to remove.
10664 (if (or gnus-inhibit-limiting
10665 (and (null gnus-newsgroup-dormant)
10666 (not (eq gnus-fetch-old-headers 'some))
10667 (null gnus-summary-expunge-below)
10668 (not (eq gnus-build-sparse-threads 'some))
10669 (not (eq gnus-build-sparse-threads 'more))
10670 (null gnus-thread-expunge-below)
10671 (not gnus-use-nocem)))
10673 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10674 (setq gnus-newsgroup-limit nil)
10677 (unless (car (symbol-value node))
10678 ;; These threads have no parents -- they are roots.
10679 (let ((nodes (cdr (symbol-value node)))
10682 (if (and gnus-thread-expunge-below
10683 (< (gnus-thread-total-score (car nodes))
10684 gnus-thread-expunge-below))
10685 (gnus-expunge-thread (pop nodes))
10686 (setq thread (pop nodes))
10687 (gnus-summary-limit-children thread))))))
10688 gnus-newsgroup-dependencies)
10689 ;; If this limitation resulted in an empty group, we might
10690 ;; pop the previous limit and use it instead.
10691 (when (and (not gnus-newsgroup-limit)
10693 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10694 gnus-newsgroup-limit))
10696 (defun gnus-summary-limit-children (thread)
10697 "Return 1 if this subthread is visible and 0 if it is not."
10698 ;; First we get the number of visible children to this thread. This
10699 ;; is done by recursing down the thread using this function, so this
10700 ;; will really go down to a leaf article first, before slowly
10701 ;; working its way up towards the root.
10705 (apply '+ (mapcar 'gnus-summary-limit-children
10708 (number (mail-header-number (car thread)))
10711 ;; If this article is dormant and has absolutely no visible
10712 ;; children, then this article isn't visible.
10713 (and (memq number gnus-newsgroup-dormant)
10715 ;; If this is a "fetch-old-headered" and there is only one
10716 ;; visible child (or less), then we don't want this article.
10717 (and (eq gnus-fetch-old-headers 'some)
10718 (memq number gnus-newsgroup-ancient)
10720 ;; If this is a sparsely inserted article with no children,
10721 ;; we don't want it.
10722 (and (eq gnus-build-sparse-threads 'some)
10723 (memq number gnus-newsgroup-sparse)
10725 ;; If we use expunging, and this article is really
10726 ;; low-scored, then we don't want this article.
10727 (when (and gnus-summary-expunge-below
10729 (or (cdr (assq number gnus-newsgroup-scored))
10730 gnus-summary-default-score))
10731 gnus-summary-expunge-below))
10732 ;; We increase the expunge-tally here, but that has
10733 ;; nothing to do with the limits, really.
10734 (incf gnus-newsgroup-expunged-tally)
10735 ;; We also mark as read here, if that's wanted.
10736 (when (and gnus-summary-mark-below
10737 (< score gnus-summary-mark-below))
10738 (setq gnus-newsgroup-unreads
10739 (delq number gnus-newsgroup-unreads))
10740 (if gnus-newsgroup-auto-expire
10741 (push number gnus-newsgroup-expirable)
10742 (push (cons number gnus-low-score-mark)
10743 gnus-newsgroup-reads)))
10745 (and gnus-use-nocem
10746 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10747 ;; Nope, invisible article.
10749 ;; Ok, this article is to be visible, so we add it to the limit
10751 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10754 (defun gnus-expunge-thread (thread)
10755 "Mark all articles in THREAD as read."
10756 (let* ((number (mail-header-number (car thread))))
10757 (incf gnus-newsgroup-expunged-tally)
10758 ;; We also mark as read here, if that's wanted.
10759 (setq gnus-newsgroup-unreads
10760 (delq number gnus-newsgroup-unreads))
10761 (if gnus-newsgroup-auto-expire
10762 (push number gnus-newsgroup-expirable)
10763 (push (cons number gnus-low-score-mark)
10764 gnus-newsgroup-reads)))
10765 ;; Go recursively through all subthreads.
10766 (mapcar 'gnus-expunge-thread (cdr thread)))
10768 ;; Summary article oriented commands
10770 (defun gnus-summary-refer-parent-article (n)
10771 "Refer parent article N times.
10772 The difference between N and the number of articles fetched is returned."
10774 (gnus-set-global-variables)
10778 (let* ((header (gnus-summary-article-header))
10780 ;; If we try to find the parent of the currently
10781 ;; displayed article, then we take a look at the actual
10782 ;; References header, since this is slightly more
10783 ;; reliable than the References field we got from the
10785 (if (and (eq (mail-header-number header)
10786 (cdr gnus-article-current))
10787 (equal gnus-newsgroup-name
10788 (car gnus-article-current)))
10790 (set-buffer gnus-original-article-buffer)
10791 (nnheader-narrow-to-headers)
10793 (mail-fetch-field "references")
10795 ;; It's not the current article, so we take a bet on
10796 ;; the value we got from the server.
10797 (mail-header-references header))))
10798 (if (setq ref (or ref (mail-header-references header)))
10799 (or (gnus-summary-refer-article (gnus-parent-id ref))
10800 (gnus-message 1 "Couldn't find parent"))
10801 (gnus-message 1 "No references in article %d"
10802 (gnus-summary-article-number))
10805 (gnus-summary-position-point)
10808 (defun gnus-summary-refer-references ()
10809 "Fetch all articles mentioned in the References header.
10810 Return how many articles were fetched."
10812 (gnus-set-global-variables)
10813 (let ((ref (mail-header-references (gnus-summary-article-header)))
10814 (current (gnus-summary-article-number))
10816 ;; For each Message-ID in the References header...
10817 (while (string-match "<[^>]*>" ref)
10819 ;; ... fetch that article.
10820 (gnus-summary-refer-article
10821 (prog1 (match-string 0 ref)
10822 (setq ref (substring ref (match-end 0))))))
10823 (gnus-summary-goto-subject current)
10824 (gnus-summary-position-point)
10827 (defun gnus-summary-refer-article (message-id)
10828 "Fetch an article specified by MESSAGE-ID."
10829 (interactive "sMessage-ID: ")
10830 (when (and (stringp message-id)
10831 (not (zerop (length message-id))))
10832 ;; Construct the correct Message-ID if necessary.
10833 ;; Suggested by tale@pawl.rpi.edu.
10834 (unless (string-match "^<" message-id)
10835 (setq message-id (concat "<" message-id)))
10836 (unless (string-match ">$" message-id)
10837 (setq message-id (concat message-id ">")))
10838 (let ((header (car (gnus-gethash message-id
10839 gnus-newsgroup-dependencies))))
10841 ;; The article is present in the buffer, to we just go to it.
10842 (gnus-summary-goto-article (mail-header-number header) nil t)
10843 ;; We fetch the article
10844 (let ((gnus-override-method
10845 (and (gnus-news-group-p gnus-newsgroup-name)
10846 gnus-refer-article-method))
10848 ;; Start the special refer-article method, if necessary.
10849 (when gnus-refer-article-method
10850 (gnus-check-server gnus-refer-article-method))
10851 ;; Fetch the header, and display the article.
10852 (if (setq number (gnus-summary-insert-subject message-id))
10853 (gnus-summary-select-article nil nil nil number)
10854 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10856 (defun gnus-summary-enter-digest-group (&optional force)
10857 "Enter a digest group based on the current article."
10859 (gnus-set-global-variables)
10860 (gnus-summary-select-article)
10861 (let ((name (format "%s-%d"
10862 (gnus-group-prefixed-name
10863 gnus-newsgroup-name (list 'nndoc ""))
10864 gnus-current-article))
10865 (ogroup gnus-newsgroup-name)
10866 (case-fold-search t)
10867 (buf (current-buffer))
10870 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10871 (insert-buffer-substring gnus-original-article-buffer)
10873 (goto-char (point-min))
10874 (or (search-forward "\n\n" nil t) (point)))
10875 (goto-char (point-min))
10876 (delete-matching-lines "^\\(Path\\):\\|^From ")
10879 (if (gnus-group-read-ephemeral-group
10880 name `(nndoc ,name (nndoc-address
10882 (nndoc-article-type ,(if force 'digest 'guess))) t)
10883 ;; Make all postings to this group go to the parent group.
10884 (nconc (gnus-info-params (gnus-get-info name))
10885 (list (cons 'to-group ogroup)))
10886 ;; Couldn't select this doc group.
10887 (switch-to-buffer buf)
10888 (gnus-set-global-variables)
10889 (gnus-configure-windows 'summary)
10890 (gnus-message 3 "Article couldn't be entered?"))
10891 (kill-buffer dig))))
10893 (defun gnus-summary-isearch-article (&optional regexp-p)
10894 "Do incremental search forward on the current article.
10895 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10897 (gnus-set-global-variables)
10898 (gnus-summary-select-article)
10899 (gnus-configure-windows 'article)
10900 (gnus-eval-in-buffer-window
10901 gnus-article-buffer
10902 (goto-char (point-min))
10903 (isearch-forward regexp-p)))
10905 (defun gnus-summary-search-article-forward (regexp &optional backward)
10906 "Search for an article containing REGEXP forward.
10907 If BACKWARD, search backward instead."
10910 (format "Search article %s (regexp%s): "
10911 (if current-prefix-arg "backward" "forward")
10912 (if gnus-last-search-regexp
10913 (concat ", default " gnus-last-search-regexp)
10915 current-prefix-arg))
10916 (gnus-set-global-variables)
10917 (if (string-equal regexp "")
10918 (setq regexp (or gnus-last-search-regexp ""))
10919 (setq gnus-last-search-regexp regexp))
10920 (if (gnus-summary-search-article regexp backward)
10921 (gnus-article-set-window-start
10922 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10923 (error "Search failed: \"%s\"" regexp)))
10925 (defun gnus-summary-search-article-backward (regexp)
10926 "Search for an article containing REGEXP backward."
10929 (format "Search article backward (regexp%s): "
10930 (if gnus-last-search-regexp
10931 (concat ", default " gnus-last-search-regexp)
10933 (gnus-summary-search-article-forward regexp 'backward))
10935 (defun gnus-summary-search-article (regexp &optional backward)
10936 "Search for an article containing REGEXP.
10937 Optional argument BACKWARD means do search for backward.
10938 gnus-select-article-hook is not called during the search."
10939 (let ((gnus-select-article-hook nil) ;Disable hook.
10940 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10943 (function re-search-backward) (function re-search-forward)))
10946 ;; Hidden thread subtrees must be searched for ,too.
10947 (gnus-summary-show-all-threads)
10948 ;; First of all, search current article.
10949 ;; We don't want to read article again from NNTP server nor reset
10951 (gnus-summary-select-article)
10952 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10953 (setq last gnus-current-article)
10954 (gnus-eval-in-buffer-window
10955 gnus-article-buffer
10958 ;; Begin search from current point.
10959 (setq found (funcall re-search regexp nil t))))
10960 ;; Then search next articles.
10961 (while (and (not found)
10962 (gnus-summary-display-article
10963 (if backward (gnus-summary-find-prev)
10964 (gnus-summary-find-next))))
10965 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10966 (gnus-eval-in-buffer-window
10967 gnus-article-buffer
10970 (goto-char (if backward (point-max) (point-min)))
10971 (setq found (funcall re-search regexp nil t)))))
10973 ;; Adjust article pointer.
10974 (or (eq last gnus-current-article)
10975 (setq gnus-last-article last))
10976 ;; Return T if found such article.
10979 (defun gnus-summary-find-matching (header regexp &optional backward unread
10981 "Return a list of all articles that match REGEXP on HEADER.
10982 The search stars on the current article and goes forwards unless
10983 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10984 If UNREAD is non-nil, only unread articles will
10985 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10986 in the comparisons."
10987 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10988 (gnus-data-find-list
10989 (gnus-summary-article-number) (gnus-data-list backward))))
10990 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10991 (case-fold-search (not not-case-fold))
10993 (or (fboundp (intern (concat "mail-header-" header)))
10994 (error "%s is not a valid header" header))
10996 (setq d (car data))
10997 (and (or (not unread) ; We want all articles...
10998 (gnus-data-unread-p d)) ; Or just unreads.
10999 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11000 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11001 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11002 (setq data (cdr data)))
11003 (nreverse articles)))
11005 (defun gnus-summary-execute-command (header regexp command &optional backward)
11006 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11007 If HEADER is an empty string (or nil), the match is done on the entire
11008 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11010 (list (let ((completion-ignore-case t))
11013 (mapcar (lambda (string) (list string))
11014 '("Number" "Subject" "From" "Lines" "Date"
11015 "Message-ID" "Xref" "References" "Body"))
11016 nil 'require-match))
11017 (read-string "Regexp: ")
11018 (read-key-sequence "Command: ")
11019 current-prefix-arg))
11020 (when (equal header "Body")
11022 (gnus-set-global-variables)
11023 ;; Hidden thread subtrees must be searched as well.
11024 (gnus-summary-show-all-threads)
11025 ;; We don't want to change current point nor window configuration.
11027 (save-window-excursion
11028 (gnus-message 6 "Executing %s..." (key-description command))
11029 ;; We'd like to execute COMMAND interactively so as to give arguments.
11030 (gnus-execute header regexp
11031 `(lambda () (call-interactively ',(key-binding command)))
11033 (gnus-message 6 "Executing %s...done" (key-description command)))))
11035 (defun gnus-summary-beginning-of-article ()
11036 "Scroll the article back to the beginning."
11038 (gnus-set-global-variables)
11039 (gnus-summary-select-article)
11040 (gnus-configure-windows 'article)
11041 (gnus-eval-in-buffer-window
11042 gnus-article-buffer
11044 (goto-char (point-min))
11045 (and gnus-break-pages (gnus-narrow-to-page))))
11047 (defun gnus-summary-end-of-article ()
11048 "Scroll to the end of the article."
11050 (gnus-set-global-variables)
11051 (gnus-summary-select-article)
11052 (gnus-configure-windows 'article)
11053 (gnus-eval-in-buffer-window
11054 gnus-article-buffer
11056 (goto-char (point-max))
11058 (and gnus-break-pages (gnus-narrow-to-page))))
11060 (defun gnus-summary-show-article (&optional arg)
11061 "Force re-fetching of the current article.
11062 If ARG (the prefix) is non-nil, show the raw article without any
11063 article massaging functions being run."
11065 (gnus-set-global-variables)
11067 ;; Select the article the normal way.
11068 (gnus-summary-select-article nil 'force)
11069 ;; Bind the article treatment functions to nil.
11070 (let ((gnus-have-all-headers t)
11071 gnus-article-display-hook
11072 gnus-article-prepare-hook
11074 (gnus-summary-select-article nil 'force)))
11075 ; (gnus-configure-windows 'article)
11076 (gnus-summary-position-point))
11078 (defun gnus-summary-verbose-headers (&optional arg)
11079 "Toggle permanent full header display.
11080 If ARG is a positive number, turn header display on.
11081 If ARG is a negative number, turn header display off."
11083 (gnus-set-global-variables)
11084 (gnus-summary-toggle-header arg)
11085 (setq gnus-show-all-headers
11086 (cond ((or (not (numberp arg))
11088 (not gnus-show-all-headers))
11092 (defun gnus-summary-toggle-header (&optional arg)
11093 "Show the headers if they are hidden, or hide them if they are shown.
11094 If ARG is a positive number, show the entire header.
11095 If ARG is a negative number, hide the unwanted header lines."
11097 (gnus-set-global-variables)
11099 (set-buffer gnus-article-buffer)
11100 (let* ((buffer-read-only nil)
11101 (inhibit-point-motion-hooks t)
11102 (hidden (text-property-any
11103 (goto-char (point-min)) (search-forward "\n\n")
11106 (goto-char (point-min))
11107 (when (search-forward "\n\n" nil t)
11108 (delete-region (point-min) (1- (point))))
11109 (goto-char (point-min))
11111 (set-buffer gnus-original-article-buffer)
11112 (goto-char (point-min))
11113 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11114 (insert-buffer-substring gnus-original-article-buffer 1 e)
11115 (let ((gnus-inhibit-hiding t))
11116 (run-hooks 'gnus-article-display-hook))
11117 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11118 (gnus-article-hide-headers)))))
11120 (defun gnus-summary-show-all-headers ()
11121 "Make all header lines visible."
11123 (gnus-set-global-variables)
11124 (gnus-article-show-all-headers))
11126 (defun gnus-summary-toggle-mime (&optional arg)
11127 "Toggle MIME processing.
11128 If ARG is a positive number, turn MIME processing on."
11130 (gnus-set-global-variables)
11131 (setq gnus-show-mime
11132 (if (null arg) (not gnus-show-mime)
11133 (> (prefix-numeric-value arg) 0)))
11134 (gnus-summary-select-article t 'force))
11136 (defun gnus-summary-caesar-message (&optional arg)
11137 "Caesar rotate the current article by 13.
11138 The numerical prefix specifies how manu places to rotate each letter
11141 (gnus-set-global-variables)
11142 (gnus-summary-select-article)
11143 (let ((mail-header-separator ""))
11144 (gnus-eval-in-buffer-window
11145 gnus-article-buffer
11148 (let ((start (window-start)))
11149 (news-caesar-buffer-body arg)
11150 (set-window-start (get-buffer-window (current-buffer)) start))))))
11152 (defun gnus-summary-stop-page-breaking ()
11153 "Stop page breaking in the current article."
11155 (gnus-set-global-variables)
11156 (gnus-summary-select-article)
11157 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11159 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11160 "Move the current article to a different newsgroup.
11161 If N is a positive number, move the N next articles.
11162 If N is a negative number, move the N previous articles.
11163 If N is nil and any articles have been marked with the process mark,
11164 move those articles instead.
11165 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11166 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11167 re-spool using this method.
11169 For this function to work, both the current newsgroup and the
11170 newsgroup that you want to move to have to support the `request-move'
11171 and `request-accept' functions."
11173 (unless action (setq action 'move))
11174 (gnus-set-global-variables)
11175 ;; Check whether the source group supports the required functions.
11176 (cond ((and (eq action 'move)
11177 (not (gnus-check-backend-function
11178 'request-move-article gnus-newsgroup-name)))
11179 (error "The current group does not support article moving"))
11180 ((and (eq action 'crosspost)
11181 (not (gnus-check-backend-function
11182 'request-replace-article gnus-newsgroup-name)))
11183 (error "The current group does not support article editing")))
11184 (let ((articles (gnus-summary-work-articles n))
11185 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11186 (names '((move "move" "Moving")
11187 (copy "copy" "Copying")
11188 (crosspost "crosspost" "Crossposting")))
11189 (copy-buf (save-excursion
11190 (nnheader-set-temp-buffer " *copy article*")))
11191 art-group to-method new-xref article to-groups)
11192 (unless (assq action names)
11193 (error "Unknown action %s" action))
11194 ;; Read the newsgroup name.
11195 (when (and (not to-newsgroup)
11196 (not select-method))
11198 (gnus-read-move-group-name
11199 (cadr (assq action names))
11200 gnus-current-move-group articles prefix))
11201 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11202 (setq to-method (or select-method
11203 (gnus-find-method-for-group to-newsgroup)))
11204 ;; Check the method we are to move this article to...
11205 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11206 (error "%s does not support article copying" (car to-method)))
11207 (or (gnus-check-server to-method)
11208 (error "Can't open server %s" (car to-method)))
11209 (gnus-message 6 "%s to %s: %s..."
11210 (caddr (assq action names))
11211 (or (car select-method) to-newsgroup) articles)
11213 (setq article (pop articles))
11217 ;; Move the article.
11219 (gnus-request-move-article
11220 article ; Article to move
11221 gnus-newsgroup-name ; From newsgrouo
11222 (nth 1 (gnus-find-method-for-group
11223 gnus-newsgroup-name)) ; Server
11224 (list 'gnus-request-accept-article
11225 to-newsgroup (list 'quote select-method)
11226 (not articles)) ; Accept form
11227 (not articles))) ; Only save nov last time
11228 ;; Copy the article.
11231 (set-buffer copy-buf)
11232 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11233 (gnus-request-accept-article
11234 to-newsgroup select-method (not articles))))
11235 ;; Crosspost the article.
11236 ((eq action 'crosspost)
11237 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11238 (setq new-xref (concat gnus-newsgroup-name ":" article))
11239 (if (and xref (not (string= xref "")))
11241 (when (string-match "^Xref: " xref)
11242 (setq xref (substring xref (match-end 0))))
11243 (setq new-xref (concat xref " " new-xref)))
11244 (setq new-xref (concat (system-name) " " new-xref)))
11246 (set-buffer copy-buf)
11247 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11248 (nnheader-replace-header "xref" new-xref)
11249 (gnus-request-accept-article
11250 to-newsgroup select-method (not articles)))))))
11251 (if (not art-group)
11252 (gnus-message 1 "Couldn't %s article %s"
11253 (cadr (assq action names)) article)
11256 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11258 (gnus-group-prefixed-name
11261 (gnus-find-method-for-group to-newsgroup)))
11262 gnus-newsrc-hashtb)))
11263 (info (nth 2 entry))
11264 (to-group (gnus-info-group info)))
11265 ;; Update the group that has been moved to.
11267 (memq action '(move copy)))
11268 (unless (member to-group to-groups)
11269 (push to-group to-groups))
11271 (unless (memq article gnus-newsgroup-unreads)
11272 (gnus-info-set-read
11273 info (gnus-add-to-range (gnus-info-read info)
11274 (list (cdr art-group)))))
11276 ;; Copy any marks over to the new group.
11277 (let ((marks gnus-article-mark-lists)
11278 (to-article (cdr art-group)))
11280 ;; See whether the article is to be put in the cache.
11281 (when gnus-use-cache
11282 (gnus-cache-possibly-enter-article
11283 to-group to-article
11284 (let ((header (copy-sequence
11285 (gnus-summary-article-header article))))
11286 (mail-header-set-number header to-article)
11288 (memq article gnus-newsgroup-marked)
11289 (memq article gnus-newsgroup-dormant)
11290 (memq article gnus-newsgroup-unreads)))
11293 (when (memq article (symbol-value
11294 (intern (format "gnus-newsgroup-%s"
11296 ;; If the other group is the same as this group,
11297 ;; then we have to add the mark to the list.
11298 (when (equal to-group gnus-newsgroup-name)
11299 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11302 (intern (format "gnus-newsgroup-%s"
11304 ;; Copy mark to other group.
11305 (gnus-add-marked-articles
11306 to-group (cdar marks) (list to-article) info))
11307 (setq marks (cdr marks)))))
11309 ;; Update the Xref header in this article to point to
11310 ;; the new crossposted article we have just created.
11311 (when (eq action 'crosspost)
11313 (set-buffer copy-buf)
11314 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11315 (nnheader-replace-header
11316 "xref" (concat new-xref " " (gnus-group-prefixed-name
11317 (car art-group) to-method)
11318 ":" (cdr art-group)))
11319 (gnus-request-replace-article
11320 article gnus-newsgroup-name (current-buffer)))))
11322 (gnus-summary-goto-subject article)
11323 (when (eq action 'move)
11324 (gnus-summary-mark-article article gnus-canceled-mark)))
11325 (gnus-summary-remove-process-mark article))
11326 ;; Re-activate all groups that have been moved to.
11328 (gnus-activate-group (pop to-groups)))
11330 (gnus-kill-buffer copy-buf)
11331 (gnus-summary-position-point)
11332 (gnus-set-mode-line 'summary)))
11334 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11335 "Move the current article to a different newsgroup.
11336 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11337 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11338 re-spool using this method."
11340 (gnus-summary-move-article n nil select-method 'copy))
11342 (defun gnus-summary-crosspost-article (&optional n)
11343 "Crosspost the current article to some other group."
11345 (gnus-summary-move-article n nil nil 'crosspost))
11347 (defun gnus-summary-respool-article (&optional n method)
11348 "Respool the current article.
11349 The article will be squeezed through the mail spooling process again,
11350 which means that it will be put in some mail newsgroup or other
11351 depending on `nnmail-split-methods'.
11352 If N is a positive number, respool the N next articles.
11353 If N is a negative number, respool the N previous articles.
11354 If N is nil and any articles have been marked with the process mark,
11355 respool those articles instead.
11357 Respooling can be done both from mail groups and \"real\" newsgroups.
11358 In the former case, the articles in question will be moved from the
11359 current group into whatever groups they are destined to. In the
11360 latter case, they will be copied into the relevant groups."
11362 (list current-prefix-arg
11363 (let* ((methods (gnus-methods-using 'respool))
11365 (symbol-name (car (gnus-find-method-for-group
11366 gnus-newsgroup-name))))
11369 "What backend do you want to use when respooling? "
11370 methods nil t (cons methname 0)))
11373 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11374 (list (intern method) ""))
11378 (cdr (completing-read
11380 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11381 (gnus-set-global-variables)
11383 (error "No method given for respooling"))
11384 (if (assoc (symbol-name
11385 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11386 (gnus-methods-using 'respool))
11387 (gnus-summary-move-article n nil method)
11388 (gnus-summary-copy-article n nil method)))
11390 (defun gnus-summary-import-article (file)
11391 "Import a random file into a mail newsgroup."
11392 (interactive "fImport file: ")
11393 (gnus-set-global-variables)
11394 (let ((group gnus-newsgroup-name)
11395 (now (current-time))
11397 (or (gnus-check-backend-function 'request-accept-article group)
11398 (error "%s does not support article importing" group))
11399 (or (file-readable-p file)
11400 (not (file-regular-p file))
11401 (error "Can't read %s" file))
11403 (set-buffer (get-buffer-create " *import file*"))
11404 (buffer-disable-undo (current-buffer))
11406 (insert-file-contents file)
11407 (goto-char (point-min))
11408 (unless (nnheader-article-p)
11409 ;; This doesn't look like an article, so we fudge some headers.
11410 (setq atts (file-attributes file)
11411 lines (count-lines (point-min) (point-max)))
11412 (insert "From: " (read-string "From: ") "\n"
11413 "Subject: " (read-string "Subject: ") "\n"
11414 "Date: " (timezone-make-date-arpa-standard
11415 (current-time-string (nth 5 atts))
11416 (current-time-zone now)
11417 (current-time-zone now)) "\n"
11418 "Message-ID: " (gnus-inews-message-id) "\n"
11419 "Lines: " (int-to-string lines) "\n"
11420 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11421 (gnus-request-accept-article group nil t)
11422 (kill-buffer (current-buffer)))))
11424 (defun gnus-summary-expire-articles ()
11425 "Expire all articles that are marked as expirable in the current group."
11427 (gnus-set-global-variables)
11428 (when (gnus-check-backend-function
11429 'request-expire-articles gnus-newsgroup-name)
11430 ;; This backend supports expiry.
11431 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11432 (expirable (if total
11433 (gnus-list-of-read-articles gnus-newsgroup-name)
11434 (setq gnus-newsgroup-expirable
11435 (sort gnus-newsgroup-expirable '<))))
11436 (expiry-wait (gnus-group-get-parameter
11437 gnus-newsgroup-name 'expiry-wait))
11440 ;; There are expirable articles in this group, so we run them
11441 ;; through the expiry process.
11442 (gnus-message 6 "Expiring articles...")
11443 ;; The list of articles that weren't expired is returned.
11445 (let ((nnmail-expiry-wait-function nil)
11446 (nnmail-expiry-wait expiry-wait))
11447 (setq es (gnus-request-expire-articles
11448 expirable gnus-newsgroup-name)))
11449 (setq es (gnus-request-expire-articles
11450 expirable gnus-newsgroup-name)))
11451 (or total (setq gnus-newsgroup-expirable es))
11452 ;; We go through the old list of expirable, and mark all
11453 ;; really expired articles as nonexistent.
11454 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11455 (let ((gnus-use-cache nil))
11457 (unless (memq (car expirable) es)
11458 (when (gnus-data-find (car expirable))
11459 (gnus-summary-mark-article
11460 (car expirable) gnus-canceled-mark)))
11461 (setq expirable (cdr expirable)))))
11462 (gnus-message 6 "Expiring articles...done")))))
11464 (defun gnus-summary-expire-articles-now ()
11465 "Expunge all expirable articles in the current group.
11466 This means that *all* articles that are marked as expirable will be
11467 deleted forever, right now."
11469 (gnus-set-global-variables)
11470 (or gnus-expert-user
11472 "Are you really, really, really sure you want to expunge? ")
11474 (let ((nnmail-expiry-wait 'immediate)
11475 (nnmail-expiry-wait-function nil))
11476 (gnus-summary-expire-articles)))
11478 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11479 (defun gnus-summary-delete-article (&optional n)
11480 "Delete the N next (mail) articles.
11481 This command actually deletes articles. This is not a marking
11482 command. The article will disappear forever from your life, never to
11484 If N is negative, delete backwards.
11485 If N is nil and articles have been marked with the process mark,
11486 delete these instead."
11488 (gnus-set-global-variables)
11489 (or (gnus-check-backend-function 'request-expire-articles
11490 gnus-newsgroup-name)
11491 (error "The current newsgroup does not support article deletion."))
11492 ;; Compute the list of articles to delete.
11493 (let ((articles (gnus-summary-work-articles n))
11495 (if (and gnus-novice-user
11496 (not (gnus-y-or-n-p
11497 (format "Do you really want to delete %s forever? "
11498 (if (> (length articles) 1) "these articles"
11499 "this article")))))
11501 ;; Delete the articles.
11502 (setq not-deleted (gnus-request-expire-articles
11503 articles gnus-newsgroup-name 'force))
11505 (gnus-summary-remove-process-mark (car articles))
11506 ;; The backend might not have been able to delete the article
11508 (or (memq (car articles) not-deleted)
11509 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11510 (setq articles (cdr articles))))
11511 (gnus-summary-position-point)
11512 (gnus-set-mode-line 'summary)
11515 (defun gnus-summary-edit-article (&optional force)
11516 "Enter into a buffer and edit the current article.
11517 This will have permanent effect only in mail groups.
11518 If FORCE is non-nil, allow editing of articles even in read-only
11522 (set-buffer gnus-summary-buffer)
11523 (gnus-set-global-variables)
11524 (when (and (not force)
11525 (gnus-group-read-only-p))
11526 (error "The current newsgroup does not support article editing."))
11527 (gnus-summary-select-article t nil t)
11528 (gnus-configure-windows 'article)
11529 (select-window (get-buffer-window gnus-article-buffer))
11530 (gnus-message 6 "C-c C-c to end edits")
11531 (setq buffer-read-only nil)
11533 (use-local-map (copy-keymap (current-local-map)))
11534 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11535 (buffer-enable-undo)
11537 (goto-char (point-min))
11538 (search-forward "\n\n" nil t)))
11540 (defun gnus-summary-edit-article-done ()
11541 "Make edits to the current article permanent."
11543 (if (gnus-group-read-only-p)
11545 (gnus-summary-edit-article-postpone)
11547 1 "The current newsgroup does not support article editing.")
11549 (let ((buf (format "%s" (buffer-string))))
11552 (if (not (gnus-request-replace-article
11553 (cdr gnus-article-current) (car gnus-article-current)
11555 (error "Couldn't replace article.")
11556 (gnus-article-mode)
11557 (use-local-map gnus-article-mode-map)
11558 (setq buffer-read-only t)
11559 (buffer-disable-undo (current-buffer))
11560 (gnus-configure-windows 'summary)
11561 (gnus-summary-update-article (cdr gnus-article-current))
11562 (when gnus-use-cache
11563 (gnus-cache-update-article
11564 (cdr gnus-article-current) (car gnus-article-current))))
11565 (run-hooks 'gnus-article-display-hook)
11566 (and (gnus-visual-p 'summary-highlight 'highlight)
11567 (run-hooks 'gnus-visual-mark-article-hook)))))
11569 (defun gnus-summary-edit-article-postpone ()
11570 "Postpone changes to the current article."
11572 (gnus-article-mode)
11573 (use-local-map gnus-article-mode-map)
11574 (setq buffer-read-only t)
11575 (buffer-disable-undo (current-buffer))
11576 (gnus-configure-windows 'summary)
11577 (and (gnus-visual-p 'summary-highlight 'highlight)
11578 (run-hooks 'gnus-visual-mark-article-hook)))
11580 (defun gnus-summary-respool-query ()
11581 "Query where the respool algorithm would put this article."
11583 (gnus-set-global-variables)
11584 (gnus-summary-select-article)
11586 (set-buffer gnus-article-buffer)
11588 (goto-char (point-min))
11589 (search-forward "\n\n")
11590 (narrow-to-region (point-min) (point))
11591 (pp-eval-expression
11592 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11594 ;; Summary score commands.
11596 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11598 (defun gnus-summary-raise-score (n)
11599 "Raise the score of the current article by N."
11601 (gnus-set-global-variables)
11602 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11604 (defun gnus-summary-set-score (n)
11605 "Set the score of the current article to N."
11607 (gnus-set-global-variables)
11609 (gnus-summary-show-thread)
11610 (let ((buffer-read-only nil))
11612 (gnus-summary-update-mark
11613 (if (= n (or gnus-summary-default-score 0)) ?
11614 (if (< n (or gnus-summary-default-score 0))
11615 gnus-score-below-mark gnus-score-over-mark)) 'score))
11616 (let* ((article (gnus-summary-article-number))
11617 (score (assq article gnus-newsgroup-scored)))
11618 (if score (setcdr score n)
11619 (setq gnus-newsgroup-scored
11620 (cons (cons article n) gnus-newsgroup-scored))))
11621 (gnus-summary-update-line)))
11623 (defun gnus-summary-current-score ()
11624 "Return the score of the current article."
11626 (gnus-set-global-variables)
11627 (message "%s" (gnus-summary-article-score)))
11629 ;; Summary marking commands.
11631 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11632 "Mark articles which has the same subject as read, and then select the next.
11633 If UNMARK is positive, remove any kind of mark.
11634 If UNMARK is negative, tick articles."
11636 (gnus-set-global-variables)
11638 (setq unmark (prefix-numeric-value unmark)))
11640 (gnus-summary-mark-same-subject
11641 (gnus-summary-article-subject) unmark)))
11642 ;; Select next unread article. If auto-select-same mode, should
11643 ;; select the first unread article.
11644 (gnus-summary-next-article t (and gnus-auto-select-same
11645 (gnus-summary-article-subject)))
11646 (gnus-message 7 "%d article%s marked as %s"
11647 count (if (= count 1) " is" "s are")
11648 (if unmark "unread" "read"))))
11650 (defun gnus-summary-kill-same-subject (&optional unmark)
11651 "Mark articles which has the same subject as read.
11652 If UNMARK is positive, remove any kind of mark.
11653 If UNMARK is negative, tick articles."
11655 (gnus-set-global-variables)
11657 (setq unmark (prefix-numeric-value unmark)))
11659 (gnus-summary-mark-same-subject
11660 (gnus-summary-article-subject) unmark)))
11661 ;; If marked as read, go to next unread subject.
11663 ;; Go to next unread subject.
11664 (gnus-summary-next-subject 1 t))
11665 (gnus-message 7 "%d articles are marked as %s"
11666 count (if unmark "unread" "read"))))
11668 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11669 "Mark articles with same SUBJECT as read, and return marked number.
11670 If optional argument UNMARK is positive, remove any kinds of marks.
11671 If optional argument UNMARK is negative, mark articles as unread instead."
11675 ((null unmark) ; Mark as read.
11678 (gnus-summary-mark-article-as-read gnus-killed-mark)
11679 (gnus-summary-show-thread) t)
11680 (gnus-summary-find-subject subject))
11681 (setq count (1+ count))))
11682 ((> unmark 0) ; Tick.
11685 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11686 (gnus-summary-show-thread) t)
11687 (gnus-summary-find-subject subject))
11688 (setq count (1+ count))))
11689 (t ; Mark as unread.
11692 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11693 (gnus-summary-show-thread) t)
11694 (gnus-summary-find-subject subject))
11695 (setq count (1+ count)))))
11696 (gnus-set-mode-line 'summary)
11697 ;; Return the number of marked articles.
11700 (defun gnus-summary-mark-as-processable (n &optional unmark)
11701 "Set the process mark on the next N articles.
11702 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11703 the process mark instead. The difference between N and the actual
11704 number of articles marked is returned."
11706 (gnus-set-global-variables)
11707 (let ((backward (< n 0))
11712 (gnus-summary-remove-process-mark
11713 (gnus-summary-article-number))
11714 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11715 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11717 (if (/= 0 n) (gnus-message 7 "No more articles"))
11718 (gnus-summary-recenter)
11719 (gnus-summary-position-point)
11722 (defun gnus-summary-unmark-as-processable (n)
11723 "Remove the process mark from the next N articles.
11724 If N is negative, mark backward instead. The difference between N and
11725 the actual number of articles marked is returned."
11727 (gnus-set-global-variables)
11728 (gnus-summary-mark-as-processable n t))
11730 (defun gnus-summary-unmark-all-processable ()
11731 "Remove the process mark from all articles."
11733 (gnus-set-global-variables)
11735 (while gnus-newsgroup-processable
11736 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11737 (gnus-summary-position-point))
11739 (defun gnus-summary-mark-as-expirable (n)
11740 "Mark N articles forward as expirable.
11741 If N is negative, mark backward instead. The difference between N and
11742 the actual number of articles marked is returned."
11744 (gnus-set-global-variables)
11745 (gnus-summary-mark-forward n gnus-expirable-mark))
11747 (defun gnus-summary-mark-article-as-replied (article)
11748 "Mark ARTICLE replied and update the summary line."
11749 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11750 (let ((buffer-read-only nil))
11751 (when (gnus-summary-goto-subject article)
11752 (gnus-summary-update-secondary-mark article))))
11754 (defun gnus-summary-set-bookmark (article)
11755 "Set a bookmark in current article."
11756 (interactive (list (gnus-summary-article-number)))
11757 (gnus-set-global-variables)
11758 (if (or (not (get-buffer gnus-article-buffer))
11759 (not gnus-current-article)
11760 (not gnus-article-current)
11761 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11762 (error "No current article selected"))
11763 ;; Remove old bookmark, if one exists.
11764 (let ((old (assq article gnus-newsgroup-bookmarks)))
11765 (if old (setq gnus-newsgroup-bookmarks
11766 (delq old gnus-newsgroup-bookmarks))))
11767 ;; Set the new bookmark, which is on the form
11768 ;; (article-number . line-number-in-body).
11769 (setq gnus-newsgroup-bookmarks
11773 (set-buffer gnus-article-buffer)
11777 (goto-char (point-min))
11778 (search-forward "\n\n" nil t)
11781 gnus-newsgroup-bookmarks))
11782 (gnus-message 6 "A bookmark has been added to the current article."))
11784 (defun gnus-summary-remove-bookmark (article)
11785 "Remove the bookmark from the current article."
11786 (interactive (list (gnus-summary-article-number)))
11787 (gnus-set-global-variables)
11788 ;; Remove old bookmark, if one exists.
11789 (let ((old (assq article gnus-newsgroup-bookmarks)))
11792 (setq gnus-newsgroup-bookmarks
11793 (delq old gnus-newsgroup-bookmarks))
11794 (gnus-message 6 "Removed bookmark."))
11795 (gnus-message 6 "No bookmark in current article."))))
11797 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11798 (defun gnus-summary-mark-as-dormant (n)
11799 "Mark N articles forward as dormant.
11800 If N is negative, mark backward instead. The difference between N and
11801 the actual number of articles marked is returned."
11803 (gnus-set-global-variables)
11804 (gnus-summary-mark-forward n gnus-dormant-mark))
11806 (defun gnus-summary-set-process-mark (article)
11807 "Set the process mark on ARTICLE and update the summary line."
11808 (setq gnus-newsgroup-processable
11810 (delq article gnus-newsgroup-processable)))
11811 (when (gnus-summary-goto-subject article)
11812 (gnus-summary-show-thread)
11813 (gnus-summary-update-secondary-mark article)))
11815 (defun gnus-summary-remove-process-mark (article)
11816 "Remove the process mark from ARTICLE and update the summary line."
11817 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11818 (when (gnus-summary-goto-subject article)
11819 (gnus-summary-show-thread)
11820 (gnus-summary-update-secondary-mark article)))
11822 (defun gnus-summary-set-saved-mark (article)
11823 "Set the process mark on ARTICLE and update the summary line."
11824 (push article gnus-newsgroup-saved)
11825 (when (gnus-summary-goto-subject article)
11826 (gnus-summary-update-secondary-mark article)))
11828 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11829 "Mark N articles as read forwards.
11830 If N is negative, mark backwards instead.
11831 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11833 The difference between N and the actual number of articles marked is
11836 (gnus-set-global-variables)
11837 (let ((backward (< n 0))
11838 (gnus-summary-goto-unread
11839 (and gnus-summary-goto-unread
11840 (not (eq gnus-summary-goto-unread 'never))
11841 (not (memq mark (list gnus-unread-mark
11842 gnus-ticked-mark gnus-dormant-mark)))))
11844 (mark (or mark gnus-del-mark)))
11845 (while (and (> n 0)
11846 (gnus-summary-mark-article nil mark no-expire)
11847 (zerop (gnus-summary-next-subject
11849 (and gnus-summary-goto-unread
11850 (not (eq gnus-summary-goto-unread 'never)))
11853 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11854 (gnus-summary-recenter)
11855 (gnus-summary-position-point)
11856 (gnus-set-mode-line 'summary)
11859 (defun gnus-summary-mark-article-as-read (mark)
11860 "Mark the current article quickly as read with MARK."
11861 (let ((article (gnus-summary-article-number)))
11862 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11863 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11864 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11865 (setq gnus-newsgroup-reads
11866 (cons (cons article mark) gnus-newsgroup-reads))
11867 ;; Possibly remove from cache, if that is used.
11868 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11869 ;; Allow the backend to change the mark.
11870 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11871 ;; Check for auto-expiry.
11872 (when (and gnus-newsgroup-auto-expire
11873 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11874 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11875 (= mark gnus-ancient-mark)
11876 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11877 (setq mark gnus-expirable-mark)
11878 (push article gnus-newsgroup-expirable))
11879 ;; Set the mark in the buffer.
11880 (gnus-summary-update-mark mark 'unread)
11883 (defun gnus-summary-mark-article-as-unread (mark)
11884 "Mark the current article quickly as unread with MARK."
11885 (let ((article (gnus-summary-article-number)))
11886 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11887 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11888 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11889 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11890 (cond ((= mark gnus-ticked-mark)
11891 (push article gnus-newsgroup-marked))
11892 ((= mark gnus-dormant-mark)
11893 (push article gnus-newsgroup-dormant))
11895 (push article gnus-newsgroup-unreads)))
11896 (setq gnus-newsgroup-reads
11897 (delq (assq article gnus-newsgroup-reads)
11898 gnus-newsgroup-reads))
11900 ;; See whether the article is to be put in the cache.
11901 (and gnus-use-cache
11902 (vectorp (gnus-summary-article-header article))
11904 (gnus-cache-possibly-enter-article
11905 gnus-newsgroup-name article
11906 (gnus-summary-article-header article)
11907 (= mark gnus-ticked-mark)
11908 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11911 (gnus-summary-update-mark mark 'unread)
11914 (defun gnus-summary-mark-article (&optional article mark no-expire)
11915 "Mark ARTICLE with MARK. MARK can be any character.
11916 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11917 `??' (dormant) and `?E' (expirable).
11918 If MARK is nil, then the default character `?D' is used.
11919 If ARTICLE is nil, then the article on the current line will be
11921 ;; The mark might be a string.
11922 (and (stringp mark)
11923 (setq mark (aref mark 0)))
11924 ;; If no mark is given, then we check auto-expiring.
11925 (and (not no-expire)
11926 gnus-newsgroup-auto-expire
11928 (and (numberp mark)
11929 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11930 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11931 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11932 (setq mark gnus-expirable-mark))
11933 (let* ((mark (or mark gnus-del-mark))
11934 (article (or article (gnus-summary-article-number))))
11935 (or article (error "No article on current line"))
11936 (if (or (= mark gnus-unread-mark)
11937 (= mark gnus-ticked-mark)
11938 (= mark gnus-dormant-mark))
11939 (gnus-mark-article-as-unread article mark)
11940 (gnus-mark-article-as-read article mark))
11942 ;; See whether the article is to be put in the cache.
11943 (and gnus-use-cache
11944 (not (= mark gnus-canceled-mark))
11945 (vectorp (gnus-summary-article-header article))
11947 (gnus-cache-possibly-enter-article
11948 gnus-newsgroup-name article
11949 (gnus-summary-article-header article)
11950 (= mark gnus-ticked-mark)
11951 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11953 (if (gnus-summary-goto-subject article nil t)
11954 (let ((buffer-read-only nil))
11955 (gnus-summary-show-thread)
11957 (gnus-summary-update-mark mark 'unread)
11960 (defun gnus-summary-update-secondary-mark (article)
11961 "Update the secondary (read, process, cache) mark."
11962 (gnus-summary-update-mark
11963 (cond ((memq article gnus-newsgroup-processable)
11965 ((memq article gnus-newsgroup-cached)
11967 ((memq article gnus-newsgroup-replied)
11969 ((memq article gnus-newsgroup-saved)
11971 (t gnus-unread-mark))
11973 (when (gnus-visual-p 'summary-highlight 'highlight)
11974 (run-hooks 'gnus-summary-update-hook))
11977 (defun gnus-summary-update-mark (mark type)
11978 (beginning-of-line)
11979 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11980 (buffer-read-only nil))
11982 ;; Go to the right position on the line.
11983 (forward-char forward)
11984 ;; Replace the old mark with the new mark.
11985 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11986 ;; Optionally update the marks by some user rule.
11987 (when (eq type 'unread)
11988 (gnus-data-set-mark
11989 (gnus-data-find (gnus-summary-article-number)) mark)
11990 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11992 (defun gnus-mark-article-as-read (article &optional mark)
11993 "Enter ARTICLE in the pertinent lists and remove it from others."
11994 ;; Make the article expirable.
11995 (let ((mark (or mark gnus-del-mark)))
11996 (if (= mark gnus-expirable-mark)
11997 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11998 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11999 ;; Remove from unread and marked lists.
12000 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12001 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12002 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12003 (push (cons article mark) gnus-newsgroup-reads)
12004 ;; Possibly remove from cache, if that is used.
12005 (when gnus-use-cache
12006 (gnus-cache-enter-remove-article article))))
12008 (defun gnus-mark-article-as-unread (article &optional mark)
12009 "Enter ARTICLE in the pertinent lists and remove it from others."
12010 (let ((mark (or mark gnus-ticked-mark)))
12011 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12012 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12013 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12014 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12015 (cond ((= mark gnus-ticked-mark)
12016 (push article gnus-newsgroup-marked))
12017 ((= mark gnus-dormant-mark)
12018 (push article gnus-newsgroup-dormant))
12020 (push article gnus-newsgroup-unreads)))
12021 (setq gnus-newsgroup-reads
12022 (delq (assq article gnus-newsgroup-reads)
12023 gnus-newsgroup-reads))))
12025 (defalias 'gnus-summary-mark-as-unread-forward
12026 'gnus-summary-tick-article-forward)
12027 (make-obsolete 'gnus-summary-mark-as-unread-forward
12028 'gnus-summary-tick-article-forward)
12029 (defun gnus-summary-tick-article-forward (n)
12030 "Tick N articles forwards.
12031 If N is negative, tick backwards instead.
12032 The difference between N and the number of articles ticked is returned."
12034 (gnus-summary-mark-forward n gnus-ticked-mark))
12036 (defalias 'gnus-summary-mark-as-unread-backward
12037 'gnus-summary-tick-article-backward)
12038 (make-obsolete 'gnus-summary-mark-as-unread-backward
12039 'gnus-summary-tick-article-backward)
12040 (defun gnus-summary-tick-article-backward (n)
12041 "Tick N articles backwards.
12042 The difference between N and the number of articles ticked is returned."
12044 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12046 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12047 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12048 (defun gnus-summary-tick-article (&optional article clear-mark)
12049 "Mark current article as unread.
12050 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12051 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12053 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12054 gnus-ticked-mark)))
12056 (defun gnus-summary-mark-as-read-forward (n)
12057 "Mark N articles as read forwards.
12058 If N is negative, mark backwards instead.
12059 The difference between N and the actual number of articles marked is
12062 (gnus-summary-mark-forward n gnus-del-mark t))
12064 (defun gnus-summary-mark-as-read-backward (n)
12065 "Mark the N articles as read backwards.
12066 The difference between N and the actual number of articles marked is
12069 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12071 (defun gnus-summary-mark-as-read (&optional article mark)
12072 "Mark current article as read.
12073 ARTICLE specifies the article to be marked as read.
12074 MARK specifies a string to be inserted at the beginning of the line."
12075 (gnus-summary-mark-article article mark))
12077 (defun gnus-summary-clear-mark-forward (n)
12078 "Clear marks from N articles forward.
12079 If N is negative, clear backward instead.
12080 The difference between N and the number of marks cleared is returned."
12082 (gnus-summary-mark-forward n gnus-unread-mark))
12084 (defun gnus-summary-clear-mark-backward (n)
12085 "Clear marks from N articles backward.
12086 The difference between N and the number of marks cleared is returned."
12088 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12090 (defun gnus-summary-mark-unread-as-read ()
12091 "Intended to be used by `gnus-summary-mark-article-hook'."
12092 (when (memq gnus-current-article gnus-newsgroup-unreads)
12093 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12095 (defun gnus-summary-mark-read-and-unread-as-read ()
12096 "Intended to be used by `gnus-summary-mark-article-hook'."
12097 (let ((mark (gnus-summary-article-mark)))
12098 (when (or (gnus-unread-mark-p mark)
12099 (gnus-read-mark-p mark))
12100 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12102 (defun gnus-summary-mark-region-as-read (point mark all)
12103 "Mark all unread articles between point and mark as read.
12104 If given a prefix, mark all articles between point and mark as read,
12105 even ticked and dormant ones."
12106 (interactive "r\nP")
12110 (beginning-of-line)
12115 (memq (setq article (gnus-summary-article-number))
12116 gnus-newsgroup-unreads))
12117 (gnus-summary-mark-article article gnus-del-mark))
12119 (gnus-summary-find-next))))))
12121 (defun gnus-summary-mark-below (score mark)
12122 "Mark articles with score less than SCORE with MARK."
12123 (interactive "P\ncMark: ")
12124 (gnus-set-global-variables)
12125 (setq score (if score
12126 (prefix-numeric-value score)
12127 (or gnus-summary-default-score 0)))
12129 (set-buffer gnus-summary-buffer)
12130 (goto-char (point-min))
12133 (and (< (gnus-summary-article-score) score)
12134 (gnus-summary-mark-article nil mark))
12135 (gnus-summary-find-next)))))
12137 (defun gnus-summary-kill-below (&optional score)
12138 "Mark articles with score below SCORE as read."
12140 (gnus-set-global-variables)
12141 (gnus-summary-mark-below score gnus-killed-mark))
12143 (defun gnus-summary-clear-above (&optional score)
12144 "Clear all marks from articles with score above SCORE."
12146 (gnus-set-global-variables)
12147 (gnus-summary-mark-above score gnus-unread-mark))
12149 (defun gnus-summary-tick-above (&optional score)
12150 "Tick all articles with score above SCORE."
12152 (gnus-set-global-variables)
12153 (gnus-summary-mark-above score gnus-ticked-mark))
12155 (defun gnus-summary-mark-above (score mark)
12156 "Mark articles with score over SCORE with MARK."
12157 (interactive "P\ncMark: ")
12158 (gnus-set-global-variables)
12159 (setq score (if score
12160 (prefix-numeric-value score)
12161 (or gnus-summary-default-score 0)))
12163 (set-buffer gnus-summary-buffer)
12164 (goto-char (point-min))
12166 (if (> (gnus-summary-article-score) score)
12167 (gnus-summary-mark-article nil mark))
12169 (gnus-summary-find-next)))))
12171 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12172 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12173 (defun gnus-summary-limit-include-expunged ()
12174 "Display all the hidden articles that were expunged for low scores."
12176 (gnus-set-global-variables)
12177 (let ((buffer-read-only nil))
12178 (let ((scored gnus-newsgroup-scored)
12181 (or (gnus-summary-goto-subject (caar scored))
12182 (and (setq h (gnus-summary-article-header (caar scored)))
12183 (< (cdar scored) gnus-summary-expunge-below)
12184 (setq headers (cons h headers))))
12185 (setq scored (cdr scored)))
12186 (or headers (error "No expunged articles hidden."))
12187 (goto-char (point-min))
12188 (gnus-summary-prepare-unthreaded (nreverse headers)))
12189 (goto-char (point-min))
12190 (gnus-summary-position-point)))
12192 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12193 "Mark all articles not marked as unread in this newsgroup as read.
12194 If prefix argument ALL is non-nil, all articles are marked as read.
12195 If QUIETLY is non-nil, no questions will be asked.
12196 If TO-HERE is non-nil, it should be a point in the buffer. All
12197 articles before this point will be marked as read.
12198 The number of articles marked as read is returned."
12200 (gnus-set-global-variables)
12203 (not gnus-interactive-catchup) ;Without confirmation?
12207 "Mark absolutely all articles as read? "
12208 "Mark all unread articles as read? ")))
12210 (not gnus-newsgroup-adaptive)
12211 (not gnus-newsgroup-auto-expire))
12214 (setq gnus-newsgroup-marked nil
12215 gnus-newsgroup-dormant nil))
12216 (setq gnus-newsgroup-unreads nil))
12217 ;; We actually mark all articles as canceled, which we
12218 ;; have to do when using auto-expiry or adaptive scoring.
12219 (gnus-summary-show-all-threads)
12220 (if (gnus-summary-first-subject (not all))
12222 (if to-here (< (point) to-here) t)
12223 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12224 (gnus-summary-find-next (not all)))))
12226 (setq gnus-newsgroup-unreads nil))
12227 (gnus-set-mode-line 'summary)))
12228 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12229 (if (and (not to-here) (eq 'nnvirtual (car method)))
12230 (nnvirtual-catchup-group
12231 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12232 (gnus-summary-position-point)))
12234 (defun gnus-summary-catchup-to-here (&optional all)
12235 "Mark all unticked articles before the current one as read.
12236 If ALL is non-nil, also mark ticked and dormant articles as read."
12238 (gnus-set-global-variables)
12240 (let ((beg (point)))
12241 ;; We check that there are unread articles.
12242 (when (or all (gnus-summary-find-prev))
12243 (gnus-summary-catchup all t beg))))
12244 (gnus-summary-position-point))
12246 (defun gnus-summary-catchup-all (&optional quietly)
12247 "Mark all articles in this newsgroup as read."
12249 (gnus-set-global-variables)
12250 (gnus-summary-catchup t quietly))
12252 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12253 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12254 If prefix argument ALL is non-nil, all articles are marked as read."
12256 (gnus-set-global-variables)
12257 (gnus-summary-catchup all quietly nil 'fast)
12258 ;; Select next newsgroup or exit.
12259 (if (eq gnus-auto-select-next 'quietly)
12260 (gnus-summary-next-group nil)
12261 (gnus-summary-exit)))
12263 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12264 "Mark all articles in this newsgroup as read, and then exit."
12266 (gnus-set-global-variables)
12267 (gnus-summary-catchup-and-exit t quietly))
12269 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12270 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12271 "Mark all articles in this group as read and select the next group.
12272 If given a prefix, mark all articles, unread as well as ticked, as
12275 (gnus-set-global-variables)
12277 (gnus-summary-catchup all))
12278 (gnus-summary-next-article t nil nil t))
12280 ;; Thread-based commands.
12282 (defun gnus-summary-articles-in-thread (&optional article)
12283 "Return a list of all articles in the current thread.
12284 If ARTICLE is non-nil, return all articles in the thread that starts
12285 with that article."
12286 (let* ((article (or article (gnus-summary-article-number)))
12287 (data (gnus-data-find-list article))
12288 (top-level (gnus-data-level (car data)))
12290 (cond ((null gnus-thread-operation-ignore-subject)
12291 (gnus-simplify-subject-re
12292 (mail-header-subject (gnus-data-header (car data)))))
12293 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12294 (gnus-simplify-subject-fuzzy
12295 (mail-header-subject (gnus-data-header (car data)))))
12299 () ; This article doesn't exist.
12301 (and (or (not top-subject)
12302 (string= top-subject
12303 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12304 (gnus-simplify-subject-fuzzy
12305 (mail-header-subject
12306 (gnus-data-header (car data))))
12307 (gnus-simplify-subject-re
12308 (mail-header-subject
12309 (gnus-data-header (car data)))))))
12310 (setq articles (cons (gnus-data-number (car data)) articles)))
12311 (if (and (setq data (cdr data))
12312 (> (gnus-data-level (car data)) top-level))
12315 ;; Return the list of articles.
12316 (nreverse articles))))
12318 (defun gnus-summary-rethread-current ()
12319 "Rethread the thread the current article is part of."
12321 (gnus-set-global-variables)
12322 (let* ((gnus-show-threads t)
12323 (article (gnus-summary-article-number))
12324 (id (mail-header-id (gnus-summary-article-header)))
12325 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12327 (error "No article on the current line"))
12328 (gnus-rebuild-thread id)
12329 (gnus-summary-goto-subject article)))
12331 (defun gnus-summary-reparent-thread ()
12332 "Make current article child of the marked (or previous) article.
12334 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12335 is non-nil or the Subject: of both articles are the same."
12337 (or (not (gnus-group-read-only-p))
12338 (error "The current newsgroup does not support article editing."))
12339 (or (<= (length gnus-newsgroup-processable) 1)
12340 (error "No more than one article may be marked."))
12341 (save-window-excursion
12342 (let ((gnus-article-buffer " *reparent*")
12343 (current-article (gnus-summary-article-number))
12344 ; first grab the marked article, otherwise one line up.
12345 (parent-article (if (not (null gnus-newsgroup-processable))
12346 (car gnus-newsgroup-processable)
12348 (if (eq (forward-line -1) 0)
12349 (gnus-summary-article-number)
12350 (error "Beginning of summary buffer."))))))
12351 (or (not (eq current-article parent-article))
12352 (error "An article may not be self-referential."))
12353 (let ((message-id (mail-header-id
12354 (gnus-summary-article-header parent-article))))
12355 (or (and message-id (not (equal message-id "")))
12356 (error "No message-id in desired parent."))
12357 (gnus-summary-select-article t t nil current-article)
12358 (set-buffer gnus-article-buffer)
12359 (setq buffer-read-only nil)
12360 (let ((buf (format "%s" (buffer-string))))
12363 (goto-char (point-min))
12364 (if (search-forward-regexp "^References: " nil t)
12365 (insert message-id " " )
12366 (insert "References: " message-id "\n"))
12367 (or (gnus-request-replace-article current-article
12368 (car gnus-article-current)
12369 gnus-article-buffer)
12370 (error "Couldn't replace article."))
12371 (set-buffer gnus-summary-buffer)
12372 (gnus-summary-unmark-all-processable)
12373 (gnus-summary-rethread-current)
12374 (message "Article %d is now the child of article %d."
12375 current-article parent-article)))))
12377 (defun gnus-summary-toggle-threads (&optional arg)
12378 "Toggle showing conversation threads.
12379 If ARG is positive number, turn showing conversation threads on."
12381 (gnus-set-global-variables)
12382 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12383 (setq gnus-show-threads
12384 (if (null arg) (not gnus-show-threads)
12385 (> (prefix-numeric-value arg) 0)))
12386 (gnus-summary-prepare)
12387 (gnus-summary-goto-subject current)
12388 (gnus-summary-position-point)))
12390 (defun gnus-summary-show-all-threads ()
12391 "Show all threads."
12393 (gnus-set-global-variables)
12395 (let ((buffer-read-only nil))
12396 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12397 (gnus-summary-position-point))
12399 (defun gnus-summary-show-thread ()
12400 "Show thread subtrees.
12401 Returns nil if no thread was there to be shown."
12403 (gnus-set-global-variables)
12404 (let ((buffer-read-only nil)
12406 ;; first goto end then to beg, to have point at beg after let
12407 (end (progn (end-of-line) (point)))
12408 (beg (progn (beginning-of-line) (point))))
12410 ;; Any hidden lines here?
12411 (search-forward "\r" end t)
12412 (subst-char-in-region beg end ?\^M ?\n t)
12414 (gnus-summary-position-point))))
12416 (defun gnus-summary-hide-all-threads ()
12417 "Hide all thread subtrees."
12419 (gnus-set-global-variables)
12421 (goto-char (point-min))
12422 (gnus-summary-hide-thread)
12423 (while (zerop (gnus-summary-next-thread 1 t))
12424 (gnus-summary-hide-thread)))
12425 (gnus-summary-position-point))
12427 (defun gnus-summary-hide-thread ()
12428 "Hide thread subtrees.
12429 Returns nil if no threads were there to be hidden."
12431 (gnus-set-global-variables)
12432 (let ((buffer-read-only nil)
12434 (article (gnus-summary-article-number)))
12436 ;; Go forward until either the buffer ends or the subthread
12438 (when (and (not (eobp))
12439 (or (zerop (gnus-summary-next-thread 1 t))
12440 (goto-char (point-max))))
12442 (if (and (> (point) start)
12443 (search-backward "\n" start t))
12445 (subst-char-in-region start (point) ?\n ?\^M)
12446 (gnus-summary-goto-subject article))
12449 ;;(gnus-summary-position-point)
12452 (defun gnus-summary-go-to-next-thread (&optional previous)
12453 "Go to the same level (or less) next thread.
12454 If PREVIOUS is non-nil, go to previous thread instead.
12455 Return the article number moved to, or nil if moving was impossible."
12456 (let ((level (gnus-summary-thread-level))
12457 (way (if previous -1 1))
12460 (while (and (not (eobp))
12461 (< level (gnus-summary-thread-level)))
12462 (forward-line way))
12469 (gnus-summary-article-number)
12470 (goto-char beg)))))
12472 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12473 "Go to the same level (or less) next thread.
12474 If PREVIOUS is non-nil, go to previous thread instead.
12475 Return the article number moved to, or nil if moving was impossible."
12476 (if (and (eq gnus-summary-make-false-root 'dummy)
12477 (gnus-summary-article-intangible-p))
12478 (let ((beg (point)))
12479 (while (and (zerop (forward-line 1))
12480 (not (gnus-summary-article-intangible-p))
12481 (not (zerop (save-excursion
12482 (gnus-summary-thread-level))))))
12488 (let* ((level (gnus-summary-thread-level))
12489 (article (gnus-summary-article-number))
12490 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12493 (if (<= (gnus-data-level (car data)) level)
12494 (setq oart (gnus-data-number (car data))
12496 (setq data (cdr data))))
12498 (gnus-summary-goto-subject oart)))))
12500 (defun gnus-summary-next-thread (n &optional silent)
12501 "Go to the same level next N'th thread.
12502 If N is negative, search backward instead.
12503 Returns the difference between N and the number of skips actually
12506 If SILENT, don't output messages."
12508 (gnus-set-global-variables)
12509 (let ((backward (< n 0))
12512 (while (and (> n 0)
12513 (gnus-summary-go-to-next-thread backward))
12516 (gnus-summary-position-point))
12517 (when (and (not silent) (/= 0 n))
12518 (gnus-message 7 "No more threads"))
12521 (defun gnus-summary-prev-thread (n)
12522 "Go to the same level previous N'th thread.
12523 Returns the difference between N and the number of skips actually
12526 (gnus-set-global-variables)
12527 (gnus-summary-next-thread (- n)))
12529 (defun gnus-summary-go-down-thread ()
12530 "Go down one level in the current thread."
12531 (let ((children (gnus-summary-article-children)))
12533 (gnus-summary-goto-subject (car children)))))
12535 (defun gnus-summary-go-up-thread ()
12536 "Go up one level in the current thread."
12537 (let ((parent (gnus-summary-article-parent)))
12539 (gnus-summary-goto-subject parent))))
12541 (defun gnus-summary-down-thread (n)
12542 "Go down thread N steps.
12543 If N is negative, go up instead.
12544 Returns the difference between N and how many steps down that were
12547 (gnus-set-global-variables)
12550 (while (and (> n 0)
12551 (if up (gnus-summary-go-up-thread)
12552 (gnus-summary-go-down-thread)))
12554 (gnus-summary-position-point)
12555 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12558 (defun gnus-summary-up-thread (n)
12559 "Go up thread N steps.
12560 If N is negative, go up instead.
12561 Returns the difference between N and how many steps down that were
12564 (gnus-set-global-variables)
12565 (gnus-summary-down-thread (- n)))
12567 (defun gnus-summary-top-thread ()
12568 "Go to the top of the thread."
12570 (gnus-set-global-variables)
12571 (while (gnus-summary-go-up-thread))
12572 (gnus-summary-article-number))
12574 (defun gnus-summary-kill-thread (&optional unmark)
12575 "Mark articles under current thread as read.
12576 If the prefix argument is positive, remove any kinds of marks.
12577 If the prefix argument is negative, tick articles instead."
12579 (gnus-set-global-variables)
12581 (setq unmark (prefix-numeric-value unmark)))
12582 (let ((articles (gnus-summary-articles-in-thread)))
12584 ;; Expand the thread.
12585 (gnus-summary-show-thread)
12586 ;; Mark all the articles.
12588 (gnus-summary-goto-subject (car articles))
12589 (cond ((null unmark)
12590 (gnus-summary-mark-article-as-read gnus-killed-mark))
12592 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12594 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12595 (setq articles (cdr articles))))
12596 ;; Hide killed subtrees.
12598 gnus-thread-hide-killed
12599 (gnus-summary-hide-thread))
12600 ;; If marked as read, go to next unread subject.
12602 ;; Go to next unread subject.
12603 (gnus-summary-next-subject 1 t)))
12604 (gnus-set-mode-line 'summary))
12606 ;; Summary sorting commands
12608 (defun gnus-summary-sort-by-number (&optional reverse)
12609 "Sort summary buffer by article number.
12610 Argument REVERSE means reverse order."
12612 (gnus-summary-sort 'number reverse))
12614 (defun gnus-summary-sort-by-author (&optional reverse)
12615 "Sort summary buffer by author name alphabetically.
12616 If case-fold-search is non-nil, case of letters is ignored.
12617 Argument REVERSE means reverse order."
12619 (gnus-summary-sort 'author reverse))
12621 (defun gnus-summary-sort-by-subject (&optional reverse)
12622 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12623 If case-fold-search is non-nil, case of letters is ignored.
12624 Argument REVERSE means reverse order."
12626 (gnus-summary-sort 'subject reverse))
12628 (defun gnus-summary-sort-by-date (&optional reverse)
12629 "Sort summary buffer by date.
12630 Argument REVERSE means reverse order."
12632 (gnus-summary-sort 'date reverse))
12634 (defun gnus-summary-sort-by-score (&optional reverse)
12635 "Sort summary buffer by score.
12636 Argument REVERSE means reverse order."
12638 (gnus-summary-sort 'score reverse))
12640 (defun gnus-summary-sort (predicate reverse)
12641 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12642 (gnus-set-global-variables)
12643 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12644 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12645 (gnus-thread-sort-functions
12650 (,thread t2 t1)))))
12651 (gnus-article-sort-functions
12656 (,article t2 t1)))))
12658 (gnus-summary-prepare-hook nil))
12659 ;; We do the sorting by regenerating the threads.
12660 (gnus-summary-prepare)
12661 ;; Hide subthreads if needed.
12662 (when (and gnus-show-threads gnus-thread-hide-subtree)
12663 (gnus-summary-hide-all-threads)))
12664 ;; If in async mode, we send some info to the backend.
12665 (when gnus-newsgroup-async
12666 (gnus-request-asynchronous
12667 gnus-newsgroup-name gnus-newsgroup-data)))
12669 (defun gnus-sortable-date (date)
12670 "Make sortable string by string-lessp from DATE.
12671 Timezone package is used."
12672 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12673 (year (aref date 0))
12674 (month (aref date 1))
12675 (day (aref date 2)))
12676 (timezone-make-sortable-date
12678 (timezone-make-time-string
12679 (aref date 3) (aref date 4) (aref date 5)))))
12681 ;; Summary saving commands.
12683 (defun gnus-summary-save-article (&optional n not-saved)
12684 "Save the current article using the default saver function.
12685 If N is a positive number, save the N next articles.
12686 If N is a negative number, save the N previous articles.
12687 If N is nil and any articles have been marked with the process mark,
12688 save those articles instead.
12689 The variable `gnus-default-article-saver' specifies the saver function."
12691 (gnus-set-global-variables)
12692 (let ((articles (gnus-summary-work-articles n))
12693 file header article)
12695 (setq header (gnus-summary-article-header
12696 (setq article (pop articles))))
12697 (if (not (vectorp header))
12698 ;; This is a pseudo-article.
12699 (if (assq 'name header)
12700 (gnus-copy-file (cdr (assq 'name header)))
12701 (gnus-message 1 "Article %d is unsaveable" article))
12702 ;; This is a real article.
12703 (save-window-excursion
12704 (gnus-summary-select-article t nil nil article))
12705 (unless gnus-save-all-headers
12706 ;; Remove headers accoring to `gnus-saved-headers'.
12707 (let ((gnus-visible-headers
12708 (or gnus-saved-headers gnus-visible-headers)))
12709 (gnus-article-hide-headers nil t)))
12710 ;; Remove any X-Gnus lines.
12712 (set-buffer gnus-article-buffer)
12714 (let ((buffer-read-only nil))
12715 (nnheader-narrow-to-headers)
12716 (while (re-search-forward "^X-Gnus" nil t)
12717 (gnus-delete-line)))))
12718 (save-window-excursion
12719 (if (not gnus-default-article-saver)
12720 (error "No default saver is defined.")
12721 (setq file (funcall
12722 gnus-default-article-saver
12724 ((not gnus-prompt-before-saving)
12726 ((eq gnus-prompt-before-saving 'always)
12729 (gnus-summary-remove-process-mark article)
12731 (gnus-summary-set-saved-mark article))))
12732 (gnus-summary-position-point)
12735 (defun gnus-summary-pipe-output (&optional arg)
12736 "Pipe the current article to a subprocess.
12737 If N is a positive number, pipe the N next articles.
12738 If N is a negative number, pipe the N previous articles.
12739 If N is nil and any articles have been marked with the process mark,
12740 pipe those articles instead."
12742 (gnus-set-global-variables)
12743 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12744 (gnus-summary-save-article arg t))
12745 (gnus-configure-windows 'pipe))
12747 (defun gnus-summary-save-article-mail (&optional arg)
12748 "Append the current article to an mail file.
12749 If N is a positive number, save the N next articles.
12750 If N is a negative number, save the N previous articles.
12751 If N is nil and any articles have been marked with the process mark,
12752 save those articles instead."
12754 (gnus-set-global-variables)
12755 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12756 (gnus-summary-save-article arg)))
12758 (defun gnus-summary-save-article-rmail (&optional arg)
12759 "Append the current article to an rmail file.
12760 If N is a positive number, save the N next articles.
12761 If N is a negative number, save the N previous articles.
12762 If N is nil and any articles have been marked with the process mark,
12763 save those articles instead."
12765 (gnus-set-global-variables)
12766 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12767 (gnus-summary-save-article arg)))
12769 (defun gnus-summary-save-article-file (&optional arg)
12770 "Append the current article to a file.
12771 If N is a positive number, save the N next articles.
12772 If N is a negative number, save the N previous articles.
12773 If N is nil and any articles have been marked with the process mark,
12774 save those articles instead."
12776 (gnus-set-global-variables)
12777 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12778 (gnus-summary-save-article arg)))
12780 (defun gnus-summary-save-article-body-file (&optional arg)
12781 "Append the current article body to a file.
12782 If N is a positive number, save the N next articles.
12783 If N is a negative number, save the N previous articles.
12784 If N is nil and any articles have been marked with the process mark,
12785 save those articles instead."
12787 (gnus-set-global-variables)
12788 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12789 (gnus-summary-save-article arg)))
12791 (defun gnus-get-split-value (methods)
12792 "Return a value based on the split METHODS."
12793 (let (split-name method result match)
12796 (set-buffer gnus-original-article-buffer)
12798 (nnheader-narrow-to-headers)
12800 (goto-char (point-min))
12801 (setq method (pop methods))
12802 (setq match (car method))
12805 ;; Regular expression.
12807 (re-search-forward match nil t)
12809 ((gnus-functionp match)
12813 (setq result (funcall match gnus-newsgroup-name))))
12818 (setq result (eval match)))))
12819 (setq split-name (append (cdr method) split-name))
12820 (cond ((stringp result)
12821 (push result split-name))
12823 (setq split-name (append result split-name)))))))))
12826 (defun gnus-read-move-group-name (prompt default articles prefix)
12827 "Read a group name."
12828 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12830 (format "Where do you want to %s %s? "
12832 (if (> (length articles) 1)
12833 (format "these %d articles" (length articles))
12841 (format "(default %s) " default)
12843 gnus-active-hashtb nil nil prefix))
12844 ((= 1 (length split-name))
12845 (completing-read prom gnus-active-hashtb
12846 nil nil (cons (car split-name) 0)))
12849 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12852 (if (or (string= to-newsgroup "")
12853 (string= to-newsgroup prefix))
12854 (setq to-newsgroup (or default "")))
12855 (or (gnus-active to-newsgroup)
12856 (gnus-activate-group to-newsgroup)
12857 (error "No such group: %s" to-newsgroup)))
12860 (defun gnus-read-save-file-name (prompt default-name)
12861 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12863 ;; Let the split methods have their say.
12865 ;; No split name was found.
12868 (concat prompt " (default "
12869 (file-name-nondirectory default-name) ") ")
12870 (file-name-directory default-name)
12872 ;; A single split name was found
12873 ((= 1 (length split-name))
12875 (concat prompt " (default " (car split-name) ") ")
12876 gnus-article-save-directory
12877 (concat gnus-article-save-directory (car split-name))))
12878 ;; A list of splits was found.
12880 (setq split-name (mapcar (lambda (el) (list el))
12881 (nreverse split-name)))
12882 (let ((result (completing-read
12883 (concat prompt " ") split-name nil nil)))
12884 (concat gnus-article-save-directory
12885 (if (string= result "")
12888 ;; If we have read a directory, we append the default file name.
12889 (when (file-directory-p file)
12890 (setq file (concat (file-name-as-directory file)
12891 (file-name-nondirectory default-name))))
12892 ;; Possibly translate some charaters.
12893 (nnheader-translate-file-chars file)))
12895 (defun gnus-article-archive-name (group)
12896 "Return the first instance of an \"Archive-name\" in the current buffer."
12897 (let ((case-fold-search t))
12898 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12899 (match-string 1))))
12901 (defun gnus-summary-save-in-rmail (&optional filename)
12902 "Append this article to Rmail file.
12903 Optional argument FILENAME specifies file name.
12904 Directory to save to is default to `gnus-article-save-directory' which
12905 is initialized from the SAVEDIR environment variable."
12907 (gnus-set-global-variables)
12908 (let ((default-name
12909 (funcall gnus-rmail-save-name gnus-newsgroup-name
12910 gnus-current-headers gnus-newsgroup-last-rmail)))
12912 (cond ((eq filename 'default)
12914 (filename filename)
12915 (t (gnus-read-save-file-name
12916 "Save in rmail file:" default-name))))
12917 (gnus-make-directory (file-name-directory filename))
12918 (gnus-eval-in-buffer-window
12919 gnus-original-article-buffer
12923 (gnus-output-to-rmail filename))))
12924 ;; Remember the directory name to save articles
12925 (setq gnus-newsgroup-last-rmail filename)))
12927 (defun gnus-summary-save-in-mail (&optional filename)
12928 "Append this article to Unix mail file.
12929 Optional argument FILENAME specifies file name.
12930 Directory to save to is default to `gnus-article-save-directory' which
12931 is initialized from the SAVEDIR environment variable."
12933 (gnus-set-global-variables)
12934 (let ((default-name
12935 (funcall gnus-mail-save-name gnus-newsgroup-name
12936 gnus-current-headers gnus-newsgroup-last-mail)))
12938 (cond ((eq filename 'default)
12940 (filename filename)
12941 (t (gnus-read-save-file-name
12942 "Save in Unix mail file:" default-name))))
12944 (expand-file-name filename
12946 (file-name-directory default-name))))
12947 (gnus-make-directory (file-name-directory filename))
12948 (gnus-eval-in-buffer-window
12949 gnus-original-article-buffer
12953 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12954 (gnus-output-to-rmail filename)
12955 (let ((mail-use-rfc822 t))
12956 (rmail-output filename 1 t t))))))
12957 ;; Remember the directory name to save articles.
12958 (setq gnus-newsgroup-last-mail filename)))
12960 (defun gnus-summary-save-in-file (&optional filename)
12961 "Append this article to file.
12962 Optional argument FILENAME specifies file name.
12963 Directory to save to is default to `gnus-article-save-directory' which
12964 is initialized from the SAVEDIR environment variable."
12966 (gnus-set-global-variables)
12967 (let ((default-name
12968 (funcall gnus-file-save-name gnus-newsgroup-name
12969 gnus-current-headers gnus-newsgroup-last-file)))
12971 (cond ((eq filename 'default)
12973 (filename filename)
12974 (t (gnus-read-save-file-name
12975 "Save in file:" default-name))))
12976 (gnus-make-directory (file-name-directory filename))
12977 (gnus-eval-in-buffer-window
12978 gnus-original-article-buffer
12982 (gnus-output-to-file filename))))
12983 ;; Remember the directory name to save articles.
12984 (setq gnus-newsgroup-last-file filename)))
12986 (defun gnus-summary-save-body-in-file (&optional filename)
12987 "Append this article body to a file.
12988 Optional argument FILENAME specifies file name.
12989 The directory to save in defaults to `gnus-article-save-directory' which
12990 is initialized from the SAVEDIR environment variable."
12992 (gnus-set-global-variables)
12993 (let ((default-name
12994 (funcall gnus-file-save-name gnus-newsgroup-name
12995 gnus-current-headers gnus-newsgroup-last-file)))
12997 (cond ((eq filename 'default)
12999 (filename filename)
13000 (t (gnus-read-save-file-name
13001 "Save body in file:" default-name))))
13002 (gnus-make-directory (file-name-directory filename))
13003 (gnus-eval-in-buffer-window
13004 gnus-article-buffer
13008 (goto-char (point-min))
13009 (and (search-forward "\n\n" nil t)
13010 (narrow-to-region (point) (point-max)))
13011 (gnus-output-to-file filename))))
13012 ;; Remember the directory name to save articles.
13013 (setq gnus-newsgroup-last-file filename)))
13015 (defun gnus-summary-save-in-pipe (&optional command)
13016 "Pipe this article to subprocess."
13018 (gnus-set-global-variables)
13020 (cond ((eq command 'default)
13021 gnus-last-shell-command)
13023 (t (read-string "Shell command on article: "
13024 gnus-last-shell-command))))
13025 (if (string-equal command "")
13026 (setq command gnus-last-shell-command))
13027 (gnus-eval-in-buffer-window
13028 gnus-article-buffer
13031 (shell-command-on-region (point-min) (point-max) command nil)))
13032 (setq gnus-last-shell-command command))
13034 ;; Summary extract commands
13036 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13037 (let ((buffer-read-only nil)
13038 (article (gnus-summary-article-number))
13040 (or (gnus-summary-goto-subject article)
13041 (error (format "No such article: %d" article)))
13042 (gnus-summary-position-point)
13043 ;; If all commands are to be bunched up on one line, we collect
13045 (if gnus-view-pseudos-separately
13047 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13050 (setq action (cdr (assq 'action (car ps))))
13051 (setq files (list (cdr (assq 'name (car ps)))))
13052 (while (and ps (cdr ps)
13053 (string= (or action "1")
13054 (or (cdr (assq 'action (cadr ps))) "2")))
13055 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13056 (setcdr ps (cddr ps)))
13059 (if (not (string-match "%s" action))
13060 (setq files (cons " " files)))
13061 (setq files (cons " " files))
13062 (and (assq 'execute (car ps))
13063 (setcdr (assq 'execute (car ps))
13064 (funcall (if (string-match "%s" action)
13067 (mapconcat (lambda (f) f) files " ")))))
13068 (setq ps (cdr ps)))))
13069 (if (and gnus-view-pseudos (not not-view))
13071 (and (assq 'execute (car pslist))
13072 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13073 (eq gnus-view-pseudos 'not-confirm)))
13074 (setq pslist (cdr pslist)))
13077 (setq after-article (or (cdr (assq 'article (car pslist)))
13078 (gnus-summary-article-number)))
13079 (gnus-summary-goto-subject after-article)
13082 (insert " " (file-name-nondirectory
13083 (cdr (assq 'name (car pslist))))
13084 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13086 (forward-line -1) ; back to `b'
13087 (add-text-properties
13088 b e (list 'gnus-number gnus-reffed-article-number
13089 gnus-mouse-face-prop gnus-mouse-face))
13091 after-article gnus-reffed-article-number
13092 gnus-unread-mark b (car pslist) 0 (- e b))
13093 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13094 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13095 (setq pslist (cdr pslist)))))))
13097 (defun gnus-pseudos< (p1 p2)
13098 (let ((c1 (cdr (assq 'action p1)))
13099 (c2 (cdr (assq 'action p2))))
13100 (and c1 c2 (string< c1 c2))))
13102 (defun gnus-request-pseudo-article (props)
13103 (cond ((assq 'execute props)
13104 (gnus-execute-command (cdr (assq 'execute props)))))
13105 (let ((gnus-current-article (gnus-summary-article-number)))
13106 (run-hooks 'gnus-mark-article-hook)))
13108 (defun gnus-execute-command (command &optional automatic)
13110 (gnus-article-setup-buffer)
13111 (set-buffer gnus-article-buffer)
13112 (let ((command (if automatic command (read-string "Command: " command)))
13113 (buffer-read-only nil))
13115 (insert "$ " command "\n\n")
13116 (if gnus-view-pseudo-asynchronously
13117 (start-process "gnus-execute" nil "sh" "-c" command)
13118 (call-process "sh" nil t nil "-c" command)))))
13120 (defun gnus-copy-file (file &optional to)
13123 (list (read-file-name "Copy file: " default-directory)
13124 (read-file-name "Copy file to: " default-directory)))
13125 (gnus-set-global-variables)
13126 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13127 (and (file-directory-p to)
13128 (setq to (concat (file-name-as-directory to)
13129 (file-name-nondirectory file))))
13130 (copy-file file to))
13132 ;; Summary kill commands.
13134 (defun gnus-summary-edit-global-kill (article)
13135 "Edit the \"global\" kill file."
13136 (interactive (list (gnus-summary-article-number)))
13137 (gnus-set-global-variables)
13138 (gnus-group-edit-global-kill article))
13140 (defun gnus-summary-edit-local-kill ()
13141 "Edit a local kill file applied to the current newsgroup."
13143 (gnus-set-global-variables)
13144 (setq gnus-current-headers (gnus-summary-article-header))
13145 (gnus-set-global-variables)
13146 (gnus-group-edit-local-kill
13147 (gnus-summary-article-number) gnus-newsgroup-name))
13151 ;;; Gnus article mode
13154 (put 'gnus-article-mode 'mode-class 'special)
13156 (if gnus-article-mode-map
13158 (setq gnus-article-mode-map (make-keymap))
13159 (suppress-keymap gnus-article-mode-map)
13161 (gnus-define-keys gnus-article-mode-map
13162 " " gnus-article-goto-next-page
13163 "\177" gnus-article-goto-prev-page
13164 [delete] gnus-article-goto-prev-page
13165 "\C-c^" gnus-article-refer-article
13166 "h" gnus-article-show-summary
13167 "s" gnus-article-show-summary
13168 "\C-c\C-m" gnus-article-mail
13169 "?" gnus-article-describe-briefly
13170 gnus-mouse-2 gnus-article-push-button
13171 "\r" gnus-article-press-button
13172 "\t" gnus-article-next-button
13173 "\M-\t" gnus-article-prev-button
13174 "\C-c\C-b" gnus-bug)
13176 (substitute-key-definition
13177 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13179 (defun gnus-article-mode ()
13180 "Major mode for displaying an article.
13182 All normal editing commands are switched off.
13184 The following commands are available:
13186 \\<gnus-article-mode-map>
13187 \\[gnus-article-next-page]\t Scroll the article one page forwards
13188 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13189 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13190 \\[gnus-article-show-summary]\t Display the summary buffer
13191 \\[gnus-article-mail]\t Send a reply to the address near point
13192 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13193 \\[gnus-info-find-node]\t Go to the Gnus info node"
13195 (when (and menu-bar-mode
13196 (gnus-visual-p 'article-menu 'menu))
13197 (gnus-article-make-menu-bar))
13198 (kill-all-local-variables)
13199 (gnus-simplify-mode-line)
13200 (setq mode-name "Article")
13201 (setq major-mode 'gnus-article-mode)
13202 (make-local-variable 'minor-mode-alist)
13203 (or (assq 'gnus-show-mime minor-mode-alist)
13204 (setq minor-mode-alist
13205 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13206 (use-local-map gnus-article-mode-map)
13207 (make-local-variable 'page-delimiter)
13208 (setq page-delimiter gnus-page-delimiter)
13209 (buffer-disable-undo (current-buffer))
13210 (setq buffer-read-only t) ;Disable modification
13211 (run-hooks 'gnus-article-mode-hook))
13213 (defun gnus-article-setup-buffer ()
13214 "Initialize the article buffer."
13215 (let* ((name (if gnus-single-article-buffer "*Article*"
13216 (concat "*Article " gnus-newsgroup-name "*")))
13218 (progn (string-match "\\*Article" name)
13219 (concat " *Original Article"
13220 (substring name (match-end 0))))))
13221 (setq gnus-article-buffer name)
13222 (setq gnus-original-article-buffer original)
13223 ;; This might be a variable local to the summary buffer.
13224 (unless gnus-single-article-buffer
13226 (set-buffer gnus-summary-buffer)
13227 (setq gnus-article-buffer name)
13228 (setq gnus-original-article-buffer original)
13229 (gnus-set-global-variables))
13230 (make-local-variable 'gnus-summary-buffer))
13231 ;; Init original article buffer.
13233 (set-buffer (get-buffer-create gnus-original-article-buffer))
13234 (buffer-disable-undo (current-buffer))
13235 (setq major-mode 'gnus-original-article-mode)
13236 (make-local-variable 'gnus-original-article))
13237 (if (get-buffer name)
13240 (buffer-disable-undo (current-buffer))
13241 (setq buffer-read-only t)
13242 (gnus-add-current-to-buffer-list)
13243 (or (eq major-mode 'gnus-article-mode)
13244 (gnus-article-mode))
13247 (set-buffer (get-buffer-create name))
13248 (gnus-add-current-to-buffer-list)
13249 (gnus-article-mode)
13250 (current-buffer)))))
13252 ;; Set article window start at LINE, where LINE is the number of lines
13253 ;; from the head of the article.
13254 (defun gnus-article-set-window-start (&optional line)
13256 (get-buffer-window gnus-article-buffer)
13258 (set-buffer gnus-article-buffer)
13259 (goto-char (point-min))
13262 (gnus-message 6 "Moved to bookmark")
13263 (search-forward "\n\n" nil t)
13264 (forward-line line)
13267 (defun gnus-kill-all-overlays ()
13268 "Delete all overlays in the current buffer."
13269 (when (fboundp 'overlay-lists)
13270 (let* ((overlayss (overlay-lists))
13271 (buffer-read-only nil)
13272 (overlays (nconc (car overlayss) (cdr overlayss))))
13274 (delete-overlay (pop overlays))))))
13276 (defun gnus-request-article-this-buffer (article group)
13277 "Get an article and insert it into this buffer."
13278 (let (do-update-line)
13282 (gnus-kill-all-overlays)
13283 (setq group (or group gnus-newsgroup-name))
13285 ;; Open server if it has closed.
13286 (gnus-check-server (gnus-find-method-for-group group))
13288 ;; Using `gnus-request-article' directly will insert the article into
13289 ;; `nntp-server-buffer' - so we'll save some time by not having to
13290 ;; copy it from the server buffer into the article buffer.
13292 ;; We only request an article by message-id when we do not have the
13293 ;; headers for it, so we'll have to get those.
13294 (when (stringp article)
13295 (let ((gnus-override-method gnus-refer-article-method))
13296 (gnus-read-header article)))
13298 ;; If the article number is negative, that means that this article
13299 ;; doesn't belong in this newsgroup (possibly), so we find its
13300 ;; message-id and request it by id instead of number.
13301 (when (and (numberp article)
13302 gnus-summary-buffer
13303 (get-buffer gnus-summary-buffer)
13304 (buffer-name (get-buffer gnus-summary-buffer)))
13306 (set-buffer gnus-summary-buffer)
13307 (let ((header (gnus-summary-article-header article)))
13310 ((memq article gnus-newsgroup-sparse)
13311 ;; This is a sparse gap article.
13312 (setq do-update-line article)
13313 (setq article (mail-header-id header))
13314 (let ((gnus-override-method gnus-refer-article-method))
13315 (gnus-read-header article)))
13317 ;; It's a real article.
13318 (setq article (mail-header-id header)))
13320 ;; It is an extracted pseudo-article.
13321 (setq article 'pseudo)
13322 (gnus-request-pseudo-article header))))
13324 (let ((method (gnus-find-method-for-group
13325 gnus-newsgroup-name)))
13326 (if (not (eq (car method) 'nneething))
13328 (let ((dir (concat (file-name-as-directory (nth 1 method))
13329 (mail-header-subject header))))
13330 (if (file-directory-p dir)
13332 (setq article 'nneething)
13333 (gnus-group-enter-directory dir)))))))))
13336 ;; We first check `gnus-original-article-buffer'.
13337 ((and (get-buffer gnus-original-article-buffer)
13339 (set-buffer gnus-original-article-buffer)
13340 (and (equal (car gnus-original-article) group)
13341 (eq (cdr gnus-original-article) article))))
13342 (insert-buffer-substring gnus-original-article-buffer)
13344 ;; Check the backlog.
13345 ((and gnus-keep-backlog
13346 (gnus-backlog-request-article group article (current-buffer)))
13348 ;; Check the cache.
13349 ((and gnus-use-cache
13351 (gnus-cache-request-article article group))
13353 ;; Get the article and put into the article buffer.
13354 ((or (stringp article) (numberp article))
13355 (let ((gnus-override-method
13356 (and (stringp article) gnus-refer-article-method))
13357 (buffer-read-only nil))
13359 (gnus-kill-all-overlays)
13360 (if (gnus-request-article article group (current-buffer))
13362 (and gnus-keep-backlog
13364 (gnus-backlog-enter-article
13365 group article (current-buffer)))
13367 ;; It was a pseudo.
13370 ;; Take the article from the original article buffer
13371 ;; and place it in the buffer it's supposed to be in.
13372 (when (and (get-buffer gnus-article-buffer)
13373 (equal (buffer-name (current-buffer))
13374 (buffer-name (get-buffer gnus-article-buffer))))
13376 (if (get-buffer gnus-original-article-buffer)
13377 (set-buffer (get-buffer gnus-original-article-buffer))
13378 (set-buffer (get-buffer-create gnus-original-article-buffer))
13379 (buffer-disable-undo (current-buffer))
13380 (setq major-mode 'gnus-original-article-mode)
13381 (setq buffer-read-only t)
13382 (gnus-add-current-to-buffer-list))
13383 (let (buffer-read-only)
13385 (insert-buffer-substring gnus-article-buffer))
13386 (setq gnus-original-article (cons group article))))
13388 ;; Update sparse articles.
13389 (when do-update-line
13391 (set-buffer gnus-summary-buffer)
13392 (gnus-summary-update-article do-update-line)
13393 (gnus-summary-goto-subject do-update-line)
13394 (set-window-point (get-buffer-window (current-buffer) t)
13397 (defun gnus-read-header (id &optional header)
13398 "Read the headers of article ID and enter them into the Gnus system."
13399 (let ((group gnus-newsgroup-name)
13401 ;; First we check to see whether the header in question is already
13404 ;; This is a Message-ID.
13405 (setq header (or header (gnus-id-to-header id)))
13406 ;; This is an article number.
13407 (setq header (or header (gnus-summary-article-header id))))
13409 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13410 ;; We have found the header.
13412 ;; We have to really fetch the header to this article.
13414 (if (gnus-check-backend-function 'request-head group)
13415 (gnus-request-head id group)
13416 (gnus-request-article id group)))
13418 (set-buffer nntp-server-buffer)
13419 (and (search-forward "\n\n" nil t)
13420 (delete-region (1- (point)) (point-max)))
13421 (goto-char (point-max))
13423 (goto-char (point-min))
13427 ((cdr where) (cdr where))
13428 (header (mail-header-number header))
13429 (t gnus-reffed-article-number))
13431 (insert " Article retrieved.\n"))
13433 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13434 ; (setcar (gnus-id-to-thread id) nil))
13435 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13436 () ; Malformed head.
13437 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13438 (if (and (stringp id)
13439 (not (string= (gnus-group-real-name group)
13441 ;; If we fetched by Message-ID and the article came
13442 ;; from a different group, we fudge some bogus article
13443 ;; numbers for this article.
13444 (mail-header-set-number header gnus-reffed-article-number))
13445 (decf gnus-reffed-article-number)
13446 (push header gnus-newsgroup-headers)
13447 (setq gnus-current-headers header)
13448 (push (mail-header-number header) gnus-newsgroup-limit))
13451 (defun gnus-article-prepare (article &optional all-headers header)
13452 "Prepare ARTICLE in article mode buffer.
13453 ARTICLE should either be an article number or a Message-ID.
13454 If ARTICLE is an id, HEADER should be the article headers.
13455 If ALL-HEADERS is non-nil, no headers are hidden."
13457 ;; Make sure we start in a summary buffer.
13458 (unless (eq major-mode 'gnus-summary-mode)
13459 (set-buffer gnus-summary-buffer))
13460 (setq gnus-summary-buffer (current-buffer))
13461 ;; Make sure the connection to the server is alive.
13462 (unless (gnus-server-opened
13463 (gnus-find-method-for-group gnus-newsgroup-name))
13464 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13465 (gnus-request-group gnus-newsgroup-name t))
13466 (let* ((article (if header (mail-header-number header) article))
13467 (summary-buffer (current-buffer))
13468 (internal-hook gnus-article-internal-prepare-hook)
13469 (group gnus-newsgroup-name)
13472 (gnus-article-setup-buffer)
13473 (set-buffer gnus-article-buffer)
13474 ;; Deactivate active regions.
13475 (when (and (boundp 'transient-mark-mode)
13476 transient-mark-mode)
13477 (setq mark-active nil))
13478 (if (not (setq result (let ((buffer-read-only nil))
13479 (gnus-request-article-this-buffer
13481 ;; There is no such article.
13483 (when (and (numberp article)
13484 (not (memq article gnus-newsgroup-sparse)))
13485 (setq gnus-article-current
13486 (cons gnus-newsgroup-name article))
13487 (set-buffer gnus-summary-buffer)
13488 (setq gnus-current-article article)
13489 (gnus-summary-mark-article article gnus-canceled-mark))
13490 (unless (memq article gnus-newsgroup-sparse)
13492 1 "No such article (may have expired or been canceled)")
13495 (if (or (eq result 'pseudo) (eq result 'nneething))
13498 (set-buffer summary-buffer)
13499 (setq gnus-last-article gnus-current-article
13500 gnus-newsgroup-history (cons gnus-current-article
13501 gnus-newsgroup-history)
13502 gnus-current-article 0
13503 gnus-current-headers nil
13504 gnus-article-current nil)
13505 (if (eq result 'nneething)
13506 (gnus-configure-windows 'summary)
13507 (gnus-configure-windows 'article))
13508 (gnus-set-global-variables))
13509 (gnus-set-mode-line 'article))
13510 ;; The result from the `request' was an actual article -
13511 ;; or at least some text that is now displayed in the
13513 (if (and (numberp article)
13514 (not (eq article gnus-current-article)))
13515 ;; Seems like a new article has been selected.
13516 ;; `gnus-current-article' must be an article number.
13518 (set-buffer summary-buffer)
13519 (setq gnus-last-article gnus-current-article
13520 gnus-newsgroup-history (cons gnus-current-article
13521 gnus-newsgroup-history)
13522 gnus-current-article article
13523 gnus-current-headers
13524 (gnus-summary-article-header gnus-current-article)
13525 gnus-article-current
13526 (cons gnus-newsgroup-name gnus-current-article))
13527 (unless (vectorp gnus-current-headers)
13528 (setq gnus-current-headers nil))
13529 (gnus-summary-show-thread)
13530 (run-hooks 'gnus-mark-article-hook)
13531 (gnus-set-mode-line 'summary)
13532 (and (gnus-visual-p 'article-highlight 'highlight)
13533 (run-hooks 'gnus-visual-mark-article-hook))
13534 ;; Set the global newsgroup variables here.
13535 ;; Suggested by Jim Sisolak
13536 ;; <sisolak@trans4.neep.wisc.edu>.
13537 (gnus-set-global-variables)
13538 (setq gnus-have-all-headers
13539 (or all-headers gnus-show-all-headers))
13540 (and gnus-use-cache
13541 (vectorp (gnus-summary-article-header article))
13542 (gnus-cache-possibly-enter-article
13544 (gnus-summary-article-header article)
13545 (memq article gnus-newsgroup-marked)
13546 (memq article gnus-newsgroup-dormant)
13547 (memq article gnus-newsgroup-unreads)))))
13548 ;; Hooks for getting information from the article.
13549 ;; This hook must be called before being narrowed.
13550 (let (buffer-read-only)
13551 (run-hooks 'internal-hook)
13552 (run-hooks 'gnus-article-prepare-hook)
13553 ;; Decode MIME message.
13555 (if (or (not gnus-strict-mime)
13556 (gnus-fetch-field "Mime-Version"))
13557 (funcall gnus-show-mime-method)
13558 (funcall gnus-decode-encoded-word-method)))
13559 ;; Perform the article display hooks.
13560 (run-hooks 'gnus-article-display-hook))
13562 (goto-char (point-min))
13563 (and gnus-break-pages (gnus-narrow-to-page))
13564 (gnus-set-mode-line 'article)
13565 (gnus-configure-windows 'article)
13566 (goto-char (point-min))
13569 (defun gnus-article-show-all-headers ()
13570 "Show all article headers in article mode buffer."
13572 (gnus-article-setup-buffer)
13573 (set-buffer gnus-article-buffer)
13574 (let ((buffer-read-only nil))
13575 (gnus-unhide-text (point-min) (point-max)))))
13577 (defun gnus-article-hide-headers-if-wanted ()
13578 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13579 Provided for backwards compatibility."
13580 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13581 gnus-inhibit-hiding
13582 (gnus-article-hide-headers)))
13584 (defun gnus-article-hide-headers (&optional arg delete)
13585 "Toggle whether to hide unwanted headers and possibly sort them as well.
13586 If given a negative prefix, always show; if given a positive prefix,
13589 (unless (gnus-article-check-hidden-text 'headers arg)
13590 ;; This function might be inhibited.
13591 (unless gnus-inhibit-hiding
13593 (set-buffer gnus-article-buffer)
13595 (let ((buffer-read-only nil)
13596 (props (nconc (list 'gnus-type 'headers)
13597 gnus-hidden-properties))
13598 (ignored (when (not (stringp gnus-visible-headers))
13599 (cond ((stringp gnus-ignored-headers)
13600 gnus-ignored-headers)
13601 ((listp gnus-ignored-headers)
13602 (mapconcat 'identity gnus-ignored-headers
13605 (cond ((stringp gnus-visible-headers)
13606 gnus-visible-headers)
13607 ((and gnus-visible-headers
13608 (listp gnus-visible-headers))
13609 (mapconcat 'identity gnus-visible-headers "\\|"))))
13611 ;; First we narrow to just the headers.
13613 (goto-char (point-min))
13614 ;; Hide any "From " lines at the beginning of (mail) articles.
13615 (while (looking-at "From ")
13618 (gnus-hide-text (point-min) (point) props))
13619 ;; Then treat the rest of the header lines.
13622 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13623 ;; Then we use the two regular expressions
13624 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13625 ;; select which header lines is to remain visible in the
13627 (goto-char (point-min))
13628 (while (re-search-forward "^[^ \t]*:" nil t)
13629 (beginning-of-line)
13630 ;; We add the headers we want to keep to a list and delete
13631 ;; them from the buffer.
13632 (if (or (and visible (looking-at visible))
13633 (and ignored (not (looking-at ignored))))
13635 (push (buffer-substring
13639 ;; Be sure to get multi-line headers...
13640 (re-search-forward "^[^ \t]*:" nil t)
13641 (beginning-of-line)
13644 (delete-region beg (point)))
13646 ;; Sort the headers that we want to display.
13647 (setq want-list (sort want-list 'gnus-article-header-less))
13648 (goto-char (point-min))
13650 (insert (pop want-list)))
13651 ;; We make the unwanted headers invisible.
13653 (delete-region (point-min) (point-max))
13654 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13655 (gnus-hide-text-type (point) (point-max) 'headers))))))))
13657 (defsubst gnus-article-header-rank (header)
13658 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13659 (let ((list gnus-sorted-header-list)
13662 (when (string-match (car list) header)
13664 (setq list (cdr list))
13668 (defun gnus-article-header-less (h1 h2)
13669 "Say whether string H1 is \"less\" than string H2."
13670 (< (gnus-article-header-rank h1)
13671 (gnus-article-header-rank h2)))
13673 (defun gnus-article-hide-boring-headers (&optional arg)
13674 "Toggle hiding of headers that aren't very interesting.
13675 If given a negative prefix, always show; if given a positive prefix,
13678 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13680 (set-buffer gnus-article-buffer)
13682 (let ((buffer-read-only nil)
13683 (list gnus-boring-article-headers)
13684 (inhibit-point-motion-hooks t)
13686 (nnheader-narrow-to-headers)
13688 (setq elem (pop list))
13689 (goto-char (point-min))
13691 ;; Hide empty headers.
13693 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13695 (gnus-hide-text-type
13696 (progn (beginning-of-line) (point))
13699 (if (re-search-forward "^[^ \t]" nil t)
13700 (match-beginning 0)
13703 ;; Hide boring Newsgroups header.
13704 ((eq elem 'newsgroups)
13705 (when (equal (mail-fetch-field "newsgroups")
13706 (gnus-group-real-name gnus-newsgroup-name))
13707 (gnus-article-hide-header "newsgroups")))
13708 ((eq elem 'followup-to)
13709 (when (equal (mail-fetch-field "followup-to")
13710 (mail-fetch-field "newsgroups"))
13711 (gnus-article-hide-header "followup-to")))
13712 ((eq elem 'reply-to)
13713 (let ((from (mail-fetch-field "from"))
13714 (reply-to (mail-fetch-field "reply-to")))
13718 (nth 1 (funcall gnus-extract-address-components from))
13719 (nth 1 (funcall gnus-extract-address-components
13721 (gnus-article-hide-header "reply-to"))))
13723 (let ((date (mail-fetch-field "date")))
13725 (< (gnus-days-between date (current-time-string))
13727 (gnus-article-hide-header "date")))))))))))
13729 (defun gnus-article-hide-header (header)
13731 (goto-char (point-min))
13732 (when (re-search-forward (concat "^" header ":") nil t)
13733 (gnus-hide-text-type
13734 (progn (beginning-of-line) (point))
13737 (if (re-search-forward "^[^ \t]" nil t)
13738 (match-beginning 0)
13740 'boring-headers))))
13742 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13743 (defun gnus-article-treat-overstrike ()
13744 "Translate overstrikes into bold text."
13747 (set-buffer gnus-article-buffer)
13748 (let ((buffer-read-only nil))
13749 (while (search-forward "\b" nil t)
13750 (let ((next (following-char))
13751 (previous (char-after (- (point) 2))))
13752 (cond ((eq next previous)
13753 (put-text-property (- (point) 2) (point) 'invisible t)
13754 (put-text-property (point) (1+ (point)) 'face 'bold))
13756 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13758 (- (point) 2) (1- (point)) 'face 'underline))
13760 (put-text-property (- (point) 2) (point) 'invisible t)
13762 (point) (1+ (point)) 'face 'underline))))))))
13764 (defun gnus-article-word-wrap ()
13765 "Format too long lines."
13768 (set-buffer gnus-article-buffer)
13769 (let ((buffer-read-only nil))
13771 (goto-char (point-min))
13772 (search-forward "\n\n" nil t)
13774 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13775 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13776 (adaptive-fill-mode t))
13777 (while (not (eobp))
13778 (and (>= (current-column) (min fill-column (window-width)))
13779 (/= (preceding-char) ?:)
13780 (fill-paragraph nil))
13781 (end-of-line 2))))))
13783 (defun gnus-article-remove-cr ()
13784 "Remove carriage returns from an article."
13787 (set-buffer gnus-article-buffer)
13788 (let ((buffer-read-only nil))
13789 (goto-char (point-min))
13790 (while (search-forward "\r" nil t)
13791 (replace-match "" t t)))))
13793 (defun gnus-article-remove-trailing-blank-lines ()
13794 "Remove all trailing blank lines from the article."
13797 (set-buffer gnus-article-buffer)
13798 (let ((buffer-read-only nil))
13799 (goto-char (point-max))
13803 (while (looking-at "^[ \t]*$")
13808 (defun gnus-article-display-x-face (&optional force)
13809 "Look for an X-Face header and display it if present."
13810 (interactive (list 'force))
13812 (set-buffer gnus-article-buffer)
13813 ;; Delete the old process, if any.
13814 (when (process-status "gnus-x-face")
13815 (delete-process "gnus-x-face"))
13816 (let ((inhibit-point-motion-hooks t)
13817 (case-fold-search nil)
13820 (nnheader-narrow-to-headers)
13821 (setq from (mail-fetch-field "from"))
13822 (goto-char (point-min))
13823 (when (and gnus-article-x-face-command
13825 ;; Check whether this face is censored.
13826 (not gnus-article-x-face-too-ugly)
13827 (and gnus-article-x-face-too-ugly from
13828 (not (string-match gnus-article-x-face-too-ugly
13830 ;; Has to be present.
13831 (re-search-forward "^X-Face: " nil t))
13832 ;; We now have the area of the buffer where the X-Face is stored.
13833 (let ((beg (point))
13834 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13835 ;; We display the face.
13836 (if (symbolp gnus-article-x-face-command)
13837 ;; The command is a lisp function, so we call it.
13838 (if (gnus-functionp gnus-article-x-face-command)
13839 (funcall gnus-article-x-face-command beg end)
13840 (error "%s is not a function" gnus-article-x-face-command))
13841 ;; The command is a string, so we interpret the command
13842 ;; as a, well, command, and fork it off.
13843 (let ((process-connection-type nil))
13844 (process-kill-without-query
13846 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13847 (process-send-region "gnus-x-face" beg end)
13848 (process-send-eof "gnus-x-face")))))))))
13850 (defun gnus-headers-decode-quoted-printable ()
13851 "Hack to remove QP encoding from headers."
13852 (let ((case-fold-search t)
13853 (inhibit-point-motion-hooks t)
13855 (goto-char (point-min))
13856 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13857 (setq string (match-string 1))
13858 (narrow-to-region (match-beginning 0) (match-end 0))
13859 (delete-region (point-min) (point-max))
13861 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13862 (subst-char-in-region (point-min) (point-max) ?_ ? )
13864 (goto-char (point-min)))))
13866 (defun gnus-article-de-quoted-unreadable (&optional force)
13867 "Do a naive translation of a quoted-printable-encoded article.
13868 This is in no way, shape or form meant as a replacement for real MIME
13869 processing, but is simply a stop-gap measure until MIME support is
13871 If FORCE, decode the article whether it is marked as quoted-printable
13873 (interactive (list 'force))
13875 (set-buffer gnus-article-buffer)
13876 (let ((case-fold-search t)
13877 (buffer-read-only nil)
13878 (type (gnus-fetch-field "content-transfer-encoding")))
13880 (and type (string-match "quoted-printable" type)))
13881 (gnus-headers-decode-quoted-printable)
13882 (goto-char (point-min))
13883 (search-forward "\n\n" nil 'move)
13884 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13886 (defun gnus-mime-decode-quoted-printable (from to)
13887 "Decode Quoted-Printable in the region between FROM and TO."
13889 (while (search-forward "=" to t)
13890 (cond ((eq (following-char) ?\n)
13893 ((looking-at "[0-9A-F][0-9A-F]")
13895 (insert (hexl-hex-string-to-integer
13896 (buffer-substring (point) (+ 2 (point)))))
13900 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13902 (defun gnus-article-hide-pgp (&optional arg)
13903 "Toggle hiding of any PGP headers and signatures in the current article.
13904 If given a negative prefix, always show; if given a positive prefix,
13907 (unless (gnus-article-check-hidden-text 'pgp arg)
13909 (set-buffer gnus-article-buffer)
13910 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13911 buffer-read-only beg end)
13913 (goto-char (point-min))
13914 ;; Hide the "header".
13915 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13916 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13918 ;; Hide the actual signature.
13919 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13920 (setq end (1+ (match-beginning 0)))
13923 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13925 ;; Perhaps we shouldn't hide to the end of the buffer
13926 ;; if there is no end to the signature?
13929 ;; Hide "- " PGP quotation markers.
13930 (when (and beg end)
13931 (narrow-to-region beg end)
13932 (goto-char (point-min))
13933 (while (re-search-forward "^- " nil t)
13934 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13937 (defun gnus-article-hide-signature (&optional arg)
13938 "Hide the signature in the current article.
13939 If given a negative prefix, always show; if given a positive prefix,
13942 (unless (gnus-article-check-hidden-text 'signature arg)
13944 (set-buffer gnus-article-buffer)
13946 (let ((buffer-read-only nil))
13947 (when (gnus-narrow-to-signature)
13948 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
13950 (defun gnus-article-strip-leading-blank-lines ()
13951 "Remove all blank lines from the beginning of the article."
13954 (set-buffer gnus-article-buffer)
13955 (let (buffer-read-only)
13956 (goto-char (point-min))
13957 (when (search-forward "\n\n" nil t)
13958 (while (looking-at "[ \t]$")
13959 (gnus-delete-line))))))
13961 (defun gnus-narrow-to-signature ()
13962 "Narrow to the signature."
13964 (goto-char (point-max))
13965 (when (re-search-backward gnus-signature-separator nil t)
13967 (when (or (null gnus-signature-limit)
13968 (and (numberp gnus-signature-limit)
13969 (< (- (point-max) (point)) gnus-signature-limit))
13970 (and (gnus-functionp gnus-signature-limit)
13971 (funcall gnus-signature-limit))
13972 (and (stringp gnus-signature-limit)
13973 (not (re-search-forward gnus-signature-limit nil t))))
13974 (narrow-to-region (point) (point-max))
13977 (defun gnus-article-check-hidden-text (type arg)
13978 "Return nil if hiding is necessary."
13980 (set-buffer gnus-article-buffer)
13981 (let ((hide (gnus-article-hidden-text-p type)))
13982 (cond ((or (and (null arg) (eq hide 'hidden))
13983 (and arg (< 0 (prefix-numeric-value arg))))
13984 (gnus-article-show-hidden-text type))
13986 (gnus-article-show-hidden-text type t))
13989 (defun gnus-article-hidden-text-p (type)
13990 "Say whether the current buffer contains hidden text of type TYPE."
13991 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
13993 (if (get-text-property pos 'invisible)
13997 (defun gnus-article-hide (&optional arg force)
13998 "Hide all the gruft in the current article.
13999 This means that PGP stuff, signatures, cited text and (some)
14000 headers will be hidden.
14001 If given a prefix, show the hidden text instead."
14002 (interactive (list current-prefix-arg 'force))
14003 (gnus-article-hide-headers arg)
14004 (gnus-article-hide-pgp arg)
14005 (gnus-article-hide-citation-maybe arg force)
14006 (gnus-article-hide-signature arg))
14008 (defun gnus-article-show-hidden-text (type &optional hide)
14009 "Show all hidden text of type TYPE.
14010 If HIDE, hide the text instead."
14012 (set-buffer gnus-article-buffer)
14013 (let ((buffer-read-only nil)
14014 (inhibit-point-motion-hooks t)
14016 (while (gnus-goto-char (text-property-any
14017 beg (point-max) 'gnus-type type))
14021 (gnus-hide-text beg (point) gnus-hidden-properties)
14022 (gnus-unhide-text beg (point)))
14023 (setq beg (point)))
14026 (defvar gnus-article-time-units
14027 `((year . ,(* 365.25 24 60 60))
14028 (week . ,(* 7 24 60 60))
14029 (day . ,(* 24 60 60))
14030 (hour . ,(* 60 60))
14033 "Mapping from time units to seconds.")
14035 (defun gnus-article-date-ut (&optional type highlight)
14036 "Convert DATE date to universal time in the current article.
14037 If TYPE is `local', convert to local time; if it is `lapsed', output
14038 how much time has lapsed since DATE."
14039 (interactive (list 'ut t))
14040 (let* ((header (or gnus-current-headers
14041 (gnus-summary-article-header) ""))
14042 (date (and (vectorp header) (mail-header-date header)))
14043 (date-regexp "^Date: \\|^X-Sent: ")
14044 (now (current-time))
14045 (inhibit-point-motion-hooks t)
14047 (when (and date (not (string= date "")))
14049 (set-buffer gnus-article-buffer)
14051 (nnheader-narrow-to-headers)
14052 (let ((buffer-read-only nil))
14053 ;; Delete any old Date headers.
14054 (if (re-search-forward date-regexp nil t)
14056 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14057 eface (get-text-property (gnus-point-at-eol) 'face))
14058 (message-remove-header date-regexp t)
14059 (beginning-of-line))
14060 (goto-char (point-max)))
14063 ;; Convert to the local timezone. We have to slap a
14064 ;; `condition-case' round the calls to the timezone
14065 ;; functions since they aren't particularly resistant to
14068 (concat "Date: " (condition-case ()
14069 (timezone-make-date-arpa-standard date)
14072 ;; Convert to Universal Time.
14076 (timezone-make-date-arpa-standard date nil "UT")
14079 ;; Get the original date from the article.
14080 ((eq type 'original)
14081 (concat "Date: " date "\n"))
14082 ;; Do an X-Sent lapsed format.
14084 ;; If the date is seriously mangled, the timezone
14085 ;; functions are liable to bug out, so we condition-case
14086 ;; the entire thing.
14091 (timezone-make-date-arpa-standard
14092 (current-time-string now)
14093 (current-time-zone now) "UT"))
14095 (timezone-make-date-arpa-standard
14098 (real-sec (+ (* (float (car real-time)) 65536)
14100 (sec (abs real-sec))
14106 ;; This is a bit convoluted, but basically we go
14107 ;; through the time units for years, weeks, etc,
14108 ;; and divide things to see whether that results
14109 ;; in positive answers.
14112 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14113 ;; The (remaining) seconds are too few to
14114 ;; be divided into this time unit.
14116 ;; It's big enough, so we output it.
14117 (setq sec (- sec (* num (cdr unit))))
14119 (concat (if prev ", " "") (int-to-string
14121 " " (symbol-name (car unit))
14122 (if (> num 1) "s" ""))
14124 gnus-article-time-units "")
14125 ;; If dates are odd, then it might appear like the
14126 ;; article was sent in the future.
14129 " in the future\n")))))
14131 (error "Unknown conversion type: %s" type)))))
14132 ;; Do highlighting.
14133 (beginning-of-line)
14134 (when (and highlight (gnus-visual-p 'article-highlight 'highlight)
14135 (looking-at "\\([^:]\\): *\\(.*\\)$"))
14136 (put-text-property (match-beginning 1) (match-end 1)
14138 (put-text-property (match-beginning 2) (match-end 2)
14141 (defun gnus-article-date-local (&optional highlight)
14142 "Convert the current article date to the local timezone."
14143 (interactive (list t))
14144 (gnus-article-date-ut 'local highlight))
14146 (defun gnus-article-date-original (&optional highlight)
14147 "Convert the current article date to what it was originally.
14148 This is only useful if you have used some other date conversion
14149 function and want to see what the date was before converting."
14150 (interactive (list t))
14151 (gnus-article-date-ut 'original highlight))
14153 (defun gnus-article-date-lapsed (&optional highlight)
14154 "Convert the current article date to time lapsed since it was sent."
14155 (interactive (list t))
14156 (gnus-article-date-ut 'lapsed highlight))
14158 (defun gnus-article-maybe-highlight ()
14159 "Do some article highlighting if `gnus-visual' is non-nil."
14160 (if (gnus-visual-p 'article-highlight 'highlight)
14161 (gnus-article-highlight-some)))
14165 (defun gnus-output-to-rmail (file-name)
14166 "Append the current article to an Rmail file named FILE-NAME."
14168 ;; Most of these codes are borrowed from rmailout.el.
14169 (setq file-name (expand-file-name file-name))
14170 (setq rmail-default-rmail-file file-name)
14171 (let ((artbuf (current-buffer))
14172 (tmpbuf (get-buffer-create " *Gnus-output*")))
14174 (or (get-file-buffer file-name)
14175 (file-exists-p file-name)
14176 (if (gnus-yes-or-no-p
14177 (concat "\"" file-name "\" does not exist, create it? "))
14178 (let ((file-buffer (create-file-buffer file-name)))
14180 (set-buffer file-buffer)
14181 (rmail-insert-rmail-file-header)
14182 (let ((require-final-newline nil))
14183 (write-region (point-min) (point-max) file-name t 1)))
14184 (kill-buffer file-buffer))
14185 (error "Output file does not exist")))
14186 (set-buffer tmpbuf)
14187 (buffer-disable-undo (current-buffer))
14189 (insert-buffer-substring artbuf)
14190 (gnus-convert-article-to-rmail)
14191 ;; Decide whether to append to a file or to an Emacs buffer.
14192 (let ((outbuf (get-file-buffer file-name)))
14194 (append-to-file (point-min) (point-max) file-name)
14195 ;; File has been visited, in buffer OUTBUF.
14196 (set-buffer outbuf)
14197 (let ((buffer-read-only nil)
14198 (msg (and (boundp 'rmail-current-message)
14199 (symbol-value 'rmail-current-message))))
14200 ;; If MSG is non-nil, buffer is in RMAIL mode.
14203 (narrow-to-region (point-max) (point-max))))
14204 (insert-buffer-substring tmpbuf)
14207 (goto-char (point-min))
14209 (search-backward "\^_")
14210 (narrow-to-region (point) (point-max))
14211 (goto-char (1+ (point-min)))
14212 (rmail-count-new-messages t)
14213 (rmail-show-message msg)))))))
14214 (kill-buffer tmpbuf)))
14216 (defun gnus-output-to-file (file-name)
14217 "Append the current article to a file named FILE-NAME."
14218 (setq file-name (expand-file-name file-name))
14219 (let ((artbuf (current-buffer))
14220 (tmpbuf (get-buffer-create " *Gnus-output*")))
14222 (set-buffer tmpbuf)
14223 (buffer-disable-undo (current-buffer))
14225 (insert-buffer-substring artbuf)
14226 ;; Append newline at end of the buffer as separator, and then
14227 ;; save it to file.
14228 (goto-char (point-max))
14230 (append-to-file (point-min) (point-max) file-name))
14231 (kill-buffer tmpbuf)))
14233 (defun gnus-convert-article-to-rmail ()
14234 "Convert article in current buffer to Rmail message format."
14235 (let ((buffer-read-only nil))
14236 ;; Convert article directly into Babyl format.
14237 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14238 (goto-char (point-min))
14239 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14240 (while (search-forward "\n\^_" nil t) ;single char
14241 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14242 (goto-char (point-max))
14245 (defun gnus-narrow-to-page (&optional arg)
14246 "Narrow the article buffer to a page.
14247 If given a numerical ARG, move forward ARG pages."
14249 (setq arg (if arg (prefix-numeric-value arg) 0))
14251 (set-buffer gnus-article-buffer)
14252 (goto-char (point-min))
14254 (when (gnus-visual-p 'page-marker)
14255 (let ((buffer-read-only nil))
14256 (gnus-remove-text-with-property 'gnus-prev)
14257 (gnus-remove-text-with-property 'gnus-next)))
14260 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14262 (re-search-forward page-delimiter nil 'move arg)))
14263 (goto-char (match-end 0)))
14266 (if (re-search-forward page-delimiter nil 'move)
14267 (match-beginning 0)
14269 (when (and (gnus-visual-p 'page-marker)
14270 (not (= (point-min) 1)))
14272 (goto-char (point-min))
14273 (gnus-insert-prev-page-button)))
14274 (when (and (gnus-visual-p 'page-marker)
14275 (not (= (1- (point-max)) (buffer-size))))
14277 (goto-char (point-max))
14278 (gnus-insert-next-page-button)))))
14280 ;; Article mode commands
14282 (defun gnus-article-goto-next-page ()
14283 "Show the next page of the article."
14285 (when (gnus-article-next-page)
14286 (gnus-article-read-summary-keys nil ?n)))
14288 (defun gnus-article-goto-prev-page ()
14289 "Show the next page of the article."
14291 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14292 (gnus-article-prev-page nil)))
14294 (defun gnus-article-next-page (&optional lines)
14295 "Show the next page of the current article.
14296 If end of article, return non-nil. Otherwise return nil.
14297 Argument LINES specifies lines to be scrolled up."
14299 (move-to-window-line -1)
14300 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14301 (if (save-excursion
14303 (and (pos-visible-in-window-p) ;Not continuation line.
14305 ;; Nothing in this page.
14306 (if (or (not gnus-break-pages)
14309 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14311 (gnus-narrow-to-page 1) ;Go to next page.
14313 ;; More in this page.
14317 ;; Long lines may cause an end-of-buffer error.
14318 (goto-char (point-max))))
14319 (move-to-window-line 0)
14322 (defun gnus-article-prev-page (&optional lines)
14323 "Show previous page of current article.
14324 Argument LINES specifies lines to be scrolled down."
14326 (move-to-window-line 0)
14327 (if (and gnus-break-pages
14329 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14331 (gnus-narrow-to-page -1) ;Go to previous page.
14332 (goto-char (point-max))
14336 (scroll-down lines)
14338 (move-to-window-line 0))))
14340 (defun gnus-article-refer-article ()
14341 "Read article specified by message-id around point."
14343 (let ((point (point)))
14344 (search-forward ">" nil t) ;Move point to end of "<....>".
14345 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14346 (let ((message-id (match-string 1)))
14348 (set-buffer gnus-summary-buffer)
14349 (gnus-summary-refer-article message-id))
14350 (goto-char (point))
14351 (error "No references around point"))))
14353 (defun gnus-article-show-summary ()
14354 "Reconfigure windows to show summary buffer."
14356 (gnus-configure-windows 'article)
14357 (gnus-summary-goto-subject gnus-current-article))
14359 (defun gnus-article-describe-briefly ()
14360 "Describe article mode commands briefly."
14363 (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")))
14365 (defun gnus-article-summary-command ()
14366 "Execute the last keystroke in the summary buffer."
14368 (let ((obuf (current-buffer))
14369 (owin (current-window-configuration))
14371 (switch-to-buffer gnus-summary-buffer 'norecord)
14372 (setq func (lookup-key (current-local-map) (this-command-keys)))
14373 (call-interactively func)
14375 (set-window-configuration owin)
14376 (set-window-point (get-buffer-window (current-buffer)) (point))))
14378 (defun gnus-article-summary-command-nosave ()
14379 "Execute the last keystroke in the summary buffer."
14382 (pop-to-buffer gnus-summary-buffer 'norecord)
14383 (setq func (lookup-key (current-local-map) (this-command-keys)))
14384 (call-interactively func)))
14386 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14387 "Read a summary buffer key sequence and execute it from the article buffer."
14390 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14391 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14395 (set-buffer gnus-summary-buffer)
14396 (push (or key last-command-event) unread-command-events)
14397 (setq keys (read-key-sequence nil)))
14400 (if (member keys nosaves)
14402 (pop-to-buffer gnus-summary-buffer 'norecord)
14403 (if (setq func (lookup-key (current-local-map) keys))
14404 (call-interactively func)
14406 (let ((obuf (current-buffer))
14407 (owin (current-window-configuration))
14410 (if not-restore-window
14411 (pop-to-buffer gnus-summary-buffer 'norecord)
14412 (switch-to-buffer gnus-summary-buffer 'norecord))
14413 (setq in-buffer (current-buffer))
14414 (if (setq func (lookup-key (current-local-map) keys))
14415 (call-interactively func)
14417 (when (eq in-buffer (current-buffer))
14419 (unless not-restore-window
14420 (set-window-configuration owin))
14421 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14425 ;;; Kill file handling.
14429 (defalias 'gnus-batch-kill 'gnus-batch-score)
14431 (defun gnus-batch-score ()
14432 "Run batched scoring.
14433 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14434 Newsgroups is a list of strings in Bnews format. If you want to score
14435 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14436 score the alt hierarchy, you'd say \"!alt.all\"."
14439 (gnus-newsrc-parse-options
14440 (apply (function concat)
14441 (mapcar (lambda (g) (concat g " "))
14442 command-line-args-left))))
14443 (gnus-expert-user t)
14444 (nnmail-spool-file nil)
14445 (gnus-use-dribble-file nil)
14446 (yes (car yes-and-no))
14447 (no (cdr yes-and-no))
14449 ;; Disable verbose message.
14450 gnus-novice-user gnus-large-newsgroup)
14451 ;; Eat all arguments.
14452 (setq command-line-args-left nil)
14455 ;; Apply kills to specified newsgroups in command line arguments.
14456 (setq newsrc (cdr gnus-newsrc-alist))
14458 (setq group (caar newsrc))
14459 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14460 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14462 (or (eq (car entry) t)
14463 (not (zerop (car entry)))))
14464 (if yes (string-match yes group) t)
14465 (or (null no) (not (string-match no group))))
14467 (gnus-summary-read-group group nil t nil t)
14468 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14469 (gnus-summary-exit))))
14470 (setq newsrc (cdr newsrc)))
14472 (switch-to-buffer gnus-group-buffer)
14473 (gnus-group-save-newsrc)))
14475 (defun gnus-apply-kill-file ()
14476 "Apply a kill file to the current newsgroup.
14477 Returns the number of articles marked as read."
14478 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14479 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14480 (gnus-apply-kill-file-internal)
14483 (defun gnus-kill-save-kill-buffer ()
14484 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14485 (when (get-file-buffer file)
14487 (set-buffer (get-file-buffer file))
14488 (and (buffer-modified-p) (save-buffer))
14489 (kill-buffer (current-buffer))))))
14491 (defvar gnus-kill-file-name "KILL"
14492 "Suffix of the kill files.")
14494 (defun gnus-newsgroup-kill-file (newsgroup)
14495 "Return the name of a kill file name for NEWSGROUP.
14496 If NEWSGROUP is nil, return the global kill file name instead."
14498 ;; The global KILL file is placed at top of the directory.
14499 ((or (null newsgroup)
14500 (string-equal newsgroup ""))
14501 (expand-file-name gnus-kill-file-name
14502 (or gnus-kill-files-directory "~/News")))
14503 ;; Append ".KILL" to newsgroup name.
14504 ((gnus-use-long-file-name 'not-kill)
14505 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14506 "." gnus-kill-file-name)
14507 (or gnus-kill-files-directory "~/News")))
14508 ;; Place "KILL" under the hierarchical directory.
14510 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14511 "/" gnus-kill-file-name)
14512 (or gnus-kill-files-directory "~/News")))))
14519 (defvar gnus-dribble-ignore nil)
14520 (defvar gnus-dribble-eval-file nil)
14522 (defun gnus-dribble-file-name ()
14523 "Return the dribble file for the current .newsrc."
14525 (if gnus-dribble-directory
14526 (concat (file-name-as-directory gnus-dribble-directory)
14527 (file-name-nondirectory gnus-current-startup-file))
14528 gnus-current-startup-file)
14531 (defun gnus-dribble-enter (string)
14532 "Enter STRING into the dribble buffer."
14533 (if (and (not gnus-dribble-ignore)
14534 gnus-dribble-buffer
14535 (buffer-name gnus-dribble-buffer))
14536 (let ((obuf (current-buffer)))
14537 (set-buffer gnus-dribble-buffer)
14538 (insert string "\n")
14539 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14540 (set-buffer obuf))))
14542 (defun gnus-dribble-read-file ()
14543 "Read the dribble file from disk."
14544 (let ((dribble-file (gnus-dribble-file-name)))
14546 (set-buffer (setq gnus-dribble-buffer
14548 (file-name-nondirectory dribble-file))))
14549 (gnus-add-current-to-buffer-list)
14551 (setq buffer-file-name dribble-file)
14553 (buffer-disable-undo (current-buffer))
14554 (bury-buffer (current-buffer))
14555 (set-buffer-modified-p nil)
14556 (let ((auto (make-auto-save-file-name))
14557 (gnus-dribble-ignore t))
14558 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14559 ;; Load whichever file is newest -- the auto save file
14560 ;; or the "real" file.
14561 (if (file-newer-than-file-p auto dribble-file)
14562 (insert-file-contents auto)
14563 (insert-file-contents dribble-file))
14564 (unless (zerop (buffer-size))
14565 (set-buffer-modified-p t))
14566 ;; Set the file modes to reflect the .newsrc file modes.
14568 (when (file-exists-p gnus-current-startup-file)
14569 (set-file-modes dribble-file
14570 (file-modes gnus-current-startup-file)))
14571 ;; Possibly eval the file later.
14572 (when (gnus-y-or-n-p
14573 "Auto-save file exists. Do you want to read it? ")
14574 (setq gnus-dribble-eval-file t)))))))
14576 (defun gnus-dribble-eval-file ()
14577 (if (not gnus-dribble-eval-file)
14579 (setq gnus-dribble-eval-file nil)
14581 (let ((gnus-dribble-ignore t))
14582 (set-buffer gnus-dribble-buffer)
14583 (eval-buffer (current-buffer))))))
14585 (defun gnus-dribble-delete-file ()
14586 (if (file-exists-p (gnus-dribble-file-name))
14587 (delete-file (gnus-dribble-file-name)))
14588 (if gnus-dribble-buffer
14590 (set-buffer gnus-dribble-buffer)
14591 (let ((auto (make-auto-save-file-name)))
14592 (if (file-exists-p auto)
14593 (delete-file auto))
14595 (set-buffer-modified-p nil)))))
14597 (defun gnus-dribble-save ()
14598 (if (and gnus-dribble-buffer
14599 (buffer-name gnus-dribble-buffer))
14601 (set-buffer gnus-dribble-buffer)
14604 (defun gnus-dribble-clear ()
14606 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14608 (set-buffer gnus-dribble-buffer)
14610 (set-buffer-modified-p nil)
14611 (setq buffer-saved-size (buffer-size))))))
14615 ;;; Server Communication
14618 (defun gnus-start-news-server (&optional confirm)
14619 "Open a method for getting news.
14620 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14622 (if gnus-current-select-method
14623 ;; Stream is already opened.
14625 ;; Open NNTP server.
14626 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14629 ;; Read server name with completion.
14630 (setq gnus-nntp-server
14631 (completing-read "NNTP server: "
14632 (mapcar (lambda (server) (list server))
14633 (cons (list gnus-nntp-server)
14634 gnus-secondary-servers))
14635 nil nil gnus-nntp-server))))
14637 (if (and gnus-nntp-server
14638 (stringp gnus-nntp-server)
14639 (not (string= gnus-nntp-server "")))
14640 (setq gnus-select-method
14641 (cond ((or (string= gnus-nntp-server "")
14642 (string= gnus-nntp-server "::"))
14643 (list 'nnspool (system-name)))
14644 ((string-match "^:" gnus-nntp-server)
14645 (list 'nnmh gnus-nntp-server
14646 (list 'nnmh-directory
14647 (file-name-as-directory
14649 (concat "~/" (substring
14650 gnus-nntp-server 1)))))
14651 (list 'nnmh-get-new-mail nil)))
14653 (list 'nntp gnus-nntp-server)))))
14655 (setq how (car gnus-select-method))
14656 (cond ((eq how 'nnspool)
14658 (gnus-message 5 "Looking up local news spool..."))
14661 (gnus-message 5 "Looking up mh spool..."))
14664 (setq gnus-current-select-method gnus-select-method)
14665 (run-hooks 'gnus-open-server-hook)
14667 ;; gnus-open-server-hook might have opened it
14668 (gnus-server-opened gnus-select-method)
14669 (gnus-open-server gnus-select-method)
14672 "%s (%s) open error: '%s'. Continue? "
14673 (car gnus-select-method) (cadr gnus-select-method)
14674 (gnus-status-message gnus-select-method)))
14676 (gnus-message 1 "Couldn't open server on %s"
14677 (nth 1 gnus-select-method))
14681 (defun gnus-check-group (group)
14682 "Try to make sure that the server where GROUP exists is alive."
14683 (let ((method (gnus-find-method-for-group group)))
14684 (or (gnus-server-opened method)
14685 (gnus-open-server method))))
14687 (defun gnus-check-server (&optional method silent)
14688 "Check whether the connection to METHOD is down.
14689 If METHOD is nil, use `gnus-select-method'.
14690 If it is down, start it up (again)."
14691 (let ((method (or method gnus-select-method)))
14692 ;; Transform virtual server names into select methods.
14693 (when (stringp method)
14694 (setq method (gnus-server-to-method method)))
14695 (if (gnus-server-opened method)
14696 ;; The stream is already opened.
14698 ;; Open the server.
14700 (gnus-message 5 "Opening %s server%s..." (car method)
14701 (if (equal (nth 1 method) "") ""
14702 (format " on %s" (nth 1 method)))))
14703 (run-hooks 'gnus-open-server-hook)
14705 (gnus-open-server method)
14709 (defun gnus-get-function (method function)
14710 "Return a function symbol based on METHOD and FUNCTION."
14711 ;; Translate server names into methods.
14713 (error "Attempted use of a nil select method"))
14714 (when (stringp method)
14715 (setq method (gnus-server-to-method method)))
14716 (let ((func (intern (format "%s-%s" (car method) function))))
14717 ;; If the functions isn't bound, we require the backend in
14719 (unless (fboundp func)
14720 (require (car method))
14721 (unless (fboundp func)
14722 ;; This backend doesn't implement this function.
14723 (error "No such function: %s" func)))
14728 ;;; Interface functions to the backends.
14731 (defun gnus-open-server (method)
14732 "Open a connection to METHOD."
14733 (when (stringp method)
14734 (setq method (gnus-server-to-method method)))
14735 (let ((elem (assoc method gnus-opened-servers)))
14736 ;; If this method was previously denied, we just return nil.
14737 (if (eq (nth 1 elem) 'denied)
14739 (gnus-message 1 "Denied server")
14741 ;; Open the server.
14743 (funcall (gnus-get-function method 'open-server)
14744 (nth 1 method) (nthcdr 2 method))))
14745 ;; If this hasn't been opened before, we add it to the list.
14747 (setq elem (list method nil)
14748 gnus-opened-servers (cons elem gnus-opened-servers)))
14749 ;; Set the status of this server.
14750 (setcar (cdr elem) (if result 'ok 'denied))
14751 ;; Return the result from the "open" call.
14754 (defun gnus-close-server (method)
14755 "Close the connection to METHOD."
14756 (when (stringp method)
14757 (setq method (gnus-server-to-method method)))
14758 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14760 (defun gnus-request-list (method)
14761 "Request the active file from METHOD."
14762 (when (stringp method)
14763 (setq method (gnus-server-to-method method)))
14764 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14766 (defun gnus-request-list-newsgroups (method)
14767 "Request the newsgroups file from METHOD."
14768 (when (stringp method)
14769 (setq method (gnus-server-to-method method)))
14770 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14772 (defun gnus-request-newgroups (date method)
14773 "Request all new groups since DATE from METHOD."
14774 (when (stringp method)
14775 (setq method (gnus-server-to-method method)))
14776 (funcall (gnus-get-function method 'request-newgroups)
14777 date (nth 1 method)))
14779 (defun gnus-server-opened (method)
14780 "Check whether a connection to METHOD has been opened."
14781 (when (stringp method)
14782 (setq method (gnus-server-to-method method)))
14783 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14785 (defun gnus-status-message (method)
14786 "Return the status message from METHOD.
14787 If METHOD is a string, it is interpreted as a group name. The method
14788 this group uses will be queried."
14789 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14791 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14793 (defun gnus-request-group (group &optional dont-check method)
14794 "Request GROUP. If DONT-CHECK, no information is required."
14795 (let ((method (or method (gnus-find-method-for-group group))))
14796 (when (stringp method)
14797 (setq method (gnus-server-to-method method)))
14798 (funcall (gnus-get-function method 'request-group)
14799 (gnus-group-real-name group) (nth 1 method) dont-check)))
14801 (defun gnus-request-asynchronous (group &optional articles)
14802 "Request that GROUP behave asynchronously.
14803 ARTICLES is the `data' of the group."
14804 (let ((method (gnus-find-method-for-group group)))
14805 (funcall (gnus-get-function method 'request-asynchronous)
14806 (gnus-group-real-name group) (nth 1 method) articles)))
14808 (defun gnus-list-active-group (group)
14809 "Request active information on GROUP."
14810 (let ((method (gnus-find-method-for-group group))
14811 (func 'list-active-group))
14812 (when (gnus-check-backend-function func group)
14813 (funcall (gnus-get-function method func)
14814 (gnus-group-real-name group) (nth 1 method)))))
14816 (defun gnus-request-group-description (group)
14817 "Request a description of GROUP."
14818 (let ((method (gnus-find-method-for-group group))
14819 (func 'request-group-description))
14820 (when (gnus-check-backend-function func group)
14821 (funcall (gnus-get-function method func)
14822 (gnus-group-real-name group) (nth 1 method)))))
14824 (defun gnus-close-group (group)
14825 "Request the GROUP be closed."
14826 (let ((method (gnus-find-method-for-group group)))
14827 (funcall (gnus-get-function method 'close-group)
14828 (gnus-group-real-name group) (nth 1 method))))
14830 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14831 "Request headers for ARTICLES in GROUP.
14832 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14833 (let ((method (gnus-find-method-for-group group)))
14834 (if (and gnus-use-cache (numberp (car articles)))
14835 (gnus-cache-retrieve-headers articles group fetch-old)
14836 (funcall (gnus-get-function method 'retrieve-headers)
14837 articles (gnus-group-real-name group) (nth 1 method)
14840 (defun gnus-retrieve-groups (groups method)
14841 "Request active information on GROUPS from METHOD."
14842 (when (stringp method)
14843 (setq method (gnus-server-to-method method)))
14844 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14846 (defun gnus-request-type (group &optional article)
14847 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14848 (let ((method (gnus-find-method-for-group group)))
14849 (if (not (gnus-check-backend-function 'request-type (car method)))
14851 (funcall (gnus-get-function method 'request-type)
14852 (gnus-group-real-name group) article))))
14854 (defun gnus-request-update-mark (group article mark)
14855 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14856 (let ((method (gnus-find-method-for-group group)))
14857 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14859 (funcall (gnus-get-function method 'request-update-mark)
14860 (gnus-group-real-name group) article mark))))
14862 (defun gnus-request-article (article group &optional buffer)
14863 "Request the ARTICLE in GROUP.
14864 ARTICLE can either be an article number or an article Message-ID.
14865 If BUFFER, insert the article in that group."
14866 (let ((method (gnus-find-method-for-group group)))
14867 (funcall (gnus-get-function method 'request-article)
14868 article (gnus-group-real-name group) (nth 1 method) buffer)))
14870 (defun gnus-request-head (article group)
14871 "Request the head of ARTICLE in GROUP."
14872 (let ((method (gnus-find-method-for-group group)))
14873 (funcall (gnus-get-function method 'request-head)
14874 article (gnus-group-real-name group) (nth 1 method))))
14876 (defun gnus-request-body (article group)
14877 "Request the body of ARTICLE in GROUP."
14878 (let ((method (gnus-find-method-for-group group)))
14879 (funcall (gnus-get-function method 'request-body)
14880 article (gnus-group-real-name group) (nth 1 method))))
14882 (defun gnus-request-post (method)
14883 "Post the current buffer using METHOD."
14884 (when (stringp method)
14885 (setq method (gnus-server-to-method method)))
14886 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14888 (defun gnus-request-scan (group method)
14889 "Request a SCAN being performed in GROUP from METHOD.
14890 If GROUP is nil, all groups on METHOD are scanned."
14891 (let ((method (if group (gnus-find-method-for-group group) method)))
14892 (funcall (gnus-get-function method 'request-scan)
14893 (and group (gnus-group-real-name group)) (nth 1 method))))
14895 (defsubst gnus-request-update-info (info method)
14896 "Request that METHOD update INFO."
14897 (when (stringp method)
14898 (setq method (gnus-server-to-method method)))
14899 (when (gnus-check-backend-function 'request-update-info (car method))
14900 (funcall (gnus-get-function method 'request-update-info)
14901 (gnus-group-real-name (gnus-info-group info))
14902 info (nth 1 method))))
14904 (defun gnus-request-expire-articles (articles group &optional force)
14905 (let ((method (gnus-find-method-for-group group)))
14906 (funcall (gnus-get-function method 'request-expire-articles)
14907 articles (gnus-group-real-name group) (nth 1 method)
14910 (defun gnus-request-move-article
14911 (article group server accept-function &optional last)
14912 (let ((method (gnus-find-method-for-group group)))
14913 (funcall (gnus-get-function method 'request-move-article)
14914 article (gnus-group-real-name group)
14915 (nth 1 method) accept-function last)))
14917 (defun gnus-request-accept-article (group method &optional last)
14918 ;; Make sure there's a newline at the end of the article.
14919 (when (stringp method)
14920 (setq method (gnus-server-to-method method)))
14921 (when (and (not method)
14923 (setq method (gnus-find-method-for-group group)))
14924 (goto-char (point-max))
14927 (let ((func (car (or method (gnus-find-method-for-group group)))))
14928 (funcall (intern (format "%s-request-accept-article" func))
14929 (if (stringp group) (gnus-group-real-name group) group)
14933 (defun gnus-request-replace-article (article group buffer)
14934 (let ((func (car (gnus-find-method-for-group group))))
14935 (funcall (intern (format "%s-request-replace-article" func))
14936 article (gnus-group-real-name group) buffer)))
14938 (defun gnus-request-associate-buffer (group)
14939 (let ((method (gnus-find-method-for-group group)))
14940 (funcall (gnus-get-function method 'request-associate-buffer)
14941 (gnus-group-real-name group))))
14943 (defun gnus-request-restore-buffer (article group)
14944 "Request a new buffer restored to the state of ARTICLE."
14945 (let ((method (gnus-find-method-for-group group)))
14946 (funcall (gnus-get-function method 'request-restore-buffer)
14947 article (gnus-group-real-name group) (nth 1 method))))
14949 (defun gnus-request-create-group (group &optional method)
14950 (when (stringp method)
14951 (setq method (gnus-server-to-method method)))
14952 (let ((method (or method (gnus-find-method-for-group group))))
14953 (funcall (gnus-get-function method 'request-create-group)
14954 (gnus-group-real-name group) (nth 1 method))))
14956 (defun gnus-request-delete-group (group &optional force)
14957 (let ((method (gnus-find-method-for-group group)))
14958 (funcall (gnus-get-function method 'request-delete-group)
14959 (gnus-group-real-name group) force (nth 1 method))))
14961 (defun gnus-request-rename-group (group new-name)
14962 (let ((method (gnus-find-method-for-group group)))
14963 (funcall (gnus-get-function method 'request-rename-group)
14964 (gnus-group-real-name group)
14965 (gnus-group-real-name new-name) (nth 1 method))))
14967 (defun gnus-member-of-valid (symbol group)
14968 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14969 (memq symbol (assoc
14970 (symbol-name (car (gnus-find-method-for-group group)))
14971 gnus-valid-select-methods)))
14973 (defun gnus-method-option-p (method option)
14974 "Return non-nil if select METHOD has OPTION as a parameter."
14975 (when (stringp method)
14976 (setq method (gnus-server-to-method method)))
14977 (memq option (assoc (format "%s" (car method))
14978 gnus-valid-select-methods)))
14980 (defun gnus-server-extend-method (group method)
14981 ;; This function "extends" a virtual server. If the server is
14982 ;; "hello", and the select method is ("hello" (my-var "something"))
14983 ;; in the group "alt.alt", this will result in a new virtual server
14984 ;; called "hello+alt.alt".
14986 (gnus-copy-sequence
14987 (if (equal (car method) "native") gnus-select-method
14988 (cdr (assoc (car method) gnus-server-alist))))))
14989 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14990 (nconc entry (cdr method))))
14992 (defun gnus-find-method-for-group (group &optional info)
14993 "Find the select method that GROUP uses."
14994 (or gnus-override-method
14996 gnus-select-method)
14997 (let ((info (or info (gnus-get-info group)))
15000 (not (setq method (gnus-info-method info)))
15001 (equal method "native"))
15004 (cond ((stringp method)
15005 (gnus-server-to-method method))
15006 ((stringp (car method))
15007 (gnus-server-extend-method group method))
15010 (if (equal (cadr method) "")
15012 (gnus-server-add-address method))))))
15014 (defun gnus-check-backend-function (func group)
15015 "Check whether GROUP supports function FUNC."
15016 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15018 (fboundp (intern (format "%s-%s" method func)))))
15020 (defun gnus-methods-using (feature)
15021 "Find all methods that have FEATURE."
15022 (let ((valids gnus-valid-select-methods)
15025 (if (memq feature (car valids))
15026 (setq outs (cons (car valids) outs)))
15027 (setq valids (cdr valids)))
15032 ;;; Active & Newsrc File Handling
15035 (defun gnus-setup-news (&optional rawfile level dont-connect)
15036 "Setup news information.
15037 If RAWFILE is non-nil, the .newsrc file will also be read.
15038 If LEVEL is non-nil, the news will be set up at level LEVEL."
15039 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15042 ;; Clear some variables to re-initialize news information.
15043 (setq gnus-newsrc-alist nil
15044 gnus-active-hashtb nil)
15045 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15046 (gnus-read-newsrc-file rawfile))
15048 (when (and (not (assoc "archive" gnus-server-alist))
15049 gnus-message-archive-method)
15050 (push (cons "archive" gnus-message-archive-method)
15051 gnus-server-alist))
15053 ;; If we don't read the complete active file, we fill in the
15055 (if (or (null gnus-read-active-file)
15056 (eq gnus-read-active-file 'some))
15057 (gnus-update-active-hashtb-from-killed))
15059 ;; Read the active file and create `gnus-active-hashtb'.
15060 ;; If `gnus-read-active-file' is nil, then we just create an empty
15061 ;; hash table. The partial filling out of the hash table will be
15062 ;; done in `gnus-get-unread-articles'.
15063 (and gnus-read-active-file
15065 (gnus-read-active-file))
15067 (or gnus-active-hashtb
15068 (setq gnus-active-hashtb (make-vector 4095 0)))
15070 ;; Initialize the cache.
15071 (when gnus-use-cache
15074 ;; Possibly eval the dribble file.
15075 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15077 (gnus-update-format-specifications)
15079 ;; See whether we need to read the description file.
15080 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15081 (not gnus-description-hashtb)
15083 gnus-read-active-file)
15084 (gnus-read-all-descriptions-files))
15086 ;; Find new newsgroups and treat them.
15087 (if (and init gnus-check-new-newsgroups (not level)
15088 (gnus-check-server gnus-select-method))
15089 (gnus-find-new-newsgroups))
15091 ;; We might read in new NoCeM messages here.
15092 (when gnus-use-nocem
15093 (gnus-nocem-scan-groups))
15095 ;; Find the number of unread articles in each non-dead group.
15096 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15097 (gnus-get-unread-articles level))
15099 (if (and init gnus-check-bogus-newsgroups
15100 gnus-read-active-file (not level)
15101 (gnus-server-opened gnus-select-method))
15102 (gnus-check-bogus-newsgroups))))
15104 (defun gnus-find-new-newsgroups (&optional arg)
15105 "Search for new newsgroups and add them.
15106 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15107 The `-n' option line from .newsrc is respected.
15108 If ARG (the prefix), use the `ask-server' method to query
15109 the server for new groups."
15111 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15112 (null gnus-read-active-file)
15113 (eq gnus-read-active-file 'some))
15114 'ask-server gnus-check-new-newsgroups)))
15115 (unless (gnus-check-first-time-used)
15116 (if (or (consp check)
15117 (eq check 'ask-server))
15118 ;; Ask the server for new groups.
15119 (gnus-ask-server-for-new-groups)
15120 ;; Go through the active hashtb and look for new groups.
15122 group new-newsgroups)
15123 (gnus-message 5 "Looking for new newsgroups...")
15124 (unless gnus-have-read-active-file
15125 (gnus-read-active-file))
15126 (setq gnus-newsrc-last-checked-date (current-time-string))
15127 (unless gnus-killed-hashtb
15128 (gnus-make-hashtable-from-killed))
15129 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15130 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15133 (if (or (null (setq group (symbol-name sym)))
15135 (null (symbol-value sym))
15136 (gnus-gethash group gnus-killed-hashtb)
15137 (gnus-gethash group gnus-newsrc-hashtb))
15139 (let ((do-sub (gnus-matches-options-n group)))
15141 ((eq do-sub 'subscribe)
15142 (setq groups (1+ groups))
15143 (gnus-sethash group group gnus-killed-hashtb)
15144 (funcall gnus-subscribe-options-newsgroup-method group))
15145 ((eq do-sub 'ignore)
15148 (setq groups (1+ groups))
15149 (gnus-sethash group group gnus-killed-hashtb)
15150 (if gnus-subscribe-hierarchical-interactive
15151 (setq new-newsgroups (cons group new-newsgroups))
15152 (funcall gnus-subscribe-newsgroup-method group)))))))
15153 gnus-active-hashtb)
15154 (when new-newsgroups
15155 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15156 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15158 (gnus-message 6 "%d new newsgroup%s arrived."
15159 groups (if (> groups 1) "s have" " has"))
15160 (gnus-message 6 "No new newsgroups.")))))))
15162 (defun gnus-matches-options-n (group)
15163 ;; Returns `subscribe' if the group is to be unconditionally
15164 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15165 ;; no match for the group.
15167 ;; First we check the two user variables.
15169 ((and gnus-options-subscribe
15170 (string-match gnus-options-subscribe group))
15172 ((and gnus-auto-subscribed-groups
15173 (string-match gnus-auto-subscribed-groups group))
15175 ((and gnus-options-not-subscribe
15176 (string-match gnus-options-not-subscribe group))
15178 ;; Then we go through the list that was retrieved from the .newsrc
15179 ;; file. This list has elements on the form
15180 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15181 ;; is in the reverse order of the options line) is returned.
15183 (let ((regs gnus-newsrc-options-n))
15185 (not (string-match (caar regs) group)))
15186 (setq regs (cdr regs)))
15187 (and regs (cdar regs))))))
15189 (defun gnus-ask-server-for-new-groups ()
15190 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15191 (methods (cons gnus-select-method
15193 (when gnus-message-archive-method
15196 (and (consp gnus-check-new-newsgroups)
15197 gnus-check-new-newsgroups)
15198 gnus-secondary-select-methods))))
15200 (new-date (current-time-string))
15201 group new-newsgroups got-new method hashtb
15202 gnus-override-subscribe-method)
15203 ;; Go through both primary and secondary select methods and
15204 ;; request new newsgroups.
15205 (while (setq method (gnus-server-get-method nil (pop methods)))
15206 (setq new-newsgroups nil)
15207 (setq gnus-override-subscribe-method method)
15208 (when (and (gnus-check-server method)
15209 (gnus-request-newgroups date method))
15212 (setq hashtb (gnus-make-hashtable 100))
15213 (set-buffer nntp-server-buffer)
15214 ;; Enter all the new groups into a hashtable.
15215 (gnus-active-to-gnus-format method hashtb 'ignore)))
15216 ;; Now all new groups from `method' are in `hashtb'.
15218 (lambda (group-sym)
15219 (if (or (null (setq group (symbol-name group-sym)))
15220 (null (symbol-value group-sym))
15221 (gnus-gethash group gnus-newsrc-hashtb)
15222 (member group gnus-zombie-list)
15223 (member group gnus-killed-list))
15224 ;; The group is already known.
15226 ;; Make this group active.
15227 (when (symbol-value group-sym)
15228 (gnus-set-active group (symbol-value group-sym)))
15229 ;; Check whether we want it or not.
15230 (let ((do-sub (gnus-matches-options-n group)))
15232 ((eq do-sub 'subscribe)
15234 (gnus-sethash group group gnus-killed-hashtb)
15235 (funcall gnus-subscribe-options-newsgroup-method group))
15236 ((eq do-sub 'ignore)
15240 (gnus-sethash group group gnus-killed-hashtb)
15241 (if gnus-subscribe-hierarchical-interactive
15242 (push group new-newsgroups)
15243 (funcall gnus-subscribe-newsgroup-method group)))))))
15245 (when new-newsgroups
15246 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15247 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15249 (gnus-message 6 "%d new newsgroup%s arrived."
15250 groups (if (> groups 1) "s have" " has")))
15251 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15254 (defun gnus-check-first-time-used ()
15255 (if (or (> (length gnus-newsrc-alist) 1)
15256 (file-exists-p gnus-startup-file)
15257 (file-exists-p (concat gnus-startup-file ".el"))
15258 (file-exists-p (concat gnus-startup-file ".eld")))
15260 (gnus-message 6 "First time user; subscribing you to default groups")
15261 (unless gnus-have-read-active-file
15262 (gnus-read-active-file))
15263 (setq gnus-newsrc-last-checked-date (current-time-string))
15264 (let ((groups gnus-default-subscribed-newsgroups)
15268 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15271 (if (null (setq group (symbol-name sym)))
15273 (let ((do-sub (gnus-matches-options-n group)))
15275 ((eq do-sub 'subscribe)
15276 (gnus-sethash group group gnus-killed-hashtb)
15277 (funcall gnus-subscribe-options-newsgroup-method group))
15278 ((eq do-sub 'ignore)
15281 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15282 gnus-active-hashtb)
15284 (if (gnus-active (car groups))
15285 (gnus-group-change-level
15286 (car groups) gnus-level-default-subscribed gnus-level-killed))
15287 (setq groups (cdr groups)))
15288 (gnus-group-make-help-group)
15289 (and gnus-novice-user
15290 (gnus-message 7 "`A k' to list killed groups"))))))
15292 (defun gnus-subscribe-group (group previous &optional method)
15293 (gnus-group-change-level
15295 (list t group gnus-level-default-subscribed nil nil method)
15297 gnus-level-default-subscribed gnus-level-killed previous t))
15299 ;; `gnus-group-change-level' is the fundamental function for changing
15300 ;; subscription levels of newsgroups. This might mean just changing
15301 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15302 ;; again, which subscribes/unsubscribes a group, which is equally
15303 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15304 ;; from 8-9 to 1-7 means that you remove the group from the list of
15305 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15306 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15307 ;; which is trivial.
15308 ;; ENTRY can either be a string (newsgroup name) or a list (if
15309 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15310 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15312 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15313 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15315 (defun gnus-group-change-level (entry level &optional oldlevel
15316 previous fromkilled)
15317 (let (group info active num)
15318 ;; Glean what info we can from the arguments
15320 (if fromkilled (setq group (nth 1 entry))
15321 (setq group (car (nth 2 entry))))
15322 (setq group entry))
15323 (if (and (stringp entry)
15325 (< oldlevel gnus-level-zombie))
15326 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15327 (if (and (not oldlevel)
15329 (setq oldlevel (gnus-info-level (nth 2 entry)))
15330 (setq oldlevel (or oldlevel 9)))
15331 (if (stringp previous)
15332 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15334 (if (and (>= oldlevel gnus-level-zombie)
15335 (gnus-gethash group gnus-newsrc-hashtb))
15336 ;; We are trying to subscribe a group that is already
15340 (or (gnus-ephemeral-group-p group)
15341 (gnus-dribble-enter
15342 (format "(gnus-group-change-level %S %S %S %S %S)"
15343 group level oldlevel (car (nth 2 previous)) fromkilled)))
15345 ;; Then we remove the newgroup from any old structures, if needed.
15346 ;; If the group was killed, we remove it from the killed or zombie
15347 ;; list. If not, and it is in fact going to be killed, we remove
15348 ;; it from the newsrc hash table and assoc.
15350 ((>= oldlevel gnus-level-zombie)
15351 (if (= oldlevel gnus-level-zombie)
15352 (setq gnus-zombie-list (delete group gnus-zombie-list))
15353 (setq gnus-killed-list (delete group gnus-killed-list))))
15355 (if (and (>= level gnus-level-zombie)
15358 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15360 (setcdr (gnus-gethash (car (nth 3 entry))
15361 gnus-newsrc-hashtb)
15363 (setcdr (cdr entry) (cdddr entry))))))
15365 ;; Finally we enter (if needed) the list where it is supposed to
15366 ;; go, and change the subscription level. If it is to be killed,
15367 ;; we enter it into the killed or zombie list.
15369 ((>= level gnus-level-zombie)
15370 ;; Remove from the hash table.
15371 (gnus-sethash group nil gnus-newsrc-hashtb)
15372 ;; We do not enter foreign groups into the list of dead
15374 (unless (gnus-group-foreign-p group)
15375 (if (= level gnus-level-zombie)
15376 (setq gnus-zombie-list (cons group gnus-zombie-list))
15377 (setq gnus-killed-list (cons group gnus-killed-list)))))
15379 ;; If the list is to be entered into the newsrc assoc, and
15380 ;; it was killed, we have to create an entry in the newsrc
15381 ;; hashtb format and fix the pointers in the newsrc assoc.
15382 (if (< oldlevel gnus-level-zombie)
15383 ;; It was alive, and it is going to stay alive, so we
15384 ;; just change the level and don't change any pointers or
15385 ;; hash table entries.
15386 (setcar (cdaddr entry) level)
15388 (setq info (cdr entry)
15390 (setq active (gnus-active group))
15392 (if active (- (1+ (cdr active)) (car active)) t))
15393 ;; Check whether the group is foreign. If so, the
15394 ;; foreign select method has to be entered into the
15396 (let ((method (or gnus-override-subscribe-method
15397 (gnus-group-method group))))
15398 (if (eq method gnus-select-method)
15399 (setq info (list group level nil))
15400 (setq info (list group level nil nil method)))))
15403 (let ((p gnus-newsrc-alist))
15407 (setq entry (cons info (cddr previous)))
15410 (setcdr (cdr previous) entry)
15411 (gnus-sethash group (cons num (cdr previous))
15412 gnus-newsrc-hashtb))
15413 (setcdr previous entry)
15414 (gnus-sethash group (cons num previous)
15415 gnus-newsrc-hashtb))
15417 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15418 (when gnus-group-change-level-function
15419 (funcall gnus-group-change-level-function group level oldlevel)))))
15421 (defun gnus-kill-newsgroup (newsgroup)
15422 "Obsolete function. Kills a newsgroup."
15423 (gnus-group-change-level
15424 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15426 (defun gnus-check-bogus-newsgroups (&optional confirm)
15427 "Remove bogus newsgroups.
15428 If CONFIRM is non-nil, the user has to confirm the deletion of every
15430 (let ((newsrc (cdr gnus-newsrc-alist))
15431 bogus group entry info)
15432 (gnus-message 5 "Checking bogus newsgroups...")
15433 (unless gnus-have-read-active-file
15434 (gnus-read-active-file))
15435 (when (member gnus-select-method gnus-have-read-active-file)
15436 ;; Find all bogus newsgroup that are subscribed.
15438 (setq info (pop newsrc)
15439 group (gnus-info-group info))
15440 (unless (or (gnus-active group) ; Active
15441 (gnus-info-method info) ; Foreign
15443 (not (gnus-y-or-n-p
15444 (format "Remove bogus newsgroup: %s " group)))))
15445 ;; Found a bogus newsgroup.
15446 (push group bogus)))
15447 ;; Remove all bogus subscribed groups by first killing them, and
15448 ;; then removing them from the list of killed groups.
15450 (when (setq entry (gnus-gethash (setq group (pop bogus))
15451 gnus-newsrc-hashtb))
15452 (gnus-group-change-level entry gnus-level-killed)
15453 (setq gnus-killed-list (delete group gnus-killed-list))))
15454 ;; Then we remove all bogus groups from the list of killed and
15455 ;; zombie groups. They are are removed without confirmation.
15456 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15459 (setq killed (symbol-value (car dead-lists)))
15461 (unless (gnus-active (setq group (pop killed)))
15462 ;; The group is bogus.
15463 ;; !!!Slow as hell.
15464 (set (car dead-lists)
15465 (delete group (symbol-value (car dead-lists))))))
15466 (setq dead-lists (cdr dead-lists))))
15467 (gnus-message 5 "Checking bogus newsgroups...done"))))
15469 (defun gnus-check-duplicate-killed-groups ()
15470 "Remove duplicates from the list of killed groups."
15472 (let ((killed gnus-killed-list))
15474 (gnus-message 9 "%d" (length killed))
15475 (setcdr killed (delete (car killed) (cdr killed)))
15476 (setq killed (cdr killed)))))
15478 ;; We want to inline a function from gnus-cache, so we cheat here:
15481 (require 'gnus-cache))
15483 (defun gnus-get-unread-articles-in-group (info active &optional update)
15485 ;; Allow the backend to update the info in the group.
15487 (gnus-request-update-info
15488 info (gnus-find-method-for-group (gnus-info-group info))))
15489 (gnus-activate-group (gnus-info-group info)))
15490 (let* ((range (gnus-info-read info))
15492 ;; If a cache is present, we may have to alter the active info.
15493 (when (and gnus-use-cache info)
15494 (inline (gnus-cache-possibly-alter-active
15495 (gnus-info-group info) active)))
15496 ;; Modify the list of read articles according to what articles
15497 ;; are available; then tally the unread articles and add the
15498 ;; number to the group hash table entry.
15500 ((zerop (cdr active))
15503 (setq num (- (1+ (cdr active)) (car active))))
15504 ((not (listp (cdr range)))
15505 ;; Fix a single (num . num) range according to the
15506 ;; active hash table.
15507 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15508 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15509 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15510 ;; Compute number of unread articles.
15511 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15513 ;; The read list is a list of ranges. Fix them according to
15514 ;; the active hash table.
15515 ;; First peel off any elements that are below the lower
15517 (while (and (cdr range)
15519 (or (and (atom (cadr range)) (cadr range))
15521 (if (numberp (car range))
15524 (or (and (numberp (cadr range))
15527 (setcdr (car range)
15528 (or (and (numberp (nth 1 range)) (nth 1 range))
15530 (setcdr range (cddr range)))
15531 ;; Adjust the first element to be the same as the lower limit.
15532 (if (and (not (atom (car range)))
15533 (< (cdar range) (car active)))
15534 (setcdr (car range) (1- (car active))))
15535 ;; Then we want to peel off any elements that are higher
15536 ;; than the upper active limit.
15537 (let ((srange range))
15538 ;; Go past all legal elements.
15539 (while (and (cdr srange)
15540 (<= (or (and (atom (cadr srange))
15542 (caadr srange)) (cdr active)))
15543 (setq srange (cdr srange)))
15545 ;; Nuke all remaining illegal elements.
15546 (setcdr srange nil))
15548 ;; Adjust the final element.
15549 (if (and (not (atom (car srange)))
15550 (> (cdar srange) (cdr active)))
15551 (setcdr (car srange) (cdr active))))
15552 ;; Compute the number of unread articles.
15554 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15556 (or (and (atom (car range)) (car range))
15558 (setq range (cdr range)))
15559 (setq num (max 0 (- (cdr active) num)))))
15560 ;; Set the number of unread articles.
15562 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15565 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15566 ;; and compute how many unread articles there are in each group.
15567 (defun gnus-get-unread-articles (&optional level)
15568 (let* ((newsrc (cdr gnus-newsrc-alist))
15569 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15572 (cond ((and gnus-activate-foreign-newsgroups
15573 (not (numberp gnus-activate-foreign-newsgroups)))
15574 (1+ gnus-level-subscribed))
15575 ((numberp gnus-activate-foreign-newsgroups)
15576 gnus-activate-foreign-newsgroups)
15579 info group active method)
15580 (gnus-message 5 "Checking new news...")
15583 (setq active (gnus-active (setq group (gnus-info-group
15584 (setq info (pop newsrc))))))
15586 ;; Check newsgroups. If the user doesn't want to check them, or
15587 ;; they can't be checked (for instance, if the news server can't
15588 ;; be reached) we just set the number of unread articles in this
15589 ;; newsgroup to t. This means that Gnus thinks that there are
15590 ;; unread articles, but it has no idea how many.
15591 (if (and (setq method (gnus-info-method info))
15592 (not (gnus-server-equal
15594 (setq method (gnus-server-get-method nil method))))
15595 (not (gnus-secondary-method-p method)))
15596 ;; These groups are foreign. Check the level.
15597 (when (<= (gnus-info-level info) foreign-level)
15598 (setq active (gnus-activate-group group 'scan))
15599 (unless (inline (gnus-virtual-group-p group))
15600 (inline (gnus-close-group group))))
15602 ;; These groups are native or secondary.
15603 (when (and (<= (gnus-info-level info) level)
15604 (not gnus-read-active-file))
15605 (setq active (gnus-activate-group group 'scan))
15606 (inline (gnus-close-group group))))
15609 (inline (gnus-get-unread-articles-in-group
15612 (fboundp (intern (concat (symbol-name (car method))
15613 "-request-scan"))))))
15614 ;; The group couldn't be reached, so we nix out the number of
15615 ;; unread articles and stuff.
15616 (gnus-set-active group nil)
15617 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15619 (gnus-message 5 "Checking new news...done")))
15621 ;; Create a hash table out of the newsrc alist. The `car's of the
15622 ;; alist elements are used as keys.
15623 (defun gnus-make-hashtable-from-newsrc-alist ()
15624 (let ((alist gnus-newsrc-alist)
15625 (ohashtb gnus-newsrc-hashtb)
15627 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15629 (setq prev (setq gnus-newsrc-alist
15630 (if (equal (caar gnus-newsrc-alist)
15633 (cons (list "dummy.group" 0 nil) alist)))))
15637 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15639 gnus-newsrc-hashtb)
15641 alist (cdr alist)))))
15643 (defun gnus-make-hashtable-from-killed ()
15644 "Create a hash table from the killed and zombie lists."
15645 (let ((lists '(gnus-killed-list gnus-zombie-list))
15647 (setq gnus-killed-hashtb
15648 (gnus-make-hashtable
15649 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15650 (while (setq list (pop lists))
15651 (setq list (symbol-value list))
15653 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15655 (defun gnus-activate-group (group &optional scan)
15656 ;; Check whether a group has been activated or not.
15657 ;; If SCAN, request a scan of that group as well.
15658 (let ((method (gnus-find-method-for-group group))
15660 (and (gnus-check-server method)
15661 ;; We escape all bugs and quit here to make it possible to
15662 ;; continue if a group is so out-there that it reports bugs
15666 (gnus-check-backend-function 'request-scan (car method))
15667 (gnus-request-scan group method))
15670 (gnus-request-group group)
15674 (set-buffer nntp-server-buffer)
15675 (goto-char (point-min))
15676 ;; Parse the result we got from `gnus-request-group'.
15677 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15679 (goto-char (match-beginning 1))
15681 group (setq active (cons (read (current-buffer))
15682 (read (current-buffer)))))
15683 ;; Return the new active info.
15686 (defun gnus-update-read-articles (group unread)
15687 "Update the list of read and ticked articles in GROUP using the
15688 UNREAD and TICKED lists.
15689 Note: UNSELECTED has to be sorted over `<'.
15690 Returns whether the updating was successful."
15691 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15692 (entry (gnus-gethash group gnus-newsrc-hashtb))
15693 (info (nth 2 entry))
15695 (unread (sort (copy-sequence unread) '<))
15697 (if (or (not info) (not active))
15698 ;; There is no info on this group if it was, in fact,
15699 ;; killed. Gnus stores no information on killed groups, so
15700 ;; there's nothing to be done.
15701 ;; One could store the information somewhere temporarily,
15702 ;; perhaps... Hmmm...
15704 ;; Remove any negative articles numbers.
15705 (while (and unread (< (car unread) 0))
15706 (setq unread (cdr unread)))
15707 ;; Remove any expired article numbers
15708 (while (and unread (< (car unread) (car active)))
15709 (setq unread (cdr unread)))
15710 ;; Compute the ranges of read articles by looking at the list of
15711 ;; unread articles.
15713 (if (/= (car unread) prev)
15714 (setq read (cons (if (= prev (1- (car unread))) prev
15715 (cons prev (1- (car unread)))) read)))
15716 (setq prev (1+ (car unread)))
15717 (setq unread (cdr unread)))
15718 (when (<= prev (cdr active))
15719 (setq read (cons (cons prev (cdr active)) read)))
15720 ;; Enter this list into the group info.
15721 (gnus-info-set-read
15722 info (if (> (length read) 1) (nreverse read) read))
15723 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15724 (gnus-get-unread-articles-in-group info (gnus-active group))
15727 (defun gnus-make-articles-unread (group articles)
15728 "Mark ARTICLES in GROUP as unread."
15729 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15730 (gnus-gethash (gnus-group-real-name group)
15731 gnus-newsrc-hashtb))))
15732 (ranges (gnus-info-read info))
15735 (when (gnus-member-of-range
15736 (setq article (pop articles)) ranges)
15737 (setq news (cons article news))))
15739 (gnus-info-set-read
15740 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15741 (gnus-group-update-group group t))))
15743 ;; Enter all dead groups into the hashtb.
15744 (defun gnus-update-active-hashtb-from-killed ()
15745 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15746 (lists (list gnus-killed-list gnus-zombie-list))
15749 (setq killed (car lists))
15751 (gnus-sethash (car killed) nil hashtb)
15752 (setq killed (cdr killed)))
15753 (setq lists (cdr lists)))))
15755 ;; Get the active file(s) from the backend(s).
15756 (defun gnus-read-active-file ()
15757 (gnus-group-set-mode-line)
15760 (if (gnus-check-server gnus-select-method)
15761 ;; The native server is available.
15762 (cons gnus-select-method gnus-secondary-select-methods)
15763 ;; The native server is down, so we just do the
15765 gnus-secondary-select-methods)
15766 ;; Also read from the archive server.
15767 (when gnus-message-archive-method
15768 (list "archive"))))
15770 (setq gnus-have-read-active-file nil)
15772 (set-buffer nntp-server-buffer)
15774 (let* ((method (if (stringp (car methods))
15775 (gnus-server-get-method nil (car methods))
15777 (where (nth 1 method))
15778 (mesg (format "Reading active file%s via %s..."
15779 (if (and where (not (zerop (length where))))
15780 (concat " from " where) "")
15782 (gnus-message 5 mesg)
15783 (when (gnus-check-server method)
15784 ;; Request that the backend scan its incoming messages.
15785 (and (gnus-check-backend-function 'request-scan (car method))
15786 (gnus-request-scan nil method))
15788 ((and (eq gnus-read-active-file 'some)
15789 (gnus-check-backend-function 'retrieve-groups (car method)))
15790 (let ((newsrc (cdr gnus-newsrc-alist))
15791 (gmethod (gnus-server-get-method nil method))
15793 (while (setq info (pop newsrc))
15794 (when (gnus-server-equal
15795 (gnus-find-method-for-group
15796 (gnus-info-group info) info)
15798 (push (gnus-group-real-name (gnus-info-group info))
15801 (gnus-check-server method)
15802 (setq list-type (gnus-retrieve-groups groups method))
15806 1 "Cannot read partial active file from %s server."
15810 ((eq list-type 'active)
15811 (gnus-active-to-gnus-format method gnus-active-hashtb))
15813 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15815 (if (not (gnus-request-list method))
15817 (unless (equal method gnus-message-archive-method)
15818 (gnus-message 1 "Cannot read active file from %s server."
15821 (gnus-active-to-gnus-format method)
15822 ;; We mark this active file as read.
15823 (push method gnus-have-read-active-file)
15824 (gnus-message 5 "%sdone" mesg))))))
15825 (setq methods (cdr methods))))))
15827 ;; Read an active file and place the results in `gnus-active-hashtb'.
15828 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15830 (setq method gnus-select-method))
15831 (let ((cur (current-buffer))
15833 (if (and gnus-active-hashtb
15834 (not (equal method gnus-select-method)))
15836 (setq gnus-active-hashtb
15837 (if (equal method gnus-select-method)
15838 (gnus-make-hashtable
15839 (count-lines (point-min) (point-max)))
15840 (gnus-make-hashtable 4096)))))))
15841 ;; Delete unnecessary lines.
15842 (goto-char (point-min))
15843 (while (search-forward "\nto." nil t)
15844 (delete-region (1+ (match-beginning 0))
15845 (progn (forward-line 1) (point))))
15846 (or (string= gnus-ignored-newsgroups "")
15848 (goto-char (point-min))
15849 (delete-matching-lines gnus-ignored-newsgroups)))
15850 ;; Make the group names readable as a lisp expression even if they
15851 ;; contain special characters.
15852 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15853 (goto-char (point-max))
15854 (while (re-search-backward "[][';?()#]" nil t)
15856 ;; If these are groups from a foreign select method, we insert the
15857 ;; group prefix in front of the group names.
15858 (and method (not (gnus-server-equal
15859 (gnus-server-get-method nil method)
15860 (gnus-server-get-method nil gnus-select-method)))
15861 (let ((prefix (gnus-group-prefixed-name "" method)))
15862 (goto-char (point-min))
15863 (while (and (not (eobp))
15864 (progn (insert prefix)
15865 (zerop (forward-line 1)))))))
15866 ;; Store the active file in a hash table.
15867 (goto-char (point-min))
15868 (if (string-match "%[oO]" gnus-group-line-format)
15869 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15870 ;; If we want information on moderated groups, we use this
15872 (let* ((mod-hashtb (make-vector 7 0))
15873 (m (intern "m" mod-hashtb))
15875 (while (not (eobp))
15876 (condition-case nil
15878 (narrow-to-region (point) (gnus-point-at-eol))
15879 (setq group (let ((obarray hashtb)) (read cur)))
15880 (if (and (numberp (setq max (read cur)))
15881 (numberp (setq min (read cur)))
15883 (skip-chars-forward " \t")
15885 (or (= (following-char) ?=)
15886 (= (following-char) ?x)
15887 (= (following-char) ?j)))))
15888 (set group (cons min max))
15890 ;; Enter moderated groups into a list.
15891 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15892 (setq gnus-moderated-list
15893 (cons (symbol-name group) gnus-moderated-list))))
15900 ;; And if we do not care about moderation, we use this loop,
15901 ;; which is faster.
15902 (let (group max min)
15903 (while (not (eobp))
15906 (narrow-to-region (point) (gnus-point-at-eol))
15907 ;; group gets set to a symbol interned in the hash table
15908 ;; (what a hack!!) - jwz
15909 (setq group (let ((obarray hashtb)) (read cur)))
15910 (if (and (numberp (setq max (read cur)))
15911 (numberp (setq min (read cur)))
15913 (skip-chars-forward " \t")
15915 (or (= (following-char) ?=)
15916 (= (following-char) ?x)
15917 (= (following-char) ?j)))))
15918 (set group (cons min max))
15926 (gnus-message 3 "Warning - illegal active: %s"
15928 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15930 (forward-line 1))))))
15932 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15933 ;; Parse a "groups" active file.
15934 (let ((cur (current-buffer))
15936 (if (and method gnus-active-hashtb)
15938 (setq gnus-active-hashtb
15939 (gnus-make-hashtable
15940 (count-lines (point-min) (point-max)))))))
15941 (prefix (and method
15942 (not (gnus-server-equal
15943 (gnus-server-get-method nil method)
15944 (gnus-server-get-method nil gnus-select-method)))
15945 (gnus-group-prefixed-name "" method))))
15947 (goto-char (point-min))
15948 ;; We split this into to separate loops, one with the prefix
15949 ;; and one without to speed the reading up somewhat.
15951 (let (min max opoint group)
15952 (while (not (eobp))
15955 (read cur) (read cur)
15956 (setq min (read cur)
15959 (skip-chars-forward " \t")
15962 (set (let ((obarray hashtb)) (read cur))
15964 (error (and group (symbolp group) (set group nil))))
15966 (let (min max group)
15967 (while (not (eobp))
15969 (if (= (following-char) ?2)
15971 (read cur) (read cur)
15972 (setq min (read cur)
15974 (set (setq group (let ((obarray hashtb)) (read cur)))
15976 (error (and group (symbolp group) (set group nil))))
15977 (forward-line 1))))))
15979 (defun gnus-read-newsrc-file (&optional force)
15980 "Read startup file.
15981 If FORCE is non-nil, the .newsrc file is read."
15982 ;; Reset variables that might be defined in the .newsrc.eld file.
15983 (let ((variables gnus-variable-list))
15985 (set (car variables) nil)
15986 (setq variables (cdr variables))))
15987 (let* ((newsrc-file gnus-current-startup-file)
15988 (quick-file (concat newsrc-file ".el")))
15990 ;; We always load the .newsrc.eld file. If always contains
15991 ;; much information that can not be gotten from the .newsrc
15992 ;; file (ticked articles, killed groups, foreign methods, etc.)
15993 (gnus-read-newsrc-el-file quick-file)
15995 (if (and (file-exists-p gnus-current-startup-file)
15997 (and (file-newer-than-file-p newsrc-file quick-file)
15998 (file-newer-than-file-p newsrc-file
15999 (concat quick-file "d")))
16000 (not gnus-newsrc-alist)))
16001 ;; We read the .newsrc file. Note that if there if a
16002 ;; .newsrc.eld file exists, it has already been read, and
16003 ;; the `gnus-newsrc-hashtb' has been created. While reading
16004 ;; the .newsrc file, Gnus will only use the information it
16005 ;; can find there for changing the data already read -
16006 ;; ie. reading the .newsrc file will not trash the data
16007 ;; already read (except for read articles).
16009 (gnus-message 5 "Reading %s..." newsrc-file)
16010 (set-buffer (find-file-noselect newsrc-file))
16011 (buffer-disable-undo (current-buffer))
16012 (gnus-newsrc-to-gnus-format)
16013 (kill-buffer (current-buffer))
16014 (gnus-message 5 "Reading %s...done" newsrc-file)))
16016 ;; Read any slave files.
16018 (gnus-master-read-slave-newsrc)))))
16020 (defun gnus-read-newsrc-el-file (file)
16021 (let ((ding-file (concat file "d")))
16022 ;; We always, always read the .eld file.
16023 (gnus-message 5 "Reading %s..." ding-file)
16024 (let (gnus-newsrc-assoc)
16025 (condition-case nil
16026 (load ding-file t t t)
16028 (gnus-message 1 "Error in %s" ding-file)
16030 (when gnus-newsrc-assoc
16031 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16032 (gnus-make-hashtable-from-newsrc-alist)
16033 (when (file-newer-than-file-p file ding-file)
16034 ;; Old format quick file
16035 (gnus-message 5 "Reading %s..." file)
16036 ;; The .el file is newer than the .eld file, so we read that one
16038 (gnus-read-old-newsrc-el-file file))))
16040 ;; Parse the old-style quick startup file
16041 (defun gnus-read-old-newsrc-el-file (file)
16042 (let (newsrc killed marked group m info)
16044 (let ((gnus-killed-assoc nil)
16045 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16047 (condition-case nil
16050 (setq newsrc gnus-newsrc-assoc
16051 killed gnus-killed-assoc
16052 marked gnus-marked-assoc)))
16053 (setq gnus-newsrc-alist nil)
16054 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16057 (gnus-info-set-read info (cddr group))
16058 (gnus-info-set-level
16059 info (if (nth 1 group) gnus-level-default-subscribed
16060 gnus-level-default-unsubscribed))
16061 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16064 (if (nth 1 group) gnus-level-default-subscribed
16065 gnus-level-default-unsubscribed)
16067 gnus-newsrc-alist))
16068 ;; Copy marks into info.
16069 (when (setq m (assoc (car group) marked))
16070 (unless (nthcdr 3 info)
16071 (nconc info (list nil)))
16072 (gnus-info-set-marks
16073 info (list (cons 'tick (gnus-compress-sequence
16074 (sort (cdr m) '<) t))))))
16075 (setq newsrc killed)
16077 (setcar newsrc (caar newsrc))
16078 (setq newsrc (cdr newsrc)))
16079 (setq gnus-killed-list killed))
16080 ;; The .el file version of this variable does not begin with
16081 ;; "options", while the .eld version does, so we just add it if it
16084 gnus-newsrc-options
16086 (and (not (string-match "^ *options" gnus-newsrc-options))
16087 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16088 (and (not (string-match "\n$" gnus-newsrc-options))
16089 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16090 ;; Finally, if we read some options lines, we parse them.
16091 (or (string= gnus-newsrc-options "")
16092 (gnus-newsrc-parse-options gnus-newsrc-options))))
16094 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16095 (gnus-make-hashtable-from-newsrc-alist)))
16097 (defun gnus-make-newsrc-file (file)
16098 "Make server dependent file name by catenating FILE and server host name."
16099 (let* ((file (expand-file-name file nil))
16100 (real-file (concat file "-" (nth 1 gnus-select-method))))
16101 (if (or (file-exists-p real-file)
16102 (file-exists-p (concat real-file ".el"))
16103 (file-exists-p (concat real-file ".eld")))
16106 (defun gnus-newsrc-to-gnus-format ()
16107 (setq gnus-newsrc-options "")
16108 (setq gnus-newsrc-options-n nil)
16110 (or gnus-active-hashtb
16111 (setq gnus-active-hashtb (make-vector 4095 0)))
16112 (let ((buf (current-buffer))
16113 (already-read (> (length gnus-newsrc-alist) 1))
16114 group subscribed options-symbol newsrc Options-symbol
16116 (goto-char (point-min))
16117 ;; We intern the symbol `options' in the active hashtb so that we
16118 ;; can `eq' against it later.
16119 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16120 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16122 (while (not (eobp))
16123 ;; We first read the first word on the line by narrowing and
16124 ;; then reading into `gnus-active-hashtb'. Most groups will
16125 ;; already exist in that hashtb, so this will save some string
16129 (progn (skip-chars-forward "^ \t!:\n") (point)))
16130 (goto-char (point-min))
16132 (and (/= (point-min) (point-max))
16133 (let ((obarray gnus-active-hashtb)) (read buf))))
16135 ;; Now, the symbol we have read is either `options' or a group
16136 ;; name. If it is an options line, we just add it to a string.
16138 ((or (eq symbol options-symbol)
16139 (eq symbol Options-symbol))
16140 (setq gnus-newsrc-options
16141 ;; This concating is quite inefficient, but since our
16142 ;; thorough studies show that approx 99.37% of all
16143 ;; .newsrc files only contain a single options line, we
16144 ;; don't give a damn, frankly, my dear.
16145 (concat gnus-newsrc-options
16147 (gnus-point-at-bol)
16148 ;; Options may continue on the next line.
16149 (or (and (re-search-forward "^[^ \t]" nil 'move)
16150 (progn (beginning-of-line) (point)))
16154 ;; Group names can be just numbers.
16155 (when (numberp symbol)
16156 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16157 (or (boundp symbol) (set symbol nil))
16158 ;; It was a group name.
16159 (setq subscribed (= (following-char) ?:)
16160 group (symbol-name symbol)
16163 ;; If the line ends here, this is clearly a buggy line, so
16164 ;; we put point a the beginning of line and let the cond
16165 ;; below do the error handling.
16166 (beginning-of-line)
16167 ;; We skip to the beginning of the ranges.
16168 (skip-chars-forward "!: \t"))
16169 ;; We are now at the beginning of the list of read articles.
16170 ;; We read them range by range.
16173 ((looking-at "[0-9]+")
16174 ;; We narrow and read a number instead of buffer-substring/
16175 ;; string-to-int because it's faster. narrow/widen is
16176 ;; faster than save-restriction/narrow, and save-restriction
16177 ;; produces a garbage object.
16179 (narrow-to-region (match-beginning 0) (match-end 0))
16182 ;; If the next character is a dash, then this is a range.
16183 (if (= (following-char) ?-)
16185 ;; We read the upper bound of the range.
16187 (if (not (looking-at "[0-9]+"))
16188 ;; This is a buggy line, by we pretend that
16189 ;; it's kinda OK. Perhaps the user should be
16191 (setq reads (cons num1 reads))
16196 (narrow-to-region (match-beginning 0)
16201 ;; It was just a simple number, so we add it to the
16203 (setq reads (cons num1 reads)))
16204 ;; If the next char in ?\n, then we have reached the end
16205 ;; of the line and return nil.
16206 (/= (following-char) ?\n))
16207 ((= (following-char) ?\n)
16208 ;; End of line, so we end.
16211 ;; Not numbers and not eol, so this might be a buggy
16214 ;; If it was eob instead of ?\n, we allow it.
16216 ;; The line was buggy.
16218 (gnus-message 3 "Mangled line: %s"
16219 (buffer-substring (gnus-point-at-bol)
16220 (gnus-point-at-eol)))
16224 ;; Skip past ", ". Spaces are illegal in these ranges, but
16225 ;; we allow them, because it's a common mistake to put a
16226 ;; space after the comma.
16227 (skip-chars-forward ", "))
16229 ;; We have already read .newsrc.eld, so we gently update the
16230 ;; data in the hash table with the information we have just
16233 (let ((info (gnus-get-info group))
16236 ;; There is an entry for this file in the alist.
16238 (gnus-info-set-read info (nreverse reads))
16239 ;; We update the level very gently. In fact, we
16240 ;; only change it if there's been a status change
16241 ;; from subscribed to unsubscribed, or vice versa.
16242 (setq level (gnus-info-level info))
16243 (cond ((and (<= level gnus-level-subscribed)
16245 (setq level (if reads
16246 gnus-level-default-unsubscribed
16247 (1+ gnus-level-default-unsubscribed))))
16248 ((and (> level gnus-level-subscribed) subscribed)
16249 (setq level gnus-level-default-subscribed)))
16250 (gnus-info-set-level info level))
16251 ;; This is a new group.
16252 (setq info (list group
16254 gnus-level-default-subscribed
16256 (1+ gnus-level-subscribed)
16257 gnus-level-default-unsubscribed))
16258 (nreverse reads))))
16259 (setq newsrc (cons info newsrc))))))
16262 (setq newsrc (nreverse newsrc))
16264 (if (not already-read)
16266 ;; We now have two newsrc lists - `newsrc', which is what we
16267 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16268 ;; what we've read from .newsrc.eld. We have to merge these
16269 ;; lists. We do this by "attaching" any (foreign) groups in the
16270 ;; gnus-newsrc-alist to the (native) group that precedes them.
16271 (let ((rc (cdr gnus-newsrc-alist))
16272 (prev gnus-newsrc-alist)
16275 (or (null (nth 4 (car rc))) ; It's a native group.
16276 (assoc (caar rc) newsrc) ; It's already in the alist.
16277 (if (setq entry (assoc (caar prev) newsrc))
16278 (setcdr (setq mentry (memq entry newsrc))
16279 (cons (car rc) (cdr mentry)))
16280 (setq newsrc (cons (car rc) newsrc))))
16284 (setq gnus-newsrc-alist newsrc)
16285 ;; We make the newsrc hashtb.
16286 (gnus-make-hashtable-from-newsrc-alist)
16288 ;; Finally, if we read some options lines, we parse them.
16289 (or (string= gnus-newsrc-options "")
16290 (gnus-newsrc-parse-options gnus-newsrc-options))))
16292 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16293 ;; The return value will be a list on the form
16294 ;; ((regexp1 . ignore)
16295 ;; (regexp2 . subscribe)...)
16296 ;; When handling new newsgroups, groups that match a `ignore' regexp
16297 ;; will be ignored, and groups that match a `subscribe' regexp will be
16298 ;; subscribed. A line like
16299 ;; options -n !all rec.all
16300 ;; will lead to a list that looks like
16301 ;; (("^rec\\..+" . subscribe)
16302 ;; ("^.+" . ignore))
16303 ;; So all "rec.*" groups will be subscribed, while all the other
16304 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16305 ;; different from "options -n rec.all !all".
16306 (defun gnus-newsrc-parse-options (options)
16309 (gnus-set-work-buffer)
16310 (insert (regexp-quote options))
16311 ;; First we treat all continuation lines.
16312 (goto-char (point-min))
16313 (while (re-search-forward "\n[ \t]+" nil t)
16314 (replace-match " " t t))
16315 ;; Then we transform all "all"s into ".+"s.
16316 (goto-char (point-min))
16317 (while (re-search-forward "\\ball\\b" nil t)
16318 (replace-match ".+" t t))
16319 (goto-char (point-min))
16320 ;; We remove all other options than the "-n" ones.
16321 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16322 (replace-match " ")
16324 (goto-char (point-min))
16326 ;; We are only interested in "options -n" lines - we
16327 ;; ignore the other option lines.
16328 (while (re-search-forward "[ \t]-n" nil t)
16330 (or (save-excursion
16331 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16333 (gnus-point-at-eol)))
16334 ;; Search for all "words"...
16335 (while (re-search-forward "[^ \t,\n]+" eol t)
16336 (if (= (char-after (match-beginning 0)) ?!)
16337 ;; If the word begins with a bang (!), this is a "not"
16338 ;; spec. We put this spec (minus the bang) and the
16339 ;; symbol `ignore' into the list.
16340 (setq out (cons (cons (concat
16341 "^" (buffer-substring
16342 (1+ (match-beginning 0))
16345 ;; There was no bang, so this is a "yes" spec.
16346 (setq out (cons (cons (concat "^" (match-string 0))
16347 'subscribe) out)))))
16349 (setq gnus-newsrc-options-n out))))
16351 (defun gnus-save-newsrc-file (&optional force)
16352 "Save .newsrc file."
16353 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16354 ;; from the variable gnus-newsrc-alist.
16355 (when (and (or gnus-newsrc-alist gnus-killed-list)
16356 gnus-current-startup-file)
16358 (if (and (or gnus-use-dribble-file gnus-slave)
16360 (or (not gnus-dribble-buffer)
16361 (not (buffer-name gnus-dribble-buffer))
16362 (zerop (save-excursion
16363 (set-buffer gnus-dribble-buffer)
16365 (gnus-message 4 "(No changes need to be saved)")
16366 (run-hooks 'gnus-save-newsrc-hook)
16368 (gnus-slave-save-newsrc)
16370 (when gnus-save-newsrc-file
16371 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16372 (gnus-gnus-to-newsrc-format)
16373 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16374 ;; Save .newsrc.eld.
16375 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16376 (make-local-variable 'version-control)
16377 (setq version-control 'never)
16378 (setq buffer-file-name
16379 (concat gnus-current-startup-file ".eld"))
16380 (gnus-add-current-to-buffer-list)
16381 (buffer-disable-undo (current-buffer))
16383 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16384 (gnus-gnus-to-quick-newsrc-format)
16385 (run-hooks 'gnus-save-quick-newsrc-hook)
16387 (kill-buffer (current-buffer))
16389 5 "Saving %s.eld...done" gnus-current-startup-file))
16390 (gnus-dribble-delete-file)))))
16392 (defun gnus-gnus-to-quick-newsrc-format ()
16393 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16394 (insert ";; Gnus startup file.\n")
16395 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16396 (insert ";; to read .newsrc.\n")
16397 (insert "(setq gnus-newsrc-file-version "
16398 (prin1-to-string gnus-version) ")\n")
16400 (if gnus-save-killed-list gnus-variable-list
16401 ;; Remove the `gnus-killed-list' from the list of variables
16402 ;; to be saved, if required.
16403 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16404 ;; Peel off the "dummy" group.
16405 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16407 ;; Insert the variables into the file.
16409 (when (and (boundp (setq variable (pop variables)))
16410 (symbol-value variable))
16411 (insert "(setq " (symbol-name variable) " '")
16412 (prin1 (symbol-value variable) (current-buffer))
16415 (defun gnus-gnus-to-newsrc-format ()
16416 ;; Generate and save the .newsrc file.
16418 (set-buffer (create-file-buffer gnus-current-startup-file))
16419 (let ((newsrc (cdr gnus-newsrc-alist))
16420 (standard-output (current-buffer))
16421 info ranges range method)
16422 (setq buffer-file-name gnus-current-startup-file)
16423 (buffer-disable-undo (current-buffer))
16426 (if gnus-newsrc-options (insert gnus-newsrc-options))
16427 ;; Write subscribed and unsubscribed.
16428 (while (setq info (pop newsrc))
16429 ;; Don't write foreign groups to .newsrc.
16430 (when (or (null (setq method (gnus-info-method info)))
16431 (equal method "native")
16432 (gnus-server-equal method gnus-select-method))
16433 (insert (gnus-info-group info)
16434 (if (> (gnus-info-level info) gnus-level-subscribed)
16436 (when (setq ranges (gnus-info-read info))
16438 (if (not (listp (cdr ranges)))
16439 (if (= (car ranges) (cdr ranges))
16440 (princ (car ranges))
16441 (princ (car ranges))
16443 (princ (cdr ranges)))
16444 (while (setq range (pop ranges))
16445 (if (or (atom range) (= (car range) (cdr range)))
16446 (princ (or (and (atom range) range) (car range)))
16447 (princ (car range))
16449 (princ (cdr range)))
16450 (if ranges (insert ",")))))
16452 (make-local-variable 'version-control)
16453 (setq version-control 'never)
16454 ;; It has been reported that sometime the modtime on the .newsrc
16455 ;; file seems to be off. We really do want to overwrite it, so
16456 ;; we clear the modtime here before saving. It's a bit odd,
16458 ;; sometimes the modtime clear isn't sufficient. most brute force:
16459 ;; delete the silly thing entirely first. but this fails to provide
16460 ;; such niceties as .newsrc~ creation.
16461 (if gnus-modtime-botch
16462 (delete-file gnus-startup-file)
16463 (clear-visited-file-modtime))
16464 (run-hooks 'gnus-save-standard-newsrc-hook)
16466 (kill-buffer (current-buffer)))))
16470 ;;; Slave functions.
16473 (defun gnus-slave-save-newsrc ()
16475 (set-buffer gnus-dribble-buffer)
16477 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16478 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16480 (defun gnus-master-read-slave-newsrc ()
16483 (file-name-directory gnus-current-startup-file)
16487 (file-name-nondirectory gnus-current-startup-file)
16491 (if (not slave-files)
16492 () ; There are no slave files to read.
16493 (gnus-message 7 "Reading slave newsrcs...")
16495 (set-buffer (get-buffer-create " *gnus slave*"))
16496 (buffer-disable-undo (current-buffer))
16498 (sort (mapcar (lambda (file)
16499 (list (nth 5 (file-attributes file)) file))
16502 (or (< (caar f1) (caar f2))
16503 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16506 (setq file (nth 1 (car slave-files)))
16507 (insert-file-contents file)
16508 (if (condition-case ()
16510 (eval-buffer (current-buffer))
16513 (gnus-message 3 "Possible error in %s" file)
16517 (or gnus-slave ; Slaves shouldn't delete these files.
16521 (setq slave-files (cdr slave-files))))
16522 (gnus-message 7 "Reading slave newsrcs...done"))))
16526 ;;; Group description.
16529 (defun gnus-read-all-descriptions-files ()
16530 (let ((methods (cons gnus-select-method
16532 (when gnus-message-archive-method
16534 gnus-secondary-select-methods))))
16536 (gnus-read-descriptions-file (car methods))
16537 (setq methods (cdr methods)))
16540 (defun gnus-read-descriptions-file (&optional method)
16541 (let ((method (or method gnus-select-method)))
16542 (when (stringp method)
16543 (setq method (gnus-server-to-method method)))
16544 ;; We create the hashtable whether we manage to read the desc file
16545 ;; to avoid trying to re-read after a failed read.
16546 (or gnus-description-hashtb
16547 (setq gnus-description-hashtb
16548 (gnus-make-hashtable (length gnus-active-hashtb))))
16549 ;; Mark this method's desc file as read.
16550 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16551 gnus-description-hashtb)
16553 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16555 ((not (gnus-check-server method))
16556 (gnus-message 1 "Couldn't open server")
16558 ((not (gnus-request-list-newsgroups method))
16559 (gnus-message 1 "Couldn't read newsgroups descriptions")
16565 (set-buffer nntp-server-buffer)
16566 (goto-char (point-min))
16567 (if (or (search-forward "\n.\n" nil t)
16568 (goto-char (point-max)))
16570 (beginning-of-line)
16571 (narrow-to-region (point-min) (point))))
16572 (goto-char (point-min))
16573 (while (not (eobp))
16574 ;; If we get an error, we set group to 0, which is not a
16578 (let ((obarray gnus-description-hashtb))
16579 ;; Group is set to a symbol interned in this
16581 (read nntp-server-buffer))
16583 (skip-chars-forward " \t")
16584 ;; ... which leads to this line being effectively ignored.
16585 (and (symbolp group)
16586 (set group (buffer-substring
16587 (point) (progn (end-of-line) (point)))))
16588 (forward-line 1))))
16589 (gnus-message 5 "Reading descriptions file...done")
16592 (defun gnus-group-get-description (group)
16593 "Get the description of a group by sending XGTITLE to the server."
16594 (when (gnus-request-group-description group)
16596 (set-buffer nntp-server-buffer)
16597 (goto-char (point-min))
16598 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16599 (match-string 1)))))
16603 ;;; Buffering of read articles.
16606 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16607 (defvar gnus-backlog-articles nil)
16608 (defvar gnus-backlog-hashtb nil)
16610 (defun gnus-backlog-buffer ()
16611 "Return the backlog buffer."
16612 (or (get-buffer gnus-backlog-buffer)
16614 (set-buffer (get-buffer-create gnus-backlog-buffer))
16615 (buffer-disable-undo (current-buffer))
16616 (setq buffer-read-only t)
16617 (gnus-add-current-to-buffer-list)
16618 (get-buffer gnus-backlog-buffer))))
16620 (defun gnus-backlog-setup ()
16621 "Initialize backlog variables."
16622 (unless gnus-backlog-hashtb
16623 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16625 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16627 (defun gnus-backlog-shutdown ()
16628 "Clear all backlog variables and buffers."
16629 (when (get-buffer gnus-backlog-buffer)
16630 (kill-buffer gnus-backlog-buffer))
16631 (setq gnus-backlog-hashtb nil
16632 gnus-backlog-articles nil))
16634 (defun gnus-backlog-enter-article (group number buffer)
16635 (gnus-backlog-setup)
16636 (let ((ident (intern (concat group ":" (int-to-string number))
16637 gnus-backlog-hashtb))
16639 (if (memq ident gnus-backlog-articles)
16640 () ; It's already kept.
16641 ;; Remove the oldest article, if necessary.
16642 (and (numberp gnus-keep-backlog)
16643 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16644 (gnus-backlog-remove-oldest-article))
16645 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16646 ;; Insert the new article.
16648 (set-buffer (gnus-backlog-buffer))
16649 (let (buffer-read-only)
16650 (goto-char (point-max))
16651 (or (bolp) (insert "\n"))
16653 (insert-buffer-substring buffer)
16654 ;; Tag the beginning of the article with the ident.
16655 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16657 (defun gnus-backlog-remove-oldest-article ()
16659 (set-buffer (gnus-backlog-buffer))
16660 (goto-char (point-min))
16661 (if (zerop (buffer-size))
16662 () ; The buffer is empty.
16663 (let ((ident (get-text-property (point) 'gnus-backlog))
16665 ;; Remove the ident from the list of articles.
16667 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16668 ;; Delete the article itself.
16670 (point) (next-single-property-change
16671 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16673 (defun gnus-backlog-request-article (group number buffer)
16674 (when (numberp number)
16675 (gnus-backlog-setup)
16676 (let ((ident (intern (concat group ":" (int-to-string number))
16677 gnus-backlog-hashtb))
16679 (when (memq ident gnus-backlog-articles)
16680 ;; It was in the backlog.
16682 (set-buffer (gnus-backlog-buffer))
16683 (if (not (setq beg (text-property-any
16684 (point-min) (point-max) 'gnus-backlog
16686 ;; It wasn't in the backlog after all.
16688 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16689 ;; Find the end (i. e., the beginning of the next article).
16691 (next-single-property-change
16692 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16693 (let ((buffer-read-only nil))
16695 (insert-buffer-substring gnus-backlog-buffer beg end)
16698 ;; Allow redefinition of Gnus functions.
16700 (gnus-ems-redefine)
16704 ;;; gnus.el ends here