1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
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.
31 (defvar tool-bar-map))
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
48 (autoload 'mm-uu-dissect "mm-uu")
49 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
50 "Deuglify broken Outlook (Express) articles and redisplay."
52 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
53 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
54 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
56 (defcustom gnus-kill-summary-on-exit t
57 "*If non-nil, kill the summary buffer when you exit from it.
58 If nil, the summary will become a \"*Dead Summary*\" buffer, and
59 it will be killed sometime later."
60 :group 'gnus-summary-exit
63 (defcustom gnus-fetch-old-headers nil
64 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
65 If an unread article in the group refers to an older, already read (or
66 just marked as read) article, the old article will not normally be
67 displayed in the Summary buffer. If this variable is non-nil, Gnus
68 will attempt to grab the headers to the old articles, and thereby
69 build complete threads. If it has the value `some', only enough
70 headers to connect otherwise loose threads will be displayed. This
71 variable can also be a number. In that case, no more than that number
72 of old headers will be fetched. If it has the value `invisible', all
73 old headers will be fetched, but none will be displayed.
75 The server has to support NOV for any of this to work."
77 :type '(choice (const :tag "off" nil)
80 (sexp :menu-tag "other" t)))
82 (defcustom gnus-refer-thread-limit 200
83 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
84 If t, fetch all the available old headers."
87 (sexp :menu-tag "other" t)))
89 (defcustom gnus-summary-make-false-root 'adopt
90 "*nil means that Gnus won't gather loose threads.
91 If the root of a thread has expired or been read in a previous
92 session, the information necessary to build a complete thread has been
93 lost. Instead of having many small sub-threads from this original thread
94 scattered all over the summary buffer, Gnus can gather them.
96 If non-nil, Gnus will try to gather all loose sub-threads from an
97 original thread into one large thread.
99 If this variable is non-nil, it should be one of `none', `adopt',
102 If this variable is `none', Gnus will not make a false root, but just
103 present the sub-threads after another.
104 If this variable is `dummy', Gnus will create a dummy root that will
105 have all the sub-threads as children.
106 If this variable is `adopt', Gnus will make one of the \"children\"
107 the parent and mark all the step-children as such.
108 If this variable is `empty', the \"children\" are printed with empty
109 subject fields. (Or rather, they will be printed with a string
110 given by the `gnus-summary-same-subject' variable.)"
112 :type '(choice (const :tag "off" nil)
118 (defcustom gnus-summary-make-false-root-always nil
119 "Always make a false dummy root."
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include:
151 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
152 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
154 :type '(repeat function))
156 (defcustom gnus-simplify-ignored-prefixes nil
157 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
159 :type '(choice (const :tag "off" nil)
162 (defcustom gnus-build-sparse-threads nil
163 "*If non-nil, fill in the gaps in threads.
164 If `some', only fill in the gaps that are needed to tie loose threads
165 together. If `more', fill in all leaf nodes that Gnus can find. If
166 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
168 :type '(choice (const :tag "off" nil)
171 (sexp :menu-tag "all" t)))
173 (defcustom gnus-summary-thread-gathering-function
174 'gnus-gather-threads-by-subject
175 "*Function used for gathering loose threads.
176 There are two pre-defined functions: `gnus-gather-threads-by-subject',
177 which only takes Subjects into consideration; and
178 `gnus-gather-threads-by-references', which compared the References
179 headers of the articles to find matches."
181 :type '(radio (function-item gnus-gather-threads-by-subject)
182 (function-item gnus-gather-threads-by-references)
183 (function :tag "other")))
185 (defcustom gnus-summary-same-subject ""
186 "*String indicating that the current article has the same subject as the previous.
187 This variable will only be used if the value of
188 `gnus-summary-make-false-root' is `empty'."
189 :group 'gnus-summary-format
192 (defcustom gnus-summary-goto-unread t
193 "*If t, many commands will go to the next unread article.
194 This applies to marking commands as well as other commands that
195 \"naturally\" select the next article, like, for instance, `SPC' at
196 the end of an article.
198 If nil, the marking commands do NOT go to the next unread article
199 \(they go to the next article instead). If `never', commands that
200 usually go to the next unread article, will go to the next article,
201 whether it is read or not."
202 :group 'gnus-summary-marks
203 :link '(custom-manual "(gnus)Setting Marks")
204 :type '(choice (const :tag "off" nil)
206 (sexp :menu-tag "on" t)))
208 (defcustom gnus-summary-default-score 0
209 "*Default article score level.
210 All scores generated by the score files will be added to this score.
211 If this variable is nil, scoring will be disabled."
212 :group 'gnus-score-default
213 :type '(choice (const :tag "disable")
216 (defcustom gnus-summary-default-high-score 0
217 "*Default threshold for a high scored article.
218 An article will be highlighted as high scored if its score is greater
220 :group 'gnus-score-default
223 (defcustom gnus-summary-default-low-score 0
224 "*Default threshold for a low scored article.
225 An article will be highlighted as low scored if its score is smaller
227 :group 'gnus-score-default
230 (defcustom gnus-summary-zcore-fuzz 0
231 "*Fuzziness factor for the zcore in the summary buffer.
232 Articles with scores closer than this to `gnus-summary-default-score'
234 :group 'gnus-summary-format
237 (defcustom gnus-simplify-subject-fuzzy-regexp nil
238 "*Strings to be removed when doing fuzzy matches.
239 This can either be a regular expression or list of regular expressions
240 that will be removed from subject strings if fuzzy subject
241 simplification is selected."
243 :type '(repeat regexp))
245 (defcustom gnus-show-threads t
246 "*If non-nil, display threads in summary mode."
250 (defcustom gnus-thread-hide-subtree nil
251 "*If non-nil, hide all threads initially.
252 This can be a predicate specifier which says which threads to hide.
253 If threads are hidden, you have to run the command
254 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
255 to expose hidden threads."
257 :type '(radio (sexp :format "Non-nil\n"
258 :match (lambda (widget value)
259 (not (or (consp value) (functionp value))))
262 (sexp :tag "Predicate specifier" :size 0)))
264 (defcustom gnus-thread-hide-killed t
265 "*If non-nil, hide killed threads automatically."
269 (defcustom gnus-thread-ignore-subject t
270 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
271 If nil, articles that have different subjects from their parents will
272 start separate threads."
276 (defcustom gnus-thread-operation-ignore-subject t
277 "*If non-nil, subjects will be ignored when doing thread commands.
278 This affects commands like `gnus-summary-kill-thread' and
279 `gnus-summary-lower-thread'.
281 If this variable is nil, articles in the same thread with different
282 subjects will not be included in the operation in question. If this
283 variable is `fuzzy', only articles that have subjects that are fuzzily
284 equal will be included."
286 :type '(choice (const :tag "off" nil)
290 (defcustom gnus-thread-indent-level 4
291 "*Number that says how much each sub-thread should be indented."
295 (defcustom gnus-auto-extend-newsgroup t
296 "*If non-nil, extend newsgroup forward and backward when requested."
297 :group 'gnus-summary-choose
300 (defcustom gnus-auto-select-first t
301 "*If non-nil, select the article under point.
302 Which article this is is controlled by the `gnus-auto-select-subject'
305 If you want to prevent automatic selection of articles in some
306 newsgroups, set the variable to nil in `gnus-select-group-hook'."
307 :group 'gnus-group-select
308 :type '(choice (const :tag "none" nil)
309 (sexp :menu-tag "first" t)))
311 (defcustom gnus-auto-select-subject 'unread
312 "*Says what subject to place under point when entering a group.
314 This variable can either be the symbols `first' (place point on the
315 first subject), `unread' (place point on the subject line of the first
316 unread article), `best' (place point on the subject line of the
317 higest-scored article), `unseen' (place point on the subject line of
318 the first unseen article), 'unseen-or-unread' (place point on the subject
319 line of the first unseen article or, if all article have been seen, on the
320 subject line of the first unread article), or a function to be called to
321 place point on some subject line."
322 :group 'gnus-group-select
323 :type '(choice (const best)
327 (const unseen-or-unread)))
329 (defcustom gnus-auto-select-next t
330 "*If non-nil, offer to go to the next group from the end of the previous.
331 If the value is t and the next newsgroup is empty, Gnus will exit
332 summary mode and go back to group mode. If the value is neither nil
333 nor t, Gnus will select the following unread newsgroup. In
334 particular, if the value is the symbol `quietly', the next unread
335 newsgroup will be selected without any confirmation, and if it is
336 `almost-quietly', the next group will be selected without any
337 confirmation if you are located on the last article in the group.
338 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
339 will go to the next group without confirmation."
340 :group 'gnus-summary-maneuvering
341 :type '(choice (const :tag "off" nil)
343 (const almost-quietly)
344 (const slightly-quietly)
345 (sexp :menu-tag "on" t)))
347 (defcustom gnus-auto-select-same nil
348 "*If non-nil, select the next article with the same subject.
349 If there are no more articles with the same subject, go to
350 the first unread article."
351 :group 'gnus-summary-maneuvering
354 (defcustom gnus-auto-goto-ignores 'unfetched
355 "*Says how to handle unfetched articles when maneuvering.
357 This variable can either be the symbols nil (maneuver to any
358 article), `undownloaded' (maneuvering while unplugged ignores articles
359 that have not been fetched), `always-undownloaded' (maneuvering always
360 ignores articles that have not been fetched), `unfetched' (maneuvering
361 ignores articles whose headers have not been fetched).
363 NOTE: The list of unfetched articles will always be nil when plugged
364 and, when unplugged, a subset of the undownloaded article list."
365 :group 'gnus-summary-maneuvering
366 :type '(choice (const :tag "None" nil)
367 (const :tag "Undownloaded when unplugged" undownloaded)
368 (const :tag "Undownloaded" always-undownloaded)
369 (const :tag "Unfetched" unfetched)))
371 (defcustom gnus-summary-check-current nil
372 "*If non-nil, consider the current article when moving.
373 The \"unread\" movement commands will stay on the same line if the
374 current article is unread."
375 :group 'gnus-summary-maneuvering
378 (defcustom gnus-auto-center-summary 2
379 "*If non-nil, always center the current summary buffer.
380 In particular, if `vertical' do only vertical recentering. If non-nil
381 and non-`vertical', do both horizontal and vertical recentering."
382 :group 'gnus-summary-maneuvering
383 :type '(choice (const :tag "none" nil)
385 (integer :tag "height")
386 (sexp :menu-tag "both" t)))
388 (defvar gnus-auto-center-group t
389 "*If non-nil, always center the group buffer.")
391 (defcustom gnus-show-all-headers nil
392 "*If non-nil, don't hide any headers."
393 :group 'gnus-article-hiding
394 :group 'gnus-article-headers
397 (defcustom gnus-summary-ignore-duplicates nil
398 "*If non-nil, ignore articles with identical Message-ID headers."
402 (defcustom gnus-single-article-buffer t
403 "*If non-nil, display all articles in the same buffer.
404 If nil, each group will get its own article buffer."
405 :group 'gnus-article-various
408 (defcustom gnus-break-pages t
409 "*If non-nil, do page breaking on articles.
410 The page delimiter is specified by the `gnus-page-delimiter'
412 :group 'gnus-article-various
415 (defcustom gnus-move-split-methods nil
416 "*Variable used to suggest where articles are to be moved to.
417 It uses the same syntax as the `gnus-split-methods' variable.
418 However, whereas `gnus-split-methods' specifies file names as targets,
419 this variable specifies group names."
420 :group 'gnus-summary-mail
421 :type '(repeat (choice (list :value (fun) function)
422 (cons :value ("" "") regexp (repeat string))
425 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
426 "Function used to compute default prefix for article move/copy/etc prompts.
427 The function should take one argument, a group name, and return a
428 string with the suggested prefix."
429 :group 'gnus-summary-mail
432 (defcustom gnus-unread-mark ? ;Whitespace
433 "*Mark used for unread articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-ticked-mark ?!
438 "*Mark used for ticked articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-dormant-mark ??
443 "*Mark used for dormant articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-del-mark ?r
448 "*Mark used for del'd articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-read-mark ?R
453 "*Mark used for read articles."
454 :group 'gnus-summary-marks
457 (defcustom gnus-expirable-mark ?E
458 "*Mark used for expirable articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-killed-mark ?K
463 "*Mark used for killed articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-spam-mark ?$
468 "*Mark used for spam articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-souped-mark ?F
473 "*Mark used for souped articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-kill-file-mark ?X
478 "*Mark used for articles killed by kill files."
479 :group 'gnus-summary-marks
482 (defcustom gnus-low-score-mark ?Y
483 "*Mark used for articles with a low score."
484 :group 'gnus-summary-marks
487 (defcustom gnus-catchup-mark ?C
488 "*Mark used for articles that are caught up."
489 :group 'gnus-summary-marks
492 (defcustom gnus-replied-mark ?A
493 "*Mark used for articles that have been replied to."
494 :group 'gnus-summary-marks
497 (defcustom gnus-forwarded-mark ?F
498 "*Mark used for articles that have been forwarded."
499 :group 'gnus-summary-marks
502 (defcustom gnus-recent-mark ?N
503 "*Mark used for articles that are recent."
504 :group 'gnus-summary-marks
507 (defcustom gnus-cached-mark ?*
508 "*Mark used for articles that are in the cache."
509 :group 'gnus-summary-marks
512 (defcustom gnus-saved-mark ?S
513 "*Mark used for articles that have been saved."
514 :group 'gnus-summary-marks
517 (defcustom gnus-unseen-mark ?.
518 "*Mark used for articles that haven't been seen."
519 :group 'gnus-summary-marks
522 (defcustom gnus-no-mark ? ;Whitespace
523 "*Mark used for articles that have no other secondary mark."
524 :group 'gnus-summary-marks
527 (defcustom gnus-ancient-mark ?O
528 "*Mark used for ancient articles."
529 :group 'gnus-summary-marks
532 (defcustom gnus-sparse-mark ?Q
533 "*Mark used for sparsely reffed articles."
534 :group 'gnus-summary-marks
537 (defcustom gnus-canceled-mark ?G
538 "*Mark used for canceled articles."
539 :group 'gnus-summary-marks
542 (defcustom gnus-duplicate-mark ?M
543 "*Mark used for duplicate articles."
544 :group 'gnus-summary-marks
547 (defcustom gnus-undownloaded-mark ?-
548 "*Mark used for articles that weren't downloaded."
549 :group 'gnus-summary-marks
552 (defcustom gnus-downloaded-mark ?+
553 "*Mark used for articles that were downloaded."
554 :group 'gnus-summary-marks
557 (defcustom gnus-downloadable-mark ?%
558 "*Mark used for articles that are to be downloaded."
559 :group 'gnus-summary-marks
562 (defcustom gnus-unsendable-mark ?=
563 "*Mark used for articles that won't be sent."
564 :group 'gnus-summary-marks
567 (defcustom gnus-score-over-mark ?+
568 "*Score mark used for articles with high scores."
569 :group 'gnus-summary-marks
572 (defcustom gnus-score-below-mark ?-
573 "*Score mark used for articles with low scores."
574 :group 'gnus-summary-marks
577 (defcustom gnus-empty-thread-mark ? ;Whitespace
578 "*There is no thread under the article."
579 :group 'gnus-summary-marks
582 (defcustom gnus-not-empty-thread-mark ?=
583 "*There is a thread under the article."
584 :group 'gnus-summary-marks
587 (defcustom gnus-view-pseudo-asynchronously nil
588 "*If non-nil, Gnus will view pseudo-articles asynchronously."
589 :group 'gnus-extract-view
592 (defcustom gnus-auto-expirable-marks
593 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
594 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
595 gnus-souped-mark gnus-duplicate-mark)
596 "*The list of marks converted into expiration if a group is auto-expirable."
599 :type '(repeat character))
601 (defcustom gnus-inhibit-user-auto-expire t
602 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
607 (defcustom gnus-view-pseudos nil
608 "*If `automatic', pseudo-articles will be viewed automatically.
609 If `not-confirm', pseudos will be viewed automatically, and the user
610 will not be asked to confirm the command."
611 :group 'gnus-extract-view
612 :type '(choice (const :tag "off" nil)
614 (const not-confirm)))
616 (defcustom gnus-view-pseudos-separately t
617 "*If non-nil, one pseudo-article will be created for each file to be viewed.
618 If nil, all files that use the same viewing command will be given as a
619 list of parameters to that command."
620 :group 'gnus-extract-view
623 (defcustom gnus-insert-pseudo-articles t
624 "*If non-nil, insert pseudo-articles when decoding articles."
625 :group 'gnus-extract-view
628 (defcustom gnus-summary-dummy-line-format
630 "*The format specification for the dummy roots in the summary buffer.
631 It works along the same lines as a normal formatting string,
632 with some simple extensions.
636 General format specifiers can also be used.
637 See `(gnus)Formatting Variables'."
638 :link '(custom-manual "(gnus)Formatting Variables")
639 :group 'gnus-threading
642 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
643 "*The format specification for the summary mode line.
644 It works along the same lines as a normal formatting string,
645 with some simple extensions:
648 %p Unprefixed group name
649 %A Current article number
650 %z Current article score
652 %U Number of unread articles in the group
653 %e Number of unselected articles in the group
654 %Z A string with unread/unselected article counts
655 %g Shortish group name
656 %S Subject of the current article
658 %s Current score file name
659 %d Number of dormant articles
660 %r Number of articles that have been marked as read in this session
661 %E Number of articles expunged by the score files"
662 :group 'gnus-summary-format
665 (defcustom gnus-list-identifiers nil
666 "Regexp that matches list identifiers to be removed from subject.
667 This can also be a list of regexps."
669 :group 'gnus-summary-format
670 :group 'gnus-article-hiding
671 :type '(choice (const :tag "none" nil)
673 (repeat :value (".*") regexp)))
675 (defcustom gnus-summary-mark-below 0
676 "*Mark all articles with a score below this variable as read.
677 This variable is local to each summary buffer and usually set by the
679 :group 'gnus-score-default
682 (defun gnus-widget-reversible-match (widget value)
683 "Ignoring WIDGET, convert VALUE to internal form.
684 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
688 (eq (length value) 2)
689 (eq (nth 0 value) 'not)
690 (symbolp (nth 1 value)))))
692 (defun gnus-widget-reversible-to-internal (widget value)
693 "Ignoring WIDGET, convert VALUE to internal form.
694 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
695 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
699 (list (nth 1 value) t)))
701 (defun gnus-widget-reversible-to-external (widget value)
702 "Ignoring WIDGET, convert VALUE to external form.
703 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
704 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
707 (list 'not (nth 0 value))
710 (define-widget 'gnus-widget-reversible 'group
711 "A `group' that convert values."
712 :match 'gnus-widget-reversible-match
713 :value-to-internal 'gnus-widget-reversible-to-internal
714 :value-to-external 'gnus-widget-reversible-to-external)
716 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
717 "*List of functions used for sorting articles in the summary buffer.
719 Each function takes two articles and returns non-nil if the first
720 article should be sorted before the other. If you use more than one
721 function, the primary sort function should be the last. You should
722 probably always include `gnus-article-sort-by-number' in the list of
723 sorting functions -- preferably first. Also note that sorting by date
724 is often much slower than sorting by number, and the sorting order is
725 very similar. (Sorting by date means sorting by the time the message
726 was sent, sorting by number means sorting by arrival time.)
728 Each item can also be a list `(not F)' where F is a function;
729 this reverses the sort order.
731 Ready-made functions include `gnus-article-sort-by-number',
732 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
733 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
734 and `gnus-article-sort-by-score'.
736 When threading is turned on, the variable `gnus-thread-sort-functions'
737 controls how articles are sorted."
738 :group 'gnus-summary-sort
739 :type '(repeat (gnus-widget-reversible
740 (choice (function-item gnus-article-sort-by-number)
741 (function-item gnus-article-sort-by-author)
742 (function-item gnus-article-sort-by-subject)
743 (function-item gnus-article-sort-by-date)
744 (function-item gnus-article-sort-by-score)
745 (function-item gnus-article-sort-by-random)
746 (function :tag "other"))
747 (boolean :tag "Reverse order"))))
750 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
751 "*List of functions used for sorting threads in the summary buffer.
752 By default, threads are sorted by article number.
754 Each function takes two threads and returns non-nil if the first
755 thread should be sorted before the other. If you use more than one
756 function, the primary sort function should be the last. You should
757 probably always include `gnus-thread-sort-by-number' in the list of
758 sorting functions -- preferably first. Also note that sorting by date
759 is often much slower than sorting by number, and the sorting order is
760 very similar. (Sorting by date means sorting by the time the message
761 was sent, sorting by number means sorting by arrival time.)
763 Each list item can also be a list `(not F)' where F is a
764 function; this specifies reversed sort order.
766 Ready-made functions include `gnus-thread-sort-by-number',
767 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
768 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
769 `gnus-thread-sort-by-most-recent-number',
770 `gnus-thread-sort-by-most-recent-date',
771 `gnus-thread-sort-by-random', and
772 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
774 When threading is turned off, the variable
775 `gnus-article-sort-functions' controls how articles are sorted."
776 :group 'gnus-summary-sort
778 (gnus-widget-reversible
779 (choice (function-item gnus-thread-sort-by-number)
780 (function-item gnus-thread-sort-by-author)
781 (function-item gnus-thread-sort-by-subject)
782 (function-item gnus-thread-sort-by-date)
783 (function-item gnus-thread-sort-by-score)
784 (function-item gnus-thread-sort-by-most-recent-number)
785 (function-item gnus-thread-sort-by-most-recent-date)
786 (function-item gnus-thread-sort-by-random)
787 (function-item gnus-thread-sort-by-total-score)
788 (function :tag "other"))
789 (boolean :tag "Reverse order"))))
791 (defcustom gnus-thread-score-function '+
792 "*Function used for calculating the total score of a thread.
794 The function is called with the scores of the article and each
795 subthread and should then return the score of the thread.
797 Some functions you can use are `+', `max', or `min'."
798 :group 'gnus-summary-sort
801 (defcustom gnus-summary-expunge-below nil
802 "All articles that have a score less than this variable will be expunged.
803 This variable is local to the summary buffers."
804 :group 'gnus-score-default
805 :type '(choice (const :tag "off" nil)
808 (defcustom gnus-thread-expunge-below nil
809 "All threads that have a total score less than this variable will be expunged.
810 See `gnus-thread-score-function' for en explanation of what a
813 This variable is local to the summary buffers."
814 :group 'gnus-threading
815 :group 'gnus-score-default
816 :type '(choice (const :tag "off" nil)
819 (defcustom gnus-summary-mode-hook nil
820 "*A hook for Gnus summary mode.
821 This hook is run before any variables are set in the summary buffer."
822 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
823 :group 'gnus-summary-various
826 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
827 (when (featurep 'xemacs)
828 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
829 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
830 (add-hook 'gnus-summary-mode-hook
831 'gnus-xmas-switch-horizontal-scrollbar-off))
833 (defcustom gnus-summary-menu-hook nil
834 "*Hook run after the creation of the summary mode menu."
835 :group 'gnus-summary-visual
838 (defcustom gnus-summary-exit-hook nil
839 "*A hook called on exit from the summary buffer.
840 It will be called with point in the group buffer."
841 :group 'gnus-summary-exit
844 (defcustom gnus-summary-prepare-hook nil
845 "*A hook called after the summary buffer has been generated.
846 If you want to modify the summary buffer, you can use this hook."
847 :group 'gnus-summary-various
850 (defcustom gnus-summary-prepared-hook nil
851 "*A hook called as the last thing after the summary buffer has been generated."
852 :group 'gnus-summary-various
855 (defcustom gnus-summary-generate-hook nil
856 "*A hook run just before generating the summary buffer.
857 This hook is commonly used to customize threading variables and the
859 :group 'gnus-summary-various
862 (defcustom gnus-select-group-hook nil
863 "*A hook called when a newsgroup is selected.
865 If you'd like to simplify subjects like the
866 `gnus-summary-next-same-subject' command does, you can use the
869 (add-hook gnus-select-group-hook
871 (mapcar (lambda (header)
872 (mail-header-set-subject
874 (gnus-simplify-subject
875 (mail-header-subject header) 're-only)))
876 gnus-newsgroup-headers)))"
877 :group 'gnus-group-select
880 (defcustom gnus-select-article-hook nil
881 "*A hook called when an article is selected."
882 :group 'gnus-summary-choose
883 :options '(gnus-agent-fetch-selected-article)
886 (defcustom gnus-visual-mark-article-hook
887 (list 'gnus-highlight-selected-summary)
888 "*Hook run after selecting an article in the summary buffer.
889 It is meant to be used for highlighting the article in some way. It
890 is not run if `gnus-visual' is nil."
891 :group 'gnus-summary-visual
894 (defcustom gnus-parse-headers-hook nil
895 "*A hook called before parsing the headers."
899 (defcustom gnus-exit-group-hook nil
900 "*A hook called when exiting summary mode.
901 This hook is not called from the non-updating exit commands like `Q'."
905 (defcustom gnus-summary-update-hook
906 (list 'gnus-summary-highlight-line)
907 "*A hook called when a summary line is changed.
908 The hook will not be called if `gnus-visual' is nil.
910 The default function `gnus-summary-highlight-line' will
911 highlight the line according to the `gnus-summary-highlight'
913 :group 'gnus-summary-visual
916 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
917 "*A hook called when an article is selected for the first time.
918 The hook is intended to mark an article as read (or unread)
919 automatically when it is selected."
920 :group 'gnus-summary-choose
923 (defcustom gnus-group-no-more-groups-hook nil
924 "*A hook run when returning to group mode having no more (unread) groups."
925 :group 'gnus-group-select
928 (defcustom gnus-ps-print-hook nil
929 "*A hook run before ps-printing something from Gnus."
933 (defcustom gnus-summary-article-move-hook nil
934 "*A hook called after an article is moved, copied, respooled, or crossposted."
938 (defcustom gnus-summary-article-delete-hook nil
939 "*A hook called after an article is deleted."
943 (defcustom gnus-summary-article-expire-hook nil
944 "*A hook called after an article is expired."
948 (defcustom gnus-summary-display-arrow
949 (and (fboundp 'display-graphic-p)
951 "*If non-nil, display an arrow highlighting the current article."
956 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
957 "Face used for highlighting the current article in the summary buffer."
958 :group 'gnus-summary-visual
961 (defvar gnus-tmp-downloaded nil)
963 (defcustom gnus-summary-highlight
964 '(((eq mark gnus-canceled-mark)
965 . gnus-summary-cancelled-face)
966 ((and uncached (> score default-high))
967 . gnus-summary-high-undownloaded-face)
968 ((and uncached (< score default-low))
969 . gnus-summary-low-undownloaded-face)
971 . gnus-summary-normal-undownloaded-face)
972 ((and (> score default-high)
973 (or (eq mark gnus-dormant-mark)
974 (eq mark gnus-ticked-mark)))
975 . gnus-summary-high-ticked-face)
976 ((and (< score default-low)
977 (or (eq mark gnus-dormant-mark)
978 (eq mark gnus-ticked-mark)))
979 . gnus-summary-low-ticked-face)
980 ((or (eq mark gnus-dormant-mark)
981 (eq mark gnus-ticked-mark))
982 . gnus-summary-normal-ticked-face)
983 ((and (> score default-high) (eq mark gnus-ancient-mark))
984 . gnus-summary-high-ancient-face)
985 ((and (< score default-low) (eq mark gnus-ancient-mark))
986 . gnus-summary-low-ancient-face)
987 ((eq mark gnus-ancient-mark)
988 . gnus-summary-normal-ancient-face)
989 ((and (> score default-high) (eq mark gnus-unread-mark))
990 . gnus-summary-high-unread-face)
991 ((and (< score default-low) (eq mark gnus-unread-mark))
992 . gnus-summary-low-unread-face)
993 ((eq mark gnus-unread-mark)
994 . gnus-summary-normal-unread-face)
995 ((> score default-high)
996 . gnus-summary-high-read-face)
997 ((< score default-low)
998 . gnus-summary-low-read-face)
1000 . gnus-summary-normal-read-face))
1001 "*Controls the highlighting of summary buffer lines.
1003 A list of (FORM . FACE) pairs. When deciding how a a particular
1004 summary line should be displayed, each form is evaluated. The content
1005 of the face field after the first true form is used. You can change
1006 how those summary lines are displayed, by editing the face field.
1008 You can use the following variables in the FORM field.
1010 score: The article's score
1011 default: The default article score.
1012 default-high: The default score for high scored articles.
1013 default-low: The default score for low scored articles.
1014 below: The score below which articles are automatically marked as read.
1015 mark: The article's mark.
1016 uncached: Non-nil if the article is uncached."
1017 :group 'gnus-summary-visual
1018 :type '(repeat (cons (sexp :tag "Form" nil)
1021 (defcustom gnus-alter-header-function nil
1022 "Function called to allow alteration of article header structures.
1023 The function is called with one parameter, the article header vector,
1024 which it may alter in any way."
1025 :type '(choice (const :tag "None" nil)
1027 :group 'gnus-summary)
1029 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1030 "Variable that says which function should be used to decode a string with encoded words.")
1032 (defcustom gnus-extra-headers '(To Newsgroups)
1033 "*Extra headers to parse."
1035 :group 'gnus-summary
1036 :type '(repeat symbol))
1038 (defcustom gnus-ignored-from-addresses
1039 (and user-mail-address (regexp-quote user-mail-address))
1040 "*Regexp of From headers that may be suppressed in favor of To headers."
1042 :group 'gnus-summary
1045 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1046 "List of charsets that should be ignored.
1047 When these charsets are used in the \"charset\" parameter, the
1048 default charset will be used instead."
1050 :type '(repeat symbol)
1051 :group 'gnus-charset)
1053 (gnus-define-group-parameter
1057 "Return the ignored charsets of GROUP."
1058 :variable gnus-group-ignored-charsets-alist
1060 '(("alt\\.chinese\\.text" iso-8859-1))
1062 "Alist of regexps (to match group names) and charsets that should be ignored.
1063 When these charsets are used in the \"charset\" parameter, the
1064 default charset will be used instead."
1065 :variable-group gnus-charset
1066 :variable-type '(repeat (cons (regexp :tag "Group")
1068 :parameter-type '(choice :tag "Ignored charsets"
1071 :parameter-document "\
1072 List of charsets that should be ignored.
1074 When these charsets are used in the \"charset\" parameter, the
1075 default charset will be used instead.")
1077 (defcustom gnus-group-highlight-words-alist nil
1078 "Alist of group regexps and highlight regexps.
1079 This variable uses the same syntax as `gnus-emphasis-alist'."
1081 :type '(repeat (cons (regexp :tag "Group")
1082 (repeat (list (regexp :tag "Highlight regexp")
1083 (number :tag "Group for entire word" 0)
1084 (number :tag "Group for displayed part" 0)
1086 gnus-emphasis-highlight-words)))))
1087 :group 'gnus-summary-visual)
1089 (defcustom gnus-summary-show-article-charset-alist
1091 "Alist of number and charset.
1092 The article will be shown with the charset corresponding to the
1094 For example: ((1 . cn-gb-2312) (2 . big5))."
1096 :type '(repeat (cons (number :tag "Argument" 1)
1097 (symbol :tag "Charset")))
1098 :group 'gnus-charset)
1100 (defcustom gnus-preserve-marks t
1101 "Whether marks are preserved when moving, copying and respooling messages."
1104 :group 'gnus-summary-marks)
1106 (defcustom gnus-alter-articles-to-read-function nil
1107 "Function to be called to alter the list of articles to be selected."
1108 :type '(choice (const nil) function)
1109 :group 'gnus-summary)
1111 (defcustom gnus-orphan-score nil
1112 "*All orphans get this score added. Set in the score file."
1113 :group 'gnus-score-default
1114 :type '(choice (const nil)
1117 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1118 "*A regexp to match MIME parts when saving multiple parts of a
1119 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1120 This regexp will be used by default when prompting the user for which
1121 type of files to save."
1122 :group 'gnus-summary
1125 (defcustom gnus-read-all-available-headers nil
1126 "Whether Gnus should parse all headers made available to it.
1127 This is mostly relevant for slow back ends where the user may
1128 wish to widen the summary buffer to include all headers
1129 that were fetched. Say, for nnultimate groups."
1130 :group 'gnus-summary
1131 :type '(choice boolean regexp))
1133 (defcustom gnus-summary-muttprint-program "muttprint"
1134 "Command (and optional arguments) used to run Muttprint."
1136 :group 'gnus-summary
1139 (defcustom gnus-article-loose-mime t
1140 "If non-nil, don't require MIME-Version header.
1141 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1142 supply the MIME-Version header or deliberately strip it from the mail.
1143 If non-nil (the default), Gnus will treat some articles as MIME
1144 even if the MIME-Version header is missing."
1147 :group 'gnus-article-mime)
1149 (defcustom gnus-article-emulate-mime t
1150 "If non-nil, use MIME emulation for uuencode and the like.
1151 This means that Gnus will search message bodies for text that look
1152 like uuencoded bits, yEncoded bits, and so on, and present that using
1153 the normal Gnus MIME machinery."
1155 :group 'gnus-article-mime)
1157 ;;; Internal variables
1159 (defvar gnus-summary-display-cache nil)
1160 (defvar gnus-article-mime-handles nil)
1161 (defvar gnus-article-decoded-p nil)
1162 (defvar gnus-article-charset nil)
1163 (defvar gnus-article-ignored-charsets nil)
1164 (defvar gnus-scores-exclude-files nil)
1165 (defvar gnus-page-broken nil)
1167 (defvar gnus-original-article nil)
1168 (defvar gnus-article-internal-prepare-hook nil)
1169 (defvar gnus-newsgroup-process-stack nil)
1171 (defvar gnus-thread-indent-array nil)
1172 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1173 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1174 "Function called to sort the articles within a thread after it has been gathered together.")
1176 (defvar gnus-summary-save-parts-type-history nil)
1177 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1179 ;; Avoid highlighting in kill files.
1180 (defvar gnus-summary-inhibit-highlight nil)
1181 (defvar gnus-newsgroup-selected-overlay nil)
1182 (defvar gnus-inhibit-limiting nil)
1183 (defvar gnus-newsgroup-adaptive-score-file nil)
1184 (defvar gnus-current-score-file nil)
1185 (defvar gnus-current-move-group nil)
1186 (defvar gnus-current-copy-group nil)
1187 (defvar gnus-current-crosspost-group nil)
1188 (defvar gnus-newsgroup-display nil)
1190 (defvar gnus-newsgroup-dependencies nil)
1191 (defvar gnus-newsgroup-adaptive nil)
1192 (defvar gnus-summary-display-article-function nil)
1193 (defvar gnus-summary-highlight-line-function nil
1194 "Function called after highlighting a summary line.")
1196 (defvar gnus-summary-line-format-alist
1197 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1198 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1199 (?s gnus-tmp-subject-or-nil ?s)
1200 (?n gnus-tmp-name ?s)
1201 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1203 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1205 (?F gnus-tmp-from ?s)
1206 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1207 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1208 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1209 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1210 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1211 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1212 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1213 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1214 (?L gnus-tmp-lines ?s)
1215 (?O gnus-tmp-downloaded ?c)
1216 (?I gnus-tmp-indentation ?s)
1217 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1218 (?R gnus-tmp-replied ?c)
1219 (?\[ gnus-tmp-opening-bracket ?c)
1220 (?\] gnus-tmp-closing-bracket ?c)
1221 (?\> (make-string gnus-tmp-level ? ) ?s)
1222 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1223 (?i gnus-tmp-score ?d)
1224 (?z gnus-tmp-score-char ?c)
1225 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1226 (?U gnus-tmp-unread ?c)
1227 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1229 (?t (gnus-summary-number-of-articles-in-thread
1230 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1232 (?e (gnus-summary-number-of-articles-in-thread
1233 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1235 (?u gnus-tmp-user-defined ?s)
1236 (?P (gnus-pick-line-number) ?d)
1237 (?B gnus-tmp-thread-tree-header-string ?s)
1238 (user-date (gnus-user-date
1239 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1240 "An alist of format specifications that can appear in summary lines.
1241 These are paired with what variables they correspond with, along with
1242 the type of the variable (string, integer, character, etc).")
1244 (defvar gnus-summary-dummy-line-format-alist
1245 `((?S gnus-tmp-subject ?s)
1246 (?N gnus-tmp-number ?d)
1247 (?u gnus-tmp-user-defined ?s)))
1249 (defvar gnus-summary-mode-line-format-alist
1250 `((?G gnus-tmp-group-name ?s)
1251 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1252 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1253 (?A gnus-tmp-article-number ?d)
1254 (?Z gnus-tmp-unread-and-unselected ?s)
1255 (?V gnus-version ?s)
1256 (?U gnus-tmp-unread-and-unticked ?d)
1257 (?S gnus-tmp-subject ?s)
1258 (?e gnus-tmp-unselected ?d)
1259 (?u gnus-tmp-user-defined ?s)
1260 (?d (length gnus-newsgroup-dormant) ?d)
1261 (?t (length gnus-newsgroup-marked) ?d)
1262 (?h (length gnus-newsgroup-spam-marked) ?d)
1263 (?r (length gnus-newsgroup-reads) ?d)
1264 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1265 (?E gnus-newsgroup-expunged-tally ?d)
1266 (?s (gnus-current-score-file-nondirectory) ?s)))
1268 (defvar gnus-last-search-regexp nil
1269 "Default regexp for article search command.")
1271 (defvar gnus-last-shell-command nil
1272 "Default shell command on article.")
1274 (defvar gnus-newsgroup-agentized nil
1275 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1276 (defvar gnus-newsgroup-begin nil)
1277 (defvar gnus-newsgroup-end nil)
1278 (defvar gnus-newsgroup-last-rmail nil)
1279 (defvar gnus-newsgroup-last-mail nil)
1280 (defvar gnus-newsgroup-last-folder nil)
1281 (defvar gnus-newsgroup-last-file nil)
1282 (defvar gnus-newsgroup-auto-expire nil)
1283 (defvar gnus-newsgroup-active nil)
1285 (defvar gnus-newsgroup-data nil)
1286 (defvar gnus-newsgroup-data-reverse nil)
1287 (defvar gnus-newsgroup-limit nil)
1288 (defvar gnus-newsgroup-limits nil)
1289 (defvar gnus-summary-use-undownloaded-faces nil)
1291 (defvar gnus-newsgroup-unreads nil
1292 "Sorted list of unread articles in the current newsgroup.")
1294 (defvar gnus-newsgroup-unselected nil
1295 "Sorted list of unselected unread articles in the current newsgroup.")
1297 (defvar gnus-newsgroup-reads nil
1298 "Alist of read articles and article marks in the current newsgroup.")
1300 (defvar gnus-newsgroup-expunged-tally nil)
1302 (defvar gnus-newsgroup-marked nil
1303 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1305 (defvar gnus-newsgroup-spam-marked nil
1306 "List of ranges of articles that have been marked as spam.")
1308 (defvar gnus-newsgroup-killed nil
1309 "List of ranges of articles that have been through the scoring process.")
1311 (defvar gnus-newsgroup-cached nil
1312 "Sorted list of articles that come from the article cache.")
1314 (defvar gnus-newsgroup-saved nil
1315 "List of articles that have been saved.")
1317 (defvar gnus-newsgroup-kill-headers nil)
1319 (defvar gnus-newsgroup-replied nil
1320 "List of articles that have been replied to in the current newsgroup.")
1322 (defvar gnus-newsgroup-forwarded nil
1323 "List of articles that have been forwarded in the current newsgroup.")
1325 (defvar gnus-newsgroup-recent nil
1326 "List of articles that have are recent in the current newsgroup.")
1328 (defvar gnus-newsgroup-expirable nil
1329 "Sorted list of articles in the current newsgroup that can be expired.")
1331 (defvar gnus-newsgroup-processable nil
1332 "List of articles in the current newsgroup that can be processed.")
1334 (defvar gnus-newsgroup-downloadable nil
1335 "Sorted list of articles in the current newsgroup that can be processed.")
1337 (defvar gnus-newsgroup-unfetched nil
1338 "Sorted list of articles in the current newsgroup whose headers have
1339 not been fetched into the agent.
1341 This list will always be a subset of gnus-newsgroup-undownloaded.")
1343 (defvar gnus-newsgroup-undownloaded nil
1344 "List of articles in the current newsgroup that haven't been downloaded.")
1346 (defvar gnus-newsgroup-unsendable nil
1347 "List of articles in the current newsgroup that won't be sent.")
1349 (defvar gnus-newsgroup-bookmarks nil
1350 "List of articles in the current newsgroup that have bookmarks.")
1352 (defvar gnus-newsgroup-dormant nil
1353 "Sorted list of dormant articles in the current newsgroup.")
1355 (defvar gnus-newsgroup-unseen nil
1356 "List of unseen articles in the current newsgroup.")
1358 (defvar gnus-newsgroup-seen nil
1359 "Range of seen articles in the current newsgroup.")
1361 (defvar gnus-newsgroup-articles nil
1362 "List of articles in the current newsgroup.")
1364 (defvar gnus-newsgroup-scored nil
1365 "List of scored articles in the current newsgroup.")
1367 (defvar gnus-newsgroup-headers nil
1368 "List of article headers in the current newsgroup.")
1370 (defvar gnus-newsgroup-threads nil)
1372 (defvar gnus-newsgroup-prepared nil
1373 "Whether the current group has been prepared properly.")
1375 (defvar gnus-newsgroup-ancient nil
1376 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1378 (defvar gnus-newsgroup-sparse nil)
1380 (defvar gnus-current-article nil)
1381 (defvar gnus-article-current nil)
1382 (defvar gnus-current-headers nil)
1383 (defvar gnus-have-all-headers nil)
1384 (defvar gnus-last-article nil)
1385 (defvar gnus-newsgroup-history nil)
1386 (defvar gnus-newsgroup-charset nil)
1387 (defvar gnus-newsgroup-ephemeral-charset nil)
1388 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1390 (defvar gnus-article-before-search nil)
1392 (defvar gnus-summary-local-variables
1393 '(gnus-newsgroup-name
1394 gnus-newsgroup-begin gnus-newsgroup-end
1395 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1396 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1397 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1398 gnus-newsgroup-unselected gnus-newsgroup-marked
1399 gnus-newsgroup-spam-marked
1400 gnus-newsgroup-reads gnus-newsgroup-saved
1401 gnus-newsgroup-replied gnus-newsgroup-forwarded
1402 gnus-newsgroup-recent
1403 gnus-newsgroup-expirable
1404 gnus-newsgroup-processable gnus-newsgroup-killed
1405 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1406 gnus-newsgroup-unfetched
1407 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1408 gnus-newsgroup-seen gnus-newsgroup-articles
1409 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1410 gnus-newsgroup-headers gnus-newsgroup-threads
1411 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1412 gnus-current-article gnus-current-headers gnus-have-all-headers
1413 gnus-last-article gnus-article-internal-prepare-hook
1414 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1415 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1416 gnus-thread-expunge-below
1417 gnus-score-alist gnus-current-score-file
1418 (gnus-summary-expunge-below . global)
1419 (gnus-summary-mark-below . global)
1420 (gnus-orphan-score . global)
1421 gnus-newsgroup-active gnus-scores-exclude-files
1422 gnus-newsgroup-history gnus-newsgroup-ancient
1423 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1424 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1425 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1426 (gnus-newsgroup-expunged-tally . 0)
1427 gnus-cache-removable-articles gnus-newsgroup-cached
1428 gnus-newsgroup-data gnus-newsgroup-data-reverse
1429 gnus-newsgroup-limit gnus-newsgroup-limits
1430 gnus-newsgroup-charset gnus-newsgroup-display
1431 gnus-summary-use-undownloaded-faces)
1432 "Variables that are buffer-local to the summary buffers.")
1434 (defvar gnus-newsgroup-variables nil
1435 "A list of variables that have separate values in different newsgroups.
1436 A list of newsgroup (summary buffer) local variables, or cons of
1437 variables and their default expressions to be evalled (when the default
1438 values are not nil), that should be made global while the summary buffer
1441 Note: The default expressions will be evaluated (using function `eval')
1442 before assignment to the local variable rather than just assigned to it.
1443 If the default expression is the symbol `global', that symbol will not
1444 be evaluated but the global value of the local variable will be used
1447 These variables can be used to set variables in the group parameters
1448 while still allowing them to affect operations done in other buffers.
1451 \(setq gnus-newsgroup-variables
1452 '(message-use-followup-to
1453 (gnus-visible-headers .
1454 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1457 ;; Byte-compiler warning.
1459 ;; Bind features so that require will believe that gnus-sum has
1460 ;; already been loaded (avoids infinite recursion)
1461 (let ((features (cons 'gnus-sum features)))
1462 ;; Several of the declarations in gnus-sum are needed to load the
1463 ;; following files. Right now, these definitions have been
1464 ;; compiled but not defined (evaluated). We could either do a
1465 ;; eval-and-compile about all of the declarations or evaluate the
1467 (if (boundp 'gnus-newsgroup-variables)
1469 (load "gnus-sum.el" t t t))
1471 (require 'gnus-agent)
1472 (require 'gnus-art)))
1476 (defvar gnus-decode-encoded-word-methods
1477 '(mail-decode-encoded-word-string)
1478 "List of methods used to decode encoded words.
1480 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1481 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1482 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1483 whose names match REGEXP.
1486 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1487 mail-decode-encoded-word-string
1488 (\"chinese\" . rfc1843-decode-string))")
1490 (defvar gnus-decode-encoded-word-methods-cache nil)
1492 (defun gnus-multi-decode-encoded-word-string (string)
1493 "Apply the functions from `gnus-encoded-word-methods' that match."
1494 (unless (and gnus-decode-encoded-word-methods-cache
1495 (eq gnus-newsgroup-name
1496 (car gnus-decode-encoded-word-methods-cache)))
1497 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1500 (nconc gnus-decode-encoded-word-methods-cache (list x))
1501 (if (and gnus-newsgroup-name
1502 (string-match (car x) gnus-newsgroup-name))
1503 (nconc gnus-decode-encoded-word-methods-cache
1505 gnus-decode-encoded-word-methods))
1506 (let ((xlist gnus-decode-encoded-word-methods-cache))
1509 (setq string (funcall (pop xlist) string))))
1512 ;; Subject simplification.
1514 (defun gnus-simplify-whitespace (str)
1515 "Remove excessive whitespace from STR."
1517 (while (string-match "[ \t][ \t]+" str)
1518 (setq str (concat (substring str 0 (match-beginning 0))
1520 (substring str (match-end 0)))))
1522 (when (string-match "^[ \t]+" str)
1523 (setq str (substring str (match-end 0))))
1525 (when (string-match "[ \t]+$" str)
1526 (setq str (substring str 0 (match-beginning 0))))
1529 (defun gnus-simplify-all-whitespace (str)
1530 "Remove all whitespace from STR."
1531 (while (string-match "[ \t\n]+" str)
1532 (setq str (replace-match "" nil nil str)))
1535 (defsubst gnus-simplify-subject-re (subject)
1536 "Remove \"Re:\" from subject lines."
1537 (if (string-match message-subject-re-regexp subject)
1538 (substring subject (match-end 0))
1541 (defun gnus-simplify-subject (subject &optional re-only)
1542 "Remove `Re:' and words in parentheses.
1543 If RE-ONLY is non-nil, strip leading `Re:'s only."
1544 (let ((case-fold-search t)) ;Ignore case.
1545 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1546 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1547 (setq subject (substring subject (match-end 0))))
1548 ;; Remove uninteresting prefixes.
1549 (when (and (not re-only)
1550 gnus-simplify-ignored-prefixes
1551 (string-match gnus-simplify-ignored-prefixes subject))
1552 (setq subject (substring subject (match-end 0))))
1553 ;; Remove words in parentheses from end.
1555 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1556 (setq subject (substring subject 0 (match-beginning 0)))))
1557 ;; Return subject string.
1560 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1562 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1563 (goto-char (point-min))
1564 (while (re-search-forward regexp nil t)
1565 (replace-match (or newtext ""))))
1567 (defun gnus-simplify-buffer-fuzzy ()
1568 "Simplify string in the buffer fuzzily.
1569 The string in the accessible portion of the current buffer is simplified.
1570 It is assumed to be a single-line subject.
1571 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1572 matter is removed. Additional things can be deleted by setting
1573 `gnus-simplify-subject-fuzzy-regexp'."
1574 (let ((case-fold-search t)
1576 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1578 (while (not (eq modified-tick (buffer-modified-tick)))
1579 (setq modified-tick (buffer-modified-tick))
1581 ((listp gnus-simplify-subject-fuzzy-regexp)
1582 (mapcar 'gnus-simplify-buffer-fuzzy-step
1583 gnus-simplify-subject-fuzzy-regexp))
1584 (gnus-simplify-subject-fuzzy-regexp
1585 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1586 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1587 (gnus-simplify-buffer-fuzzy-step
1588 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1589 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1591 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1592 (gnus-simplify-buffer-fuzzy-step " +" " ")
1593 (gnus-simplify-buffer-fuzzy-step " $")
1594 (gnus-simplify-buffer-fuzzy-step "^ +")))
1596 (defun gnus-simplify-subject-fuzzy (subject)
1597 "Simplify a subject string fuzzily.
1598 See `gnus-simplify-buffer-fuzzy' for details."
1600 (gnus-set-work-buffer)
1601 (let ((case-fold-search t))
1602 ;; Remove uninteresting prefixes.
1603 (when (and gnus-simplify-ignored-prefixes
1604 (string-match gnus-simplify-ignored-prefixes subject))
1605 (setq subject (substring subject (match-end 0))))
1607 (inline (gnus-simplify-buffer-fuzzy))
1610 (defsubst gnus-simplify-subject-fully (subject)
1611 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1613 (gnus-simplify-subject-functions
1614 (gnus-map-function gnus-simplify-subject-functions subject))
1615 ((null gnus-summary-gather-subject-limit)
1616 (gnus-simplify-subject-re subject))
1617 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1618 (gnus-simplify-subject-fuzzy subject))
1619 ((numberp gnus-summary-gather-subject-limit)
1620 (gnus-limit-string (gnus-simplify-subject-re subject)
1621 gnus-summary-gather-subject-limit))
1625 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1626 "Check whether two subjects are equal.
1627 If optional argument SIMPLE-FIRST is t, first argument is already
1630 ((null simple-first)
1631 (equal (gnus-simplify-subject-fully s1)
1632 (gnus-simplify-subject-fully s2)))
1635 (gnus-simplify-subject-fully s2)))))
1637 (defun gnus-summary-bubble-group ()
1638 "Increase the score of the current group.
1639 This is a handy function to add to `gnus-summary-exit-hook' to
1640 increase the score of each group you read."
1641 (gnus-group-add-score gnus-newsgroup-name))
1645 ;;; Gnus summary mode
1648 (put 'gnus-summary-mode 'mode-class 'special)
1650 (defvar gnus-article-commands-menu)
1652 ;; Non-orthogonal keys
1654 (gnus-define-keys gnus-summary-mode-map
1655 " " gnus-summary-next-page
1656 "\177" gnus-summary-prev-page
1657 [delete] gnus-summary-prev-page
1658 [backspace] gnus-summary-prev-page
1659 "\r" gnus-summary-scroll-up
1660 "\M-\r" gnus-summary-scroll-down
1661 "n" gnus-summary-next-unread-article
1662 "p" gnus-summary-prev-unread-article
1663 "N" gnus-summary-next-article
1664 "P" gnus-summary-prev-article
1665 "\M-\C-n" gnus-summary-next-same-subject
1666 "\M-\C-p" gnus-summary-prev-same-subject
1667 "\M-n" gnus-summary-next-unread-subject
1668 "\M-p" gnus-summary-prev-unread-subject
1669 "." gnus-summary-first-unread-article
1670 "," gnus-summary-best-unread-article
1671 "\M-s" gnus-summary-search-article-forward
1672 "\M-r" gnus-summary-search-article-backward
1673 "<" gnus-summary-beginning-of-article
1674 ">" gnus-summary-end-of-article
1675 "j" gnus-summary-goto-article
1676 "^" gnus-summary-refer-parent-article
1677 "\M-^" gnus-summary-refer-article
1678 "u" gnus-summary-tick-article-forward
1679 "!" gnus-summary-tick-article-forward
1680 "U" gnus-summary-tick-article-backward
1681 "d" gnus-summary-mark-as-read-forward
1682 "D" gnus-summary-mark-as-read-backward
1683 "E" gnus-summary-mark-as-expirable
1684 "\M-u" gnus-summary-clear-mark-forward
1685 "\M-U" gnus-summary-clear-mark-backward
1686 "k" gnus-summary-kill-same-subject-and-select
1687 "\C-k" gnus-summary-kill-same-subject
1688 "\M-\C-k" gnus-summary-kill-thread
1689 "\M-\C-l" gnus-summary-lower-thread
1690 "e" gnus-summary-edit-article
1691 "#" gnus-summary-mark-as-processable
1692 "\M-#" gnus-summary-unmark-as-processable
1693 "\M-\C-t" gnus-summary-toggle-threads
1694 "\M-\C-s" gnus-summary-show-thread
1695 "\M-\C-h" gnus-summary-hide-thread
1696 "\M-\C-f" gnus-summary-next-thread
1697 "\M-\C-b" gnus-summary-prev-thread
1698 [(meta down)] gnus-summary-next-thread
1699 [(meta up)] gnus-summary-prev-thread
1700 "\M-\C-u" gnus-summary-up-thread
1701 "\M-\C-d" gnus-summary-down-thread
1702 "&" gnus-summary-execute-command
1703 "c" gnus-summary-catchup-and-exit
1704 "\C-w" gnus-summary-mark-region-as-read
1705 "\C-t" gnus-summary-toggle-truncation
1706 "?" gnus-summary-mark-as-dormant
1707 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1708 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1709 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1710 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1711 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1712 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1713 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1714 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1715 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1716 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1717 "=" gnus-summary-expand-window
1718 "\C-x\C-s" gnus-summary-reselect-current-group
1719 "\M-g" gnus-summary-rescan-group
1720 "w" gnus-summary-stop-page-breaking
1721 "\C-c\C-r" gnus-summary-caesar-message
1722 "f" gnus-summary-followup
1723 "F" gnus-summary-followup-with-original
1724 "C" gnus-summary-cancel-article
1725 "r" gnus-summary-reply
1726 "R" gnus-summary-reply-with-original
1727 "\C-c\C-f" gnus-summary-mail-forward
1728 "o" gnus-summary-save-article
1729 "\C-o" gnus-summary-save-article-mail
1730 "|" gnus-summary-pipe-output
1731 "\M-k" gnus-summary-edit-local-kill
1732 "\M-K" gnus-summary-edit-global-kill
1734 "\C-c\C-d" gnus-summary-describe-group
1735 "q" gnus-summary-exit
1736 "Q" gnus-summary-exit-no-update
1737 "\C-c\C-i" gnus-info-find-node
1738 gnus-mouse-2 gnus-mouse-pick-article
1739 "m" gnus-summary-mail-other-window
1740 "a" gnus-summary-post-news
1741 "i" gnus-summary-news-other-window
1742 "x" gnus-summary-limit-to-unread
1743 "s" gnus-summary-isearch-article
1744 "t" gnus-summary-toggle-header
1745 "g" gnus-summary-show-article
1746 "l" gnus-summary-goto-last-article
1747 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1748 "\C-d" gnus-summary-enter-digest-group
1749 "\M-\C-d" gnus-summary-read-document
1750 "\M-\C-e" gnus-summary-edit-parameters
1751 "\M-\C-a" gnus-summary-customize-parameters
1753 "*" gnus-cache-enter-article
1754 "\M-*" gnus-cache-remove-article
1755 "\M-&" gnus-summary-universal-argument
1756 "\C-l" gnus-recenter
1757 "I" gnus-summary-increase-score
1758 "L" gnus-summary-lower-score
1759 "\M-i" gnus-symbolic-argument
1760 "h" gnus-summary-select-article-buffer
1762 "b" gnus-article-view-part
1763 "\M-t" gnus-summary-toggle-display-buttonized
1765 "V" gnus-summary-score-map
1766 "X" gnus-uu-extract-map
1767 "S" gnus-summary-send-map)
1769 ;; Sort of orthogonal keymap
1770 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1771 "t" gnus-summary-tick-article-forward
1772 "!" gnus-summary-tick-article-forward
1773 "d" gnus-summary-mark-as-read-forward
1774 "r" gnus-summary-mark-as-read-forward
1775 "c" gnus-summary-clear-mark-forward
1776 " " gnus-summary-clear-mark-forward
1777 "e" gnus-summary-mark-as-expirable
1778 "x" gnus-summary-mark-as-expirable
1779 "?" gnus-summary-mark-as-dormant
1780 "b" gnus-summary-set-bookmark
1781 "B" gnus-summary-remove-bookmark
1782 "#" gnus-summary-mark-as-processable
1783 "\M-#" gnus-summary-unmark-as-processable
1784 "S" gnus-summary-limit-include-expunged
1785 "C" gnus-summary-catchup
1786 "H" gnus-summary-catchup-to-here
1787 "h" gnus-summary-catchup-from-here
1788 "\C-c" gnus-summary-catchup-all
1789 "k" gnus-summary-kill-same-subject-and-select
1790 "K" gnus-summary-kill-same-subject
1791 "P" gnus-uu-mark-map)
1793 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1794 "c" gnus-summary-clear-above
1795 "u" gnus-summary-tick-above
1796 "m" gnus-summary-mark-above
1797 "k" gnus-summary-kill-below)
1799 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1800 "/" gnus-summary-limit-to-subject
1801 "n" gnus-summary-limit-to-articles
1802 "w" gnus-summary-pop-limit
1803 "s" gnus-summary-limit-to-subject
1804 "a" gnus-summary-limit-to-author
1805 "u" gnus-summary-limit-to-unread
1806 "m" gnus-summary-limit-to-marks
1807 "M" gnus-summary-limit-exclude-marks
1808 "v" gnus-summary-limit-to-score
1809 "*" gnus-summary-limit-include-cached
1810 "D" gnus-summary-limit-include-dormant
1811 "T" gnus-summary-limit-include-thread
1812 "d" gnus-summary-limit-exclude-dormant
1813 "t" gnus-summary-limit-to-age
1814 "." gnus-summary-limit-to-unseen
1815 "x" gnus-summary-limit-to-extra
1816 "p" gnus-summary-limit-to-display-predicate
1817 "E" gnus-summary-limit-include-expunged
1818 "c" gnus-summary-limit-exclude-childless-dormant
1819 "C" gnus-summary-limit-mark-excluded-as-read
1820 "o" gnus-summary-insert-old-articles
1821 "N" gnus-summary-insert-new-articles
1822 "r" gnus-summary-limit-to-replied)
1824 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1825 "n" gnus-summary-next-unread-article
1826 "p" gnus-summary-prev-unread-article
1827 "N" gnus-summary-next-article
1828 "P" gnus-summary-prev-article
1829 "\C-n" gnus-summary-next-same-subject
1830 "\C-p" gnus-summary-prev-same-subject
1831 "\M-n" gnus-summary-next-unread-subject
1832 "\M-p" gnus-summary-prev-unread-subject
1833 "f" gnus-summary-first-unread-article
1834 "b" gnus-summary-best-unread-article
1835 "j" gnus-summary-goto-article
1836 "g" gnus-summary-goto-subject
1837 "l" gnus-summary-goto-last-article
1838 "o" gnus-summary-pop-article)
1840 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1841 "k" gnus-summary-kill-thread
1842 "l" gnus-summary-lower-thread
1843 "i" gnus-summary-raise-thread
1844 "T" gnus-summary-toggle-threads
1845 "t" gnus-summary-rethread-current
1846 "^" gnus-summary-reparent-thread
1847 "s" gnus-summary-show-thread
1848 "S" gnus-summary-show-all-threads
1849 "h" gnus-summary-hide-thread
1850 "H" gnus-summary-hide-all-threads
1851 "n" gnus-summary-next-thread
1852 "p" gnus-summary-prev-thread
1853 "u" gnus-summary-up-thread
1854 "o" gnus-summary-top-thread
1855 "d" gnus-summary-down-thread
1856 "#" gnus-uu-mark-thread
1857 "\M-#" gnus-uu-unmark-thread)
1859 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1860 "g" gnus-summary-prepare
1861 "c" gnus-summary-insert-cached-articles
1862 "d" gnus-summary-insert-dormant-articles)
1864 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1865 "c" gnus-summary-catchup-and-exit
1866 "C" gnus-summary-catchup-all-and-exit
1867 "E" gnus-summary-exit-no-update
1868 "Q" gnus-summary-exit
1869 "Z" gnus-summary-exit
1870 "n" gnus-summary-catchup-and-goto-next-group
1871 "R" gnus-summary-reselect-current-group
1872 "G" gnus-summary-rescan-group
1873 "N" gnus-summary-next-group
1874 "s" gnus-summary-save-newsrc
1875 "P" gnus-summary-prev-group)
1877 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1878 " " gnus-summary-next-page
1879 "n" gnus-summary-next-page
1880 "\177" gnus-summary-prev-page
1881 [delete] gnus-summary-prev-page
1882 "p" gnus-summary-prev-page
1883 "\r" gnus-summary-scroll-up
1884 "\M-\r" gnus-summary-scroll-down
1885 "<" gnus-summary-beginning-of-article
1886 ">" gnus-summary-end-of-article
1887 "b" gnus-summary-beginning-of-article
1888 "e" gnus-summary-end-of-article
1889 "^" gnus-summary-refer-parent-article
1890 "r" gnus-summary-refer-parent-article
1891 "D" gnus-summary-enter-digest-group
1892 "R" gnus-summary-refer-references
1893 "T" gnus-summary-refer-thread
1894 "g" gnus-summary-show-article
1895 "s" gnus-summary-isearch-article
1896 "P" gnus-summary-print-article
1897 "M" gnus-mailing-list-insinuate
1898 "t" gnus-article-babel)
1900 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1901 "b" gnus-article-add-buttons
1902 "B" gnus-article-add-buttons-to-head
1903 "o" gnus-article-treat-overstrike
1904 "e" gnus-article-emphasize
1905 "w" gnus-article-fill-cited-article
1906 "Q" gnus-article-fill-long-lines
1907 "C" gnus-article-capitalize-sentences
1908 "c" gnus-article-remove-cr
1909 "q" gnus-article-de-quoted-unreadable
1910 "6" gnus-article-de-base64-unreadable
1911 "Z" gnus-article-decode-HZ
1912 "A" gnus-article-treat-ansi-sequences
1913 "h" gnus-article-wash-html
1914 "u" gnus-article-unsplit-urls
1915 "s" gnus-summary-force-verify-and-decrypt
1916 "f" gnus-article-display-x-face
1917 "l" gnus-summary-stop-page-breaking
1918 "r" gnus-summary-caesar-message
1919 "m" gnus-summary-morse-message
1920 "t" gnus-summary-toggle-header
1921 "g" gnus-treat-smiley
1922 "v" gnus-summary-verbose-headers
1923 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1924 "p" gnus-article-verify-x-pgp-sig
1925 "d" gnus-article-treat-dumbquotes)
1927 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1928 ;; mnemonic: deuglif*Y*
1929 "u" gnus-article-outlook-unwrap-lines
1930 "a" gnus-article-outlook-repair-attribution
1931 "c" gnus-article-outlook-rearrange-citation
1932 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1934 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1935 "a" gnus-article-hide
1936 "h" gnus-article-hide-headers
1937 "b" gnus-article-hide-boring-headers
1938 "s" gnus-article-hide-signature
1939 "c" gnus-article-hide-citation
1940 "C" gnus-article-hide-citation-in-followups
1941 "l" gnus-article-hide-list-identifiers
1942 "B" gnus-article-strip-banner
1943 "P" gnus-article-hide-pem
1944 "\C-c" gnus-article-hide-citation-maybe)
1946 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1947 "a" gnus-article-highlight
1948 "h" gnus-article-highlight-headers
1949 "c" gnus-article-highlight-citation
1950 "s" gnus-article-highlight-signature)
1952 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1953 "f" gnus-article-treat-fold-headers
1954 "u" gnus-article-treat-unfold-headers
1955 "n" gnus-article-treat-fold-newsgroups)
1957 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1958 "x" gnus-article-display-x-face
1959 "d" gnus-article-display-face
1960 "s" gnus-treat-smiley
1961 "D" gnus-article-remove-images
1962 "f" gnus-treat-from-picon
1963 "m" gnus-treat-mail-picon
1964 "n" gnus-treat-newsgroups-picon)
1966 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1967 "w" gnus-article-decode-mime-words
1968 "c" gnus-article-decode-charset
1969 "v" gnus-mime-view-all-parts
1970 "b" gnus-article-view-part)
1972 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1973 "z" gnus-article-date-ut
1974 "u" gnus-article-date-ut
1975 "l" gnus-article-date-local
1976 "p" gnus-article-date-english
1977 "e" gnus-article-date-lapsed
1978 "o" gnus-article-date-original
1979 "i" gnus-article-date-iso8601
1980 "s" gnus-article-date-user)
1982 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1983 "t" gnus-article-remove-trailing-blank-lines
1984 "l" gnus-article-strip-leading-blank-lines
1985 "m" gnus-article-strip-multiple-blank-lines
1986 "a" gnus-article-strip-blank-lines
1987 "A" gnus-article-strip-all-blank-lines
1988 "s" gnus-article-strip-leading-space
1989 "e" gnus-article-strip-trailing-space
1990 "w" gnus-article-remove-leading-whitespace)
1992 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1994 "f" gnus-summary-fetch-faq
1995 "d" gnus-summary-describe-group
1996 "h" gnus-summary-describe-briefly
1997 "i" gnus-info-find-node
1998 "c" gnus-group-fetch-charter
1999 "C" gnus-group-fetch-control)
2001 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2002 "e" gnus-summary-expire-articles
2003 "\M-\C-e" gnus-summary-expire-articles-now
2004 "\177" gnus-summary-delete-article
2005 [delete] gnus-summary-delete-article
2006 [backspace] gnus-summary-delete-article
2007 "m" gnus-summary-move-article
2008 "r" gnus-summary-respool-article
2009 "w" gnus-summary-edit-article
2010 "c" gnus-summary-copy-article
2011 "B" gnus-summary-crosspost-article
2012 "q" gnus-summary-respool-query
2013 "t" gnus-summary-respool-trace
2014 "i" gnus-summary-import-article
2015 "I" gnus-summary-create-article
2016 "p" gnus-summary-article-posted-p)
2018 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2019 "o" gnus-summary-save-article
2020 "m" gnus-summary-save-article-mail
2021 "F" gnus-summary-write-article-file
2022 "r" gnus-summary-save-article-rmail
2023 "f" gnus-summary-save-article-file
2024 "b" gnus-summary-save-article-body-file
2025 "h" gnus-summary-save-article-folder
2026 "v" gnus-summary-save-article-vm
2027 "p" gnus-summary-pipe-output
2028 "P" gnus-summary-muttprint
2029 "s" gnus-soup-add-article)
2031 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2032 "b" gnus-summary-display-buttonized
2033 "m" gnus-summary-repair-multipart
2034 "v" gnus-article-view-part
2035 "o" gnus-article-save-part
2036 "c" gnus-article-copy-part
2037 "C" gnus-article-view-part-as-charset
2038 "e" gnus-article-view-part-externally
2039 "E" gnus-article-encrypt-body
2040 "i" gnus-article-inline-part
2041 "|" gnus-article-pipe-part)
2043 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2044 "p" gnus-summary-mark-as-processable
2045 "u" gnus-summary-unmark-as-processable
2046 "U" gnus-summary-unmark-all-processable
2047 "v" gnus-uu-mark-over
2048 "s" gnus-uu-mark-series
2049 "r" gnus-uu-mark-region
2050 "g" gnus-uu-unmark-region
2051 "R" gnus-uu-mark-by-regexp
2052 "G" gnus-uu-unmark-by-regexp
2053 "t" gnus-uu-mark-thread
2054 "T" gnus-uu-unmark-thread
2055 "a" gnus-uu-mark-all
2056 "b" gnus-uu-mark-buffer
2057 "S" gnus-uu-mark-sparse
2058 "k" gnus-summary-kill-process-mark
2059 "y" gnus-summary-yank-process-mark
2060 "w" gnus-summary-save-process-mark
2061 "i" gnus-uu-invert-processable)
2063 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2064 ;;"x" gnus-uu-extract-any
2065 "m" gnus-summary-save-parts
2066 "u" gnus-uu-decode-uu
2067 "U" gnus-uu-decode-uu-and-save
2068 "s" gnus-uu-decode-unshar
2069 "S" gnus-uu-decode-unshar-and-save
2070 "o" gnus-uu-decode-save
2071 "O" gnus-uu-decode-save
2072 "b" gnus-uu-decode-binhex
2073 "B" gnus-uu-decode-binhex
2074 "p" gnus-uu-decode-postscript
2075 "P" gnus-uu-decode-postscript-and-save)
2078 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2079 "u" gnus-uu-decode-uu-view
2080 "U" gnus-uu-decode-uu-and-save-view
2081 "s" gnus-uu-decode-unshar-view
2082 "S" gnus-uu-decode-unshar-and-save-view
2083 "o" gnus-uu-decode-save-view
2084 "O" gnus-uu-decode-save-view
2085 "b" gnus-uu-decode-binhex-view
2086 "B" gnus-uu-decode-binhex-view
2087 "p" gnus-uu-decode-postscript-view
2088 "P" gnus-uu-decode-postscript-and-save-view)
2090 (defvar gnus-article-post-menu nil)
2092 (defconst gnus-summary-menu-maxlen 20)
2094 (defun gnus-summary-menu-split (menu)
2095 ;; If we have lots of elements, divide them into groups of 20
2096 ;; and make a pane (or submenu) for each one.
2097 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2098 (let ((menu menu) sublists next
2101 ;; Pull off the next gnus-summary-menu-maxlen elements
2102 ;; and make them the next element of sublist.
2103 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2105 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2107 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2108 (aref (car (last menu)) 0)) menu)
2112 (nreverse sublists))
2113 ;; Few elements--put them all in one pane.
2116 (defun gnus-summary-make-menu-bar ()
2117 (gnus-turn-off-edit-menu 'summary)
2119 (unless (boundp 'gnus-summary-misc-menu)
2122 gnus-summary-kill-menu gnus-summary-mode-map ""
2127 ["Customize" gnus-score-customize t])
2128 (gnus-make-score-map 'increase)
2129 (gnus-make-score-map 'lower)
2131 ["Kill below" gnus-summary-kill-below t]
2132 ["Mark above" gnus-summary-mark-above t]
2133 ["Tick above" gnus-summary-tick-above t]
2134 ["Clear above" gnus-summary-clear-above t])
2135 ["Current score" gnus-summary-current-score t]
2136 ["Set score" gnus-summary-set-score t]
2137 ["Switch current score file..." gnus-score-change-score-file t]
2138 ["Set mark below..." gnus-score-set-mark-below t]
2139 ["Set expunge below..." gnus-score-set-expunge-below t]
2140 ["Edit current score file" gnus-score-edit-current-scores t]
2141 ["Edit score file" gnus-score-edit-file t]
2142 ["Trace score" gnus-score-find-trace t]
2143 ["Find words" gnus-score-find-favourite-words t]
2144 ["Rescore buffer" gnus-summary-rescore t]
2145 ["Increase score..." gnus-summary-increase-score t]
2146 ["Lower score..." gnus-summary-lower-score t]))))
2148 ;; Define both the Article menu in the summary buffer and the
2149 ;; equivalent Commands menu in the article buffer here for
2153 ["All" gnus-article-hide t]
2154 ["Headers" gnus-article-hide-headers t]
2155 ["Signature" gnus-article-hide-signature t]
2156 ["Citation" gnus-article-hide-citation t]
2157 ["List identifiers" gnus-article-hide-list-identifiers t]
2158 ["Banner" gnus-article-strip-banner t]
2159 ["Boring headers" gnus-article-hide-boring-headers t])
2161 ["All" gnus-article-highlight t]
2162 ["Headers" gnus-article-highlight-headers t]
2163 ["Signature" gnus-article-highlight-signature t]
2164 ["Citation" gnus-article-highlight-citation t])
2166 ["Words" gnus-article-decode-mime-words t]
2167 ["Charset" gnus-article-decode-charset t]
2168 ["QP" gnus-article-de-quoted-unreadable t]
2169 ["Base64" gnus-article-de-base64-unreadable t]
2170 ["View MIME buttons" gnus-summary-display-buttonized t]
2171 ["View all" gnus-mime-view-all-parts t]
2172 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2173 ["Encrypt body" gnus-article-encrypt-body
2174 :active (not (gnus-group-read-only-p))
2175 ,@(if (featurep 'xemacs) nil
2176 '(:help "Encrypt the message body on disk"))]
2177 ["Extract all parts..." gnus-summary-save-parts t]
2179 ["Repair multipart" gnus-summary-repair-multipart t]
2180 ["Pipe part..." gnus-article-pipe-part t]
2181 ["Inline part" gnus-article-inline-part t]
2182 ["Encrypt body" gnus-article-encrypt-body
2183 :active (not (gnus-group-read-only-p))
2184 ,@(if (featurep 'xemacs) nil
2185 '(:help "Encrypt the message body on disk"))]
2186 ["View part externally" gnus-article-view-part-externally t]
2187 ["View part with charset..." gnus-article-view-part-as-charset t]
2188 ["Copy part" gnus-article-copy-part t]
2189 ["Save part..." gnus-article-save-part t]
2190 ["View part" gnus-article-view-part t]))
2192 ["Local" gnus-article-date-local t]
2193 ["ISO8601" gnus-article-date-iso8601 t]
2194 ["UT" gnus-article-date-ut t]
2195 ["Original" gnus-article-date-original t]
2196 ["Lapsed" gnus-article-date-lapsed t]
2197 ["User-defined" gnus-article-date-user t])
2199 ["Remove images" gnus-article-remove-images t]
2200 ["Toggle smiley" gnus-treat-smiley t]
2201 ["Show X-Face" gnus-article-display-x-face t]
2202 ["Show picons in From" gnus-treat-from-picon t]
2203 ["Show picons in mail headers" gnus-treat-mail-picon t]
2204 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2205 ("View as different encoding"
2206 ,@(gnus-summary-menu-split
2209 ;; Since easymenu under Emacs doesn't allow
2210 ;; lambda forms for menu commands, we should
2211 ;; provide intern'ed function symbols.
2212 (let ((command (intern (format "\
2213 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2217 (let ((gnus-summary-show-article-charset-alist
2219 (gnus-summary-show-article 1))))
2220 `[,(symbol-name cs) ,command t]))
2221 (sort (if (fboundp 'coding-system-list)
2222 (coding-system-list)
2223 (mapcar 'car mm-mime-mule-charset-alist))
2227 ["Leading" gnus-article-strip-leading-blank-lines t]
2228 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2229 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2230 ["All of the above" gnus-article-strip-blank-lines t]
2231 ["All" gnus-article-strip-all-blank-lines t]
2232 ["Leading space" gnus-article-strip-leading-space t]
2233 ["Trailing space" gnus-article-strip-trailing-space t]
2234 ["Leading space in headers"
2235 gnus-article-remove-leading-whitespace t])
2236 ["Overstrike" gnus-article-treat-overstrike t]
2237 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2238 ["Emphasis" gnus-article-emphasize t]
2239 ["Word wrap" gnus-article-fill-cited-article t]
2240 ["Fill long lines" gnus-article-fill-long-lines t]
2241 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2242 ["Remove CR" gnus-article-remove-cr t]
2243 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2244 ["Base64" gnus-article-de-base64-unreadable t]
2245 ["Rot 13" gnus-summary-caesar-message
2246 ,@(if (featurep 'xemacs) '(t)
2247 '(:help "\"Caesar rotate\" article by 13"))]
2248 ["Morse decode" gnus-summary-morse-message t]
2249 ["Unix pipe..." gnus-summary-pipe-message t]
2250 ["Add buttons" gnus-article-add-buttons t]
2251 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2252 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2253 ["Verbose header" gnus-summary-verbose-headers t]
2254 ["Toggle header" gnus-summary-toggle-header t]
2255 ["Unfold headers" gnus-article-treat-unfold-headers t]
2256 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2257 ["Html" gnus-article-wash-html t]
2258 ["Unsplit URLs" gnus-article-unsplit-urls t]
2259 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2260 ["Decode HZ" gnus-article-decode-HZ t]
2261 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2262 ("(Outlook) Deuglify"
2263 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2264 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2265 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2266 ["Full (Outlook) deuglify"
2267 gnus-article-outlook-deuglify-article t])
2270 ["Save in default format..." gnus-summary-save-article
2271 ,@(if (featurep 'xemacs) '(t)
2272 '(:help "Save article using default method"))]
2273 ["Save in file..." gnus-summary-save-article-file
2274 ,@(if (featurep 'xemacs) '(t)
2275 '(:help "Save article in file"))]
2276 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2277 ["Save in MH folder..." gnus-summary-save-article-folder t]
2278 ["Save in VM folder..." gnus-summary-save-article-vm t]
2279 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2280 ["Save body in file..." gnus-summary-save-article-body-file t]
2281 ["Pipe through a filter..." gnus-summary-pipe-output t]
2282 ["Add to SOUP packet" gnus-soup-add-article t]
2283 ["Print with Muttprint..." gnus-summary-muttprint t]
2284 ["Print" gnus-summary-print-article
2285 ,@(if (featurep 'xemacs) '(t)
2286 '(:help "Generate and print a PostScript image"))])
2287 ("Copy, move,... (Backend)"
2288 ,@(if (featurep 'xemacs) nil
2289 '(:help "Copying, moving, expiring articles..."))
2290 ["Respool article..." gnus-summary-respool-article t]
2291 ["Move article..." gnus-summary-move-article
2292 (gnus-check-backend-function
2293 'request-move-article gnus-newsgroup-name)]
2294 ["Copy article..." gnus-summary-copy-article t]
2295 ["Crosspost article..." gnus-summary-crosspost-article
2296 (gnus-check-backend-function
2297 'request-replace-article gnus-newsgroup-name)]
2298 ["Import file..." gnus-summary-import-article
2299 (gnus-check-backend-function
2300 'request-accept-article gnus-newsgroup-name)]
2301 ["Create article..." gnus-summary-create-article
2302 (gnus-check-backend-function
2303 'request-accept-article gnus-newsgroup-name)]
2304 ["Check if posted" gnus-summary-article-posted-p t]
2305 ["Edit article" gnus-summary-edit-article
2306 (not (gnus-group-read-only-p))]
2307 ["Delete article" gnus-summary-delete-article
2308 (gnus-check-backend-function
2309 'request-expire-articles gnus-newsgroup-name)]
2310 ["Query respool" gnus-summary-respool-query t]
2311 ["Trace respool" gnus-summary-respool-trace t]
2312 ["Delete expirable articles" gnus-summary-expire-articles-now
2313 (gnus-check-backend-function
2314 'request-expire-articles gnus-newsgroup-name)])
2316 ["Uudecode" gnus-uu-decode-uu
2317 ,@(if (featurep 'xemacs) '(t)
2318 '(:help "Decode uuencoded article(s)"))]
2319 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2320 ["Unshar" gnus-uu-decode-unshar t]
2321 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2322 ["Save" gnus-uu-decode-save t]
2323 ["Binhex" gnus-uu-decode-binhex t]
2324 ["Postscript" gnus-uu-decode-postscript t]
2325 ["All MIME parts" gnus-summary-save-parts t])
2327 ["Enter article" gnus-cache-enter-article t]
2328 ["Remove article" gnus-cache-remove-article t])
2329 ["Translate" gnus-article-babel t]
2330 ["Select article buffer" gnus-summary-select-article-buffer t]
2331 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2332 ["Isearch article..." gnus-summary-isearch-article t]
2333 ["Beginning of the article" gnus-summary-beginning-of-article t]
2334 ["End of the article" gnus-summary-end-of-article t]
2335 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2336 ["Fetch referenced articles" gnus-summary-refer-references t]
2337 ["Fetch current thread" gnus-summary-refer-thread t]
2338 ["Fetch article with id..." gnus-summary-refer-article t]
2339 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2340 ["Redisplay" gnus-summary-show-article t]
2341 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2343 gnus-summary-article-menu gnus-summary-mode-map ""
2344 (cons "Article" innards))
2346 (if (not (keymapp gnus-summary-article-menu))
2348 gnus-article-commands-menu gnus-article-mode-map ""
2349 (cons "Commands" innards))
2350 ;; in Emacs, don't share menu.
2351 (setq gnus-article-commands-menu
2352 (copy-keymap gnus-summary-article-menu))
2353 (define-key gnus-article-mode-map [menu-bar commands]
2354 (cons "Commands" gnus-article-commands-menu))))
2357 gnus-summary-thread-menu gnus-summary-mode-map ""
2359 ["Find all messages in thread" gnus-summary-refer-thread t]
2360 ["Toggle threading" gnus-summary-toggle-threads t]
2361 ["Hide threads" gnus-summary-hide-all-threads t]
2362 ["Show threads" gnus-summary-show-all-threads t]
2363 ["Hide thread" gnus-summary-hide-thread t]
2364 ["Show thread" gnus-summary-show-thread t]
2365 ["Go to next thread" gnus-summary-next-thread t]
2366 ["Go to previous thread" gnus-summary-prev-thread t]
2367 ["Go down thread" gnus-summary-down-thread t]
2368 ["Go up thread" gnus-summary-up-thread t]
2369 ["Top of thread" gnus-summary-top-thread t]
2370 ["Mark thread as read" gnus-summary-kill-thread t]
2371 ["Lower thread score" gnus-summary-lower-thread t]
2372 ["Raise thread score" gnus-summary-raise-thread t]
2373 ["Rethread current" gnus-summary-rethread-current t]))
2376 gnus-summary-post-menu gnus-summary-mode-map ""
2378 ["Send a message (mail or news)" gnus-summary-post-news
2379 ,@(if (featurep 'xemacs) '(t)
2380 '(:help "Compose a new message (mail or news)"))]
2381 ["Followup" gnus-summary-followup
2382 ,@(if (featurep 'xemacs) '(t)
2383 '(:help "Post followup to this article"))]
2384 ["Followup and yank" gnus-summary-followup-with-original
2385 ,@(if (featurep 'xemacs) '(t)
2386 '(:help "Post followup to this article, quoting its contents"))]
2387 ["Supersede article" gnus-summary-supersede-article t]
2388 ["Cancel article" gnus-summary-cancel-article
2389 ,@(if (featurep 'xemacs) '(t)
2390 '(:help "Cancel an article you posted"))]
2391 ["Reply" gnus-summary-reply t]
2392 ["Reply and yank" gnus-summary-reply-with-original t]
2393 ["Wide reply" gnus-summary-wide-reply t]
2394 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2395 ,@(if (featurep 'xemacs) '(t)
2396 '(:help "Mail a reply, quoting this article"))]
2397 ["Very wide reply" gnus-summary-very-wide-reply t]
2398 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2399 ,@(if (featurep 'xemacs) '(t)
2400 '(:help "Mail a very wide reply, quoting this article"))]
2401 ["Mail forward" gnus-summary-mail-forward t]
2402 ["Post forward" gnus-summary-post-forward t]
2403 ["Digest and mail" gnus-uu-digest-mail-forward t]
2404 ["Digest and post" gnus-uu-digest-post-forward t]
2405 ["Resend message" gnus-summary-resend-message t]
2406 ["Resend message edit" gnus-summary-resend-message-edit t]
2407 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2408 ["Send a mail" gnus-summary-mail-other-window t]
2409 ["Create a local message" gnus-summary-news-other-window t]
2410 ["Uuencode and post" gnus-uu-post-news
2411 ,@(if (featurep 'xemacs) '(t)
2412 '(:help "Post a uuencoded article"))]
2413 ["Followup via news" gnus-summary-followup-to-mail t]
2414 ["Followup via news and yank"
2415 gnus-summary-followup-to-mail-with-original t]
2417 ;;["Send" gnus-summary-send-draft t]
2418 ;;["Send bounced" gnus-resend-bounced-mail t])
2422 ((not (keymapp gnus-summary-post-menu))
2423 (setq gnus-article-post-menu gnus-summary-post-menu))
2424 ((not gnus-article-post-menu)
2425 ;; Don't share post menu.
2426 (setq gnus-article-post-menu
2427 (copy-keymap gnus-summary-post-menu))))
2428 (define-key gnus-article-mode-map [menu-bar post]
2429 (cons "Post" gnus-article-post-menu))
2432 gnus-summary-misc-menu gnus-summary-mode-map ""
2435 ["Mark as read" gnus-summary-mark-as-read-forward t]
2436 ["Mark same subject and select"
2437 gnus-summary-kill-same-subject-and-select t]
2438 ["Mark same subject" gnus-summary-kill-same-subject t]
2439 ["Catchup" gnus-summary-catchup
2440 ,@(if (featurep 'xemacs) '(t)
2441 '(:help "Mark unread articles in this group as read"))]
2442 ["Catchup all" gnus-summary-catchup-all t]
2443 ["Catchup to here" gnus-summary-catchup-to-here t]
2444 ["Catchup from here" gnus-summary-catchup-from-here t]
2445 ["Catchup region" gnus-summary-mark-region-as-read
2446 (gnus-mark-active-p)]
2447 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2449 ["Tick" gnus-summary-tick-article-forward t]
2450 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2451 ["Remove marks" gnus-summary-clear-mark-forward t]
2452 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2453 ["Set bookmark" gnus-summary-set-bookmark t]
2454 ["Remove bookmark" gnus-summary-remove-bookmark t])
2456 ["Marks..." gnus-summary-limit-to-marks t]
2457 ["Subject..." gnus-summary-limit-to-subject t]
2458 ["Author..." gnus-summary-limit-to-author t]
2459 ["Age..." gnus-summary-limit-to-age t]
2460 ["Extra..." gnus-summary-limit-to-extra t]
2461 ["Score..." gnus-summary-limit-to-score t]
2462 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2463 ["Unread" gnus-summary-limit-to-unread t]
2464 ["Unseen" gnus-summary-limit-to-unseen t]
2465 ["Replied" gnus-summary-limit-to-replied t]
2466 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2467 ["Next articles" gnus-summary-limit-to-articles t]
2468 ["Pop limit" gnus-summary-pop-limit t]
2469 ["Show dormant" gnus-summary-limit-include-dormant t]
2470 ["Hide childless dormant"
2471 gnus-summary-limit-exclude-childless-dormant t]
2472 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2473 ["Hide marked" gnus-summary-limit-exclude-marks t]
2474 ["Show expunged" gnus-summary-limit-include-expunged t])
2476 ["Set mark" gnus-summary-mark-as-processable t]
2477 ["Remove mark" gnus-summary-unmark-as-processable t]
2478 ["Remove all marks" gnus-summary-unmark-all-processable t]
2479 ["Invert marks" gnus-uu-invert-processable t]
2480 ["Mark above" gnus-uu-mark-over t]
2481 ["Mark series" gnus-uu-mark-series t]
2482 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2483 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2484 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2485 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2486 ["Mark all" gnus-uu-mark-all t]
2487 ["Mark buffer" gnus-uu-mark-buffer t]
2488 ["Mark sparse" gnus-uu-mark-sparse t]
2489 ["Mark thread" gnus-uu-mark-thread t]
2490 ["Unmark thread" gnus-uu-unmark-thread t]
2491 ("Process Mark Sets"
2492 ["Kill" gnus-summary-kill-process-mark t]
2493 ["Yank" gnus-summary-yank-process-mark
2494 gnus-newsgroup-process-stack]
2495 ["Save" gnus-summary-save-process-mark t]
2496 ["Run command on marked..." gnus-summary-universal-argument t]))
2498 ["Page forward" gnus-summary-next-page
2499 ,@(if (featurep 'xemacs) '(t)
2500 '(:help "Show next page of article"))]
2501 ["Page backward" gnus-summary-prev-page
2502 ,@(if (featurep 'xemacs) '(t)
2503 '(:help "Show previous page of article"))]
2504 ["Line forward" gnus-summary-scroll-up t])
2506 ["Next unread article" gnus-summary-next-unread-article t]
2507 ["Previous unread article" gnus-summary-prev-unread-article t]
2508 ["Next article" gnus-summary-next-article t]
2509 ["Previous article" gnus-summary-prev-article t]
2510 ["Next unread subject" gnus-summary-next-unread-subject t]
2511 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2512 ["Next article same subject" gnus-summary-next-same-subject t]
2513 ["Previous article same subject" gnus-summary-prev-same-subject t]
2514 ["First unread article" gnus-summary-first-unread-article t]
2515 ["Best unread article" gnus-summary-best-unread-article t]
2516 ["Go to subject number..." gnus-summary-goto-subject t]
2517 ["Go to article number..." gnus-summary-goto-article t]
2518 ["Go to the last article" gnus-summary-goto-last-article t]
2519 ["Pop article off history" gnus-summary-pop-article t])
2521 ["Sort by number" gnus-summary-sort-by-number t]
2522 ["Sort by author" gnus-summary-sort-by-author t]
2523 ["Sort by subject" gnus-summary-sort-by-subject t]
2524 ["Sort by date" gnus-summary-sort-by-date t]
2525 ["Sort by score" gnus-summary-sort-by-score t]
2526 ["Sort by lines" gnus-summary-sort-by-lines t]
2527 ["Sort by characters" gnus-summary-sort-by-chars t]
2528 ["Randomize" gnus-summary-sort-by-random t]
2529 ["Original sort" gnus-summary-sort-by-original t])
2531 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2532 ["Describe group" gnus-summary-describe-group t]
2533 ["Fetch charter" gnus-group-fetch-charter
2534 ,@(if (featurep 'xemacs) nil
2535 '(:help "Display the charter of the current group"))]
2536 ["Fetch control message" gnus-group-fetch-control
2537 ,@(if (featurep 'xemacs) nil
2538 '(:help "Display the archived control message for the current group"))]
2539 ["Read manual" gnus-info-find-node t])
2541 ["Pick and read" gnus-pick-mode t]
2542 ["Binary" gnus-binary-mode t])
2544 ["Regenerate" gnus-summary-prepare t]
2545 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2546 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2547 ["Toggle threading" gnus-summary-toggle-threads t])
2548 ["See old articles" gnus-summary-insert-old-articles t]
2549 ["See new articles" gnus-summary-insert-new-articles t]
2550 ["Filter articles..." gnus-summary-execute-command t]
2551 ["Run command on articles..." gnus-summary-universal-argument t]
2552 ["Search articles forward..." gnus-summary-search-article-forward t]
2553 ["Search articles backward..." gnus-summary-search-article-backward t]
2554 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2555 ["Expand window" gnus-summary-expand-window t]
2556 ["Expire expirable articles" gnus-summary-expire-articles
2557 (gnus-check-backend-function
2558 'request-expire-articles gnus-newsgroup-name)]
2559 ["Edit local kill file" gnus-summary-edit-local-kill t]
2560 ["Edit main kill file" gnus-summary-edit-global-kill t]
2561 ["Edit group parameters" gnus-summary-edit-parameters t]
2562 ["Customize group parameters" gnus-summary-customize-parameters t]
2563 ["Send a bug report" gnus-bug t]
2565 ["Catchup and exit" gnus-summary-catchup-and-exit
2566 ,@(if (featurep 'xemacs) '(t)
2567 '(:help "Mark unread articles in this group as read, then exit"))]
2568 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2569 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2570 ["Exit group" gnus-summary-exit
2571 ,@(if (featurep 'xemacs) '(t)
2572 '(:help "Exit current group, return to group selection mode"))]
2573 ["Exit group without updating" gnus-summary-exit-no-update t]
2574 ["Exit and goto next group" gnus-summary-next-group t]
2575 ["Exit and goto prev group" gnus-summary-prev-group t]
2576 ["Reselect group" gnus-summary-reselect-current-group t]
2577 ["Rescan group" gnus-summary-rescan-group t]
2578 ["Update dribble" gnus-summary-save-newsrc t])))
2580 (gnus-run-hooks 'gnus-summary-menu-hook)))
2582 (defvar gnus-summary-tool-bar-map nil)
2584 ;; Emacs 21 tool bar. Should be no-op otherwise.
2585 (defun gnus-summary-make-tool-bar ()
2586 (if (and (fboundp 'tool-bar-add-item-from-menu)
2587 (default-value 'tool-bar-mode)
2588 (not gnus-summary-tool-bar-map))
2589 (setq gnus-summary-tool-bar-map
2590 (let ((tool-bar-map (make-sparse-keymap))
2591 (load-path (mm-image-load-path)))
2592 (tool-bar-add-item-from-menu
2593 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2594 (tool-bar-add-item-from-menu
2595 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2596 (tool-bar-add-item-from-menu
2597 'gnus-summary-post-news "post" gnus-summary-mode-map)
2598 (tool-bar-add-item-from-menu
2599 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2600 (tool-bar-add-item-from-menu
2601 'gnus-summary-followup "followup" gnus-summary-mode-map)
2602 (tool-bar-add-item-from-menu
2603 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2604 (tool-bar-add-item-from-menu
2605 'gnus-summary-reply "reply" gnus-summary-mode-map)
2606 (tool-bar-add-item-from-menu
2607 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2608 (tool-bar-add-item-from-menu
2609 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2610 (tool-bar-add-item-from-menu
2611 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2612 (tool-bar-add-item-from-menu
2613 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2614 (tool-bar-add-item-from-menu
2615 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2616 (tool-bar-add-item-from-menu
2617 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2618 (tool-bar-add-item-from-menu
2619 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2620 (tool-bar-add-item-from-menu
2621 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2622 (tool-bar-add-item-from-menu
2623 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2625 (if gnus-summary-tool-bar-map
2626 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2628 (defun gnus-score-set-default (var value)
2629 "A version of set that updates the GNU Emacs menu-bar."
2631 ;; It is the message that forces the active status to be updated.
2634 (defun gnus-make-score-map (type)
2635 "Make a summary score map of type TYPE."
2638 (let ((headers '(("author" "from" string)
2639 ("subject" "subject" string)
2640 ("article body" "body" string)
2641 ("article head" "head" string)
2642 ("xref" "xref" string)
2643 ("extra header" "extra" string)
2644 ("lines" "lines" number)
2645 ("followups to author" "followup" string)))
2646 (types '((number ("less than" <)
2649 (string ("substring" s)
2653 (perms '(("temporary" (current-time-string))
2661 (if (eq type 'lower)
2666 (setq header (car headers))
2672 (let ((ts (cdr (assoc (nth 2 header) types)))
2688 'gnus-summary-score-entry
2690 (if (or (string= (nth 1 header)
2692 (string= (nth 1 header)
2695 (list 'gnus-summary-header
2697 (list 'quote (nth 1 (car ts)))
2698 (list 'gnus-score-delta-default
2705 (list (nreverse outp))))
2708 (list (nreverse outt))))
2710 (setq headers (cdr headers)))
2711 (list (nreverse outh))))))))
2715 (defun gnus-summary-mode (&optional group)
2716 "Major mode for reading articles.
2718 All normal editing commands are switched off.
2719 \\<gnus-summary-mode-map>
2720 Each line in this buffer represents one article. To read an
2721 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2722 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2725 You can also post articles and send mail from this buffer. To
2726 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2727 of an article, type `\\[gnus-summary-reply]'.
2729 There are approx. one gazillion commands you can execute in this
2730 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2732 The following commands are available:
2734 \\{gnus-summary-mode-map}"
2736 (kill-all-local-variables)
2737 (when (gnus-visual-p 'summary-menu 'menu)
2738 (gnus-summary-make-menu-bar)
2739 (gnus-summary-make-tool-bar))
2740 (gnus-summary-make-local-variables)
2741 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2742 (gnus-summary-make-local-variables))
2743 (gnus-make-thread-indent-array)
2744 (gnus-simplify-mode-line)
2745 (setq major-mode 'gnus-summary-mode)
2746 (setq mode-name "Summary")
2747 (make-local-variable 'minor-mode-alist)
2748 (use-local-map gnus-summary-mode-map)
2749 (buffer-disable-undo)
2750 (setq buffer-read-only t ;Disable modification
2751 show-trailing-whitespace nil)
2752 (setq truncate-lines t)
2753 (setq selective-display t)
2754 (setq selective-display-ellipses t) ;Display `...'
2755 (gnus-summary-set-display-table)
2756 (gnus-set-default-directory)
2757 (setq gnus-newsgroup-name group)
2758 (make-local-variable 'gnus-summary-line-format)
2759 (make-local-variable 'gnus-summary-line-format-spec)
2760 (make-local-variable 'gnus-summary-dummy-line-format)
2761 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2762 (make-local-variable 'gnus-summary-mark-positions)
2763 (gnus-make-local-hook 'pre-command-hook)
2764 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2765 (gnus-run-hooks 'gnus-summary-mode-hook)
2766 (turn-on-gnus-mailing-list-mode)
2767 (mm-enable-multibyte)
2768 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2769 (gnus-update-summary-mark-positions))
2771 (defun gnus-summary-make-local-variables ()
2772 "Make all the local summary buffer variables."
2774 (dolist (local gnus-summary-local-variables)
2777 (if (eq (cdr local) 'global)
2778 ;; Copy the global value of the variable.
2779 (setq global (symbol-value (car local)))
2780 ;; Use the value from the list.
2781 (setq global (eval (cdr local))))
2782 (set (make-local-variable (car local)) global))
2783 ;; Simple nil-valued local variable.
2784 (set (make-local-variable local) nil)))))
2786 (defun gnus-summary-clear-local-variables ()
2787 (let ((locals gnus-summary-local-variables))
2789 (if (consp (car locals))
2790 (and (vectorp (caar locals))
2791 (set (caar locals) nil))
2792 (and (vectorp (car locals))
2793 (set (car locals) nil)))
2794 (setq locals (cdr locals)))))
2796 ;; Summary data functions.
2798 (defmacro gnus-data-number (data)
2801 (defmacro gnus-data-set-number (data number)
2802 `(setcar ,data ,number))
2804 (defmacro gnus-data-mark (data)
2807 (defmacro gnus-data-set-mark (data mark)
2808 `(setcar (nthcdr 1 ,data) ,mark))
2810 (defmacro gnus-data-pos (data)
2813 (defmacro gnus-data-set-pos (data pos)
2814 `(setcar (nthcdr 2 ,data) ,pos))
2816 (defmacro gnus-data-header (data)
2819 (defmacro gnus-data-set-header (data header)
2820 `(setf (nth 3 ,data) ,header))
2822 (defmacro gnus-data-level (data)
2825 (defmacro gnus-data-unread-p (data)
2826 `(= (nth 1 ,data) gnus-unread-mark))
2828 (defmacro gnus-data-read-p (data)
2829 `(/= (nth 1 ,data) gnus-unread-mark))
2831 (defmacro gnus-data-pseudo-p (data)
2832 `(consp (nth 3 ,data)))
2834 (defmacro gnus-data-find (number)
2835 `(assq ,number gnus-newsgroup-data))
2837 (defmacro gnus-data-find-list (number &optional data)
2838 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2839 (memq (assq ,number bdata)
2842 (defmacro gnus-data-make (number mark pos header level)
2843 `(list ,number ,mark ,pos ,header ,level))
2845 (defun gnus-data-enter (after-article number mark pos header level offset)
2846 (let ((data (gnus-data-find-list after-article)))
2848 (error "No such article: %d" after-article))
2849 (setcdr data (cons (gnus-data-make number mark pos header level)
2851 (setq gnus-newsgroup-data-reverse nil)
2852 (gnus-data-update-list (cddr data) offset)))
2854 (defun gnus-data-enter-list (after-article list &optional offset)
2856 (let ((data (and after-article (gnus-data-find-list after-article)))
2860 (let ((odata gnus-newsgroup-data))
2861 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2863 (gnus-data-update-list odata offset)))
2864 ;; Find the last element in the list to be spliced into the main
2867 (setq list (cdr list)))
2870 (setcdr list gnus-newsgroup-data)
2871 (setq gnus-newsgroup-data ilist)
2873 (gnus-data-update-list (cdr list) offset)))
2874 (setcdr list (cdr data))
2877 (gnus-data-update-list (cdr list) offset))))
2878 (setq gnus-newsgroup-data-reverse nil))))
2880 (defun gnus-data-remove (article &optional offset)
2881 (let ((data gnus-newsgroup-data))
2882 (if (= (gnus-data-number (car data)) article)
2884 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2885 gnus-newsgroup-data-reverse nil)
2887 (gnus-data-update-list gnus-newsgroup-data offset)))
2889 (when (= (gnus-data-number (cadr data)) article)
2890 (setcdr data (cddr data))
2892 (gnus-data-update-list (cdr data) offset))
2894 gnus-newsgroup-data-reverse nil))
2895 (setq data (cdr data))))))
2897 (defmacro gnus-data-list (backward)
2899 (or gnus-newsgroup-data-reverse
2900 (setq gnus-newsgroup-data-reverse
2901 (reverse gnus-newsgroup-data)))
2902 gnus-newsgroup-data))
2904 (defun gnus-data-update-list (data offset)
2905 "Add OFFSET to the POS of all data entries in DATA."
2906 (setq gnus-newsgroup-data-reverse nil)
2908 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2909 (setq data (cdr data))))
2911 (defun gnus-summary-article-pseudo-p (article)
2912 "Say whether this article is a pseudo article or not."
2913 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2915 (defmacro gnus-summary-article-sparse-p (article)
2916 "Say whether this article is a sparse article or not."
2917 `(memq ,article gnus-newsgroup-sparse))
2919 (defmacro gnus-summary-article-ancient-p (article)
2920 "Say whether this article is a sparse article or not."
2921 `(memq ,article gnus-newsgroup-ancient))
2923 (defun gnus-article-parent-p (number)
2924 "Say whether this article is a parent or not."
2925 (let ((data (gnus-data-find-list number)))
2926 (and (cdr data) ; There has to be an article after...
2927 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2928 (gnus-data-level (nth 1 data))))))
2930 (defun gnus-article-children (number)
2931 "Return a list of all children to NUMBER."
2932 (let* ((data (gnus-data-find-list number))
2933 (level (gnus-data-level (car data)))
2935 (setq data (cdr data))
2937 (= (gnus-data-level (car data)) (1+ level)))
2938 (push (gnus-data-number (car data)) children)
2939 (setq data (cdr data)))
2942 (defmacro gnus-summary-skip-intangible ()
2943 "If the current article is intangible, then jump to a different article."
2944 '(let ((to (get-text-property (point) 'gnus-intangible)))
2945 (and to (gnus-summary-goto-subject to))))
2947 (defmacro gnus-summary-article-intangible-p ()
2948 "Say whether this article is intangible or not."
2949 '(get-text-property (point) 'gnus-intangible))
2951 (defun gnus-article-read-p (article)
2952 "Say whether ARTICLE is read or not."
2953 (not (or (memq article gnus-newsgroup-marked)
2954 (memq article gnus-newsgroup-spam-marked)
2955 (memq article gnus-newsgroup-unreads)
2956 (memq article gnus-newsgroup-unselected)
2957 (memq article gnus-newsgroup-dormant))))
2959 ;; Some summary mode macros.
2961 (defmacro gnus-summary-article-number ()
2962 "The article number of the article on the current line.
2963 If there isn't an article number here, then we return the current
2966 (gnus-summary-skip-intangible)
2967 (or (get-text-property (point) 'gnus-number)
2968 (gnus-summary-last-subject))))
2970 (defmacro gnus-summary-article-header (&optional number)
2971 "Return the header of article NUMBER."
2972 `(gnus-data-header (gnus-data-find
2973 ,(or number '(gnus-summary-article-number)))))
2975 (defmacro gnus-summary-thread-level (&optional number)
2976 "Return the level of thread that starts with article NUMBER."
2977 `(if (and (eq gnus-summary-make-false-root 'dummy)
2978 (get-text-property (point) 'gnus-intangible))
2980 (gnus-data-level (gnus-data-find
2981 ,(or number '(gnus-summary-article-number))))))
2983 (defmacro gnus-summary-article-mark (&optional number)
2984 "Return the mark of article NUMBER."
2985 `(gnus-data-mark (gnus-data-find
2986 ,(or number '(gnus-summary-article-number)))))
2988 (defmacro gnus-summary-article-pos (&optional number)
2989 "Return the position of the line of article NUMBER."
2990 `(gnus-data-pos (gnus-data-find
2991 ,(or number '(gnus-summary-article-number)))))
2993 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2994 (defmacro gnus-summary-article-subject (&optional number)
2995 "Return current subject string or nil if nothing."
2998 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2999 '(gnus-data-header (assq (gnus-summary-article-number)
3000 gnus-newsgroup-data)))))
3003 (mail-header-subject headers))))
3005 (defmacro gnus-summary-article-score (&optional number)
3006 "Return current article score."
3007 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3008 gnus-newsgroup-scored))
3009 gnus-summary-default-score 0))
3011 (defun gnus-summary-article-children (&optional number)
3012 "Return a list of article numbers that are children of article NUMBER."
3013 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3014 (level (gnus-data-level (car data)))
3016 (while (and (setq data (cdr data))
3017 (> (setq l (gnus-data-level (car data))) level))
3018 (and (= (1+ level) l)
3019 (push (gnus-data-number (car data))
3021 (nreverse children)))
3023 (defun gnus-summary-article-parent (&optional number)
3024 "Return the article number of the parent of article NUMBER."
3025 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3026 (gnus-data-list t)))
3027 (level (gnus-data-level (car data))))
3029 () ; This is a root.
3030 ;; We search until we find an article with a level less than
3031 ;; this one. That function has to be the parent.
3032 (while (and (setq data (cdr data))
3033 (not (< (gnus-data-level (car data)) level))))
3034 (and data (gnus-data-number (car data))))))
3036 (defun gnus-unread-mark-p (mark)
3037 "Say whether MARK is the unread mark."
3038 (= mark gnus-unread-mark))
3040 (defun gnus-read-mark-p (mark)
3041 "Say whether MARK is one of the marks that mark as read.
3042 This is all marks except unread, ticked, dormant, and expirable."
3043 (not (or (= mark gnus-unread-mark)
3044 (= mark gnus-ticked-mark)
3045 (= mark gnus-spam-mark)
3046 (= mark gnus-dormant-mark)
3047 (= mark gnus-expirable-mark))))
3049 (defmacro gnus-article-mark (number)
3050 "Return the MARK of article NUMBER.
3051 This macro should only be used when computing the mark the \"first\"
3052 time; i.e., when generating the summary lines. After that,
3053 `gnus-summary-article-mark' should be used to examine the
3056 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3057 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3058 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3059 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3060 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3061 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3062 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3063 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3064 gnus-ancient-mark))))
3066 ;; Saving hidden threads.
3068 (defmacro gnus-save-hidden-threads (&rest forms)
3069 "Save hidden threads, eval FORMS, and restore the hidden threads."
3070 (let ((config (make-symbol "config")))
3071 `(let ((,config (gnus-hidden-threads-configuration)))
3075 (gnus-restore-hidden-threads-configuration ,config)))))
3076 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3077 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3079 (defun gnus-data-compute-positions ()
3080 "Compute the positions of all articles."
3081 (setq gnus-newsgroup-data-reverse nil)
3082 (let ((data gnus-newsgroup-data))
3084 (gnus-save-hidden-threads
3085 (gnus-summary-show-all-threads)
3086 (goto-char (point-min))
3088 (while (get-text-property (point) 'gnus-intangible)
3090 (gnus-data-set-pos (car data) (+ (point) 3))
3091 (setq data (cdr data))
3092 (forward-line 1))))))
3094 (defun gnus-hidden-threads-configuration ()
3095 "Return the current hidden threads configuration."
3098 (goto-char (point-min))
3099 (while (search-forward "\r" nil t)
3100 (push (1- (point)) config))
3103 (defun gnus-restore-hidden-threads-configuration (config)
3104 "Restore hidden threads configuration from CONFIG."
3106 (let (point buffer-read-only)
3107 (while (setq point (pop config))
3108 (when (and (< point (point-max))
3110 (eq (char-after) ?\n))
3111 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3113 ;; Various summary mode internalish functions.
3115 (defun gnus-mouse-pick-article (e)
3118 (gnus-summary-next-page nil t))
3120 (defun gnus-summary-set-display-table ()
3121 "Change the display table.
3122 Odd characters have a tendency to mess
3123 up nicely formatted displays - we make all possible glyphs
3124 display only a single character."
3126 ;; We start from the standard display table, if any.
3127 (let ((table (or (copy-sequence standard-display-table)
3128 (make-display-table)))
3130 ;; Nix out all the control chars...
3131 (while (>= (setq i (1- i)) 0)
3132 (aset table i [??]))
3133 ;; ... but not newline and cr, of course. (cr is necessary for the
3134 ;; selective display).
3135 (aset table ?\n nil)
3136 (aset table ?\r nil)
3137 ;; We keep TAB as well.
3138 (aset table ?\t nil)
3139 ;; We nix out any glyphs over 126 that are not set already.
3141 (while (>= (setq i (1- i)) 127)
3142 ;; Only modify if the entry is nil.
3143 (unless (aref table i)
3144 (aset table i [??]))))
3145 (setq buffer-display-table table)))
3147 (defun gnus-summary-set-article-display-arrow (pos)
3148 "Update the overlay arrow to point to line at position POS."
3149 (when (and gnus-summary-display-arrow
3150 (boundp 'overlay-arrow-position)
3151 (boundp 'overlay-arrow-string))
3155 (unless overlay-arrow-position
3156 (setq overlay-arrow-position (make-marker)))
3157 (setq overlay-arrow-string "=>"
3158 overlay-arrow-position (set-marker overlay-arrow-position
3160 (current-buffer))))))
3162 (defun gnus-summary-setup-buffer (group)
3163 "Initialize summary buffer."
3164 (let ((buffer (gnus-summary-buffer-name group))
3165 (dead-name (concat "*Dead Summary "
3166 (gnus-group-decoded-name group) "*")))
3167 ;; If a dead summary buffer exists, we kill it.
3168 (when (gnus-buffer-live-p dead-name)
3169 (gnus-kill-buffer dead-name))
3170 (if (get-buffer buffer)
3173 (setq gnus-summary-buffer (current-buffer))
3174 (not gnus-newsgroup-prepared))
3175 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3176 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3177 (gnus-summary-mode group)
3179 (gnus-carpal-setup-buffer 'summary))
3180 (unless gnus-single-article-buffer
3181 (make-local-variable 'gnus-article-buffer)
3182 (make-local-variable 'gnus-article-current)
3183 (make-local-variable 'gnus-original-article-buffer))
3184 (setq gnus-newsgroup-name group)
3185 ;; Set any local variables in the group parameters.
3186 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3189 (defun gnus-set-global-variables ()
3190 "Set the global equivalents of the buffer-local variables.
3191 They are set to the latest values they had. These reflect the summary
3192 buffer that was in action when the last article was fetched."
3193 (when (eq major-mode 'gnus-summary-mode)
3194 (setq gnus-summary-buffer (current-buffer))
3195 (let ((name gnus-newsgroup-name)
3196 (marked gnus-newsgroup-marked)
3197 (spam gnus-newsgroup-spam-marked)
3198 (unread gnus-newsgroup-unreads)
3199 (headers gnus-current-headers)
3200 (data gnus-newsgroup-data)
3201 (summary gnus-summary-buffer)
3202 (article-buffer gnus-article-buffer)
3203 (original gnus-original-article-buffer)
3204 (gac gnus-article-current)
3205 (reffed gnus-reffed-article-number)
3206 (score-file gnus-current-score-file)
3207 (default-charset gnus-newsgroup-charset)
3209 (let ((locals gnus-newsgroup-variables))
3211 (if (consp (car locals))
3212 (push (eval (caar locals)) vlist)
3213 (push (eval (car locals)) vlist))
3214 (setq locals (cdr locals)))
3215 (setq vlist (nreverse vlist)))
3216 (with-current-buffer gnus-group-buffer
3217 (setq gnus-newsgroup-name name
3218 gnus-newsgroup-marked marked
3219 gnus-newsgroup-spam-marked spam
3220 gnus-newsgroup-unreads unread
3221 gnus-current-headers headers
3222 gnus-newsgroup-data data
3223 gnus-article-current gac
3224 gnus-summary-buffer summary
3225 gnus-article-buffer article-buffer
3226 gnus-original-article-buffer original
3227 gnus-reffed-article-number reffed
3228 gnus-current-score-file score-file
3229 gnus-newsgroup-charset default-charset)
3230 (let ((locals gnus-newsgroup-variables))
3232 (if (consp (car locals))
3233 (set (caar locals) (pop vlist))
3234 (set (car locals) (pop vlist)))
3235 (setq locals (cdr locals))))
3236 ;; The article buffer also has local variables.
3237 (when (gnus-buffer-live-p gnus-article-buffer)
3238 (set-buffer gnus-article-buffer)
3239 (setq gnus-summary-buffer summary))))))
3241 (defun gnus-summary-article-unread-p (article)
3242 "Say whether ARTICLE is unread or not."
3243 (memq article gnus-newsgroup-unreads))
3245 (defun gnus-summary-first-article-p (&optional article)
3246 "Return whether ARTICLE is the first article in the buffer."
3247 (if (not (setq article (or article (gnus-summary-article-number))))
3249 (eq article (caar gnus-newsgroup-data))))
3251 (defun gnus-summary-last-article-p (&optional article)
3252 "Return whether ARTICLE is the last article in the buffer."
3253 (if (not (setq article (or article (gnus-summary-article-number))))
3254 ;; All non-existent numbers are the last article. :-)
3256 (not (cdr (gnus-data-find-list article)))))
3258 (defun gnus-make-thread-indent-array ()
3260 (unless (and gnus-thread-indent-array
3261 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3262 (setq gnus-thread-indent-array (make-vector 201 "")
3263 gnus-thread-indent-array-level gnus-thread-indent-level)
3265 (aset gnus-thread-indent-array n
3266 (make-string (* n gnus-thread-indent-level) ? ))
3269 (defun gnus-update-summary-mark-positions ()
3270 "Compute where the summary marks are to go."
3272 (when (gnus-buffer-exists-p gnus-summary-buffer)
3273 (set-buffer gnus-summary-buffer))
3274 (let ((gnus-replied-mark 129)
3275 (gnus-score-below-mark 130)
3276 (gnus-score-over-mark 130)
3277 (gnus-undownloaded-mark 131)
3278 (spec gnus-summary-line-format-spec)
3281 (gnus-set-work-buffer)
3282 (let ((gnus-summary-line-format-spec spec)
3283 (gnus-newsgroup-downloadable '(0)))
3284 (gnus-summary-insert-line
3285 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3286 0 nil t 128 t nil "" nil 1)
3287 (goto-char (point-min))
3288 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3289 (- (point) (point-min) 1)))))
3290 (goto-char (point-min))
3291 (push (cons 'replied (and (search-forward "\201" nil t)
3292 (- (point) (point-min) 1)))
3294 (goto-char (point-min))
3295 (push (cons 'score (and (search-forward "\202" nil t)
3296 (- (point) (point-min) 1)))
3298 (goto-char (point-min))
3299 (push (cons 'download
3300 (and (search-forward "\203" nil t)
3301 (- (point) (point-min) 1)))
3303 (setq gnus-summary-mark-positions pos))))
3305 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3306 "Insert a dummy root in the summary buffer."
3308 (gnus-add-text-properties
3309 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3310 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3312 (defun gnus-summary-extract-address-component (from)
3313 (or (car (funcall gnus-extract-address-components from))
3316 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3317 (let ((mail-parse-charset gnus-newsgroup-charset)
3318 ; Is it really necessary to do this next part for each summary line?
3319 ; Luckily, doesn't seem to slow things down much.
3320 (mail-parse-ignored-charsets
3321 (with-current-buffer gnus-summary-buffer
3322 gnus-newsgroup-ignored-charsets)))
3324 (and gnus-ignored-from-addresses
3325 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3326 (let ((extra-headers (mail-header-extra header))
3330 ((setq to (cdr (assq 'To extra-headers)))
3333 (gnus-summary-extract-address-component
3334 (funcall gnus-decode-encoded-word-function to)))))
3335 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3336 (concat "=> " newsgroups)))))
3337 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3339 (defun gnus-summary-insert-line (gnus-tmp-header
3340 gnus-tmp-level gnus-tmp-current
3341 undownloaded gnus-tmp-unread gnus-tmp-replied
3342 gnus-tmp-expirable gnus-tmp-subject-or-nil
3343 &optional gnus-tmp-dummy gnus-tmp-score
3345 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3346 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3347 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3348 (gnus-tmp-score-char
3349 (if (or (null gnus-summary-default-score)
3350 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3351 gnus-summary-zcore-fuzz))
3353 (if (< gnus-tmp-score gnus-summary-default-score)
3354 gnus-score-below-mark gnus-score-over-mark)))
3355 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3357 (cond (gnus-tmp-process gnus-process-mark)
3358 ((memq gnus-tmp-current gnus-newsgroup-cached)
3360 (gnus-tmp-replied gnus-replied-mark)
3361 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3362 gnus-forwarded-mark)
3363 ((memq gnus-tmp-current gnus-newsgroup-saved)
3365 ((memq gnus-tmp-number gnus-newsgroup-recent)
3367 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3370 (gnus-tmp-downloaded
3372 gnus-undownloaded-mark)
3373 (gnus-newsgroup-agentized
3374 gnus-downloaded-mark)
3377 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3380 ((string-match "<[^>]+> *$" gnus-tmp-from)
3381 (let ((beg (match-beginning 0)))
3382 (or (and (string-match "^\".+\"" gnus-tmp-from)
3383 (substring gnus-tmp-from 1 (1- (match-end 0))))
3384 (substring gnus-tmp-from 0 beg))))
3385 ((string-match "(.+)" gnus-tmp-from)
3386 (substring gnus-tmp-from
3387 (1+ (match-beginning 0)) (1- (match-end 0))))
3389 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3390 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3391 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3392 (buffer-read-only nil))
3393 (when (string= gnus-tmp-name "")
3394 (setq gnus-tmp-name gnus-tmp-from))
3395 (unless (numberp gnus-tmp-lines)
3396 (setq gnus-tmp-lines -1))
3397 (if (= gnus-tmp-lines -1)
3398 (setq gnus-tmp-lines "?")
3399 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3400 (gnus-put-text-property
3402 (progn (eval gnus-summary-line-format-spec) (point))
3403 'gnus-number gnus-tmp-number)
3404 (when (gnus-visual-p 'summary-highlight 'highlight)
3406 (gnus-run-hooks 'gnus-summary-update-hook)
3409 (defun gnus-summary-update-line (&optional dont-update)
3410 "Update summary line after change."
3411 (when (and gnus-summary-default-score
3412 (not gnus-summary-inhibit-highlight))
3413 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3414 (article (gnus-summary-article-number))
3415 (score (gnus-summary-article-score article)))
3417 (if (and gnus-summary-mark-below
3418 (< (gnus-summary-article-score)
3419 gnus-summary-mark-below))
3420 ;; This article has a low score, so we mark it as read.
3421 (when (memq article gnus-newsgroup-unreads)
3422 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3423 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3424 ;; This article was previously marked as read on account
3425 ;; of a low score, but now it has risen, so we mark it as
3427 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3428 (gnus-summary-update-mark
3429 (if (or (null gnus-summary-default-score)
3430 (<= (abs (- score gnus-summary-default-score))
3431 gnus-summary-zcore-fuzz))
3433 (if (< score gnus-summary-default-score)
3434 gnus-score-below-mark gnus-score-over-mark))
3436 ;; Do visual highlighting.
3437 (when (gnus-visual-p 'summary-highlight 'highlight)
3438 (gnus-run-hooks 'gnus-summary-update-hook)))))
3440 (defvar gnus-tmp-new-adopts nil)
3442 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3443 "Return the number of articles in THREAD.
3444 This may be 0 in some cases -- if none of the articles in
3445 the thread are to be displayed."
3447 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3449 ((not (listp thread))
3451 ((and (consp thread) (cdr thread))
3454 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3457 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3460 (when (and level (zerop level) gnus-tmp-new-adopts)
3463 'gnus-summary-number-of-articles-in-thread
3464 gnus-tmp-new-adopts))))
3466 (if (> number 1) gnus-not-empty-thread-mark
3467 gnus-empty-thread-mark)
3470 (defsubst gnus-summary-line-message-size (head)
3471 "Return pretty-printed version of message size.
3472 This function is intended to be used in
3473 `gnus-summary-line-format-alist'."
3474 (let ((c (or (mail-header-chars head) -1)))
3475 (cond ((< c 0) "n/a") ; chars not available
3476 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3477 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3478 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3479 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3482 (defun gnus-summary-set-local-parameters (group)
3483 "Go through the local params of GROUP and set all variable specs in that list."
3484 (let ((params (gnus-group-find-parameter group))
3485 (vars '(quit-config)) ; Ignore quit-config.
3488 (setq elem (car params)
3489 params (cdr params))
3490 (and (consp elem) ; Has to be a cons.
3491 (consp (cdr elem)) ; The cdr has to be a list.
3492 (symbolp (car elem)) ; Has to be a symbol in there.
3493 (not (memq (car elem) vars))
3494 (ignore-errors ; So we set it.
3495 (push (car elem) vars)
3496 (make-local-variable (car elem))
3497 (set (car elem) (eval (nth 1 elem))))))))
3499 (defun gnus-summary-read-group (group &optional show-all no-article
3500 kill-buffer no-display backward
3502 "Start reading news in newsgroup GROUP.
3503 If SHOW-ALL is non-nil, already read articles are also listed.
3504 If NO-ARTICLE is non-nil, no article is selected initially.
3505 If NO-DISPLAY, don't generate a summary buffer."
3509 (let ((gnus-auto-select-next nil))
3510 (or (gnus-summary-read-group-1
3511 group show-all no-article
3512 kill-buffer no-display
3515 select-articles nil)))))
3516 (eq gnus-auto-select-next 'quietly))
3517 (set-buffer gnus-group-buffer)
3518 ;; The entry function called above goes to the next
3519 ;; group automatically, so we go two groups back
3520 ;; if we are searching for the previous group.
3522 (gnus-group-prev-unread-group 2))
3523 (if (not (equal group (gnus-group-group-name)))
3524 (setq group (gnus-group-group-name))
3528 (defun gnus-summary-read-group-1 (group show-all no-article
3529 kill-buffer no-display
3530 &optional select-articles)
3531 ;; Killed foreign groups can't be entered.
3532 ;; (when (and (not (gnus-group-native-p group))
3533 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3534 ;; (error "Dead non-native groups can't be entered"))
3535 (gnus-message 5 "Retrieving newsgroup: %s..."
3536 (gnus-group-decoded-name group))
3537 (let* ((new-group (gnus-summary-setup-buffer group))
3538 (quit-config (gnus-group-quit-config group))
3539 (did-select (and new-group (gnus-select-newsgroup
3540 group show-all select-articles))))
3542 ;; This summary buffer exists already, so we just select it.
3544 (gnus-set-global-variables)
3546 (gnus-kill-or-deaden-summary kill-buffer))
3547 (gnus-configure-windows 'summary 'force)
3548 (gnus-set-mode-line 'summary)
3549 (gnus-summary-position-point)
3552 ;; We couldn't select this group.
3554 (when (and (eq major-mode 'gnus-summary-mode)
3555 (not (equal (current-buffer) kill-buffer)))
3556 (kill-buffer (current-buffer))
3557 (if (not quit-config)
3559 ;; Update the info -- marks might need to be removed,
3561 (gnus-summary-update-info)
3562 (set-buffer gnus-group-buffer)
3563 (gnus-group-jump-to-group group)
3564 (gnus-group-next-unread-group 1))
3565 (gnus-handle-ephemeral-exit quit-config)))
3566 (let ((grpinfo (gnus-get-info group)))
3567 (if (null (gnus-info-read grpinfo))
3568 (gnus-message 3 "Group %s contains no messages"
3569 (gnus-group-decoded-name group))
3570 (gnus-message 3 "Can't select group")))
3572 ;; The user did a `C-g' while prompting for number of articles,
3573 ;; so we exit this group.
3574 ((eq did-select 'quit)
3575 (and (eq major-mode 'gnus-summary-mode)
3576 (not (equal (current-buffer) kill-buffer))
3577 (kill-buffer (current-buffer)))
3579 (gnus-kill-or-deaden-summary kill-buffer))
3580 (if (not quit-config)
3582 (set-buffer gnus-group-buffer)
3583 (gnus-group-jump-to-group group)
3584 (gnus-group-next-unread-group 1)
3585 (gnus-configure-windows 'group 'force))
3586 (gnus-handle-ephemeral-exit quit-config))
3587 ;; Finally signal the quit.
3589 ;; The group was successfully selected.
3591 (gnus-set-global-variables)
3592 ;; Save the active value in effect when the group was entered.
3593 (setq gnus-newsgroup-active
3595 (gnus-active gnus-newsgroup-name)))
3596 ;; You can change the summary buffer in some way with this hook.
3597 (gnus-run-hooks 'gnus-select-group-hook)
3598 (gnus-update-format-specifications
3599 nil 'summary 'summary-mode 'summary-dummy)
3600 (gnus-update-summary-mark-positions)
3601 ;; Do score processing.
3602 (when gnus-use-scoring
3603 (gnus-possibly-score-headers))
3604 ;; Check whether to fill in the gaps in the threads.
3605 (when gnus-build-sparse-threads
3606 (gnus-build-sparse-threads))
3607 ;; Find the initial limit.
3609 (let ((gnus-newsgroup-dormant nil))
3610 (gnus-summary-initial-limit show-all))
3611 (gnus-summary-initial-limit show-all))
3612 ;; Generate the summary buffer.
3614 (gnus-summary-prepare))
3615 (when gnus-use-trees
3616 (gnus-tree-open group)
3617 (setq gnus-summary-highlight-line-function
3618 'gnus-tree-highlight-article))
3619 ;; If the summary buffer is empty, but there are some low-scored
3620 ;; articles or some excluded dormants, we include these in the
3622 (when (and (zerop (buffer-size))
3624 (cond (gnus-newsgroup-dormant
3625 (gnus-summary-limit-include-dormant))
3626 ((and gnus-newsgroup-scored show-all)
3627 (gnus-summary-limit-include-expunged t))))
3628 ;; Function `gnus-apply-kill-file' must be called in this hook.
3629 (gnus-run-hooks 'gnus-apply-kill-hook)
3630 (if (and (zerop (buffer-size))
3633 ;; This newsgroup is empty.
3634 (gnus-summary-catchup-and-exit nil t)
3635 (gnus-message 6 "No unread news")
3637 (gnus-kill-or-deaden-summary kill-buffer))
3638 ;; Return nil from this function.
3640 ;; Hide conversation thread subtrees. We cannot do this in
3641 ;; gnus-summary-prepare-hook since kill processing may not
3642 ;; work with hidden articles.
3643 (gnus-summary-maybe-hide-threads)
3645 (gnus-kill-or-deaden-summary kill-buffer))
3646 (gnus-summary-auto-select-subject)
3647 ;; Show first unread article if requested.
3648 (if (and (not no-article)
3650 gnus-newsgroup-unreads
3651 gnus-auto-select-first)
3653 (gnus-configure-windows 'summary)
3654 (let ((art (gnus-summary-article-number)))
3655 (unless (and (not gnus-plugged)
3656 (or (memq art gnus-newsgroup-undownloaded)
3657 (memq art gnus-newsgroup-downloadable)))
3658 (gnus-summary-goto-article art))))
3659 ;; Don't select any articles.
3660 (gnus-summary-position-point)
3661 (gnus-configure-windows 'summary 'force)
3662 (gnus-set-mode-line 'summary))
3663 (when (and gnus-auto-center-group
3664 (get-buffer-window gnus-group-buffer t))
3665 ;; Gotta use windows, because recenter does weird stuff if
3666 ;; the current buffer ain't the displayed window.
3667 (let ((owin (selected-window)))
3668 (select-window (get-buffer-window gnus-group-buffer t))
3669 (when (gnus-group-goto-group group)
3671 (select-window owin)))
3672 ;; Mark this buffer as "prepared".
3673 (setq gnus-newsgroup-prepared t)
3674 (gnus-run-hooks 'gnus-summary-prepared-hook)
3675 (unless (gnus-ephemeral-group-p group)
3676 (gnus-group-update-group group))
3679 (defun gnus-summary-auto-select-subject ()
3680 "Select the subject line on initial group entry."
3681 (goto-char (point-min))
3683 ((eq gnus-auto-select-subject 'best)
3684 (gnus-summary-best-unread-subject))
3685 ((eq gnus-auto-select-subject 'unread)
3686 (gnus-summary-first-unread-subject))
3687 ((eq gnus-auto-select-subject 'unseen)
3688 (gnus-summary-first-unseen-subject))
3689 ((eq gnus-auto-select-subject 'unseen-or-unread)
3690 (gnus-summary-first-unseen-or-unread-subject))
3691 ((eq gnus-auto-select-subject 'first)
3694 ((functionp gnus-auto-select-subject)
3695 (funcall gnus-auto-select-subject))))
3697 (defun gnus-summary-prepare ()
3698 "Generate the summary buffer."
3700 (let ((buffer-read-only nil))
3702 (setq gnus-newsgroup-data nil
3703 gnus-newsgroup-data-reverse nil)
3704 (gnus-run-hooks 'gnus-summary-generate-hook)
3705 ;; Generate the buffer, either with threads or without.
3706 (when gnus-newsgroup-headers
3707 (gnus-summary-prepare-threads
3708 (if gnus-show-threads
3709 (gnus-sort-gathered-threads
3710 (funcall gnus-summary-thread-gathering-function
3712 (gnus-cut-threads (gnus-make-threads)))))
3713 ;; Unthreaded display.
3714 (gnus-sort-articles gnus-newsgroup-headers))))
3715 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3716 ;; Call hooks for modifying summary buffer.
3717 (goto-char (point-min))
3718 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3720 (defsubst gnus-general-simplify-subject (subject)
3721 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3724 ;; Truncate the subject.
3725 (gnus-simplify-subject-functions
3726 (gnus-map-function gnus-simplify-subject-functions subject))
3727 ((numberp gnus-summary-gather-subject-limit)
3728 (setq subject (gnus-simplify-subject-re subject))
3729 (if (> (length subject) gnus-summary-gather-subject-limit)
3730 (substring subject 0 gnus-summary-gather-subject-limit)
3732 ;; Fuzzily simplify it.
3733 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3734 (gnus-simplify-subject-fuzzy subject))
3735 ;; Just remove the leading "Re:".
3737 (gnus-simplify-subject-re subject))))
3739 (if (and gnus-summary-gather-exclude-subject
3740 (string-match gnus-summary-gather-exclude-subject subject))
3741 nil ; This article shouldn't be gathered
3744 (defun gnus-summary-simplify-subject-query ()
3745 "Query where the respool algorithm would put this article."
3747 (gnus-summary-select-article)
3748 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3750 (defun gnus-gather-threads-by-subject (threads)
3751 "Gather threads by looking at Subject headers."
3752 (if (not gnus-summary-make-false-root)
3754 (let ((hashtb (gnus-make-hashtable 1024))
3757 subject hthread whole-subject)
3759 (setq subject (gnus-general-simplify-subject
3760 (setq whole-subject (mail-header-subject
3763 (if (setq hthread (gnus-gethash subject hashtb))
3765 ;; We enter a dummy root into the thread, if we
3766 ;; haven't done that already.
3767 (unless (stringp (caar hthread))
3768 (setcar hthread (list whole-subject (car hthread))))
3769 ;; We add this new gathered thread to this gathered
3771 (setcdr (car hthread)
3772 (nconc (cdar hthread) (list (car threads))))
3773 ;; Remove it from the list of threads.
3774 (setcdr prev (cdr threads))
3775 (setq threads prev))
3776 ;; Enter this thread into the hash table.
3777 (gnus-sethash subject
3778 (if gnus-summary-make-false-root-always
3780 ;; If you want a dummy root above all
3782 (setcar threads (list whole-subject
3788 (setq threads (cdr threads)))
3791 (defun gnus-gather-threads-by-references (threads)
3792 "Gather threads by looking at References headers."
3793 (let ((idhashtb (gnus-make-hashtable 1024))
3794 (thhashtb (gnus-make-hashtable 1024))
3797 ids references id gthread gid entered ref)
3799 (when (setq references (mail-header-references (caar threads)))
3800 (setq id (mail-header-id (caar threads))
3801 ids (inline (gnus-split-references references))
3803 (while (setq ref (pop ids))
3804 (setq ids (delete ref ids))
3805 (if (not (setq gid (gnus-gethash ref idhashtb)))
3807 (gnus-sethash ref id idhashtb)
3808 (gnus-sethash id threads thhashtb))
3809 (setq gthread (gnus-gethash gid thhashtb))
3811 ;; We enter a dummy root into the thread, if we
3812 ;; haven't done that already.
3813 (unless (stringp (caar gthread))
3814 (setcar gthread (list (mail-header-subject (caar gthread))
3816 ;; We add this new gathered thread to this gathered
3818 (setcdr (car gthread)
3819 (nconc (cdar gthread) (list (car threads)))))
3820 ;; Add it into the thread hash table.
3821 (gnus-sethash id gthread thhashtb)
3823 ;; Remove it from the list of threads.
3824 (setcdr prev (cdr threads))
3825 (setq threads prev))))
3827 (setq threads (cdr threads)))
3830 (defun gnus-sort-gathered-threads (threads)
3831 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3832 (let ((result threads))
3834 (when (stringp (caar threads))
3835 (setcdr (car threads)
3836 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3837 (setq threads (cdr threads)))
3840 (defun gnus-thread-loop-p (root thread)
3841 "Say whether ROOT is in THREAD."
3842 (let ((stack (list thread))
3845 (while (setq thread (pop stack))
3846 (setq th (cdr thread))
3848 (not (eq (caar th) root)))
3851 ;; We have found a loop.
3853 (setcdr thread (delq (car th) (cdr thread)))
3854 (if (boundp (setq ref-dep (intern "none"
3855 gnus-newsgroup-dependencies)))
3856 (setcdr (symbol-value ref-dep)
3857 (nconc (cdr (symbol-value ref-dep))
3859 (set ref-dep (list nil (car th))))
3862 ;; Push all the subthreads onto the stack.
3863 (push (cdr thread) stack)))
3866 (defun gnus-make-threads ()
3867 "Go through the dependency hashtb and find the roots. Return all threads."
3869 (while (catch 'infloop
3872 ;; Deal with self-referencing References loops.
3873 (when (and (car (symbol-value refs))
3880 (car (symbol-value refs)) thread))
3881 (cdr (symbol-value refs)))))))
3884 (unless (car (symbol-value refs))
3885 ;; These threads do not refer back to any other
3886 ;; articles, so they're roots.
3887 (setq threads (append (cdr (symbol-value refs)) threads))))
3888 gnus-newsgroup-dependencies)))
3891 ;; Build the thread tree.
3892 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3893 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3895 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3896 if it was already present.
3898 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3899 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3900 Message-IDs will be renamed to a unique Message-ID before being
3903 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3904 (let* ((id (mail-header-id header))
3905 (id-dep (and id (intern id dependencies)))
3906 parent-id ref ref-dep ref-header replaced)
3907 ;; Enter this `header' in the `dependencies' table.
3911 ;; The first two cases do the normal part: enter a new `header'
3912 ;; in the `dependencies' table.
3913 ((not (boundp id-dep))
3914 (set id-dep (list header)))
3915 ((null (car (symbol-value id-dep)))
3916 (setcar (symbol-value id-dep) header))
3918 ;; From here the `header' was already present in the
3919 ;; `dependencies' table.
3921 ;; Overrides an existing entry;
3922 ;; just set the header part of the entry.
3923 (setcar (symbol-value id-dep) header)
3926 ;; Renames the existing `header' to a unique Message-ID.
3927 ((not gnus-summary-ignore-duplicates)
3928 ;; An article with this Message-ID has already been seen.
3929 ;; We rename the Message-ID.
3930 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3932 (mail-header-set-id header id))
3934 ;; The last case ignores an existing entry, except it adds any
3935 ;; additional Xrefs (in case the two articles came from different
3937 ;; Also sets `header' to `nil' meaning that the `dependencies'
3938 ;; table was *not* modified.
3940 (mail-header-set-xref
3941 (car (symbol-value id-dep))
3942 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3944 (or (mail-header-xref header) "")))
3947 (when (and header (not replaced))
3948 ;; First check that we are not creating a References loop.
3949 (setq parent-id (gnus-parent-id (mail-header-references header)))
3950 (setq ref parent-id)
3952 (setq ref-dep (intern-soft ref dependencies))
3954 (setq ref-header (car (symbol-value ref-dep))))
3955 (if (string= id ref)
3956 ;; Yuk! This is a reference loop. Make the article be a
3959 (mail-header-set-references (car (symbol-value id-dep)) "none")
3961 (setq parent-id nil))
3962 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3963 (setq ref-dep (intern (or parent-id "none") dependencies))
3964 (if (boundp ref-dep)
3965 (setcdr (symbol-value ref-dep)
3966 (nconc (cdr (symbol-value ref-dep))
3967 (list (symbol-value id-dep))))
3968 (set ref-dep (list nil (symbol-value id-dep)))))
3971 (defun gnus-extract-message-id-from-in-reply-to (string)
3972 (if (string-match "<[^>]+>" string)
3973 (substring string (match-beginning 0) (match-end 0))
3976 (defun gnus-build-sparse-threads ()
3977 (let ((headers gnus-newsgroup-headers)
3978 (mail-parse-charset gnus-newsgroup-charset)
3979 (gnus-summary-ignore-duplicates t)
3980 header references generation relations
3981 subject child end new-child date)
3982 ;; First we create an alist of generations/relations, where
3983 ;; generations is how much we trust the relation, and the relation
3985 (gnus-message 7 "Making sparse threads...")
3987 (nnheader-set-temp-buffer " *gnus sparse threads*")
3988 (while (setq header (pop headers))
3989 (when (and (setq references (mail-header-references header))
3990 (not (string= references "")))
3992 (setq child (mail-header-id header)
3993 subject (mail-header-subject header)
3994 date (mail-header-date header)
3996 (while (search-backward ">" nil t)
3997 (setq end (1+ (point)))
3998 (when (search-backward "<" nil t)
3999 (setq new-child (buffer-substring (point) end))
4000 (push (list (incf generation)
4001 child (setq child new-child)
4005 (push (list (1+ generation) child nil subject) relations))
4007 (kill-buffer (current-buffer)))
4008 ;; Sort over trustworthiness.
4011 (when (gnus-dependencies-add-header
4012 (make-full-mail-header
4013 gnus-reffed-article-number
4014 (nth 3 relation) "" (or (nth 4 relation) "")
4016 (or (nth 2 relation) "") 0 0 "")
4017 gnus-newsgroup-dependencies nil)
4018 (push gnus-reffed-article-number gnus-newsgroup-limit)
4019 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4020 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4021 gnus-newsgroup-reads)
4022 (decf gnus-reffed-article-number)))
4023 (sort relations 'car-less-than-car))
4024 (gnus-message 7 "Making sparse threads...done")))
4026 (defun gnus-build-old-threads ()
4027 ;; Look at all the articles that refer back to old articles, and
4028 ;; fetch the headers for the articles that aren't there. This will
4029 ;; build complete threads - if the roots haven't been expired by the
4031 (let ((mail-parse-charset gnus-newsgroup-charset)
4035 (when (not (car (symbol-value refs)))
4036 (setq heads (cdr (symbol-value refs)))
4038 (if (memq (mail-header-number (caar heads))
4039 gnus-newsgroup-dormant)
4040 (setq heads (cdr heads))
4041 (setq id (symbol-name refs))
4042 (while (and (setq id (gnus-build-get-header id))
4043 (not (car (gnus-id-to-thread id)))))
4044 (setq heads nil)))))
4045 gnus-newsgroup-dependencies)))
4047 (defsubst gnus-remove-odd-characters (string)
4048 "Translate STRING into something that doesn't contain weird characters."
4049 (mm-subst-char-in-string
4051 (mm-subst-char-in-string ?\n ?\- string t) t))
4053 ;; This function has to be called with point after the article number
4054 ;; on the beginning of the line.
4055 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4056 (let ((eol (point-at-eol))
4057 (buffer (current-buffer))
4058 header references in-reply-to)
4060 ;; overview: [num subject from date id refs chars lines misc]
4063 (narrow-to-region (point) eol)
4068 (make-full-mail-header
4070 (condition-case () ; subject
4071 (gnus-remove-odd-characters
4072 (funcall gnus-decode-encoded-word-function
4073 (setq x (nnheader-nov-field))))
4075 (condition-case () ; from
4076 (gnus-remove-odd-characters
4077 (funcall gnus-decode-encoded-word-function
4078 (setq x (nnheader-nov-field))))
4080 (nnheader-nov-field) ; date
4081 (nnheader-nov-read-message-id number) ; id
4082 (setq references (nnheader-nov-field)) ; refs
4083 (nnheader-nov-read-integer) ; chars
4084 (nnheader-nov-read-integer) ; lines
4086 (if (looking-at "Xref: ")
4087 (goto-char (match-end 0)))
4088 (nnheader-nov-field)) ; Xref
4089 (nnheader-nov-parse-extra)))) ; extra
4093 (when (and (string= references "")
4094 (setq in-reply-to (mail-header-extra header))
4095 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4096 (mail-header-set-references
4097 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4099 (when gnus-alter-header-function
4100 (funcall gnus-alter-header-function header))
4101 (gnus-dependencies-add-header header dependencies force-new)))
4103 (defun gnus-build-get-header (id)
4104 "Look through the buffer of NOV lines and find the header to ID.
4105 Enter this line into the dependencies hash table, and return
4106 the id of the parent article (if any)."
4107 (let ((deps gnus-newsgroup-dependencies)
4111 (set-buffer nntp-server-buffer)
4112 (let ((case-fold-search nil))
4113 (goto-char (point-min))
4114 (while (and (not found)
4115 (search-forward id nil t))
4117 (setq found (looking-at
4118 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4119 (regexp-quote id))))
4120 (or found (beginning-of-line 2)))
4124 (setq header (gnus-nov-parse-line
4125 (read (current-buffer)) deps))
4126 (gnus-parent-id (mail-header-references header))))))
4128 (let ((number (mail-header-number header)))
4129 (push number gnus-newsgroup-limit)
4130 (push header gnus-newsgroup-headers)
4131 (if (memq number gnus-newsgroup-unselected)
4133 (setq gnus-newsgroup-unreads
4134 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4136 (setq gnus-newsgroup-unselected
4137 (delq number gnus-newsgroup-unselected)))
4138 (push number gnus-newsgroup-ancient)))))))
4140 (defun gnus-build-all-threads ()
4141 "Read all the headers."
4142 (let ((gnus-summary-ignore-duplicates t)
4143 (mail-parse-charset gnus-newsgroup-charset)
4144 (dependencies gnus-newsgroup-dependencies)
4147 (set-buffer nntp-server-buffer)
4148 (let ((case-fold-search nil))
4149 (goto-char (point-min))
4152 (setq article (read (current-buffer))
4153 header (gnus-nov-parse-line article dependencies)))
4155 (with-current-buffer gnus-summary-buffer
4156 (push header gnus-newsgroup-headers)
4157 (if (memq (setq article (mail-header-number header))
4158 gnus-newsgroup-unselected)
4160 (setq gnus-newsgroup-unreads
4161 (gnus-add-to-sorted-list
4162 gnus-newsgroup-unreads article))
4163 (setq gnus-newsgroup-unselected
4164 (delq article gnus-newsgroup-unselected)))
4165 (push article gnus-newsgroup-ancient)))
4166 (forward-line 1)))))))
4168 (defun gnus-summary-update-article-line (article header)
4169 "Update the line for ARTICLE using HEADER."
4170 (let* ((id (mail-header-id header))
4171 (thread (gnus-id-to-thread id)))
4173 (error "Article in no thread"))
4174 ;; Update the thread.
4175 (setcar thread header)
4176 (gnus-summary-goto-subject article)
4177 (let* ((datal (gnus-data-find-list article))
4179 (buffer-read-only nil)
4180 (level (gnus-summary-thread-level)))
4182 (let ((inserted (- (point)
4184 (gnus-summary-insert-line
4186 (memq article gnus-newsgroup-undownloaded)
4187 (gnus-article-mark article)
4188 (memq article gnus-newsgroup-replied)
4189 (memq article gnus-newsgroup-expirable)
4190 ;; Only insert the Subject string when it's different
4191 ;; from the previous Subject string.
4196 (mail-header-subject
4199 (gnus-data-find-list
4201 (gnus-data-list t)))))
4202 ;; Error on the side of excessive subjects.
4204 (mail-header-subject header)))
4206 (mail-header-subject header))
4207 nil (cdr (assq article gnus-newsgroup-scored))
4208 (memq article gnus-newsgroup-processable))
4211 (gnus-data-update-list
4213 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4215 (defun gnus-summary-update-article (article &optional iheader)
4216 "Update ARTICLE in the summary buffer."
4217 (set-buffer gnus-summary-buffer)
4218 (let* ((header (gnus-summary-article-header article))
4219 (id (mail-header-id header))
4220 (data (gnus-data-find article))
4221 (thread (gnus-id-to-thread id))
4222 (references (mail-header-references header))
4226 (when (and references
4227 (not (equal "" references)))
4230 (buffer-read-only nil)
4236 (delq thread parent)))
4237 (if (gnus-summary-insert-subject id header)
4238 ;; Set the (possibly) new article number in the data structure.
4239 (gnus-data-set-number data (gnus-id-to-article id))
4243 (defun gnus-rebuild-thread (id &optional line)
4244 "Rebuild the thread containing ID.
4245 If LINE, insert the rebuilt thread starting on line LINE."
4246 (let ((buffer-read-only nil)
4247 old-pos current thread data)
4248 (if (not gnus-show-threads)
4249 (setq thread (list (car (gnus-id-to-thread id))))
4250 ;; Get the thread this article is part of.
4251 (setq thread (gnus-remove-thread id)))
4252 (setq old-pos (point-at-bol))
4253 (setq current (save-excursion
4254 (and (re-search-backward "[\r\n]" nil t)
4255 (gnus-summary-article-number))))
4256 ;; If this is a gathered thread, we have to go some re-gathering.
4257 (when (stringp (car thread))
4258 (let ((subject (car thread))
4260 (setq thread (cdr thread))
4262 (unless (memq (setq thr (gnus-id-to-thread
4264 (mail-header-id (caar thread)))))
4267 (setq thread (cdr thread)))
4268 ;; We now have all (unique) roots.
4269 (if (= (length roots) 1)
4270 ;; All the loose roots are now one solid root.
4271 (setq thread (car roots))
4272 (setq thread (cons subject (gnus-sort-threads roots))))))
4274 ;; We then insert this thread into the summary buffer.
4276 (goto-char (point-min))
4277 (forward-line (1- line)))
4278 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4279 (if gnus-show-threads
4280 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4281 (gnus-summary-prepare-unthreaded thread))
4282 (setq data (nreverse gnus-newsgroup-data))
4283 (setq threads gnus-newsgroup-threads))
4284 ;; We splice the new data into the data structure.
4285 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4286 ;;!!! then we want to insert at the beginning of the buffer.
4287 ;;!!! That happens to be true with Gnus now, but that may
4288 ;;!!! change in the future. Perhaps.
4289 (gnus-data-enter-list
4290 (if line nil current) data (- (point) old-pos))
4291 (setq gnus-newsgroup-threads
4292 (nconc threads gnus-newsgroup-threads))
4293 (gnus-data-compute-positions))))
4295 (defun gnus-number-to-header (number)
4296 "Return the header for article NUMBER."
4297 (let ((headers gnus-newsgroup-headers))
4299 (not (= number (mail-header-number (car headers)))))
4304 (defun gnus-parent-headers (in-headers &optional generation)
4305 "Return the headers of the GENERATIONeth parent of HEADERS."
4307 (setq generation 1))
4309 (headers in-headers)
4312 (not (zerop generation))
4313 (setq references (mail-header-references headers)))
4314 (setq headers (if (and references
4315 (setq parent (gnus-parent-id references)))
4316 (car (gnus-id-to-thread parent))
4319 (and (not (eq headers in-headers))
4322 (defun gnus-id-to-thread (id)
4323 "Return the (sub-)thread where ID appears."
4324 (gnus-gethash id gnus-newsgroup-dependencies))
4326 (defun gnus-id-to-article (id)
4327 "Return the article number of ID."
4328 (let ((thread (gnus-id-to-thread id)))
4331 (mail-header-number (car thread)))))
4333 (defun gnus-id-to-header (id)
4334 "Return the article headers of ID."
4335 (car (gnus-id-to-thread id)))
4337 (defun gnus-article-displayed-root-p (article)
4338 "Say whether ARTICLE is a root(ish) article."
4339 (let ((level (gnus-summary-thread-level article))
4340 (refs (mail-header-references (gnus-summary-article-header article)))
4346 ((null (gnus-parent-id refs)) t)
4348 (null (setq particle (gnus-id-to-article
4349 (gnus-parent-id refs))))
4350 (null (gnus-summary-thread-level particle)))))))
4352 (defun gnus-root-id (id)
4353 "Return the id of the root of the thread where ID appears."
4355 (while (and id (setq prev (car (gnus-id-to-thread id))))
4357 id (gnus-parent-id (mail-header-references prev))))
4360 (defun gnus-articles-in-thread (thread)
4361 "Return the list of articles in THREAD."
4362 (cons (mail-header-number (car thread))
4363 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4365 (defun gnus-remove-thread (id &optional dont-remove)
4366 "Remove the thread that has ID in it."
4367 (let (headers thread last-id)
4368 ;; First go up in this thread until we find the root.
4369 (setq last-id (gnus-root-id id)
4370 headers (message-flatten-list (gnus-id-to-thread last-id)))
4371 ;; We have now found the real root of this thread. It might have
4372 ;; been gathered into some loose thread, so we have to search
4373 ;; through the threads to find the thread we wanted.
4374 (let ((threads gnus-newsgroup-threads)
4377 (setq sub (car threads))
4378 (if (stringp (car sub))
4379 ;; This is a gathered thread, so we look at the roots
4380 ;; below it to find whether this article is in this
4383 (setq sub (cdr sub))
4385 (when (member (caar sub) headers)
4386 (setq thread (car threads)
4389 (setq sub (cdr sub))))
4390 ;; It's an ordinary thread, so we check it.
4391 (when (eq (car sub) (car headers))
4394 (setq threads (cdr threads)))
4395 ;; If this article is in no thread, then it's a root.
4398 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4399 (setq thread (gnus-id-to-thread last-id)))
4402 thread ; We return this thread.
4404 (if (stringp (car thread))
4406 ;; If we use dummy roots, then we have to remove the
4407 ;; dummy root as well.
4408 (when (eq gnus-summary-make-false-root 'dummy)
4409 ;; We go to the dummy root by going to
4410 ;; the first sub-"thread", and then one line up.
4411 (gnus-summary-goto-article
4412 (mail-header-number (caadr thread)))
4415 (gnus-data-compute-positions))
4416 (setq thread (cdr thread))
4418 (gnus-remove-thread-1 (car thread))
4419 (setq thread (cdr thread))))
4420 (gnus-remove-thread-1 thread))))))))
4422 (defun gnus-remove-thread-1 (thread)
4423 "Remove the thread THREAD recursively."
4424 (let ((number (mail-header-number (pop thread)))
4426 (setq thread (reverse thread))
4428 (gnus-remove-thread-1 (pop thread)))
4429 (when (setq d (gnus-data-find number))
4430 (goto-char (gnus-data-pos d))
4431 (gnus-summary-show-thread)
4437 (gnus-delete-line)))))))
4439 (defun gnus-sort-threads-1 (threads func)
4440 (sort (mapcar (lambda (thread)
4443 (gnus-sort-threads-1 (cdr thread) func))))
4446 (defun gnus-sort-threads (threads)
4448 (if (not gnus-thread-sort-functions)
4450 (gnus-message 8 "Sorting threads...")
4451 (let ((max-lisp-eval-depth 5000))
4452 (prog1 (gnus-sort-threads-1
4454 (gnus-make-sort-function gnus-thread-sort-functions))
4455 (gnus-message 8 "Sorting threads...done")))))
4457 (defun gnus-sort-articles (articles)
4459 (when gnus-article-sort-functions
4460 (gnus-message 7 "Sorting articles...")
4462 (setq gnus-newsgroup-headers
4463 (sort articles (gnus-make-sort-function
4464 gnus-article-sort-functions)))
4465 (gnus-message 7 "Sorting articles...done"))))
4467 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4468 (defmacro gnus-thread-header (thread)
4469 "Return header of first article in THREAD.
4470 Note that THREAD must never, ever be anything else than a variable -
4471 using some other form will lead to serious barfage."
4472 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4473 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4474 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4477 (defsubst gnus-article-sort-by-number (h1 h2)
4478 "Sort articles by article number."
4479 (< (mail-header-number h1)
4480 (mail-header-number h2)))
4482 (defun gnus-thread-sort-by-number (h1 h2)
4483 "Sort threads by root article number."
4484 (gnus-article-sort-by-number
4485 (gnus-thread-header h1) (gnus-thread-header h2)))
4487 (defsubst gnus-article-sort-by-random (h1 h2)
4488 "Sort articles by article number."
4491 (defun gnus-thread-sort-by-random (h1 h2)
4492 "Sort threads by root article number."
4493 (gnus-article-sort-by-random
4494 (gnus-thread-header h1) (gnus-thread-header h2)))
4496 (defsubst gnus-article-sort-by-lines (h1 h2)
4497 "Sort articles by article Lines header."
4498 (< (mail-header-lines h1)
4499 (mail-header-lines h2)))
4501 (defun gnus-thread-sort-by-lines (h1 h2)
4502 "Sort threads by root article Lines header."
4503 (gnus-article-sort-by-lines
4504 (gnus-thread-header h1) (gnus-thread-header h2)))
4506 (defsubst gnus-article-sort-by-chars (h1 h2)
4507 "Sort articles by octet length."
4508 (< (mail-header-chars h1)
4509 (mail-header-chars h2)))
4511 (defun gnus-thread-sort-by-chars (h1 h2)
4512 "Sort threads by root article octet length."
4513 (gnus-article-sort-by-chars
4514 (gnus-thread-header h1) (gnus-thread-header h2)))
4516 (defsubst gnus-article-sort-by-author (h1 h2)
4517 "Sort articles by root author."
4519 (let ((extract (funcall
4520 gnus-extract-address-components
4521 (mail-header-from h1))))
4522 (or (car extract) (cadr extract) ""))
4523 (let ((extract (funcall
4524 gnus-extract-address-components
4525 (mail-header-from h2))))
4526 (or (car extract) (cadr extract) ""))))
4528 (defun gnus-thread-sort-by-author (h1 h2)
4529 "Sort threads by root author."
4530 (gnus-article-sort-by-author
4531 (gnus-thread-header h1) (gnus-thread-header h2)))
4533 (defsubst gnus-article-sort-by-subject (h1 h2)
4534 "Sort articles by root subject."
4536 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4537 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4539 (defun gnus-thread-sort-by-subject (h1 h2)
4540 "Sort threads by root subject."
4541 (gnus-article-sort-by-subject
4542 (gnus-thread-header h1) (gnus-thread-header h2)))
4544 (defsubst gnus-article-sort-by-date (h1 h2)
4545 "Sort articles by root article date."
4547 (gnus-date-get-time (mail-header-date h1))
4548 (gnus-date-get-time (mail-header-date h2))))
4550 (defun gnus-thread-sort-by-date (h1 h2)
4551 "Sort threads by root article date."
4552 (gnus-article-sort-by-date
4553 (gnus-thread-header h1) (gnus-thread-header h2)))
4555 (defsubst gnus-article-sort-by-score (h1 h2)
4556 "Sort articles by root article score.
4557 Unscored articles will be counted as having a score of zero."
4558 (> (or (cdr (assq (mail-header-number h1)
4559 gnus-newsgroup-scored))
4560 gnus-summary-default-score 0)
4561 (or (cdr (assq (mail-header-number h2)
4562 gnus-newsgroup-scored))
4563 gnus-summary-default-score 0)))
4565 (defun gnus-thread-sort-by-score (h1 h2)
4566 "Sort threads by root article score."
4567 (gnus-article-sort-by-score
4568 (gnus-thread-header h1) (gnus-thread-header h2)))
4570 (defun gnus-thread-sort-by-total-score (h1 h2)
4571 "Sort threads by the sum of all scores in the thread.
4572 Unscored articles will be counted as having a score of zero."
4573 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4575 (defun gnus-thread-total-score (thread)
4576 ;; This function find the total score of THREAD.
4581 (if (stringp (car thread))
4582 (apply gnus-thread-score-function 0
4583 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4584 (gnus-thread-total-score-1 thread)))
4586 (gnus-thread-total-score-1 (list thread)))))
4588 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4589 "Sort threads such that the thread with the most recently arrived article comes first."
4590 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4592 (defun gnus-thread-highest-number (thread)
4593 "Return the highest article number in THREAD."
4594 (apply 'max (mapcar (lambda (header)
4595 (mail-header-number header))
4596 (message-flatten-list thread))))
4598 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4599 "Sort threads such that the thread with the most recently dated article comes first."
4600 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4602 (defun gnus-thread-latest-date (thread)
4603 "Return the highest article date in THREAD."
4604 (let ((previous-time 0))
4610 (time-to-seconds (mail-header-parse-date
4611 (mail-header-date header)))
4612 (error previous-time))))
4614 (message-flatten-list thread)
4616 (< (mail-header-number h1)
4617 (mail-header-number h2))))))))
4619 (defun gnus-thread-total-score-1 (root)
4620 ;; This function find the total score of the thread below ROOT.
4621 (setq root (car root))
4622 (apply gnus-thread-score-function
4624 (mapcar 'gnus-thread-total-score
4625 (cdr (gnus-id-to-thread (mail-header-id root))))
4626 (when (> (mail-header-number root) 0)
4627 (list (or (cdr (assq (mail-header-number root)
4628 gnus-newsgroup-scored))
4629 gnus-summary-default-score 0))))
4630 (list gnus-summary-default-score)
4633 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4634 (defvar gnus-tmp-prev-subject nil)
4635 (defvar gnus-tmp-false-parent nil)
4636 (defvar gnus-tmp-root-expunged nil)
4637 (defvar gnus-tmp-dummy-line nil)
4639 (eval-when-compile (defvar gnus-tmp-header))
4640 (defun gnus-extra-header (type &optional header)
4641 "Return the extra header of TYPE."
4642 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4645 (defvar gnus-tmp-thread-tree-header-string "")
4647 (defcustom gnus-sum-thread-tree-root "> "
4648 "With %B spec, used for the root of a thread.
4649 If nil, use subject instead."
4650 :type '(radio (const :format "%v " nil) (string :size 0))
4651 :group 'gnus-thread)
4652 (defcustom gnus-sum-thread-tree-false-root "> "
4653 "With %B spec, used for a false root of a thread.
4654 If nil, use subject instead."
4655 :type '(radio (const :format "%v " nil) (string :size 0))
4656 :group 'gnus-thread)
4657 (defcustom gnus-sum-thread-tree-single-indent ""
4658 "With %B spec, used for a thread with just one message.
4659 If nil, use subject instead."
4660 :type '(radio (const :format "%v " nil) (string :size 0))
4661 :group 'gnus-thread)
4662 (defcustom gnus-sum-thread-tree-vertical "| "
4663 "With %B spec, used for drawing a vertical line."
4665 :group 'gnus-thread)
4666 (defcustom gnus-sum-thread-tree-indent " "
4667 "With %B spec, used for indenting."
4669 :group 'gnus-thread)
4670 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4671 "With %B spec, used for a leaf with brothers."
4673 :group 'gnus-thread)
4674 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4675 "With %B spec, used for a leaf without brothers."
4677 :group 'gnus-thread)
4679 (defun gnus-summary-prepare-threads (threads)
4680 "Prepare summary buffer from THREADS and indentation LEVEL.
4681 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4682 or a straight list of headers."
4683 (gnus-message 7 "Generating summary...")
4685 (setq gnus-newsgroup-threads threads)
4688 (let ((gnus-tmp-level 0)
4689 (default-score (or gnus-summary-default-score 0))
4690 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4691 (building-line-count gnus-summary-display-while-building)
4692 (building-count (integerp gnus-summary-display-while-building))
4693 thread number subject stack state gnus-tmp-gathered beg-match
4694 new-roots gnus-tmp-new-adopts thread-end simp-subject
4695 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4696 gnus-tmp-replied gnus-tmp-subject-or-nil
4697 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4698 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4699 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4702 (setq gnus-tmp-prev-subject nil
4703 gnus-tmp-thread-tree-header-string "")
4705 (if (vectorp (car threads))
4706 ;; If this is a straight (sic) list of headers, then a
4707 ;; threaded summary display isn't required, so we just create
4708 ;; an unthreaded one.
4709 (gnus-summary-prepare-unthreaded threads)
4711 ;; Do the threaded display.
4713 (if gnus-summary-display-while-building
4714 (switch-to-buffer (buffer-name)))
4715 (while (or threads stack gnus-tmp-new-adopts new-roots)
4717 (if (and (= gnus-tmp-level 0)
4720 (not gnus-tmp-false-parent)
4721 (or gnus-tmp-new-adopts new-roots))
4722 (if gnus-tmp-new-adopts
4723 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4724 thread (list (car gnus-tmp-new-adopts))
4725 gnus-tmp-header (caar thread)
4726 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4728 (setq thread (list (car new-roots))
4729 gnus-tmp-header (caar thread)
4730 new-roots (cdr new-roots))))
4733 ;; If there are some threads, we do them before the
4734 ;; threads on the stack.
4735 (setq thread threads
4736 gnus-tmp-header (caar thread))
4737 ;; There were no current threads, so we pop something off
4739 (setq state (car stack)
4740 gnus-tmp-level (car state)
4741 tree-stack (cadr state)
4742 thread (caddr state)
4744 gnus-tmp-header (caar thread))))
4746 (setq gnus-tmp-false-parent nil)
4747 (setq gnus-tmp-root-expunged nil)
4748 (setq thread-end nil)
4750 (if (stringp gnus-tmp-header)
4751 ;; The header is a dummy root.
4753 ((eq gnus-summary-make-false-root 'adopt)
4754 ;; We let the first article adopt the rest.
4755 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4757 (setq gnus-tmp-gathered
4759 (lambda (h) (mail-header-number (car h)))
4762 (setq thread (cons (list (caar thread)
4765 (setq gnus-tmp-level -1
4766 gnus-tmp-false-parent t))
4767 ((eq gnus-summary-make-false-root 'empty)
4768 ;; We print adopted articles with empty subject fields.
4769 (setq gnus-tmp-gathered
4771 (lambda (h) (mail-header-number (car h)))
4774 (setq gnus-tmp-level -1))
4775 ((eq gnus-summary-make-false-root 'dummy)
4776 ;; We remember that we probably want to output a dummy
4778 (setq gnus-tmp-dummy-line gnus-tmp-header)
4779 (setq gnus-tmp-prev-subject gnus-tmp-header))
4781 ;; We do not make a root for the gathered
4782 ;; sub-threads at all.
4783 (setq gnus-tmp-level -1)))
4785 (setq number (mail-header-number gnus-tmp-header)
4786 subject (mail-header-subject gnus-tmp-header)
4787 simp-subject (gnus-simplify-subject-fully subject))
4790 ;; If the thread has changed subject, we might want to make
4791 ;; this subthread into a root.
4792 ((and (null gnus-thread-ignore-subject)
4793 (not (zerop gnus-tmp-level))
4794 gnus-tmp-prev-subject
4795 (not (string= gnus-tmp-prev-subject simp-subject)))
4796 (setq new-roots (nconc new-roots (list (car thread)))
4798 gnus-tmp-header nil))
4799 ;; If the article lies outside the current limit,
4800 ;; then we do not display it.
4801 ((not (memq number gnus-newsgroup-limit))
4802 (setq gnus-tmp-gathered
4804 (lambda (h) (mail-header-number (car h)))
4807 (setq gnus-tmp-new-adopts (if (cdar thread)
4808 (append gnus-tmp-new-adopts
4810 gnus-tmp-new-adopts)
4812 gnus-tmp-header nil)
4813 (when (zerop gnus-tmp-level)
4814 (setq gnus-tmp-root-expunged t)))
4815 ;; Perhaps this article is to be marked as read?
4816 ((and gnus-summary-mark-below
4817 (< (or (cdr (assq number gnus-newsgroup-scored))
4819 gnus-summary-mark-below)
4820 ;; Don't touch sparse articles.
4821 (not (gnus-summary-article-sparse-p number))
4822 (not (gnus-summary-article-ancient-p number)))
4823 (setq gnus-newsgroup-unreads
4824 (delq number gnus-newsgroup-unreads))
4825 (if gnus-newsgroup-auto-expire
4826 (setq gnus-newsgroup-expirable
4827 (gnus-add-to-sorted-list
4828 gnus-newsgroup-expirable number))
4829 (push (cons number gnus-low-score-mark)
4830 gnus-newsgroup-reads))))
4832 (when gnus-tmp-header
4833 ;; We may have an old dummy line to output before this
4835 (when (and gnus-tmp-dummy-line
4838 (mail-header-subject gnus-tmp-header)))
4839 (gnus-summary-insert-dummy-line
4840 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4841 (setq gnus-tmp-dummy-line nil))
4843 ;; Compute the mark.
4844 (setq gnus-tmp-unread (gnus-article-mark number))
4846 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4847 gnus-tmp-header gnus-tmp-level)
4848 gnus-newsgroup-data)
4850 ;; Actually insert the line.
4852 gnus-tmp-subject-or-nil
4854 ((and gnus-thread-ignore-subject
4855 gnus-tmp-prev-subject
4856 (not (string= gnus-tmp-prev-subject simp-subject)))
4858 ((zerop gnus-tmp-level)
4859 (if (and (eq gnus-summary-make-false-root 'empty)
4860 (memq number gnus-tmp-gathered)
4861 gnus-tmp-prev-subject
4862 (string= gnus-tmp-prev-subject simp-subject))
4863 gnus-summary-same-subject
4865 (t gnus-summary-same-subject)))
4866 (if (and (eq gnus-summary-make-false-root 'adopt)
4867 (= gnus-tmp-level 1)
4868 (memq number gnus-tmp-gathered))
4869 (setq gnus-tmp-opening-bracket ?\<
4870 gnus-tmp-closing-bracket ?\>)
4871 (setq gnus-tmp-opening-bracket ?\[
4872 gnus-tmp-closing-bracket ?\]))
4874 gnus-tmp-indentation
4875 (aref gnus-thread-indent-array gnus-tmp-level)
4876 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4877 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4878 gnus-summary-default-score 0)
4880 (if (or (null gnus-summary-default-score)
4881 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4882 gnus-summary-zcore-fuzz))
4884 (if (< gnus-tmp-score gnus-summary-default-score)
4885 gnus-score-below-mark gnus-score-over-mark))
4887 (cond ((memq number gnus-newsgroup-processable)
4889 ((memq number gnus-newsgroup-cached)
4891 ((memq number gnus-newsgroup-replied)
4893 ((memq number gnus-newsgroup-forwarded)
4894 gnus-forwarded-mark)
4895 ((memq number gnus-newsgroup-saved)
4897 ((memq number gnus-newsgroup-recent)
4899 ((memq number gnus-newsgroup-unseen)
4903 (cond ((memq number gnus-newsgroup-undownloaded)
4904 gnus-undownloaded-mark)
4905 (gnus-newsgroup-agentized
4906 gnus-downloaded-mark)
4909 gnus-tmp-from (mail-header-from gnus-tmp-header)
4912 ((string-match "<[^>]+> *$" gnus-tmp-from)
4913 (setq beg-match (match-beginning 0))
4914 (or (and (string-match "^\".+\"" gnus-tmp-from)
4915 (substring gnus-tmp-from 1 (1- (match-end 0))))
4916 (substring gnus-tmp-from 0 beg-match)))
4917 ((string-match "(.+)" gnus-tmp-from)
4918 (substring gnus-tmp-from
4919 (1+ (match-beginning 0)) (1- (match-end 0))))
4923 gnus-tmp-thread-tree-header-string
4925 ((not gnus-show-threads) "")
4926 ((zerop gnus-tmp-level)
4927 (cond ((cdar thread)
4928 (or gnus-sum-thread-tree-root subject))
4929 (gnus-tmp-new-adopts
4930 (or gnus-sum-thread-tree-false-root subject))
4932 (or gnus-sum-thread-tree-single-indent subject))))
4934 (concat (apply 'concat
4935 (mapcar (lambda (item)
4937 gnus-sum-thread-tree-vertical
4938 gnus-sum-thread-tree-indent))
4939 (cdr (reverse tree-stack))))
4941 gnus-sum-thread-tree-leaf-with-other
4942 gnus-sum-thread-tree-single-leaf)))))
4943 (when (string= gnus-tmp-name "")
4944 (setq gnus-tmp-name gnus-tmp-from))
4945 (unless (numberp gnus-tmp-lines)
4946 (setq gnus-tmp-lines -1))
4947 (if (= gnus-tmp-lines -1)
4948 (setq gnus-tmp-lines "?")
4949 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4950 (gnus-put-text-property
4952 (progn (eval gnus-summary-line-format-spec) (point))
4953 'gnus-number number)
4956 (gnus-run-hooks 'gnus-summary-update-hook)
4959 (setq gnus-tmp-prev-subject simp-subject)))
4961 (when (nth 1 thread)
4962 (push (list (max 0 gnus-tmp-level)
4963 (copy-sequence tree-stack)
4966 (push (if (nth 1 thread) 1 0) tree-stack)
4967 (incf gnus-tmp-level)
4968 (setq threads (if thread-end nil (cdar thread)))
4969 (if gnus-summary-display-while-building
4972 ;; use a set frequency
4973 (setq building-line-count (1- building-line-count))
4974 (when (= building-line-count 0)
4976 (setq building-line-count
4977 gnus-summary-display-while-building)))
4981 (setq gnus-tmp-level 0)))))
4982 (gnus-message 7 "Generating summary...done"))
4984 (defun gnus-summary-prepare-unthreaded (headers)
4985 "Generate an unthreaded summary buffer based on HEADERS."
4986 (let (header number mark)
4991 ;; We may have to root out some bad articles...
4992 (when (memq (setq number (mail-header-number
4993 (setq header (pop headers))))
4994 gnus-newsgroup-limit)
4995 ;; Mark article as read when it has a low score.
4996 (when (and gnus-summary-mark-below
4997 (< (or (cdr (assq number gnus-newsgroup-scored))
4998 gnus-summary-default-score 0)
4999 gnus-summary-mark-below)
5000 (not (gnus-summary-article-ancient-p number)))
5001 (setq gnus-newsgroup-unreads
5002 (delq number gnus-newsgroup-unreads))
5003 (if gnus-newsgroup-auto-expire
5004 (push number gnus-newsgroup-expirable)
5005 (push (cons number gnus-low-score-mark)
5006 gnus-newsgroup-reads)))
5008 (setq mark (gnus-article-mark number))
5009 (push (gnus-data-make number mark (1+ (point)) header 0)
5010 gnus-newsgroup-data)
5011 (gnus-summary-insert-line
5013 (memq number gnus-newsgroup-undownloaded)
5014 mark (memq number gnus-newsgroup-replied)
5015 (memq number gnus-newsgroup-expirable)
5016 (mail-header-subject header) nil
5017 (cdr (assq number gnus-newsgroup-scored))
5018 (memq number gnus-newsgroup-processable))))))
5020 (defun gnus-summary-remove-list-identifiers ()
5021 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5022 (let ((regexp (if (consp gnus-list-identifiers)
5023 (mapconcat 'identity gnus-list-identifiers " *\\|")
5024 gnus-list-identifiers))
5027 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5028 (dolist (header gnus-newsgroup-headers)
5029 (setq subject (mail-header-subject header)
5031 (while (string-match regexp subject)
5033 (concat (substring subject 0 (match-beginning 1))
5034 (substring subject (match-end 0)))
5037 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5039 (concat (substring subject 0 (match-beginning 1))
5040 (substring subject (match-end 1)))))
5041 (mail-header-set-subject header subject))))))
5043 (defun gnus-fetch-headers (articles)
5044 "Fetch headers of ARTICLES."
5045 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5046 (gnus-message 5 "Fetching headers for %s..." name)
5049 (setq gnus-headers-retrieved-by
5050 (gnus-retrieve-headers
5051 articles gnus-newsgroup-name
5052 ;; We might want to fetch old headers, but
5053 ;; not if there is only 1 article.
5055 (not (eq gnus-fetch-old-headers 'some))
5056 (not (numberp gnus-fetch-old-headers)))
5057 (> (length articles) 1))
5058 gnus-fetch-old-headers))))
5059 (gnus-get-newsgroup-headers-xover
5060 articles nil nil gnus-newsgroup-name t)
5061 (gnus-get-newsgroup-headers))
5062 (gnus-message 5 "Fetching headers for %s...done" name))))
5064 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5065 "Select newsgroup GROUP.
5066 If READ-ALL is non-nil, all articles in the group are selected.
5067 If SELECT-ARTICLES, only select those articles from GROUP."
5068 (let* ((entry (gnus-group-entry group))
5069 ;;!!! Dirty hack; should be removed.
5070 (gnus-summary-ignore-duplicates
5071 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5073 gnus-summary-ignore-duplicates))
5074 (info (nth 2 entry))
5075 articles fetched-articles cached)
5077 (unless (gnus-check-server
5078 (set (make-local-variable 'gnus-current-select-method)
5079 (gnus-find-method-for-group group)))
5080 (error "Couldn't open server"))
5082 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5083 (gnus-activate-group group) ; Or we can activate it...
5084 (progn ; Or we bug out.
5085 (when (equal major-mode 'gnus-summary-mode)
5086 (gnus-kill-buffer (current-buffer)))
5087 (error "Couldn't activate group %s: %s"
5088 group (gnus-status-message group))))
5090 (unless (gnus-request-group group t)
5091 (when (equal major-mode 'gnus-summary-mode)
5092 (gnus-kill-buffer (current-buffer)))
5093 (error "Couldn't request group %s: %s"
5094 group (gnus-status-message group)))
5097 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5099 (setq gnus-summary-use-undownloaded-faces
5100 (gnus-agent-find-parameter
5102 'agent-enable-undownloaded-faces)))
5104 (setq gnus-newsgroup-name group
5105 gnus-newsgroup-unselected nil
5106 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5108 (let ((display (gnus-group-find-parameter group 'display)))
5109 (setq gnus-newsgroup-display
5111 ((not (zerop (or (car-safe read-all) 0)))
5112 ;; The user entered the group with C-u SPC/RET, let's show
5118 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5120 ;; The following is probably the "correct" solution, but
5121 ;; it makes Gnus fetch all headers and then limit the
5122 ;; articles (which is slow), so instead we hack the
5123 ;; select-articles parameter instead. -- Simon Josefsson
5126 ;; (gnus-byte-compile
5127 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5129 (setq select-articles
5130 (gnus-uncompress-range
5131 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5135 (cdr (gnus-active group)))))
5140 (gnus-summary-setup-default-charset)
5142 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5143 (when (gnus-virtual-group-p group)
5144 (setq cached gnus-newsgroup-cached))
5146 (setq gnus-newsgroup-unreads
5147 (gnus-sorted-ndifference
5148 (gnus-sorted-ndifference gnus-newsgroup-unreads
5149 gnus-newsgroup-marked)
5150 gnus-newsgroup-dormant))
5152 (setq gnus-newsgroup-processable nil)
5154 (gnus-update-read-articles group gnus-newsgroup-unreads)
5156 ;; Adjust and set lists of article marks.
5158 (gnus-adjust-marked-articles info))
5159 (if (setq articles select-articles)
5160 (setq gnus-newsgroup-unselected
5161 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5162 (setq articles (gnus-articles-to-read group read-all)))
5166 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5168 ((eq articles 0) nil)
5170 ;; Init the dependencies hash table.
5171 (setq gnus-newsgroup-dependencies
5172 (gnus-make-hashtable (length articles)))
5173 (gnus-set-global-variables)
5174 ;; Retrieve the headers and read them in.
5176 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5178 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5180 (setq gnus-newsgroup-cached cached))
5182 ;; Suppress duplicates?
5183 (when gnus-suppress-duplicates
5184 (gnus-dup-suppress-articles))
5186 ;; Set the initial limit.
5187 (setq gnus-newsgroup-limit (copy-sequence articles))
5188 ;; Remove canceled articles from the list of unread articles.
5189 (setq fetched-articles
5190 (mapcar (lambda (headers) (mail-header-number headers))
5191 gnus-newsgroup-headers))
5192 (setq gnus-newsgroup-articles fetched-articles)
5193 (setq gnus-newsgroup-unreads
5194 (gnus-sorted-nintersection
5195 gnus-newsgroup-unreads fetched-articles))
5196 (gnus-compute-unseen-list)
5198 ;; Removed marked articles that do not exist.
5199 (gnus-update-missing-marks
5200 (gnus-sorted-difference articles fetched-articles))
5201 ;; We might want to build some more threads first.
5202 (when (and gnus-fetch-old-headers
5203 (eq gnus-headers-retrieved-by 'nov))
5204 (if (eq gnus-fetch-old-headers 'invisible)
5205 (gnus-build-all-threads)
5206 (gnus-build-old-threads)))
5207 ;; Let the Gnus agent mark articles as read.
5209 (gnus-agent-get-undownloaded-list))
5210 ;; Remove list identifiers from subject
5211 (when gnus-list-identifiers
5212 (gnus-summary-remove-list-identifiers))
5213 ;; Check whether auto-expire is to be done in this group.
5214 (setq gnus-newsgroup-auto-expire
5215 (gnus-group-auto-expirable-p group))
5216 ;; Set up the article buffer now, if necessary.
5217 (unless gnus-single-article-buffer
5218 (gnus-article-setup-buffer))
5219 ;; First and last article in this newsgroup.
5220 (when gnus-newsgroup-headers
5221 (setq gnus-newsgroup-begin
5222 (mail-header-number (car gnus-newsgroup-headers))
5225 (gnus-last-element gnus-newsgroup-headers))))
5226 ;; GROUP is successfully selected.
5227 (or gnus-newsgroup-headers t)))))
5229 (defun gnus-compute-unseen-list ()
5230 ;; The `seen' marks are treated specially.
5231 (if (not gnus-newsgroup-seen)
5232 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5233 (setq gnus-newsgroup-unseen
5234 (gnus-inverse-list-range-intersection
5235 gnus-newsgroup-articles gnus-newsgroup-seen))))
5237 (defun gnus-summary-display-make-predicate (display)
5238 (require 'gnus-agent)
5239 (when (= (length display) 1)
5240 (setq display (car display)))
5241 (unless gnus-summary-display-cache
5242 (dolist (elem (append '((unread . unread)
5245 gnus-article-mark-lists))
5246 (push (cons (cdr elem)
5248 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5249 gnus-summary-display-cache)))
5250 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5251 (gnus-category-predicate-cache gnus-summary-display-cache))
5252 (gnus-get-predicate display)))
5254 ;; Uses the dynamically bound `number' variable.
5257 (defun gnus-article-marked-p (type &optional article)
5258 (let ((article (or article number)))
5261 (memq article gnus-newsgroup-marked))
5263 (memq article gnus-newsgroup-spam-marked))
5265 (memq article gnus-newsgroup-unsendable))
5266 ((eq type 'undownload)
5267 (memq article gnus-newsgroup-undownloaded))
5268 ((eq type 'download)
5269 (memq article gnus-newsgroup-downloadable))
5271 (memq article gnus-newsgroup-unreads))
5273 (memq article gnus-newsgroup-reads))
5275 (memq article gnus-newsgroup-dormant) )
5277 (memq article gnus-newsgroup-expirable))
5279 (memq article gnus-newsgroup-replied))
5281 (memq article gnus-newsgroup-killed))
5282 ((eq type 'bookmark)
5283 (assq article gnus-newsgroup-bookmarks))
5285 (assq article gnus-newsgroup-scored))
5287 (memq article gnus-newsgroup-saved))
5289 (memq article gnus-newsgroup-cached))
5291 (memq article gnus-newsgroup-forwarded))
5293 (not (memq article gnus-newsgroup-unseen)))
5295 (memq article gnus-newsgroup-recent))
5298 (defun gnus-articles-to-read (group &optional read-all)
5299 "Find out what articles the user wants to read."
5301 ;; Select all articles if `read-all' is non-nil, or if there
5302 ;; are no unread articles.
5304 (and (zerop (length gnus-newsgroup-marked))
5305 (zerop (length gnus-newsgroup-unreads)))
5306 ;; Fetch all if the predicate is non-nil.
5307 gnus-newsgroup-display)
5308 ;; We want to select the headers for all the articles in
5309 ;; the group, so we select either all the active
5310 ;; articles in the group, or (if that's nil), the
5311 ;; articles in the cache.
5313 (gnus-uncompress-range (gnus-active group))
5314 (gnus-cache-articles-in-group group))
5315 ;; Select only the "normal" subset of articles.
5317 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5318 gnus-newsgroup-unreads)))
5319 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5320 (scored (length scored-list))
5321 (number (length articles))
5322 (marked (+ (length gnus-newsgroup-marked)
5323 (length gnus-newsgroup-dormant)))
5328 ((numberp gnus-newsgroup-display)
5329 gnus-newsgroup-display)
5333 ((and (or (<= scored marked) (= scored number))
5334 (numberp gnus-large-newsgroup)
5335 (> number gnus-large-newsgroup))
5336 (let* ((cursor-in-echo-area nil)
5337 (initial (gnus-parameter-large-newsgroup-initial
5338 gnus-newsgroup-name))
5342 "How many articles from %s (%s %d): "
5344 (gnus-group-decoded-name gnus-newsgroup-name)
5346 (if initial "max" "default")
5349 (cons (number-to-string initial)
5351 (if (string-match "^[ \t]*$" input) number input)))
5352 ((and (> scored marked) (< scored number)
5353 (> (- scored number) 20))
5356 (format "%s %s (%d scored, %d total): "
5357 "How many articles from"
5358 (gnus-group-decoded-name group)
5360 (if (string-match "^[ \t]*$" input)
5364 (message "Quit getting the articles to read")
5366 (setq select (if (stringp select) (string-to-number select) select))
5367 (if (or (null select) (zerop select))
5369 (if (and (not (zerop scored)) (<= (abs select) scored))
5371 (setq articles (sort scored-list '<))
5372 (setq number (length articles)))
5373 (setq articles (copy-sequence articles)))
5375 (when (< (abs select) number)
5377 ;; Select the N oldest articles.
5378 (setcdr (nthcdr (1- (abs select)) articles) nil)
5379 ;; Select the N most recent articles.
5380 (setq articles (nthcdr (- number select) articles))))
5381 (setq gnus-newsgroup-unselected
5382 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5383 (when gnus-alter-articles-to-read-function
5386 (funcall gnus-alter-articles-to-read-function
5387 gnus-newsgroup-name articles)
5391 (defun gnus-killed-articles (killed articles)
5394 (when (inline (gnus-member-of-range (car articles) killed))
5395 (push (car articles) out))
5396 (setq articles (cdr articles)))
5399 (defun gnus-uncompress-marks (marks)
5400 "Uncompress the mark ranges in MARKS."
5401 (let ((uncompressed '(score bookmark))
5404 (if (memq (caar marks) uncompressed)
5405 (push (car marks) out)
5406 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5407 (setq marks (cdr marks)))
5410 (defun gnus-article-mark-to-type (mark)
5411 "Return the type of MARK."
5412 (or (cadr (assq mark gnus-article-special-mark-lists))
5415 (defun gnus-article-unpropagatable-p (mark)
5416 "Return whether MARK should be propagated to back end."
5417 (memq mark gnus-article-unpropagated-mark-lists))
5419 (defun gnus-adjust-marked-articles (info)
5420 "Set all article lists and remove all marks that are no longer valid."
5421 (let* ((marked-lists (gnus-info-marks info))
5422 (active (gnus-active (gnus-info-group info)))
5425 (types gnus-article-mark-lists)
5426 marks var articles article mark mark-type
5429 (dolist (marks marked-lists)
5430 (setq mark (car marks)
5431 mark-type (gnus-article-mark-to-type mark)
5432 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5434 ;; We set the variable according to the type of the marks list,
5435 ;; and then adjust the marks to a subset of the active articles.
5437 ;; Adjust "simple" lists - compressed yet unsorted
5438 ((eq mark-type 'list)
5439 ;; Simultaneously uncompress and clip to active range
5440 ;; See gnus-uncompress-range for a description of possible marks
5442 (if (not (cadr marks))
5444 (setq articles (if (numberp (cddr marks))
5450 (while (setq article (pop articles))
5451 (cond ((consp article)
5452 (setq bgn (max (car article) min)
5453 end (min (cdr article) max))
5455 (setq l (setcdr l (cons bgn nil))
5457 ((and (<= min article)
5459 (setq l (setcdr l (cons article nil))))))
5460 (set var (cdr lh)))))
5462 ((eq mark-type 'tuple)
5463 (set var (setq articles (cdr marks)))
5464 (when (not (listp (cdr (symbol-value var))))
5465 (set var (list (symbol-value var))))
5466 (when (not (listp (cdr articles)))
5467 (setq articles (list articles)))
5469 (when (or (not (consp (setq article (pop articles))))
5470 (< (car article) min)
5471 (> (car article) max))
5472 (set var (delq article (symbol-value var))))))
5473 ;; Adjust ranges (sloppily).
5474 ((eq mark-type 'range)
5477 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5478 ;; It should be (seen (NUM1 . NUM2)).
5479 (when (numberp (cddr marks))
5480 (setcdr marks (list (cdr marks))))
5481 (setq articles (cdr marks))
5482 (while (and articles
5483 (or (and (consp (car articles))
5484 (> min (cdar articles)))
5485 (and (numberp (car articles))
5486 (> min (car articles)))))
5488 (set var articles))))))))
5490 (defun gnus-update-missing-marks (missing)
5491 "Go through the list of MISSING articles and remove them from the mark lists."
5494 ;; Go through all types.
5495 (dolist (elem gnus-article-mark-lists)
5496 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5497 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5498 (when (symbol-value var)
5499 ;; This list has articles. So we delete all missing
5500 ;; articles from it.
5503 (set var (delq (pop m) (symbol-value var))))))))))
5505 (defun gnus-update-marks ()
5506 "Enter the various lists of marked articles into the newsgroup info list."
5507 (let ((types gnus-article-mark-lists)
5508 (info (gnus-get-info gnus-newsgroup-name))
5509 type list newmarked symbol delta-marks)
5511 ;; Add all marks lists to the list of marks lists.
5512 (while (setq type (pop types))
5513 (setq list (symbol-value
5515 (intern (format "gnus-newsgroup-%s" (car type))))))
5518 ;; Get rid of the entries of the articles that have the
5520 (when (and (eq (cdr type) 'score)
5524 (prev (cons nil list))
5527 (if (or (not (consp (car arts)))
5528 (= (cdar arts) gnus-summary-default-score))
5529 (setcdr prev (cdr arts))
5531 (setq arts (cdr arts)))
5532 (setq list (cdr all)))))
5534 (when (eq (cdr type) 'seen)
5535 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5537 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5538 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5540 (when (and (gnus-check-backend-function
5541 'request-set-mark gnus-newsgroup-name)
5542 (not (gnus-article-unpropagatable-p (cdr type))))
5543 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5544 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5545 (add (gnus-remove-from-range
5546 (gnus-copy-sequence list) old)))
5548 (push (list add 'add (list (cdr type))) delta-marks))
5550 (push (list del 'del (list (cdr type))) delta-marks))))
5553 (push (cons (cdr type) list) newmarked)))
5556 (unless (gnus-check-group gnus-newsgroup-name)
5557 (error "Can't open server for %s" gnus-newsgroup-name))
5558 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5560 ;; Enter these new marks into the info of the group.
5562 (setcar (nthcdr 3 info) newmarked)
5563 ;; Add the marks lists to the end of the info.
5565 (setcdr (nthcdr 2 info) (list newmarked))))
5567 ;; Cut off the end of the info if there's nothing else there.
5571 (when (nthcdr (decf i) info)
5572 (setcdr (nthcdr i info) nil)))))))
5574 (defun gnus-set-mode-line (where)
5575 "Set the mode line of the article or summary buffers.
5576 If WHERE is `summary', the summary mode line format will be used."
5577 ;; Is this mode line one we keep updated?
5578 (when (and (memq where gnus-updated-mode-lines)
5580 (intern (format "gnus-%s-mode-line-format-spec" where))))
5583 ;; We evaluate this in the summary buffer since these
5584 ;; variables are buffer-local to that buffer.
5585 (set-buffer gnus-summary-buffer)
5586 ;; We bind all these variables that are used in the `eval' form
5588 (let* ((mformat (symbol-value
5590 (format "gnus-%s-mode-line-format-spec" where))))
5591 (gnus-tmp-group-name (gnus-group-decoded-name
5592 gnus-newsgroup-name))
5593 (gnus-tmp-article-number (or gnus-current-article 0))
5594 (gnus-tmp-unread gnus-newsgroup-unreads)
5595 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5596 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5597 (gnus-tmp-unread-and-unselected
5598 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5599 (zerop gnus-tmp-unselected))
5601 ((zerop gnus-tmp-unselected)
5602 (format "{%d more}" gnus-tmp-unread-and-unticked))
5603 (t (format "{%d(+%d) more}"
5604 gnus-tmp-unread-and-unticked
5605 gnus-tmp-unselected))))
5607 (if (and gnus-current-headers
5608 (vectorp gnus-current-headers))
5609 (gnus-mode-string-quote
5610 (mail-header-subject gnus-current-headers))
5612 bufname-length max-len
5613 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5614 (setq mode-string (eval mformat))
5615 (setq bufname-length (if (string-match "%b" mode-string)
5618 (if (eq where 'summary)
5620 (get-buffer gnus-article-buffer))))
5623 (setq max-len (max 4 (if gnus-mode-non-string-length
5625 gnus-mode-non-string-length
5627 (length mode-string))))
5628 ;; We might have to chop a bit of the string off...
5629 (when (> (length mode-string) max-len)
5631 (concat (truncate-string-to-width mode-string (- max-len 3))
5633 ;; Pad the mode string a bit.
5634 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5635 ;; Update the mode line.
5636 (setq mode-line-buffer-identification
5637 (gnus-mode-line-buffer-identification (list mode-string)))
5638 (set-buffer-modified-p t))))
5640 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5641 "Go through the HEADERS list and add all Xrefs to a hash table.
5642 The resulting hash table is returned, or nil if no Xrefs were found."
5643 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5644 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5645 (xref-hashtb (gnus-make-hashtable))
5646 start group entry number xrefs header)
5648 (setq header (pop headers))
5649 (when (and (setq xrefs (mail-header-xref header))
5650 (not (memq (setq number (mail-header-number header))
5653 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5654 (setq start (match-end 0))
5655 (setq group (if prefix
5656 (concat prefix (substring xrefs (match-beginning 1)
5658 (substring xrefs (match-beginning 1) (match-end 1))))
5660 (string-to-int (substring xrefs (match-beginning 2)
5662 (if (setq entry (gnus-gethash group xref-hashtb))
5663 (setcdr entry (cons number (cdr entry)))
5664 (gnus-sethash group (cons number nil) xref-hashtb)))))
5665 (and start xref-hashtb)))
5667 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5668 "Look through all the headers and mark the Xrefs as read."
5669 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5670 name info xref-hashtb idlist method nth4)
5672 (set-buffer gnus-group-buffer)
5673 (when (setq xref-hashtb
5674 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5677 (unless (string= from-newsgroup (setq name (symbol-name group)))
5678 (setq idlist (symbol-value group))
5679 ;; Dead groups are not updated.
5681 (setq info (gnus-get-info name))
5682 (when (stringp (setq nth4 (gnus-info-method info)))
5683 (setq nth4 (gnus-server-to-method nth4))))
5684 ;; Only do the xrefs if the group has the same
5685 ;; select method as the group we have just read.
5686 (or (gnus-methods-equal-p
5687 nth4 (gnus-find-method-for-group from-newsgroup))
5689 (equal nth4 (setq method (gnus-find-method-for-group
5691 (and (equal (car nth4) (car method))
5692 (equal (nth 1 nth4) (nth 1 method))))
5693 gnus-use-cross-reference
5694 (or (not (eq gnus-use-cross-reference t))
5696 ;; Only do cross-references on subscribed
5697 ;; groups, if that is what is wanted.
5698 (<= (gnus-info-level info) gnus-level-subscribed))
5699 (gnus-group-make-articles-read name idlist))))
5702 (defun gnus-compute-read-articles (group articles)
5703 (let* ((entry (gnus-group-entry group))
5704 (info (nth 2 entry))
5705 (active (gnus-active group))
5708 ;; First peel off all invalid article numbers.
5710 (let ((ids articles)
5712 (while (setq id (pop ids))
5713 (when (and first (> id (cdr active)))
5714 ;; We'll end up in this situation in one particular
5715 ;; obscure situation. If you re-scan a group and get
5716 ;; a new article that is cross-posted to a different
5717 ;; group that has not been re-scanned, you might get
5718 ;; crossposted article that has a higher number than
5719 ;; Gnus believes possible. So we re-activate this
5720 ;; group as well. This might mean doing the
5721 ;; crossposting thingy will *increase* the number
5722 ;; of articles in some groups. Tsk, tsk.
5723 (setq active (or (gnus-activate-group group) active)))
5724 (when (or (> id (cdr active))
5725 (< id (car active)))
5726 (setq articles (delq id articles))))))
5727 ;; If the read list is nil, we init it.
5729 (null (gnus-info-read info))
5731 (setq ninfo (cons 1 (1- (car active))))
5732 (setq ninfo (gnus-info-read info)))
5733 ;; Then we add the read articles to the range.
5735 ninfo (setq articles (sort articles '<))))))
5737 (defun gnus-group-make-articles-read (group articles)
5738 "Update the info of GROUP to say that ARTICLES are read."
5740 (entry (gnus-group-entry group))
5741 (info (nth 2 entry))
5742 (active (gnus-active group))
5745 (setq range (gnus-compute-read-articles group articles))
5746 (with-current-buffer gnus-group-buffer
5749 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5750 (gnus-info-set-read ',info ',(gnus-info-read info))
5751 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5752 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5753 (gnus-group-update-group ,group t))))
5754 ;; Add the read articles to the range.
5755 (gnus-info-set-read info range)
5756 (gnus-request-set-mark group (list (list range 'add '(read))))
5757 ;; Then we have to re-compute how many unread
5758 ;; articles there are in this group.
5762 (setq num (- (1+ (cdr active)) (car active))))
5763 ((not (listp (cdr range)))
5764 (setq num (- (cdr active) (- (1+ (cdr range))
5768 (if (numberp (car range))
5770 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5771 (setq range (cdr range)))
5772 (setq num (- (cdr active) num))))
5773 ;; Update the number of unread articles.
5775 ;; Update the group buffer.
5776 (unless (gnus-ephemeral-group-p group)
5777 (gnus-group-update-group group t))))))
5779 (defvar gnus-newsgroup-none-id 0)
5781 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5782 (let ((cur nntp-server-buffer)
5785 (with-current-buffer gnus-summary-buffer
5786 gnus-newsgroup-dependencies)))
5787 headers id end ref number
5788 (mail-parse-charset gnus-newsgroup-charset)
5789 (mail-parse-ignored-charsets
5790 (save-excursion (condition-case nil
5791 (set-buffer gnus-summary-buffer)
5793 gnus-newsgroup-ignored-charsets)))
5795 (set-buffer nntp-server-buffer)
5796 ;; Translate all TAB characters into SPACE characters.
5797 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5798 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5799 (ietf-drums-unfold-fws)
5800 (gnus-run-hooks 'gnus-parse-headers-hook)
5801 (let ((case-fold-search t)
5802 in-reply-to header p lines chars)
5803 (goto-char (point-min))
5804 ;; Search to the beginning of the next header. Error messages
5805 ;; do not begin with 2 or 3.
5806 (while (re-search-forward "^[23][0-9]+ " nil t)
5809 ;; This implementation of this function, with nine
5810 ;; search-forwards instead of the one re-search-forward and
5811 ;; a case (which basically was the old function) is actually
5812 ;; about twice as fast, even though it looks messier. You
5813 ;; can't have everything, I guess. Speed and elegance
5814 ;; doesn't always go hand in hand.
5820 (setq number (read cur))
5823 (narrow-to-region (point)
5824 (or (and (search-forward "\n.\n" nil t)
5830 (if (search-forward "\nsubject:" nil t)
5831 (funcall gnus-decode-encoded-word-function
5832 (nnheader-header-value))
5837 (if (search-forward "\nfrom:" nil t)
5838 (funcall gnus-decode-encoded-word-function
5839 (nnheader-header-value))
5844 (if (search-forward "\ndate:" nil t)
5845 (nnheader-header-value) ""))
5849 (setq id (if (re-search-forward
5850 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5851 ;; We do it this way to make sure the Message-ID
5852 ;; is (somewhat) syntactically valid.
5853 (buffer-substring (match-beginning 1)
5855 ;; If there was no message-id, we just fake one
5856 ;; to make subsequent routines simpler.
5857 (nnheader-generate-fake-message-id number))))
5861 (if (search-forward "\nreferences:" nil t)
5865 (nnheader-header-value)
5870 (search-backward ">" end t)
5873 (search-backward "<" end t)
5875 ;; Get the references from the in-reply-to header if there
5876 ;; were no references and the in-reply-to header looks
5878 (if (and (search-forward "\nin-reply-to:" nil t)
5879 (setq in-reply-to (nnheader-header-value))
5880 (string-match "<[^>]+>" in-reply-to))
5882 (setq ref (substring in-reply-to (match-beginning 0)
5884 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5885 (setq ref2 (substring in-reply-to (match-beginning 0)
5887 (when (> (length ref2) (length ref))
5894 (if (search-forward "\nchars: " nil t)
5895 (if (numberp (setq chars (ignore-errors (read cur))))
5901 (if (search-forward "\nlines: " nil t)
5902 (if (numberp (setq lines (ignore-errors (read cur))))
5908 (and (search-forward "\nxref:" nil t)
5909 (nnheader-header-value)))
5911 (when gnus-extra-headers
5912 (let ((extra gnus-extra-headers)
5916 (when (search-forward
5917 (concat "\n" (symbol-name (car extra)) ":") nil t)
5918 (push (cons (car extra) (nnheader-header-value))
5922 (when (equal id ref)
5925 (when gnus-alter-header-function
5926 (funcall gnus-alter-header-function header)
5927 (setq id (mail-header-id header)
5928 ref (gnus-parent-id (mail-header-references header))))
5931 (gnus-dependencies-add-header
5932 header dependencies force-new))
5933 (push header headers))
5934 (goto-char (point-max))
5936 (nreverse headers)))))
5938 ;; Goes through the xover lines and returns a list of vectors
5939 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5940 force-new dependencies
5941 group also-fetch-heads)
5942 "Parse the news overview data in the server buffer.
5943 Return a list of headers that match SEQUENCE (see
5944 `nntp-retrieve-headers')."
5945 ;; Get the Xref when the users reads the articles since most/some
5946 ;; NNTP servers do not include Xrefs when using XOVER.
5947 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5948 (let ((mail-parse-charset gnus-newsgroup-charset)
5949 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5950 (cur nntp-server-buffer)
5951 (dependencies (or dependencies gnus-newsgroup-dependencies))
5953 ((eq gnus-read-all-available-headers t)
5955 ((stringp gnus-read-all-available-headers)
5956 (string-match gnus-read-all-available-headers group))
5959 number headers header)
5961 (set-buffer nntp-server-buffer)
5962 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5963 ;; Allow the user to mangle the headers before parsing them.
5964 (gnus-run-hooks 'gnus-parse-headers-hook)
5965 (goto-char (point-min))
5966 (gnus-parse-without-error
5967 (while (and (or sequence allp)
5969 (setq number (read cur))
5971 (while (and sequence
5972 (< (car sequence) number))
5973 (setq sequence (cdr sequence))))
5976 (eq number (car sequence))))
5978 (setq sequence (cdr sequence))
5979 (setq header (inline
5980 (gnus-nov-parse-line
5981 number dependencies force-new)))))
5982 (push header headers))
5984 ;; A common bug in inn is that if you have posted an article and
5985 ;; then retrieves the active file, it will answer correctly --
5986 ;; the new article is included. However, a NOV entry for the
5987 ;; article may not have been generated yet, so this may fail.
5988 ;; We work around this problem by retrieving the last few
5989 ;; headers using HEAD.
5990 (if (or (not also-fetch-heads)
5992 ;; We (probably) got all the headers.
5994 (let ((gnus-nov-is-evil t))
5997 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5998 (gnus-get-newsgroup-headers))))))))
6000 (defun gnus-article-get-xrefs ()
6001 "Fill in the Xref value in `gnus-current-headers', if necessary.
6002 This is meant to be called in `gnus-article-internal-prepare-hook'."
6003 (let ((headers (with-current-buffer gnus-summary-buffer
6004 gnus-current-headers)))
6005 (or (not gnus-use-cross-reference)
6007 (and (mail-header-xref headers)
6008 (not (string= (mail-header-xref headers) "")))
6009 (let ((case-fold-search t)
6012 (nnheader-narrow-to-headers)
6013 (goto-char (point-min))
6014 (when (or (and (not (eobp))
6015 (eq (downcase (char-after)) ?x)
6016 (looking-at "Xref:"))
6017 (search-forward "\nXref:" nil t))
6018 (goto-char (1+ (match-end 0)))
6019 (setq xref (buffer-substring (point) (point-at-eol)))
6020 (mail-header-set-xref headers xref)))))))
6022 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6023 "Find article ID and insert the summary line for that article.
6024 OLD-HEADER can either be a header or a line number to insert
6025 the subject line on."
6026 (let* ((line (and (numberp old-header) old-header))
6027 (old-header (and (vectorp old-header) old-header))
6028 (header (cond ((and old-header use-old-header)
6031 (gnus-number-to-header id))
6032 (gnus-number-to-header id))
6034 (gnus-read-header id))))
6035 (number (and (numberp id) id))
6038 ;; Rebuild the thread that this article is part of and go to the
6039 ;; article we have fetched.
6040 (when (and (not gnus-show-threads)
6043 (setq d (gnus-data-find (mail-header-number old-header))))
6044 (goto-char (gnus-data-pos d))
6050 (gnus-delete-line))))))
6052 (mail-header-set-number header (mail-header-number old-header)))
6053 (setq gnus-newsgroup-sparse
6054 (delq (setq number (mail-header-number header))
6055 gnus-newsgroup-sparse))
6056 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6057 (push number gnus-newsgroup-limit)
6058 (gnus-rebuild-thread (mail-header-id header) line)
6059 (gnus-summary-goto-subject number nil t))
6060 (when (and (numberp number)
6062 ;; We have to update the boundaries even if we can't fetch the
6063 ;; article if ID is a number -- so that the next `P' or `N'
6064 ;; command will fetch the previous (or next) article even
6065 ;; if the one we tried to fetch this time has been canceled.
6066 (when (> number gnus-newsgroup-end)
6067 (setq gnus-newsgroup-end number))
6068 (when (< number gnus-newsgroup-begin)
6069 (setq gnus-newsgroup-begin number))
6070 (setq gnus-newsgroup-unselected
6071 (delq number gnus-newsgroup-unselected)))
6072 ;; Report back a success?
6073 (and header (mail-header-number header))))
6075 ;;; Process/prefix in the summary buffer
6077 (defun gnus-summary-work-articles (n)
6078 "Return a list of articles to be worked upon.
6079 The prefix argument, the list of process marked articles, and the
6080 current article will be taken into consideration."
6082 (set-buffer gnus-summary-buffer)
6085 ;; A numerical prefix has been given.
6086 (setq n (prefix-numeric-value n))
6087 (let ((backward (< n 0))
6088 (n (abs (prefix-numeric-value n)))
6093 (push (setq article (gnus-summary-article-number))
6096 (gnus-summary-find-prev nil article)
6097 (gnus-summary-find-next nil article)))
6099 (nreverse articles)))
6100 ((and (gnus-region-active-p) (mark))
6101 (message "region active")
6102 ;; Work on the region between point and mark.
6103 (let ((max (max (point) (mark)))
6106 (goto-char (min (min (point) (mark))))
6109 (push (setq article (gnus-summary-article-number)) articles)
6110 (gnus-summary-find-next nil article)
6112 (nreverse articles))))
6113 (gnus-newsgroup-processable
6114 ;; There are process-marked articles present.
6115 ;; Save current state.
6116 (gnus-summary-save-process-mark)
6118 (reverse gnus-newsgroup-processable))
6120 ;; Just return the current article.
6121 (list (gnus-summary-article-number))))))
6123 (defmacro gnus-summary-iterate (arg &rest forms)
6124 "Iterate over the process/prefixed articles and do FORMS.
6125 ARG is the interactive prefix given to the command. FORMS will be
6126 executed with point over the summary line of the articles."
6127 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6128 `(let ((,articles (gnus-summary-work-articles ,arg)))
6130 (gnus-summary-goto-subject (car ,articles))
6134 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6135 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6137 (defun gnus-summary-save-process-mark ()
6138 "Push the current set of process marked articles on the stack."
6140 (push (copy-sequence gnus-newsgroup-processable)
6141 gnus-newsgroup-process-stack))
6143 (defun gnus-summary-kill-process-mark ()
6144 "Push the current set of process marked articles on the stack and unmark."
6146 (gnus-summary-save-process-mark)
6147 (gnus-summary-unmark-all-processable))
6149 (defun gnus-summary-yank-process-mark ()
6150 "Pop the last process mark state off the stack and restore it."
6152 (unless gnus-newsgroup-process-stack
6153 (error "Empty mark stack"))
6154 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6156 (defun gnus-summary-process-mark-set (set)
6157 "Make SET into the current process marked articles."
6158 (gnus-summary-unmark-all-processable)
6160 (gnus-summary-set-process-mark (pop set))))
6162 ;;; Searching and stuff
6164 (defun gnus-summary-search-group (&optional backward use-level)
6165 "Search for next unread newsgroup.
6166 If optional argument BACKWARD is non-nil, search backward instead."
6168 (set-buffer gnus-group-buffer)
6169 (when (gnus-group-search-forward
6170 backward nil (if use-level (gnus-group-group-level) nil))
6171 (gnus-group-group-name))))
6173 (defun gnus-summary-best-group (&optional exclude-group)
6174 "Find the name of the best unread group.
6175 If EXCLUDE-GROUP, do not go to this group."
6176 (with-current-buffer gnus-group-buffer
6178 (gnus-group-best-unread-group exclude-group))))
6180 (defun gnus-summary-find-next (&optional unread article backward)
6182 (gnus-summary-find-prev unread article)
6183 (let* ((dummy (gnus-summary-article-intangible-p))
6184 (article (or article (gnus-summary-article-number)))
6185 (data (gnus-data-find-list article))
6187 (when (and (not dummy)
6188 (or (not gnus-summary-check-current)
6190 (not (gnus-data-unread-p (car data)))))
6191 (setq data (cdr data)))
6196 (unless (memq (gnus-data-number (car data))
6198 ((eq gnus-auto-goto-ignores
6199 'always-undownloaded)
6200 gnus-newsgroup-undownloaded)
6203 ((eq gnus-auto-goto-ignores
6205 gnus-newsgroup-unfetched)
6206 ((eq gnus-auto-goto-ignores
6208 gnus-newsgroup-undownloaded)))
6209 (when (gnus-data-unread-p (car data))
6210 (setq result (car data)
6212 (setq data (cdr data)))
6215 (goto-char (gnus-data-pos result))
6216 (gnus-data-number result)))))
6218 (defun gnus-summary-find-prev (&optional unread article)
6219 (let* ((eobp (eobp))
6220 (article (or article (gnus-summary-article-number)))
6221 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6223 (when (and (not eobp)
6224 (or (not gnus-summary-check-current)
6226 (not (gnus-data-unread-p (car data)))))
6227 (setq data (cdr data)))
6232 (unless (memq (gnus-data-number (car data))
6234 ((eq gnus-auto-goto-ignores
6235 'always-undownloaded)
6236 gnus-newsgroup-undownloaded)
6239 ((eq gnus-auto-goto-ignores
6241 gnus-newsgroup-unfetched)
6242 ((eq gnus-auto-goto-ignores
6244 gnus-newsgroup-undownloaded)))
6245 (when (gnus-data-unread-p (car data))
6246 (setq result (car data)
6248 (setq data (cdr data)))
6251 (goto-char (gnus-data-pos result))
6252 (gnus-data-number result))))
6254 (defun gnus-summary-find-subject (subject &optional unread backward article)
6255 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6256 (article (or article (gnus-summary-article-number)))
6257 (articles (gnus-data-list backward))
6258 (arts (gnus-data-find-list article articles))
6260 (when (or (not gnus-summary-check-current)
6262 (not (gnus-data-unread-p (car arts))))
6263 (setq arts (cdr arts)))
6265 (and (or (not unread)
6266 (gnus-data-unread-p (car arts)))
6267 (vectorp (gnus-data-header (car arts)))
6269 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6270 (setq result (car arts)
6272 (setq arts (cdr arts)))
6274 (goto-char (gnus-data-pos result))
6275 (gnus-data-number result))))
6277 (defun gnus-summary-search-forward (&optional unread subject backward)
6278 "Search forward for an article.
6279 If UNREAD, look for unread articles. If SUBJECT, look for
6280 articles with that subject. If BACKWARD, search backward instead."
6281 (cond (subject (gnus-summary-find-subject subject unread backward))
6282 (backward (gnus-summary-find-prev unread))
6283 (t (gnus-summary-find-next unread))))
6285 (defun gnus-recenter (&optional n)
6286 "Center point in window and redisplay frame.
6287 Also do horizontal recentering."
6289 (when (and gnus-auto-center-summary
6290 (not (eq gnus-auto-center-summary 'vertical)))
6291 (gnus-horizontal-recenter))
6294 (defun gnus-summary-recenter ()
6295 "Center point in the summary window.
6296 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6297 displayed, no centering will be performed."
6298 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6299 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6301 ;; The user has to want it.
6302 (when gnus-auto-center-summary
6303 (let* ((top (cond ((< (window-height) 4) 0)
6304 ((< (window-height) 7) 1)
6305 (t (if (numberp gnus-auto-center-summary)
6306 gnus-auto-center-summary
6307 (/ (1- (window-height)) 2)))))
6308 (height (1- (window-height)))
6309 (bottom (save-excursion (goto-char (point-max))
6310 (forward-line (- height))
6312 (window (get-buffer-window (current-buffer))))
6313 (when (get-buffer-window gnus-article-buffer)
6314 ;; Only do recentering when the article buffer is displayed,
6315 ;; Set the window start to either `bottom', which is the biggest
6316 ;; possible valid number, or the second line from the top,
6317 ;; whichever is the least.
6318 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6319 (if (> bottom top-pos)
6320 ;; Keep the second line from the top visible
6321 (set-window-start window top-pos t)
6322 ;; Try to keep the bottom line visible; if it's partially
6323 ;; obscured, either scroll one more line to make it fully
6324 ;; visible, or revert to using TOP-POS.
6326 (goto-char (point-max))
6328 (let ((last-line-start (point)))
6330 (set-window-start window (point) t)
6331 (when (not (pos-visible-in-window-p last-line-start window))
6333 (set-window-start window (min (point) top-pos) t)))))))
6334 ;; Do horizontal recentering while we're at it.
6335 (when (and (get-buffer-window (current-buffer) t)
6336 (not (eq gnus-auto-center-summary 'vertical)))
6337 (let ((selected (selected-window)))
6338 (select-window (get-buffer-window (current-buffer) t))
6339 (gnus-summary-position-point)
6340 (gnus-horizontal-recenter)
6341 (select-window selected))))))
6343 (defun gnus-summary-jump-to-group (newsgroup)
6344 "Move point to NEWSGROUP in group mode buffer."
6345 ;; Keep update point of group mode buffer if visible.
6346 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6347 (save-window-excursion
6348 ;; Take care of tree window mode.
6349 (when (get-buffer-window gnus-group-buffer)
6350 (pop-to-buffer gnus-group-buffer))
6351 (gnus-group-jump-to-group newsgroup))
6353 ;; Take care of tree window mode.
6354 (if (get-buffer-window gnus-group-buffer)
6355 (pop-to-buffer gnus-group-buffer)
6356 (set-buffer gnus-group-buffer))
6357 (gnus-group-jump-to-group newsgroup))))
6359 ;; This function returns a list of article numbers based on the
6360 ;; difference between the ranges of read articles in this group and
6361 ;; the range of active articles.
6362 (defun gnus-list-of-unread-articles (group)
6363 (let* ((read (gnus-info-read (gnus-get-info group)))
6364 (active (or (gnus-active group) (gnus-activate-group group)))
6367 ;; If none are read, then all are unread.
6369 (setq first (car active))
6370 ;; If the range of read articles is a single range, then the
6371 ;; first unread article is the article after the last read
6372 ;; article. Sounds logical, doesn't it?
6373 (if (and (not (listp (cdr read)))
6374 (or (< (car read) (car active))
6375 (progn (setq read (list read))
6377 (setq first (max (car active) (1+ (cdr read))))
6378 ;; `read' is a list of ranges.
6379 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6382 (setq first (car active)))
6385 (while (< first nlast)
6386 (setq unread (cons first unread)
6388 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6389 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6390 (setq read (cdr read)))))
6391 ;; And add the last unread articles.
6392 (while (<= first last)
6393 (setq unread (cons first unread)
6395 ;; Return the list of unread articles.
6396 (delq 0 (nreverse unread))))
6398 (defun gnus-list-of-read-articles (group)
6399 "Return a list of unread, unticked and non-dormant articles."
6400 (let* ((info (gnus-get-info group))
6401 (marked (gnus-info-marks info))
6402 (active (gnus-active group)))
6404 (gnus-list-range-difference
6405 (gnus-list-range-difference
6406 (gnus-sorted-complement
6407 (gnus-uncompress-range active)
6408 (gnus-list-of-unread-articles group))
6409 (cdr (assq 'dormant marked)))
6410 (cdr (assq 'tick marked))))))
6412 ;; This function returns a sequence of article numbers based on the
6413 ;; difference between the ranges of read articles in this group and
6414 ;; the range of active articles.
6415 (defun gnus-sequence-of-unread-articles (group)
6416 (let* ((read (gnus-info-read (gnus-get-info group)))
6417 (active (or (gnus-active group) (gnus-activate-group group)))
6420 ;; If none are read, then all are unread.
6422 (setq first (car active))
6423 ;; If the range of read articles is a single range, then the
6424 ;; first unread article is the article after the last read
6425 ;; article. Sounds logical, doesn't it?
6426 (if (and (not (listp (cdr read)))
6427 (or (< (car read) (car active))
6428 (progn (setq read (list read))
6430 (setq first (max (car active) (1+ (cdr read))))
6431 ;; `read' is a list of ranges.
6432 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6435 (setq first (car active)))
6438 (push (cons first nlast) unread))
6439 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6440 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6441 (setq read (cdr read)))))
6442 ;; And add the last unread articles.
6443 (cond ((< first last)
6444 (push (cons first last) unread))
6446 (push first unread)))
6447 ;; Return the sequence of unread articles.
6448 (delq 0 (nreverse unread))))
6450 ;; Various summary commands
6452 (defun gnus-summary-select-article-buffer ()
6453 "Reconfigure windows to show article buffer."
6455 (if (not (gnus-buffer-live-p gnus-article-buffer))
6456 (error "There is no article buffer for this summary buffer")
6457 (gnus-configure-windows 'article)
6458 (select-window (get-buffer-window gnus-article-buffer))))
6460 (defun gnus-summary-universal-argument (arg)
6461 "Perform any operation on all articles that are process/prefixed."
6463 (let ((articles (gnus-summary-work-articles arg))
6470 (substitute-command-keys
6471 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6473 (gnus-error 1 "Undefined key")
6476 (gnus-summary-goto-subject (setq article (pop articles)))
6477 (let (gnus-newsgroup-processable)
6478 (command-execute func))
6479 (gnus-summary-remove-process-mark article)))))
6480 (gnus-summary-position-point))
6482 (defun gnus-summary-toggle-truncation (&optional arg)
6483 "Toggle truncation of summary lines.
6484 With ARG, turn line truncation on if ARG is positive."
6486 (setq truncate-lines
6487 (if (null arg) (not truncate-lines)
6488 (> (prefix-numeric-value arg) 0)))
6491 (defun gnus-summary-find-for-reselect ()
6492 "Return the number of an article to stay on across a reselect.
6493 The current article is considered, then following articles, then previous
6494 articles. An article is sought which is not cancelled and isn't a temporary
6495 insertion from another group. If there's no such then return a dummy 0."
6497 (dolist (rev '(nil t))
6498 (unless found ; don't demand the reverse list if we don't need it
6499 (let ((data (gnus-data-find-list
6500 (gnus-summary-article-number) (gnus-data-list rev))))
6501 (while (and data (not found))
6502 (if (and (< 0 (gnus-data-number (car data)))
6503 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6504 (setq found (gnus-data-number (car data))))
6505 (setq data (cdr data))))))
6508 (defun gnus-summary-reselect-current-group (&optional all rescan)
6509 "Exit and then reselect the current newsgroup.
6510 The prefix argument ALL means to select all articles."
6512 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6513 (error "Ephemeral groups can't be reselected"))
6514 (let ((current-subject (gnus-summary-find-for-reselect))
6515 (group gnus-newsgroup-name))
6516 (setq gnus-newsgroup-begin nil)
6517 (gnus-summary-exit nil 'leave-hidden)
6518 ;; We have to adjust the point of group mode buffer because
6519 ;; point was moved to the next unread newsgroup by exiting.
6520 (gnus-summary-jump-to-group group)
6523 (gnus-group-get-new-news-this-group 1)))
6524 (gnus-group-read-group all t)
6525 (gnus-summary-goto-subject current-subject nil t)))
6527 (defun gnus-summary-rescan-group (&optional all)
6528 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6530 (gnus-summary-reselect-current-group all t))
6532 (defun gnus-summary-update-info (&optional non-destructive)
6534 (let ((group gnus-newsgroup-name))
6536 (when gnus-newsgroup-kill-headers
6537 (setq gnus-newsgroup-killed
6538 (gnus-compress-sequence
6540 (gnus-list-range-intersection
6541 gnus-newsgroup-unselected gnus-newsgroup-killed)
6542 gnus-newsgroup-unreads)
6544 (unless (listp (cdr gnus-newsgroup-killed))
6545 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6546 (let ((headers gnus-newsgroup-headers))
6547 ;; Set the new ranges of read articles.
6548 (with-current-buffer gnus-group-buffer
6549 (gnus-undo-force-boundary))
6550 (gnus-update-read-articles
6551 group (gnus-sorted-union
6552 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6553 ;; Set the current article marks.
6554 (let ((gnus-newsgroup-scored
6555 (if (and (not gnus-save-score)
6556 (not non-destructive))
6558 gnus-newsgroup-scored)))
6560 (gnus-update-marks)))
6561 ;; Do the cross-ref thing.
6562 (when gnus-use-cross-reference
6563 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6564 ;; Do not switch windows but change the buffer to work.
6565 (set-buffer gnus-group-buffer)
6566 (unless (gnus-ephemeral-group-p group)
6567 (gnus-group-update-group group)))))))
6569 (defun gnus-summary-save-newsrc (&optional force)
6570 "Save the current number of read/marked articles in the dribble buffer.
6571 The dribble buffer will then be saved.
6572 If FORCE (the prefix), also save the .newsrc file(s)."
6574 (gnus-summary-update-info t)
6576 (gnus-save-newsrc-file)
6577 (gnus-dribble-save)))
6579 (defun gnus-summary-exit (&optional temporary leave-hidden)
6580 "Exit reading current newsgroup, and then return to group selection mode.
6581 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6583 (gnus-set-global-variables)
6584 (when (gnus-buffer-live-p gnus-article-buffer)
6586 (set-buffer gnus-article-buffer)
6587 (mm-destroy-parts gnus-article-mime-handles)
6588 ;; Set it to nil for safety reason.
6589 (setq gnus-article-mime-handle-alist nil)
6590 (setq gnus-article-mime-handles nil)))
6591 (gnus-kill-save-kill-buffer)
6592 (gnus-async-halt-prefetch)
6593 (let* ((group gnus-newsgroup-name)
6594 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6595 (gnus-group-is-exiting-p t)
6598 (buf (current-buffer)))
6600 ;; Do adaptive scoring, and possibly save score files.
6601 (when gnus-newsgroup-adaptive
6602 (gnus-score-adaptive))
6603 (when gnus-use-scoring
6605 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6606 ;; If we have several article buffers, we kill them at exit.
6607 (unless gnus-single-article-buffer
6608 (gnus-kill-buffer gnus-original-article-buffer)
6609 (setq gnus-article-current nil))
6610 (when gnus-use-cache
6611 (gnus-cache-possibly-remove-articles)
6612 (gnus-cache-save-buffers))
6613 (gnus-async-prefetch-remove-group group)
6614 (when gnus-suppress-duplicates
6615 (gnus-dup-enter-articles))
6616 (when gnus-use-trees
6617 (gnus-tree-close group))
6618 (when gnus-use-cache
6619 (gnus-cache-write-active))
6620 ;; Remove entries for this group.
6621 (nnmail-purge-split-history (gnus-group-real-name group))
6622 ;; Make all changes in this group permanent.
6624 (gnus-run-hooks 'gnus-exit-group-hook)
6625 (gnus-summary-update-info))
6626 (gnus-close-group group)
6627 ;; Make sure where we were, and go to next newsgroup.
6628 (set-buffer gnus-group-buffer)
6630 (gnus-group-jump-to-group group))
6631 (gnus-run-hooks 'gnus-summary-exit-hook)
6632 (unless (or quit-config
6633 ;; If this group has disappeared from the summary
6634 ;; buffer, don't skip forwards.
6635 (not (string= group (gnus-group-group-name))))
6636 (gnus-group-next-unread-group 1))
6637 (setq group-point (point))
6640 ;; If we have several article buffers, we kill them at exit.
6641 (unless gnus-single-article-buffer
6642 (gnus-kill-buffer gnus-article-buffer)
6643 (gnus-kill-buffer gnus-original-article-buffer)
6644 (setq gnus-article-current nil))
6646 (if (not gnus-kill-summary-on-exit)
6648 (gnus-deaden-summary)
6650 ;; We set all buffer-local variables to nil. It is unclear why
6651 ;; this is needed, but if we don't, buffer-local variables are
6652 ;; not garbage-collected, it seems. This would the lead to en
6653 ;; ever-growing Emacs.
6654 (gnus-summary-clear-local-variables)
6655 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6656 (gnus-summary-clear-local-variables))
6657 (when (get-buffer gnus-article-buffer)
6658 (bury-buffer gnus-article-buffer))
6659 ;; We clear the global counterparts of the buffer-local
6660 ;; variables as well, just to be on the safe side.
6661 (set-buffer gnus-group-buffer)
6662 (gnus-summary-clear-local-variables)
6663 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6664 (gnus-summary-clear-local-variables))
6665 ;; Return to group mode buffer.
6666 (when (eq mode 'gnus-summary-mode)
6667 (gnus-kill-buffer buf)))
6668 (setq gnus-current-select-method gnus-select-method)
6670 (set-buffer gnus-group-buffer)
6671 (pop-to-buffer gnus-group-buffer))
6672 (if (not quit-config)
6674 (goto-char group-point)
6675 (unless leave-hidden
6676 (gnus-configure-windows 'group 'force)))
6677 (gnus-handle-ephemeral-exit quit-config))
6678 ;; Clear the current group name.
6680 (setq gnus-newsgroup-name nil)))))
6682 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6683 (defun gnus-summary-exit-no-update (&optional no-questions)
6684 "Quit reading current newsgroup without updating read article info."
6686 (let* ((group gnus-newsgroup-name)
6687 (gnus-group-is-exiting-p t)
6688 (gnus-group-is-exiting-without-update-p t)
6689 (quit-config (gnus-group-quit-config group)))
6690 (when (or no-questions
6692 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6693 (gnus-async-halt-prefetch)
6694 (run-hooks 'gnus-summary-prepare-exit-hook)
6695 (when (gnus-buffer-live-p gnus-article-buffer)
6697 (set-buffer gnus-article-buffer)
6698 (mm-destroy-parts gnus-article-mime-handles)
6699 ;; Set it to nil for safety reason.
6700 (setq gnus-article-mime-handle-alist nil)
6701 (setq gnus-article-mime-handles nil)))
6702 ;; If we have several article buffers, we kill them at exit.
6703 (unless gnus-single-article-buffer
6704 (gnus-kill-buffer gnus-article-buffer)
6705 (gnus-kill-buffer gnus-original-article-buffer)
6706 (setq gnus-article-current nil))
6707 (if (not gnus-kill-summary-on-exit)
6708 (gnus-deaden-summary)
6709 (gnus-close-group group)
6710 (gnus-summary-clear-local-variables)
6711 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6712 (gnus-summary-clear-local-variables))
6713 (set-buffer gnus-group-buffer)
6714 (gnus-summary-clear-local-variables)
6715 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6716 (gnus-summary-clear-local-variables))
6717 (gnus-kill-buffer gnus-summary-buffer))
6718 (unless gnus-single-article-buffer
6719 (setq gnus-article-current nil))
6720 (when gnus-use-trees
6721 (gnus-tree-close group))
6722 (gnus-async-prefetch-remove-group group)
6723 (when (get-buffer gnus-article-buffer)
6724 (bury-buffer gnus-article-buffer))
6725 ;; Return to the group buffer.
6726 (gnus-configure-windows 'group 'force)
6727 ;; Clear the current group name.
6728 (setq gnus-newsgroup-name nil)
6729 (unless (gnus-ephemeral-group-p group)
6730 (gnus-group-update-group group))
6731 (when (equal (gnus-group-group-name) group)
6732 (gnus-group-next-unread-group 1))
6734 (gnus-handle-ephemeral-exit quit-config)))))
6736 (defun gnus-handle-ephemeral-exit (quit-config)
6737 "Handle movement when leaving an ephemeral group.
6738 The state which existed when entering the ephemeral is reset."
6739 (if (not (buffer-name (car quit-config)))
6740 (gnus-configure-windows 'group 'force)
6741 (set-buffer (car quit-config))
6742 (cond ((eq major-mode 'gnus-summary-mode)
6743 (gnus-set-global-variables))
6744 ((eq major-mode 'gnus-article-mode)
6746 ;; The `gnus-summary-buffer' variable may point
6747 ;; to the old summary buffer when using a single
6749 (unless (gnus-buffer-live-p gnus-summary-buffer)
6750 (set-buffer gnus-group-buffer))
6751 (set-buffer gnus-summary-buffer)
6752 (gnus-set-global-variables))))
6753 (if (or (eq (cdr quit-config) 'article)
6754 (eq (cdr quit-config) 'pick))
6756 ;; The current article may be from the ephemeral group
6757 ;; thus it is best that we reload this article
6759 ;; If we're exiting from a large digest, this can be
6760 ;; extremely slow. So, it's better not to reload it. -- jh.
6761 ;;(gnus-summary-show-article)
6762 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6763 (gnus-configure-windows 'pick 'force)
6764 (gnus-configure-windows (cdr quit-config) 'force)))
6765 (gnus-configure-windows (cdr quit-config) 'force))
6766 (when (eq major-mode 'gnus-summary-mode)
6767 (gnus-summary-next-subject 1 nil t)
6768 (gnus-summary-recenter)
6769 (gnus-summary-position-point))))
6773 (defvar gnus-dead-summary-mode-map nil)
6775 (unless gnus-dead-summary-mode-map
6776 (setq gnus-dead-summary-mode-map (make-keymap))
6777 (suppress-keymap gnus-dead-summary-mode-map)
6778 (substitute-key-definition
6779 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6780 (dolist (key '("\C-d" "\r" "\177" [delete]))
6781 (define-key gnus-dead-summary-mode-map
6782 key 'gnus-summary-wake-up-the-dead))
6783 (dolist (key '("q" "Q"))
6784 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6786 (defvar gnus-dead-summary-mode nil
6787 "Minor mode for Gnus summary buffers.")
6789 (defun gnus-dead-summary-mode (&optional arg)
6790 "Minor mode for Gnus summary buffers."
6792 (when (eq major-mode 'gnus-summary-mode)
6793 (make-local-variable 'gnus-dead-summary-mode)
6794 (setq gnus-dead-summary-mode
6795 (if (null arg) (not gnus-dead-summary-mode)
6796 (> (prefix-numeric-value arg) 0)))
6797 (when gnus-dead-summary-mode
6799 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6801 (defun gnus-deaden-summary ()
6802 "Make the current summary buffer into a dead summary buffer."
6803 ;; Kill any previous dead summary buffer.
6804 (when (and gnus-dead-summary
6805 (buffer-name gnus-dead-summary))
6806 (with-current-buffer gnus-dead-summary
6807 (when gnus-dead-summary-mode
6808 (kill-buffer (current-buffer)))))
6809 ;; Make this the current dead summary.
6810 (setq gnus-dead-summary (current-buffer))
6811 (gnus-dead-summary-mode 1)
6812 (let ((name (buffer-name)))
6813 (when (string-match "Summary" name)
6815 (concat (substring name 0 (match-beginning 0)) "Dead "
6816 (substring name (match-beginning 0)))
6820 (defun gnus-kill-or-deaden-summary (buffer)
6821 "Kill or deaden the summary BUFFER."
6823 (when (and (buffer-name buffer)
6824 (not gnus-single-article-buffer))
6825 (with-current-buffer buffer
6826 (gnus-kill-buffer gnus-article-buffer)
6827 (gnus-kill-buffer gnus-original-article-buffer)))
6830 (gnus-kill-summary-on-exit
6831 (when (and gnus-use-trees
6832 (gnus-buffer-exists-p buffer))
6835 (gnus-tree-close gnus-newsgroup-name)))
6836 (gnus-kill-buffer buffer))
6837 ;; Deaden the buffer.
6838 ((gnus-buffer-exists-p buffer)
6841 (gnus-deaden-summary))))))
6843 (defun gnus-summary-wake-up-the-dead (&rest args)
6844 "Wake up the dead summary buffer."
6846 (gnus-dead-summary-mode -1)
6847 (let ((name (buffer-name)))
6848 (when (string-match "Dead " name)
6850 (concat (substring name 0 (match-beginning 0))
6851 (substring name (match-end 0)))
6853 (gnus-message 3 "This dead summary is now alive again"))
6855 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6856 (defun gnus-summary-fetch-faq (&optional faq-dir)
6857 "Fetch the FAQ for the current group.
6858 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6862 (when current-prefix-arg
6864 "FAQ dir: " (and (listp gnus-group-faq-directory)
6866 gnus-group-faq-directory))))))
6867 (let (gnus-faq-buffer)
6868 (when (setq gnus-faq-buffer
6869 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6870 (gnus-configure-windows 'summary-faq))))
6872 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6873 (defun gnus-summary-describe-group (&optional force)
6874 "Describe the current newsgroup."
6876 (gnus-group-describe-group force gnus-newsgroup-name))
6878 (defun gnus-summary-describe-briefly ()
6879 "Describe summary mode commands briefly."
6881 (gnus-message 6 (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")))
6883 ;; Walking around group mode buffer from summary mode.
6885 (defun gnus-summary-next-group (&optional no-article target-group backward)
6886 "Exit current newsgroup and then select next unread newsgroup.
6887 If prefix argument NO-ARTICLE is non-nil, no article is selected
6888 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6889 previous group instead."
6891 ;; Stop pre-fetching.
6892 (gnus-async-halt-prefetch)
6893 (let ((current-group gnus-newsgroup-name)
6894 (current-buffer (current-buffer))
6896 ;; First we semi-exit this group to update Xrefs and all variables.
6897 ;; We can't do a real exit, because the window conf must remain
6898 ;; the same in case the user is prompted for info, and we don't
6899 ;; want the window conf to change before that...
6900 (gnus-summary-exit t)
6901 (while (not entered)
6902 ;; Then we find what group we are supposed to enter.
6903 (set-buffer gnus-group-buffer)
6904 (gnus-group-jump-to-group current-group)
6907 (if (eq gnus-keep-same-level 'best)
6908 (gnus-summary-best-group gnus-newsgroup-name)
6909 (gnus-summary-search-group backward gnus-keep-same-level))))
6910 (if (not target-group)
6911 ;; There are no further groups, so we return to the group
6914 (gnus-message 5 "Returning to the group buffer")
6916 (when (gnus-buffer-live-p current-buffer)
6917 (set-buffer current-buffer)
6918 (gnus-summary-exit))
6919 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6920 ;; We try to enter the target group.
6921 (gnus-group-jump-to-group target-group)
6922 (let ((unreads (gnus-group-group-unread)))
6923 (if (and (or (eq t unreads)
6924 (and unreads (not (zerop unreads))))
6925 (gnus-summary-read-group
6926 target-group nil no-article
6927 (and (buffer-name current-buffer) current-buffer)
6930 (setq current-group target-group
6931 target-group nil)))))))
6933 (defun gnus-summary-prev-group (&optional no-article)
6934 "Exit current newsgroup and then select previous unread newsgroup.
6935 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6937 (gnus-summary-next-group no-article nil t))
6939 ;; Walking around summary lines.
6941 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6942 "Go to the first subject satisfying any non-nil constraint.
6943 If UNREAD is non-nil, the article should be unread.
6944 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6945 If UNSEEN is non-nil, the article should be unseen.
6946 Returns the article selected or nil if there are no matching articles."
6950 ((null gnus-newsgroup-data)
6951 (gnus-message 3 "No articles in the group")
6953 ;; Pick the first article.
6954 ((not (or unread undownloaded unseen))
6955 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6956 (gnus-data-number (car gnus-newsgroup-data)))
6957 ;; Find the first unread article.
6959 (let ((data gnus-newsgroup-data))
6961 (let ((num (gnus-data-number (car data))))
6962 (or (memq num gnus-newsgroup-unfetched)
6963 (not (or (and unread
6964 (memq num gnus-newsgroup-unreads))
6966 (memq num gnus-newsgroup-undownloaded))
6968 (memq num gnus-newsgroup-unseen)))))))
6969 (setq data (cdr data)))
6973 (goto-char (gnus-data-pos (car data)))
6974 (gnus-data-number (car data)))
6975 (gnus-message 3 "No more%s articles"
6976 (let* ((r (when unread " unread"))
6977 (d (when undownloaded " undownloaded"))
6978 (s (when unseen " unseen"))
6979 (l (delq nil (list r d s))))
6980 (cond ((= 3 (length l))
6981 (concat r "," d ", or" s))
6983 (concat (car l) ", or" (cadr l)))
6990 (gnus-summary-position-point))))))
6992 (defun gnus-summary-next-subject (n &optional unread dont-display)
6993 "Go to next N'th summary line.
6994 If N is negative, go to the previous N'th subject line.
6995 If UNREAD is non-nil, only unread articles are selected.
6996 The difference between N and the actual number of steps taken is
6999 (let ((backward (< n 0))
7003 (gnus-summary-find-prev unread)
7004 (gnus-summary-find-next unread)))
7005 (unless (zerop (setq n (1- n)))
7006 (gnus-summary-show-thread)))
7008 (gnus-message 7 "No more%s articles"
7009 (if unread " unread" "")))
7010 (unless dont-display
7011 (gnus-summary-recenter)
7012 (gnus-summary-position-point))
7015 (defun gnus-summary-next-unread-subject (n)
7016 "Go to next N'th unread summary line."
7018 (gnus-summary-next-subject n t))
7020 (defun gnus-summary-prev-subject (n &optional unread)
7021 "Go to previous N'th summary line.
7022 If optional argument UNREAD is non-nil, only unread article is selected."
7024 (gnus-summary-next-subject (- n) unread))
7026 (defun gnus-summary-prev-unread-subject (n)
7027 "Go to previous N'th unread summary line."
7029 (gnus-summary-next-subject (- n) t))
7031 (defun gnus-summary-goto-subjects (articles)
7032 "Insert the subject header for ARTICLES in the current buffer."
7034 (dolist (article articles)
7035 (gnus-summary-goto-subject article t)))
7036 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7037 (gnus-summary-position-point))
7039 (defun gnus-summary-goto-subject (article &optional force silent)
7040 "Go the subject line of ARTICLE.
7041 If FORCE, also allow jumping to articles not currently shown."
7042 (interactive "nArticle number: ")
7043 (unless (numberp article)
7044 (error "Article %s is not a number" article))
7046 (data (gnus-data-find article)))
7047 ;; We read in the article if we have to.
7050 (gnus-summary-insert-subject
7052 (if (or (numberp force) (vectorp force)) force)
7054 (setq data (gnus-data-find article)))
7059 (gnus-message 3 "Can't find article %d" article))
7061 (let ((pt (gnus-data-pos data)))
7063 (gnus-summary-set-article-display-arrow pt))
7064 (gnus-summary-position-point)
7067 ;; Walking around summary lines with displaying articles.
7069 (defun gnus-summary-expand-window (&optional arg)
7070 "Make the summary buffer take up the entire Emacs frame.
7071 Given a prefix, will force an `article' buffer configuration."
7074 (gnus-configure-windows 'article 'force)
7075 (gnus-configure-windows 'summary 'force)))
7077 (defun gnus-summary-display-article (article &optional all-header)
7078 "Display ARTICLE in article buffer."
7079 (when (gnus-buffer-live-p gnus-article-buffer)
7080 (with-current-buffer gnus-article-buffer
7081 (mm-enable-multibyte)))
7082 (gnus-set-global-variables)
7083 (when (gnus-buffer-live-p gnus-article-buffer)
7084 (with-current-buffer gnus-article-buffer
7085 (setq gnus-article-charset gnus-newsgroup-charset)
7086 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7087 (mm-enable-multibyte)))
7091 (if gnus-summary-display-article-function
7092 (funcall gnus-summary-display-article-function article all-header)
7093 (gnus-article-prepare article all-header))
7094 (gnus-run-hooks 'gnus-select-article-hook)
7095 (when (and gnus-current-article
7096 (not (zerop gnus-current-article)))
7097 (gnus-summary-goto-subject gnus-current-article))
7098 (gnus-summary-recenter)
7099 (when (and gnus-use-trees gnus-show-threads)
7100 (gnus-possibly-generate-tree article)
7101 (gnus-highlight-selected-tree article))
7102 ;; Successfully display article.
7103 (gnus-article-set-window-start
7104 (cdr (assq article gnus-newsgroup-bookmarks))))))
7106 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7107 "Select the current article.
7108 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7109 non-nil, the article will be re-fetched even if it already present in
7110 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7112 ;; Make sure we are in the summary buffer to work around bbdb bug.
7113 (unless (eq major-mode 'gnus-summary-mode)
7114 (set-buffer gnus-summary-buffer))
7115 (let ((article (or article (gnus-summary-article-number)))
7116 (all-headers (not (not all-headers))) ;Must be t or nil.
7117 gnus-summary-display-article-function)
7119 (gnus-summary-article-pseudo-p article)
7120 (error "This is a pseudo-article"))
7122 (set-buffer gnus-summary-buffer)
7123 (if (or (and gnus-single-article-buffer
7124 (or (null gnus-current-article)
7125 (null gnus-article-current)
7126 (null (get-buffer gnus-article-buffer))
7127 (not (eq article (cdr gnus-article-current)))
7128 (not (equal (car gnus-article-current)
7129 gnus-newsgroup-name))))
7130 (and (not gnus-single-article-buffer)
7131 (or (null gnus-current-article)
7132 (not (eq gnus-current-article article))))
7134 ;; The requested article is different from the current article.
7136 (gnus-summary-display-article article all-headers)
7137 (when (gnus-buffer-live-p gnus-article-buffer)
7138 (with-current-buffer gnus-article-buffer
7139 (if (not gnus-article-decoded-p) ;; a local variable
7140 (mm-disable-multibyte))))
7141 (gnus-article-set-window-start
7142 (cdr (assq article gnus-newsgroup-bookmarks)))
7146 (defun gnus-summary-force-verify-and-decrypt ()
7147 "Display buttons for signed/encrypted parts and verify/decrypt them."
7149 (let ((mm-verify-option 'known)
7150 (mm-decrypt-option 'known)
7151 (gnus-article-emulate-mime t)
7152 (mm-fill-flowed nil)
7153 (gnus-buttonized-mime-types (append (list "multipart/signed"
7154 "multipart/encrypted")
7155 gnus-buttonized-mime-types)))
7156 (gnus-summary-select-article nil 'force)))
7158 (defun gnus-summary-set-current-mark (&optional current-mark)
7159 "Obsolete function."
7162 (defun gnus-summary-next-article (&optional unread subject backward push)
7163 "Select the next article.
7164 If UNREAD, only unread articles are selected.
7165 If SUBJECT, only articles with SUBJECT are selected.
7166 If BACKWARD, the previous article is selected instead of the next."
7169 ;; Is there such an article?
7170 ((and (gnus-summary-search-forward unread subject backward)
7171 (or (gnus-summary-display-article (gnus-summary-article-number))
7172 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7173 (gnus-summary-position-point))
7174 ;; If not, we try the first unread, if that is wanted.
7176 gnus-auto-select-same
7177 (gnus-summary-first-unread-article))
7178 (gnus-summary-position-point)
7179 (gnus-message 6 "Wrapped"))
7180 ;; Try to get next/previous article not displayed in this group.
7181 ((and gnus-auto-extend-newsgroup
7182 (not unread) (not subject))
7183 (gnus-summary-goto-article
7184 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7185 nil (count-lines (point-min) (point))))
7186 ;; Go to next/previous group.
7188 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7189 (gnus-summary-jump-to-group gnus-newsgroup-name))
7190 (let ((cmd last-command-char)
7192 (with-current-buffer gnus-group-buffer
7195 (if (eq gnus-keep-same-level 'best)
7196 (gnus-summary-best-group gnus-newsgroup-name)
7197 (gnus-summary-search-group backward gnus-keep-same-level))))
7198 ;; For some reason, the group window gets selected. We change
7200 (select-window (get-buffer-window (current-buffer)))
7201 ;; Select next unread newsgroup automagically.
7203 ((or (not gnus-auto-select-next)
7205 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7206 ((or (eq gnus-auto-select-next 'quietly)
7207 (and (eq gnus-auto-select-next 'slightly-quietly)
7209 (and (eq gnus-auto-select-next 'almost-quietly)
7210 (gnus-summary-last-article-p)))
7212 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7214 (gnus-message 7 "No more%s articles (%s)..."
7215 (if unread " unread" "")
7216 (if group (concat "selecting " group)
7218 (gnus-summary-next-group nil group backward)))
7220 (when (gnus-key-press-event-p last-input-event)
7221 (gnus-summary-walk-group-buffer
7222 gnus-newsgroup-name cmd unread backward point))))))))
7224 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7225 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7226 (?\C-p (gnus-group-prev-unread-group 1))))
7227 (cursor-in-echo-area t)
7228 keve key group ended prompt)
7230 (set-buffer gnus-group-buffer)
7233 (if (eq gnus-keep-same-level 'best)
7234 (gnus-summary-best-group gnus-newsgroup-name)
7235 (gnus-summary-search-group backward gnus-keep-same-level))))
7239 "No more%s articles%s " (if unread " unread" "")
7241 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7242 (format " (Type %s for %s [%s])"
7243 (single-key-description cmd) group
7244 (gnus-group-unread group))
7245 (format " (Type %s to exit %s)"
7246 (single-key-description cmd)
7247 gnus-newsgroup-name))))
7248 ;; Confirm auto selection.
7249 (setq key (car (setq keve (gnus-read-event-char prompt)))
7252 ((assq key keystrokes)
7253 (let ((obuf (current-buffer)))
7254 (switch-to-buffer gnus-group-buffer)
7256 (gnus-group-jump-to-group group))
7257 (eval (cadr (assq key keystrokes)))
7258 (setq group (gnus-group-group-name))
7259 (switch-to-buffer obuf))
7263 (gnus-ephemeral-group-p gnus-newsgroup-name))
7265 (gnus-summary-next-group nil group backward)))
7267 (push (cdr keve) unread-command-events))))))
7269 (defun gnus-summary-next-unread-article ()
7270 "Select unread article after current one."
7272 (gnus-summary-next-article
7273 (or (not (eq gnus-summary-goto-unread 'never))
7274 (gnus-summary-last-article-p (gnus-summary-article-number)))
7275 (and gnus-auto-select-same
7276 (gnus-summary-article-subject))))
7278 (defun gnus-summary-prev-article (&optional unread subject)
7279 "Select the article after the current one.
7280 If UNREAD is non-nil, only unread articles are selected."
7282 (gnus-summary-next-article unread subject t))
7284 (defun gnus-summary-prev-unread-article ()
7285 "Select unread article before current one."
7287 (gnus-summary-prev-article
7288 (or (not (eq gnus-summary-goto-unread 'never))
7289 (gnus-summary-first-article-p (gnus-summary-article-number)))
7290 (and gnus-auto-select-same
7291 (gnus-summary-article-subject))))
7293 (defun gnus-summary-next-page (&optional lines circular stop)
7294 "Show next page of the selected article.
7295 If at the end of the current article, select the next article.
7296 LINES says how many lines should be scrolled up.
7298 If CIRCULAR is non-nil, go to the start of the article instead of
7299 selecting the next article when reaching the end of the current
7302 If STOP is non-nil, just stop when reaching the end of the message.
7304 Also see the variable `gnus-article-skip-boring'."
7306 (setq gnus-summary-buffer (current-buffer))
7307 (gnus-set-global-variables)
7308 (let ((article (gnus-summary-article-number))
7309 (article-window (get-buffer-window gnus-article-buffer t))
7311 ;; If the buffer is empty, we have no article.
7313 (error "No article to select"))
7314 (gnus-configure-windows 'article)
7315 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7316 (if (and (eq gnus-summary-goto-unread 'never)
7317 (not (gnus-summary-last-article-p article)))
7318 (gnus-summary-next-article)
7319 (gnus-summary-next-unread-article))
7320 (if (or (null gnus-current-article)
7321 (null gnus-article-current)
7322 (/= article (cdr gnus-article-current))
7323 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7324 ;; Selected subject is different from current article's.
7325 (gnus-summary-display-article article)
7326 (when article-window
7327 (gnus-eval-in-buffer-window gnus-article-buffer
7328 (setq endp (or (gnus-article-next-page lines)
7329 (gnus-article-only-boring-p))))
7332 (gnus-message 3 "End of message"))
7334 (gnus-summary-beginning-of-article))
7336 (gnus-message 3 "End of message"))
7338 (if (and (eq gnus-summary-goto-unread 'never)
7339 (not (gnus-summary-last-article-p article)))
7340 (gnus-summary-next-article)
7341 (gnus-summary-next-unread-article))))))))
7342 (gnus-summary-recenter)
7343 (gnus-summary-position-point)))
7345 (defun gnus-summary-prev-page (&optional lines move)
7346 "Show previous page of selected article.
7347 Argument LINES specifies lines to be scrolled down.
7348 If MOVE, move to the previous unread article if point is at
7349 the beginning of the buffer."
7351 (let ((article (gnus-summary-article-number))
7352 (article-window (get-buffer-window gnus-article-buffer t))
7354 (gnus-configure-windows 'article)
7355 (if (or (null gnus-current-article)
7356 (null gnus-article-current)
7357 (/= article (cdr gnus-article-current))
7358 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7359 ;; Selected subject is different from current article's.
7360 (gnus-summary-display-article article)
7361 (gnus-summary-recenter)
7362 (when article-window
7363 (gnus-eval-in-buffer-window gnus-article-buffer
7364 (setq endp (gnus-article-prev-page lines)))
7365 (when (and move endp)
7367 (gnus-message 3 "Beginning of message"))
7369 (if (and (eq gnus-summary-goto-unread 'never)
7370 (not (gnus-summary-first-article-p article)))
7371 (gnus-summary-prev-article)
7372 (gnus-summary-prev-unread-article))))))))
7373 (gnus-summary-position-point))
7375 (defun gnus-summary-prev-page-or-article (&optional lines)
7376 "Show previous page of selected article.
7377 Argument LINES specifies lines to be scrolled down.
7378 If at the beginning of the article, go to the next article."
7380 (gnus-summary-prev-page lines t))
7382 (defun gnus-summary-scroll-up (lines)
7383 "Scroll up (or down) one line current article.
7384 Argument LINES specifies lines to be scrolled up (or down if negative)."
7386 (gnus-configure-windows 'article)
7387 (gnus-summary-show-thread)
7388 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7389 (gnus-eval-in-buffer-window gnus-article-buffer
7391 (when (gnus-article-next-page lines)
7392 (gnus-message 3 "End of message")))
7394 (gnus-article-prev-page (- lines))))))
7395 (gnus-summary-recenter)
7396 (gnus-summary-position-point))
7398 (defun gnus-summary-scroll-down (lines)
7399 "Scroll down (or up) one line current article.
7400 Argument LINES specifies lines to be scrolled down (or up if negative)."
7402 (gnus-summary-scroll-up (- lines)))
7404 (defun gnus-summary-next-same-subject ()
7405 "Select next article which has the same subject as current one."
7407 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7409 (defun gnus-summary-prev-same-subject ()
7410 "Select previous article which has the same subject as current one."
7412 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7414 (defun gnus-summary-next-unread-same-subject ()
7415 "Select next unread article which has the same subject as current one."
7417 (gnus-summary-next-article t (gnus-summary-article-subject)))
7419 (defun gnus-summary-prev-unread-same-subject ()
7420 "Select previous unread article which has the same subject as current one."
7422 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7424 (defun gnus-summary-first-unread-article ()
7425 "Select the first unread article.
7426 Return nil if there are no unread articles."
7429 (when (gnus-summary-first-subject t)
7430 (gnus-summary-show-thread)
7431 (gnus-summary-first-subject t)
7432 (gnus-summary-display-article (gnus-summary-article-number)))
7433 (gnus-summary-position-point)))
7435 (defun gnus-summary-first-unread-subject ()
7436 "Place the point on the subject line of the first unread article.
7437 Return nil if there are no unread articles."
7440 (when (gnus-summary-first-subject t)
7441 (gnus-summary-show-thread)
7442 (gnus-summary-first-subject t))
7443 (gnus-summary-position-point)))
7445 (defun gnus-summary-first-unseen-subject ()
7446 "Place the point on the subject line of the first unseen article.
7447 Return nil if there are no unseen articles."
7450 (when (gnus-summary-first-subject nil nil t)
7451 (gnus-summary-show-thread)
7452 (gnus-summary-first-subject nil nil t))
7453 (gnus-summary-position-point)))
7455 (defun gnus-summary-first-unseen-or-unread-subject ()
7456 "Place the point on the subject line of the first unseen article or,
7457 if all article have been seen, on the subject line of the first unread
7461 (unless (when (gnus-summary-first-subject nil nil t)
7462 (gnus-summary-show-thread)
7463 (gnus-summary-first-subject nil nil t))
7464 (when (gnus-summary-first-subject t)
7465 (gnus-summary-show-thread)
7466 (gnus-summary-first-subject t)))
7467 (gnus-summary-position-point)))
7469 (defun gnus-summary-first-article ()
7470 "Select the first article.
7471 Return nil if there are no articles."
7474 (when (gnus-summary-first-subject)
7475 (gnus-summary-show-thread)
7476 (gnus-summary-first-subject)
7477 (gnus-summary-display-article (gnus-summary-article-number)))
7478 (gnus-summary-position-point)))
7480 (defun gnus-summary-best-unread-article (&optional arg)
7481 "Select the unread article with the highest score.
7482 If given a prefix argument, select the next unread article that has a
7483 score higher than the default score."
7485 (let ((article (if arg
7486 (gnus-summary-better-unread-subject)
7487 (gnus-summary-best-unread-subject))))
7489 (gnus-summary-goto-article article)
7490 (error "No unread articles"))))
7492 (defun gnus-summary-best-unread-subject ()
7493 "Select the unread subject with the highest score."
7495 (let ((best -1000000)
7496 (data gnus-newsgroup-data)
7499 (and (gnus-data-unread-p (car data))
7501 (gnus-summary-article-score (gnus-data-number (car data))))
7504 article (gnus-data-number (car data))))
7505 (setq data (cdr data)))
7507 (gnus-summary-goto-subject article))
7508 (gnus-summary-position-point)
7511 (defun gnus-summary-better-unread-subject ()
7512 "Select the first unread subject that has a score over the default score."
7514 (let ((data gnus-newsgroup-data)
7516 (while (and (setq article (gnus-data-number (car data)))
7517 (or (gnus-data-read-p (car data))
7518 (not (> (gnus-summary-article-score article)
7519 gnus-summary-default-score))))
7520 (setq data (cdr data)))
7522 (gnus-summary-goto-subject article))
7523 (gnus-summary-position-point)
7526 (defun gnus-summary-last-subject ()
7527 "Go to the last displayed subject line in the group."
7528 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7530 (gnus-summary-goto-subject article))))
7532 (defun gnus-summary-goto-article (article &optional all-headers force)
7533 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7534 If ALL-HEADERS is non-nil, no header lines are hidden.
7535 If FORCE, go to the article even if it isn't displayed. If FORCE
7536 is a number, it is the line the article is to be displayed on."
7540 "Article number or Message-ID: "
7541 (mapcar (lambda (number) (list (int-to-string number)))
7542 gnus-newsgroup-limit))
7546 (if (and (stringp article)
7547 (string-match "@\\|%40" article))
7548 (gnus-summary-refer-article article)
7549 (when (stringp article)
7550 (setq article (string-to-number article)))
7551 (if (gnus-summary-goto-subject article force)
7552 (gnus-summary-display-article article all-headers)
7553 (gnus-message 4 "Couldn't go to article %s" article) nil))
7554 (gnus-summary-position-point)))
7556 (defun gnus-summary-goto-last-article ()
7557 "Go to the previously read article."
7560 (when gnus-last-article
7561 (gnus-summary-goto-article gnus-last-article nil t))
7562 (gnus-summary-position-point)))
7564 (defun gnus-summary-pop-article (number)
7565 "Pop one article off the history and go to the previous.
7566 NUMBER articles will be popped off."
7569 (setq gnus-newsgroup-history
7570 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7572 (gnus-summary-goto-article (car to) nil t)
7573 (error "Article history empty")))
7574 (gnus-summary-position-point))
7576 ;; Summary commands and functions for limiting the summary buffer.
7578 (defun gnus-summary-limit-to-articles (n)
7579 "Limit the summary buffer to the next N articles.
7580 If not given a prefix, use the process marked articles instead."
7583 (let ((articles (gnus-summary-work-articles n)))
7584 (setq gnus-newsgroup-processable nil)
7585 (gnus-summary-limit articles))
7586 (gnus-summary-position-point)))
7588 (defun gnus-summary-pop-limit (&optional total)
7589 "Restore the previous limit.
7590 If given a prefix, remove all limits."
7593 (setq gnus-newsgroup-limits
7594 (list (mapcar (lambda (h) (mail-header-number h))
7595 gnus-newsgroup-headers))))
7596 (unless gnus-newsgroup-limits
7597 (error "No limit to pop"))
7599 (gnus-summary-limit nil 'pop)
7600 (gnus-summary-position-point)))
7602 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7603 "Limit the summary buffer to articles that have subjects that match a regexp.
7604 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7606 (list (read-string (if current-prefix-arg
7607 "Exclude subject (regexp): "
7608 "Limit to subject (regexp): "))
7609 nil current-prefix-arg))
7611 (setq header "subject"))
7612 (when (not (equal "" subject))
7614 (let ((articles (gnus-summary-find-matching
7615 (or header "subject") subject 'all nil nil
7618 (error "Found no matches for \"%s\"" subject))
7619 (gnus-summary-limit articles))
7620 (gnus-summary-position-point))))
7622 (defun gnus-summary-limit-to-author (from &optional not-matching)
7623 "Limit the summary buffer to articles that have authors that match a regexp.
7624 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7626 (list (read-string (if current-prefix-arg
7627 "Exclude author (regexp): "
7628 "Limit to author (regexp): "))
7629 current-prefix-arg))
7630 (gnus-summary-limit-to-subject from "from" not-matching))
7632 (defun gnus-summary-limit-to-age (age &optional younger-p)
7633 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7634 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7635 articles that are younger than AGE days."
7637 (let ((younger current-prefix-arg)
7640 (while (not days-got)
7641 (setq days (if younger
7642 (read-string "Limit to articles younger than (in days, older when negative): ")
7644 "Limit to articles older than (in days, younger when negative): ")))
7645 (when (> (length days) 0)
7646 (setq days (read days)))
7651 (setq younger (not younger))
7652 (setq days (* days -1))))
7653 (message "Please enter a number.")
7655 (list days younger)))
7657 (let ((data gnus-newsgroup-data)
7658 (cutoff (days-to-time age))
7659 articles d date is-younger)
7660 (while (setq d (pop data))
7661 (when (and (vectorp (gnus-data-header d))
7662 (setq date (mail-header-date (gnus-data-header d))))
7663 (setq is-younger (time-less-p
7664 (time-since (condition-case ()
7671 (push (gnus-data-number d) articles))))
7672 (gnus-summary-limit (nreverse articles)))
7673 (gnus-summary-position-point)))
7675 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7676 "Limit the summary buffer to articles that match an 'extra' header."
7680 (gnus-completing-read-with-default
7681 (symbol-name (car gnus-extra-headers))
7682 (if current-prefix-arg
7683 "Exclude extra header:"
7684 "Limit extra header:")
7686 (cons (symbol-name x) x))
7691 (read-string (format "%s header %s (regexp): "
7692 (if current-prefix-arg "Exclude" "Limit to")
7694 current-prefix-arg)))
7695 (when (not (equal "" regexp))
7697 (let ((articles (gnus-summary-find-matching
7698 (cons 'extra header) regexp 'all nil nil
7701 (error "Found no matches for \"%s\"" regexp))
7702 (gnus-summary-limit articles))
7703 (gnus-summary-position-point))))
7705 (defun gnus-summary-limit-to-display-predicate ()
7706 "Limit the summary buffer to the predicated in the `display' group parameter."
7708 (unless gnus-newsgroup-display
7709 (error "There is no `display' group parameter"))
7711 (dolist (number gnus-newsgroup-articles)
7712 (when (funcall gnus-newsgroup-display)
7713 (push number articles)))
7714 (gnus-summary-limit articles))
7715 (gnus-summary-position-point))
7717 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7719 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7721 (defun gnus-summary-limit-to-unread (&optional all)
7722 "Limit the summary buffer to articles that are not marked as read.
7723 If ALL is non-nil, limit strictly to unread articles."
7726 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7727 (gnus-summary-limit-to-marks
7728 ;; Concat all the marks that say that an article is read and have
7730 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7731 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7732 gnus-low-score-mark gnus-expirable-mark
7733 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7734 gnus-duplicate-mark gnus-souped-mark)
7737 (defun gnus-summary-limit-to-replied (&optional unreplied)
7738 "Limit the summary buffer to replied articles.
7739 If UNREPLIED (the prefix), limit to unreplied articles."
7743 (gnus-set-difference gnus-newsgroup-articles
7744 gnus-newsgroup-replied))
7745 (gnus-summary-limit gnus-newsgroup-replied))
7746 (gnus-summary-position-point))
7748 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7749 (make-obsolete 'gnus-summary-delete-marked-with
7750 'gnus-summary-limit-exclude-marks)
7752 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7753 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7754 If REVERSE, limit the summary buffer to articles that are marked
7755 with MARKS. MARKS can either be a string of marks or a list of marks.
7756 Returns how many articles were removed."
7757 (interactive "sMarks: ")
7758 (gnus-summary-limit-to-marks marks t))
7760 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7761 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7762 If REVERSE (the prefix), limit the summary buffer to articles that are
7763 not marked with MARKS. MARKS can either be a string of marks or a
7765 Returns how many articles were removed."
7766 (interactive "sMarks: \nP")
7768 (let ((data gnus-newsgroup-data)
7769 (marks (if (listp marks) marks
7770 (append marks nil))) ; Transform to list.
7773 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7774 (memq (gnus-data-mark (car data)) marks))
7775 (push (gnus-data-number (car data)) articles))
7776 (setq data (cdr data)))
7777 (gnus-summary-limit articles))
7778 (gnus-summary-position-point)))
7780 (defun gnus-summary-limit-to-score (score)
7781 "Limit to articles with score at or above SCORE."
7782 (interactive "NLimit to articles with score of at least: ")
7783 (let ((data gnus-newsgroup-data)
7786 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7788 (push (gnus-data-number (car data)) articles))
7789 (setq data (cdr data)))
7791 (gnus-summary-limit articles)
7792 (gnus-summary-position-point))))
7794 (defun gnus-summary-limit-to-unseen ()
7795 "Limit to unseen articles."
7798 (gnus-summary-limit gnus-newsgroup-unseen)
7799 (gnus-summary-position-point)))
7801 (defun gnus-summary-limit-include-thread (id)
7802 "Display all the hidden articles that is in the thread with ID in it.
7803 When called interactively, ID is the Message-ID of the current
7805 (interactive (list (mail-header-id (gnus-summary-article-header))))
7806 (let ((articles (gnus-articles-in-thread
7807 (gnus-id-to-thread (gnus-root-id id)))))
7809 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7810 (gnus-summary-limit-include-matching-articles
7812 (regexp-quote (gnus-simplify-subject-re
7813 (mail-header-subject (gnus-id-to-header id)))))
7814 (gnus-summary-position-point))))
7816 (defun gnus-summary-limit-include-matching-articles (header regexp)
7817 "Display all the hidden articles that have HEADERs that match REGEXP."
7818 (interactive (list (read-string "Match on header: ")
7819 (read-string "Regexp: ")))
7820 (let ((articles (gnus-find-matching-articles header regexp)))
7822 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7823 (gnus-summary-position-point))))
7825 (defun gnus-summary-insert-dormant-articles ()
7826 "Insert all the dormant articles for this group into the current buffer."
7828 (let ((gnus-verbose (max 6 gnus-verbose)))
7829 (if (not gnus-newsgroup-dormant)
7830 (gnus-message 3 "No cached articles for this group")
7831 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7833 (defun gnus-summary-limit-include-dormant ()
7834 "Display all the hidden articles that are marked as dormant.
7835 Note that this command only works on a subset of the articles currently
7836 fetched for this group."
7838 (unless gnus-newsgroup-dormant
7839 (error "There are no dormant articles in this group"))
7841 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7842 (gnus-summary-position-point)))
7844 (defun gnus-summary-limit-exclude-dormant ()
7845 "Hide all dormant articles."
7848 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7849 (gnus-summary-position-point)))
7851 (defun gnus-summary-limit-exclude-childless-dormant ()
7852 "Hide all dormant articles that have no children."
7854 (let ((data (gnus-data-list t))
7855 articles d children)
7856 ;; Find all articles that are either not dormant or have
7858 (while (setq d (pop data))
7859 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7861 (gnus-article-children (gnus-data-number d)))
7864 (when (memq (car children) articles)
7869 (push (gnus-data-number d) articles)))
7872 (gnus-summary-limit articles)
7873 (gnus-summary-position-point))))
7875 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7876 "Mark all unread excluded articles as read.
7877 If ALL, mark even excluded ticked and dormants as read."
7879 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7880 (let ((articles (gnus-sorted-ndifference
7882 (mapcar (lambda (h) (mail-header-number h))
7883 gnus-newsgroup-headers)
7885 gnus-newsgroup-limit))
7887 (setq gnus-newsgroup-unreads
7888 (gnus-sorted-intersection gnus-newsgroup-unreads
7889 gnus-newsgroup-limit))
7891 (setq gnus-newsgroup-dormant nil
7892 gnus-newsgroup-marked nil
7893 gnus-newsgroup-reads
7895 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7896 gnus-newsgroup-reads))
7897 (while (setq article (pop articles))
7898 (unless (or (memq article gnus-newsgroup-dormant)
7899 (memq article gnus-newsgroup-marked))
7900 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7902 (defun gnus-summary-limit (articles &optional pop)
7904 ;; We pop the previous limit off the stack and use that.
7905 (setq articles (car gnus-newsgroup-limits)
7906 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7907 ;; We use the new limit, so we push the old limit on the stack.
7908 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7910 (setq gnus-newsgroup-limit articles)
7911 (let ((total (length gnus-newsgroup-data))
7912 (data (gnus-data-find-list (gnus-summary-article-number)))
7913 (gnus-summary-mark-below nil) ; Inhibit this.
7915 ;; This will do all the work of generating the new summary buffer
7916 ;; according to the new limit.
7917 (gnus-summary-prepare)
7918 ;; Hide any threads, possibly.
7919 (gnus-summary-maybe-hide-threads)
7920 ;; Try to return to the article you were at, or one in the
7923 ;; We try to find some article after the current one.
7925 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7928 (setq data (cdr data))))
7930 ;; If there is no data, that means that we were after the last
7931 ;; article. The same goes when we can't find any articles
7932 ;; after the current one.
7933 (goto-char (point-max))
7934 (gnus-summary-find-prev))
7935 (gnus-set-mode-line 'summary)
7936 ;; We return how many articles were removed from the summary
7937 ;; buffer as a result of the new limit.
7938 (- total (length gnus-newsgroup-data))))
7940 (defsubst gnus-invisible-cut-children (threads)
7943 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7948 (defsubst gnus-cut-thread (thread)
7949 "Go forwards in the thread until we find an article that we want to display."
7950 (when (or (eq gnus-fetch-old-headers 'some)
7951 (eq gnus-fetch-old-headers 'invisible)
7952 (numberp gnus-fetch-old-headers)
7953 (eq gnus-build-sparse-threads 'some)
7954 (eq gnus-build-sparse-threads 'more))
7955 ;; Deal with old-fetched headers and sparse threads.
7959 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7960 (gnus-summary-article-ancient-p
7961 (mail-header-number (car thread))))
7962 (if (or (<= (length (cdr thread)) 1)
7963 (eq gnus-fetch-old-headers 'invisible))
7964 (setq gnus-newsgroup-limit
7965 (delq (mail-header-number (car thread))
7966 gnus-newsgroup-limit)
7967 thread (cadr thread))
7968 (when (gnus-invisible-cut-children (cdr thread))
7969 (let ((th (cdr thread)))
7971 (if (memq (mail-header-number (caar th))
7972 gnus-newsgroup-limit)
7973 (setq thread (car th)
7975 (setq th (cdr th))))))))))
7978 (defun gnus-cut-threads (threads)
7979 "Cut off all uninteresting articles from the beginning of THREADS."
7980 (when (or (eq gnus-fetch-old-headers 'some)
7981 (eq gnus-fetch-old-headers 'invisible)
7982 (numberp gnus-fetch-old-headers)
7983 (eq gnus-build-sparse-threads 'some)
7984 (eq gnus-build-sparse-threads 'more))
7987 (setcar th (gnus-cut-thread (car th)))
7988 (setq th (cdr th)))))
7989 ;; Remove nixed out threads.
7992 (defun gnus-summary-initial-limit (&optional show-if-empty)
7993 "Figure out what the initial limit is supposed to be on group entry.
7994 This entails weeding out unwanted dormants, low-scored articles,
7995 fetch-old-headers verbiage, and so on."
7996 ;; Most groups have nothing to remove.
7997 (if (or gnus-inhibit-limiting
7998 (and (null gnus-newsgroup-dormant)
7999 (eq gnus-newsgroup-display 'gnus-not-ignore)
8000 (not (eq gnus-fetch-old-headers 'some))
8001 (not (numberp gnus-fetch-old-headers))
8002 (not (eq gnus-fetch-old-headers 'invisible))
8003 (null gnus-summary-expunge-below)
8004 (not (eq gnus-build-sparse-threads 'some))
8005 (not (eq gnus-build-sparse-threads 'more))
8006 (null gnus-thread-expunge-below)
8007 (not gnus-use-nocem)))
8009 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8010 (setq gnus-newsgroup-limit nil)
8013 (unless (car (symbol-value node))
8014 ;; These threads have no parents -- they are roots.
8015 (let ((nodes (cdr (symbol-value node)))
8018 (if (and gnus-thread-expunge-below
8019 (< (gnus-thread-total-score (car nodes))
8020 gnus-thread-expunge-below))
8021 (gnus-expunge-thread (pop nodes))
8022 (setq thread (pop nodes))
8023 (gnus-summary-limit-children thread))))))
8024 gnus-newsgroup-dependencies)
8025 ;; If this limitation resulted in an empty group, we might
8026 ;; pop the previous limit and use it instead.
8027 (when (and (not gnus-newsgroup-limit)
8029 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8030 gnus-newsgroup-limit))
8032 (defun gnus-summary-limit-children (thread)
8033 "Return 1 if this subthread is visible and 0 if it is not."
8034 ;; First we get the number of visible children to this thread. This
8035 ;; is done by recursing down the thread using this function, so this
8036 ;; will really go down to a leaf article first, before slowly
8037 ;; working its way up towards the root.
8039 (let* ((max-lisp-eval-depth 5000)
8042 (apply '+ (mapcar 'gnus-summary-limit-children
8045 (number (mail-header-number (car thread)))
8048 (not (memq number gnus-newsgroup-marked))
8050 ;; If this article is dormant and has absolutely no visible
8051 ;; children, then this article isn't visible.
8052 (and (memq number gnus-newsgroup-dormant)
8054 ;; If this is "fetch-old-headered" and there is no
8055 ;; visible children, then we don't want this article.
8056 (and (or (eq gnus-fetch-old-headers 'some)
8057 (numberp gnus-fetch-old-headers))
8058 (gnus-summary-article-ancient-p number)
8060 ;; If this is "fetch-old-headered" and `invisible', then
8061 ;; we don't want this article.
8062 (and (eq gnus-fetch-old-headers 'invisible)
8063 (gnus-summary-article-ancient-p number))
8064 ;; If this is a sparsely inserted article with no children,
8065 ;; we don't want it.
8066 (and (eq gnus-build-sparse-threads 'some)
8067 (gnus-summary-article-sparse-p number)
8069 ;; If we use expunging, and this article is really
8070 ;; low-scored, then we don't want this article.
8071 (when (and gnus-summary-expunge-below
8073 (or (cdr (assq number gnus-newsgroup-scored))
8074 gnus-summary-default-score))
8075 gnus-summary-expunge-below))
8076 ;; We increase the expunge-tally here, but that has
8077 ;; nothing to do with the limits, really.
8078 (incf gnus-newsgroup-expunged-tally)
8079 ;; We also mark as read here, if that's wanted.
8080 (when (and gnus-summary-mark-below
8081 (< score gnus-summary-mark-below))
8082 (setq gnus-newsgroup-unreads
8083 (delq number gnus-newsgroup-unreads))
8084 (if gnus-newsgroup-auto-expire
8085 (push number gnus-newsgroup-expirable)
8086 (push (cons number gnus-low-score-mark)
8087 gnus-newsgroup-reads)))
8089 ;; Do the `display' group parameter.
8090 (and gnus-newsgroup-display
8091 (not (funcall gnus-newsgroup-display)))
8092 ;; Check NoCeM things.
8093 (when (and gnus-use-nocem
8094 (gnus-nocem-unwanted-article-p
8095 (mail-header-id (car thread))))
8096 (setq gnus-newsgroup-unreads
8097 (delq number gnus-newsgroup-unreads))
8099 ;; Nope, invisible article.
8101 ;; Ok, this article is to be visible, so we add it to the limit
8103 (push number gnus-newsgroup-limit)
8106 (defun gnus-expunge-thread (thread)
8107 "Mark all articles in THREAD as read."
8108 (let* ((number (mail-header-number (car thread))))
8109 (incf gnus-newsgroup-expunged-tally)
8110 ;; We also mark as read here, if that's wanted.
8111 (setq gnus-newsgroup-unreads
8112 (delq number gnus-newsgroup-unreads))
8113 (if gnus-newsgroup-auto-expire
8114 (push number gnus-newsgroup-expirable)
8115 (push (cons number gnus-low-score-mark)
8116 gnus-newsgroup-reads)))
8117 ;; Go recursively through all subthreads.
8118 (mapcar 'gnus-expunge-thread (cdr thread)))
8120 ;; Summary article oriented commands
8122 (defun gnus-summary-refer-parent-article (n)
8123 "Refer parent article N times.
8124 If N is negative, go to ancestor -N instead.
8125 The difference between N and the number of articles fetched is returned."
8129 (when (not (natnump n))
8134 (setq header (gnus-summary-article-header))
8135 (if (and (eq (mail-header-number header)
8136 (cdr gnus-article-current))
8137 (equal gnus-newsgroup-name
8138 (car gnus-article-current)))
8139 ;; If we try to find the parent of the currently
8140 ;; displayed article, then we take a look at the actual
8141 ;; References header, since this is slightly more
8142 ;; reliable than the References field we got from the
8145 (set-buffer gnus-original-article-buffer)
8146 (nnheader-narrow-to-headers)
8147 (unless (setq ref (message-fetch-field "references"))
8148 (when (setq ref (message-fetch-field "in-reply-to"))
8149 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8152 ;; It's not the current article, so we take a bet on
8153 ;; the value we got from the server.
8154 (mail-header-references header)))
8156 (not (equal ref "")))
8157 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8158 (gnus-message 1 "Couldn't find parent"))
8159 (gnus-message 1 "No references in article %d"
8160 (gnus-summary-article-number))
8163 (gnus-summary-position-point)
8166 (defun gnus-summary-refer-references ()
8167 "Fetch all articles mentioned in the References header.
8168 Return the number of articles fetched."
8170 (let ((ref (mail-header-references (gnus-summary-article-header)))
8171 (current (gnus-summary-article-number))
8175 (error "No References in the current article")
8176 ;; For each Message-ID in the References header...
8177 (while (string-match "<[^>]*>" ref)
8179 ;; ... fetch that article.
8180 (gnus-summary-refer-article
8181 (prog1 (match-string 0 ref)
8182 (setq ref (substring ref (match-end 0))))))
8183 (gnus-summary-goto-subject current)
8184 (gnus-summary-position-point)
8187 (defun gnus-summary-refer-thread (&optional limit)
8188 "Fetch all articles in the current thread.
8189 If LIMIT (the numerical prefix), fetch that many old headers instead
8190 of what's specified by the `gnus-refer-thread-limit' variable."
8192 (let ((id (mail-header-id (gnus-summary-article-header)))
8193 (limit (if limit (prefix-numeric-value limit)
8194 gnus-refer-thread-limit)))
8195 (unless (eq gnus-fetch-old-headers 'invisible)
8196 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8197 ;; Retrieve the headers and read them in.
8198 (if (eq (if (numberp limit)
8199 (gnus-retrieve-headers
8201 (+ (mail-header-number
8202 (gnus-summary-article-header))
8204 gnus-newsgroup-end))
8205 gnus-newsgroup-name (* limit 2))
8206 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8208 (gnus-retrieve-headers (list gnus-newsgroup-end)
8209 gnus-newsgroup-name limit))
8211 (gnus-build-all-threads)
8212 (error "Can't fetch thread from back ends that don't support NOV"))
8213 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8214 (gnus-summary-limit-include-thread id)))
8216 (defun gnus-summary-refer-article (message-id)
8217 "Fetch an article specified by MESSAGE-ID."
8218 (interactive "sMessage-ID: ")
8219 (when (and (stringp message-id)
8220 (not (zerop (length message-id))))
8221 (setq message-id (gnus-replace-in-string message-id " " ""))
8222 ;; Construct the correct Message-ID if necessary.
8223 ;; Suggested by tale@pawl.rpi.edu.
8224 (unless (string-match "^<" message-id)
8225 (setq message-id (concat "<" message-id)))
8226 (unless (string-match ">$" message-id)
8227 (setq message-id (concat message-id ">")))
8228 ;; People often post MIDs from URLs, so unhex it:
8229 (unless (string-match "@" message-id)
8230 (setq message-id (gnus-url-unhex-string message-id)))
8231 (let* ((header (gnus-id-to-header message-id))
8233 (gnus-summary-article-sparse-p
8234 (mail-header-number header))
8235 (memq (mail-header-number header)
8236 gnus-newsgroup-limit)))
8239 ;; If the article is present in the buffer we just go to it.
8241 (or (not (gnus-summary-article-sparse-p
8242 (mail-header-number header)))
8245 (gnus-summary-goto-article
8246 (mail-header-number header) nil t)
8248 (gnus-summary-update-article (mail-header-number header)))))
8250 ;; We fetch the article.
8252 (dolist (gnus-override-method (gnus-refer-article-methods))
8253 (when (and (gnus-check-server gnus-override-method)
8254 ;; Fetch the header,
8255 (setq number (gnus-summary-insert-subject message-id)))
8256 ;; and display the article.
8257 (gnus-summary-select-article nil nil nil number)
8259 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8261 (defun gnus-refer-article-methods ()
8262 "Return a list of referable methods."
8264 ;; No method, so we default to current and native.
8265 ((null gnus-refer-article-method)
8266 (list gnus-current-select-method gnus-select-method))
8268 ((eq 'current gnus-refer-article-method)
8269 (list gnus-current-select-method))
8270 ;; List of select methods.
8271 ((not (and (symbolp (car gnus-refer-article-method))
8272 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8274 (dolist (method gnus-refer-article-method)
8275 (push (if (eq 'current method)
8276 gnus-current-select-method
8280 ;; One single select method.
8282 (list gnus-refer-article-method))))
8284 (defun gnus-summary-edit-parameters ()
8285 "Edit the group parameters of the current group."
8287 (gnus-group-edit-group gnus-newsgroup-name 'params))
8289 (defun gnus-summary-customize-parameters ()
8290 "Customize the group parameters of the current group."
8292 (gnus-group-customize gnus-newsgroup-name))
8294 (defun gnus-summary-enter-digest-group (&optional force)
8295 "Enter an nndoc group based on the current article.
8296 If FORCE, force a digest interpretation. If not, try
8297 to guess what the document format is."
8299 (let ((conf gnus-current-window-configuration))
8300 (save-window-excursion
8302 (let (gnus-article-prepare-hook
8303 gnus-display-mime-function
8305 (gnus-summary-select-article))))
8306 (setq gnus-current-window-configuration conf)
8307 (let* ((name (format "%s-%d"
8308 (gnus-group-prefixed-name
8309 gnus-newsgroup-name (list 'nndoc ""))
8310 (with-current-buffer gnus-summary-buffer
8311 gnus-current-article)))
8312 (ogroup gnus-newsgroup-name)
8313 (params (append (gnus-info-params (gnus-get-info ogroup))
8314 (list (cons 'to-group ogroup))
8315 (list (cons 'parent-group ogroup))
8316 (list (cons 'save-article-group ogroup))))
8317 (case-fold-search t)
8318 (buf (current-buffer))
8321 (set-buffer gnus-original-article-buffer)
8322 ;; Have the digest group inherit the main mail address of
8323 ;; the parent article.
8324 (when (setq to-address (or (gnus-fetch-field "reply-to")
8325 (gnus-fetch-field "from")))
8326 (setq params (append
8327 (list (cons 'to-address
8328 (funcall gnus-decode-encoded-word-function
8330 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8331 (insert-buffer-substring gnus-original-article-buffer)
8332 ;; Remove lines that may lead nndoc to misinterpret the
8335 (goto-char (point-min))
8336 (or (search-forward "\n\n" nil t) (point)))
8337 (goto-char (point-min))
8338 (delete-matching-lines "^Path:\\|^From ")
8341 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8342 (gnus-newsgroup-ephemeral-ignored-charsets
8343 gnus-newsgroup-ignored-charsets))
8344 (gnus-group-read-ephemeral-group
8345 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8347 ,(if force 'mbox 'guess)))
8349 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8351 ;; Make all postings to this group go to the parent group.
8352 (nconc (gnus-info-params (gnus-get-info name))
8354 ;; Couldn't select this doc group.
8355 (switch-to-buffer buf)
8356 (gnus-set-global-variables)
8357 (gnus-configure-windows 'summary)
8358 (gnus-message 3 "Article couldn't be entered?"))
8359 (kill-buffer dig)))))
8361 (defun gnus-summary-read-document (n)
8362 "Open a new group based on the current article(s).
8363 This will allow you to read digests and other similar
8364 documents as newsgroups.
8365 Obeys the standard process/prefix convention."
8367 (let* ((articles (gnus-summary-work-articles n))
8368 (ogroup gnus-newsgroup-name)
8369 (params (append (gnus-info-params (gnus-get-info ogroup))
8370 (list (cons 'to-group ogroup))))
8371 article group egroup groups vgroup)
8372 (while (setq article (pop articles))
8373 (setq group (format "%s-%d" gnus-newsgroup-name article))
8374 (gnus-summary-remove-process-mark article)
8375 (when (gnus-summary-display-article article)
8378 (insert-buffer-substring gnus-original-article-buffer)
8379 ;; Remove some headers that may lead nndoc to make
8381 (message-narrow-to-head)
8382 (goto-char (point-min))
8383 (delete-matching-lines "^Path:\\|^From ")
8386 (gnus-group-read-ephemeral-group
8387 group `(nndoc ,group (nndoc-address ,(current-buffer))
8388 (nndoc-article-type guess))
8391 ;; Make all postings to this group go to the parent group.
8392 (nconc (gnus-info-params (gnus-get-info egroup))
8394 (push egroup groups))
8395 ;; Couldn't select this doc group.
8396 (gnus-error 3 "Article couldn't be entered"))))))
8397 ;; Now we have selected all the documents.
8400 (error "None of the articles could be interpreted as documents"))
8401 ((gnus-group-read-ephemeral-group
8402 (setq vgroup (format
8403 "nnvirtual:%s-%s" gnus-newsgroup-name
8404 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8405 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8407 (cons (current-buffer) 'summary)))
8409 (error "Couldn't select virtual nndoc group")))))
8411 (defun gnus-summary-isearch-article (&optional regexp-p)
8412 "Do incremental search forward on the current article.
8413 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8415 (gnus-summary-select-article)
8416 (gnus-configure-windows 'article)
8417 (gnus-eval-in-buffer-window gnus-article-buffer
8420 (isearch-forward regexp-p))))
8422 (defun gnus-summary-search-article-forward (regexp &optional backward)
8423 "Search for an article containing REGEXP forward.
8424 If BACKWARD, search backward instead."
8427 (format "Search article %s (regexp%s): "
8428 (if current-prefix-arg "backward" "forward")
8429 (if gnus-last-search-regexp
8430 (concat ", default " gnus-last-search-regexp)
8432 current-prefix-arg))
8433 (if (string-equal regexp "")
8434 (setq regexp (or gnus-last-search-regexp ""))
8435 (setq gnus-last-search-regexp regexp)
8436 (setq gnus-article-before-search gnus-current-article))
8437 ;; Intentionally set gnus-last-article.
8438 (setq gnus-last-article gnus-article-before-search)
8439 (let ((gnus-last-article gnus-last-article))
8440 (if (gnus-summary-search-article regexp backward)
8441 (gnus-summary-show-thread)
8442 (error "Search failed: \"%s\"" regexp))))
8444 (defun gnus-summary-search-article-backward (regexp)
8445 "Search for an article containing REGEXP backward."
8448 (format "Search article backward (regexp%s): "
8449 (if gnus-last-search-regexp
8450 (concat ", default " gnus-last-search-regexp)
8452 (gnus-summary-search-article-forward regexp 'backward))
8454 (defun gnus-summary-search-article (regexp &optional backward)
8455 "Search for an article containing REGEXP.
8456 Optional argument BACKWARD means do search for backward.
8457 `gnus-select-article-hook' is not called during the search."
8458 ;; We have to require this here to make sure that the following
8459 ;; dynamic binding isn't shadowed by autoloading.
8460 (require 'gnus-async)
8462 (let ((gnus-select-article-hook nil) ;Disable hook.
8463 (gnus-article-prepare-hook nil)
8464 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8465 (gnus-use-article-prefetch nil)
8466 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8467 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8469 (gnus-keep-backlog nil)
8470 (gnus-break-pages nil)
8471 (gnus-summary-display-arrow nil)
8472 (gnus-updated-mode-lines nil)
8473 (gnus-auto-center-summary nil)
8474 (sum (current-buffer))
8475 (gnus-display-mime-function nil)
8478 (gnus-save-hidden-threads
8479 (gnus-summary-select-article)
8480 (set-buffer gnus-article-buffer)
8481 (goto-char (window-point (get-buffer-window (current-buffer))))
8485 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8487 (re-search-backward regexp nil t)
8488 (re-search-forward regexp nil t))
8489 ;; We found the regexp.
8494 (get-buffer-window (current-buffer))
8498 (get-buffer-window (current-buffer))
8501 (setq point (point)))
8502 ;; We didn't find it, so we go to the next article.
8505 (while (eq found 'not)
8506 (if (not (if backward (gnus-summary-find-prev)
8507 (gnus-summary-find-next)))
8508 ;; No more articles.
8510 ;; Select the next article and adjust point.
8511 (unless (gnus-summary-article-sparse-p
8512 (gnus-summary-article-number))
8514 (gnus-summary-select-article)
8515 (set-buffer gnus-article-buffer)
8517 (goto-char (if backward (point-max) (point-min))))))))
8518 (gnus-message 7 ""))
8519 ;; Return whether we found the regexp.
8520 (when (eq found 'found)
8522 (gnus-summary-show-thread)
8523 (gnus-summary-goto-subject gnus-current-article)
8524 (gnus-summary-position-point)
8527 (defun gnus-find-matching-articles (header regexp)
8528 "Return a list of all articles that match REGEXP on HEADER.
8529 This search includes all articles in the current group that Gnus has
8530 fetched headers for, whether they are displayed or not."
8531 (let ((articles nil)
8532 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8533 (case-fold-search t))
8534 (dolist (header gnus-newsgroup-headers)
8535 (when (string-match regexp (funcall func header))
8536 (push (mail-header-number header) articles)))
8537 (nreverse articles)))
8539 (defun gnus-summary-find-matching (header regexp &optional backward unread
8540 not-case-fold not-matching)
8541 "Return a list of all articles that match REGEXP on HEADER.
8542 The search stars on the current article and goes forwards unless
8543 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8544 If UNREAD is non-nil, only unread articles will
8545 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8546 in the comparisons. If NOT-MATCHING, return a list of all articles that
8547 not match REGEXP on HEADER."
8548 (let ((case-fold-search (not not-case-fold))
8551 (if (eq (car header) 'extra)
8554 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8556 (error "%s is an invalid header" header))
8557 (unless (fboundp (intern (concat "mail-header-" header)))
8558 (error "%s is not a valid header" header))
8559 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8560 (dolist (d (if (eq backward 'all)
8562 (gnus-data-find-list
8563 (gnus-summary-article-number)
8564 (gnus-data-list backward))))
8565 (when (and (or (not unread) ; We want all articles...
8566 (gnus-data-unread-p d)) ; Or just unreads.
8567 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8571 (funcall func (gnus-data-header d))))
8572 (string-match regexp
8573 (funcall func (gnus-data-header d)))))
8574 (push (gnus-data-number d) articles))) ; Success!
8575 (nreverse articles)))
8577 (defun gnus-summary-execute-command (header regexp command &optional backward)
8578 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8579 If HEADER is an empty string (or nil), the match is done on the entire
8580 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8582 (list (let ((completion-ignore-case t))
8585 (mapcar (lambda (header) (list (format "%s" header)))
8587 '("Number" "Subject" "From" "Lines" "Date"
8588 "Message-ID" "Xref" "References" "Body")
8589 gnus-extra-headers))
8590 nil 'require-match))
8591 (read-string "Regexp: ")
8592 (read-key-sequence "Command: ")
8593 current-prefix-arg))
8594 (when (equal header "Body")
8596 ;; Hidden thread subtrees must be searched as well.
8597 (gnus-summary-show-all-threads)
8598 ;; We don't want to change current point nor window configuration.
8600 (save-window-excursion
8602 gnus-treat-strip-trailing-blank-lines
8603 gnus-treat-strip-leading-blank-lines
8604 gnus-treat-strip-multiple-blank-lines
8605 gnus-treat-hide-boring-headers
8606 gnus-treat-fold-newsgroups
8607 gnus-article-prepare-hook)
8608 (gnus-message 6 "Executing %s..." (key-description command))
8609 ;; We'd like to execute COMMAND interactively so as to give arguments.
8610 (gnus-execute header regexp
8611 `(call-interactively ',(key-binding command))
8613 (gnus-message 6 "Executing %s...done" (key-description command))))))
8615 (defun gnus-summary-beginning-of-article ()
8616 "Scroll the article back to the beginning."
8618 (gnus-summary-select-article)
8619 (gnus-configure-windows 'article)
8620 (gnus-eval-in-buffer-window gnus-article-buffer
8622 (goto-char (point-min))
8623 (when gnus-break-pages
8624 (gnus-narrow-to-page))))
8626 (defun gnus-summary-end-of-article ()
8627 "Scroll to the end of the article."
8629 (gnus-summary-select-article)
8630 (gnus-configure-windows 'article)
8631 (gnus-eval-in-buffer-window gnus-article-buffer
8633 (goto-char (point-max))
8635 (when gnus-break-pages
8636 (when (re-search-backward page-delimiter nil t)
8637 (narrow-to-region (match-end 0) (point-max)))
8638 (gnus-narrow-to-page))))
8640 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8641 "Truncate to LEN and quote all \"(\"'s in STRING."
8642 (gnus-replace-in-string (if (and len (> (length string) len))
8643 (substring string 0 len)
8647 (defun gnus-summary-print-article (&optional filename n)
8648 "Generate and print a PostScript image of the process-marked (mail) articles.
8650 If used interactively, print the current article if none are
8651 process-marked. With prefix arg, prompt the user for the name of the
8654 When used from Lisp, accept two optional args FILENAME and N. N means
8655 to print the next N articles. If N is negative, print the N previous
8656 articles. If N is nil and articles have been marked with the process
8657 mark, print these instead.
8659 If the optional first argument FILENAME is nil, send the image to the
8660 printer. If FILENAME is a string, save the PostScript image in a file with
8661 that name. If FILENAME is a number, prompt the user for the name of the file
8663 (interactive (list (ps-print-preprint current-prefix-arg)))
8664 (dolist (article (gnus-summary-work-articles n))
8665 (gnus-summary-select-article nil nil 'pseudo article)
8666 (gnus-eval-in-buffer-window gnus-article-buffer
8667 (gnus-print-buffer))
8668 (gnus-summary-remove-process-mark article))
8669 (ps-despool filename))
8671 (defun gnus-print-buffer ()
8672 (let ((buffer (generate-new-buffer " *print*")))
8675 (copy-to-buffer buffer (point-min) (point-max))
8677 (gnus-remove-text-with-property 'gnus-decoration)
8678 (when (gnus-visual-p 'article-highlight 'highlight)
8679 ;; Copy-to-buffer doesn't copy overlay. So redo
8681 (let ((gnus-article-buffer buffer))
8682 (gnus-article-highlight-citation t)
8683 (gnus-article-highlight-signature)
8684 (gnus-article-emphasize)
8685 (gnus-article-delete-invisible-text)))
8686 (let ((ps-left-header
8689 (gnus-summary-print-truncate-and-quote
8690 (mail-header-subject gnus-current-headers)
8693 (gnus-summary-print-truncate-and-quote
8694 (mail-header-from gnus-current-headers)
8698 "/pagenumberstring load"
8700 (mail-header-date gnus-current-headers) ")"))))
8701 (gnus-run-hooks 'gnus-ps-print-hook)
8704 (ps-spool-buffer-with-faces)
8705 (ps-spool-buffer)))))
8706 (kill-buffer buffer))))
8708 (defun gnus-summary-show-article (&optional arg)
8709 "Force redisplaying of the current article.
8710 If ARG (the prefix) is a number, show the article with the charset
8711 defined in `gnus-summary-show-article-charset-alist', or the charset
8713 If ARG (the prefix) is non-nil and not a number, show the raw article
8714 without any article massaging functions being run. Normally, the key
8715 strokes are `C-u g'."
8719 (gnus-summary-show-article t)
8720 (let ((gnus-newsgroup-charset
8721 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8722 (mm-read-coding-system
8723 "View as charset: " ;; actually it is coding system.
8725 (set-buffer gnus-article-buffer)
8726 (mm-detect-coding-region (point) (point-max))))))
8727 (gnus-newsgroup-ignored-charsets 'gnus-all))
8728 (gnus-summary-select-article nil 'force)
8729 (let ((deps gnus-newsgroup-dependencies)
8732 (set-buffer gnus-original-article-buffer)
8734 (message-narrow-to-head)
8735 (setq head (buffer-string))
8736 (goto-char (point-min))
8737 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8738 (goto-char (point-max))
8740 (setq lines (1- (count-lines (point) (point-max))))))
8742 (insert (format "211 %d Article retrieved.\n"
8743 (cdr gnus-article-current)))
8745 (if lines (insert (format "Lines: %d\n" lines)))
8747 (let ((nntp-server-buffer (current-buffer)))
8748 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8749 (gnus-data-set-header
8750 (gnus-data-find (cdr gnus-article-current))
8752 (gnus-summary-update-article-line
8753 (cdr gnus-article-current) header)
8754 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8755 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8757 ;; Select the article the normal way.
8758 (gnus-summary-select-article nil 'force))
8760 ;; We have to require this here to make sure that the following
8761 ;; dynamic binding isn't shadowed by autoloading.
8762 (require 'gnus-async)
8764 ;; Bind the article treatment functions to nil.
8765 (let ((gnus-have-all-headers t)
8766 gnus-article-prepare-hook
8767 gnus-article-decode-hook
8768 gnus-display-mime-function
8770 ;; Destroy any MIME parts.
8771 (when (gnus-buffer-live-p gnus-article-buffer)
8773 (set-buffer gnus-article-buffer)
8774 (mm-destroy-parts gnus-article-mime-handles)
8775 ;; Set it to nil for safety reason.
8776 (setq gnus-article-mime-handle-alist nil)
8777 (setq gnus-article-mime-handles nil)))
8778 (gnus-summary-select-article nil 'force))))
8779 (gnus-summary-goto-subject gnus-current-article)
8780 (gnus-summary-position-point))
8782 (defun gnus-summary-show-raw-article ()
8783 "Show the raw article without any article massaging functions being run."
8785 (gnus-summary-show-article t))
8787 (defun gnus-summary-verbose-headers (&optional arg)
8788 "Toggle permanent full header display.
8789 If ARG is a positive number, turn header display on.
8790 If ARG is a negative number, turn header display off."
8792 (setq gnus-show-all-headers
8793 (cond ((or (not (numberp arg))
8795 (not gnus-show-all-headers))
8798 (gnus-summary-show-article))
8800 (defun gnus-summary-toggle-header (&optional arg)
8801 "Show the headers if they are hidden, or hide them if they are shown.
8802 If ARG is a positive number, show the entire header.
8803 If ARG is a negative number, hide the unwanted header lines."
8805 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8806 (get-buffer-window gnus-article-buffer t))))
8807 (with-current-buffer gnus-article-buffer
8809 (article-narrow-to-head)
8810 (let* ((buffer-read-only nil)
8811 (inhibit-point-motion-hooks t)
8812 (hidden (if (numberp arg)
8814 (gnus-article-hidden-text-p 'headers)))
8816 (delete-region (point-min) (point-max))
8817 (with-current-buffer gnus-original-article-buffer
8818 (goto-char (setq s (point-min)))
8819 (setq e (if (search-forward "\n\n" nil t)
8822 (insert-buffer-substring gnus-original-article-buffer s e)
8823 (run-hooks 'gnus-article-decode-hook)
8825 (let ((gnus-treat-hide-headers nil)
8826 (gnus-treat-hide-boring-headers nil))
8827 (gnus-delete-wash-type 'headers)
8828 (gnus-treat-article 'head))
8829 (gnus-treat-article 'head))
8832 (set-window-start window (goto-char (point-min))))
8833 (if gnus-break-pages
8834 (gnus-narrow-to-page)
8835 (when (gnus-visual-p 'page-marker)
8836 (let ((buffer-read-only nil))
8837 (gnus-remove-text-with-property 'gnus-prev)
8838 (gnus-remove-text-with-property 'gnus-next))))
8839 (gnus-set-mode-line 'article)))))
8841 (defun gnus-summary-show-all-headers ()
8842 "Make all header lines visible."
8844 (gnus-summary-toggle-header 1))
8846 (defun gnus-summary-caesar-message (&optional arg)
8847 "Caesar rotate the current article by 13.
8848 The numerical prefix specifies how many places to rotate each letter
8851 (gnus-summary-select-article)
8852 (let ((mail-header-separator ""))
8853 (gnus-eval-in-buffer-window gnus-article-buffer
8856 (let ((start (window-start))
8858 (message-caesar-buffer-body arg)
8859 (set-window-start (get-buffer-window (current-buffer)) start))))))
8861 (autoload 'unmorse-region "morse"
8862 "Convert morse coded text in region to ordinary ASCII text."
8865 (defun gnus-summary-morse-message (&optional arg)
8866 "Morse decode the current article."
8868 (gnus-summary-select-article)
8869 (let ((mail-header-separator ""))
8870 (gnus-eval-in-buffer-window gnus-article-buffer
8874 (let ((pos (window-start))
8876 (goto-char (point-min))
8877 (when (message-goto-body)
8878 (gnus-narrow-to-body))
8879 (goto-char (point-min))
8880 (while (search-forward "·" (point-max) t)
8881 (replace-match "."))
8882 (unmorse-region (point-min) (point-max))
8884 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8886 (defun gnus-summary-stop-page-breaking ()
8887 "Stop page breaking in the current article."
8889 (gnus-summary-select-article)
8890 (gnus-eval-in-buffer-window gnus-article-buffer
8892 (when (gnus-visual-p 'page-marker)
8893 (let ((buffer-read-only nil))
8894 (gnus-remove-text-with-property 'gnus-prev)
8895 (gnus-remove-text-with-property 'gnus-next))
8896 (setq gnus-page-broken nil))))
8898 (defun gnus-summary-move-article (&optional n to-newsgroup
8899 select-method action)
8900 "Move the current article to a different newsgroup.
8901 If N is a positive number, move the N next articles.
8902 If N is a negative number, move the N previous articles.
8903 If N is nil and any articles have been marked with the process mark,
8904 move those articles instead.
8905 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8906 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8907 re-spool using this method.
8909 When called interactively with TO-NEWSGROUP being nil, the value of
8910 the variable `gnus-move-split-methods' is used for finding a default
8911 for the target newsgroup.
8913 For this function to work, both the current newsgroup and the
8914 newsgroup that you want to move to have to support the `request-move'
8915 and `request-accept' functions.
8917 ACTION can be either `move' (the default), `crosspost' or `copy'."
8920 (setq action 'move))
8921 ;; Check whether the source group supports the required functions.
8922 (cond ((and (eq action 'move)
8923 (not (gnus-check-backend-function
8924 'request-move-article gnus-newsgroup-name)))
8925 (error "The current group does not support article moving"))
8926 ((and (eq action 'crosspost)
8927 (not (gnus-check-backend-function
8928 'request-replace-article gnus-newsgroup-name)))
8929 (error "The current group does not support article editing")))
8930 (let ((articles (gnus-summary-work-articles n))
8931 (prefix (if (gnus-check-backend-function
8932 'request-move-article gnus-newsgroup-name)
8933 (funcall gnus-move-group-prefix-function
8934 gnus-newsgroup-name)
8936 (names '((move "Move" "Moving")
8937 (copy "Copy" "Copying")
8938 (crosspost "Crosspost" "Crossposting")))
8939 (copy-buf (save-excursion
8940 (nnheader-set-temp-buffer " *copy article*")))
8941 art-group to-method new-xref article to-groups)
8942 (unless (assq action names)
8943 (error "Unknown action %s" action))
8944 ;; Read the newsgroup name.
8945 (when (and (not to-newsgroup)
8946 (not select-method))
8947 (if (and gnus-move-split-methods
8949 (and (memq gnus-current-article articles)
8950 (gnus-buffer-live-p gnus-original-article-buffer))))
8951 ;; When `gnus-move-split-methods' is non-nil, we have to
8952 ;; select an article to give `gnus-read-move-group-name' an
8953 ;; opportunity to suggest an appropriate default. However,
8954 ;; we needn't render or mark the article.
8955 (let ((gnus-display-mime-function nil)
8956 (gnus-article-prepare-hook nil)
8957 (gnus-mark-article-hook nil))
8958 (gnus-summary-select-article nil nil nil (car articles))))
8960 (gnus-read-move-group-name
8961 (cadr (assq action names))
8962 (symbol-value (intern (format "gnus-current-%s-group" action)))
8964 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8965 (setq to-method (or select-method
8966 (gnus-server-to-method
8967 (gnus-group-method to-newsgroup))))
8968 ;; Check the method we are to move this article to...
8969 (unless (gnus-check-backend-function
8970 'request-accept-article (car to-method))
8971 (error "%s does not support article copying" (car to-method)))
8972 (unless (gnus-check-server to-method)
8973 (error "Can't open server %s" (car to-method)))
8974 (gnus-message 6 "%s to %s: %s..."
8975 (caddr (assq action names))
8976 (or (car select-method) to-newsgroup) articles)
8978 (setq article (pop articles))
8982 ;; Move the article.
8984 ;; Remove this article from future suppression.
8985 (gnus-dup-unsuppress-article article)
8986 (gnus-request-move-article
8987 article ; Article to move
8988 gnus-newsgroup-name ; From newsgroup
8989 (nth 1 (gnus-find-method-for-group
8990 gnus-newsgroup-name)) ; Server
8991 (list 'gnus-request-accept-article
8992 to-newsgroup (list 'quote select-method)
8993 (not articles) t) ; Accept form
8994 (not articles))) ; Only save nov last time
8995 ;; Copy the article.
8998 (set-buffer copy-buf)
8999 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9000 (gnus-request-accept-article
9001 to-newsgroup select-method (not articles) t))))
9002 ;; Crosspost the article.
9003 ((eq action 'crosspost)
9004 (let ((xref (message-tokenize-header
9005 (mail-header-xref (gnus-summary-article-header article))
9007 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9008 ":" (number-to-string article)))
9010 (setq xref (list (system-name))))
9013 (mapconcat 'identity
9014 (delete "Xref:" (delete new-xref xref))
9018 (set-buffer copy-buf)
9019 ;; First put the article in the destination group.
9020 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9021 (when (consp (setq art-group
9022 (gnus-request-accept-article
9023 to-newsgroup select-method (not articles))))
9024 (setq new-xref (concat new-xref " " (car art-group)
9026 (number-to-string (cdr art-group))))
9027 ;; Now we have the new Xrefs header, so we insert
9028 ;; it and replace the new article.
9029 (nnheader-replace-header "Xref" new-xref)
9030 (gnus-request-replace-article
9031 (cdr art-group) to-newsgroup (current-buffer))
9035 (gnus-message 1 "Couldn't %s article %s: %s"
9036 (cadr (assq action names)) article
9037 (nnheader-get-report (car to-method))))
9038 ((eq art-group 'junk)
9039 (when (eq action 'move)
9040 (gnus-summary-mark-article article gnus-canceled-mark)
9041 (gnus-message 4 "Deleted article %s" article)
9042 ;; run the delete hook
9043 (run-hook-with-args 'gnus-summary-article-delete-hook
9046 (assoc article (gnus-data-list nil)))
9047 gnus-newsgroup-name nil
9050 (let* ((pto-group (gnus-group-prefixed-name
9051 (car art-group) to-method))
9052 (info (gnus-get-info pto-group))
9053 (to-group (gnus-info-group info))
9055 ;; Update the group that has been moved to.
9057 (memq action '(move copy)))
9058 (unless (member to-group to-groups)
9059 (push to-group to-groups))
9061 (unless (memq article gnus-newsgroup-unreads)
9062 (push 'read to-marks)
9064 info (gnus-add-to-range (gnus-info-read info)
9065 (list (cdr art-group)))))
9067 ;; See whether the article is to be put in the cache.
9068 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9069 gnus-article-mark-lists
9070 (delete '(expirable . expire)
9071 (copy-sequence gnus-article-mark-lists))))
9072 (to-article (cdr art-group)))
9074 ;; Enter the article into the cache in the new group,
9075 ;; if that is required.
9076 (when gnus-use-cache
9077 (gnus-cache-possibly-enter-article
9079 (memq article gnus-newsgroup-marked)
9080 (memq article gnus-newsgroup-dormant)
9081 (memq article gnus-newsgroup-unreads)))
9083 (when gnus-preserve-marks
9084 ;; Copy any marks over to the new group.
9085 (when (and (equal to-group gnus-newsgroup-name)
9086 (not (memq article gnus-newsgroup-unreads)))
9087 ;; Mark this article as read in this group.
9088 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9089 (setcdr (gnus-active to-group) to-article)
9090 (setcdr gnus-newsgroup-active to-article))
9093 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9094 (when (memq article (symbol-value
9095 (intern (format "gnus-newsgroup-%s"
9097 (push (cdar marks) to-marks)
9098 ;; If the other group is the same as this group,
9099 ;; then we have to add the mark to the list.
9100 (when (equal to-group gnus-newsgroup-name)
9101 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9104 (intern (format "gnus-newsgroup-%s"
9106 ;; Copy the marks to other group.
9107 (gnus-add-marked-articles
9108 to-group (cdar marks) (list to-article) info)))
9109 (setq marks (cdr marks)))
9111 (gnus-request-set-mark
9112 to-group (list (list (list to-article) 'add to-marks))))
9115 (concat "(gnus-group-set-info '"
9116 (gnus-prin1-to-string (gnus-get-info to-group))
9119 ;; Update the Xref header in this article to point to
9120 ;; the new crossposted article we have just created.
9121 (when (eq action 'crosspost)
9123 (set-buffer copy-buf)
9124 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9125 (nnheader-replace-header "Xref" new-xref)
9126 (gnus-request-replace-article
9127 article gnus-newsgroup-name (current-buffer))))
9129 ;; run the move/copy/crosspost/respool hook
9130 (run-hook-with-args 'gnus-summary-article-move-hook
9133 (assoc article (gnus-data-list nil)))
9138 ;;;!!!Why is this necessary?
9139 (set-buffer gnus-summary-buffer)
9141 (gnus-summary-goto-subject article)
9142 (when (eq action 'move)
9143 (gnus-summary-mark-article article gnus-canceled-mark))))
9144 (gnus-summary-remove-process-mark article))
9145 ;; Re-activate all groups that have been moved to.
9147 (set-buffer gnus-group-buffer)
9148 (let ((gnus-group-marked to-groups))
9149 (gnus-group-get-new-news-this-group nil t)))
9151 (gnus-kill-buffer copy-buf)
9152 (gnus-summary-position-point)
9153 (gnus-set-mode-line 'summary)))
9155 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9156 "Move the current article to a different newsgroup.
9157 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9158 When called interactively, if TO-NEWSGROUP is nil, use the value of
9159 the variable `gnus-move-split-methods' for finding a default target
9161 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9162 re-spool using this method."
9164 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9166 (defun gnus-summary-crosspost-article (&optional n)
9167 "Crosspost the current article to some other group."
9169 (gnus-summary-move-article n nil nil 'crosspost))
9171 (defcustom gnus-summary-respool-default-method nil
9172 "Default method type for respooling an article.
9173 If nil, use to the current newsgroup method."
9175 :group 'gnus-summary-mail)
9177 (defcustom gnus-summary-display-while-building nil
9178 "If non-nil, show and update the summary buffer as it's being built.
9179 If the value is t, update the buffer after every line is inserted. If
9180 the value is an integer (N), update the display every N lines."
9182 :type '(choice (const :tag "off" nil)
9184 (const :tag "frequently" t)))
9186 (defun gnus-summary-respool-article (&optional n method)
9187 "Respool the current article.
9188 The article will be squeezed through the mail spooling process again,
9189 which means that it will be put in some mail newsgroup or other
9190 depending on `nnmail-split-methods'.
9191 If N is a positive number, respool the N next articles.
9192 If N is a negative number, respool the N previous articles.
9193 If N is nil and any articles have been marked with the process mark,
9194 respool those articles instead.
9196 Respooling can be done both from mail groups and \"real\" newsgroups.
9197 In the former case, the articles in question will be moved from the
9198 current group into whatever groups they are destined to. In the
9199 latter case, they will be copied into the relevant groups."
9201 (list current-prefix-arg
9202 (let* ((methods (gnus-methods-using 'respool))
9204 (symbol-name (or gnus-summary-respool-default-method
9205 (car (gnus-find-method-for-group
9206 gnus-newsgroup-name)))))
9208 (gnus-completing-read-with-default
9209 methname "What backend do you want to use when respooling?"
9210 methods nil t nil 'gnus-mail-method-history))
9213 ((zerop (length (setq ms (gnus-servers-using-backend
9215 (list (intern method) ""))
9219 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9220 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9223 (error "No method given for respooling"))
9224 (if (assoc (symbol-name
9225 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9226 (gnus-methods-using 'respool))
9227 (gnus-summary-move-article n nil method)
9228 (gnus-summary-copy-article n nil method)))
9230 (defun gnus-summary-import-article (file &optional edit)
9231 "Import an arbitrary file into a mail newsgroup."
9232 (interactive "fImport file: \nP")
9233 (let ((group gnus-newsgroup-name)
9234 (now (current-time))
9235 atts lines group-art)
9236 (unless (gnus-check-backend-function 'request-accept-article group)
9237 (error "%s does not support article importing" group))
9238 (or (file-readable-p file)
9239 (not (file-regular-p file))
9240 (error "Can't read %s" file))
9242 (set-buffer (gnus-get-buffer-create " *import file*"))
9244 (nnheader-insert-file-contents file)
9245 (goto-char (point-min))
9246 (if (nnheader-article-p)
9248 (goto-char (point-min))
9249 (search-forward "\n\n" nil t)
9250 (narrow-to-region (point-min) (1- (point)))
9251 (goto-char (point-min))
9252 (unless (re-search-forward "^date:" nil t)
9253 (goto-char (point-max))
9254 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9255 ;; This doesn't look like an article, so we fudge some headers.
9256 (setq atts (file-attributes file)
9257 lines (count-lines (point-min) (point-max)))
9258 (insert "From: " (read-string "From: ") "\n"
9259 "Subject: " (read-string "Subject: ") "\n"
9260 "Date: " (message-make-date (nth 5 atts)) "\n"
9261 "Message-ID: " (message-make-message-id) "\n"
9262 "Lines: " (int-to-string lines) "\n"
9263 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9264 (setq group-art (gnus-request-accept-article group nil t))
9265 (kill-buffer (current-buffer)))
9266 (setq gnus-newsgroup-active (gnus-activate-group group))
9268 (gnus-summary-goto-article (cdr group-art) nil t)
9270 (gnus-summary-edit-article))))
9272 (defun gnus-summary-create-article ()
9273 "Create an article in a mail newsgroup."
9275 (let ((group gnus-newsgroup-name)
9276 (now (current-time))
9278 (unless (gnus-check-backend-function 'request-accept-article group)
9279 (error "%s does not support article importing" group))
9281 (set-buffer (gnus-get-buffer-create " *import file*"))
9283 (goto-char (point-min))
9284 ;; This doesn't look like an article, so we fudge some headers.
9285 (insert "From: " (read-string "From: ") "\n"
9286 "Subject: " (read-string "Subject: ") "\n"
9287 "Date: " (message-make-date now) "\n"
9288 "Message-ID: " (message-make-message-id) "\n")
9289 (setq group-art (gnus-request-accept-article group nil t))
9290 (kill-buffer (current-buffer)))
9291 (setq gnus-newsgroup-active (gnus-activate-group group))
9293 (gnus-summary-goto-article (cdr group-art) nil t)
9294 (gnus-summary-edit-article)))
9296 (defun gnus-summary-article-posted-p ()
9297 "Say whether the current (mail) article is available from news as well.
9298 This will be the case if the article has both been mailed and posted."
9300 (let ((id (mail-header-references (gnus-summary-article-header)))
9301 (gnus-override-method (car (gnus-refer-article-methods))))
9302 (if (gnus-request-head id "")
9303 (gnus-message 2 "The current message was found on %s"
9304 gnus-override-method)
9305 (gnus-message 2 "The current message couldn't be found on %s"
9306 gnus-override-method)
9309 (defun gnus-summary-expire-articles (&optional now)
9310 "Expire all articles that are marked as expirable in the current group."
9312 (when (and (not gnus-group-is-exiting-without-update-p)
9313 (gnus-check-backend-function
9314 'request-expire-articles gnus-newsgroup-name))
9315 ;; This backend supports expiry.
9316 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9317 (expirable (if total
9319 ;; We need to update the info for
9320 ;; this group for `gnus-list-of-read-articles'
9321 ;; to give us the right answer.
9322 (gnus-run-hooks 'gnus-exit-group-hook)
9323 (gnus-summary-update-info)
9324 (gnus-list-of-read-articles gnus-newsgroup-name))
9325 (setq gnus-newsgroup-expirable
9326 (sort gnus-newsgroup-expirable '<))))
9327 (expiry-wait (if now 'immediate
9328 (gnus-group-find-parameter
9329 gnus-newsgroup-name 'expiry-wait)))
9330 (nnmail-expiry-target
9331 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9332 nnmail-expiry-target))
9335 ;; There are expirable articles in this group, so we run them
9336 ;; through the expiry process.
9337 (gnus-message 6 "Expiring articles...")
9338 (unless (gnus-check-group gnus-newsgroup-name)
9339 (error "Can't open server for %s" gnus-newsgroup-name))
9340 ;; The list of articles that weren't expired is returned.
9343 (let ((nnmail-expiry-wait-function nil)
9344 (nnmail-expiry-wait expiry-wait))
9345 (setq es (gnus-request-expire-articles
9346 expirable gnus-newsgroup-name)))
9347 (setq es (gnus-request-expire-articles
9348 expirable gnus-newsgroup-name)))
9350 (setq gnus-newsgroup-expirable es))
9351 ;; We go through the old list of expirable, and mark all
9352 ;; really expired articles as nonexistent.
9353 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9354 (let ((gnus-use-cache nil))
9355 (dolist (article expirable)
9356 (when (and (not (memq article es))
9357 (gnus-data-find article))
9358 (gnus-summary-mark-article article gnus-canceled-mark)
9359 (run-hook-with-args 'gnus-summary-article-expire-hook
9362 (assoc article (gnus-data-list nil)))
9366 (gnus-message 6 "Expiring articles...done")))))
9368 (defun gnus-summary-expire-articles-now ()
9369 "Expunge all expirable articles in the current group.
9370 This means that *all* articles that are marked as expirable will be
9371 deleted forever, right now."
9373 (or gnus-expert-user
9375 "Are you really, really, really sure you want to delete all these messages? ")
9377 (gnus-summary-expire-articles t))
9379 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9380 (defun gnus-summary-delete-article (&optional n)
9381 "Delete the N next (mail) articles.
9382 This command actually deletes articles. This is not a marking
9383 command. The article will disappear forever from your life, never to
9386 If N is negative, delete backwards.
9387 If N is nil and articles have been marked with the process mark,
9388 delete these instead.
9390 If `gnus-novice-user' is non-nil you will be asked for
9391 confirmation before the articles are deleted."
9393 (unless (gnus-check-backend-function 'request-expire-articles
9394 gnus-newsgroup-name)
9395 (error "The current newsgroup does not support article deletion"))
9396 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9397 (error "Couldn't open server"))
9398 ;; Compute the list of articles to delete.
9399 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9400 (nnmail-expiry-target 'delete)
9402 (if (and gnus-novice-user
9403 (not (gnus-yes-or-no-p
9404 (format "Do you really want to delete %s forever? "
9405 (if (> (length articles) 1)
9406 (format "these %s articles" (length articles))
9409 ;; Delete the articles.
9410 (setq not-deleted (gnus-request-expire-articles
9411 articles gnus-newsgroup-name 'force))
9413 (gnus-summary-remove-process-mark (car articles))
9414 ;; The backend might not have been able to delete the article
9416 (unless (memq (car articles) not-deleted)
9417 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9418 (let* ((article (car articles))
9419 (ghead (gnus-data-header
9420 (assoc article (gnus-data-list nil)))))
9421 (run-hook-with-args 'gnus-summary-article-delete-hook
9422 'delete ghead gnus-newsgroup-name nil
9424 (setq articles (cdr articles)))
9426 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9427 (gnus-summary-position-point)
9428 (gnus-set-mode-line 'summary)
9431 (defun gnus-summary-edit-article (&optional arg)
9432 "Edit the current article.
9433 This will have permanent effect only in mail groups.
9434 If ARG is nil, edit the decoded articles.
9435 If ARG is 1, edit the raw articles.
9436 If ARG is 2, edit the raw articles even in read-only groups.
9437 If ARG is 3, edit the articles with the current handles.
9438 Otherwise, allow editing of articles even in read-only
9441 (let (force raw current-handles)
9450 (setq current-handles
9451 (and (gnus-buffer-live-p gnus-article-buffer)
9452 (with-current-buffer gnus-article-buffer
9454 gnus-article-mime-handles
9455 (setq gnus-article-mime-handles nil))))))
9458 (when (and raw (not force)
9459 (member gnus-newsgroup-name '("nndraft:delayed"
9462 (error "Can't edit the raw article in group %s"
9463 gnus-newsgroup-name))
9465 (set-buffer gnus-summary-buffer)
9466 (let ((mail-parse-charset gnus-newsgroup-charset)
9467 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9468 (gnus-set-global-variables)
9469 (when (and (not force)
9470 (gnus-group-read-only-p))
9471 (error "The current newsgroup does not support article editing"))
9472 (gnus-summary-show-article t)
9473 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9474 (with-current-buffer gnus-article-buffer
9475 (mm-enable-multibyte)))
9476 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9478 (gnus-article-edit-article
9481 (let ((mbl mml-buffer-list))
9482 (setq mml-buffer-list nil)
9483 (mime-to-mml ,'current-handles)
9484 (let ((mbl1 mml-buffer-list))
9485 (setq mml-buffer-list mbl)
9486 (set (make-local-variable 'mml-buffer-list) mbl1))
9487 (gnus-make-local-hook 'kill-buffer-hook)
9488 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9489 `(lambda (no-highlight)
9490 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9491 (message-options message-options)
9492 (message-options-set-recipient)
9493 (mail-parse-ignored-charsets
9494 ',gnus-newsgroup-ignored-charsets))
9495 ,(if (not raw) '(progn
9497 (mml-destroy-buffers)
9498 (remove-hook 'kill-buffer-hook
9499 'mml-destroy-buffers t)
9500 (kill-local-variable 'mml-buffer-list)))
9501 (gnus-summary-edit-article-done
9502 ,(or (mail-header-references gnus-current-headers) "")
9503 ,(gnus-group-read-only-p)
9504 ,gnus-summary-buffer no-highlight))))))))
9506 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9508 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9510 "Make edits to the current article permanent."
9513 ;; The buffer restriction contains the entire article if it exists.
9514 (when (article-goto-body)
9515 (let ((lines (count-lines (point) (point-max)))
9516 (length (- (point-max) (point)))
9517 (case-fold-search t)
9518 (body (copy-marker (point))))
9519 (goto-char (point-min))
9520 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9521 (delete-region (match-beginning 1) (match-end 1))
9522 (insert (number-to-string length)))
9523 (goto-char (point-min))
9524 (when (re-search-forward
9525 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9526 (delete-region (match-beginning 1) (match-end 1))
9527 (insert (number-to-string length)))
9528 (goto-char (point-min))
9529 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9530 (delete-region (match-beginning 1) (match-end 1))
9531 (insert (number-to-string lines))))))
9532 ;; Replace the article.
9533 (let ((buf (current-buffer)))
9535 (insert-buffer-substring buf)
9537 (if (and (not read-only)
9538 (not (gnus-request-replace-article
9539 (cdr gnus-article-current) (car gnus-article-current)
9540 (current-buffer) t)))
9541 (error "Couldn't replace article")
9542 ;; Update the summary buffer.
9544 (equal (message-tokenize-header references " ")
9545 (message-tokenize-header
9546 (or (message-fetch-field "references") "") " ")))
9547 ;; We only have to update this line.
9550 (message-narrow-to-head)
9551 (let ((head (buffer-string))
9554 (insert (format "211 %d Article retrieved.\n"
9555 (cdr gnus-article-current)))
9558 (let ((nntp-server-buffer (current-buffer)))
9559 (setq header (car (gnus-get-newsgroup-headers
9562 (set-buffer gnus-summary-buffer)
9563 (gnus-data-set-header
9564 (gnus-data-find (cdr gnus-article-current))
9566 (gnus-summary-update-article-line
9567 (cdr gnus-article-current) header)
9568 (if (gnus-summary-goto-subject
9569 (cdr gnus-article-current) nil t)
9570 (gnus-summary-update-secondary-mark
9571 (cdr gnus-article-current))))))))
9573 (set-buffer (or buffer gnus-summary-buffer))
9574 (gnus-summary-update-article (cdr gnus-article-current))
9575 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9576 (gnus-summary-update-secondary-mark
9577 (cdr gnus-article-current))))
9578 ;; Prettify the article buffer again.
9579 (unless no-highlight
9581 (set-buffer gnus-article-buffer)
9582 ;;;!!! Fix this -- article should be rehighlighted.
9583 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9584 (set-buffer gnus-original-article-buffer)
9585 (gnus-request-article
9586 (cdr gnus-article-current)
9587 (car gnus-article-current) (current-buffer))))
9588 ;; Prettify the summary buffer line.
9589 (when (gnus-visual-p 'summary-highlight 'highlight)
9590 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9592 (defun gnus-summary-edit-wash (key)
9593 "Perform editing command KEY in the article buffer."
9597 (message "%s" (concat (this-command-keys) "- "))
9600 (gnus-summary-edit-article)
9601 (execute-kbd-macro (concat (this-command-keys) key))
9602 (gnus-article-edit-done))
9606 (defun gnus-summary-respool-query (&optional silent trace)
9607 "Query where the respool algorithm would put this article."
9609 (let (gnus-mark-article-hook)
9610 (gnus-summary-select-article)
9612 (set-buffer gnus-original-article-buffer)
9613 (let ((groups (nnmail-article-group 'identity trace)))
9616 (message "This message would go to %s"
9617 (mapconcat 'car groups ", "))
9618 (message "This message would go to no groups"))
9621 (defun gnus-summary-respool-trace ()
9622 "Trace where the respool algorithm would put this article.
9623 Display a buffer showing all fancy splitting patterns which matched."
9625 (gnus-summary-respool-query nil t))
9627 ;; Summary marking commands.
9629 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9630 "Mark articles which has the same subject as read, and then select the next.
9631 If UNMARK is positive, remove any kind of mark.
9632 If UNMARK is negative, tick articles."
9635 (setq unmark (prefix-numeric-value unmark)))
9637 (gnus-summary-mark-same-subject
9638 (gnus-summary-article-subject) unmark)))
9639 ;; Select next unread article. If auto-select-same mode, should
9640 ;; select the first unread article.
9641 (gnus-summary-next-article t (and gnus-auto-select-same
9642 (gnus-summary-article-subject)))
9643 (gnus-message 7 "%d article%s marked as %s"
9644 count (if (= count 1) " is" "s are")
9645 (if unmark "unread" "read"))))
9647 (defun gnus-summary-kill-same-subject (&optional unmark)
9648 "Mark articles which has the same subject as read.
9649 If UNMARK is positive, remove any kind of mark.
9650 If UNMARK is negative, tick articles."
9653 (setq unmark (prefix-numeric-value unmark)))
9655 (gnus-summary-mark-same-subject
9656 (gnus-summary-article-subject) unmark)))
9657 ;; If marked as read, go to next unread subject.
9659 ;; Go to next unread subject.
9660 (gnus-summary-next-subject 1 t))
9661 (gnus-message 7 "%d articles are marked as %s"
9662 count (if unmark "unread" "read"))))
9664 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9665 "Mark articles with same SUBJECT as read, and return marked number.
9666 If optional argument UNMARK is positive, remove any kinds of marks.
9667 If optional argument UNMARK is negative, mark articles as unread instead."
9671 ((null unmark) ; Mark as read.
9674 (gnus-summary-mark-article-as-read gnus-killed-mark)
9675 (gnus-summary-show-thread) t)
9676 (gnus-summary-find-subject subject))
9677 (setq count (1+ count))))
9678 ((> unmark 0) ; Tick.
9681 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9682 (gnus-summary-show-thread) t)
9683 (gnus-summary-find-subject subject))
9684 (setq count (1+ count))))
9685 (t ; Mark as unread.
9688 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9689 (gnus-summary-show-thread) t)
9690 (gnus-summary-find-subject subject))
9691 (setq count (1+ count)))))
9692 (gnus-set-mode-line 'summary)
9693 ;; Return the number of marked articles.
9696 (defun gnus-summary-mark-as-processable (n &optional unmark)
9697 "Set the process mark on the next N articles.
9698 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9699 the process mark instead. The difference between N and the actual
9700 number of articles marked is returned."
9702 (if (and (null n) (gnus-region-active-p))
9703 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9704 (setq n (prefix-numeric-value n))
9705 (let ((backward (< n 0))
9710 (gnus-summary-remove-process-mark
9711 (gnus-summary-article-number))
9712 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9713 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9716 (gnus-message 7 "No more articles"))
9717 (gnus-summary-recenter)
9718 (gnus-summary-position-point)
9721 (defun gnus-summary-unmark-as-processable (n)
9722 "Remove the process mark from the next N articles.
9723 If N is negative, unmark backward instead. The difference between N and
9724 the actual number of articles unmarked is returned."
9726 (gnus-summary-mark-as-processable n t))
9728 (defun gnus-summary-unmark-all-processable ()
9729 "Remove the process mark from all articles."
9732 (while gnus-newsgroup-processable
9733 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9734 (gnus-summary-position-point))
9736 (defun gnus-summary-add-mark (article type)
9737 "Mark ARTICLE with a mark of TYPE."
9738 (let ((vtype (car (assq type gnus-article-mark-lists)))
9741 (error "No such mark type: %s" type)
9742 (setq var (intern (format "gnus-newsgroup-%s" type)))
9743 (set var (cons article (symbol-value var)))
9744 (if (memq type '(processable cached replied forwarded recent saved))
9745 (gnus-summary-update-secondary-mark article)
9746 ;;; !!! This is bogus. We should find out what primary
9747 ;;; !!! mark we want to set.
9748 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9750 (defun gnus-summary-mark-as-expirable (n)
9751 "Mark N articles forward as expirable.
9752 If N is negative, mark backward instead. The difference between N and
9753 the actual number of articles marked is returned."
9755 (gnus-summary-mark-forward n gnus-expirable-mark))
9757 (defun gnus-summary-mark-as-spam (n)
9758 "Mark N articles forward as spam.
9759 If N is negative, mark backward instead. The difference between N and
9760 the actual number of articles marked is returned."
9762 (gnus-summary-mark-forward n gnus-spam-mark))
9764 (defun gnus-summary-mark-article-as-replied (article)
9765 "Mark ARTICLE as replied to and update the summary line.
9766 ARTICLE can also be a list of articles."
9767 (interactive (list (gnus-summary-article-number)))
9768 (let ((articles (if (listp article) article (list article))))
9769 (dolist (article articles)
9770 (unless (numberp article)
9771 (error "%s is not a number" article))
9772 (push article gnus-newsgroup-replied)
9773 (let ((buffer-read-only nil))
9774 (when (gnus-summary-goto-subject article nil t)
9775 (gnus-summary-update-secondary-mark article))))))
9777 (defun gnus-summary-mark-article-as-forwarded (article)
9778 "Mark ARTICLE as forwarded and update the summary line.
9779 ARTICLE can also be a list of articles."
9780 (let ((articles (if (listp article) article (list article))))
9781 (dolist (article articles)
9782 (push article gnus-newsgroup-forwarded)
9783 (let ((buffer-read-only nil))
9784 (when (gnus-summary-goto-subject article nil t)
9785 (gnus-summary-update-secondary-mark article))))))
9787 (defun gnus-summary-set-bookmark (article)
9788 "Set a bookmark in current article."
9789 (interactive (list (gnus-summary-article-number)))
9790 (when (or (not (get-buffer gnus-article-buffer))
9791 (not gnus-current-article)
9792 (not gnus-article-current)
9793 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9794 (error "No current article selected"))
9795 ;; Remove old bookmark, if one exists.
9796 (gnus-pull article gnus-newsgroup-bookmarks)
9797 ;; Set the new bookmark, which is on the form
9798 ;; (article-number . line-number-in-body).
9801 (with-current-buffer gnus-article-buffer
9808 gnus-newsgroup-bookmarks)
9809 (gnus-message 6 "A bookmark has been added to the current article."))
9811 (defun gnus-summary-remove-bookmark (article)
9812 "Remove the bookmark from the current article."
9813 (interactive (list (gnus-summary-article-number)))
9814 ;; Remove old bookmark, if one exists.
9815 (if (not (assq article gnus-newsgroup-bookmarks))
9816 (gnus-message 6 "No bookmark in current article.")
9817 (gnus-pull article gnus-newsgroup-bookmarks)
9818 (gnus-message 6 "Removed bookmark.")))
9820 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9821 (defun gnus-summary-mark-as-dormant (n)
9822 "Mark N articles forward as dormant.
9823 If N is negative, mark backward instead. The difference between N and
9824 the actual number of articles marked is returned."
9826 (gnus-summary-mark-forward n gnus-dormant-mark))
9828 (defun gnus-summary-set-process-mark (article)
9829 "Set the process mark on ARTICLE and update the summary line."
9830 (setq gnus-newsgroup-processable
9832 (delq article gnus-newsgroup-processable)))
9833 (when (gnus-summary-goto-subject article)
9834 (gnus-summary-show-thread)
9835 (gnus-summary-goto-subject article)
9836 (gnus-summary-update-secondary-mark article)))
9838 (defun gnus-summary-remove-process-mark (article)
9839 "Remove the process mark from ARTICLE and update the summary line."
9840 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9841 (when (gnus-summary-goto-subject article)
9842 (gnus-summary-show-thread)
9843 (gnus-summary-goto-subject article)
9844 (gnus-summary-update-secondary-mark article)))
9846 (defun gnus-summary-set-saved-mark (article)
9847 "Set the process mark on ARTICLE and update the summary line."
9848 (push article gnus-newsgroup-saved)
9849 (when (gnus-summary-goto-subject article)
9850 (gnus-summary-update-secondary-mark article)))
9852 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9853 "Mark N articles as read forwards.
9854 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9855 The difference between N and the actual number of articles marked is
9857 If NO-EXPIRE, auto-expiry will be inhibited."
9859 (gnus-summary-show-thread)
9860 (let ((backward (< n 0))
9861 (gnus-summary-goto-unread
9862 (and gnus-summary-goto-unread
9863 (not (eq gnus-summary-goto-unread 'never))
9864 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9865 gnus-ticked-mark gnus-dormant-mark)))))
9867 (mark (or mark gnus-del-mark)))
9869 (gnus-summary-mark-article nil mark no-expire)
9870 (zerop (gnus-summary-next-subject
9872 (and gnus-summary-goto-unread
9873 (not (eq gnus-summary-goto-unread 'never)))
9877 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9878 (gnus-summary-recenter)
9879 (gnus-summary-position-point)
9880 (gnus-set-mode-line 'summary)
9883 (defun gnus-summary-mark-article-as-read (mark)
9884 "Mark the current article quickly as read with MARK."
9885 (let ((article (gnus-summary-article-number)))
9886 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9887 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9888 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9889 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9890 (push (cons article mark) gnus-newsgroup-reads)
9891 ;; Possibly remove from cache, if that is used.
9892 (when gnus-use-cache
9893 (gnus-cache-enter-remove-article article))
9894 ;; Allow the backend to change the mark.
9895 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9896 ;; Check for auto-expiry.
9897 (when (and gnus-newsgroup-auto-expire
9898 (memq mark gnus-auto-expirable-marks))
9899 (setq mark gnus-expirable-mark)
9900 ;; Let the backend know about the mark change.
9901 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9902 (push article gnus-newsgroup-expirable))
9903 ;; Set the mark in the buffer.
9904 (gnus-summary-update-mark mark 'unread)
9907 (defun gnus-summary-mark-article-as-unread (mark)
9908 "Mark the current article quickly as unread with MARK."
9909 (let* ((article (gnus-summary-article-number))
9910 (old-mark (gnus-summary-article-mark article)))
9911 ;; Allow the backend to change the mark.
9912 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9913 (if (eq mark old-mark)
9917 (gnus-error 1 "Can't mark negative article numbers")
9919 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9920 (setq gnus-newsgroup-spam-marked
9921 (delq article gnus-newsgroup-spam-marked))
9922 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9923 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9924 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9925 (cond ((= mark gnus-ticked-mark)
9926 (setq gnus-newsgroup-marked
9927 (gnus-add-to-sorted-list gnus-newsgroup-marked
9929 ((= mark gnus-spam-mark)
9930 (setq gnus-newsgroup-spam-marked
9931 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9933 ((= mark gnus-dormant-mark)
9934 (setq gnus-newsgroup-dormant
9935 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9938 (setq gnus-newsgroup-unreads
9939 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9941 (gnus-pull article gnus-newsgroup-reads)
9943 ;; See whether the article is to be put in the cache.
9945 (vectorp (gnus-summary-article-header article))
9947 (gnus-cache-possibly-enter-article
9948 gnus-newsgroup-name article
9949 (= mark gnus-ticked-mark)
9950 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9953 (gnus-summary-update-mark mark 'unread)
9956 (defun gnus-summary-mark-article (&optional article mark no-expire)
9957 "Mark ARTICLE with MARK. MARK can be any character.
9958 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9959 `??' (dormant) and `?E' (expirable).
9960 If MARK is nil, then the default character `?r' is used.
9961 If ARTICLE is nil, then the article on the current line will be
9963 If NO-EXPIRE, auto-expiry will be inhibited."
9964 ;; The mark might be a string.
9965 (when (stringp mark)
9966 (setq mark (aref mark 0)))
9967 ;; If no mark is given, then we check auto-expiring.
9969 (setq mark gnus-del-mark))
9970 (when (and (not no-expire)
9971 gnus-newsgroup-auto-expire
9972 (memq mark gnus-auto-expirable-marks))
9973 (setq mark gnus-expirable-mark))
9974 (let ((article (or article (gnus-summary-article-number)))
9975 (old-mark (gnus-summary-article-mark article)))
9976 ;; Allow the backend to change the mark.
9977 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9978 (if (eq mark old-mark)
9981 (error "No article on current line"))
9982 (if (not (if (or (= mark gnus-unread-mark)
9983 (= mark gnus-ticked-mark)
9984 (= mark gnus-spam-mark)
9985 (= mark gnus-dormant-mark))
9986 (gnus-mark-article-as-unread article mark)
9987 (gnus-mark-article-as-read article mark)))
9989 ;; See whether the article is to be put in the cache.
9991 (not (= mark gnus-canceled-mark))
9992 (vectorp (gnus-summary-article-header article))
9994 (gnus-cache-possibly-enter-article
9995 gnus-newsgroup-name article
9996 (= mark gnus-ticked-mark)
9997 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9999 (when (gnus-summary-goto-subject article nil t)
10000 (let ((buffer-read-only nil))
10001 (gnus-summary-show-thread)
10003 (gnus-summary-update-mark mark 'unread)
10006 (defun gnus-summary-update-secondary-mark (article)
10007 "Update the secondary (read, process, cache) mark."
10008 (gnus-summary-update-mark
10009 (cond ((memq article gnus-newsgroup-processable)
10011 ((memq article gnus-newsgroup-cached)
10013 ((memq article gnus-newsgroup-replied)
10015 ((memq article gnus-newsgroup-forwarded)
10016 gnus-forwarded-mark)
10017 ((memq article gnus-newsgroup-saved)
10019 ((memq article gnus-newsgroup-recent)
10021 ((memq article gnus-newsgroup-unseen)
10025 (when (gnus-visual-p 'summary-highlight 'highlight)
10026 (gnus-run-hooks 'gnus-summary-update-hook))
10029 (defun gnus-summary-update-download-mark (article)
10030 "Update the download mark."
10031 (gnus-summary-update-mark
10032 (cond ((memq article gnus-newsgroup-undownloaded)
10033 gnus-undownloaded-mark)
10034 (gnus-newsgroup-agentized
10035 gnus-downloaded-mark)
10039 (gnus-summary-update-line t)
10042 (defun gnus-summary-update-mark (mark type)
10043 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10044 (buffer-read-only nil))
10045 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10047 (when (looking-at "\r")
10049 (when (<= (+ forward (point)) (point-max))
10050 ;; Go to the right position on the line.
10051 (goto-char (+ forward (point)))
10052 ;; Replace the old mark with the new mark.
10053 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10054 ;; Optionally update the marks by some user rule.
10055 (when (eq type 'unread)
10056 (gnus-data-set-mark
10057 (gnus-data-find (gnus-summary-article-number)) mark)
10058 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10060 (defun gnus-mark-article-as-read (article &optional mark)
10061 "Enter ARTICLE in the pertinent lists and remove it from others."
10062 ;; Make the article expirable.
10063 (let ((mark (or mark gnus-del-mark)))
10064 (setq gnus-newsgroup-expirable
10065 (if (= mark gnus-expirable-mark)
10066 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10067 (delq article gnus-newsgroup-expirable)))
10068 ;; Remove from unread and marked lists.
10069 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10070 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10071 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10072 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10073 (push (cons article mark) gnus-newsgroup-reads)
10074 ;; Possibly remove from cache, if that is used.
10075 (when gnus-use-cache
10076 (gnus-cache-enter-remove-article article))
10079 (defun gnus-mark-article-as-unread (article &optional mark)
10080 "Enter ARTICLE in the pertinent lists and remove it from others."
10081 (let ((mark (or mark gnus-ticked-mark)))
10084 (gnus-error 1 "Can't mark negative article numbers")
10086 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10087 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10088 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10089 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10090 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10092 ;; Unsuppress duplicates?
10093 (when gnus-suppress-duplicates
10094 (gnus-dup-unsuppress-article article))
10096 (cond ((= mark gnus-ticked-mark)
10097 (setq gnus-newsgroup-marked
10098 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10099 ((= mark gnus-spam-mark)
10100 (setq gnus-newsgroup-spam-marked
10101 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10103 ((= mark gnus-dormant-mark)
10104 (setq gnus-newsgroup-dormant
10105 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10107 (setq gnus-newsgroup-unreads
10108 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10109 (gnus-pull article gnus-newsgroup-reads)
10112 (defalias 'gnus-summary-mark-as-unread-forward
10113 'gnus-summary-tick-article-forward)
10114 (make-obsolete 'gnus-summary-mark-as-unread-forward
10115 'gnus-summary-tick-article-forward)
10116 (defun gnus-summary-tick-article-forward (n)
10117 "Tick N articles forwards.
10118 If N is negative, tick backwards instead.
10119 The difference between N and the number of articles ticked is returned."
10121 (gnus-summary-mark-forward n gnus-ticked-mark))
10123 (defalias 'gnus-summary-mark-as-unread-backward
10124 'gnus-summary-tick-article-backward)
10125 (make-obsolete 'gnus-summary-mark-as-unread-backward
10126 'gnus-summary-tick-article-backward)
10127 (defun gnus-summary-tick-article-backward (n)
10128 "Tick N articles backwards.
10129 The difference between N and the number of articles ticked is returned."
10131 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10133 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10134 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10135 (defun gnus-summary-tick-article (&optional article clear-mark)
10136 "Mark current article as unread.
10137 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10138 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10140 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10141 gnus-ticked-mark)))
10143 (defun gnus-summary-mark-as-read-forward (n)
10144 "Mark N articles as read forwards.
10145 If N is negative, mark backwards instead.
10146 The difference between N and the actual number of articles marked is
10149 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10151 (defun gnus-summary-mark-as-read-backward (n)
10152 "Mark the N articles as read backwards.
10153 The difference between N and the actual number of articles marked is
10156 (gnus-summary-mark-forward
10157 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10159 (defun gnus-summary-mark-as-read (&optional article mark)
10160 "Mark current article as read.
10161 ARTICLE specifies the article to be marked as read.
10162 MARK specifies a string to be inserted at the beginning of the line."
10163 (gnus-summary-mark-article article mark))
10165 (defun gnus-summary-clear-mark-forward (n)
10166 "Clear marks from N articles forward.
10167 If N is negative, clear backward instead.
10168 The difference between N and the number of marks cleared is returned."
10170 (gnus-summary-mark-forward n gnus-unread-mark))
10172 (defun gnus-summary-clear-mark-backward (n)
10173 "Clear marks from N articles backward.
10174 The difference between N and the number of marks cleared is returned."
10176 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10178 (defun gnus-summary-mark-unread-as-read ()
10179 "Intended to be used by `gnus-summary-mark-article-hook'."
10180 (when (memq gnus-current-article gnus-newsgroup-unreads)
10181 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10183 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10184 "Intended to be used by `gnus-summary-mark-article-hook'."
10185 (let ((mark (gnus-summary-article-mark)))
10186 (when (or (gnus-unread-mark-p mark)
10187 (gnus-read-mark-p mark))
10188 (gnus-summary-mark-article gnus-current-article
10189 (or new-mark gnus-read-mark)))))
10191 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10192 "Intended to be used by `gnus-summary-mark-article-hook'."
10193 (let ((mark (gnus-summary-article-mark)))
10194 (when (or (gnus-unread-mark-p mark)
10195 (gnus-read-mark-p mark))
10196 (gnus-summary-mark-article (gnus-summary-article-number)
10197 (or new-mark gnus-read-mark)))))
10199 (defun gnus-summary-mark-unread-as-ticked ()
10200 "Intended to be used by `gnus-summary-mark-article-hook'."
10201 (when (memq gnus-current-article gnus-newsgroup-unreads)
10202 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10204 (defun gnus-summary-mark-region-as-read (point mark all)
10205 "Mark all unread articles between point and mark as read.
10206 If given a prefix, mark all articles between point and mark as read,
10207 even ticked and dormant ones."
10208 (interactive "r\nP")
10212 (beginning-of-line)
10217 (memq (setq article (gnus-summary-article-number))
10218 gnus-newsgroup-unreads))
10219 (gnus-summary-mark-article article gnus-del-mark))
10221 (gnus-summary-find-next))))))
10223 (defun gnus-summary-mark-below (score mark)
10224 "Mark articles with score less than SCORE with MARK."
10225 (interactive "P\ncMark: ")
10226 (setq score (if score
10227 (prefix-numeric-value score)
10228 (or gnus-summary-default-score 0)))
10230 (set-buffer gnus-summary-buffer)
10231 (goto-char (point-min))
10234 (and (< (gnus-summary-article-score) score)
10235 (gnus-summary-mark-article nil mark))
10236 (gnus-summary-find-next)))))
10238 (defun gnus-summary-kill-below (&optional score)
10239 "Mark articles with score below SCORE as read."
10241 (gnus-summary-mark-below score gnus-killed-mark))
10243 (defun gnus-summary-clear-above (&optional score)
10244 "Clear all marks from articles with score above SCORE."
10246 (gnus-summary-mark-above score gnus-unread-mark))
10248 (defun gnus-summary-tick-above (&optional score)
10249 "Tick all articles with score above SCORE."
10251 (gnus-summary-mark-above score gnus-ticked-mark))
10253 (defun gnus-summary-mark-above (score mark)
10254 "Mark articles with score over SCORE with MARK."
10255 (interactive "P\ncMark: ")
10256 (setq score (if score
10257 (prefix-numeric-value score)
10258 (or gnus-summary-default-score 0)))
10260 (set-buffer gnus-summary-buffer)
10261 (goto-char (point-min))
10263 (when (> (gnus-summary-article-score) score)
10264 (gnus-summary-mark-article nil mark))
10266 (gnus-summary-find-next)))))
10268 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10269 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10270 (defun gnus-summary-limit-include-expunged (&optional no-error)
10271 "Display all the hidden articles that were expunged for low scores."
10273 (let ((buffer-read-only nil))
10274 (let ((scored gnus-newsgroup-scored)
10277 (unless (gnus-summary-article-header (caar scored))
10278 (and (setq h (gnus-number-to-header (caar scored)))
10279 (< (cdar scored) gnus-summary-expunge-below)
10281 (setq scored (cdr scored)))
10283 (when (not no-error)
10284 (error "No expunged articles hidden"))
10285 (goto-char (point-min))
10286 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10287 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10288 (mapcar (lambda (x) (push (mail-header-number x)
10289 gnus-newsgroup-limit))
10291 (gnus-summary-prepare-unthreaded (nreverse headers))
10292 (goto-char (point-min))
10293 (gnus-summary-position-point)
10296 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10297 "Mark all unread articles in this newsgroup as read.
10298 If prefix argument ALL is non-nil, ticked and dormant articles will
10299 also be marked as read.
10300 If QUIETLY is non-nil, no questions will be asked.
10302 If TO-HERE is non-nil, it should be a point in the buffer. All
10303 articles before (after, if REVERSE is set) this point will be marked
10306 Note that this function will only catch up the unread article
10307 in the current summary buffer limitation.
10309 The number of articles marked as read is returned."
10314 (not gnus-interactive-catchup) ;Without confirmation?
10318 "Mark absolutely all articles as read? "
10319 "Mark all unread articles as read? ")))
10321 (not gnus-newsgroup-adaptive)
10322 (not gnus-newsgroup-auto-expire)
10323 (not gnus-suppress-duplicates)
10324 (or (not gnus-use-cache)
10325 (eq gnus-use-cache 'passive)))
10328 (setq gnus-newsgroup-marked nil
10329 gnus-newsgroup-spam-marked nil
10330 gnus-newsgroup-dormant nil))
10331 (setq gnus-newsgroup-unreads
10332 (gnus-sorted-nunion
10333 (gnus-intersection gnus-newsgroup-unreads
10334 gnus-newsgroup-downloadable)
10335 gnus-newsgroup-unfetched)))
10336 ;; We actually mark all articles as canceled, which we
10337 ;; have to do when using auto-expiry or adaptive scoring.
10338 (gnus-summary-show-all-threads)
10339 (if (and to-here reverse)
10341 (goto-char to-here)
10342 (gnus-summary-mark-current-read-and-unread-as-read
10344 (while (gnus-summary-find-next (not all))
10345 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10346 (when (gnus-summary-first-subject (not all))
10348 (if to-here (< (point) to-here) t)
10349 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10350 (gnus-summary-find-next (not all))))))
10351 (gnus-set-mode-line 'summary))
10353 (gnus-summary-position-point)))
10355 (defun gnus-summary-catchup-to-here (&optional all)
10356 "Mark all unticked articles before the current one as read.
10357 If ALL is non-nil, also mark ticked and dormant articles as read."
10360 (gnus-save-hidden-threads
10361 (let ((beg (point)))
10362 ;; We check that there are unread articles.
10363 (when (or all (gnus-summary-find-prev))
10364 (gnus-summary-catchup all t beg)))))
10365 (gnus-summary-position-point))
10367 (defun gnus-summary-catchup-from-here (&optional all)
10368 "Mark all unticked articles after (and including) the current one as read.
10369 If ALL is non-nil, also mark ticked and dormant articles as read."
10372 (gnus-save-hidden-threads
10373 (let ((beg (point)))
10374 ;; We check that there are unread articles.
10375 (when (or all (gnus-summary-find-next))
10376 (gnus-summary-catchup all t beg nil t)))))
10377 (gnus-summary-position-point))
10379 (defun gnus-summary-catchup-all (&optional quietly)
10380 "Mark all articles in this newsgroup as read.
10381 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10382 instead, which marks only unread articles as read."
10384 (gnus-summary-catchup t quietly))
10386 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10387 "Mark all unread articles in this group as read, then exit.
10388 If prefix argument ALL is non-nil, all articles are marked as read.
10389 If QUIETLY is non-nil, no questions will be asked."
10391 (when (gnus-summary-catchup all quietly nil 'fast)
10392 ;; Select next newsgroup or exit.
10393 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10394 (eq gnus-auto-select-next 'quietly))
10395 (gnus-summary-next-group nil)
10396 (gnus-summary-exit))))
10398 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10399 "Mark all articles in this newsgroup as read, and then exit.
10400 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10401 instead, which marks only unread articles as read."
10403 (gnus-summary-catchup-and-exit t quietly))
10405 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10406 "Mark all articles in this group as read and select the next group.
10407 If given a prefix, mark all articles, unread as well as ticked, as
10411 (gnus-summary-catchup all))
10412 (gnus-summary-next-group))
10418 (defmacro gnus-with-article (article &rest forms)
10419 "Select ARTICLE and perform FORMS in the original article buffer.
10420 Then replace the article with the result."
10422 ;; We don't want the article to be marked as read.
10423 (let (gnus-mark-article-hook)
10424 (gnus-summary-select-article t t nil ,article))
10425 (set-buffer gnus-original-article-buffer)
10427 (if (not (gnus-check-backend-function
10428 'request-replace-article (car gnus-article-current)))
10429 (gnus-message 5 "Read-only group; not replacing")
10430 (unless (gnus-request-replace-article
10431 ,article (car gnus-article-current)
10432 (current-buffer) t)
10433 (error "Couldn't replace article")))
10434 ;; The cache and backlog have to be flushed somewhat.
10435 (when gnus-keep-backlog
10436 (gnus-backlog-remove-article
10437 (car gnus-article-current) (cdr gnus-article-current)))
10438 (when gnus-use-cache
10439 (gnus-cache-update-article
10440 (car gnus-article-current) (cdr gnus-article-current)))))
10442 (put 'gnus-with-article 'lisp-indent-function 1)
10443 (put 'gnus-with-article 'edebug-form-spec '(form body))
10445 ;; Thread-based commands.
10447 (defun gnus-summary-articles-in-thread (&optional article)
10448 "Return a list of all articles in the current thread.
10449 If ARTICLE is non-nil, return all articles in the thread that starts
10450 with that article."
10451 (let* ((article (or article (gnus-summary-article-number)))
10452 (data (gnus-data-find-list article))
10453 (top-level (gnus-data-level (car data)))
10455 (cond ((null gnus-thread-operation-ignore-subject)
10456 (gnus-simplify-subject-re
10457 (mail-header-subject (gnus-data-header (car data)))))
10458 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10459 (gnus-simplify-subject-fuzzy
10460 (mail-header-subject (gnus-data-header (car data)))))
10462 (end-point (save-excursion
10463 (if (gnus-summary-go-to-next-thread)
10464 (point) (point-max))))
10467 (< (gnus-data-pos (car data)) end-point))
10468 (when (or (not top-subject)
10469 (string= top-subject
10470 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10471 (gnus-simplify-subject-fuzzy
10472 (mail-header-subject
10473 (gnus-data-header (car data))))
10474 (gnus-simplify-subject-re
10475 (mail-header-subject
10476 (gnus-data-header (car data)))))))
10477 (push (gnus-data-number (car data)) articles))
10478 (unless (and (setq data (cdr data))
10479 (> (gnus-data-level (car data)) top-level))
10481 ;; Return the list of articles.
10482 (nreverse articles)))
10484 (defun gnus-summary-rethread-current ()
10485 "Rethread the thread the current article is part of."
10487 (let* ((gnus-show-threads t)
10488 (article (gnus-summary-article-number))
10489 (id (mail-header-id (gnus-summary-article-header)))
10490 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10492 (error "No article on the current line"))
10493 (gnus-rebuild-thread id)
10494 (gnus-summary-goto-subject article)))
10496 (defun gnus-summary-reparent-thread ()
10497 "Make the current article child of the marked (or previous) article.
10499 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10500 is non-nil or the Subject: of both articles are the same."
10502 (unless (not (gnus-group-read-only-p))
10503 (error "The current newsgroup does not support article editing"))
10504 (unless (<= (length gnus-newsgroup-processable) 1)
10505 (error "No more than one article may be marked"))
10506 (save-window-excursion
10507 (let ((gnus-article-buffer " *reparent*")
10508 (current-article (gnus-summary-article-number))
10509 ;; First grab the marked article, otherwise one line up.
10510 (parent-article (if (not (null gnus-newsgroup-processable))
10511 (car gnus-newsgroup-processable)
10513 (if (eq (forward-line -1) 0)
10514 (gnus-summary-article-number)
10515 (error "Beginning of summary buffer"))))))
10516 (unless (not (eq current-article parent-article))
10517 (error "An article may not be self-referential"))
10518 (let ((message-id (mail-header-id
10519 (gnus-summary-article-header parent-article))))
10520 (unless (and message-id (not (equal message-id "")))
10521 (error "No message-id in desired parent"))
10522 (gnus-with-article current-article
10524 (goto-char (point-min))
10525 (message-narrow-to-head)
10526 (if (re-search-forward "^References: " nil t)
10528 (re-search-forward "^[^ \t]" nil t)
10531 (insert " " message-id))
10532 (insert "References: " message-id "\n"))))
10533 (set-buffer gnus-summary-buffer)
10534 (gnus-summary-unmark-all-processable)
10535 (gnus-summary-update-article current-article)
10536 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10537 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10538 (gnus-summary-rethread-current)
10539 (gnus-message 3 "Article %d is now the child of article %d"
10540 current-article parent-article)))))
10542 (defun gnus-summary-toggle-threads (&optional arg)
10543 "Toggle showing conversation threads.
10544 If ARG is positive number, turn showing conversation threads on."
10546 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10547 (setq gnus-show-threads
10548 (if (null arg) (not gnus-show-threads)
10549 (> (prefix-numeric-value arg) 0)))
10550 (gnus-summary-prepare)
10551 (gnus-summary-goto-subject current)
10552 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10553 (gnus-summary-position-point)))
10555 (defun gnus-summary-show-all-threads ()
10556 "Show all threads."
10559 (let ((buffer-read-only nil))
10560 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10561 (gnus-summary-position-point))
10563 (defun gnus-summary-show-thread ()
10564 "Show thread subtrees.
10565 Returns nil if no thread was there to be shown."
10567 (let ((buffer-read-only nil)
10569 (end (point-at-eol))
10570 ;; Leave point at bol
10571 (beg (progn (beginning-of-line) (point))))
10573 ;; Any hidden lines here?
10574 (search-forward "\r" end t)
10575 (subst-char-in-region beg end ?\^M ?\n t)
10577 (gnus-summary-position-point))))
10579 (defun gnus-summary-maybe-hide-threads ()
10580 "If requested, hide the threads that should be hidden."
10581 (when (and gnus-show-threads
10582 gnus-thread-hide-subtree)
10583 (gnus-summary-hide-all-threads
10584 (if (or (consp gnus-thread-hide-subtree)
10585 (functionp gnus-thread-hide-subtree))
10586 (gnus-make-predicate gnus-thread-hide-subtree)
10589 ;;; Hiding predicates.
10591 (defun gnus-article-unread-p (header)
10592 (memq (mail-header-number header) gnus-newsgroup-unreads))
10594 (defun gnus-article-unseen-p (header)
10595 (memq (mail-header-number header) gnus-newsgroup-unseen))
10597 (defun gnus-map-articles (predicate articles)
10598 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10599 (apply 'gnus-or (mapcar predicate
10600 (mapcar 'gnus-summary-article-header articles))))
10602 (defun gnus-summary-hide-all-threads (&optional predicate)
10603 "Hide all thread subtrees.
10604 If PREDICATE is supplied, threads that satisfy this predicate
10605 will not be hidden."
10608 (goto-char (point-min))
10611 (when (or (not predicate)
10613 predicate (gnus-summary-article-children)))
10614 (gnus-summary-hide-thread))
10615 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10616 (gnus-summary-position-point))
10618 (defun gnus-summary-hide-thread ()
10619 "Hide thread subtrees.
10620 If PREDICATE is supplied, threads that satisfy this predicate
10621 will not be hidden.
10622 Returns nil if no threads were there to be hidden."
10624 (let ((buffer-read-only nil)
10626 (article (gnus-summary-article-number)))
10628 ;; Go forward until either the buffer ends or the subthread
10630 (when (and (not (eobp))
10631 (or (zerop (gnus-summary-next-thread 1 t))
10632 (goto-char (point-max))))
10634 (if (and (> (point) start)
10635 (search-backward "\n" start t))
10637 (subst-char-in-region start (point) ?\n ?\^M)
10638 (gnus-summary-goto-subject article))
10642 (defun gnus-summary-go-to-next-thread (&optional previous)
10643 "Go to the same level (or less) next thread.
10644 If PREVIOUS is non-nil, go to previous thread instead.
10645 Return the article number moved to, or nil if moving was impossible."
10646 (let ((level (gnus-summary-thread-level))
10647 (way (if previous -1 1))
10650 (while (and (not (eobp))
10651 (< level (gnus-summary-thread-level)))
10652 (forward-line way))
10659 (gnus-summary-article-number)
10660 (goto-char beg)))))
10662 (defun gnus-summary-next-thread (n &optional silent)
10663 "Go to the same level next N'th thread.
10664 If N is negative, search backward instead.
10665 Returns the difference between N and the number of skips actually
10668 If SILENT, don't output messages."
10670 (let ((backward (< n 0))
10672 (while (and (> n 0)
10673 (gnus-summary-go-to-next-thread backward))
10676 (gnus-summary-position-point))
10677 (when (and (not silent) (/= 0 n))
10678 (gnus-message 7 "No more threads"))
10681 (defun gnus-summary-prev-thread (n)
10682 "Go to the same level previous N'th thread.
10683 Returns the difference between N and the number of skips actually
10686 (gnus-summary-next-thread (- n)))
10688 (defun gnus-summary-go-down-thread ()
10689 "Go down one level in the current thread."
10690 (let ((children (gnus-summary-article-children)))
10692 (gnus-summary-goto-subject (car children)))))
10694 (defun gnus-summary-go-up-thread ()
10695 "Go up one level in the current thread."
10696 (let ((parent (gnus-summary-article-parent)))
10698 (gnus-summary-goto-subject parent))))
10700 (defun gnus-summary-down-thread (n)
10701 "Go down thread N steps.
10702 If N is negative, go up instead.
10703 Returns the difference between N and how many steps down that were
10708 (while (and (> n 0)
10709 (if up (gnus-summary-go-up-thread)
10710 (gnus-summary-go-down-thread)))
10712 (gnus-summary-position-point)
10714 (gnus-message 7 "Can't go further"))
10717 (defun gnus-summary-up-thread (n)
10718 "Go up thread N steps.
10719 If N is negative, go down instead.
10720 Returns the difference between N and how many steps down that were
10723 (gnus-summary-down-thread (- n)))
10725 (defun gnus-summary-top-thread ()
10726 "Go to the top of the thread."
10728 (while (gnus-summary-go-up-thread))
10729 (gnus-summary-article-number))
10731 (defun gnus-summary-kill-thread (&optional unmark)
10732 "Mark articles under current thread as read.
10733 If the prefix argument is positive, remove any kinds of marks.
10734 If the prefix argument is negative, tick articles instead."
10737 (setq unmark (prefix-numeric-value unmark)))
10738 (let ((articles (gnus-summary-articles-in-thread)))
10740 ;; Expand the thread.
10741 (gnus-summary-show-thread)
10742 ;; Mark all the articles.
10744 (gnus-summary-goto-subject (car articles))
10745 (cond ((null unmark)
10746 (gnus-summary-mark-article-as-read gnus-killed-mark))
10748 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10750 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10751 (setq articles (cdr articles))))
10752 ;; Hide killed subtrees.
10754 gnus-thread-hide-killed
10755 (gnus-summary-hide-thread))
10756 ;; If marked as read, go to next unread subject.
10757 (when (null unmark)
10758 ;; Go to next unread subject.
10759 (gnus-summary-next-subject 1 t)))
10760 (gnus-set-mode-line 'summary))
10762 ;; Summary sorting commands
10764 (defun gnus-summary-sort-by-number (&optional reverse)
10765 "Sort the summary buffer by article number.
10766 Argument REVERSE means reverse order."
10768 (gnus-summary-sort 'number reverse))
10770 (defun gnus-summary-sort-by-random (&optional reverse)
10771 "Randomize the order in the summary buffer.
10772 Argument REVERSE means to randomize in reverse order."
10774 (gnus-summary-sort 'random reverse))
10776 (defun gnus-summary-sort-by-author (&optional reverse)
10777 "Sort the summary buffer by author name alphabetically.
10778 If `case-fold-search' is non-nil, case of letters is ignored.
10779 Argument REVERSE means reverse order."
10781 (gnus-summary-sort 'author reverse))
10783 (defun gnus-summary-sort-by-subject (&optional reverse)
10784 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10785 If `case-fold-search' is non-nil, case of letters is ignored.
10786 Argument REVERSE means reverse order."
10788 (gnus-summary-sort 'subject reverse))
10790 (defun gnus-summary-sort-by-date (&optional reverse)
10791 "Sort the summary buffer by date.
10792 Argument REVERSE means reverse order."
10794 (gnus-summary-sort 'date reverse))
10796 (defun gnus-summary-sort-by-score (&optional reverse)
10797 "Sort the summary buffer by score.
10798 Argument REVERSE means reverse order."
10800 (gnus-summary-sort 'score reverse))
10802 (defun gnus-summary-sort-by-lines (&optional reverse)
10803 "Sort the summary buffer by the number of lines.
10804 Argument REVERSE means reverse order."
10806 (gnus-summary-sort 'lines reverse))
10808 (defun gnus-summary-sort-by-chars (&optional reverse)
10809 "Sort the summary buffer by article length.
10810 Argument REVERSE means reverse order."
10812 (gnus-summary-sort 'chars reverse))
10814 (defun gnus-summary-sort-by-original (&optional reverse)
10815 "Sort the summary buffer using the default sorting method.
10816 Argument REVERSE means reverse order."
10818 (let* ((buffer-read-only)
10819 (gnus-summary-prepare-hook nil))
10820 ;; We do the sorting by regenerating the threads.
10821 (gnus-summary-prepare)
10822 ;; Hide subthreads if needed.
10823 (gnus-summary-maybe-hide-threads)))
10825 (defun gnus-summary-sort (predicate reverse)
10826 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10827 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10828 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10829 (gnus-thread-sort-functions
10834 (gnus-sort-gathered-threads-function
10835 gnus-thread-sort-functions)
10836 (gnus-article-sort-functions
10840 (,article t2 t1))))
10842 (gnus-summary-prepare-hook nil))
10843 ;; We do the sorting by regenerating the threads.
10844 (gnus-summary-prepare)
10845 ;; Hide subthreads if needed.
10846 (gnus-summary-maybe-hide-threads)))
10848 ;; Summary saving commands.
10850 (defun gnus-summary-save-article (&optional n not-saved)
10851 "Save the current article using the default saver function.
10852 If N is a positive number, save the N next articles.
10853 If N is a negative number, save the N previous articles.
10854 If N is nil and any articles have been marked with the process mark,
10855 save those articles instead.
10856 The variable `gnus-default-article-saver' specifies the saver function."
10858 (let* ((articles (gnus-summary-work-articles n))
10859 (save-buffer (save-excursion
10860 (nnheader-set-temp-buffer " *Gnus Save*")))
10861 (num (length articles))
10863 (dolist (article articles)
10864 (setq header (gnus-summary-article-header article))
10865 (if (not (vectorp header))
10866 ;; This is a pseudo-article.
10867 (if (assq 'name header)
10868 (gnus-copy-file (cdr (assq 'name header)))
10869 (gnus-message 1 "Article %d is unsaveable" article))
10870 ;; This is a real article.
10871 (save-window-excursion
10872 (let ((gnus-display-mime-function nil)
10873 (gnus-article-prepare-hook nil))
10874 (gnus-summary-select-article t nil nil article)))
10876 (set-buffer save-buffer)
10878 (insert-buffer-substring gnus-original-article-buffer))
10879 (setq file (gnus-article-save save-buffer file num))
10880 (gnus-summary-remove-process-mark article)
10882 (gnus-summary-set-saved-mark article))))
10883 (gnus-kill-buffer save-buffer)
10884 (gnus-summary-position-point)
10885 (gnus-set-mode-line 'summary)
10888 (defun gnus-summary-pipe-output (&optional arg headers)
10889 "Pipe the current article to a subprocess.
10890 If N is a positive number, pipe the N next articles.
10891 If N is a negative number, pipe the N previous articles.
10892 If N is nil and any articles have been marked with the process mark,
10893 pipe those articles instead.
10894 If HEADERS (the symbolic prefix), include the headers, too."
10895 (interactive (gnus-interactive "P\ny"))
10896 (require 'gnus-art)
10897 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10898 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10899 (gnus-summary-save-article arg t))
10900 (let ((buffer (get-buffer "*Shell Command Output*")))
10902 (not (zerop (buffer-size buffer))))
10903 (gnus-configure-windows 'pipe))))
10905 (defun gnus-summary-save-article-mail (&optional arg)
10906 "Append the current article to an mail file.
10907 If N is a positive number, save the N next articles.
10908 If N is a negative number, save the N previous articles.
10909 If N is nil and any articles have been marked with the process mark,
10910 save those articles instead."
10912 (require 'gnus-art)
10913 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10914 (gnus-summary-save-article arg)))
10916 (defun gnus-summary-save-article-rmail (&optional arg)
10917 "Append the current article to an rmail file.
10918 If N is a positive number, save the N next articles.
10919 If N is a negative number, save the N previous articles.
10920 If N is nil and any articles have been marked with the process mark,
10921 save those articles instead."
10923 (require 'gnus-art)
10924 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10925 (gnus-summary-save-article arg)))
10927 (defun gnus-summary-save-article-file (&optional arg)
10928 "Append the current article to a file.
10929 If N is a positive number, save the N next articles.
10930 If N is a negative number, save the N previous articles.
10931 If N is nil and any articles have been marked with the process mark,
10932 save those articles instead."
10934 (require 'gnus-art)
10935 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10936 (gnus-summary-save-article arg)))
10938 (defun gnus-summary-write-article-file (&optional arg)
10939 "Write the current article to a file, deleting the previous file.
10940 If N is a positive number, save the N next articles.
10941 If N is a negative number, save the N previous articles.
10942 If N is nil and any articles have been marked with the process mark,
10943 save those articles instead."
10945 (require 'gnus-art)
10946 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10947 (gnus-summary-save-article arg)))
10949 (defun gnus-summary-save-article-body-file (&optional arg)
10950 "Append the current article body to a file.
10951 If N is a positive number, save the N next articles.
10952 If N is a negative number, save the N previous articles.
10953 If N is nil and any articles have been marked with the process mark,
10954 save those articles instead."
10956 (require 'gnus-art)
10957 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10958 (gnus-summary-save-article arg)))
10960 (defun gnus-summary-muttprint (&optional arg)
10961 "Print the current article using Muttprint.
10962 If N is a positive number, save the N next articles.
10963 If N is a negative number, save the N previous articles.
10964 If N is nil and any articles have been marked with the process mark,
10965 save those articles instead."
10967 (require 'gnus-art)
10968 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10969 (gnus-summary-save-article arg t)))
10971 (defun gnus-summary-pipe-message (program)
10972 "Pipe the current article through PROGRAM."
10973 (interactive "sProgram: ")
10974 (gnus-summary-select-article)
10975 (let ((mail-header-separator ""))
10976 (gnus-eval-in-buffer-window gnus-article-buffer
10979 (let ((start (window-start))
10981 (message-pipe-buffer-body program)
10982 (set-window-start (get-buffer-window (current-buffer)) start))))))
10984 (defun gnus-get-split-value (methods)
10985 "Return a value based on the split METHODS."
10986 (let (split-name method result match)
10989 (set-buffer gnus-original-article-buffer)
10991 (nnheader-narrow-to-headers)
10992 (while (and methods (not split-name))
10993 (goto-char (point-min))
10994 (setq method (pop methods))
10995 (setq match (car method))
10998 ;; Regular expression.
11000 (re-search-forward match nil t)))
11005 (setq result (funcall match gnus-newsgroup-name))))
11010 (setq result (eval match)))))
11011 (setq split-name (cdr method))
11012 (cond ((stringp result)
11013 (push (expand-file-name
11014 result gnus-article-save-directory)
11017 (setq split-name (append result split-name)))))))))
11018 (nreverse split-name)))
11020 (defun gnus-valid-move-group-p (group)
11021 (and (boundp group)
11022 (symbol-name group)
11023 (symbol-value group)
11024 (gnus-get-function (gnus-find-method-for-group
11025 (symbol-name group)) 'request-accept-article t)))
11027 (defun gnus-read-move-group-name (prompt default articles prefix)
11028 "Read a group name."
11029 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11030 (minibuffer-confirm-incomplete nil) ; XEmacs
11032 (format "%s %s to:"
11034 (if (> (length articles) 1)
11035 (format "these %d articles" (length articles))
11040 (gnus-completing-read-with-default
11043 'gnus-valid-move-group-p
11045 'gnus-group-history))
11046 ((= 1 (length split-name))
11047 (gnus-completing-read-with-default
11048 (car split-name) prom
11050 'gnus-valid-move-group-p
11052 'gnus-group-history))
11054 (gnus-completing-read-with-default
11056 (mapcar 'list (nreverse split-name))
11058 'gnus-group-history))))
11059 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11061 (if (or (string= to-newsgroup "")
11062 (string= to-newsgroup prefix))
11063 (setq to-newsgroup default))
11064 (unless to-newsgroup
11065 (error "No group name entered"))
11066 (or (gnus-active to-newsgroup)
11067 (gnus-activate-group to-newsgroup nil nil to-method)
11068 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11070 (or (and (gnus-request-create-group to-newsgroup to-method)
11071 (gnus-activate-group
11072 to-newsgroup nil nil to-method)
11073 (gnus-subscribe-group to-newsgroup))
11074 (error "Couldn't create group %s" to-newsgroup)))
11075 (error "No such group: %s" to-newsgroup)))
11078 (defun gnus-summary-save-parts (type dir n &optional reverse)
11079 "Save parts matching TYPE to DIR.
11080 If REVERSE, save parts that do not match TYPE."
11082 (list (read-string "Save parts of type: "
11083 (or (car gnus-summary-save-parts-type-history)
11084 gnus-summary-save-parts-default-mime)
11085 'gnus-summary-save-parts-type-history)
11086 (setq gnus-summary-save-parts-last-directory
11087 (read-file-name "Save to directory: "
11088 gnus-summary-save-parts-last-directory
11090 current-prefix-arg))
11091 (gnus-summary-iterate n
11092 (let ((gnus-display-mime-function nil)
11093 (gnus-inhibit-treatment t))
11094 (gnus-summary-select-article))
11096 (set-buffer gnus-article-buffer)
11097 (let ((handles (or gnus-article-mime-handles
11098 (mm-dissect-buffer nil gnus-article-loose-mime)
11099 (and gnus-article-emulate-mime
11100 (mm-uu-dissect)))))
11102 (gnus-summary-save-parts-1 type dir handles reverse)
11103 (unless gnus-article-mime-handles ;; Don't destroy this case.
11104 (mm-destroy-parts handles)))))))
11106 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11107 (if (stringp (car handle))
11108 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11111 (not (string-match type (mm-handle-media-type handle)))
11112 (string-match type (mm-handle-media-type handle)))
11113 (let ((file (expand-file-name
11115 mm-file-name-rewrite-functions
11116 (file-name-nondirectory
11118 (mail-content-type-get
11119 (mm-handle-disposition handle) 'filename)
11120 (mail-content-type-get
11121 (mm-handle-type handle) 'name)
11122 (concat gnus-newsgroup-name
11123 "." (number-to-string
11124 (cdr gnus-article-current))))))
11126 (unless (file-exists-p file)
11127 (mm-save-part-to-file handle file))))))
11129 ;; Summary extract commands
11131 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11132 (let ((buffer-read-only nil)
11133 (article (gnus-summary-article-number))
11135 (unless (gnus-summary-goto-subject article)
11136 (error "No such article: %d" article))
11137 (gnus-summary-position-point)
11138 ;; If all commands are to be bunched up on one line, we collect
11140 (unless gnus-view-pseudos-separately
11141 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11144 (setq action (cdr (assq 'action (car ps))))
11145 (setq files (list (cdr (assq 'name (car ps)))))
11146 (while (and ps (cdr ps)
11147 (string= (or action "1")
11148 (or (cdr (assq 'action (cadr ps))) "2")))
11149 (push (cdr (assq 'name (cadr ps))) files)
11150 (setcdr ps (cddr ps)))
11152 (when (not (string-match "%s" action))
11155 (when (assq 'execute (car ps))
11156 (setcdr (assq 'execute (car ps))
11157 (funcall (if (string-match "%s" action)
11164 (shell-quote-argument f)))
11166 (setq ps (cdr ps)))))
11167 (if (and gnus-view-pseudos (not not-view))
11169 (when (assq 'execute (car pslist))
11170 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11171 (eq gnus-view-pseudos 'not-confirm)))
11172 (setq pslist (cdr pslist)))
11175 (setq after-article (or (cdr (assq 'article (car pslist)))
11176 (gnus-summary-article-number)))
11177 (gnus-summary-goto-subject after-article)
11180 (insert " " (file-name-nondirectory
11181 (cdr (assq 'name (car pslist))))
11182 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11184 (forward-line -1) ; back to `b'
11185 (gnus-add-text-properties
11186 b (1- e) (list 'gnus-number gnus-reffed-article-number
11187 gnus-mouse-face-prop gnus-mouse-face))
11189 after-article gnus-reffed-article-number
11190 gnus-unread-mark b (car pslist) 0 (- e b))
11191 (setq gnus-newsgroup-unreads
11192 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11193 gnus-reffed-article-number))
11194 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11195 (setq pslist (cdr pslist)))))))
11197 (defun gnus-pseudos< (p1 p2)
11198 (let ((c1 (cdr (assq 'action p1)))
11199 (c2 (cdr (assq 'action p2))))
11200 (and c1 c2 (string< c1 c2))))
11202 (defun gnus-request-pseudo-article (props)
11203 (cond ((assq 'execute props)
11204 (gnus-execute-command (cdr (assq 'execute props)))))
11205 (let ((gnus-current-article (gnus-summary-article-number)))
11206 (gnus-run-hooks 'gnus-mark-article-hook)))
11208 (defun gnus-execute-command (command &optional automatic)
11210 (gnus-article-setup-buffer)
11211 (set-buffer gnus-article-buffer)
11212 (setq buffer-read-only nil)
11213 (let ((command (if automatic command
11214 (read-string "Command: " (cons command 0)))))
11216 (insert "$ " command "\n\n")
11217 (if gnus-view-pseudo-asynchronously
11218 (start-process "gnus-execute" (current-buffer) shell-file-name
11219 shell-command-switch command)
11220 (call-process shell-file-name nil t nil
11221 shell-command-switch command)))))
11223 ;; Summary kill commands.
11225 (defun gnus-summary-edit-global-kill (article)
11226 "Edit the \"global\" kill file."
11227 (interactive (list (gnus-summary-article-number)))
11228 (gnus-group-edit-global-kill article))
11230 (defun gnus-summary-edit-local-kill ()
11231 "Edit a local kill file applied to the current newsgroup."
11233 (setq gnus-current-headers (gnus-summary-article-header))
11234 (gnus-group-edit-local-kill
11235 (gnus-summary-article-number) gnus-newsgroup-name))
11237 ;;; Header reading.
11239 (defun gnus-read-header (id &optional header)
11240 "Read the headers of article ID and enter them into the Gnus system."
11241 (let ((group gnus-newsgroup-name)
11242 (gnus-override-method
11244 gnus-override-method
11245 (and (gnus-news-group-p gnus-newsgroup-name)
11246 (car (gnus-refer-article-methods)))))
11248 ;; First we check to see whether the header in question is already
11251 ;; This is a Message-ID.
11252 (setq header (or header (gnus-id-to-header id)))
11253 ;; This is an article number.
11254 (setq header (or header (gnus-summary-article-header id))))
11256 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11257 ;; We have found the header.
11259 ;; We have to really fetch the header to this article.
11261 (set-buffer nntp-server-buffer)
11262 (when (setq where (gnus-request-head id group))
11263 (nnheader-fold-continuation-lines)
11264 (goto-char (point-max))
11266 (goto-char (point-min))
11270 ((cdr where) (cdr where))
11271 (header (mail-header-number header))
11272 (t gnus-reffed-article-number))
11274 (insert " Article retrieved.\n"))
11275 (if (or (not where)
11276 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11277 () ; Malformed head.
11278 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11279 (when (and (stringp id)
11280 (not (string= (gnus-group-real-name group)
11282 ;; If we fetched by Message-ID and the article came
11283 ;; from a different group, we fudge some bogus article
11284 ;; numbers for this article.
11285 (mail-header-set-number header gnus-reffed-article-number))
11287 (set-buffer gnus-summary-buffer)
11288 (decf gnus-reffed-article-number)
11289 (gnus-remove-header (mail-header-number header))
11290 (push header gnus-newsgroup-headers)
11291 (setq gnus-current-headers header)
11292 (push (mail-header-number header) gnus-newsgroup-limit)))
11295 (defun gnus-remove-header (number)
11296 "Remove header NUMBER from `gnus-newsgroup-headers'."
11297 (if (and gnus-newsgroup-headers
11298 (= number (mail-header-number (car gnus-newsgroup-headers))))
11299 (pop gnus-newsgroup-headers)
11300 (let ((headers gnus-newsgroup-headers))
11301 (while (and (cdr headers)
11302 (not (= number (mail-header-number (cadr headers)))))
11304 (when (cdr headers)
11305 (setcdr headers (cddr headers))))))
11308 ;;; summary highlights
11311 (defun gnus-highlight-selected-summary ()
11312 "Highlight selected article in summary buffer."
11313 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11314 (when gnus-summary-selected-face
11316 (let* ((beg (point-at-bol))
11317 (end (point-at-eol))
11318 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11319 (from (if (get-text-property beg gnus-mouse-face-prop)
11321 (or (next-single-property-change
11322 beg gnus-mouse-face-prop nil end)
11327 (or (next-single-property-change
11328 from gnus-mouse-face-prop nil end)
11330 ;; If no mouse-face prop on line we will have to = from = end,
11331 ;; so we highlight the entire line instead.
11332 (when (= (+ to 2) from)
11335 (if gnus-newsgroup-selected-overlay
11336 ;; Move old overlay.
11338 gnus-newsgroup-selected-overlay from to (current-buffer))
11339 ;; Create new overlay.
11341 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11342 'face gnus-summary-selected-face))))))
11344 (defvar gnus-summary-highlight-line-cached nil)
11345 (defvar gnus-summary-highlight-line-trigger nil)
11347 (defun gnus-summary-highlight-line-0 ()
11348 (if (and (eq gnus-summary-highlight-line-trigger
11349 gnus-summary-highlight)
11350 gnus-summary-highlight-line-cached)
11351 gnus-summary-highlight-line-cached
11352 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11353 gnus-summary-highlight-line-cached
11354 (let* ((cond (list 'cond))
11356 (list gnus-summary-highlight))
11358 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11362 (gnus-byte-compile (list 'lambda nil cond))))))
11364 (defun gnus-summary-highlight-line ()
11365 "Highlight current line according to `gnus-summary-highlight'."
11366 (let* ((beg (point-at-bol))
11367 (article (or (gnus-summary-article-number) gnus-current-article))
11368 (score (or (cdr (assq article
11369 gnus-newsgroup-scored))
11370 gnus-summary-default-score 0))
11371 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11372 (inhibit-read-only t)
11373 (default gnus-summary-default-score)
11374 (default-high gnus-summary-default-high-score)
11375 (default-low gnus-summary-default-low-score)
11376 (uncached (and gnus-summary-use-undownloaded-faces
11377 (memq article gnus-newsgroup-undownloaded)
11378 (not (memq article gnus-newsgroup-cached)))))
11379 (let ((face (funcall (gnus-summary-highlight-line-0))))
11380 (unless (eq face (get-text-property beg 'face))
11381 (gnus-put-text-property-excluding-characters-with-faces
11382 beg (point-at-eol) 'face
11383 (setq face (if (boundp face) (symbol-value face) face)))
11384 (when gnus-summary-highlight-line-function
11385 (funcall gnus-summary-highlight-line-function article face))))))
11387 (defun gnus-update-read-articles (group unread &optional compute)
11388 "Update the list of read articles in GROUP.
11389 UNREAD is a sorted list."
11390 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11391 (info (gnus-get-info group))
11394 (if (or (not info) (not active))
11395 ;; There is no info on this group if it was, in fact,
11396 ;; killed. Gnus stores no information on killed groups, so
11397 ;; there's nothing to be done.
11398 ;; One could store the information somewhere temporarily,
11399 ;; perhaps... Hmmm...
11401 ;; Remove any negative articles numbers.
11402 (while (and unread (< (car unread) 0))
11403 (setq unread (cdr unread)))
11404 ;; Remove any expired article numbers
11405 (while (and unread (< (car unread) (car active)))
11406 (setq unread (cdr unread)))
11407 ;; Compute the ranges of read articles by looking at the list of
11408 ;; unread articles.
11410 (when (/= (car unread) prev)
11411 (push (if (= prev (1- (car unread))) prev
11412 (cons prev (1- (car unread))))
11414 (setq prev (1+ (car unread)))
11415 (setq unread (cdr unread)))
11416 (when (<= prev (cdr active))
11417 (push (cons prev (cdr active)) read))
11418 (setq read (if (> (length read) 1) (nreverse read) read))
11423 ;; Propagate the read marks to the backend.
11424 (when (gnus-check-backend-function 'request-set-mark group)
11425 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11426 (add (gnus-remove-from-range read (gnus-info-read info))))
11428 (unless (gnus-check-group group)
11429 (error "Can't open server for %s" group))
11430 (gnus-request-set-mark
11431 group (delq nil (list (if add (list add 'add '(read)))
11432 (if del (list del 'del '(read))))))
11434 `(gnus-request-set-mark
11437 (if del (list del 'add '(read)))
11438 (if add (list add 'del '(read))))))))))
11439 (set-buffer gnus-group-buffer)
11440 (gnus-undo-register
11442 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11443 (gnus-info-set-read ',info ',(gnus-info-read info))
11444 (gnus-get-unread-articles-in-group ',info
11445 (gnus-active ,group))
11446 (gnus-group-update-group ,group t)
11448 ;; Enter this list into the group info.
11449 (gnus-info-set-read info read)
11450 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11451 (gnus-get-unread-articles-in-group info (gnus-active group))
11454 (defun gnus-offer-save-summaries ()
11455 "Offer to save all active summary buffers."
11457 ;; Go through all buffers and find all summaries.
11458 (dolist (buffer (buffer-list))
11459 (when (and (setq buffer (buffer-name buffer))
11460 (string-match "Summary" buffer)
11461 (with-current-buffer buffer
11462 ;; We check that this is, indeed, a summary buffer.
11463 (and (eq major-mode 'gnus-summary-mode)
11464 ;; Also make sure this isn't bogus.
11465 gnus-newsgroup-prepared
11466 ;; Also make sure that this isn't a
11467 ;; dead summary buffer.
11468 (not gnus-dead-summary-mode))))
11469 (push buffer buffers)))
11470 ;; Go through all these summary buffers and offer to save them.
11474 "Update summary buffer %s? "
11476 (switch-to-buffer buf)
11477 (gnus-summary-exit))
11480 (defun gnus-summary-setup-default-charset ()
11481 "Setup newsgroup default charset."
11482 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11483 (setq gnus-newsgroup-charset nil)
11484 (let* ((ignored-charsets
11485 (or gnus-newsgroup-ephemeral-ignored-charsets
11487 (and gnus-newsgroup-name
11488 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11489 gnus-newsgroup-ignored-charsets))))
11490 (setq gnus-newsgroup-charset
11491 (or gnus-newsgroup-ephemeral-charset
11492 (and gnus-newsgroup-name
11493 (gnus-parameter-charset gnus-newsgroup-name))
11494 gnus-default-charset))
11495 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11496 ignored-charsets))))
11502 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11503 "Display the current article buffer fully MIME-buttonized.
11504 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11505 treated as multipart/mixed."
11507 (require 'gnus-art)
11508 (let ((gnus-unbuttonized-mime-types nil)
11509 (gnus-mime-display-multipart-as-mixed show-all-parts))
11510 (gnus-summary-show-article)))
11512 (defun gnus-summary-repair-multipart (article)
11513 "Add a Content-Type header to a multipart article without one."
11514 (interactive (list (gnus-summary-article-number)))
11515 (gnus-with-article article
11516 (message-narrow-to-head)
11517 (message-remove-header "Mime-Version")
11518 (goto-char (point-max))
11519 (insert "Mime-Version: 1.0\n")
11521 (when (search-forward "\n--" nil t)
11522 (let ((separator (buffer-substring (point) (point-at-eol))))
11523 (message-narrow-to-head)
11524 (message-remove-header "Content-Type")
11525 (goto-char (point-max))
11526 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11529 (let (gnus-mark-article-hook)
11530 (gnus-summary-select-article t t nil article)))
11532 (defun gnus-summary-toggle-display-buttonized ()
11533 "Toggle the buttonizing of the article buffer."
11535 (require 'gnus-art)
11536 (if (setq gnus-inhibit-mime-unbuttonizing
11537 (not gnus-inhibit-mime-unbuttonizing))
11538 (let ((gnus-unbuttonized-mime-types nil))
11539 (gnus-summary-show-article))
11540 (gnus-summary-show-article)))
11543 ;;; Generic summary marking commands
11546 (defvar gnus-summary-marking-alist
11547 '((read gnus-del-mark "d")
11548 (unread gnus-unread-mark "u")
11549 (ticked gnus-ticked-mark "!")
11550 (dormant gnus-dormant-mark "?")
11551 (expirable gnus-expirable-mark "e"))
11552 "An alist of names/marks/keystrokes.")
11554 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11555 (defvar gnus-summary-mark-map)
11557 (defun gnus-summary-make-all-marking-commands ()
11558 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11559 (dolist (elem gnus-summary-marking-alist)
11560 (apply 'gnus-summary-make-marking-command elem)))
11562 (defun gnus-summary-make-marking-command (name mark keystroke)
11563 (let ((map (make-sparse-keymap)))
11564 (define-key gnus-summary-generic-mark-map keystroke map)
11565 (dolist (lway `((next "next" next nil "n")
11566 (next-unread "next unread" next t "N")
11567 (prev "previous" prev nil "p")
11568 (prev-unread "previous unread" prev t "P")
11569 (nomove "" nil nil ,keystroke)))
11570 (let ((func (gnus-summary-make-marking-command-1
11571 mark (car lway) lway name)))
11572 (setq func (eval func))
11573 (define-key map (nth 4 lway) func)))))
11575 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11577 (format "gnus-summary-put-mark-as-%s%s"
11578 name (if (eq way 'nomove)
11580 (concat "-" (symbol-name way)))))
11583 "Mark the current article as %s%s.
11584 If N, the prefix, then repeat N times.
11585 If N is negative, move in reverse order.
11586 The difference between N and the actual number of articles marked is
11590 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11592 (defun gnus-summary-generic-mark (n mark move unread)
11593 "Mark N articles with MARK."
11594 (unless (eq major-mode 'gnus-summary-mode)
11595 (error "This command can only be used in the summary buffer"))
11596 (gnus-summary-show-thread)
11599 ((eq move 'next) 1)
11600 ((eq move 'prev) -1)
11602 (if (zerop nummove)
11606 nummove (* -1 nummove))))
11607 (while (and (> n 0)
11608 (gnus-summary-mark-article nil mark)
11609 (zerop (gnus-summary-next-subject nummove unread t)))
11612 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11613 (gnus-summary-recenter)
11614 (gnus-summary-position-point)
11615 (gnus-set-mode-line 'summary)
11618 (defun gnus-summary-insert-articles (articles)
11619 (when (setq articles
11620 (gnus-sorted-difference articles
11621 (mapcar (lambda (h)
11622 (mail-header-number h))
11623 gnus-newsgroup-headers)))
11624 (setq gnus-newsgroup-headers
11626 gnus-newsgroup-headers
11627 (gnus-fetch-headers articles)
11628 'gnus-article-sort-by-number))
11629 ;; Suppress duplicates?
11630 (when gnus-suppress-duplicates
11631 (gnus-dup-suppress-articles))
11633 ;; We might want to build some more threads first.
11634 (when (and gnus-fetch-old-headers
11635 (eq gnus-headers-retrieved-by 'nov))
11636 (if (eq gnus-fetch-old-headers 'invisible)
11637 (gnus-build-all-threads)
11638 (gnus-build-old-threads)))
11639 ;; Let the Gnus agent mark articles as read.
11641 (gnus-agent-get-undownloaded-list))
11642 ;; Remove list identifiers from subject
11643 (when gnus-list-identifiers
11644 (gnus-summary-remove-list-identifiers))
11645 ;; First and last article in this newsgroup.
11646 (when gnus-newsgroup-headers
11647 (setq gnus-newsgroup-begin
11648 (mail-header-number (car gnus-newsgroup-headers))
11650 (mail-header-number
11651 (gnus-last-element gnus-newsgroup-headers))))
11652 (when gnus-use-scoring
11653 (gnus-possibly-score-headers))))
11655 (defun gnus-summary-insert-old-articles (&optional all)
11656 "Insert all old articles in this group.
11657 If ALL is non-nil, already read articles become readable.
11658 If ALL is a number, fetch this number of articles."
11661 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11664 ;; Some nntp servers lie about their active range. When
11665 ;; this happens, the active range can be in the millions.
11666 ;; Use a compressed range to avoid creating a huge list.
11667 (gnus-range-difference (list gnus-newsgroup-active) old))
11668 (setq len (gnus-range-length older))
11673 (let ((older-range (nreverse older)))
11677 (let* ((r (pop older-range))
11678 (min (if (numberp r) r (car r)))
11679 (max (if (numberp r) r (cdr r))))
11680 (while (and (<= min max)
11685 (setq older (gnus-uncompress-range older))))
11687 (setq older (gnus-uncompress-range older)))
11689 (when (and (numberp gnus-large-newsgroup)
11690 (> len gnus-large-newsgroup))
11691 (let* ((cursor-in-echo-area nil)
11692 (initial (gnus-parameter-large-newsgroup-initial
11693 gnus-newsgroup-name))
11697 "How many articles from %s (%s %d): "
11699 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11700 (if initial "max" "default")
11703 (cons (number-to-string initial)
11705 (unless (string-match "^[ \t]*$" input)
11706 (setq all (string-to-number input))
11708 (let ((older-range (nreverse older)))
11712 (let* ((r (pop older-range))
11713 (min (if (numberp r) r (car r)))
11714 (max (if (numberp r) r (cdr r))))
11715 (while (and (<= min max)
11719 max (1- max))))))))))
11720 (setq older (gnus-uncompress-range older))))
11722 (message "No old news.")
11723 (gnus-summary-insert-articles older)
11724 (gnus-summary-limit (gnus-sorted-nunion old older))))
11725 (gnus-summary-position-point)))
11727 (defun gnus-summary-insert-new-articles ()
11728 "Insert all new articles in this group."
11731 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11732 (old-active gnus-newsgroup-active)
11733 (nnmail-fetched-sources (list t))
11735 (setq gnus-newsgroup-active
11736 (gnus-activate-group gnus-newsgroup-name 'scan))
11737 (setq i (cdr gnus-newsgroup-active))
11738 (while (> i (cdr old-active))
11742 (message "No gnus is bad news")
11743 (gnus-summary-insert-articles new)
11744 (setq gnus-newsgroup-unreads
11745 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11746 (gnus-summary-limit (gnus-sorted-nunion old new))))
11747 (gnus-summary-position-point)))
11749 (gnus-summary-make-all-marking-commands)
11751 (gnus-ems-redefine)
11753 (provide 'gnus-sum)
11755 (run-hooks 'gnus-sum-load-hook)
11757 ;; Local Variables:
11758 ;; coding: iso-8859-1
11761 ;;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11762 ;;; gnus-sum.el ends here