1 ;;; gnus-sum.el --- summary mode commands for Semi-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>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
33 (defvar tool-bar-map))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
57 (autoload 'mm-uu-dissect "mm-uu")
58 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
59 "Deuglify broken Outlook (Express) articles and redisplay."
61 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
62 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
63 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-fetch-old-headers nil
73 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
74 If an unread article in the group refers to an older, already read (or
75 just marked as read) article, the old article will not normally be
76 displayed in the Summary buffer. If this variable is t, Gnus
77 will attempt to grab the headers to the old articles, and thereby
78 build complete threads. If it has the value `some', only enough
79 headers to connect otherwise loose threads will be displayed. This
80 variable can also be a number. In that case, no more than that number
81 of old headers will be fetched. If it has the value `invisible', all
82 old headers will be fetched, but none will be displayed.
84 The server has to support NOV for any of this to work."
86 :type '(choice (const :tag "off" nil)
91 (sexp :menu-tag "other" t)))
93 (defcustom gnus-refer-thread-limit 200
94 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
95 If t, fetch all the available old headers."
98 (sexp :menu-tag "other" t)))
100 (defcustom gnus-summary-make-false-root 'adopt
101 "*nil means that Gnus won't gather loose threads.
102 If the root of a thread has expired or been read in a previous
103 session, the information necessary to build a complete thread has been
104 lost. Instead of having many small sub-threads from this original thread
105 scattered all over the summary buffer, Gnus can gather them.
107 If non-nil, Gnus will try to gather all loose sub-threads from an
108 original thread into one large thread.
110 If this variable is non-nil, it should be one of `none', `adopt',
113 If this variable is `none', Gnus will not make a false root, but just
114 present the sub-threads after another.
115 If this variable is `dummy', Gnus will create a dummy root that will
116 have all the sub-threads as children.
117 If this variable is `adopt', Gnus will make one of the \"children\"
118 the parent and mark all the step-children as such.
119 If this variable is `empty', the \"children\" are printed with empty
120 subject fields. (Or rather, they will be printed with a string
121 given by the `gnus-summary-same-subject' variable.)"
123 :type '(choice (const :tag "off" nil)
129 (defcustom gnus-summary-make-false-root-always nil
130 "Always make a false dummy root."
135 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
136 "*A regexp to match subjects to be excluded from loose thread gathering.
137 As loose thread gathering is done on subjects only, that means that
138 there can be many false gatherings performed. By rooting out certain
139 common subjects, gathering might become saner."
143 (defcustom gnus-summary-gather-subject-limit nil
144 "*Maximum length of subject comparisons when gathering loose threads.
145 Use nil to compare full subjects. Setting this variable to a low
146 number will help gather threads that have been corrupted by
147 newsreaders chopping off subject lines, but it might also mean that
148 unrelated articles that have subject that happen to begin with the
149 same few characters will be incorrectly gathered.
151 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
154 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "on" t)))
158 (defcustom gnus-simplify-subject-functions nil
159 "List of functions taking a string argument that simplify subjects.
160 The functions are applied recursively.
162 Useful functions to put in this list include:
163 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
164 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
166 :type '(repeat function))
168 (defcustom gnus-simplify-ignored-prefixes nil
169 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
171 :type '(choice (const :tag "off" nil)
174 (defcustom gnus-build-sparse-threads nil
175 "*If non-nil, fill in the gaps in threads.
176 If `some', only fill in the gaps that are needed to tie loose threads
177 together. If `more', fill in all leaf nodes that Gnus can find. If
178 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
180 :type '(choice (const :tag "off" nil)
183 (sexp :menu-tag "all" t)))
185 (defcustom gnus-summary-thread-gathering-function
186 'gnus-gather-threads-by-subject
187 "*Function used for gathering loose threads.
188 There are two pre-defined functions: `gnus-gather-threads-by-subject',
189 which only takes Subjects into consideration; and
190 `gnus-gather-threads-by-references', which compared the References
191 headers of the articles to find matches."
193 :type '(radio (function-item gnus-gather-threads-by-subject)
194 (function-item gnus-gather-threads-by-references)
195 (function :tag "other")))
197 (defcustom gnus-summary-same-subject ""
198 "*String indicating that the current article has the same subject as the previous.
199 This variable will only be used if the value of
200 `gnus-summary-make-false-root' is `empty'."
201 :group 'gnus-summary-format
204 (defcustom gnus-summary-goto-unread t
205 "*If t, many commands will go to the next unread article.
206 This applies to marking commands as well as other commands that
207 \"naturally\" select the next article, like, for instance, `SPC' at
208 the end of an article.
210 If nil, the marking commands do NOT go to the next unread article
211 \(they go to the next article instead). If `never', commands that
212 usually go to the next unread article, will go to the next article,
213 whether it is read or not."
214 :group 'gnus-summary-marks
215 :link '(custom-manual "(gnus)Setting Marks")
216 :type '(choice (const :tag "off" nil)
218 (sexp :menu-tag "on" t)))
220 (defcustom gnus-summary-default-score 0
221 "*Default article score level.
222 All scores generated by the score files will be added to this score.
223 If this variable is nil, scoring will be disabled."
224 :group 'gnus-score-default
225 :type '(choice (const :tag "disable")
228 (defcustom gnus-summary-default-high-score 0
229 "*Default threshold for a high scored article.
230 An article will be highlighted as high scored if its score is greater
233 :group 'gnus-score-default
236 (defcustom gnus-summary-default-low-score 0
237 "*Default threshold for a low scored article.
238 An article will be highlighted as low scored if its score is smaller
241 :group 'gnus-score-default
244 (defcustom gnus-summary-zcore-fuzz 0
245 "*Fuzziness factor for the zcore in the summary buffer.
246 Articles with scores closer than this to `gnus-summary-default-score'
248 :group 'gnus-summary-format
251 (defcustom gnus-simplify-subject-fuzzy-regexp nil
252 "*Strings to be removed when doing fuzzy matches.
253 This can either be a regular expression or list of regular expressions
254 that will be removed from subject strings if fuzzy subject
255 simplification is selected."
257 :type '(repeat regexp))
259 (defcustom gnus-show-threads t
260 "*If non-nil, display threads in summary mode."
264 (defcustom gnus-thread-hide-subtree nil
265 "*If non-nil, hide all threads initially.
266 This can be a predicate specifier which says which threads to hide.
267 If threads are hidden, you have to run the command
268 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
269 to expose hidden threads."
271 :type '(radio (sexp :format "Non-nil\n"
272 :match (lambda (widget value)
273 (not (or (consp value) (functionp value))))
276 (sexp :tag "Predicate specifier" :size 0)))
278 (defcustom gnus-thread-hide-killed t
279 "*If non-nil, hide killed threads automatically."
283 (defcustom gnus-thread-ignore-subject t
284 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
285 If nil, articles that have different subjects from their parents will
286 start separate threads."
290 (defcustom gnus-thread-operation-ignore-subject t
291 "*If non-nil, subjects will be ignored when doing thread commands.
292 This affects commands like `gnus-summary-kill-thread' and
293 `gnus-summary-lower-thread'.
295 If this variable is nil, articles in the same thread with different
296 subjects will not be included in the operation in question. If this
297 variable is `fuzzy', only articles that have subjects that are fuzzily
298 equal will be included."
300 :type '(choice (const :tag "off" nil)
304 (defcustom gnus-thread-indent-level 4
305 "*Number that says how much each sub-thread should be indented."
309 (defcustom gnus-auto-extend-newsgroup t
310 "*If non-nil, extend newsgroup forward and backward when requested."
311 :group 'gnus-summary-choose
314 (defcustom gnus-auto-select-first t
315 "*If non-nil, select the article under point.
316 Which article this is is controlled by the `gnus-auto-select-subject'
319 If you want to prevent automatic selection of articles in some
320 newsgroups, set the variable to nil in `gnus-select-group-hook'."
321 :group 'gnus-group-select
322 :type '(choice (const :tag "none" nil)
323 (sexp :menu-tag "first" t)))
325 (defcustom gnus-auto-select-subject 'unread
326 "*Says what subject to place under point when entering a group.
328 This variable can either be the symbols `first' (place point on the
329 first subject), `unread' (place point on the subject line of the first
330 unread article), `best' (place point on the subject line of the
331 higest-scored article), `unseen' (place point on the subject line of
332 the first unseen article), 'unseen-or-unread' (place point on the subject
333 line of the first unseen article or, if all article have been seen, on the
334 subject line of the first unread article), or a function to be called to
335 place point on some subject line."
337 :group 'gnus-group-select
338 :type '(choice (const best)
342 (const unseen-or-unread)))
344 (defcustom gnus-dont-select-after-jump-to-other-group nil
345 "If non-nil, don't select the first unread article after entering the
346 other group by the command `gnus-summary-jump-to-other-group'. If nil,
347 it is depend on the value of `gnus-auto-select-first' whether to select
349 :group 'gnus-group-select
352 (defcustom gnus-auto-select-next t
353 "*If non-nil, offer to go to the next group from the end of the previous.
354 If the value is t and the next newsgroup is empty, Gnus will exit
355 summary mode and go back to group mode. If the value is neither nil
356 nor t, Gnus will select the following unread newsgroup. In
357 particular, if the value is the symbol `quietly', the next unread
358 newsgroup will be selected without any confirmation, and if it is
359 `almost-quietly', the next group will be selected without any
360 confirmation if you are located on the last article in the group.
361 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
362 will go to the next group without confirmation."
363 :group 'gnus-summary-maneuvering
364 :type '(choice (const :tag "off" nil)
366 (const almost-quietly)
367 (const slightly-quietly)
368 (sexp :menu-tag "on" t)))
370 (defcustom gnus-auto-select-same nil
371 "*If non-nil, select the next article with the same subject.
372 If there are no more articles with the same subject, go to
373 the first unread article."
374 :group 'gnus-summary-maneuvering
377 (defcustom gnus-auto-goto-ignores 'unfetched
378 "*Says how to handle unfetched articles when maneuvering.
380 This variable can either be the symbols nil (maneuver to any
381 article), `undownloaded' (maneuvering while unplugged ignores articles
382 that have not been fetched), `always-undownloaded' (maneuvering always
383 ignores articles that have not been fetched), `unfetched' (maneuvering
384 ignores articles whose headers have not been fetched).
386 NOTE: The list of unfetched articles will always be nil when plugged
387 and, when unplugged, a subset of the undownloaded article list."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "None" nil)
391 (const :tag "Undownloaded when unplugged" undownloaded)
392 (const :tag "Undownloaded" always-undownloaded)
393 (const :tag "Unfetched" unfetched)))
395 (defcustom gnus-summary-check-current nil
396 "*If non-nil, consider the current article when moving.
397 The \"unread\" movement commands will stay on the same line if the
398 current article is unread."
399 :group 'gnus-summary-maneuvering
402 (defcustom gnus-auto-center-summary 2
403 "*If non-nil, always center the current summary buffer.
404 In particular, if `vertical' do only vertical recentering. If non-nil
405 and non-`vertical', do both horizontal and vertical recentering."
406 :group 'gnus-summary-maneuvering
407 :type '(choice (const :tag "none" nil)
409 (integer :tag "height")
410 (sexp :menu-tag "both" t)))
412 (defvar gnus-auto-center-group t
413 "*If non-nil, always center the group buffer.")
415 (defcustom gnus-show-all-headers nil
416 "*If non-nil, don't hide any headers."
417 :group 'gnus-article-hiding
418 :group 'gnus-article-headers
421 (defcustom gnus-summary-ignore-duplicates nil
422 "*If non-nil, ignore articles with identical Message-ID headers."
426 (defcustom gnus-single-article-buffer t
427 "*If non-nil, display all articles in the same buffer.
428 If nil, each group will get its own article buffer."
429 :group 'gnus-article-various
432 (defcustom gnus-break-pages t
433 "*If non-nil, do page breaking on articles.
434 The page delimiter is specified by the `gnus-page-delimiter'
436 :group 'gnus-article-various
439 (defcustom gnus-show-mime t
440 "*If non-nil, do mime processing of articles.
441 The articles will simply be fed to the function given by
442 `gnus-article-display-method-for-mime'."
443 :group 'gnus-article-mime
446 (defcustom gnus-move-split-methods nil
447 "*Variable used to suggest where articles are to be moved to.
448 It uses the same syntax as the `gnus-split-methods' variable.
449 However, whereas `gnus-split-methods' specifies file names as targets,
450 this variable specifies group names."
451 :group 'gnus-summary-mail
452 :type '(repeat (choice (list :value (fun) function)
453 (cons :value ("" "") regexp (repeat string))
456 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
457 "Function used to compute default prefix for article move/copy/etc prompts.
458 The function should take one argument, a group name, and return a
459 string with the suggested prefix."
460 :group 'gnus-summary-mail
463 ;; FIXME: Although the custom type is `character' for the following variables,
464 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
466 (defcustom gnus-unread-mark ?\ ;;;Whitespace
467 "*Mark used for unread articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-ticked-mark ?!
472 "*Mark used for ticked articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-dormant-mark ??
477 "*Mark used for dormant articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-del-mark ?r
482 "*Mark used for del'd articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-read-mark ?R
487 "*Mark used for read articles."
488 :group 'gnus-summary-marks
491 (defcustom gnus-expirable-mark ?E
492 "*Mark used for expirable articles."
493 :group 'gnus-summary-marks
496 (defcustom gnus-killed-mark ?K
497 "*Mark used for killed articles."
498 :group 'gnus-summary-marks
501 (defcustom gnus-spam-mark ?$
502 "*Mark used for spam articles."
504 :group 'gnus-summary-marks
507 (defcustom gnus-souped-mark ?F
508 "*Mark used for souped articles."
509 :group 'gnus-summary-marks
512 (defcustom gnus-kill-file-mark ?X
513 "*Mark used for articles killed by kill files."
514 :group 'gnus-summary-marks
517 (defcustom gnus-low-score-mark ?Y
518 "*Mark used for articles with a low score."
519 :group 'gnus-summary-marks
522 (defcustom gnus-catchup-mark ?C
523 "*Mark used for articles that are caught up."
524 :group 'gnus-summary-marks
527 (defcustom gnus-replied-mark ?A
528 "*Mark used for articles that have been replied to."
529 :group 'gnus-summary-marks
532 (defcustom gnus-forwarded-mark ?F
533 "*Mark used for articles that have been forwarded."
535 :group 'gnus-summary-marks
538 (defcustom gnus-recent-mark ?N
539 "*Mark used for articles that are recent."
541 :group 'gnus-summary-marks
544 (defcustom gnus-cached-mark ?*
545 "*Mark used for articles that are in the cache."
546 :group 'gnus-summary-marks
549 (defcustom gnus-saved-mark ?S
550 "*Mark used for articles that have been saved."
551 :group 'gnus-summary-marks
554 (defcustom gnus-unseen-mark ?.
555 "*Mark used for articles that haven't been seen."
557 :group 'gnus-summary-marks
560 (defcustom gnus-no-mark ?\ ;;;Whitespace
561 "*Mark used for articles that have no other secondary mark."
563 :group 'gnus-summary-marks
566 (defcustom gnus-ancient-mark ?O
567 "*Mark used for ancient articles."
568 :group 'gnus-summary-marks
571 (defcustom gnus-sparse-mark ?Q
572 "*Mark used for sparsely reffed articles."
573 :group 'gnus-summary-marks
576 (defcustom gnus-canceled-mark ?G
577 "*Mark used for canceled articles."
578 :group 'gnus-summary-marks
581 (defcustom gnus-duplicate-mark ?M
582 "*Mark used for duplicate articles."
583 :group 'gnus-summary-marks
586 (defcustom gnus-undownloaded-mark ?-
587 "*Mark used for articles that weren't downloaded."
589 :group 'gnus-summary-marks
592 (defcustom gnus-downloaded-mark ?+
593 "*Mark used for articles that were downloaded."
594 :group 'gnus-summary-marks
597 (defcustom gnus-downloadable-mark ?%
598 "*Mark used for articles that are to be downloaded."
599 :group 'gnus-summary-marks
602 (defcustom gnus-unsendable-mark ?=
603 "*Mark used for articles that won't be sent."
604 :group 'gnus-summary-marks
607 (defcustom gnus-score-over-mark ?+
608 "*Score mark used for articles with high scores."
609 :group 'gnus-summary-marks
612 (defcustom gnus-score-below-mark ?-
613 "*Score mark used for articles with low scores."
614 :group 'gnus-summary-marks
617 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
618 "*There is no thread under the article."
619 :group 'gnus-summary-marks
622 (defcustom gnus-not-empty-thread-mark ?=
623 "*There is a thread under the article."
624 :group 'gnus-summary-marks
627 (defcustom gnus-view-pseudo-asynchronously nil
628 "*If non-nil, Gnus will view pseudo-articles asynchronously."
629 :group 'gnus-extract-view
632 (defcustom gnus-auto-expirable-marks
633 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
634 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
635 gnus-souped-mark gnus-duplicate-mark)
636 "*The list of marks converted into expiration if a group is auto-expirable."
639 :type '(repeat character))
641 (defcustom gnus-inhibit-user-auto-expire t
642 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
647 (defcustom gnus-view-pseudos nil
648 "*If `automatic', pseudo-articles will be viewed automatically.
649 If `not-confirm', pseudos will be viewed automatically, and the user
650 will not be asked to confirm the command."
651 :group 'gnus-extract-view
652 :type '(choice (const :tag "off" nil)
654 (const not-confirm)))
656 (defcustom gnus-view-pseudos-separately t
657 "*If non-nil, one pseudo-article will be created for each file to be viewed.
658 If nil, all files that use the same viewing command will be given as a
659 list of parameters to that command."
660 :group 'gnus-extract-view
663 (defcustom gnus-insert-pseudo-articles t
664 "*If non-nil, insert pseudo-articles when decoding articles."
665 :group 'gnus-extract-view
668 (defcustom gnus-summary-dummy-line-format
670 "*The format specification for the dummy roots in the summary buffer.
671 It works along the same lines as a normal formatting string,
672 with some simple extensions.
676 General format specifiers can also be used.
677 See `(gnus)Formatting Variables'."
678 :link '(custom-manual "(gnus)Formatting Variables")
679 :group 'gnus-threading
682 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
683 "*The format specification for the summary mode line.
684 It works along the same lines as a normal formatting string,
685 with some simple extensions:
688 %p Unprefixed group name
689 %A Current article number
690 %z Current article score
692 %U Number of unread articles in the group
693 %e Number of unselected articles in the group
694 %Z A string with unread/unselected article counts
695 %g Shortish group name
696 %S Subject of the current article
698 %s Current score file name
699 %d Number of dormant articles
700 %r Number of articles that have been marked as read in this session
701 %E Number of articles expunged by the score files"
702 :group 'gnus-summary-format
705 (defcustom gnus-list-identifiers nil
706 "Regexp that matches list identifiers to be removed from subject.
707 This can also be a list of regexps."
709 :group 'gnus-summary-format
710 :group 'gnus-article-hiding
711 :type '(choice (const :tag "none" nil)
713 (repeat :value (".*") regexp)))
715 (defcustom gnus-summary-mark-below 0
716 "*Mark all articles with a score below this variable as read.
717 This variable is local to each summary buffer and usually set by the
719 :group 'gnus-score-default
722 (defun gnus-widget-reversible-match (widget value)
723 "Ignoring WIDGET, convert VALUE to internal form.
724 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
728 (eq (length value) 2)
729 (eq (nth 0 value) 'not)
730 (symbolp (nth 1 value)))))
732 (defun gnus-widget-reversible-to-internal (widget value)
733 "Ignoring WIDGET, convert VALUE to internal form.
734 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
735 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
739 (list (nth 1 value) t)))
741 (defun gnus-widget-reversible-to-external (widget value)
742 "Ignoring WIDGET, convert VALUE to external form.
743 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
744 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
747 (list 'not (nth 0 value))
750 (define-widget 'gnus-widget-reversible 'group
751 "A `group' that convert values."
752 :match 'gnus-widget-reversible-match
753 :value-to-internal 'gnus-widget-reversible-to-internal
754 :value-to-external 'gnus-widget-reversible-to-external)
756 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
757 "*List of functions used for sorting articles in the summary buffer.
759 Each function takes two articles and returns non-nil if the first
760 article should be sorted before the other. If you use more than one
761 function, the primary sort function should be the last. You should
762 probably always include `gnus-article-sort-by-number' in the list of
763 sorting functions -- preferably first. Also note that sorting by date
764 is often much slower than sorting by number, and the sorting order is
765 very similar. (Sorting by date means sorting by the time the message
766 was sent, sorting by number means sorting by arrival time.)
768 Each item can also be a list `(not F)' where F is a function;
769 this reverses the sort order.
771 Ready-made functions include `gnus-article-sort-by-number',
772 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
773 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
774 and `gnus-article-sort-by-score'.
776 When threading is turned on, the variable `gnus-thread-sort-functions'
777 controls how articles are sorted."
778 :group 'gnus-summary-sort
779 :type '(repeat (gnus-widget-reversible
780 (choice (function-item gnus-article-sort-by-number)
781 (function-item gnus-article-sort-by-author)
782 (function-item gnus-article-sort-by-subject)
783 (function-item gnus-article-sort-by-date)
784 (function-item gnus-article-sort-by-score)
785 (function-item gnus-article-sort-by-random)
786 (function :tag "other"))
787 (boolean :tag "Reverse order"))))
790 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
791 "*List of functions used for sorting threads in the summary buffer.
792 By default, threads are sorted by article number.
794 Each function takes two threads and returns non-nil if the first
795 thread should be sorted before the other. If you use more than one
796 function, the primary sort function should be the last. You should
797 probably always include `gnus-thread-sort-by-number' in the list of
798 sorting functions -- preferably first. Also note that sorting by date
799 is often much slower than sorting by number, and the sorting order is
800 very similar. (Sorting by date means sorting by the time the message
801 was sent, sorting by number means sorting by arrival time.)
803 Each list item can also be a list `(not F)' where F is a
804 function; this specifies reversed sort order.
806 Ready-made functions include `gnus-thread-sort-by-number',
807 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
808 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
809 `gnus-thread-sort-by-most-recent-number',
810 `gnus-thread-sort-by-most-recent-date',
811 `gnus-thread-sort-by-random', and
812 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
814 When threading is turned off, the variable
815 `gnus-article-sort-functions' controls how articles are sorted."
816 :group 'gnus-summary-sort
818 (gnus-widget-reversible
819 (choice (function-item gnus-thread-sort-by-number)
820 (function-item gnus-thread-sort-by-author)
821 (function-item gnus-thread-sort-by-subject)
822 (function-item gnus-thread-sort-by-date)
823 (function-item gnus-thread-sort-by-score)
824 (function-item gnus-thread-sort-by-most-recent-number)
825 (function-item gnus-thread-sort-by-most-recent-date)
826 (function-item gnus-thread-sort-by-random)
827 (function-item gnus-thread-sort-by-total-score)
828 (function :tag "other"))
829 (boolean :tag "Reverse order"))))
831 (defcustom gnus-thread-score-function '+
832 "*Function used for calculating the total score of a thread.
834 The function is called with the scores of the article and each
835 subthread and should then return the score of the thread.
837 Some functions you can use are `+', `max', or `min'."
838 :group 'gnus-summary-sort
841 (defcustom gnus-summary-expunge-below nil
842 "All articles that have a score less than this variable will be expunged.
843 This variable is local to the summary buffers."
844 :group 'gnus-score-default
845 :type '(choice (const :tag "off" nil)
848 (defcustom gnus-thread-expunge-below nil
849 "All threads that have a total score less than this variable will be expunged.
850 See `gnus-thread-score-function' for en explanation of what a
853 This variable is local to the summary buffers."
854 :group 'gnus-threading
855 :group 'gnus-score-default
856 :type '(choice (const :tag "off" nil)
859 (defcustom gnus-summary-mode-hook nil
860 "*A hook for Gnus summary mode.
861 This hook is run before any variables are set in the summary buffer."
862 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
863 :group 'gnus-summary-various
866 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
867 (when (featurep 'xemacs)
868 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
869 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
870 (add-hook 'gnus-summary-mode-hook
871 'gnus-xmas-switch-horizontal-scrollbar-off))
873 (defcustom gnus-summary-menu-hook nil
874 "*Hook run after the creation of the summary mode menu."
875 :group 'gnus-summary-visual
878 (defcustom gnus-summary-exit-hook nil
879 "*A hook called on exit from the summary buffer.
880 It will be called with point in the group buffer."
881 :group 'gnus-summary-exit
884 (defcustom gnus-summary-prepare-hook nil
885 "*A hook called after the summary buffer has been generated.
886 If you want to modify the summary buffer, you can use this hook."
887 :group 'gnus-summary-various
890 (defcustom gnus-summary-prepared-hook nil
891 "*A hook called as the last thing after the summary buffer has been generated."
892 :group 'gnus-summary-various
895 (defcustom gnus-summary-generate-hook nil
896 "*A hook run just before generating the summary buffer.
897 This hook is commonly used to customize threading variables and the
899 :group 'gnus-summary-various
902 (defcustom gnus-select-group-hook nil
903 "*A hook called when a newsgroup is selected.
905 If you'd like to simplify subjects like the
906 `gnus-summary-next-same-subject' command does, you can use the
909 (add-hook gnus-select-group-hook
911 (mapcar (lambda (header)
912 (mail-header-set-subject
914 (gnus-simplify-subject
915 (mail-header-subject header) 're-only)))
916 gnus-newsgroup-headers)))"
917 :group 'gnus-group-select
920 (defcustom gnus-select-article-hook nil
921 "*A hook called when an article is selected."
922 :group 'gnus-summary-choose
923 :options '(gnus-agent-fetch-selected-article)
926 (defcustom gnus-visual-mark-article-hook
927 (list 'gnus-highlight-selected-summary)
928 "*Hook run after selecting an article in the summary buffer.
929 It is meant to be used for highlighting the article in some way. It
930 is not run if `gnus-visual' is nil."
931 :group 'gnus-summary-visual
934 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
935 "*A hook called before parsing the headers."
939 (defcustom gnus-exit-group-hook nil
940 "*A hook called when exiting summary mode.
941 This hook is not called from the non-updating exit commands like `Q'."
945 (defcustom gnus-summary-update-hook
946 (list 'gnus-summary-highlight-line)
947 "*A hook called when a summary line is changed.
948 The hook will not be called if `gnus-visual' is nil.
950 The default function `gnus-summary-highlight-line' will
951 highlight the line according to the `gnus-summary-highlight'
953 :group 'gnus-summary-visual
956 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
957 "*A hook called when an article is selected for the first time.
958 The hook is intended to mark an article as read (or unread)
959 automatically when it is selected."
960 :group 'gnus-summary-choose
963 (defcustom gnus-group-no-more-groups-hook nil
964 "*A hook run when returning to group mode having no more (unread) groups."
965 :group 'gnus-group-select
968 (defcustom gnus-ps-print-hook nil
969 "*A hook run before ps-printing something from Gnus."
973 (defcustom gnus-summary-article-move-hook nil
974 "*A hook called after an article is moved, copied, respooled, or crossposted."
979 (defcustom gnus-summary-article-delete-hook nil
980 "*A hook called after an article is deleted."
985 (defcustom gnus-summary-article-expire-hook nil
986 "*A hook called after an article is expired."
991 (defcustom gnus-summary-display-arrow
992 (and (fboundp 'display-graphic-p)
994 "*If non-nil, display an arrow highlighting the current article."
999 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
1000 "Face used for highlighting the current article in the summary buffer."
1001 :group 'gnus-summary-visual
1004 (defvar gnus-tmp-downloaded nil)
1006 (defcustom gnus-summary-highlight
1007 '(((eq mark gnus-canceled-mark)
1008 . gnus-summary-cancelled-face)
1009 ((and uncached (> score default-high))
1010 . gnus-summary-high-undownloaded-face)
1011 ((and uncached (< score default-low))
1012 . gnus-summary-low-undownloaded-face)
1014 . gnus-summary-normal-undownloaded-face)
1015 ((and (> score default-high)
1016 (or (eq mark gnus-dormant-mark)
1017 (eq mark gnus-ticked-mark)))
1018 . gnus-summary-high-ticked-face)
1019 ((and (< score default-low)
1020 (or (eq mark gnus-dormant-mark)
1021 (eq mark gnus-ticked-mark)))
1022 . gnus-summary-low-ticked-face)
1023 ((or (eq mark gnus-dormant-mark)
1024 (eq mark gnus-ticked-mark))
1025 . gnus-summary-normal-ticked-face)
1026 ((and (> score default-high) (eq mark gnus-ancient-mark))
1027 . gnus-summary-high-ancient-face)
1028 ((and (< score default-low) (eq mark gnus-ancient-mark))
1029 . gnus-summary-low-ancient-face)
1030 ((eq mark gnus-ancient-mark)
1031 . gnus-summary-normal-ancient-face)
1032 ((and (> score default-high) (eq mark gnus-unread-mark))
1033 . gnus-summary-high-unread-face)
1034 ((and (< score default-low) (eq mark gnus-unread-mark))
1035 . gnus-summary-low-unread-face)
1036 ((eq mark gnus-unread-mark)
1037 . gnus-summary-normal-unread-face)
1038 ((> score default-high)
1039 . gnus-summary-high-read-face)
1040 ((< score default-low)
1041 . gnus-summary-low-read-face)
1043 . gnus-summary-normal-read-face))
1044 "*Controls the highlighting of summary buffer lines.
1046 A list of (FORM . FACE) pairs. When deciding how a a particular
1047 summary line should be displayed, each form is evaluated. The content
1048 of the face field after the first true form is used. You can change
1049 how those summary lines are displayed, by editing the face field.
1051 You can use the following variables in the FORM field.
1053 score: The article's score
1054 default: The default article score.
1055 default-high: The default score for high scored articles.
1056 default-low: The default score for low scored articles.
1057 below: The score below which articles are automatically marked as read.
1058 mark: The article's mark.
1059 uncached: Non-nil if the article is uncached."
1060 :group 'gnus-summary-visual
1061 :type '(repeat (cons (sexp :tag "Form" nil)
1064 (defcustom gnus-alter-header-function nil
1065 "Function called to allow alteration of article header structures.
1066 The function is called with one parameter, the article header vector,
1067 which it may alter in any way."
1068 :type '(choice (const :tag "None" nil)
1070 :group 'gnus-summary)
1072 (defvar gnus-decode-encoded-word-function
1073 (mime-find-field-decoder 'From 'nov)
1074 "Variable that says which function should be used to decode a string with encoded words.")
1076 (defcustom gnus-extra-headers '(To Newsgroups)
1077 "*Extra headers to parse."
1079 :group 'gnus-summary
1080 :type '(repeat symbol))
1082 (defcustom gnus-ignored-from-addresses
1083 (and user-mail-address (regexp-quote user-mail-address))
1084 "*Regexp of From headers that may be suppressed in favor of To headers."
1086 :group 'gnus-summary
1089 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1090 "List of charsets that should be ignored.
1091 When these charsets are used in the \"charset\" parameter, the
1092 default charset will be used instead."
1094 :type '(repeat symbol)
1095 :group 'gnus-charset)
1097 (gnus-define-group-parameter
1101 "Return the ignored charsets of GROUP."
1102 :variable gnus-group-ignored-charsets-alist
1104 '(("alt\\.chinese\\.text" iso-8859-1))
1106 "Alist of regexps (to match group names) and charsets that should be ignored.
1107 When these charsets are used in the \"charset\" parameter, the
1108 default charset will be used instead."
1109 :variable-group gnus-charset
1110 :variable-type '(repeat (cons (regexp :tag "Group")
1112 :parameter-type '(choice :tag "Ignored charsets"
1115 :parameter-document "\
1116 List of charsets that should be ignored.
1118 When these charsets are used in the \"charset\" parameter, the
1119 default charset will be used instead.")
1121 (defcustom gnus-group-highlight-words-alist nil
1122 "Alist of group regexps and highlight regexps.
1123 This variable uses the same syntax as `gnus-emphasis-alist'."
1125 :type '(repeat (cons (regexp :tag "Group")
1126 (repeat (list (regexp :tag "Highlight regexp")
1127 (number :tag "Group for entire word" 0)
1128 (number :tag "Group for displayed part" 0)
1130 gnus-emphasis-highlight-words)))))
1131 :group 'gnus-summary-visual)
1133 (defcustom gnus-use-wheel nil
1134 "Use Intelli-mouse on summary movement"
1136 :group 'gnus-summary-maneuvering)
1138 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1139 "Amount to scroll messages by spinning the mouse wheel.
1140 This is actually a cons cell, where the first item is the amount to scroll
1141 on a normal wheel event, and the second is the amount to scroll when the
1142 wheel is moved with the shift key depressed."
1143 :type '(cons (integer :tag "Shift") integer)
1144 :group 'gnus-summary-maneuvering)
1146 (defcustom gnus-wheel-edge-resistance 2
1147 "How hard it should be to change the current article
1148 by moving the mouse over the edge of the article window."
1150 :group 'gnus-summary-maneuvering)
1152 (defcustom gnus-summary-show-article-charset-alist
1154 "Alist of number and charset.
1155 The article will be shown with the charset corresponding to the
1157 For example: ((1 . cn-gb-2312) (2 . big5))."
1159 :type '(repeat (cons (number :tag "Argument" 1)
1160 (symbol :tag "Charset")))
1161 :group 'gnus-charset)
1163 (defcustom gnus-preserve-marks t
1164 "Whether marks are preserved when moving, copying and respooling messages."
1167 :group 'gnus-summary-marks)
1169 (defcustom gnus-alter-articles-to-read-function nil
1170 "Function to be called to alter the list of articles to be selected."
1171 :type '(choice (const nil) function)
1172 :group 'gnus-summary)
1174 (defcustom gnus-orphan-score nil
1175 "*All orphans get this score added. Set in the score file."
1176 :group 'gnus-score-default
1177 :type '(choice (const nil)
1180 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1181 "*A regexp to match MIME parts when saving multiple parts of a
1182 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1183 This regexp will be used by default when prompting the user for which
1184 type of files to save."
1185 :group 'gnus-summary
1188 (defcustom gnus-read-all-available-headers nil
1189 "Whether Gnus should parse all headers made available to it.
1190 This is mostly relevant for slow back ends where the user may
1191 wish to widen the summary buffer to include all headers
1192 that were fetched. Say, for nnultimate groups."
1194 :group 'gnus-summary
1195 :type '(choice boolean regexp))
1197 (defcustom gnus-summary-muttprint-program "muttprint"
1198 "Command (and optional arguments) used to run Muttprint."
1200 :group 'gnus-summary
1203 (defcustom gnus-article-loose-mime t
1204 "If non-nil, don't require MIME-Version header.
1205 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1206 supply the MIME-Version header or deliberately strip it from the mail.
1207 If non-nil (the default), Gnus will treat some articles as MIME
1208 even if the MIME-Version header is missing."
1211 :group 'gnus-article-mime)
1213 (defcustom gnus-article-emulate-mime t
1214 "If non-nil, use MIME emulation for uuencode and the like.
1215 This means that Gnus will search message bodies for text that look
1216 like uuencoded bits, yEncoded bits, and so on, and present that using
1217 the normal Gnus MIME machinery."
1220 :group 'gnus-article-mime)
1222 ;;; Internal variables
1224 (defvar gnus-summary-display-cache nil)
1225 (defvar gnus-article-mime-handles nil)
1226 (defvar gnus-article-decoded-p nil)
1227 (defvar gnus-article-charset nil)
1228 (defvar gnus-article-ignored-charsets nil)
1229 (defvar gnus-scores-exclude-files nil)
1230 (defvar gnus-page-broken nil)
1232 (defvar gnus-original-article nil)
1233 (defvar gnus-article-internal-prepare-hook nil)
1234 (defvar gnus-newsgroup-process-stack nil)
1236 (defvar gnus-thread-indent-array nil)
1237 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1238 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1239 "Function called to sort the articles within a thread after it has been gathered together.")
1241 (defvar gnus-summary-save-parts-type-history nil)
1242 (defvar gnus-summary-save-parts-last-directory nil)
1244 ;; Avoid highlighting in kill files.
1245 (defvar gnus-summary-inhibit-highlight nil)
1246 (defvar gnus-newsgroup-selected-overlay nil)
1247 (defvar gnus-inhibit-limiting nil)
1248 (defvar gnus-newsgroup-adaptive-score-file nil)
1249 (defvar gnus-current-score-file nil)
1250 (defvar gnus-current-move-group nil)
1251 (defvar gnus-current-copy-group nil)
1252 (defvar gnus-current-crosspost-group nil)
1253 (defvar gnus-newsgroup-display nil)
1255 (defvar gnus-newsgroup-dependencies nil)
1256 (defvar gnus-newsgroup-adaptive nil)
1257 (defvar gnus-summary-display-article-function nil)
1258 (defvar gnus-summary-highlight-line-function nil
1259 "Function called after highlighting a summary line.")
1261 (defvar gnus-summary-line-format-alist
1262 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1263 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1264 (?s gnus-tmp-subject-or-nil ?s)
1265 (?n gnus-tmp-name ?s)
1266 (?A (std11-address-string
1267 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1268 (?a (or (std11-full-name-string
1269 (car (mime-entity-read-field gnus-tmp-header 'From)))
1271 (?F gnus-tmp-from ?s)
1272 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1273 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1274 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1275 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1276 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1277 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1278 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1279 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1280 (?L gnus-tmp-lines ?s)
1281 (?O gnus-tmp-downloaded ?c)
1282 (?I gnus-tmp-indentation ?s)
1283 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1284 (?R gnus-tmp-replied ?c)
1285 (?\[ gnus-tmp-opening-bracket ?c)
1286 (?\] gnus-tmp-closing-bracket ?c)
1287 (?\> (make-string gnus-tmp-level ? ) ?s)
1288 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1289 (?i gnus-tmp-score ?d)
1290 (?z gnus-tmp-score-char ?c)
1291 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1292 (?U gnus-tmp-unread ?c)
1293 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1295 (?t (gnus-summary-number-of-articles-in-thread
1296 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1298 (?e (gnus-summary-number-of-articles-in-thread
1299 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1301 (?u gnus-tmp-user-defined ?s)
1302 (?P (gnus-pick-line-number) ?d)
1303 (?B gnus-tmp-thread-tree-header-string ?s)
1304 (user-date (gnus-user-date
1305 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1306 "An alist of format specifications that can appear in summary lines.
1307 These are paired with what variables they correspond with, along with
1308 the type of the variable (string, integer, character, etc).")
1310 (defvar gnus-summary-dummy-line-format-alist
1311 `((?S gnus-tmp-subject ?s)
1312 (?N gnus-tmp-number ?d)
1313 (?u gnus-tmp-user-defined ?s)))
1315 (defvar gnus-summary-mode-line-format-alist
1316 `((?G gnus-tmp-group-name ?s)
1317 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1318 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1319 (?A gnus-tmp-article-number ?d)
1320 (?Z gnus-tmp-unread-and-unselected ?s)
1321 (?V gnus-version ?s)
1322 (?U gnus-tmp-unread-and-unticked ?d)
1323 (?S gnus-tmp-subject ?s)
1324 (?e gnus-tmp-unselected ?d)
1325 (?u gnus-tmp-user-defined ?s)
1326 (?d (length gnus-newsgroup-dormant) ?d)
1327 (?t (length gnus-newsgroup-marked) ?d)
1328 (?h (length gnus-newsgroup-spam-marked) ?d)
1329 (?r (length gnus-newsgroup-reads) ?d)
1330 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1331 (?E gnus-newsgroup-expunged-tally ?d)
1332 (?s (gnus-current-score-file-nondirectory) ?s)))
1334 (defvar gnus-last-search-regexp nil
1335 "Default regexp for article search command.")
1337 (defvar gnus-summary-search-article-matched-data nil
1338 "Last matched data of article search command. It is the local variable
1339 in `gnus-article-buffer' which consists of the list of start position,
1340 end position and text.")
1342 (defvar gnus-last-shell-command nil
1343 "Default shell command on article.")
1345 (defvar gnus-newsgroup-agentized nil
1346 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1347 (defvar gnus-newsgroup-begin nil)
1348 (defvar gnus-newsgroup-end nil)
1349 (defvar gnus-newsgroup-last-rmail nil)
1350 (defvar gnus-newsgroup-last-mail nil)
1351 (defvar gnus-newsgroup-last-folder nil)
1352 (defvar gnus-newsgroup-last-file nil)
1353 (defvar gnus-newsgroup-auto-expire nil)
1354 (defvar gnus-newsgroup-active nil)
1356 (defvar gnus-newsgroup-data nil)
1357 (defvar gnus-newsgroup-data-reverse nil)
1358 (defvar gnus-newsgroup-limit nil)
1359 (defvar gnus-newsgroup-limits nil)
1360 (defvar gnus-summary-use-undownloaded-faces nil)
1362 (defvar gnus-newsgroup-unreads nil
1363 "Sorted list of unread articles in the current newsgroup.")
1365 (defvar gnus-newsgroup-unselected nil
1366 "Sorted list of unselected unread articles in the current newsgroup.")
1368 (defvar gnus-newsgroup-reads nil
1369 "Alist of read articles and article marks in the current newsgroup.")
1371 (defvar gnus-newsgroup-expunged-tally nil)
1373 (defvar gnus-newsgroup-marked nil
1374 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1376 (defvar gnus-newsgroup-spam-marked nil
1377 "List of ranges of articles that have been marked as spam.")
1379 (defvar gnus-newsgroup-killed nil
1380 "List of ranges of articles that have been through the scoring process.")
1382 (defvar gnus-newsgroup-cached nil
1383 "Sorted list of articles that come from the article cache.")
1385 (defvar gnus-newsgroup-saved nil
1386 "List of articles that have been saved.")
1388 (defvar gnus-newsgroup-kill-headers nil)
1390 (defvar gnus-newsgroup-replied nil
1391 "List of articles that have been replied to in the current newsgroup.")
1393 (defvar gnus-newsgroup-forwarded nil
1394 "List of articles that have been forwarded in the current newsgroup.")
1396 (defvar gnus-newsgroup-recent nil
1397 "List of articles that have are recent in the current newsgroup.")
1399 (defvar gnus-newsgroup-expirable nil
1400 "Sorted list of articles in the current newsgroup that can be expired.")
1402 (defvar gnus-newsgroup-processable nil
1403 "List of articles in the current newsgroup that can be processed.")
1405 (defvar gnus-newsgroup-downloadable nil
1406 "Sorted list of articles in the current newsgroup that can be processed.")
1408 (defvar gnus-newsgroup-unfetched nil
1409 "Sorted list of articles in the current newsgroup whose headers have
1410 not been fetched into the agent.
1412 This list will always be a subset of gnus-newsgroup-undownloaded.")
1414 (defvar gnus-newsgroup-undownloaded nil
1415 "List of articles in the current newsgroup that haven't been downloaded.")
1417 (defvar gnus-newsgroup-unsendable nil
1418 "List of articles in the current newsgroup that won't be sent.")
1420 (defvar gnus-newsgroup-bookmarks nil
1421 "List of articles in the current newsgroup that have bookmarks.")
1423 (defvar gnus-newsgroup-dormant nil
1424 "Sorted list of dormant articles in the current newsgroup.")
1426 (defvar gnus-newsgroup-unseen nil
1427 "List of unseen articles in the current newsgroup.")
1429 (defvar gnus-newsgroup-seen nil
1430 "Range of seen articles in the current newsgroup.")
1432 (defvar gnus-newsgroup-articles nil
1433 "List of articles in the current newsgroup.")
1435 (defvar gnus-newsgroup-scored nil
1436 "List of scored articles in the current newsgroup.")
1438 (defvar gnus-newsgroup-incorporated nil
1439 "List of incorporated articles in the current newsgroup.")
1441 (defvar gnus-newsgroup-headers nil
1442 "List of article headers in the current newsgroup.")
1444 (defvar gnus-newsgroup-threads nil)
1446 (defvar gnus-newsgroup-prepared nil
1447 "Whether the current group has been prepared properly.")
1449 (defvar gnus-newsgroup-ancient nil
1450 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1452 (defvar gnus-newsgroup-sparse nil)
1454 (defvar gnus-current-article nil)
1455 (defvar gnus-article-current nil)
1456 (defvar gnus-current-headers nil)
1457 (defvar gnus-have-all-headers nil)
1458 (defvar gnus-last-article nil)
1459 (defvar gnus-newsgroup-history nil)
1460 (defvar gnus-newsgroup-charset nil)
1461 (defvar gnus-newsgroup-ephemeral-charset nil)
1462 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1464 (defvar gnus-article-before-search nil)
1466 (defvar gnus-summary-local-variables
1467 '(gnus-newsgroup-name
1468 gnus-newsgroup-begin gnus-newsgroup-end
1469 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1470 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1471 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1472 gnus-newsgroup-unselected gnus-newsgroup-marked
1473 gnus-newsgroup-spam-marked
1474 gnus-newsgroup-reads gnus-newsgroup-saved
1475 gnus-newsgroup-replied gnus-newsgroup-forwarded
1476 gnus-newsgroup-recent
1477 gnus-newsgroup-expirable
1478 gnus-newsgroup-processable gnus-newsgroup-killed
1479 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1480 gnus-newsgroup-unfetched
1481 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1482 gnus-newsgroup-seen gnus-newsgroup-articles
1483 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1484 gnus-newsgroup-headers gnus-newsgroup-threads
1485 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1486 gnus-current-article gnus-current-headers gnus-have-all-headers
1487 gnus-last-article gnus-article-internal-prepare-hook
1488 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1489 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1490 gnus-thread-expunge-below
1491 gnus-score-alist gnus-current-score-file
1492 (gnus-summary-expunge-below . global)
1493 (gnus-summary-mark-below . global)
1494 (gnus-orphan-score . global)
1495 gnus-newsgroup-active gnus-scores-exclude-files
1496 gnus-newsgroup-history gnus-newsgroup-ancient
1497 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1498 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1499 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1500 (gnus-newsgroup-expunged-tally . 0)
1501 gnus-cache-removable-articles gnus-newsgroup-cached
1502 gnus-newsgroup-data gnus-newsgroup-data-reverse
1503 gnus-newsgroup-limit gnus-newsgroup-limits
1504 gnus-newsgroup-charset gnus-newsgroup-display
1505 gnus-summary-use-undownloaded-faces
1506 gnus-newsgroup-incorporated)
1507 "Variables that are buffer-local to the summary buffers.")
1509 (defvar gnus-newsgroup-variables nil
1510 "A list of variables that have separate values in different newsgroups.
1511 A list of newsgroup (summary buffer) local variables, or cons of
1512 variables and their default expressions to be evalled (when the default
1513 values are not nil), that should be made global while the summary buffer
1516 Note: The default expressions will be evaluated (using function `eval')
1517 before assignment to the local variable rather than just assigned to it.
1518 If the default expression is the symbol `global', that symbol will not
1519 be evaluated but the global value of the local variable will be used
1522 These variables can be used to set variables in the group parameters
1523 while still allowing them to affect operations done in other buffers.
1526 \(setq gnus-newsgroup-variables
1527 '(message-use-followup-to
1528 (gnus-visible-headers .
1529 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1532 ;; Byte-compiler warning.
1534 ;; Bind features so that require will believe that gnus-sum has
1535 ;; already been loaded (avoids infinite recursion)
1536 (let ((features (cons 'gnus-sum features)))
1537 ;; Several of the declarations in gnus-sum are needed to load the
1538 ;; following files. Right now, these definitions have been
1539 ;; compiled but not defined (evaluated). We could either do a
1540 ;; eval-and-compile about all of the declarations or evaluate the
1542 (if (boundp 'gnus-newsgroup-variables)
1544 (load "gnus-sum.el" t t t))
1546 (require 'gnus-art)))
1548 ;; Subject simplification.
1550 (defun gnus-simplify-whitespace (str)
1551 "Remove excessive whitespace from STR."
1553 (while (string-match "[ \t][ \t]+" str)
1554 (setq str (concat (substring str 0 (match-beginning 0))
1556 (substring str (match-end 0)))))
1558 (when (string-match "^[ \t]+" str)
1559 (setq str (substring str (match-end 0))))
1561 (when (string-match "[ \t]+$" str)
1562 (setq str (substring str 0 (match-beginning 0))))
1565 (defun gnus-simplify-all-whitespace (str)
1566 "Remove all whitespace from STR."
1567 (while (string-match "[ \t\n]+" str)
1568 (setq str (replace-match "" nil nil str)))
1571 (defsubst gnus-simplify-subject-re (subject)
1572 "Remove \"Re:\" from subject lines."
1573 (if (string-match message-subject-re-regexp subject)
1574 (substring subject (match-end 0))
1577 (defun gnus-simplify-subject (subject &optional re-only)
1578 "Remove `Re:' and words in parentheses.
1579 If RE-ONLY is non-nil, strip leading `Re:'s only."
1580 (let ((case-fold-search t)) ;Ignore case.
1581 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1582 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1583 (setq subject (substring subject (match-end 0))))
1584 ;; Remove uninteresting prefixes.
1585 (when (and (not re-only)
1586 gnus-simplify-ignored-prefixes
1587 (string-match gnus-simplify-ignored-prefixes subject))
1588 (setq subject (substring subject (match-end 0))))
1589 ;; Remove words in parentheses from end.
1591 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1592 (setq subject (substring subject 0 (match-beginning 0)))))
1593 ;; Return subject string.
1596 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1598 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1599 (goto-char (point-min))
1600 (while (re-search-forward regexp nil t)
1601 (replace-match (or newtext ""))))
1603 (defun gnus-simplify-buffer-fuzzy ()
1604 "Simplify string in the buffer fuzzily.
1605 The string in the accessible portion of the current buffer is simplified.
1606 It is assumed to be a single-line subject.
1607 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1608 matter is removed. Additional things can be deleted by setting
1609 `gnus-simplify-subject-fuzzy-regexp'."
1610 (let ((case-fold-search t)
1612 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1614 (while (not (eq modified-tick (buffer-modified-tick)))
1615 (setq modified-tick (buffer-modified-tick))
1617 ((listp gnus-simplify-subject-fuzzy-regexp)
1618 (mapcar 'gnus-simplify-buffer-fuzzy-step
1619 gnus-simplify-subject-fuzzy-regexp))
1620 (gnus-simplify-subject-fuzzy-regexp
1621 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1622 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1623 (gnus-simplify-buffer-fuzzy-step
1624 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1625 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1627 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1628 (gnus-simplify-buffer-fuzzy-step " +" " ")
1629 (gnus-simplify-buffer-fuzzy-step " $")
1630 (gnus-simplify-buffer-fuzzy-step "^ +")))
1632 (defun gnus-simplify-subject-fuzzy (subject)
1633 "Simplify a subject string fuzzily.
1634 See `gnus-simplify-buffer-fuzzy' for details."
1636 (gnus-set-work-buffer)
1637 (let ((case-fold-search t))
1638 ;; Remove uninteresting prefixes.
1639 (when (and gnus-simplify-ignored-prefixes
1640 (string-match gnus-simplify-ignored-prefixes subject))
1641 (setq subject (substring subject (match-end 0))))
1643 (inline (gnus-simplify-buffer-fuzzy))
1646 (defsubst gnus-simplify-subject-fully (subject)
1647 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1649 (gnus-simplify-subject-functions
1650 (gnus-map-function gnus-simplify-subject-functions subject))
1651 ((null gnus-summary-gather-subject-limit)
1652 (gnus-simplify-subject-re subject))
1653 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1654 (gnus-simplify-subject-fuzzy subject))
1655 ((numberp gnus-summary-gather-subject-limit)
1656 (gnus-limit-string (gnus-simplify-subject-re subject)
1657 gnus-summary-gather-subject-limit))
1661 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1662 "Check whether two subjects are equal.
1663 If optional argument SIMPLE-FIRST is t, first argument is already
1666 ((null simple-first)
1667 (equal (gnus-simplify-subject-fully s1)
1668 (gnus-simplify-subject-fully s2)))
1671 (gnus-simplify-subject-fully s2)))))
1673 (defun gnus-summary-bubble-group ()
1674 "Increase the score of the current group.
1675 This is a handy function to add to `gnus-summary-exit-hook' to
1676 increase the score of each group you read."
1677 (gnus-group-add-score gnus-newsgroup-name))
1681 ;;; Gnus summary mode
1684 (put 'gnus-summary-mode 'mode-class 'special)
1686 (defvar gnus-article-commands-menu)
1688 ;; Non-orthogonal keys
1690 (gnus-define-keys gnus-summary-mode-map
1691 " " gnus-summary-next-page
1692 "\177" gnus-summary-prev-page
1693 [delete] gnus-summary-prev-page
1694 [backspace] gnus-summary-prev-page
1695 "\r" gnus-summary-scroll-up
1696 "\M-\r" gnus-summary-scroll-down
1697 "n" gnus-summary-next-unread-article
1698 "p" gnus-summary-prev-unread-article
1699 "N" gnus-summary-next-article
1700 "P" gnus-summary-prev-article
1701 "\M-\C-n" gnus-summary-next-same-subject
1702 "\M-\C-p" gnus-summary-prev-same-subject
1703 "\M-n" gnus-summary-next-unread-subject
1704 "\M-p" gnus-summary-prev-unread-subject
1705 "." gnus-summary-first-unread-article
1706 "," gnus-summary-best-unread-article
1707 "\M-s" gnus-summary-search-article-forward
1708 "\M-r" gnus-summary-search-article-backward
1709 "<" gnus-summary-beginning-of-article
1710 ">" gnus-summary-end-of-article
1711 "j" gnus-summary-goto-article
1712 "^" gnus-summary-refer-parent-article
1713 "\M-^" gnus-summary-refer-article
1714 "u" gnus-summary-tick-article-forward
1715 "!" gnus-summary-tick-article-forward
1716 "U" gnus-summary-tick-article-backward
1717 "d" gnus-summary-mark-as-read-forward
1718 "D" gnus-summary-mark-as-read-backward
1719 "E" gnus-summary-mark-as-expirable
1720 "\M-u" gnus-summary-clear-mark-forward
1721 "\M-U" gnus-summary-clear-mark-backward
1722 "k" gnus-summary-kill-same-subject-and-select
1723 "\C-k" gnus-summary-kill-same-subject
1724 "\M-\C-k" gnus-summary-kill-thread
1725 "\M-\C-l" gnus-summary-lower-thread
1726 "e" gnus-summary-edit-article
1727 "#" gnus-summary-mark-as-processable
1728 "\M-#" gnus-summary-unmark-as-processable
1729 "\M-\C-t" gnus-summary-toggle-threads
1730 "\M-\C-s" gnus-summary-show-thread
1731 "\M-\C-h" gnus-summary-hide-thread
1732 "\M-\C-f" gnus-summary-next-thread
1733 "\M-\C-b" gnus-summary-prev-thread
1734 [(meta down)] gnus-summary-next-thread
1735 [(meta up)] gnus-summary-prev-thread
1736 "\M-\C-u" gnus-summary-up-thread
1737 "\M-\C-d" gnus-summary-down-thread
1738 "&" gnus-summary-execute-command
1739 "c" gnus-summary-catchup-and-exit
1740 "\C-w" gnus-summary-mark-region-as-read
1741 "\C-t" gnus-summary-toggle-truncation
1742 "?" gnus-summary-mark-as-dormant
1743 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1744 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1745 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1746 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1747 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1748 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1749 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1750 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1751 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1752 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1753 "=" gnus-summary-expand-window
1754 "\C-x\C-s" gnus-summary-reselect-current-group
1755 "\M-g" gnus-summary-rescan-group
1756 "w" gnus-summary-stop-page-breaking
1757 "\C-c\C-r" gnus-summary-caesar-message
1758 "\M-t" gnus-summary-toggle-mime
1759 "f" gnus-summary-followup
1760 "F" gnus-summary-followup-with-original
1761 "C" gnus-summary-cancel-article
1762 "r" gnus-summary-reply
1763 "R" gnus-summary-reply-with-original
1764 "\C-c\C-f" gnus-summary-mail-forward
1765 "o" gnus-summary-save-article
1766 "\C-o" gnus-summary-save-article-mail
1767 "|" gnus-summary-pipe-output
1768 "\M-k" gnus-summary-edit-local-kill
1769 "\M-K" gnus-summary-edit-global-kill
1771 "\C-c\C-d" gnus-summary-describe-group
1772 "q" gnus-summary-exit
1773 "Q" gnus-summary-exit-no-update
1774 "\C-c\C-i" gnus-info-find-node
1775 gnus-mouse-2 gnus-mouse-pick-article
1776 "m" gnus-summary-mail-other-window
1777 "a" gnus-summary-post-news
1778 "i" gnus-summary-news-other-window
1779 "x" gnus-summary-limit-to-unread
1780 "s" gnus-summary-isearch-article
1781 "t" gnus-summary-toggle-header
1782 "g" gnus-summary-show-article
1783 "l" gnus-summary-goto-last-article
1784 "v" gnus-summary-preview-mime-message
1785 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1786 "\C-d" gnus-summary-enter-digest-group
1787 "\M-\C-d" gnus-summary-read-document
1788 "\M-\C-e" gnus-summary-edit-parameters
1789 "\M-\C-a" gnus-summary-customize-parameters
1791 "\C-c\C-n" gnus-namazu-search
1792 "*" gnus-cache-enter-article
1793 "\M-*" gnus-cache-remove-article
1794 "\M-&" gnus-summary-universal-argument
1795 "\C-l" gnus-recenter
1796 "I" gnus-summary-increase-score
1797 "L" gnus-summary-lower-score
1798 "\M-i" gnus-symbolic-argument
1799 "h" gnus-summary-select-article-buffer
1801 "V" gnus-summary-score-map
1802 "X" gnus-uu-extract-map
1803 "S" gnus-summary-send-map)
1805 ;; Sort of orthogonal keymap
1806 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1807 "t" gnus-summary-tick-article-forward
1808 "!" gnus-summary-tick-article-forward
1809 "d" gnus-summary-mark-as-read-forward
1810 "r" gnus-summary-mark-as-read-forward
1811 "c" gnus-summary-clear-mark-forward
1812 " " gnus-summary-clear-mark-forward
1813 "e" gnus-summary-mark-as-expirable
1814 "x" gnus-summary-mark-as-expirable
1815 "?" gnus-summary-mark-as-dormant
1816 "b" gnus-summary-set-bookmark
1817 "B" gnus-summary-remove-bookmark
1818 "#" gnus-summary-mark-as-processable
1819 "\M-#" gnus-summary-unmark-as-processable
1820 "S" gnus-summary-limit-include-expunged
1821 "C" gnus-summary-catchup
1822 "H" gnus-summary-catchup-to-here
1823 "h" gnus-summary-catchup-from-here
1824 "\C-c" gnus-summary-catchup-all
1825 "k" gnus-summary-kill-same-subject-and-select
1826 "K" gnus-summary-kill-same-subject
1827 "P" gnus-uu-mark-map)
1829 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1830 "c" gnus-summary-clear-above
1831 "u" gnus-summary-tick-above
1832 "m" gnus-summary-mark-above
1833 "k" gnus-summary-kill-below)
1835 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1836 "/" gnus-summary-limit-to-subject
1837 "n" gnus-summary-limit-to-articles
1838 "w" gnus-summary-pop-limit
1839 "s" gnus-summary-limit-to-subject
1840 "a" gnus-summary-limit-to-author
1841 "u" gnus-summary-limit-to-unread
1842 "m" gnus-summary-limit-to-marks
1843 "M" gnus-summary-limit-exclude-marks
1844 "v" gnus-summary-limit-to-score
1845 "*" gnus-summary-limit-include-cached
1846 "D" gnus-summary-limit-include-dormant
1847 "T" gnus-summary-limit-include-thread
1848 "d" gnus-summary-limit-exclude-dormant
1849 "t" gnus-summary-limit-to-age
1850 "." gnus-summary-limit-to-unseen
1851 "x" gnus-summary-limit-to-extra
1852 "p" gnus-summary-limit-to-display-predicate
1853 "E" gnus-summary-limit-include-expunged
1854 "c" gnus-summary-limit-exclude-childless-dormant
1855 "C" gnus-summary-limit-mark-excluded-as-read
1856 "o" gnus-summary-insert-old-articles
1857 "N" gnus-summary-insert-new-articles
1858 "r" gnus-summary-limit-to-replied)
1860 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1861 "n" gnus-summary-next-unread-article
1862 "p" gnus-summary-prev-unread-article
1863 "N" gnus-summary-next-article
1864 "P" gnus-summary-prev-article
1865 "\C-n" gnus-summary-next-same-subject
1866 "\C-p" gnus-summary-prev-same-subject
1867 "\M-n" gnus-summary-next-unread-subject
1868 "\M-p" gnus-summary-prev-unread-subject
1869 "f" gnus-summary-first-unread-article
1870 "b" gnus-summary-best-unread-article
1871 "j" gnus-summary-goto-article
1872 "g" gnus-summary-goto-subject
1873 "l" gnus-summary-goto-last-article
1874 "o" gnus-summary-pop-article)
1876 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1877 "k" gnus-summary-kill-thread
1878 "l" gnus-summary-lower-thread
1879 "i" gnus-summary-raise-thread
1880 "T" gnus-summary-toggle-threads
1881 "t" gnus-summary-rethread-current
1882 "^" gnus-summary-reparent-thread
1883 "s" gnus-summary-show-thread
1884 "S" gnus-summary-show-all-threads
1885 "h" gnus-summary-hide-thread
1886 "H" gnus-summary-hide-all-threads
1887 "n" gnus-summary-next-thread
1888 "p" gnus-summary-prev-thread
1889 "u" gnus-summary-up-thread
1890 "o" gnus-summary-top-thread
1891 "d" gnus-summary-down-thread
1892 "#" gnus-uu-mark-thread
1893 "\M-#" gnus-uu-unmark-thread)
1895 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1896 "g" gnus-summary-prepare
1897 "c" gnus-summary-insert-cached-articles
1898 "d" gnus-summary-insert-dormant-articles)
1900 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1901 "c" gnus-summary-catchup-and-exit
1902 "C" gnus-summary-catchup-all-and-exit
1903 "E" gnus-summary-exit-no-update
1904 "J" gnus-summary-jump-to-other-group
1905 "Q" gnus-summary-exit
1906 "Z" gnus-summary-exit
1907 "n" gnus-summary-catchup-and-goto-next-group
1908 "R" gnus-summary-reselect-current-group
1909 "G" gnus-summary-rescan-group
1910 "N" gnus-summary-next-group
1911 "s" gnus-summary-save-newsrc
1912 "P" gnus-summary-prev-group)
1914 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1915 " " gnus-summary-next-page
1916 "n" gnus-summary-next-page
1917 "\177" gnus-summary-prev-page
1918 [delete] gnus-summary-prev-page
1919 "p" gnus-summary-prev-page
1920 "\r" gnus-summary-scroll-up
1921 "\M-\r" gnus-summary-scroll-down
1922 "<" gnus-summary-beginning-of-article
1923 ">" gnus-summary-end-of-article
1924 "b" gnus-summary-beginning-of-article
1925 "e" gnus-summary-end-of-article
1926 "^" gnus-summary-refer-parent-article
1927 "r" gnus-summary-refer-parent-article
1928 "D" gnus-summary-enter-digest-group
1929 "R" gnus-summary-refer-references
1930 "T" gnus-summary-refer-thread
1931 "g" gnus-summary-show-article
1932 "s" gnus-summary-isearch-article
1933 "P" gnus-summary-print-article
1934 "M" gnus-mailing-list-insinuate
1935 "t" gnus-article-babel)
1937 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1938 "b" gnus-article-add-buttons
1939 "B" gnus-article-add-buttons-to-head
1940 "o" gnus-article-treat-overstrike
1941 "e" gnus-article-emphasize
1942 "w" gnus-article-fill-cited-article
1943 "Q" gnus-article-fill-long-lines
1944 "C" gnus-article-capitalize-sentences
1945 "c" gnus-article-remove-cr
1946 "Z" gnus-article-decode-HZ
1947 "A" gnus-article-treat-ansi-sequences
1948 "h" gnus-article-wash-html
1949 "u" gnus-article-unsplit-urls
1950 "f" gnus-article-display-x-face
1951 "l" gnus-summary-stop-page-breaking
1952 "r" gnus-summary-caesar-message
1953 "m" gnus-summary-morse-message
1954 "t" gnus-summary-toggle-header
1955 "g" gnus-treat-smiley
1956 "v" gnus-summary-verbose-headers
1957 "m" gnus-summary-toggle-mime
1958 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1959 "p" gnus-article-verify-x-pgp-sig
1960 "d" gnus-article-treat-dumbquotes)
1962 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1963 ;; mnemonic: deuglif*Y*
1964 "u" gnus-article-outlook-unwrap-lines
1965 "a" gnus-article-outlook-repair-attribution
1966 "c" gnus-article-outlook-rearrange-citation
1967 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1969 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1970 "a" gnus-article-hide
1971 "h" gnus-article-hide-headers
1972 "b" gnus-article-hide-boring-headers
1973 "s" gnus-article-hide-signature
1974 "c" gnus-article-hide-citation
1975 "C" gnus-article-hide-citation-in-followups
1976 "l" gnus-article-hide-list-identifiers
1977 "B" gnus-article-strip-banner
1978 "P" gnus-article-hide-pem
1979 "\C-c" gnus-article-hide-citation-maybe)
1981 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1982 "a" gnus-article-highlight
1983 "h" gnus-article-highlight-headers
1984 "c" gnus-article-highlight-citation
1985 "s" gnus-article-highlight-signature)
1987 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1988 "f" gnus-article-treat-fold-headers
1989 "u" gnus-article-treat-unfold-headers
1990 "n" gnus-article-treat-fold-newsgroups)
1992 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1993 "x" gnus-article-display-x-face
1994 "d" gnus-article-display-face
1995 "s" gnus-treat-smiley
1996 "D" gnus-article-remove-images
1997 "f" gnus-treat-from-picon
1998 "m" gnus-treat-mail-picon
1999 "n" gnus-treat-newsgroups-picon)
2001 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2002 "z" gnus-article-date-ut
2003 "u" gnus-article-date-ut
2004 "l" gnus-article-date-local
2005 "p" gnus-article-date-english
2006 "e" gnus-article-date-lapsed
2007 "o" gnus-article-date-original
2008 "i" gnus-article-date-iso8601
2009 "s" gnus-article-date-user)
2011 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2012 "t" gnus-article-remove-trailing-blank-lines
2013 "l" gnus-article-strip-leading-blank-lines
2014 "m" gnus-article-strip-multiple-blank-lines
2015 "a" gnus-article-strip-blank-lines
2016 "A" gnus-article-strip-all-blank-lines
2017 "s" gnus-article-strip-leading-space
2018 "e" gnus-article-strip-trailing-space
2019 "w" gnus-article-remove-leading-whitespace)
2021 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2023 "f" gnus-summary-fetch-faq
2024 "d" gnus-summary-describe-group
2025 "h" gnus-summary-describe-briefly
2026 "i" gnus-info-find-node
2027 "c" gnus-group-fetch-charter
2028 "C" gnus-group-fetch-control)
2030 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2031 "e" gnus-summary-expire-articles
2032 "\M-\C-e" gnus-summary-expire-articles-now
2033 "\177" gnus-summary-delete-article
2034 [delete] gnus-summary-delete-article
2035 [backspace] gnus-summary-delete-article
2036 "m" gnus-summary-move-article
2037 "r" gnus-summary-respool-article
2038 "w" gnus-summary-edit-article
2039 "c" gnus-summary-copy-article
2040 "B" gnus-summary-crosspost-article
2041 "q" gnus-summary-respool-query
2042 "t" gnus-summary-respool-trace
2043 "i" gnus-summary-import-article
2044 "I" gnus-summary-create-article
2045 "p" gnus-summary-article-posted-p)
2047 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2048 "o" gnus-summary-save-article
2049 "m" gnus-summary-save-article-mail
2050 "F" gnus-summary-write-article-file
2051 "r" gnus-summary-save-article-rmail
2052 "f" gnus-summary-save-article-file
2053 "b" gnus-summary-save-article-body-file
2054 "h" gnus-summary-save-article-folder
2055 "v" gnus-summary-save-article-vm
2056 "p" gnus-summary-pipe-output
2057 "P" gnus-summary-muttprint
2058 "s" gnus-soup-add-article)
2060 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2061 "b" gnus-summary-display-buttonized
2062 "m" gnus-summary-repair-multipart
2063 "v" gnus-article-view-part
2064 "o" gnus-article-save-part
2065 "c" gnus-article-copy-part
2066 "C" gnus-article-view-part-as-charset
2067 "e" gnus-article-view-part-externally
2068 "E" gnus-article-encrypt-body
2069 "i" gnus-article-inline-part
2070 "|" gnus-article-pipe-part)
2072 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2073 "p" gnus-summary-mark-as-processable
2074 "u" gnus-summary-unmark-as-processable
2075 "U" gnus-summary-unmark-all-processable
2076 "v" gnus-uu-mark-over
2077 "s" gnus-uu-mark-series
2078 "r" gnus-uu-mark-region
2079 "g" gnus-uu-unmark-region
2080 "R" gnus-uu-mark-by-regexp
2081 "G" gnus-uu-unmark-by-regexp
2082 "t" gnus-uu-mark-thread
2083 "T" gnus-uu-unmark-thread
2084 "a" gnus-uu-mark-all
2085 "b" gnus-uu-mark-buffer
2086 "S" gnus-uu-mark-sparse
2087 "k" gnus-summary-kill-process-mark
2088 "y" gnus-summary-yank-process-mark
2089 "w" gnus-summary-save-process-mark
2090 "i" gnus-uu-invert-processable)
2092 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2093 ;;"x" gnus-uu-extract-any
2094 "m" gnus-summary-save-parts
2095 "u" gnus-uu-decode-uu
2096 "U" gnus-uu-decode-uu-and-save
2097 "s" gnus-uu-decode-unshar
2098 "S" gnus-uu-decode-unshar-and-save
2099 "o" gnus-uu-decode-save
2100 "O" gnus-uu-decode-save
2101 "b" gnus-uu-decode-binhex
2102 "B" gnus-uu-decode-binhex
2103 "p" gnus-uu-decode-postscript
2104 "P" gnus-uu-decode-postscript-and-save)
2107 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2108 "u" gnus-uu-decode-uu-view
2109 "U" gnus-uu-decode-uu-and-save-view
2110 "s" gnus-uu-decode-unshar-view
2111 "S" gnus-uu-decode-unshar-and-save-view
2112 "o" gnus-uu-decode-save-view
2113 "O" gnus-uu-decode-save-view
2114 "b" gnus-uu-decode-binhex-view
2115 "B" gnus-uu-decode-binhex-view
2116 "p" gnus-uu-decode-postscript-view
2117 "P" gnus-uu-decode-postscript-and-save-view)
2119 (defvar gnus-article-post-menu nil)
2121 (defconst gnus-summary-menu-maxlen 20)
2123 (defun gnus-summary-menu-split (menu)
2124 ;; If we have lots of elements, divide them into groups of 20
2125 ;; and make a pane (or submenu) for each one.
2126 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2127 (let ((menu menu) sublists next
2130 ;; Pull off the next gnus-summary-menu-maxlen elements
2131 ;; and make them the next element of sublist.
2132 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2134 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2136 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2137 (aref (car (last menu)) 0)) menu)
2141 (nreverse sublists))
2142 ;; Few elements--put them all in one pane.
2145 (defun gnus-summary-make-menu-bar ()
2146 (gnus-turn-off-edit-menu 'summary)
2148 (unless (boundp 'gnus-summary-misc-menu)
2151 gnus-summary-kill-menu gnus-summary-mode-map ""
2156 ["Customize" gnus-score-customize t])
2157 (gnus-make-score-map 'increase)
2158 (gnus-make-score-map 'lower)
2160 ["Kill below" gnus-summary-kill-below t]
2161 ["Mark above" gnus-summary-mark-above t]
2162 ["Tick above" gnus-summary-tick-above t]
2163 ["Clear above" gnus-summary-clear-above t])
2164 ["Current score" gnus-summary-current-score t]
2165 ["Set score" gnus-summary-set-score t]
2166 ["Switch current score file..." gnus-score-change-score-file t]
2167 ["Set mark below..." gnus-score-set-mark-below t]
2168 ["Set expunge below..." gnus-score-set-expunge-below t]
2169 ["Edit current score file" gnus-score-edit-current-scores t]
2170 ["Edit score file" gnus-score-edit-file t]
2171 ["Trace score" gnus-score-find-trace t]
2172 ["Find words" gnus-score-find-favourite-words t]
2173 ["Rescore buffer" gnus-summary-rescore t]
2174 ["Increase score..." gnus-summary-increase-score t]
2175 ["Lower score..." gnus-summary-lower-score t]))))
2177 ;; Define both the Article menu in the summary buffer and the
2178 ;; equivalent Commands menu in the article buffer here for
2182 ["All" gnus-article-hide t]
2183 ["Headers" gnus-article-hide-headers t]
2184 ["Signature" gnus-article-hide-signature t]
2185 ["Citation" gnus-article-hide-citation t]
2186 ["List identifiers" gnus-article-hide-list-identifiers t]
2187 ["Banner" gnus-article-strip-banner t]
2188 ["Boring headers" gnus-article-hide-boring-headers t])
2190 ["All" gnus-article-highlight t]
2191 ["Headers" gnus-article-highlight-headers t]
2192 ["Signature" gnus-article-highlight-signature t]
2193 ["Citation" gnus-article-highlight-citation t])
2195 ["Local" gnus-article-date-local t]
2196 ["ISO8601" gnus-article-date-iso8601 t]
2197 ["UT" gnus-article-date-ut t]
2198 ["Original" gnus-article-date-original t]
2199 ["Lapsed" gnus-article-date-lapsed t]
2200 ["User-defined" gnus-article-date-user t])
2202 ["Remove images" gnus-article-remove-images t]
2203 ["Toggle smiley" gnus-treat-smiley t]
2204 ["Show X-Face" gnus-article-display-x-face t]
2205 ["Show picons in From" gnus-treat-from-picon t]
2206 ["Show picons in mail headers" gnus-treat-mail-picon t]
2207 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2208 ("View as different encoding"
2209 ,@(gnus-summary-menu-split
2212 ;; Since easymenu under Emacs doesn't allow
2213 ;; lambda forms for menu commands, we should
2214 ;; provide intern'ed function symbols.
2215 (let ((command (intern (format "\
2216 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2220 (let ((gnus-summary-show-article-charset-alist
2222 (gnus-summary-show-article 1))))
2223 `[,(symbol-name cs) ,command t]))
2224 (sort (if (fboundp 'coding-system-list)
2225 (coding-system-list)
2226 ;;(mapcar 'car mm-mime-mule-charset-alist)
2231 ["Leading" gnus-article-strip-leading-blank-lines t]
2232 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2233 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2234 ["All of the above" gnus-article-strip-blank-lines t]
2235 ["All" gnus-article-strip-all-blank-lines t]
2236 ["Leading space" gnus-article-strip-leading-space t]
2237 ["Trailing space" gnus-article-strip-trailing-space t]
2238 ["Leading space in headers"
2239 gnus-article-remove-leading-whitespace t])
2240 ["Overstrike" gnus-article-treat-overstrike t]
2241 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2242 ["Emphasis" gnus-article-emphasize t]
2243 ["Word wrap" gnus-article-fill-cited-article t]
2244 ["Fill long lines" gnus-article-fill-long-lines t]
2245 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2246 ["Remove CR" gnus-article-remove-cr t]
2247 ["Rot 13" gnus-summary-caesar-message
2248 ,@(if (featurep 'xemacs) '(t)
2249 '(:help "\"Caesar rotate\" article by 13"))]
2250 ["Morse decode" gnus-summary-morse-message t]
2251 ["Unix pipe..." gnus-summary-pipe-message t]
2252 ["Add buttons" gnus-article-add-buttons t]
2253 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2254 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2255 ["Toggle MIME" gnus-summary-toggle-mime t]
2256 ["Verbose header" gnus-summary-verbose-headers t]
2257 ["Toggle header" gnus-summary-toggle-header t]
2258 ["Unfold headers" gnus-article-treat-unfold-headers t]
2259 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2260 ["Html" gnus-article-wash-html t]
2261 ["Unsplit URLs" gnus-article-unsplit-urls t]
2262 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2263 ["Decode HZ" gnus-article-decode-HZ t]
2264 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2265 ("(Outlook) Deuglify"
2266 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2267 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2268 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2269 ["Full (Outlook) deuglify"
2270 gnus-article-outlook-deuglify-article t])
2273 ["Save in default format..." gnus-summary-save-article
2274 ,@(if (featurep 'xemacs) '(t)
2275 '(:help "Save article using default method"))]
2276 ["Save in file..." gnus-summary-save-article-file
2277 ,@(if (featurep 'xemacs) '(t)
2278 '(:help "Save article in file"))]
2279 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2280 ["Save in MH folder..." gnus-summary-save-article-folder t]
2281 ["Save in VM folder..." gnus-summary-save-article-vm t]
2282 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2283 ["Save body in file..." gnus-summary-save-article-body-file t]
2284 ["Pipe through a filter..." gnus-summary-pipe-output t]
2285 ["Add to SOUP packet" gnus-soup-add-article t]
2286 ["Print with Muttprint..." gnus-summary-muttprint t]
2287 ["Print" gnus-summary-print-article
2288 ,@(if (featurep 'xemacs) '(t)
2289 '(:help "Generate and print a PostScript image"))])
2290 ("Copy, move,... (Backend)"
2291 ,@(if (featurep 'xemacs) nil
2292 '(:help "Copying, moving, expiring articles..."))
2293 ["Respool article..." gnus-summary-respool-article t]
2294 ["Move article..." gnus-summary-move-article
2295 (gnus-check-backend-function
2296 'request-move-article gnus-newsgroup-name)]
2297 ["Copy article..." gnus-summary-copy-article t]
2298 ["Crosspost article..." gnus-summary-crosspost-article
2299 (gnus-check-backend-function
2300 'request-replace-article gnus-newsgroup-name)]
2301 ["Import file..." gnus-summary-import-article
2302 (gnus-check-backend-function
2303 'request-accept-article gnus-newsgroup-name)]
2304 ["Create article..." gnus-summary-create-article
2305 (gnus-check-backend-function
2306 'request-accept-article gnus-newsgroup-name)]
2307 ["Check if posted" gnus-summary-article-posted-p t]
2308 ["Edit article" gnus-summary-edit-article
2309 (not (gnus-group-read-only-p))]
2310 ["Delete article" gnus-summary-delete-article
2311 (gnus-check-backend-function
2312 'request-expire-articles gnus-newsgroup-name)]
2313 ["Query respool" gnus-summary-respool-query t]
2314 ["Trace respool" gnus-summary-respool-trace t]
2315 ["Delete expirable articles" gnus-summary-expire-articles-now
2316 (gnus-check-backend-function
2317 'request-expire-articles gnus-newsgroup-name)])
2319 ["Uudecode" gnus-uu-decode-uu
2320 ,@(if (featurep 'xemacs) '(t)
2321 '(:help "Decode uuencoded article(s)"))]
2322 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2323 ["Unshar" gnus-uu-decode-unshar t]
2324 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2325 ["Save" gnus-uu-decode-save t]
2326 ["Binhex" gnus-uu-decode-binhex t]
2327 ["Postscript" gnus-uu-decode-postscript t])
2329 ["Enter article" gnus-cache-enter-article t]
2330 ["Remove article" gnus-cache-remove-article t])
2331 ["Translate" gnus-article-babel t]
2332 ["Select article buffer" gnus-summary-select-article-buffer t]
2333 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2334 ["Isearch article..." gnus-summary-isearch-article t]
2335 ["Beginning of the article" gnus-summary-beginning-of-article t]
2336 ["End of the article" gnus-summary-end-of-article t]
2337 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2338 ["Fetch referenced articles" gnus-summary-refer-references t]
2339 ["Fetch current thread" gnus-summary-refer-thread t]
2340 ["Fetch article with id..." gnus-summary-refer-article t]
2341 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2342 ["Redisplay" gnus-summary-show-article t]
2343 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2345 gnus-summary-article-menu gnus-summary-mode-map ""
2346 (cons "Article" innards))
2348 (if (not (keymapp gnus-summary-article-menu))
2350 gnus-article-commands-menu gnus-article-mode-map ""
2351 (cons "Commands" innards))
2352 ;; in Emacs, don't share menu.
2353 (setq gnus-article-commands-menu
2354 (copy-keymap gnus-summary-article-menu))
2355 (define-key gnus-article-mode-map [menu-bar commands]
2356 (cons "Commands" gnus-article-commands-menu))))
2359 gnus-summary-thread-menu gnus-summary-mode-map ""
2361 ["Find all messages in thread" gnus-summary-refer-thread t]
2362 ["Toggle threading" gnus-summary-toggle-threads t]
2363 ["Hide threads" gnus-summary-hide-all-threads t]
2364 ["Show threads" gnus-summary-show-all-threads t]
2365 ["Hide thread" gnus-summary-hide-thread t]
2366 ["Show thread" gnus-summary-show-thread t]
2367 ["Go to next thread" gnus-summary-next-thread t]
2368 ["Go to previous thread" gnus-summary-prev-thread t]
2369 ["Go down thread" gnus-summary-down-thread t]
2370 ["Go up thread" gnus-summary-up-thread t]
2371 ["Top of thread" gnus-summary-top-thread t]
2372 ["Mark thread as read" gnus-summary-kill-thread t]
2373 ["Lower thread score" gnus-summary-lower-thread t]
2374 ["Raise thread score" gnus-summary-raise-thread t]
2375 ["Rethread current" gnus-summary-rethread-current t]))
2378 gnus-summary-post-menu gnus-summary-mode-map ""
2380 ["Send a message (mail or news)" gnus-summary-post-news
2381 ,@(if (featurep 'xemacs) '(t)
2382 '(:help "Compose a new message (mail or news)"))]
2383 ["Followup" gnus-summary-followup
2384 ,@(if (featurep 'xemacs) '(t)
2385 '(:help "Post followup to this article"))]
2386 ["Followup and yank" gnus-summary-followup-with-original
2387 ,@(if (featurep 'xemacs) '(t)
2388 '(:help "Post followup to this article, quoting its contents"))]
2389 ["Supersede article" gnus-summary-supersede-article t]
2390 ["Cancel article" gnus-summary-cancel-article
2391 ,@(if (featurep 'xemacs) '(t)
2392 '(:help "Cancel an article you posted"))]
2393 ["Reply" gnus-summary-reply t]
2394 ["Reply and yank" gnus-summary-reply-with-original t]
2395 ["Wide reply" gnus-summary-wide-reply t]
2396 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2397 ,@(if (featurep 'xemacs) '(t)
2398 '(:help "Mail a reply, quoting this article"))]
2399 ["Very wide reply" gnus-summary-very-wide-reply t]
2400 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2401 ,@(if (featurep 'xemacs) '(t)
2402 '(:help "Mail a very wide reply, quoting this article"))]
2403 ["Mail forward" gnus-summary-mail-forward t]
2404 ["Post forward" gnus-summary-post-forward t]
2405 ["Digest and mail" gnus-summary-digest-mail-forward t]
2406 ["Digest and post" gnus-summary-digest-post-forward t]
2407 ["Resend message" gnus-summary-resend-message t]
2408 ["Resend message edit" gnus-summary-resend-message-edit t]
2409 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2410 ["Send a mail" gnus-summary-mail-other-window t]
2411 ["Create a local message" gnus-summary-news-other-window t]
2412 ["Uuencode and post" gnus-uu-post-news
2413 ,@(if (featurep 'xemacs) '(t)
2414 '(:help "Post a uuencoded article"))]
2415 ["Followup via news" gnus-summary-followup-to-mail t]
2416 ["Followup via news and yank"
2417 gnus-summary-followup-to-mail-with-original t]
2419 ;;["Send" gnus-summary-send-draft t]
2420 ;;["Send bounced" gnus-resend-bounced-mail t])
2424 ((not (keymapp gnus-summary-post-menu))
2425 (setq gnus-article-post-menu gnus-summary-post-menu))
2426 ((not gnus-article-post-menu)
2427 ;; Don't share post menu.
2428 (setq gnus-article-post-menu
2429 (copy-keymap gnus-summary-post-menu))))
2430 (define-key gnus-article-mode-map [menu-bar post]
2431 (cons "Post" gnus-article-post-menu))
2434 gnus-summary-misc-menu gnus-summary-mode-map ""
2437 ["Mark as read" gnus-summary-mark-as-read-forward t]
2438 ["Mark same subject and select"
2439 gnus-summary-kill-same-subject-and-select t]
2440 ["Mark same subject" gnus-summary-kill-same-subject t]
2441 ["Catchup" gnus-summary-catchup
2442 ,@(if (featurep 'xemacs) '(t)
2443 '(:help "Mark unread articles in this group as read"))]
2444 ["Catchup all" gnus-summary-catchup-all t]
2445 ["Catchup to here" gnus-summary-catchup-to-here t]
2446 ["Catchup from here" gnus-summary-catchup-from-here t]
2447 ["Catchup region" gnus-summary-mark-region-as-read
2448 (gnus-mark-active-p)]
2449 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2451 ["Tick" gnus-summary-tick-article-forward t]
2452 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2453 ["Remove marks" gnus-summary-clear-mark-forward t]
2454 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2455 ["Set bookmark" gnus-summary-set-bookmark t]
2456 ["Remove bookmark" gnus-summary-remove-bookmark t])
2458 ["Marks..." gnus-summary-limit-to-marks t]
2459 ["Subject..." gnus-summary-limit-to-subject t]
2460 ["Author..." gnus-summary-limit-to-author t]
2461 ["Age..." gnus-summary-limit-to-age t]
2462 ["Extra..." gnus-summary-limit-to-extra t]
2463 ["Score..." gnus-summary-limit-to-score t]
2464 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2465 ["Unread" gnus-summary-limit-to-unread t]
2466 ["Unseen" gnus-summary-limit-to-unseen t]
2467 ["Replied" gnus-summary-limit-to-replied t]
2468 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2469 ["Next articles" gnus-summary-limit-to-articles t]
2470 ["Pop limit" gnus-summary-pop-limit t]
2471 ["Show dormant" gnus-summary-limit-include-dormant t]
2472 ["Hide childless dormant"
2473 gnus-summary-limit-exclude-childless-dormant t]
2474 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2475 ["Hide marked" gnus-summary-limit-exclude-marks t]
2476 ["Show expunged" gnus-summary-limit-include-expunged t])
2478 ["Set mark" gnus-summary-mark-as-processable t]
2479 ["Remove mark" gnus-summary-unmark-as-processable t]
2480 ["Remove all marks" gnus-summary-unmark-all-processable t]
2481 ["Invert marks" gnus-uu-invert-processable t]
2482 ["Mark above" gnus-uu-mark-over t]
2483 ["Mark series" gnus-uu-mark-series t]
2484 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2485 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2486 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2487 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2488 ["Mark all" gnus-uu-mark-all t]
2489 ["Mark buffer" gnus-uu-mark-buffer t]
2490 ["Mark sparse" gnus-uu-mark-sparse t]
2491 ["Mark thread" gnus-uu-mark-thread t]
2492 ["Unmark thread" gnus-uu-unmark-thread t]
2493 ("Process Mark Sets"
2494 ["Kill" gnus-summary-kill-process-mark t]
2495 ["Yank" gnus-summary-yank-process-mark
2496 gnus-newsgroup-process-stack]
2497 ["Save" gnus-summary-save-process-mark t]
2498 ["Run command on marked..." gnus-summary-universal-argument t]))
2500 ["Page forward" gnus-summary-next-page
2501 ,@(if (featurep 'xemacs) '(t)
2502 '(:help "Show next page of article"))]
2503 ["Page backward" gnus-summary-prev-page
2504 ,@(if (featurep 'xemacs) '(t)
2505 '(:help "Show previous page of article"))]
2506 ["Line forward" gnus-summary-scroll-up t])
2508 ["Next unread article" gnus-summary-next-unread-article t]
2509 ["Previous unread article" gnus-summary-prev-unread-article t]
2510 ["Next article" gnus-summary-next-article t]
2511 ["Previous article" gnus-summary-prev-article t]
2512 ["Next unread subject" gnus-summary-next-unread-subject t]
2513 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2514 ["Next article same subject" gnus-summary-next-same-subject t]
2515 ["Previous article same subject" gnus-summary-prev-same-subject t]
2516 ["First unread article" gnus-summary-first-unread-article t]
2517 ["Best unread article" gnus-summary-best-unread-article t]
2518 ["Go to subject number..." gnus-summary-goto-subject t]
2519 ["Go to article number..." gnus-summary-goto-article t]
2520 ["Go to the last article" gnus-summary-goto-last-article t]
2521 ["Pop article off history" gnus-summary-pop-article t])
2523 ["Sort by number" gnus-summary-sort-by-number t]
2524 ["Sort by author" gnus-summary-sort-by-author t]
2525 ["Sort by subject" gnus-summary-sort-by-subject t]
2526 ["Sort by date" gnus-summary-sort-by-date t]
2527 ["Sort by score" gnus-summary-sort-by-score t]
2528 ["Sort by lines" gnus-summary-sort-by-lines t]
2529 ["Sort by characters" gnus-summary-sort-by-chars t]
2530 ["Randomize" gnus-summary-sort-by-random t]
2531 ["Original sort" gnus-summary-sort-by-original t])
2533 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2534 ["Describe group" gnus-summary-describe-group t]
2535 ["Fetch charter" gnus-group-fetch-charter
2536 ,@(if (featurep 'xemacs) nil
2537 '(:help "Display the charter of the current group"))]
2538 ["Fetch control message" gnus-group-fetch-control
2539 ,@(if (featurep 'xemacs) nil
2540 '(:help "Display the archived control message for the current group"))]
2541 ["Read manual" gnus-info-find-node t])
2543 ["Pick and read" gnus-pick-mode t]
2544 ["Binary" gnus-binary-mode t])
2546 ["Regenerate" gnus-summary-prepare t]
2547 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2548 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2549 ["Toggle threading" gnus-summary-toggle-threads t])
2550 ["See old articles" gnus-summary-insert-old-articles t]
2551 ["See new articles" gnus-summary-insert-new-articles t]
2552 ["Filter articles..." gnus-summary-execute-command t]
2553 ["Run command on articles..." gnus-summary-universal-argument t]
2554 ["Search articles forward..." gnus-summary-search-article-forward t]
2555 ["Search articles backward..." gnus-summary-search-article-backward t]
2556 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2557 ["Expand window" gnus-summary-expand-window t]
2558 ["Expire expirable articles" gnus-summary-expire-articles
2559 (gnus-check-backend-function
2560 'request-expire-articles gnus-newsgroup-name)]
2561 ["Edit local kill file" gnus-summary-edit-local-kill t]
2562 ["Edit main kill file" gnus-summary-edit-global-kill t]
2563 ["Edit group parameters" gnus-summary-edit-parameters t]
2564 ["Customize group parameters" gnus-summary-customize-parameters t]
2565 ["Send a bug report" gnus-bug t]
2567 ["Catchup and exit" gnus-summary-catchup-and-exit
2568 ,@(if (featurep 'xemacs) '(t)
2569 '(:help "Mark unread articles in this group as read, then exit"))]
2570 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2571 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2572 ["Exit group" gnus-summary-exit
2573 ,@(if (featurep 'xemacs) '(t)
2574 '(:help "Exit current group, return to group selection mode"))]
2575 ["Exit group without updating" gnus-summary-exit-no-update t]
2576 ["Exit and goto next group" gnus-summary-next-group t]
2577 ["Exit and goto prev group" gnus-summary-prev-group t]
2578 ["Reselect group" gnus-summary-reselect-current-group t]
2579 ["Rescan group" gnus-summary-rescan-group t]
2580 ["Update dribble" gnus-summary-save-newsrc t])))
2582 (gnus-run-hooks 'gnus-summary-menu-hook)))
2584 (defvar gnus-summary-tool-bar-map nil)
2586 ;; Emacs 21 tool bar. Should be no-op otherwise.
2587 (defun gnus-summary-make-tool-bar ()
2588 (if (and (fboundp 'tool-bar-add-item-from-menu)
2589 (default-value 'tool-bar-mode)
2590 (not gnus-summary-tool-bar-map))
2591 (setq gnus-summary-tool-bar-map
2592 (let ((tool-bar-map (make-sparse-keymap))
2593 (load-path (mm-image-load-path)))
2594 (tool-bar-add-item-from-menu
2595 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2596 (tool-bar-add-item-from-menu
2597 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2598 (tool-bar-add-item-from-menu
2599 'gnus-summary-post-news "post" gnus-summary-mode-map)
2600 (tool-bar-add-item-from-menu
2601 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2602 (tool-bar-add-item-from-menu
2603 'gnus-summary-followup "followup" gnus-summary-mode-map)
2604 (tool-bar-add-item-from-menu
2605 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2606 (tool-bar-add-item-from-menu
2607 'gnus-summary-reply "reply" gnus-summary-mode-map)
2608 (tool-bar-add-item-from-menu
2609 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2610 (tool-bar-add-item-from-menu
2611 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2612 (tool-bar-add-item-from-menu
2613 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2614 (tool-bar-add-item-from-menu
2615 'gnus-summary-save-article "save-art" 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-uu-post-news "uu-post" gnus-summary-mode-map)
2620 (tool-bar-add-item-from-menu
2621 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2622 (tool-bar-add-item-from-menu
2623 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2624 (tool-bar-add-item-from-menu
2625 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2627 (if gnus-summary-tool-bar-map
2628 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2630 (defun gnus-score-set-default (var value)
2631 "A version of set that updates the GNU Emacs menu-bar."
2633 ;; It is the message that forces the active status to be updated.
2636 (defun gnus-make-score-map (type)
2637 "Make a summary score map of type TYPE."
2640 (let ((headers '(("author" "from" string)
2641 ("subject" "subject" string)
2642 ("article body" "body" string)
2643 ("article head" "head" string)
2644 ("xref" "xref" string)
2645 ("extra header" "extra" string)
2646 ("lines" "lines" number)
2647 ("followups to author" "followup" string)))
2648 (types '((number ("less than" <)
2651 (string ("substring" s)
2655 (perms '(("temporary" (current-time-string))
2663 (if (eq type 'lower)
2668 (setq header (car headers))
2674 (let ((ts (cdr (assoc (nth 2 header) types)))
2690 'gnus-summary-score-entry
2692 (if (or (string= (nth 1 header)
2694 (string= (nth 1 header)
2697 (list 'gnus-summary-header
2699 (list 'quote (nth 1 (car ts)))
2700 (list 'gnus-score-delta-default
2707 (list (nreverse outp))))
2710 (list (nreverse outt))))
2712 (setq headers (cdr headers)))
2713 (list (nreverse outh))))))))
2717 (defun gnus-summary-mode (&optional group)
2718 "Major mode for reading articles.
2720 All normal editing commands are switched off.
2721 \\<gnus-summary-mode-map>
2722 Each line in this buffer represents one article. To read an
2723 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2724 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2727 You can also post articles and send mail from this buffer. To
2728 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2729 of an article, type `\\[gnus-summary-reply]'.
2731 There are approx. one gazillion commands you can execute in this
2732 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2734 The following commands are available:
2736 \\{gnus-summary-mode-map}"
2738 (kill-all-local-variables)
2739 (when (gnus-visual-p 'summary-menu 'menu)
2740 (gnus-summary-make-menu-bar)
2741 (gnus-summary-make-tool-bar))
2742 (gnus-summary-make-local-variables)
2743 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2744 (gnus-summary-make-local-variables))
2745 (gnus-make-thread-indent-array)
2746 (gnus-simplify-mode-line)
2747 (setq major-mode 'gnus-summary-mode)
2748 (setq mode-name "Summary")
2749 (make-local-variable 'minor-mode-alist)
2750 (use-local-map gnus-summary-mode-map)
2751 (buffer-disable-undo)
2752 (setq buffer-read-only t ;Disable modification
2753 show-trailing-whitespace nil)
2754 (setq truncate-lines t)
2755 (setq selective-display t)
2756 (setq selective-display-ellipses t) ;Display `...'
2757 (gnus-summary-set-display-table)
2758 (gnus-set-default-directory)
2759 (setq gnus-newsgroup-name group)
2760 (unless (gnus-news-group-p group)
2761 (setq gnus-newsgroup-incorporated
2762 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2763 (make-local-variable 'gnus-summary-line-format)
2764 (make-local-variable 'gnus-summary-line-format-spec)
2765 (make-local-variable 'gnus-summary-dummy-line-format)
2766 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2767 (make-local-variable 'gnus-summary-mark-positions)
2768 (gnus-make-local-hook 'pre-command-hook)
2769 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2770 (gnus-run-hooks 'gnus-summary-mode-hook)
2771 (turn-on-gnus-mailing-list-mode)
2772 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2773 (gnus-update-summary-mark-positions))
2775 (defun gnus-summary-make-local-variables ()
2776 "Make all the local summary buffer variables."
2778 (dolist (local gnus-summary-local-variables)
2781 (if (eq (cdr local) 'global)
2782 ;; Copy the global value of the variable.
2783 (setq global (symbol-value (car local)))
2784 ;; Use the value from the list.
2785 (setq global (eval (cdr local))))
2786 (set (make-local-variable (car local)) global))
2787 ;; Simple nil-valued local variable.
2788 (set (make-local-variable local) nil)))))
2790 (defun gnus-summary-clear-local-variables ()
2791 (let ((locals gnus-summary-local-variables))
2793 (if (consp (car locals))
2794 (and (vectorp (caar locals))
2795 (set (caar locals) nil))
2796 (and (vectorp (car locals))
2797 (set (car locals) nil)))
2798 (setq locals (cdr locals)))))
2800 ;; Summary data functions.
2802 (defmacro gnus-data-number (data)
2805 (defmacro gnus-data-set-number (data number)
2806 `(setcar ,data ,number))
2808 (defmacro gnus-data-mark (data)
2811 (defmacro gnus-data-set-mark (data mark)
2812 `(setcar (nthcdr 1 ,data) ,mark))
2814 (defmacro gnus-data-pos (data)
2817 (defmacro gnus-data-set-pos (data pos)
2818 `(setcar (nthcdr 2 ,data) ,pos))
2820 (defmacro gnus-data-header (data)
2823 (defmacro gnus-data-set-header (data header)
2824 `(setcar (nthcdr 3 ,data) ,header))
2826 (defmacro gnus-data-level (data)
2829 (defmacro gnus-data-unread-p (data)
2830 `(= (nth 1 ,data) gnus-unread-mark))
2832 (defmacro gnus-data-read-p (data)
2833 `(/= (nth 1 ,data) gnus-unread-mark))
2835 (defmacro gnus-data-pseudo-p (data)
2836 `(consp (nth 3 ,data)))
2838 (defmacro gnus-data-find (number)
2839 `(assq ,number gnus-newsgroup-data))
2841 (defmacro gnus-data-find-list (number &optional data)
2842 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2843 (memq (assq ,number bdata)
2846 (defmacro gnus-data-make (number mark pos header level)
2847 `(list ,number ,mark ,pos ,header ,level))
2849 (defun gnus-data-enter (after-article number mark pos header level offset)
2850 (let ((data (gnus-data-find-list after-article)))
2852 (error "No such article: %d" after-article))
2853 (setcdr data (cons (gnus-data-make number mark pos header level)
2855 (setq gnus-newsgroup-data-reverse nil)
2856 (gnus-data-update-list (cddr data) offset)))
2858 (defun gnus-data-enter-list (after-article list &optional offset)
2860 (let ((data (and after-article (gnus-data-find-list after-article)))
2864 (let ((odata gnus-newsgroup-data))
2865 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2867 (gnus-data-update-list odata offset)))
2868 ;; Find the last element in the list to be spliced into the main
2870 (setq list (last list))
2873 (setcdr list gnus-newsgroup-data)
2874 (setq gnus-newsgroup-data ilist)
2876 (gnus-data-update-list (cdr list) offset)))
2877 (setcdr list (cdr data))
2880 (gnus-data-update-list (cdr list) offset))))
2881 (setq gnus-newsgroup-data-reverse nil))))
2883 (defun gnus-data-remove (article &optional offset)
2884 (let ((data gnus-newsgroup-data))
2885 (if (= (gnus-data-number (car data)) article)
2887 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2888 gnus-newsgroup-data-reverse nil)
2890 (gnus-data-update-list gnus-newsgroup-data offset)))
2892 (when (= (gnus-data-number (cadr data)) article)
2893 (setcdr data (cddr data))
2895 (gnus-data-update-list (cdr data) offset))
2897 gnus-newsgroup-data-reverse nil))
2898 (setq data (cdr data))))))
2900 (defmacro gnus-data-list (backward)
2902 (or gnus-newsgroup-data-reverse
2903 (setq gnus-newsgroup-data-reverse
2904 (reverse gnus-newsgroup-data)))
2905 gnus-newsgroup-data))
2907 (defun gnus-data-update-list (data offset)
2908 "Add OFFSET to the POS of all data entries in DATA."
2909 (setq gnus-newsgroup-data-reverse nil)
2911 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2912 (setq data (cdr data))))
2914 (defun gnus-summary-article-pseudo-p (article)
2915 "Say whether this article is a pseudo article or not."
2916 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2918 (defmacro gnus-summary-article-sparse-p (article)
2919 "Say whether this article is a sparse article or not."
2920 `(memq ,article gnus-newsgroup-sparse))
2922 (defmacro gnus-summary-article-ancient-p (article)
2923 "Say whether this article is a sparse article or not."
2924 `(memq ,article gnus-newsgroup-ancient))
2926 (defun gnus-article-parent-p (number)
2927 "Say whether this article is a parent or not."
2928 (let ((data (gnus-data-find-list number)))
2929 (and (cdr data) ; There has to be an article after...
2930 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2931 (gnus-data-level (nth 1 data))))))
2933 (defun gnus-article-children (number)
2934 "Return a list of all children to NUMBER."
2935 (let* ((data (gnus-data-find-list number))
2936 (level (gnus-data-level (car data)))
2938 (setq data (cdr data))
2940 (= (gnus-data-level (car data)) (1+ level)))
2941 (push (gnus-data-number (car data)) children)
2942 (setq data (cdr data)))
2945 (defmacro gnus-summary-skip-intangible ()
2946 "If the current article is intangible, then jump to a different article."
2947 '(let ((to (get-text-property (point) 'gnus-intangible)))
2948 (and to (gnus-summary-goto-subject to))))
2950 (defmacro gnus-summary-article-intangible-p ()
2951 "Say whether this article is intangible or not."
2952 '(get-text-property (point) 'gnus-intangible))
2954 (defun gnus-article-read-p (article)
2955 "Say whether ARTICLE is read or not."
2956 (not (or (memq article gnus-newsgroup-marked)
2957 (memq article gnus-newsgroup-spam-marked)
2958 (memq article gnus-newsgroup-unreads)
2959 (memq article gnus-newsgroup-unselected)
2960 (memq article gnus-newsgroup-dormant))))
2962 ;; Some summary mode macros.
2964 (defmacro gnus-summary-article-number ()
2965 "The article number of the article on the current line.
2966 If there isn't an article number here, then we return the current
2969 (gnus-summary-skip-intangible)
2970 (or (get-text-property (point) 'gnus-number)
2971 (gnus-summary-last-subject))))
2973 (defmacro gnus-summary-article-header (&optional number)
2974 "Return the header of article NUMBER."
2975 `(gnus-data-header (gnus-data-find
2976 ,(or number '(gnus-summary-article-number)))))
2978 (defmacro gnus-summary-thread-level (&optional number)
2979 "Return the level of thread that starts with article NUMBER."
2980 `(if (and (eq gnus-summary-make-false-root 'dummy)
2981 (get-text-property (point) 'gnus-intangible))
2983 (gnus-data-level (gnus-data-find
2984 ,(or number '(gnus-summary-article-number))))))
2986 (defmacro gnus-summary-article-mark (&optional number)
2987 "Return the mark of article NUMBER."
2988 `(gnus-data-mark (gnus-data-find
2989 ,(or number '(gnus-summary-article-number)))))
2991 (defmacro gnus-summary-article-pos (&optional number)
2992 "Return the position of the line of article NUMBER."
2993 `(gnus-data-pos (gnus-data-find
2994 ,(or number '(gnus-summary-article-number)))))
2996 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2997 (defmacro gnus-summary-article-subject (&optional number)
2998 "Return current subject string or nil if nothing."
3001 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3002 '(gnus-data-header (assq (gnus-summary-article-number)
3003 gnus-newsgroup-data)))))
3006 (mail-header-subject headers))))
3008 (defmacro gnus-summary-article-score (&optional number)
3009 "Return current article score."
3010 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3011 gnus-newsgroup-scored))
3012 gnus-summary-default-score 0))
3014 (defun gnus-summary-article-children (&optional number)
3015 "Return a list of article numbers that are children of article NUMBER."
3016 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3017 (level (gnus-data-level (car data)))
3019 (while (and (setq data (cdr data))
3020 (> (setq l (gnus-data-level (car data))) level))
3021 (and (= (1+ level) l)
3022 (push (gnus-data-number (car data))
3024 (nreverse children)))
3026 (defun gnus-summary-article-parent (&optional number)
3027 "Return the article number of the parent of article NUMBER."
3028 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3029 (gnus-data-list t)))
3030 (level (gnus-data-level (car data))))
3032 () ; This is a root.
3033 ;; We search until we find an article with a level less than
3034 ;; this one. That function has to be the parent.
3035 (while (and (setq data (cdr data))
3036 (not (< (gnus-data-level (car data)) level))))
3037 (and data (gnus-data-number (car data))))))
3039 (defun gnus-unread-mark-p (mark)
3040 "Say whether MARK is the unread mark."
3041 (= mark gnus-unread-mark))
3043 (defun gnus-read-mark-p (mark)
3044 "Say whether MARK is one of the marks that mark as read.
3045 This is all marks except unread, ticked, dormant, and expirable."
3046 (not (or (= mark gnus-unread-mark)
3047 (= mark gnus-ticked-mark)
3048 (= mark gnus-spam-mark)
3049 (= mark gnus-dormant-mark)
3050 (= mark gnus-expirable-mark))))
3052 (defmacro gnus-article-mark (number)
3053 "Return the MARK of article NUMBER.
3054 This macro should only be used when computing the mark the \"first\"
3055 time; i.e., when generating the summary lines. After that,
3056 `gnus-summary-article-mark' should be used to examine the
3059 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3060 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3061 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3062 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3063 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3064 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3065 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3066 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3067 gnus-ancient-mark))))
3069 ;; Saving hidden threads.
3071 (defmacro gnus-save-hidden-threads (&rest forms)
3072 "Save hidden threads, eval FORMS, and restore the hidden threads."
3073 (let ((config (make-symbol "config")))
3074 `(let ((,config (gnus-hidden-threads-configuration)))
3078 (gnus-restore-hidden-threads-configuration ,config)))))
3079 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3080 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3082 (defun gnus-data-compute-positions ()
3083 "Compute the positions of all articles."
3084 (setq gnus-newsgroup-data-reverse nil)
3085 (let ((data gnus-newsgroup-data))
3087 (gnus-save-hidden-threads
3088 (gnus-summary-show-all-threads)
3089 (goto-char (point-min))
3091 (while (get-text-property (point) 'gnus-intangible)
3093 (gnus-data-set-pos (car data) (+ (point) 3))
3094 (setq data (cdr data))
3095 (forward-line 1))))))
3097 (defun gnus-hidden-threads-configuration ()
3098 "Return the current hidden threads configuration."
3101 (goto-char (point-min))
3102 (while (search-forward "\r" nil t)
3103 (push (1- (point)) config))
3106 (defun gnus-restore-hidden-threads-configuration (config)
3107 "Restore hidden threads configuration from CONFIG."
3109 (let (point buffer-read-only)
3110 (while (setq point (pop config))
3111 (when (and (< point (point-max))
3113 (eq (char-after) ?\n))
3114 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3116 ;; Various summary mode internalish functions.
3118 (defun gnus-mouse-pick-article (e)
3121 (gnus-summary-next-page nil t))
3123 (defun gnus-summary-set-display-table ()
3124 "Change the display table.
3125 Odd characters have a tendency to mess
3126 up nicely formatted displays - we make all possible glyphs
3127 display only a single character."
3129 ;; We start from the standard display table, if any.
3130 (let ((table (or (copy-sequence standard-display-table)
3131 (make-display-table)))
3133 ;; Nix out all the control chars...
3134 (while (>= (setq i (1- i)) 0)
3135 (aset table i [??]))
3136 ;; ... but not newline and cr, of course. (cr is necessary for the
3137 ;; selective display).
3138 (aset table ?\n nil)
3139 (aset table ?\r nil)
3140 ;; We keep TAB as well.
3141 (aset table ?\t nil)
3142 ;; We nix out any glyphs over 126 that are not set already.
3144 (while (>= (setq i (1- i)) 127)
3145 ;; Only modify if the entry is nil.
3146 (unless (aref table i)
3147 (aset table i [??]))))
3148 (setq buffer-display-table table)))
3150 (defun gnus-summary-set-article-display-arrow (pos)
3151 "Update the overlay arrow to point to line at position POS."
3152 (when (and gnus-summary-display-arrow
3153 (boundp 'overlay-arrow-position)
3154 (boundp 'overlay-arrow-string))
3158 (unless overlay-arrow-position
3159 (setq overlay-arrow-position (make-marker)))
3160 (setq overlay-arrow-string "=>"
3161 overlay-arrow-position (set-marker overlay-arrow-position
3163 (current-buffer))))))
3165 (defun gnus-summary-setup-buffer (group)
3166 "Initialize summary buffer."
3167 (let ((buffer (gnus-summary-buffer-name group))
3168 (dead-name (concat "*Dead Summary "
3169 (gnus-group-decoded-name group) "*")))
3170 ;; If a dead summary buffer exists, we kill it.
3171 (when (gnus-buffer-live-p dead-name)
3172 (gnus-kill-buffer dead-name))
3173 (if (get-buffer buffer)
3176 (setq gnus-summary-buffer (current-buffer))
3177 (not gnus-newsgroup-prepared))
3178 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3179 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3180 (gnus-summary-mode group)
3182 (gnus-carpal-setup-buffer 'summary))
3183 (unless gnus-single-article-buffer
3184 (make-local-variable 'gnus-article-buffer)
3185 (make-local-variable 'gnus-article-current)
3186 (make-local-variable 'gnus-original-article-buffer))
3187 (setq gnus-newsgroup-name group)
3188 ;; Set any local variables in the group parameters.
3189 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3192 (defun gnus-set-global-variables ()
3193 "Set the global equivalents of the buffer-local variables.
3194 They are set to the latest values they had. These reflect the summary
3195 buffer that was in action when the last article was fetched."
3196 (when (eq major-mode 'gnus-summary-mode)
3197 (setq gnus-summary-buffer (current-buffer))
3198 (let ((name gnus-newsgroup-name)
3199 (marked gnus-newsgroup-marked)
3200 (spam gnus-newsgroup-spam-marked)
3201 (unread gnus-newsgroup-unreads)
3202 (headers gnus-current-headers)
3203 (data gnus-newsgroup-data)
3204 (summary gnus-summary-buffer)
3205 (article-buffer gnus-article-buffer)
3206 (original gnus-original-article-buffer)
3207 (gac gnus-article-current)
3208 (reffed gnus-reffed-article-number)
3209 (score-file gnus-current-score-file)
3210 (default-charset gnus-newsgroup-charset)
3212 (let ((locals gnus-newsgroup-variables))
3214 (if (consp (car locals))
3215 (push (eval (caar locals)) vlist)
3216 (push (eval (car locals)) vlist))
3217 (setq locals (cdr locals)))
3218 (setq vlist (nreverse vlist)))
3219 (with-current-buffer gnus-group-buffer
3220 (setq gnus-newsgroup-name name
3221 gnus-newsgroup-marked marked
3222 gnus-newsgroup-spam-marked spam
3223 gnus-newsgroup-unreads unread
3224 gnus-current-headers headers
3225 gnus-newsgroup-data data
3226 gnus-article-current gac
3227 gnus-summary-buffer summary
3228 gnus-article-buffer article-buffer
3229 gnus-original-article-buffer original
3230 gnus-reffed-article-number reffed
3231 gnus-current-score-file score-file
3232 gnus-newsgroup-charset default-charset)
3233 (let ((locals gnus-newsgroup-variables))
3235 (if (consp (car locals))
3236 (set (caar locals) (pop vlist))
3237 (set (car locals) (pop vlist)))
3238 (setq locals (cdr locals))))
3239 ;; The article buffer also has local variables.
3240 (when (gnus-buffer-live-p gnus-article-buffer)
3241 (set-buffer gnus-article-buffer)
3242 (setq gnus-summary-buffer summary))))))
3244 (defun gnus-summary-article-unread-p (article)
3245 "Say whether ARTICLE is unread or not."
3246 (memq article gnus-newsgroup-unreads))
3248 (defun gnus-summary-first-article-p (&optional article)
3249 "Return whether ARTICLE is the first article in the buffer."
3250 (if (not (setq article (or article (gnus-summary-article-number))))
3252 (eq article (caar gnus-newsgroup-data))))
3254 (defun gnus-summary-last-article-p (&optional article)
3255 "Return whether ARTICLE is the last article in the buffer."
3256 (if (not (setq article (or article (gnus-summary-article-number))))
3257 ;; All non-existent numbers are the last article. :-)
3259 (not (cdr (gnus-data-find-list article)))))
3261 (defun gnus-make-thread-indent-array ()
3263 (unless (and gnus-thread-indent-array
3264 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3265 (setq gnus-thread-indent-array (make-vector 201 "")
3266 gnus-thread-indent-array-level gnus-thread-indent-level)
3268 (aset gnus-thread-indent-array n
3269 (make-string (* n gnus-thread-indent-level) ? ))
3272 (defun gnus-update-summary-mark-positions ()
3273 "Compute where the summary marks are to go."
3275 (when (gnus-buffer-exists-p gnus-summary-buffer)
3276 (set-buffer gnus-summary-buffer))
3277 (let ((spec gnus-summary-line-format-spec)
3280 (gnus-set-work-buffer)
3281 (let ((gnus-tmp-unread ?Z)
3282 (gnus-replied-mark ?Z)
3283 (gnus-score-below-mark ?Z)
3284 (gnus-score-over-mark ?Z)
3285 (gnus-undownloaded-mark ?Z)
3286 (gnus-summary-line-format-spec spec)
3287 (gnus-newsgroup-downloadable '(0))
3289 (make-full-mail-header
3290 0 "" "nobody" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil))
3291 case-fold-search ignores)
3292 ;; Here, all marks are bound to Z.
3293 (gnus-summary-insert-line header
3294 0 nil t gnus-tmp-unread t nil "" nil 1)
3295 (goto-char (point-min))
3296 ;; Memorize the positions of the same characters as dummy marks.
3297 (while (re-search-forward "[A-D]" nil t)
3298 (push (point) ignores))
3300 ;; We use A-D as dummy marks in order to know column positions
3301 ;; where marks should be inserted.
3302 (setq gnus-tmp-unread ?A
3303 gnus-replied-mark ?B
3304 gnus-score-below-mark ?C
3305 gnus-score-over-mark ?C
3306 gnus-undownloaded-mark ?D)
3307 (gnus-summary-insert-line header
3308 0 nil t gnus-tmp-unread t nil "" nil 1)
3309 ;; Ignore characters which aren't dummy marks.
3311 (delete-region (goto-char (1- p)) p)
3313 (goto-char (point-min))
3314 (setq pos (list (cons 'unread
3315 (and (search-forward "A" nil t)
3316 (- (point) (point-min) 1)))))
3317 (goto-char (point-min))
3318 (push (cons 'replied (and (search-forward "B" nil t)
3319 (- (point) (point-min) 1)))
3321 (goto-char (point-min))
3322 (push (cons 'score (and (search-forward "C" nil t)
3323 (- (point) (point-min) 1)))
3325 (goto-char (point-min))
3326 (push (cons 'download (and (search-forward "D" nil t)
3327 (- (point) (point-min) 1)))
3329 (setq gnus-summary-mark-positions pos))))
3331 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3332 "Insert a dummy root in the summary buffer."
3334 (gnus-add-text-properties
3335 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3336 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3338 (defun gnus-summary-extract-address-component (from)
3339 (or (car (funcall gnus-extract-address-components from))
3342 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3343 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3344 default-mime-charset)))
3345 ;; Is it really necessary to do this next part for each summary line?
3346 ;; Luckily, doesn't seem to slow things down much.
3348 (and gnus-ignored-from-addresses
3349 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3350 (let ((extra-headers (mail-header-extra header))
3354 ((setq to (cdr (assq 'To extra-headers)))
3357 (gnus-summary-extract-address-component
3358 (funcall gnus-decode-encoded-word-function to)))))
3359 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3360 (concat "=> " newsgroups)))))
3361 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3363 (defun gnus-summary-insert-line (gnus-tmp-header
3364 gnus-tmp-level gnus-tmp-current
3365 undownloaded gnus-tmp-unread gnus-tmp-replied
3366 gnus-tmp-expirable gnus-tmp-subject-or-nil
3367 &optional gnus-tmp-dummy gnus-tmp-score
3369 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3370 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3371 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3372 (gnus-tmp-score-char
3373 (if (or (null gnus-summary-default-score)
3374 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3375 gnus-summary-zcore-fuzz))
3377 (if (< gnus-tmp-score gnus-summary-default-score)
3378 gnus-score-below-mark gnus-score-over-mark)))
3379 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3381 (cond (gnus-tmp-process gnus-process-mark)
3382 ((memq gnus-tmp-current gnus-newsgroup-cached)
3384 (gnus-tmp-replied gnus-replied-mark)
3385 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3386 gnus-forwarded-mark)
3387 ((memq gnus-tmp-current gnus-newsgroup-saved)
3389 ((memq gnus-tmp-number gnus-newsgroup-recent)
3391 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3394 (gnus-tmp-downloaded
3396 gnus-undownloaded-mark)
3397 (gnus-newsgroup-agentized
3398 gnus-downloaded-mark)
3401 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3404 ((string-match "<[^>]+> *$" gnus-tmp-from)
3405 (let ((beg (match-beginning 0)))
3406 (or (and (string-match "^\".+\"" gnus-tmp-from)
3407 (substring gnus-tmp-from 1 (1- (match-end 0))))
3408 (substring gnus-tmp-from 0 beg))))
3409 ((string-match "(.+)" gnus-tmp-from)
3410 (substring gnus-tmp-from
3411 (1+ (match-beginning 0)) (1- (match-end 0))))
3413 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3414 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3415 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3416 (buffer-read-only nil))
3417 (when (string= gnus-tmp-name "")
3418 (setq gnus-tmp-name gnus-tmp-from))
3419 (unless (numberp gnus-tmp-lines)
3420 (setq gnus-tmp-lines -1))
3421 (if (= gnus-tmp-lines -1)
3422 (setq gnus-tmp-lines "?")
3423 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3424 (gnus-put-text-property-excluding-characters-with-faces
3426 (progn (eval gnus-summary-line-format-spec) (point))
3427 'gnus-number gnus-tmp-number)
3428 (when (gnus-visual-p 'summary-highlight 'highlight)
3430 (gnus-run-hooks 'gnus-summary-update-hook)
3433 (defun gnus-summary-update-line (&optional dont-update)
3434 "Update summary line after change."
3435 (when (and gnus-summary-default-score
3436 (not gnus-summary-inhibit-highlight))
3437 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3438 (article (gnus-summary-article-number))
3439 (score (gnus-summary-article-score article)))
3441 (if (and gnus-summary-mark-below
3442 (< (gnus-summary-article-score)
3443 gnus-summary-mark-below))
3444 ;; This article has a low score, so we mark it as read.
3445 (when (memq article gnus-newsgroup-unreads)
3446 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3447 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3448 ;; This article was previously marked as read on account
3449 ;; of a low score, but now it has risen, so we mark it as
3451 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3452 (gnus-summary-update-mark
3453 (if (or (null gnus-summary-default-score)
3454 (<= (abs (- score gnus-summary-default-score))
3455 gnus-summary-zcore-fuzz))
3457 (if (< score gnus-summary-default-score)
3458 gnus-score-below-mark gnus-score-over-mark))
3460 ;; Do visual highlighting.
3461 (when (gnus-visual-p 'summary-highlight 'highlight)
3462 (gnus-run-hooks 'gnus-summary-update-hook)))))
3464 (defvar gnus-tmp-new-adopts nil)
3466 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3467 "Return the number of articles in THREAD.
3468 This may be 0 in some cases -- if none of the articles in
3469 the thread are to be displayed."
3471 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3473 ((not (listp thread))
3475 ((and (consp thread) (cdr thread))
3478 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3481 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3484 (when (and level (zerop level) gnus-tmp-new-adopts)
3487 'gnus-summary-number-of-articles-in-thread
3488 gnus-tmp-new-adopts))))
3490 (if (> number 1) gnus-not-empty-thread-mark
3491 gnus-empty-thread-mark)
3494 (defsubst gnus-summary-line-message-size (head)
3495 "Return pretty-printed version of message size.
3496 This function is intended to be used in
3497 `gnus-summary-line-format-alist'."
3498 (let ((c (or (mail-header-chars head) -1)))
3499 (cond ((< c 0) "n/a") ; chars not available
3500 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3501 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3502 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3503 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3506 (defun gnus-summary-set-local-parameters (group)
3507 "Go through the local params of GROUP and set all variable specs in that list."
3508 (let ((vars '(quit-config))) ; Ignore quit-config.
3509 (dolist (elem (gnus-group-find-parameter group))
3510 (and (consp elem) ; Has to be a cons.
3511 (consp (cdr elem)) ; The cdr has to be a list.
3512 (symbolp (car elem)) ; Has to be a symbol in there.
3513 (not (memq (car elem) vars))
3514 (ignore-errors ; So we set it.
3515 (push (car elem) vars)
3516 (make-local-variable (car elem))
3517 (set (car elem) (eval (nth 1 elem))))))))
3519 (defun gnus-summary-read-group (group &optional show-all no-article
3520 kill-buffer no-display backward
3522 "Start reading news in newsgroup GROUP.
3523 If SHOW-ALL is non-nil, already read articles are also listed.
3524 If NO-ARTICLE is non-nil, no article is selected initially.
3525 If NO-DISPLAY, don't generate a summary buffer."
3529 (let ((gnus-auto-select-next nil))
3530 (or (gnus-summary-read-group-1
3531 group show-all no-article
3532 kill-buffer no-display
3535 select-articles nil)))))
3536 (eq gnus-auto-select-next 'quietly))
3537 (set-buffer gnus-group-buffer)
3538 ;; The entry function called above goes to the next
3539 ;; group automatically, so we go two groups back
3540 ;; if we are searching for the previous group.
3542 (gnus-group-prev-unread-group 2))
3543 (if (not (equal group (gnus-group-group-name)))
3544 (setq group (gnus-group-group-name))
3548 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3549 "Directly jump to the other GROUP from summary buffer.
3550 If SHOW-ALL is non-nil, already read articles are also listed."
3552 (if (eq gnus-summary-buffer (current-buffer))
3553 (list (completing-read
3554 "Group: " gnus-active-hashtb nil t
3555 (when (and gnus-newsgroup-name
3556 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3557 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3558 'gnus-group-history)
3560 (error "%s must be invoked from a gnus summary buffer." this-command)))
3561 (unless (or (zerop (length group))
3562 (and gnus-newsgroup-name
3563 (string-equal gnus-newsgroup-name group)))
3565 (gnus-summary-read-group group show-all
3566 gnus-dont-select-after-jump-to-other-group)))
3568 (defun gnus-summary-read-group-1 (group show-all no-article
3569 kill-buffer no-display
3570 &optional select-articles)
3571 ;; Killed foreign groups can't be entered.
3572 ;; (when (and (not (gnus-group-native-p group))
3573 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3574 ;; (error "Dead non-native groups can't be entered"))
3575 (gnus-message 5 "Retrieving newsgroup: %s..."
3576 (gnus-group-decoded-name group))
3577 (let* ((new-group (gnus-summary-setup-buffer group))
3578 (quit-config (gnus-group-quit-config group))
3579 (did-select (and new-group (gnus-select-newsgroup
3580 group show-all select-articles))))
3582 ;; This summary buffer exists already, so we just select it.
3584 (gnus-set-global-variables)
3586 (gnus-kill-or-deaden-summary kill-buffer))
3587 (gnus-configure-windows 'summary 'force)
3588 (gnus-set-mode-line 'summary)
3589 (gnus-summary-position-point)
3592 ;; We couldn't select this group.
3594 (when (and (eq major-mode 'gnus-summary-mode)
3595 (not (equal (current-buffer) kill-buffer)))
3596 (kill-buffer (current-buffer))
3597 (if (not quit-config)
3599 ;; Update the info -- marks might need to be removed,
3601 (gnus-summary-update-info)
3602 (set-buffer gnus-group-buffer)
3603 (gnus-group-jump-to-group group)
3604 (gnus-group-next-unread-group 1))
3605 (gnus-handle-ephemeral-exit quit-config)))
3606 (let ((grpinfo (gnus-get-info group)))
3607 (if (null (gnus-info-read grpinfo))
3608 (gnus-message 3 "Group %s contains no messages"
3609 (gnus-group-decoded-name group))
3610 (gnus-message 3 "Can't select group")))
3612 ;; The user did a `C-g' while prompting for number of articles,
3613 ;; so we exit this group.
3614 ((eq did-select 'quit)
3615 (and (eq major-mode 'gnus-summary-mode)
3616 (not (equal (current-buffer) kill-buffer))
3617 (kill-buffer (current-buffer)))
3619 (gnus-kill-or-deaden-summary kill-buffer))
3620 (if (not quit-config)
3622 (set-buffer gnus-group-buffer)
3623 (gnus-group-jump-to-group group)
3624 (gnus-group-next-unread-group 1)
3625 (gnus-configure-windows 'group 'force))
3626 (gnus-handle-ephemeral-exit quit-config))
3627 ;; Finally signal the quit.
3629 ;; The group was successfully selected.
3631 (gnus-set-global-variables)
3632 ;; Save the active value in effect when the group was entered.
3633 (setq gnus-newsgroup-active
3635 (gnus-active gnus-newsgroup-name)))
3636 ;; You can change the summary buffer in some way with this hook.
3637 (gnus-run-hooks 'gnus-select-group-hook)
3638 (when (memq 'summary (gnus-update-format-specifications
3639 nil 'summary 'summary-mode 'summary-dummy))
3640 ;; The format specification for the summary line was updated,
3641 ;; so we need to update the mark positions as well.
3642 (gnus-update-summary-mark-positions))
3643 ;; Do score processing.
3644 (when gnus-use-scoring
3645 (gnus-possibly-score-headers))
3646 ;; Check whether to fill in the gaps in the threads.
3647 (when gnus-build-sparse-threads
3648 (gnus-build-sparse-threads))
3649 ;; Find the initial limit.
3651 (let ((gnus-newsgroup-dormant nil))
3652 (gnus-summary-initial-limit show-all))
3653 (gnus-summary-initial-limit show-all))
3654 ;; Generate the summary buffer.
3656 (gnus-summary-prepare))
3657 (when gnus-use-trees
3658 (gnus-tree-open group)
3659 (setq gnus-summary-highlight-line-function
3660 'gnus-tree-highlight-article))
3661 ;; If the summary buffer is empty, but there are some low-scored
3662 ;; articles or some excluded dormants, we include these in the
3664 (when (and (zerop (buffer-size))
3666 (cond (gnus-newsgroup-dormant
3667 (gnus-summary-limit-include-dormant))
3668 ((and gnus-newsgroup-scored show-all)
3669 (gnus-summary-limit-include-expunged t))))
3670 ;; Function `gnus-apply-kill-file' must be called in this hook.
3671 (gnus-run-hooks 'gnus-apply-kill-hook)
3672 (if (and (zerop (buffer-size))
3675 ;; This newsgroup is empty.
3676 (gnus-summary-catchup-and-exit nil t)
3677 (gnus-message 6 "No unread news")
3679 (gnus-kill-or-deaden-summary kill-buffer))
3680 ;; Return nil from this function.
3682 ;; Hide conversation thread subtrees. We cannot do this in
3683 ;; gnus-summary-prepare-hook since kill processing may not
3684 ;; work with hidden articles.
3685 (gnus-summary-maybe-hide-threads)
3687 (gnus-kill-or-deaden-summary kill-buffer))
3688 (gnus-summary-auto-select-subject)
3689 ;; Show first unread article if requested.
3690 (if (and (not no-article)
3692 gnus-newsgroup-unreads
3693 gnus-auto-select-first)
3695 (gnus-configure-windows 'summary)
3696 (let ((art (gnus-summary-article-number)))
3697 (unless (and (not gnus-plugged)
3698 (or (memq art gnus-newsgroup-undownloaded)
3699 (memq art gnus-newsgroup-downloadable)))
3700 (gnus-summary-goto-article art))))
3701 ;; Don't select any articles.
3702 (gnus-summary-position-point)
3703 (gnus-configure-windows 'summary 'force)
3704 (gnus-set-mode-line 'summary))
3705 (when (and gnus-auto-center-group
3706 (get-buffer-window gnus-group-buffer t))
3707 ;; Gotta use windows, because recenter does weird stuff if
3708 ;; the current buffer ain't the displayed window.
3709 (let ((owin (selected-window)))
3710 (select-window (get-buffer-window gnus-group-buffer t))
3711 (when (gnus-group-goto-group group)
3713 (select-window owin)))
3714 ;; Mark this buffer as "prepared".
3715 (setq gnus-newsgroup-prepared t)
3716 (gnus-run-hooks 'gnus-summary-prepared-hook)
3717 (unless (gnus-ephemeral-group-p group)
3718 (gnus-group-update-group group))
3721 (defun gnus-summary-auto-select-subject ()
3722 "Select the subject line on initial group entry."
3723 (goto-char (point-min))
3725 ((eq gnus-auto-select-subject 'best)
3726 (gnus-summary-best-unread-subject))
3727 ((eq gnus-auto-select-subject 'unread)
3728 (gnus-summary-first-unread-subject))
3729 ((eq gnus-auto-select-subject 'unseen)
3730 (gnus-summary-first-unseen-subject))
3731 ((eq gnus-auto-select-subject 'unseen-or-unread)
3732 (gnus-summary-first-unseen-or-unread-subject))
3733 ((eq gnus-auto-select-subject 'first)
3736 ((functionp gnus-auto-select-subject)
3737 (funcall gnus-auto-select-subject))))
3739 (defun gnus-summary-prepare ()
3740 "Generate the summary buffer."
3742 (let ((buffer-read-only nil))
3744 (setq gnus-newsgroup-data nil
3745 gnus-newsgroup-data-reverse nil)
3746 (gnus-run-hooks 'gnus-summary-generate-hook)
3747 ;; Generate the buffer, either with threads or without.
3748 (when gnus-newsgroup-headers
3749 (gnus-summary-prepare-threads
3750 (if gnus-show-threads
3751 (gnus-sort-gathered-threads
3752 (funcall gnus-summary-thread-gathering-function
3754 (gnus-cut-threads (gnus-make-threads)))))
3755 ;; Unthreaded display.
3756 (gnus-sort-articles gnus-newsgroup-headers))))
3757 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3758 ;; Call hooks for modifying summary buffer.
3759 (goto-char (point-min))
3760 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3762 (defsubst gnus-general-simplify-subject (subject)
3763 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3766 ;; Truncate the subject.
3767 (gnus-simplify-subject-functions
3768 (gnus-map-function gnus-simplify-subject-functions subject))
3769 ((numberp gnus-summary-gather-subject-limit)
3770 (setq subject (gnus-simplify-subject-re subject))
3771 (if (> (length subject) gnus-summary-gather-subject-limit)
3772 (substring subject 0 gnus-summary-gather-subject-limit)
3774 ;; Fuzzily simplify it.
3775 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3776 (gnus-simplify-subject-fuzzy subject))
3777 ;; Just remove the leading "Re:".
3779 (gnus-simplify-subject-re subject))))
3781 (if (and gnus-summary-gather-exclude-subject
3782 (string-match gnus-summary-gather-exclude-subject subject))
3783 nil ; This article shouldn't be gathered
3786 (defun gnus-summary-simplify-subject-query ()
3787 "Query where the respool algorithm would put this article."
3789 (gnus-summary-select-article)
3791 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3793 (defun gnus-gather-threads-by-subject (threads)
3794 "Gather threads by looking at Subject headers."
3795 (if (not gnus-summary-make-false-root)
3797 (let ((hashtb (gnus-make-hashtable 1024))
3800 subject hthread whole-subject)
3802 (setq subject (gnus-general-simplify-subject
3803 (setq whole-subject (mail-header-subject
3806 (if (setq hthread (gnus-gethash subject hashtb))
3808 ;; We enter a dummy root into the thread, if we
3809 ;; haven't done that already.
3810 (unless (stringp (caar hthread))
3811 (setcar hthread (list whole-subject (car hthread))))
3812 ;; We add this new gathered thread to this gathered
3814 (setcdr (car hthread)
3815 (nconc (cdar hthread) (list (car threads))))
3816 ;; Remove it from the list of threads.
3817 (setcdr prev (cdr threads))
3818 (setq threads prev))
3819 ;; Enter this thread into the hash table.
3820 (gnus-sethash subject
3821 (if gnus-summary-make-false-root-always
3823 ;; If you want a dummy root above all
3825 (setcar threads (list whole-subject
3831 (setq threads (cdr threads)))
3834 (defun gnus-gather-threads-by-references (threads)
3835 "Gather threads by looking at References headers."
3836 (let ((idhashtb (gnus-make-hashtable 1024))
3837 (thhashtb (gnus-make-hashtable 1024))
3840 ids references id gthread gid entered ref)
3842 (when (setq references (mail-header-references (caar threads)))
3843 (setq id (mail-header-id (caar threads))
3844 ids (inline (gnus-split-references references))
3846 (while (setq ref (pop ids))
3847 (setq ids (delete ref ids))
3848 (if (not (setq gid (gnus-gethash ref idhashtb)))
3850 (gnus-sethash ref id idhashtb)
3851 (gnus-sethash id threads thhashtb))
3852 (setq gthread (gnus-gethash gid thhashtb))
3854 ;; We enter a dummy root into the thread, if we
3855 ;; haven't done that already.
3856 (unless (stringp (caar gthread))
3857 (setcar gthread (list (mail-header-subject (caar gthread))
3859 ;; We add this new gathered thread to this gathered
3861 (setcdr (car gthread)
3862 (nconc (cdar gthread) (list (car threads)))))
3863 ;; Add it into the thread hash table.
3864 (gnus-sethash id gthread thhashtb)
3866 ;; Remove it from the list of threads.
3867 (setcdr prev (cdr threads))
3868 (setq threads prev))))
3870 (setq threads (cdr threads)))
3873 (defun gnus-sort-gathered-threads (threads)
3874 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3875 (let ((result threads))
3877 (when (stringp (caar threads))
3878 (setcdr (car threads)
3879 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3880 (setq threads (cdr threads)))
3883 (defun gnus-thread-loop-p (root thread)
3884 "Say whether ROOT is in THREAD."
3885 (let ((stack (list thread))
3888 (while (setq thread (pop stack))
3889 (setq th (cdr thread))
3891 (not (eq (caar th) root)))
3894 ;; We have found a loop.
3896 (setcdr thread (delq (car th) (cdr thread)))
3897 (if (boundp (setq ref-dep (intern "none"
3898 gnus-newsgroup-dependencies)))
3899 (setcdr (symbol-value ref-dep)
3900 (nconc (cdr (symbol-value ref-dep))
3902 (set ref-dep (list nil (car th))))
3905 ;; Push all the subthreads onto the stack.
3906 (push (cdr thread) stack)))
3909 (defun gnus-make-threads ()
3910 "Go through the dependency hashtb and find the roots. Return all threads."
3912 (while (catch 'infloop
3915 ;; Deal with self-referencing References loops.
3916 (when (and (car (symbol-value refs))
3923 (car (symbol-value refs)) thread))
3924 (cdr (symbol-value refs)))))))
3927 (unless (car (symbol-value refs))
3928 ;; These threads do not refer back to any other articles,
3929 ;; so they're roots.
3930 (setq threads (append (cdr (symbol-value refs)) threads))))
3931 gnus-newsgroup-dependencies)))
3934 ;; Build the thread tree.
3935 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3936 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3938 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3939 if it was already present.
3941 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3942 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3943 Message-IDs will be renamed to a unique Message-ID before being
3946 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3947 (let* ((id (mail-header-id header))
3948 (id-dep (and id (intern id dependencies)))
3949 parent-id ref ref-dep ref-header replaced)
3950 ;; Enter this `header' in the `dependencies' table.
3954 ;; The first two cases do the normal part: enter a new `header'
3955 ;; in the `dependencies' table.
3956 ((not (boundp id-dep))
3957 (set id-dep (list header)))
3958 ((null (car (symbol-value id-dep)))
3959 (setcar (symbol-value id-dep) header))
3961 ;; From here the `header' was already present in the
3962 ;; `dependencies' table.
3964 ;; Overrides an existing entry;
3965 ;; just set the header part of the entry.
3966 (setcar (symbol-value id-dep) header)
3969 ;; Renames the existing `header' to a unique Message-ID.
3970 ((not gnus-summary-ignore-duplicates)
3971 ;; An article with this Message-ID has already been seen.
3972 ;; We rename the Message-ID.
3973 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3975 (mail-header-set-id header id))
3977 ;; The last case ignores an existing entry, except it adds any
3978 ;; additional Xrefs (in case the two articles came from different
3980 ;; Also sets `header' to `nil' meaning that the `dependencies'
3981 ;; table was *not* modified.
3983 (mail-header-set-xref
3984 (car (symbol-value id-dep))
3985 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3987 (or (mail-header-xref header) "")))
3990 (when (and header (not replaced))
3991 ;; First check that we are not creating a References loop.
3992 (setq parent-id (gnus-parent-id (mail-header-references header)))
3993 (setq ref parent-id)
3995 (setq ref-dep (intern-soft ref dependencies))
3997 (setq ref-header (car (symbol-value ref-dep))))
3998 (if (string= id ref)
3999 ;; Yuk! This is a reference loop. Make the article be a
4002 (mail-header-set-references (car (symbol-value id-dep)) "none")
4004 (setq parent-id nil))
4005 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4006 (setq ref-dep (intern (or parent-id "none") dependencies))
4007 (if (boundp ref-dep)
4008 (setcdr (symbol-value ref-dep)
4009 (nconc (cdr (symbol-value ref-dep))
4010 (list (symbol-value id-dep))))
4011 (set ref-dep (list nil (symbol-value id-dep)))))
4014 (defun gnus-extract-message-id-from-in-reply-to (string)
4015 (if (string-match "<[^>]+>" string)
4016 (substring string (match-beginning 0) (match-end 0))
4019 (defun gnus-build-sparse-threads ()
4020 (let ((headers gnus-newsgroup-headers)
4021 (mail-parse-charset gnus-newsgroup-charset)
4022 (gnus-summary-ignore-duplicates t)
4023 header references generation relations
4024 subject child end new-child date)
4025 ;; First we create an alist of generations/relations, where
4026 ;; generations is how much we trust the relation, and the relation
4028 (gnus-message 7 "Making sparse threads...")
4030 (nnheader-set-temp-buffer " *gnus sparse threads*")
4031 (while (setq header (pop headers))
4032 (when (and (setq references (mail-header-references header))
4033 (not (string= references "")))
4035 (setq child (mail-header-id header)
4036 subject (mail-header-subject header)
4037 date (mail-header-date header)
4039 (while (search-backward ">" nil t)
4040 (setq end (1+ (point)))
4041 (when (search-backward "<" nil t)
4042 (setq new-child (buffer-substring (point) end))
4043 (push (list (incf generation)
4044 child (setq child new-child)
4048 (push (list (1+ generation) child nil subject) relations))
4050 (kill-buffer (current-buffer)))
4051 ;; Sort over trustworthiness.
4054 (when (gnus-dependencies-add-header
4055 (make-full-mail-header-from-decoded-header
4056 gnus-reffed-article-number
4057 (nth 3 relation) "" (or (nth 4 relation) "")
4059 (or (nth 2 relation) "") 0 0 "")
4060 gnus-newsgroup-dependencies nil)
4061 (push gnus-reffed-article-number gnus-newsgroup-limit)
4062 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4063 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4064 gnus-newsgroup-reads)
4065 (decf gnus-reffed-article-number)))
4066 (sort relations 'car-less-than-car))
4067 (gnus-message 7 "Making sparse threads...done")))
4069 (defun gnus-build-old-threads ()
4070 ;; Look at all the articles that refer back to old articles, and
4071 ;; fetch the headers for the articles that aren't there. This will
4072 ;; build complete threads - if the roots haven't been expired by the
4074 (let ((mail-parse-charset gnus-newsgroup-charset)
4078 (when (not (car (symbol-value refs)))
4079 (setq heads (cdr (symbol-value refs)))
4081 (if (memq (mail-header-number (caar heads))
4082 gnus-newsgroup-dormant)
4083 (setq heads (cdr heads))
4084 (setq id (symbol-name refs))
4085 (while (and (setq id (gnus-build-get-header id))
4086 (not (car (gnus-id-to-thread id)))))
4087 (setq heads nil)))))
4088 gnus-newsgroup-dependencies)))
4090 (defsubst gnus-remove-odd-characters (string)
4091 "Translate STRING into something that doesn't contain weird characters."
4092 (mm-subst-char-in-string
4094 (mm-subst-char-in-string ?\n ?\- string t) t))
4096 ;; This function has to be called with point after the article number
4097 ;; on the beginning of the line.
4098 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4099 (let ((eol (point-at-eol))
4100 (buffer (current-buffer))
4101 header references in-reply-to)
4103 ;; overview: [num subject from date id refs chars lines misc]
4106 (narrow-to-region (point) eol)
4111 (make-full-mail-header
4113 (nnheader-nov-field) ; subject
4114 (nnheader-nov-field) ; from
4115 (nnheader-nov-field) ; date
4116 (nnheader-nov-read-message-id number) ; id
4117 (setq references (nnheader-nov-field)) ; refs
4118 (nnheader-nov-read-integer) ; chars
4119 (nnheader-nov-read-integer) ; lines
4121 (if (looking-at "Xref: ")
4122 (goto-char (match-end 0)))
4123 (nnheader-nov-field)) ; Xref
4124 (nnheader-nov-parse-extra)))) ; extra
4128 (when (and (string= references "")
4129 (setq in-reply-to (mail-header-extra header))
4130 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4131 (mail-header-set-references
4132 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4134 (when gnus-alter-header-function
4135 (funcall gnus-alter-header-function header))
4136 (gnus-dependencies-add-header header dependencies force-new)))
4138 (defun gnus-build-get-header (id)
4139 "Look through the buffer of NOV lines and find the header to ID.
4140 Enter this line into the dependencies hash table, and return
4141 the id of the parent article (if any)."
4142 (let ((deps gnus-newsgroup-dependencies)
4146 (set-buffer nntp-server-buffer)
4147 (let ((case-fold-search nil))
4148 (goto-char (point-min))
4149 (while (and (not found)
4150 (search-forward id nil t))
4152 (setq found (looking-at
4153 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4154 (regexp-quote id))))
4155 (or found (beginning-of-line 2)))
4159 (setq header (gnus-nov-parse-line
4160 (read (current-buffer)) deps))
4161 (gnus-parent-id (mail-header-references header))))))
4163 (let ((number (mail-header-number header)))
4164 (push number gnus-newsgroup-limit)
4165 (push header gnus-newsgroup-headers)
4166 (if (memq number gnus-newsgroup-unselected)
4168 (setq gnus-newsgroup-unreads
4169 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4171 (setq gnus-newsgroup-unselected
4172 (delq number gnus-newsgroup-unselected)))
4173 (push number gnus-newsgroup-ancient)))))))
4175 (defun gnus-build-all-threads ()
4176 "Read all the headers."
4177 (let ((gnus-summary-ignore-duplicates t)
4178 (mail-parse-charset gnus-newsgroup-charset)
4179 (dependencies gnus-newsgroup-dependencies)
4182 (set-buffer nntp-server-buffer)
4183 (let ((case-fold-search nil))
4184 (goto-char (point-min))
4187 (setq article (read (current-buffer))
4188 header (gnus-nov-parse-line article dependencies)))
4190 (with-current-buffer gnus-summary-buffer
4191 (push header gnus-newsgroup-headers)
4192 (if (memq (setq article (mail-header-number header))
4193 gnus-newsgroup-unselected)
4195 (setq gnus-newsgroup-unreads
4196 (gnus-add-to-sorted-list
4197 gnus-newsgroup-unreads article))
4198 (setq gnus-newsgroup-unselected
4199 (delq article gnus-newsgroup-unselected)))
4200 (push article gnus-newsgroup-ancient)))
4201 (forward-line 1)))))))
4203 (defun gnus-summary-update-article-line (article header)
4204 "Update the line for ARTICLE using HEADER."
4205 (let* ((id (mail-header-id header))
4206 (thread (gnus-id-to-thread id)))
4208 (error "Article in no thread"))
4209 ;; Update the thread.
4210 (setcar thread header)
4211 (gnus-summary-goto-subject article)
4212 (let* ((datal (gnus-data-find-list article))
4214 (buffer-read-only nil)
4215 (level (gnus-summary-thread-level)))
4217 (let ((inserted (- (point)
4219 (gnus-summary-insert-line
4221 (memq article gnus-newsgroup-undownloaded)
4222 (gnus-article-mark article)
4223 (memq article gnus-newsgroup-replied)
4224 (memq article gnus-newsgroup-expirable)
4225 ;; Only insert the Subject string when it's different
4226 ;; from the previous Subject string.
4231 (mail-header-subject
4234 (gnus-data-find-list
4236 (gnus-data-list t)))))
4237 ;; Error on the side of excessive subjects.
4239 (mail-header-subject header)))
4241 (mail-header-subject header))
4242 nil (cdr (assq article gnus-newsgroup-scored))
4243 (memq article gnus-newsgroup-processable))
4246 (gnus-data-update-list
4248 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4250 (defun gnus-summary-update-article (article &optional iheader)
4251 "Update ARTICLE in the summary buffer."
4252 (set-buffer gnus-summary-buffer)
4253 (let* ((header (gnus-summary-article-header article))
4254 (id (mail-header-id header))
4255 (data (gnus-data-find article))
4256 (thread (gnus-id-to-thread id))
4257 (references (mail-header-references header))
4261 (when (and references
4262 (not (equal "" references)))
4265 (buffer-read-only nil)
4271 (delq thread parent)))
4272 (if (gnus-summary-insert-subject id header)
4273 ;; Set the (possibly) new article number in the data structure.
4274 (gnus-data-set-number data (gnus-id-to-article id))
4278 (defun gnus-rebuild-thread (id &optional line)
4279 "Rebuild the thread containing ID.
4280 If LINE, insert the rebuilt thread starting on line LINE."
4281 (let ((buffer-read-only nil)
4282 old-pos current thread data)
4283 (if (not gnus-show-threads)
4284 (setq thread (list (car (gnus-id-to-thread id))))
4285 ;; Get the thread this article is part of.
4286 (setq thread (gnus-remove-thread id)))
4287 (setq old-pos (point-at-bol))
4288 (setq current (save-excursion
4289 (and (re-search-backward "[\r\n]" nil t)
4290 (gnus-summary-article-number))))
4291 ;; If this is a gathered thread, we have to go some re-gathering.
4292 (when (stringp (car thread))
4293 (let ((subject (car thread))
4295 (setq thread (cdr thread))
4297 (unless (memq (setq thr (gnus-id-to-thread
4299 (mail-header-id (caar thread)))))
4302 (setq thread (cdr thread)))
4303 ;; We now have all (unique) roots.
4304 (if (= (length roots) 1)
4305 ;; All the loose roots are now one solid root.
4306 (setq thread (car roots))
4307 (setq thread (cons subject (gnus-sort-threads roots))))))
4309 ;; We then insert this thread into the summary buffer.
4311 (goto-char (point-min))
4312 (forward-line (1- line)))
4313 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4314 (if gnus-show-threads
4315 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4316 (gnus-summary-prepare-unthreaded thread))
4317 (setq data (nreverse gnus-newsgroup-data))
4318 (setq threads gnus-newsgroup-threads))
4319 ;; We splice the new data into the data structure.
4320 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4321 ;;!!! then we want to insert at the beginning of the buffer.
4322 ;;!!! That happens to be true with Gnus now, but that may
4323 ;;!!! change in the future. Perhaps.
4324 (gnus-data-enter-list
4325 (if line nil current) data (- (point) old-pos))
4326 (setq gnus-newsgroup-threads
4327 (nconc threads gnus-newsgroup-threads))
4328 (gnus-data-compute-positions))))
4330 (defun gnus-number-to-header (number)
4331 "Return the header for article NUMBER."
4332 (let ((headers gnus-newsgroup-headers))
4334 (not (= number (mail-header-number (car headers)))))
4339 (defun gnus-parent-headers (in-headers &optional generation)
4340 "Return the headers of the GENERATIONeth parent of HEADERS."
4342 (setq generation 1))
4344 (headers in-headers)
4347 (not (zerop generation))
4348 (setq references (mail-header-references headers)))
4349 (setq headers (if (and references
4350 (setq parent (gnus-parent-id references)))
4351 (car (gnus-id-to-thread parent))
4354 (and (not (eq headers in-headers))
4357 (defun gnus-id-to-thread (id)
4358 "Return the (sub-)thread where ID appears."
4359 (gnus-gethash id gnus-newsgroup-dependencies))
4361 (defun gnus-id-to-article (id)
4362 "Return the article number of ID."
4363 (let ((thread (gnus-id-to-thread id)))
4366 (mail-header-number (car thread)))))
4368 (defun gnus-id-to-header (id)
4369 "Return the article headers of ID."
4370 (car (gnus-id-to-thread id)))
4372 (defun gnus-article-displayed-root-p (article)
4373 "Say whether ARTICLE is a root(ish) article."
4374 (let ((level (gnus-summary-thread-level article))
4375 (refs (mail-header-references (gnus-summary-article-header article)))
4381 ((null (gnus-parent-id refs)) t)
4383 (null (setq particle (gnus-id-to-article
4384 (gnus-parent-id refs))))
4385 (null (gnus-summary-thread-level particle)))))))
4387 (defun gnus-root-id (id)
4388 "Return the id of the root of the thread where ID appears."
4390 (while (and id (setq prev (car (gnus-id-to-thread id))))
4392 id (gnus-parent-id (mail-header-references prev))))
4395 (defun gnus-articles-in-thread (thread)
4396 "Return the list of articles in THREAD."
4397 (cons (mail-header-number (car thread))
4398 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4400 (defun gnus-remove-thread (id &optional dont-remove)
4401 "Remove the thread that has ID in it."
4402 (let (headers thread last-id)
4403 ;; First go up in this thread until we find the root.
4404 (setq last-id (gnus-root-id id)
4405 headers (message-flatten-list (gnus-id-to-thread last-id)))
4406 ;; We have now found the real root of this thread. It might have
4407 ;; been gathered into some loose thread, so we have to search
4408 ;; through the threads to find the thread we wanted.
4409 (let ((threads gnus-newsgroup-threads)
4412 (setq sub (car threads))
4413 (if (stringp (car sub))
4414 ;; This is a gathered thread, so we look at the roots
4415 ;; below it to find whether this article is in this
4418 (setq sub (cdr sub))
4420 (when (member (caar sub) headers)
4421 (setq thread (car threads)
4424 (setq sub (cdr sub))))
4425 ;; It's an ordinary thread, so we check it.
4426 (when (eq (car sub) (car headers))
4429 (setq threads (cdr threads)))
4430 ;; If this article is in no thread, then it's a root.
4433 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4434 (setq thread (gnus-id-to-thread last-id)))
4437 thread ; We return this thread.
4439 (if (stringp (car thread))
4441 ;; If we use dummy roots, then we have to remove the
4442 ;; dummy root as well.
4443 (when (eq gnus-summary-make-false-root 'dummy)
4444 ;; We go to the dummy root by going to
4445 ;; the first sub-"thread", and then one line up.
4446 (gnus-summary-goto-article
4447 (mail-header-number (caadr thread)))
4450 (gnus-data-compute-positions))
4451 (setq thread (cdr thread))
4453 (gnus-remove-thread-1 (car thread))
4454 (setq thread (cdr thread))))
4455 (gnus-remove-thread-1 thread))))))))
4457 (defun gnus-remove-thread-1 (thread)
4458 "Remove the thread THREAD recursively."
4459 (let ((number (mail-header-number (pop thread)))
4461 (setq thread (reverse thread))
4463 (gnus-remove-thread-1 (pop thread)))
4464 (when (setq d (gnus-data-find number))
4465 (goto-char (gnus-data-pos d))
4466 (gnus-summary-show-thread)
4472 (gnus-delete-line)))))))
4474 (defun gnus-sort-threads-1 (threads func)
4475 (sort (mapcar (lambda (thread)
4478 (gnus-sort-threads-1 (cdr thread) func))))
4481 (defun gnus-sort-threads (threads)
4483 (if (not gnus-thread-sort-functions)
4485 (gnus-message 8 "Sorting threads...")
4486 (let ((max-lisp-eval-depth 5000))
4487 (prog1 (gnus-sort-threads-1
4489 (gnus-make-sort-function gnus-thread-sort-functions))
4490 (gnus-message 8 "Sorting threads...done")))))
4492 (defun gnus-sort-articles (articles)
4494 (when gnus-article-sort-functions
4495 (gnus-message 7 "Sorting articles...")
4497 (setq gnus-newsgroup-headers
4498 (sort articles (gnus-make-sort-function
4499 gnus-article-sort-functions)))
4500 (gnus-message 7 "Sorting articles...done"))))
4502 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4503 (defmacro gnus-thread-header (thread)
4504 "Return header of first article in THREAD.
4505 Note that THREAD must never, ever be anything else than a variable -
4506 using some other form will lead to serious barfage."
4507 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4508 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4509 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4512 (defsubst gnus-article-sort-by-number (h1 h2)
4513 "Sort articles by article number."
4514 (< (mail-header-number h1)
4515 (mail-header-number h2)))
4517 (defun gnus-thread-sort-by-number (h1 h2)
4518 "Sort threads by root article number."
4519 (gnus-article-sort-by-number
4520 (gnus-thread-header h1) (gnus-thread-header h2)))
4522 (defsubst gnus-article-sort-by-random (h1 h2)
4523 "Sort articles by article number."
4526 (defun gnus-thread-sort-by-random (h1 h2)
4527 "Sort threads by root article number."
4528 (gnus-article-sort-by-random
4529 (gnus-thread-header h1) (gnus-thread-header h2)))
4531 (defsubst gnus-article-sort-by-lines (h1 h2)
4532 "Sort articles by article Lines header."
4533 (< (mail-header-lines h1)
4534 (mail-header-lines h2)))
4536 (defun gnus-thread-sort-by-lines (h1 h2)
4537 "Sort threads by root article Lines header."
4538 (gnus-article-sort-by-lines
4539 (gnus-thread-header h1) (gnus-thread-header h2)))
4541 (defsubst gnus-article-sort-by-chars (h1 h2)
4542 "Sort articles by octet length."
4543 (< (mail-header-chars h1)
4544 (mail-header-chars h2)))
4546 (defun gnus-thread-sort-by-chars (h1 h2)
4547 "Sort threads by root article octet length."
4548 (gnus-article-sort-by-chars
4549 (gnus-thread-header h1) (gnus-thread-header h2)))
4551 (defsubst gnus-article-sort-by-author (h1 h2)
4552 "Sort articles by root author."
4554 (let ((addr (car (mime-entity-read-field h1 'From))))
4555 (or (std11-full-name-string addr)
4556 (std11-address-string addr)
4558 (let ((addr (car (mime-entity-read-field h2 'From))))
4559 (or (std11-full-name-string addr)
4560 (std11-address-string addr)
4564 (defun gnus-thread-sort-by-author (h1 h2)
4565 "Sort threads by root author."
4566 (gnus-article-sort-by-author
4567 (gnus-thread-header h1) (gnus-thread-header h2)))
4569 (defsubst gnus-article-sort-by-subject (h1 h2)
4570 "Sort articles by root subject."
4572 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4573 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4575 (defun gnus-thread-sort-by-subject (h1 h2)
4576 "Sort threads by root subject."
4577 (gnus-article-sort-by-subject
4578 (gnus-thread-header h1) (gnus-thread-header h2)))
4580 (defsubst gnus-article-sort-by-date (h1 h2)
4581 "Sort articles by root article date."
4583 (gnus-date-get-time (mail-header-date h1))
4584 (gnus-date-get-time (mail-header-date h2))))
4586 (defun gnus-thread-sort-by-date (h1 h2)
4587 "Sort threads by root article date."
4588 (gnus-article-sort-by-date
4589 (gnus-thread-header h1) (gnus-thread-header h2)))
4591 (defsubst gnus-article-sort-by-score (h1 h2)
4592 "Sort articles by root article score.
4593 Unscored articles will be counted as having a score of zero."
4594 (> (or (cdr (assq (mail-header-number h1)
4595 gnus-newsgroup-scored))
4596 gnus-summary-default-score 0)
4597 (or (cdr (assq (mail-header-number h2)
4598 gnus-newsgroup-scored))
4599 gnus-summary-default-score 0)))
4601 (defun gnus-thread-sort-by-score (h1 h2)
4602 "Sort threads by root article score."
4603 (gnus-article-sort-by-score
4604 (gnus-thread-header h1) (gnus-thread-header h2)))
4606 (defun gnus-thread-sort-by-total-score (h1 h2)
4607 "Sort threads by the sum of all scores in the thread.
4608 Unscored articles will be counted as having a score of zero."
4609 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4611 (defun gnus-thread-total-score (thread)
4612 ;; This function find the total score of THREAD.
4617 (if (stringp (car thread))
4618 (apply gnus-thread-score-function 0
4619 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4620 (gnus-thread-total-score-1 thread)))
4622 (gnus-thread-total-score-1 (list thread)))))
4624 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4625 "Sort threads such that the thread with the most recently arrived article comes first."
4626 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4628 (defun gnus-thread-highest-number (thread)
4629 "Return the highest article number in THREAD."
4630 (apply 'max (mapcar (lambda (header)
4631 (mail-header-number header))
4632 (message-flatten-list thread))))
4634 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4635 "Sort threads such that the thread with the most recently dated article comes first."
4636 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4638 (defun gnus-thread-latest-date (thread)
4639 "Return the highest article date in THREAD."
4640 (let ((previous-time 0))
4646 (time-to-seconds (mail-header-parse-date
4647 (mail-header-date header)))
4648 (error previous-time))))
4650 (message-flatten-list thread)
4652 (< (mail-header-number h1)
4653 (mail-header-number h2))))))))
4655 (defun gnus-thread-total-score-1 (root)
4656 ;; This function find the total score of the thread below ROOT.
4657 (setq root (car root))
4658 (apply gnus-thread-score-function
4660 (mapcar 'gnus-thread-total-score
4661 (cdr (gnus-id-to-thread (mail-header-id root))))
4662 (when (> (mail-header-number root) 0)
4663 (list (or (cdr (assq (mail-header-number root)
4664 gnus-newsgroup-scored))
4665 gnus-summary-default-score 0))))
4666 (list gnus-summary-default-score)
4669 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4670 (defvar gnus-tmp-prev-subject nil)
4671 (defvar gnus-tmp-false-parent nil)
4672 (defvar gnus-tmp-root-expunged nil)
4673 (defvar gnus-tmp-dummy-line nil)
4675 (eval-when-compile (defvar gnus-tmp-header))
4676 (defun gnus-extra-header (type &optional header)
4677 "Return the extra header of TYPE."
4678 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4681 (defvar gnus-tmp-thread-tree-header-string "")
4683 (defcustom gnus-sum-thread-tree-root "> "
4684 "With %B spec, used for the root of a thread.
4685 If nil, use subject instead."
4687 :type '(radio (const :format "%v " nil) (string :size 0))
4688 :group 'gnus-thread)
4689 (defcustom gnus-sum-thread-tree-false-root "> "
4690 "With %B spec, used for a false root of a thread.
4691 If nil, use subject instead."
4693 :type '(radio (const :format "%v " nil) (string :size 0))
4694 :group 'gnus-thread)
4695 (defcustom gnus-sum-thread-tree-single-indent ""
4696 "With %B spec, used for a thread with just one message.
4697 If nil, use subject instead."
4699 :type '(radio (const :format "%v " nil) (string :size 0))
4700 :group 'gnus-thread)
4701 (defcustom gnus-sum-thread-tree-vertical "| "
4702 "With %B spec, used for drawing a vertical line."
4705 :group 'gnus-thread)
4706 (defcustom gnus-sum-thread-tree-indent " "
4707 "With %B spec, used for indenting."
4710 :group 'gnus-thread)
4711 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4712 "With %B spec, used for a leaf with brothers."
4715 :group 'gnus-thread)
4716 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4717 "With %B spec, used for a leaf without brothers."
4720 :group 'gnus-thread)
4722 (defun gnus-summary-prepare-threads (threads)
4723 "Prepare summary buffer from THREADS and indentation LEVEL.
4724 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4725 or a straight list of headers."
4726 (gnus-message 7 "Generating summary...")
4728 (setq gnus-newsgroup-threads threads)
4731 (let ((gnus-tmp-level 0)
4732 (default-score (or gnus-summary-default-score 0))
4733 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4734 (building-line-count gnus-summary-display-while-building)
4735 (building-count (integerp gnus-summary-display-while-building))
4736 thread number subject stack state gnus-tmp-gathered beg-match
4737 new-roots gnus-tmp-new-adopts thread-end simp-subject
4738 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4739 gnus-tmp-replied gnus-tmp-subject-or-nil
4740 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4741 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4742 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4745 (setq gnus-tmp-prev-subject nil
4746 gnus-tmp-thread-tree-header-string "")
4748 (if (vectorp (car threads))
4749 ;; If this is a straight (sic) list of headers, then a
4750 ;; threaded summary display isn't required, so we just create
4751 ;; an unthreaded one.
4752 (gnus-summary-prepare-unthreaded threads)
4754 ;; Do the threaded display.
4756 (if gnus-summary-display-while-building
4757 (switch-to-buffer (buffer-name)))
4758 (while (or threads stack gnus-tmp-new-adopts new-roots)
4760 (if (and (= gnus-tmp-level 0)
4763 (not gnus-tmp-false-parent)
4764 (or gnus-tmp-new-adopts new-roots))
4765 (if gnus-tmp-new-adopts
4766 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4767 thread (list (car gnus-tmp-new-adopts))
4768 gnus-tmp-header (caar thread)
4769 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4771 (setq thread (list (car new-roots))
4772 gnus-tmp-header (caar thread)
4773 new-roots (cdr new-roots))))
4776 ;; If there are some threads, we do them before the
4777 ;; threads on the stack.
4778 (setq thread threads
4779 gnus-tmp-header (caar thread))
4780 ;; There were no current threads, so we pop something off
4782 (setq state (car stack)
4783 gnus-tmp-level (car state)
4784 tree-stack (cadr state)
4785 thread (caddr state)
4787 gnus-tmp-header (caar thread))))
4789 (setq gnus-tmp-false-parent nil)
4790 (setq gnus-tmp-root-expunged nil)
4791 (setq thread-end nil)
4793 (if (stringp gnus-tmp-header)
4794 ;; The header is a dummy root.
4796 ((eq gnus-summary-make-false-root 'adopt)
4797 ;; We let the first article adopt the rest.
4798 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4800 (setq gnus-tmp-gathered
4802 (lambda (h) (mail-header-number (car h)))
4805 (setq thread (cons (list (caar thread)
4808 (setq gnus-tmp-level -1
4809 gnus-tmp-false-parent t))
4810 ((eq gnus-summary-make-false-root 'empty)
4811 ;; We print adopted articles with empty subject fields.
4812 (setq gnus-tmp-gathered
4814 (lambda (h) (mail-header-number (car h)))
4817 (setq gnus-tmp-level -1))
4818 ((eq gnus-summary-make-false-root 'dummy)
4819 ;; We remember that we probably want to output a dummy
4821 (setq gnus-tmp-dummy-line gnus-tmp-header)
4822 (setq gnus-tmp-prev-subject gnus-tmp-header))
4824 ;; We do not make a root for the gathered
4825 ;; sub-threads at all.
4826 (setq gnus-tmp-level -1)))
4828 (setq number (mail-header-number gnus-tmp-header)
4829 subject (mail-header-subject gnus-tmp-header)
4830 simp-subject (gnus-simplify-subject-fully subject))
4833 ;; If the thread has changed subject, we might want to make
4834 ;; this subthread into a root.
4835 ((and (null gnus-thread-ignore-subject)
4836 (not (zerop gnus-tmp-level))
4837 gnus-tmp-prev-subject
4838 (not (string= gnus-tmp-prev-subject simp-subject)))
4839 (setq new-roots (nconc new-roots (list (car thread)))
4841 gnus-tmp-header nil))
4842 ;; If the article lies outside the current limit,
4843 ;; then we do not display it.
4844 ((not (memq number gnus-newsgroup-limit))
4845 (setq gnus-tmp-gathered
4847 (lambda (h) (mail-header-number (car h)))
4850 (setq gnus-tmp-new-adopts (if (cdar thread)
4851 (append gnus-tmp-new-adopts
4853 gnus-tmp-new-adopts)
4855 gnus-tmp-header nil)
4856 (when (zerop gnus-tmp-level)
4857 (setq gnus-tmp-root-expunged t)))
4858 ;; Perhaps this article is to be marked as read?
4859 ((and gnus-summary-mark-below
4860 (< (or (cdr (assq number gnus-newsgroup-scored))
4862 gnus-summary-mark-below)
4863 ;; Don't touch sparse articles.
4864 (not (gnus-summary-article-sparse-p number))
4865 (not (gnus-summary-article-ancient-p number)))
4866 (setq gnus-newsgroup-unreads
4867 (delq number gnus-newsgroup-unreads))
4868 (if gnus-newsgroup-auto-expire
4869 (setq gnus-newsgroup-expirable
4870 (gnus-add-to-sorted-list
4871 gnus-newsgroup-expirable number))
4872 (push (cons number gnus-low-score-mark)
4873 gnus-newsgroup-reads))))
4875 (when gnus-tmp-header
4876 ;; We may have an old dummy line to output before this
4878 (when (and gnus-tmp-dummy-line
4881 (mail-header-subject gnus-tmp-header)))
4882 (gnus-summary-insert-dummy-line
4883 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4884 (setq gnus-tmp-dummy-line nil))
4886 ;; Compute the mark.
4887 (setq gnus-tmp-unread (gnus-article-mark number))
4889 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4890 gnus-tmp-header gnus-tmp-level)
4891 gnus-newsgroup-data)
4893 ;; Actually insert the line.
4895 gnus-tmp-subject-or-nil
4897 ((and gnus-thread-ignore-subject
4898 gnus-tmp-prev-subject
4899 (not (string= gnus-tmp-prev-subject simp-subject)))
4901 ((zerop gnus-tmp-level)
4902 (if (and (eq gnus-summary-make-false-root 'empty)
4903 (memq number gnus-tmp-gathered)
4904 gnus-tmp-prev-subject
4905 (string= gnus-tmp-prev-subject simp-subject))
4906 gnus-summary-same-subject
4908 (t gnus-summary-same-subject)))
4909 (if (and (eq gnus-summary-make-false-root 'adopt)
4910 (= gnus-tmp-level 1)
4911 (memq number gnus-tmp-gathered))
4912 (setq gnus-tmp-opening-bracket ?\<
4913 gnus-tmp-closing-bracket ?\>)
4914 (setq gnus-tmp-opening-bracket ?\[
4915 gnus-tmp-closing-bracket ?\]))
4917 gnus-tmp-indentation
4918 (aref gnus-thread-indent-array gnus-tmp-level)
4919 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4920 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4921 gnus-summary-default-score 0)
4923 (if (or (null gnus-summary-default-score)
4924 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4925 gnus-summary-zcore-fuzz))
4927 (if (< gnus-tmp-score gnus-summary-default-score)
4928 gnus-score-below-mark gnus-score-over-mark))
4930 (cond ((memq number gnus-newsgroup-processable)
4932 ((memq number gnus-newsgroup-cached)
4934 ((memq number gnus-newsgroup-replied)
4936 ((memq number gnus-newsgroup-forwarded)
4937 gnus-forwarded-mark)
4938 ((memq number gnus-newsgroup-saved)
4940 ((memq number gnus-newsgroup-recent)
4942 ((memq number gnus-newsgroup-unseen)
4946 (cond ((memq number gnus-newsgroup-undownloaded)
4947 gnus-undownloaded-mark)
4948 (gnus-newsgroup-agentized
4949 gnus-downloaded-mark)
4952 gnus-tmp-from (mail-header-from gnus-tmp-header)
4955 ((string-match "<[^>]+> *$" gnus-tmp-from)
4956 (setq beg-match (match-beginning 0))
4957 (or (and (string-match "^\".+\"" gnus-tmp-from)
4958 (substring gnus-tmp-from 1 (1- (match-end 0))))
4959 (substring gnus-tmp-from 0 beg-match)))
4960 ((string-match "(.+)" gnus-tmp-from)
4961 (substring gnus-tmp-from
4962 (1+ (match-beginning 0)) (1- (match-end 0))))
4966 gnus-tmp-thread-tree-header-string
4968 ((not gnus-show-threads) "")
4969 ((zerop gnus-tmp-level)
4970 (cond ((cdar thread)
4971 (or gnus-sum-thread-tree-root subject))
4972 (gnus-tmp-new-adopts
4973 (or gnus-sum-thread-tree-false-root subject))
4975 (or gnus-sum-thread-tree-single-indent subject))))
4977 (concat (apply 'concat
4978 (mapcar (lambda (item)
4980 gnus-sum-thread-tree-vertical
4981 gnus-sum-thread-tree-indent))
4982 (cdr (reverse tree-stack))))
4984 gnus-sum-thread-tree-leaf-with-other
4985 gnus-sum-thread-tree-single-leaf)))))
4986 (when (string= gnus-tmp-name "")
4987 (setq gnus-tmp-name gnus-tmp-from))
4988 (unless (numberp gnus-tmp-lines)
4989 (setq gnus-tmp-lines -1))
4990 (if (= gnus-tmp-lines -1)
4991 (setq gnus-tmp-lines "?")
4992 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4993 (gnus-put-text-property
4995 (progn (eval gnus-summary-line-format-spec) (point))
4996 'gnus-number number)
4999 (gnus-run-hooks 'gnus-summary-update-hook)
5002 (setq gnus-tmp-prev-subject simp-subject)))
5004 (when (nth 1 thread)
5005 (push (list (max 0 gnus-tmp-level)
5006 (copy-sequence tree-stack)
5009 (push (if (nth 1 thread) 1 0) tree-stack)
5010 (incf gnus-tmp-level)
5011 (setq threads (if thread-end nil (cdar thread)))
5012 (if gnus-summary-display-while-building
5015 ;; use a set frequency
5016 (setq building-line-count (1- building-line-count))
5017 (when (= building-line-count 0)
5019 (setq building-line-count
5020 gnus-summary-display-while-building)))
5024 (setq gnus-tmp-level 0)))))
5025 (gnus-message 7 "Generating summary...done"))
5027 (defun gnus-summary-prepare-unthreaded (headers)
5028 "Generate an unthreaded summary buffer based on HEADERS."
5029 (let (header number mark)
5034 ;; We may have to root out some bad articles...
5035 (when (memq (setq number (mail-header-number
5036 (setq header (pop headers))))
5037 gnus-newsgroup-limit)
5038 ;; Mark article as read when it has a low score.
5039 (when (and gnus-summary-mark-below
5040 (< (or (cdr (assq number gnus-newsgroup-scored))
5041 gnus-summary-default-score 0)
5042 gnus-summary-mark-below)
5043 (not (gnus-summary-article-ancient-p number)))
5044 (setq gnus-newsgroup-unreads
5045 (delq number gnus-newsgroup-unreads))
5046 (if gnus-newsgroup-auto-expire
5047 (push number gnus-newsgroup-expirable)
5048 (push (cons number gnus-low-score-mark)
5049 gnus-newsgroup-reads)))
5051 (setq mark (gnus-article-mark number))
5052 (push (gnus-data-make number mark (1+ (point)) header 0)
5053 gnus-newsgroup-data)
5054 (gnus-summary-insert-line
5056 (memq number gnus-newsgroup-undownloaded)
5057 mark (memq number gnus-newsgroup-replied)
5058 (memq number gnus-newsgroup-expirable)
5059 (mail-header-subject header) nil
5060 (cdr (assq number gnus-newsgroup-scored))
5061 (memq number gnus-newsgroup-processable))))))
5063 (defun gnus-summary-remove-list-identifiers ()
5064 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5065 (let ((regexp (if (consp gnus-list-identifiers)
5066 (mapconcat 'identity gnus-list-identifiers " *\\|")
5067 gnus-list-identifiers))
5070 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5071 (dolist (header gnus-newsgroup-headers)
5072 (setq subject (mail-header-subject header)
5074 (while (string-match regexp subject)
5076 (concat (substring subject 0 (match-beginning 1))
5077 (substring subject (match-end 0)))
5080 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5082 (concat (substring subject 0 (match-beginning 1))
5083 (substring subject (match-end 1)))))
5084 (mail-header-set-subject header subject))))))
5086 (defun gnus-fetch-headers (articles)
5087 "Fetch headers of ARTICLES."
5088 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5089 (gnus-message 5 "Fetching headers for %s..." name)
5092 (setq gnus-headers-retrieved-by
5093 (gnus-retrieve-headers
5094 articles gnus-newsgroup-name
5095 ;; We might want to fetch old headers, but
5096 ;; not if there is only 1 article.
5098 (not (eq gnus-fetch-old-headers 'some))
5099 (not (numberp gnus-fetch-old-headers)))
5100 (> (length articles) 1))
5101 gnus-fetch-old-headers))))
5102 (gnus-get-newsgroup-headers-xover
5103 articles nil nil gnus-newsgroup-name t)
5104 (gnus-get-newsgroup-headers))
5105 (gnus-message 5 "Fetching headers for %s...done" name))))
5107 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5108 "Select newsgroup GROUP.
5109 If READ-ALL is non-nil, all articles in the group are selected.
5110 If SELECT-ARTICLES, only select those articles from GROUP."
5111 (let* ((entry (gnus-group-entry group))
5112 ;;!!! Dirty hack; should be removed.
5113 (gnus-summary-ignore-duplicates
5114 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5116 gnus-summary-ignore-duplicates))
5117 (info (nth 2 entry))
5118 articles fetched-articles cached)
5120 (unless (gnus-check-server
5121 (set (make-local-variable 'gnus-current-select-method)
5122 (gnus-find-method-for-group group)))
5123 (error "Couldn't open server"))
5125 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5126 (gnus-activate-group group) ; Or we can activate it...
5127 (progn ; Or we bug out.
5128 (when (equal major-mode 'gnus-summary-mode)
5129 (gnus-kill-buffer (current-buffer)))
5130 (error "Couldn't activate group %s: %s"
5131 group (gnus-status-message group))))
5133 (unless (gnus-request-group group t)
5134 (when (equal major-mode 'gnus-summary-mode)
5135 (gnus-kill-buffer (current-buffer)))
5136 (error "Couldn't request group %s: %s"
5137 group (gnus-status-message group)))
5140 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5142 (setq gnus-summary-use-undownloaded-faces
5143 (gnus-agent-find-parameter
5145 'agent-enable-undownloaded-faces)))
5147 (setq gnus-newsgroup-name group
5148 gnus-newsgroup-unselected nil
5149 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5151 (let ((display (gnus-group-find-parameter group 'display)))
5152 (setq gnus-newsgroup-display
5154 ((not (zerop (or (car-safe read-all) 0)))
5155 ;; The user entered the group with C-u SPC/RET, let's show
5161 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5163 ;; The following is probably the "correct" solution, but
5164 ;; it makes Gnus fetch all headers and then limit the
5165 ;; articles (which is slow), so instead we hack the
5166 ;; select-articles parameter instead. -- Simon Josefsson
5169 ;; (gnus-byte-compile
5170 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5172 (setq select-articles
5173 (gnus-uncompress-range
5174 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5178 (cdr (gnus-active group)))))
5183 (gnus-summary-setup-default-charset)
5185 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5186 (when (gnus-virtual-group-p group)
5187 (setq cached gnus-newsgroup-cached))
5189 (setq gnus-newsgroup-unreads
5190 (gnus-sorted-ndifference
5191 (gnus-sorted-ndifference gnus-newsgroup-unreads
5192 gnus-newsgroup-marked)
5193 gnus-newsgroup-dormant))
5195 (setq gnus-newsgroup-processable nil)
5197 (gnus-update-read-articles group gnus-newsgroup-unreads)
5199 ;; Adjust and set lists of article marks.
5201 (gnus-adjust-marked-articles info))
5202 (if (setq articles select-articles)
5203 (setq gnus-newsgroup-unselected
5204 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5205 (setq articles (gnus-articles-to-read group read-all)))
5209 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5211 ((eq articles 0) nil)
5213 ;; Init the dependencies hash table.
5214 (setq gnus-newsgroup-dependencies
5215 (gnus-make-hashtable (length articles)))
5216 (gnus-set-global-variables)
5217 ;; Retrieve the headers and read them in.
5219 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5221 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5223 (setq gnus-newsgroup-cached cached))
5225 ;; Suppress duplicates?
5226 (when gnus-suppress-duplicates
5227 (gnus-dup-suppress-articles))
5229 ;; Set the initial limit.
5230 (setq gnus-newsgroup-limit (copy-sequence articles))
5231 ;; Remove canceled articles from the list of unread articles.
5232 (setq fetched-articles
5233 (mapcar (lambda (headers) (mail-header-number headers))
5234 gnus-newsgroup-headers))
5235 (setq gnus-newsgroup-articles fetched-articles)
5236 (setq gnus-newsgroup-unreads
5237 (gnus-sorted-nintersection
5238 gnus-newsgroup-unreads fetched-articles))
5239 (gnus-compute-unseen-list)
5241 ;; Removed marked articles that do not exist.
5242 (gnus-update-missing-marks
5243 (gnus-sorted-difference articles fetched-articles))
5244 ;; We might want to build some more threads first.
5245 (when (and gnus-fetch-old-headers
5246 (eq gnus-headers-retrieved-by 'nov))
5247 (if (eq gnus-fetch-old-headers 'invisible)
5248 (gnus-build-all-threads)
5249 (gnus-build-old-threads)))
5250 ;; Let the Gnus agent mark articles as read.
5252 (gnus-agent-get-undownloaded-list))
5253 ;; Remove list identifiers from subject
5254 (when gnus-list-identifiers
5255 (gnus-summary-remove-list-identifiers))
5256 ;; Check whether auto-expire is to be done in this group.
5257 (setq gnus-newsgroup-auto-expire
5258 (gnus-group-auto-expirable-p group))
5259 ;; Set up the article buffer now, if necessary.
5260 (unless gnus-single-article-buffer
5261 (gnus-article-setup-buffer))
5262 ;; First and last article in this newsgroup.
5263 (when gnus-newsgroup-headers
5264 (setq gnus-newsgroup-begin
5265 (mail-header-number (car gnus-newsgroup-headers))
5268 (gnus-last-element gnus-newsgroup-headers))))
5269 ;; GROUP is successfully selected.
5270 (or gnus-newsgroup-headers t)))))
5272 (defun gnus-compute-unseen-list ()
5273 ;; The `seen' marks are treated specially.
5274 (if (not gnus-newsgroup-seen)
5275 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5276 (setq gnus-newsgroup-unseen
5277 (gnus-inverse-list-range-intersection
5278 gnus-newsgroup-articles gnus-newsgroup-seen))))
5280 (defun gnus-summary-display-make-predicate (display)
5281 (require 'gnus-agent)
5282 (when (= (length display) 1)
5283 (setq display (car display)))
5284 (unless gnus-summary-display-cache
5285 (dolist (elem (append '((unread . unread)
5288 gnus-article-mark-lists))
5289 (push (cons (cdr elem)
5291 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5292 gnus-summary-display-cache)))
5293 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5294 (gnus-category-predicate-cache gnus-summary-display-cache))
5295 (gnus-get-predicate display)))
5297 ;; Uses the dynamically bound `number' variable.
5300 (defun gnus-article-marked-p (type &optional article)
5301 (let ((article (or article number)))
5304 (memq article gnus-newsgroup-marked))
5306 (memq article gnus-newsgroup-spam-marked))
5308 (memq article gnus-newsgroup-unsendable))
5309 ((eq type 'undownload)
5310 (memq article gnus-newsgroup-undownloaded))
5311 ((eq type 'download)
5312 (memq article gnus-newsgroup-downloadable))
5314 (memq article gnus-newsgroup-unreads))
5316 (memq article gnus-newsgroup-reads))
5318 (memq article gnus-newsgroup-dormant) )
5320 (memq article gnus-newsgroup-expirable))
5322 (memq article gnus-newsgroup-replied))
5324 (memq article gnus-newsgroup-killed))
5325 ((eq type 'bookmark)
5326 (assq article gnus-newsgroup-bookmarks))
5328 (assq article gnus-newsgroup-scored))
5330 (memq article gnus-newsgroup-saved))
5332 (memq article gnus-newsgroup-cached))
5334 (memq article gnus-newsgroup-forwarded))
5336 (not (memq article gnus-newsgroup-unseen)))
5338 (memq article gnus-newsgroup-recent))
5341 (defun gnus-articles-to-read (group &optional read-all)
5342 "Find out what articles the user wants to read."
5344 ;; Select all articles if `read-all' is non-nil, or if there
5345 ;; are no unread articles.
5347 (and (zerop (length gnus-newsgroup-marked))
5348 (zerop (length gnus-newsgroup-unreads)))
5349 ;; Fetch all if the predicate is non-nil.
5350 gnus-newsgroup-display)
5351 ;; We want to select the headers for all the articles in
5352 ;; the group, so we select either all the active
5353 ;; articles in the group, or (if that's nil), the
5354 ;; articles in the cache.
5356 (gnus-uncompress-range (gnus-active group))
5357 (gnus-cache-articles-in-group group))
5358 ;; Select only the "normal" subset of articles.
5360 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5361 gnus-newsgroup-unreads)))
5362 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5363 (scored (length scored-list))
5364 (number (length articles))
5365 (marked (+ (length gnus-newsgroup-marked)
5366 (length gnus-newsgroup-dormant)))
5371 ((numberp gnus-newsgroup-display)
5372 gnus-newsgroup-display)
5376 ((and (or (<= scored marked) (= scored number))
5377 (numberp gnus-large-newsgroup)
5378 (> number gnus-large-newsgroup))
5379 (let* ((cursor-in-echo-area nil)
5380 (initial (gnus-parameter-large-newsgroup-initial
5381 gnus-newsgroup-name))
5385 "How many articles from %s (%s %d): "
5387 (gnus-group-decoded-name gnus-newsgroup-name)
5389 (if initial "max" "default")
5392 (cons (number-to-string initial)
5394 (if (string-match "^[ \t]*$" input) number input)))
5395 ((and (> scored marked) (< scored number)
5396 (> (- scored number) 20))
5399 (format "%s %s (%d scored, %d total): "
5400 "How many articles from"
5401 (gnus-group-decoded-name group)
5403 (if (string-match "^[ \t]*$" input)
5407 (message "Quit getting the articles to read")
5409 (setq select (if (stringp select) (string-to-number select) select))
5410 (if (or (null select) (zerop select))
5412 (if (and (not (zerop scored)) (<= (abs select) scored))
5414 (setq articles (sort scored-list '<))
5415 (setq number (length articles)))
5416 (setq articles (copy-sequence articles)))
5418 (when (< (abs select) number)
5420 ;; Select the N oldest articles.
5421 (setcdr (nthcdr (1- (abs select)) articles) nil)
5422 ;; Select the N most recent articles.
5423 (setq articles (nthcdr (- number select) articles))))
5424 (setq gnus-newsgroup-unselected
5425 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5426 (when gnus-alter-articles-to-read-function
5429 (funcall gnus-alter-articles-to-read-function
5430 gnus-newsgroup-name articles)
5434 (defun gnus-killed-articles (killed articles)
5437 (when (inline (gnus-member-of-range (car articles) killed))
5438 (push (car articles) out))
5439 (setq articles (cdr articles)))
5442 (defun gnus-uncompress-marks (marks)
5443 "Uncompress the mark ranges in MARKS."
5444 (let ((uncompressed '(score bookmark))
5447 (if (memq (caar marks) uncompressed)
5448 (push (car marks) out)
5449 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5450 (setq marks (cdr marks)))
5453 (defun gnus-article-mark-to-type (mark)
5454 "Return the type of MARK."
5455 (or (cadr (assq mark gnus-article-special-mark-lists))
5458 (defun gnus-article-unpropagatable-p (mark)
5459 "Return whether MARK should be propagated to back end."
5460 (memq mark gnus-article-unpropagated-mark-lists))
5462 (defun gnus-adjust-marked-articles (info)
5463 "Set all article lists and remove all marks that are no longer valid."
5464 (let* ((marked-lists (gnus-info-marks info))
5465 (active (gnus-active (gnus-info-group info)))
5468 (types gnus-article-mark-lists)
5469 marks var articles article mark mark-type
5472 (dolist (marks marked-lists)
5473 (setq mark (car marks)
5474 mark-type (gnus-article-mark-to-type mark)
5475 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5477 ;; We set the variable according to the type of the marks list,
5478 ;; and then adjust the marks to a subset of the active articles.
5480 ;; Adjust "simple" lists - compressed yet unsorted
5481 ((eq mark-type 'list)
5482 ;; Simultaneously uncompress and clip to active range
5483 ;; See gnus-uncompress-range for a description of possible marks
5485 (if (not (cadr marks))
5487 (setq articles (if (numberp (cddr marks))
5493 (while (setq article (pop articles))
5494 (cond ((consp article)
5495 (setq bgn (max (car article) min)
5496 end (min (cdr article) max))
5498 (setq l (setcdr l (cons bgn nil))
5500 ((and (<= min article)
5502 (setq l (setcdr l (cons article nil))))))
5503 (set var (cdr lh)))))
5505 ((eq mark-type 'tuple)
5506 (set var (setq articles (cdr marks)))
5507 (when (not (listp (cdr (symbol-value var))))
5508 (set var (list (symbol-value var))))
5509 (when (not (listp (cdr articles)))
5510 (setq articles (list articles)))
5512 (when (or (not (consp (setq article (pop articles))))
5513 (< (car article) min)
5514 (> (car article) max))
5515 (set var (delq article (symbol-value var))))))
5516 ;; Adjust ranges (sloppily).
5517 ((eq mark-type 'range)
5520 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5521 ;; It should be (seen (NUM1 . NUM2)).
5522 (when (numberp (cddr marks))
5523 (setcdr marks (list (cdr marks))))
5524 (setq articles (cdr marks))
5525 (while (and articles
5526 (or (and (consp (car articles))
5527 (> min (cdar articles)))
5528 (and (numberp (car articles))
5529 (> min (car articles)))))
5531 (set var articles))))))))
5533 (defun gnus-update-missing-marks (missing)
5534 "Go through the list of MISSING articles and remove them from the mark lists."
5537 ;; Go through all types.
5538 (dolist (elem gnus-article-mark-lists)
5539 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5540 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5541 (when (symbol-value var)
5542 ;; This list has articles. So we delete all missing
5543 ;; articles from it.
5546 (set var (delq (pop m) (symbol-value var))))))))))
5548 (defun gnus-update-marks ()
5549 "Enter the various lists of marked articles into the newsgroup info list."
5550 (let ((types gnus-article-mark-lists)
5551 (info (gnus-get-info gnus-newsgroup-name))
5552 type list newmarked symbol delta-marks)
5554 ;; Add all marks lists to the list of marks lists.
5555 (while (setq type (pop types))
5556 (setq list (symbol-value
5558 (intern (format "gnus-newsgroup-%s" (car type))))))
5561 ;; Get rid of the entries of the articles that have the
5563 (when (and (eq (cdr type) 'score)
5567 (prev (cons nil list))
5570 (if (or (not (consp (car arts)))
5571 (= (cdar arts) gnus-summary-default-score))
5572 (setcdr prev (cdr arts))
5574 (setq arts (cdr arts)))
5575 (setq list (cdr all)))))
5577 (when (eq (cdr type) 'seen)
5578 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5580 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5581 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5583 (when (and (gnus-check-backend-function
5584 'request-set-mark gnus-newsgroup-name)
5585 (not (gnus-article-unpropagatable-p (cdr type))))
5586 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5587 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5588 (add (gnus-remove-from-range
5589 (gnus-copy-sequence list) old)))
5591 (push (list add 'add (list (cdr type))) delta-marks))
5593 (push (list del 'del (list (cdr type))) delta-marks))))
5596 (push (cons (cdr type) list) newmarked)))
5599 (unless (gnus-check-group gnus-newsgroup-name)
5600 (error "Can't open server for %s" gnus-newsgroup-name))
5601 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5603 ;; Enter these new marks into the info of the group.
5605 (setcar (nthcdr 3 info) newmarked)
5606 ;; Add the marks lists to the end of the info.
5608 (setcdr (nthcdr 2 info) (list newmarked))))
5610 ;; Cut off the end of the info if there's nothing else there.
5614 (when (nthcdr (decf i) info)
5615 (setcdr (nthcdr i info) nil)))))))
5617 (defun gnus-set-mode-line (where)
5618 "Set the mode line of the article or summary buffers.
5619 If WHERE is `summary', the summary mode line format will be used."
5620 ;; Is this mode line one we keep updated?
5621 (when (and (memq where gnus-updated-mode-lines)
5623 (intern (format "gnus-%s-mode-line-format-spec" where))))
5626 ;; We evaluate this in the summary buffer since these
5627 ;; variables are buffer-local to that buffer.
5628 (set-buffer gnus-summary-buffer)
5629 ;; We bind all these variables that are used in the `eval' form
5631 (let* ((mformat (symbol-value
5633 (format "gnus-%s-mode-line-format-spec" where))))
5634 (gnus-tmp-group-name (gnus-group-decoded-name
5635 gnus-newsgroup-name))
5636 (gnus-tmp-article-number (or gnus-current-article 0))
5637 (gnus-tmp-unread gnus-newsgroup-unreads)
5638 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5639 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5640 (gnus-tmp-unread-and-unselected
5641 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5642 (zerop gnus-tmp-unselected))
5644 ((zerop gnus-tmp-unselected)
5645 (format "{%d more}" gnus-tmp-unread-and-unticked))
5646 (t (format "{%d(+%d) more}"
5647 gnus-tmp-unread-and-unticked
5648 gnus-tmp-unselected))))
5650 (if (and gnus-current-headers
5651 (vectorp gnus-current-headers))
5652 (gnus-mode-string-quote
5653 (mail-header-subject gnus-current-headers))
5655 bufname-length max-len
5656 gnus-tmp-header);; passed as argument to any user-format-funcs
5657 (setq mode-string (eval mformat))
5658 (setq bufname-length (if (string-match "%b" mode-string)
5661 (if (eq where 'summary)
5663 (get-buffer gnus-article-buffer))))
5666 (setq max-len (max 4 (if gnus-mode-non-string-length
5668 gnus-mode-non-string-length
5670 (length mode-string))))
5671 ;; We might have to chop a bit of the string off...
5672 (when (> (length mode-string) max-len)
5674 (concat (gnus-truncate-string mode-string (- max-len 3))
5676 ;; Pad the mode string a bit.
5677 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5678 ;; Update the mode line.
5679 (setq mode-line-buffer-identification
5680 (gnus-mode-line-buffer-identification (list mode-string)))
5681 (set-buffer-modified-p t))))
5683 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5684 "Go through the HEADERS list and add all Xrefs to a hash table.
5685 The resulting hash table is returned, or nil if no Xrefs were found."
5686 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5687 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5688 (xref-hashtb (gnus-make-hashtable))
5689 start group entry number xrefs header)
5691 (setq header (pop headers))
5692 (when (and (setq xrefs (mail-header-xref header))
5693 (not (memq (setq number (mail-header-number header))
5696 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5697 (setq start (match-end 0))
5698 (setq group (if prefix
5699 (concat prefix (substring xrefs (match-beginning 1)
5701 (substring xrefs (match-beginning 1) (match-end 1))))
5703 (string-to-int (substring xrefs (match-beginning 2)
5705 (if (setq entry (gnus-gethash group xref-hashtb))
5706 (setcdr entry (cons number (cdr entry)))
5707 (gnus-sethash group (cons number nil) xref-hashtb)))))
5708 (and start xref-hashtb)))
5710 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5711 "Look through all the headers and mark the Xrefs as read."
5712 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5713 name info xref-hashtb idlist method nth4)
5715 (set-buffer gnus-group-buffer)
5716 (when (setq xref-hashtb
5717 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5720 (unless (string= from-newsgroup (setq name (symbol-name group)))
5721 (setq idlist (symbol-value group))
5722 ;; Dead groups are not updated.
5724 (setq info (gnus-get-info name))
5725 (when (stringp (setq nth4 (gnus-info-method info)))
5726 (setq nth4 (gnus-server-to-method nth4))))
5727 ;; Only do the xrefs if the group has the same
5728 ;; select method as the group we have just read.
5729 (or (gnus-methods-equal-p
5730 nth4 (gnus-find-method-for-group from-newsgroup))
5732 (equal nth4 (setq method (gnus-find-method-for-group
5734 (and (equal (car nth4) (car method))
5735 (equal (nth 1 nth4) (nth 1 method))))
5736 gnus-use-cross-reference
5737 (or (not (eq gnus-use-cross-reference t))
5739 ;; Only do cross-references on subscribed
5740 ;; groups, if that is what is wanted.
5741 (<= (gnus-info-level info) gnus-level-subscribed))
5742 (gnus-group-make-articles-read name idlist))))
5745 (defun gnus-compute-read-articles (group articles)
5746 (let* ((entry (gnus-group-entry group))
5747 (info (nth 2 entry))
5748 (active (gnus-active group))
5751 ;; First peel off all invalid article numbers.
5753 (let ((ids articles)
5755 (while (setq id (pop ids))
5756 (when (and first (> id (cdr active)))
5757 ;; We'll end up in this situation in one particular
5758 ;; obscure situation. If you re-scan a group and get
5759 ;; a new article that is cross-posted to a different
5760 ;; group that has not been re-scanned, you might get
5761 ;; crossposted article that has a higher number than
5762 ;; Gnus believes possible. So we re-activate this
5763 ;; group as well. This might mean doing the
5764 ;; crossposting thingy will *increase* the number
5765 ;; of articles in some groups. Tsk, tsk.
5766 (setq active (or (gnus-activate-group group) active)))
5767 (when (or (> id (cdr active))
5768 (< id (car active)))
5769 (setq articles (delq id articles))))))
5770 ;; If the read list is nil, we init it.
5772 (null (gnus-info-read info))
5774 (setq ninfo (cons 1 (1- (car active))))
5775 (setq ninfo (gnus-info-read info)))
5776 ;; Then we add the read articles to the range.
5778 ninfo (setq articles (sort articles '<))))))
5780 (defun gnus-group-make-articles-read (group articles)
5781 "Update the info of GROUP to say that ARTICLES are read."
5783 (entry (gnus-group-entry group))
5784 (info (nth 2 entry))
5785 (active (gnus-active group))
5788 (setq range (gnus-compute-read-articles group articles))
5789 (with-current-buffer gnus-group-buffer
5792 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5793 (gnus-info-set-read ',info ',(gnus-info-read info))
5794 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5795 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5796 (gnus-group-update-group ,group t))))
5797 ;; Add the read articles to the range.
5798 (gnus-info-set-read info range)
5799 (gnus-request-set-mark group (list (list range 'add '(read))))
5800 ;; Then we have to re-compute how many unread
5801 ;; articles there are in this group.
5805 (setq num (- (1+ (cdr active)) (car active))))
5806 ((not (listp (cdr range)))
5807 (setq num (- (cdr active) (- (1+ (cdr range))
5811 (if (numberp (car range))
5813 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5814 (setq range (cdr range)))
5815 (setq num (- (cdr active) num))))
5816 ;; Update the number of unread articles.
5818 ;; Update the group buffer.
5819 (unless (gnus-ephemeral-group-p group)
5820 (gnus-group-update-group group t))))))
5822 (defvar gnus-newsgroup-none-id 0)
5824 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5825 (let ((cur nntp-server-buffer)
5828 (with-current-buffer gnus-summary-buffer
5829 gnus-newsgroup-dependencies)))
5830 headers id end ref number
5831 (mail-parse-charset gnus-newsgroup-charset)
5832 (mail-parse-ignored-charsets
5833 (save-excursion (condition-case nil
5834 (set-buffer gnus-summary-buffer)
5836 gnus-newsgroup-ignored-charsets)))
5838 (set-buffer nntp-server-buffer)
5839 ;; Translate all TAB characters into SPACE characters.
5840 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5841 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5842 (ietf-drums-unfold-fws)
5843 (gnus-run-hooks 'gnus-parse-headers-hook)
5844 (let ((case-fold-search t)
5845 in-reply-to header p lines chars ctype)
5846 (goto-char (point-min))
5847 ;; Search to the beginning of the next header. Error messages
5848 ;; do not begin with 2 or 3.
5849 (while (re-search-forward "^[23][0-9]+ " nil t)
5852 ;; This implementation of this function, with nine
5853 ;; search-forwards instead of the one re-search-forward and
5854 ;; a case (which basically was the old function) is actually
5855 ;; about twice as fast, even though it looks messier. You
5856 ;; can't have everything, I guess. Speed and elegance
5857 ;; doesn't always go hand in hand.
5860 (make-full-mail-header
5863 (setq number (read cur))
5866 (narrow-to-region (point)
5867 (or (and (search-forward "\n.\n" nil t)
5873 (if (search-forward "\nsubject:" nil t)
5874 (nnheader-header-value)
5879 (if (search-forward "\nfrom:" nil t)
5880 (nnheader-header-value)
5885 (if (search-forward "\ndate:" nil t)
5886 (nnheader-header-value) ""))
5890 (setq id (if (re-search-forward
5891 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5892 ;; We do it this way to make sure the Message-ID
5893 ;; is (somewhat) syntactically valid.
5894 (buffer-substring (match-beginning 1)
5896 ;; If there was no message-id, we just fake one
5897 ;; to make subsequent routines simpler.
5898 (nnheader-generate-fake-message-id number))))
5902 (if (search-forward "\nreferences:" nil t)
5906 (nnheader-header-value)
5911 (search-backward ">" end t)
5914 (search-backward "<" end t)
5916 ;; Get the references from the in-reply-to header if there
5917 ;; were no references and the in-reply-to header looks
5919 (if (and (search-forward "\nin-reply-to:" nil t)
5920 (setq in-reply-to (nnheader-header-value))
5921 (string-match "<[^>]+>" in-reply-to))
5923 (setq ref (substring in-reply-to (match-beginning 0)
5925 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5926 (setq ref2 (substring in-reply-to (match-beginning 0)
5928 (when (> (length ref2) (length ref))
5935 (if (search-forward "\nchars: " nil t)
5936 (if (numberp (setq chars (ignore-errors (read cur))))
5942 (if (search-forward "\nlines: " nil t)
5943 (if (numberp (setq lines (ignore-errors (read cur))))
5949 (and (search-forward "\nxref:" nil t)
5950 (nnheader-header-value)))
5952 (when gnus-extra-headers
5953 (let ((extra gnus-extra-headers)
5957 (when (search-forward
5958 (concat "\n" (symbol-name (car extra)) ":") nil t)
5959 (push (cons (car extra) (nnheader-header-value)) out))
5963 (if (and (search-forward "\ncontent-type: " nil t)
5964 (setq ctype (nnheader-header-value)))
5965 (mime-entity-set-content-type-internal
5966 header (mime-parse-Content-Type ctype)))
5967 (when (equal id ref)
5970 (when gnus-alter-header-function
5971 (funcall gnus-alter-header-function header)
5972 (setq id (mail-header-id header)
5973 ref (gnus-parent-id (mail-header-references header))))
5976 (gnus-dependencies-add-header
5977 header dependencies force-new))
5978 (push header headers))
5979 (goto-char (point-max))
5981 (nreverse headers)))))
5983 ;; Goes through the xover lines and returns a list of vectors
5984 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5985 force-new dependencies
5986 group also-fetch-heads)
5987 "Parse the news overview data in the server buffer.
5988 Return a list of headers that match SEQUENCE (see
5989 `nntp-retrieve-headers')."
5990 ;; Get the Xref when the users reads the articles since most/some
5991 ;; NNTP servers do not include Xrefs when using XOVER.
5992 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5993 (let ((mail-parse-charset gnus-newsgroup-charset)
5994 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5995 (cur nntp-server-buffer)
5996 (dependencies (or dependencies gnus-newsgroup-dependencies))
5998 ((eq gnus-read-all-available-headers t)
6000 ((stringp gnus-read-all-available-headers)
6001 (string-match gnus-read-all-available-headers group))
6004 number headers header)
6006 (set-buffer nntp-server-buffer)
6007 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6008 ;; Allow the user to mangle the headers before parsing them.
6009 (gnus-run-hooks 'gnus-parse-headers-hook)
6010 (goto-char (point-min))
6011 (gnus-parse-without-error
6012 (while (and (or sequence allp)
6014 (setq number (read cur))
6016 (while (and sequence
6017 (< (car sequence) number))
6018 (setq sequence (cdr sequence))))
6021 (eq number (car sequence))))
6023 (setq sequence (cdr sequence))
6024 (setq header (inline
6025 (gnus-nov-parse-line
6026 number dependencies force-new)))))
6027 (push header headers))
6029 ;; A common bug in inn is that if you have posted an article and
6030 ;; then retrieves the active file, it will answer correctly --
6031 ;; the new article is included. However, a NOV entry for the
6032 ;; article may not have been generated yet, so this may fail.
6033 ;; We work around this problem by retrieving the last few
6034 ;; headers using HEAD.
6035 (if (or (not also-fetch-heads)
6037 ;; We (probably) got all the headers.
6039 (let ((gnus-nov-is-evil t))
6042 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6043 (gnus-get-newsgroup-headers))))))))
6045 (defun gnus-article-get-xrefs ()
6046 "Fill in the Xref value in `gnus-current-headers', if necessary.
6047 This is meant to be called in `gnus-article-internal-prepare-hook'."
6048 (let ((headers (with-current-buffer gnus-summary-buffer
6049 gnus-current-headers)))
6050 (or (not gnus-use-cross-reference)
6052 (and (mail-header-xref headers)
6053 (not (string= (mail-header-xref headers) "")))
6054 (let ((case-fold-search t)
6057 (nnheader-narrow-to-headers)
6058 (goto-char (point-min))
6059 (when (or (and (not (eobp))
6060 (eq (downcase (char-after)) ?x)
6061 (looking-at "Xref:"))
6062 (search-forward "\nXref:" nil t))
6063 (goto-char (1+ (match-end 0)))
6064 (setq xref (buffer-substring (point) (point-at-eol)))
6065 (mail-header-set-xref headers xref)))))))
6067 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6068 "Find article ID and insert the summary line for that article.
6069 OLD-HEADER can either be a header or a line number to insert
6070 the subject line on."
6071 (let* ((line (and (numberp old-header) old-header))
6072 (old-header (and (vectorp old-header) old-header))
6073 (header (cond ((and old-header use-old-header)
6076 (gnus-number-to-header id))
6077 (gnus-number-to-header id))
6079 (gnus-read-header id))))
6080 (number (and (numberp id) id))
6083 ;; Rebuild the thread that this article is part of and go to the
6084 ;; article we have fetched.
6085 (when (and (not gnus-show-threads)
6088 (setq d (gnus-data-find (mail-header-number old-header))))
6089 (goto-char (gnus-data-pos d))
6095 (gnus-delete-line))))))
6096 ;; Remove list identifiers from subject.
6097 (when gnus-list-identifiers
6098 (let ((gnus-newsgroup-headers (list header)))
6099 (gnus-summary-remove-list-identifiers)))
6101 (mail-header-set-number header (mail-header-number old-header)))
6102 (setq gnus-newsgroup-sparse
6103 (delq (setq number (mail-header-number header))
6104 gnus-newsgroup-sparse))
6105 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6106 (push number gnus-newsgroup-limit)
6107 (gnus-rebuild-thread (mail-header-id header) line)
6108 (gnus-summary-goto-subject number nil t))
6109 (when (and (numberp number)
6111 ;; We have to update the boundaries even if we can't fetch the
6112 ;; article if ID is a number -- so that the next `P' or `N'
6113 ;; command will fetch the previous (or next) article even
6114 ;; if the one we tried to fetch this time has been canceled.
6115 (when (> number gnus-newsgroup-end)
6116 (setq gnus-newsgroup-end number))
6117 (when (< number gnus-newsgroup-begin)
6118 (setq gnus-newsgroup-begin number))
6119 (setq gnus-newsgroup-unselected
6120 (delq number gnus-newsgroup-unselected)))
6121 ;; Report back a success?
6122 (and header (mail-header-number header))))
6124 ;;; Process/prefix in the summary buffer
6126 (defun gnus-summary-work-articles (n)
6127 "Return a list of articles to be worked upon.
6128 The prefix argument, the list of process marked articles, and the
6129 current article will be taken into consideration."
6131 (set-buffer gnus-summary-buffer)
6134 ;; A numerical prefix has been given.
6135 (setq n (prefix-numeric-value n))
6136 (let ((backward (< n 0))
6137 (n (abs (prefix-numeric-value n)))
6142 (push (setq article (gnus-summary-article-number))
6145 (gnus-summary-find-prev nil article)
6146 (gnus-summary-find-next nil article)))
6148 (nreverse articles)))
6149 ((and (gnus-region-active-p) (mark))
6150 (message "region active")
6151 ;; Work on the region between point and mark.
6152 (let ((max (max (point) (mark)))
6155 (goto-char (min (point) (mark)))
6158 (push (setq article (gnus-summary-article-number)) articles)
6159 (gnus-summary-find-next nil article)
6161 (nreverse articles))))
6162 (gnus-newsgroup-processable
6163 ;; There are process-marked articles present.
6164 ;; Save current state.
6165 (gnus-summary-save-process-mark)
6167 (reverse gnus-newsgroup-processable))
6169 ;; Just return the current article.
6170 (list (gnus-summary-article-number))))))
6172 (defmacro gnus-summary-iterate (arg &rest forms)
6173 "Iterate over the process/prefixed articles and do FORMS.
6174 ARG is the interactive prefix given to the command. FORMS will be
6175 executed with point over the summary line of the articles."
6176 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6177 `(let ((,articles (gnus-summary-work-articles ,arg)))
6179 (gnus-summary-goto-subject (car ,articles))
6183 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6184 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6186 (defun gnus-summary-save-process-mark ()
6187 "Push the current set of process marked articles on the stack."
6189 (push (copy-sequence gnus-newsgroup-processable)
6190 gnus-newsgroup-process-stack))
6192 (defun gnus-summary-kill-process-mark ()
6193 "Push the current set of process marked articles on the stack and unmark."
6195 (gnus-summary-save-process-mark)
6196 (gnus-summary-unmark-all-processable))
6198 (defun gnus-summary-yank-process-mark ()
6199 "Pop the last process mark state off the stack and restore it."
6201 (unless gnus-newsgroup-process-stack
6202 (error "Empty mark stack"))
6203 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6205 (defun gnus-summary-process-mark-set (set)
6206 "Make SET into the current process marked articles."
6207 (gnus-summary-unmark-all-processable)
6208 (mapc 'gnus-summary-set-process-mark set))
6210 ;;; Searching and stuff
6212 (defun gnus-summary-search-group (&optional backward use-level)
6213 "Search for next unread newsgroup.
6214 If optional argument BACKWARD is non-nil, search backward instead."
6216 (set-buffer gnus-group-buffer)
6217 (when (gnus-group-search-forward
6218 backward nil (if use-level (gnus-group-group-level) nil))
6219 (gnus-group-group-name))))
6221 (defun gnus-summary-best-group (&optional exclude-group)
6222 "Find the name of the best unread group.
6223 If EXCLUDE-GROUP, do not go to this group."
6224 (with-current-buffer gnus-group-buffer
6226 (gnus-group-best-unread-group exclude-group))))
6228 (defun gnus-summary-find-next (&optional unread article backward)
6230 (gnus-summary-find-prev unread article)
6231 (let* ((dummy (gnus-summary-article-intangible-p))
6232 (article (or article (gnus-summary-article-number)))
6233 (data (gnus-data-find-list article))
6235 (when (and (not dummy)
6236 (or (not gnus-summary-check-current)
6238 (not (gnus-data-unread-p (car data)))))
6239 (setq data (cdr data)))
6244 (unless (memq (gnus-data-number (car data))
6246 ((eq gnus-auto-goto-ignores
6247 'always-undownloaded)
6248 gnus-newsgroup-undownloaded)
6251 ((eq gnus-auto-goto-ignores
6253 gnus-newsgroup-unfetched)
6254 ((eq gnus-auto-goto-ignores
6256 gnus-newsgroup-undownloaded)))
6257 (when (gnus-data-unread-p (car data))
6258 (setq result (car data)
6260 (setq data (cdr data)))
6263 (goto-char (gnus-data-pos result))
6264 (gnus-data-number result)))))
6266 (defun gnus-summary-find-prev (&optional unread article)
6267 (let* ((eobp (eobp))
6268 (article (or article (gnus-summary-article-number)))
6269 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6271 (when (and (not eobp)
6272 (or (not gnus-summary-check-current)
6274 (not (gnus-data-unread-p (car data)))))
6275 (setq data (cdr data)))
6280 (unless (memq (gnus-data-number (car data))
6282 ((eq gnus-auto-goto-ignores
6283 'always-undownloaded)
6284 gnus-newsgroup-undownloaded)
6287 ((eq gnus-auto-goto-ignores
6289 gnus-newsgroup-unfetched)
6290 ((eq gnus-auto-goto-ignores
6292 gnus-newsgroup-undownloaded)))
6293 (when (gnus-data-unread-p (car data))
6294 (setq result (car data)
6296 (setq data (cdr data)))
6299 (goto-char (gnus-data-pos result))
6300 (gnus-data-number result))))
6302 (defun gnus-summary-find-subject (subject &optional unread backward article)
6303 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6304 (article (or article (gnus-summary-article-number)))
6305 (articles (gnus-data-list backward))
6306 (arts (gnus-data-find-list article articles))
6308 (when (or (not gnus-summary-check-current)
6310 (not (gnus-data-unread-p (car arts))))
6311 (setq arts (cdr arts)))
6313 (and (or (not unread)
6314 (gnus-data-unread-p (car arts)))
6315 (vectorp (gnus-data-header (car arts)))
6317 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6318 (setq result (car arts)
6320 (setq arts (cdr arts)))
6322 (goto-char (gnus-data-pos result))
6323 (gnus-data-number result))))
6325 (defun gnus-summary-search-forward (&optional unread subject backward)
6326 "Search forward for an article.
6327 If UNREAD, look for unread articles. If SUBJECT, look for
6328 articles with that subject. If BACKWARD, search backward instead."
6329 (cond (subject (gnus-summary-find-subject subject unread backward))
6330 (backward (gnus-summary-find-prev unread))
6331 (t (gnus-summary-find-next unread))))
6333 (defun gnus-recenter (&optional n)
6334 "Center point in window and redisplay frame.
6335 Also do horizontal recentering."
6337 (when (and gnus-auto-center-summary
6338 (not (eq gnus-auto-center-summary 'vertical)))
6339 (gnus-horizontal-recenter))
6342 (defun gnus-summary-recenter ()
6343 "Center point in the summary window.
6344 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6345 displayed, no centering will be performed."
6346 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6347 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6349 ;; The user has to want it.
6350 (when gnus-auto-center-summary
6351 (let* ((top (cond ((< (window-height) 4) 0)
6352 ((< (window-height) 7) 1)
6353 (t (if (numberp gnus-auto-center-summary)
6354 gnus-auto-center-summary
6355 (/ (1- (window-height)) 2)))))
6356 (height (1- (window-height)))
6357 (bottom (save-excursion (goto-char (point-max))
6358 (forward-line (- height))
6360 (window (get-buffer-window (current-buffer))))
6361 (when (get-buffer-window gnus-article-buffer)
6362 ;; Only do recentering when the article buffer is displayed,
6363 ;; Set the window start to either `bottom', which is the biggest
6364 ;; possible valid number, or the second line from the top,
6365 ;; whichever is the least.
6366 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6367 (if (> bottom top-pos)
6368 ;; Keep the second line from the top visible
6369 (set-window-start window top-pos t)
6370 ;; Try to keep the bottom line visible; if it's partially
6371 ;; obscured, either scroll one more line to make it fully
6372 ;; visible, or revert to using TOP-POS.
6374 (goto-char (point-max))
6376 (let ((last-line-start (point)))
6378 (set-window-start window (point) t)
6379 (when (not (pos-visible-in-window-p last-line-start window))
6381 (set-window-start window (min (point) top-pos) t)))))))
6382 ;; Do horizontal recentering while we're at it.
6383 (when (and (get-buffer-window (current-buffer) t)
6384 (not (eq gnus-auto-center-summary 'vertical)))
6385 (let ((selected (selected-window)))
6386 (select-window (get-buffer-window (current-buffer) t))
6387 (gnus-summary-position-point)
6388 (gnus-horizontal-recenter)
6389 (select-window selected))))))
6391 (defun gnus-summary-jump-to-group (newsgroup)
6392 "Move point to NEWSGROUP in group mode buffer."
6393 ;; Keep update point of group mode buffer if visible.
6394 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6395 (save-window-excursion
6396 ;; Take care of tree window mode.
6397 (when (get-buffer-window gnus-group-buffer)
6398 (pop-to-buffer gnus-group-buffer))
6399 (gnus-group-jump-to-group newsgroup))
6401 ;; Take care of tree window mode.
6402 (if (get-buffer-window gnus-group-buffer)
6403 (pop-to-buffer gnus-group-buffer)
6404 (set-buffer gnus-group-buffer))
6405 (gnus-group-jump-to-group newsgroup))))
6407 ;; This function returns a list of article numbers based on the
6408 ;; difference between the ranges of read articles in this group and
6409 ;; the range of active articles.
6410 (defun gnus-list-of-unread-articles (group)
6411 (let* ((read (gnus-info-read (gnus-get-info group)))
6412 (active (or (gnus-active group) (gnus-activate-group group)))
6415 ;; If none are read, then all are unread.
6417 (setq first (car active))
6418 ;; If the range of read articles is a single range, then the
6419 ;; first unread article is the article after the last read
6420 ;; article. Sounds logical, doesn't it?
6421 (if (and (not (listp (cdr read)))
6422 (or (< (car read) (car active))
6423 (progn (setq read (list read))
6425 (setq first (max (car active) (1+ (cdr read))))
6426 ;; `read' is a list of ranges.
6427 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6430 (setq first (car active)))
6433 (while (< first nlast)
6434 (setq unread (cons first unread)
6436 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6437 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6438 (setq read (cdr read)))))
6439 ;; And add the last unread articles.
6440 (while (<= first last)
6441 (setq unread (cons first unread)
6443 ;; Return the list of unread articles.
6444 (delq 0 (nreverse unread))))
6446 (defun gnus-list-of-read-articles (group)
6447 "Return a list of unread, unticked and non-dormant articles."
6448 (let* ((info (gnus-get-info group))
6449 (marked (gnus-info-marks info))
6450 (active (gnus-active group)))
6452 (gnus-list-range-difference
6453 (gnus-list-range-difference
6454 (gnus-sorted-complement
6455 (gnus-uncompress-range active)
6456 (gnus-list-of-unread-articles group))
6457 (cdr (assq 'dormant marked)))
6458 (cdr (assq 'tick marked))))))
6460 ;; This function returns a sequence of article numbers based on the
6461 ;; difference between the ranges of read articles in this group and
6462 ;; the range of active articles.
6463 (defun gnus-sequence-of-unread-articles (group)
6464 (let* ((read (gnus-info-read (gnus-get-info group)))
6465 (active (or (gnus-active group) (gnus-activate-group group)))
6468 ;; If none are read, then all are unread.
6470 (setq first (car active))
6471 ;; If the range of read articles is a single range, then the
6472 ;; first unread article is the article after the last read
6473 ;; article. Sounds logical, doesn't it?
6474 (if (and (not (listp (cdr read)))
6475 (or (< (car read) (car active))
6476 (progn (setq read (list read))
6478 (setq first (max (car active) (1+ (cdr read))))
6479 ;; `read' is a list of ranges.
6480 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6483 (setq first (car active)))
6486 (push (cons first nlast) unread))
6487 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6488 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6489 (setq read (cdr read)))))
6490 ;; And add the last unread articles.
6491 (cond ((< first last)
6492 (push (cons first last) unread))
6494 (push first unread)))
6495 ;; Return the sequence of unread articles.
6496 (delq 0 (nreverse unread))))
6498 ;; Various summary commands
6500 (defun gnus-summary-select-article-buffer ()
6501 "Reconfigure windows to show article buffer."
6503 (if (not (gnus-buffer-live-p gnus-article-buffer))
6504 (error "There is no article buffer for this summary buffer")
6505 (gnus-configure-windows 'article)
6506 (select-window (get-buffer-window gnus-article-buffer))))
6508 (defun gnus-summary-universal-argument (arg)
6509 "Perform any operation on all articles that are process/prefixed."
6511 (let ((articles (gnus-summary-work-articles arg))
6518 (substitute-command-keys
6519 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6521 (gnus-error 1 "Undefined key")
6524 (gnus-summary-goto-subject (setq article (pop articles)))
6525 (let (gnus-newsgroup-processable)
6526 (command-execute func))
6527 (gnus-summary-remove-process-mark article)))))
6528 (gnus-summary-position-point))
6530 (defun gnus-summary-toggle-truncation (&optional arg)
6531 "Toggle truncation of summary lines.
6532 With ARG, turn line truncation on if ARG is positive."
6534 (setq truncate-lines
6535 (if (null arg) (not truncate-lines)
6536 (> (prefix-numeric-value arg) 0)))
6539 (defun gnus-summary-find-for-reselect ()
6540 "Return the number of an article to stay on across a reselect.
6541 The current article is considered, then following articles, then previous
6542 articles. An article is sought which is not cancelled and isn't a temporary
6543 insertion from another group. If there's no such then return a dummy 0."
6545 (dolist (rev '(nil t))
6546 (unless found ; don't demand the reverse list if we don't need it
6547 (let ((data (gnus-data-find-list
6548 (gnus-summary-article-number) (gnus-data-list rev))))
6549 (while (and data (not found))
6550 (if (and (< 0 (gnus-data-number (car data)))
6551 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6552 (setq found (gnus-data-number (car data))))
6553 (setq data (cdr data))))))
6556 (defun gnus-summary-reselect-current-group (&optional all rescan)
6557 "Exit and then reselect the current newsgroup.
6558 The prefix argument ALL means to select all articles."
6560 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6561 (error "Ephemeral groups can't be reselected"))
6562 (let ((current-subject (gnus-summary-find-for-reselect))
6563 (group gnus-newsgroup-name))
6564 (setq gnus-newsgroup-begin nil)
6565 (gnus-summary-exit nil 'leave-hidden)
6566 ;; We have to adjust the point of group mode buffer because
6567 ;; point was moved to the next unread newsgroup by exiting.
6568 (gnus-summary-jump-to-group group)
6571 (save-window-excursion
6572 ;; Don't show group contents.
6573 (set-window-start (selected-window) (point-max))
6574 (gnus-group-get-new-news-this-group 1))))
6575 (gnus-group-read-group all t)
6576 (gnus-summary-goto-subject current-subject nil t)))
6578 (defun gnus-summary-rescan-group (&optional all)
6579 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6581 (gnus-summary-reselect-current-group all t))
6583 (defun gnus-summary-update-info (&optional non-destructive)
6585 (let ((group gnus-newsgroup-name))
6587 (when gnus-newsgroup-kill-headers
6588 (setq gnus-newsgroup-killed
6589 (gnus-compress-sequence
6591 (gnus-list-range-intersection
6592 gnus-newsgroup-unselected gnus-newsgroup-killed)
6593 gnus-newsgroup-unreads)
6595 (unless (listp (cdr gnus-newsgroup-killed))
6596 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6597 (let ((headers gnus-newsgroup-headers))
6598 ;; Set the new ranges of read articles.
6599 (with-current-buffer gnus-group-buffer
6600 (gnus-undo-force-boundary))
6601 (gnus-update-read-articles
6602 group (gnus-sorted-union
6603 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6604 ;; Set the current article marks.
6605 (let ((gnus-newsgroup-scored
6606 (if (and (not gnus-save-score)
6607 (not non-destructive))
6609 gnus-newsgroup-scored)))
6611 (gnus-update-marks)))
6612 ;; Do the cross-ref thing.
6613 (when gnus-use-cross-reference
6614 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6615 ;; Do not switch windows but change the buffer to work.
6616 (set-buffer gnus-group-buffer)
6617 (unless (gnus-ephemeral-group-p group)
6618 (gnus-group-update-group group)))))))
6620 (defun gnus-summary-save-newsrc (&optional force)
6621 "Save the current number of read/marked articles in the dribble buffer.
6622 The dribble buffer will then be saved.
6623 If FORCE (the prefix), also save the .newsrc file(s)."
6625 (gnus-summary-update-info t)
6627 (gnus-save-newsrc-file)
6628 (gnus-dribble-save)))
6630 (defun gnus-summary-exit (&optional temporary leave-hidden)
6631 "Exit reading current newsgroup, and then return to group selection mode.
6632 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6634 (gnus-set-global-variables)
6635 (gnus-kill-save-kill-buffer)
6636 (gnus-async-halt-prefetch)
6637 (let* ((group gnus-newsgroup-name)
6638 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6639 (gnus-group-is-exiting-p t)
6642 (buf (current-buffer)))
6644 ;; Do adaptive scoring, and possibly save score files.
6645 (when gnus-newsgroup-adaptive
6646 (gnus-score-adaptive))
6647 (when gnus-use-scoring
6649 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6650 ;; If we have several article buffers, we kill them at exit.
6651 (unless gnus-single-article-buffer
6652 (gnus-kill-buffer gnus-original-article-buffer)
6653 (setq gnus-article-current nil))
6654 (when gnus-use-cache
6655 (gnus-cache-possibly-remove-articles)
6656 (gnus-cache-save-buffers))
6657 (gnus-async-prefetch-remove-group group)
6658 (when gnus-suppress-duplicates
6659 (gnus-dup-enter-articles))
6660 (when gnus-use-trees
6661 (gnus-tree-close group))
6662 (when gnus-use-cache
6663 (gnus-cache-write-active))
6664 ;; Remove entries for this group.
6665 (nnmail-purge-split-history (gnus-group-real-name group))
6666 ;; Make all changes in this group permanent.
6668 (gnus-run-hooks 'gnus-exit-group-hook)
6669 (gnus-summary-update-info))
6670 (gnus-close-group group)
6671 ;; Make sure where we were, and go to next newsgroup.
6672 (set-buffer gnus-group-buffer)
6674 (gnus-group-jump-to-group group))
6675 (gnus-run-hooks 'gnus-summary-exit-hook)
6676 (unless (or quit-config
6677 ;; If this group has disappeared from the summary
6678 ;; buffer, don't skip forwards.
6679 (not (string= group (gnus-group-group-name))))
6680 (gnus-group-next-unread-group 1))
6681 (setq group-point (point))
6684 ;; If we have several article buffers, we kill them at exit.
6685 (unless gnus-single-article-buffer
6686 (gnus-kill-buffer gnus-article-buffer)
6687 (gnus-kill-buffer gnus-original-article-buffer)
6688 (setq gnus-article-current nil))
6690 (if (not gnus-kill-summary-on-exit)
6692 (gnus-deaden-summary)
6694 ;; We set all buffer-local variables to nil. It is unclear why
6695 ;; this is needed, but if we don't, buffer-local variables are
6696 ;; not garbage-collected, it seems. This would the lead to en
6697 ;; ever-growing Emacs.
6698 (gnus-summary-clear-local-variables)
6699 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6700 (gnus-summary-clear-local-variables))
6701 (when (get-buffer gnus-article-buffer)
6702 (bury-buffer gnus-article-buffer))
6703 ;; We clear the global counterparts of the buffer-local
6704 ;; variables as well, just to be on the safe side.
6705 (set-buffer gnus-group-buffer)
6706 (gnus-summary-clear-local-variables)
6707 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6708 (gnus-summary-clear-local-variables))
6709 ;; Return to group mode buffer.
6710 (when (eq mode 'gnus-summary-mode)
6711 (gnus-kill-buffer buf)))
6712 (setq gnus-current-select-method gnus-select-method)
6714 (set-buffer gnus-group-buffer)
6715 (pop-to-buffer gnus-group-buffer))
6716 (if (not quit-config)
6718 (goto-char group-point)
6719 (unless leave-hidden
6720 (gnus-configure-windows 'group 'force))
6721 (unless (pos-visible-in-window-p)
6722 (forward-line (/ (static-if (featurep 'xemacs)
6723 (window-displayed-height)
6724 (1- (window-height)))
6726 (set-window-start (selected-window) (point))
6727 (goto-char group-point)))
6728 (gnus-handle-ephemeral-exit quit-config))
6729 ;; Clear the current group name.
6731 (setq gnus-newsgroup-name nil)))))
6733 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6734 (defun gnus-summary-exit-no-update (&optional no-questions)
6735 "Quit reading current newsgroup without updating read article info."
6737 (let* ((group gnus-newsgroup-name)
6738 (gnus-group-is-exiting-p t)
6739 (gnus-group-is-exiting-without-update-p t)
6740 (quit-config (gnus-group-quit-config group)))
6741 (when (or no-questions
6743 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6744 (gnus-async-halt-prefetch)
6745 (run-hooks 'gnus-summary-prepare-exit-hook)
6746 ;; If we have several article buffers, we kill them at exit.
6747 (unless gnus-single-article-buffer
6748 (gnus-kill-buffer gnus-article-buffer)
6749 (gnus-kill-buffer gnus-original-article-buffer)
6750 (setq gnus-article-current nil))
6751 (if (not gnus-kill-summary-on-exit)
6752 (gnus-deaden-summary)
6753 (gnus-close-group group)
6754 (gnus-summary-clear-local-variables)
6755 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6756 (gnus-summary-clear-local-variables))
6757 (set-buffer gnus-group-buffer)
6758 (gnus-summary-clear-local-variables)
6759 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6760 (gnus-summary-clear-local-variables))
6761 (gnus-kill-buffer gnus-summary-buffer))
6762 (unless gnus-single-article-buffer
6763 (setq gnus-article-current nil))
6764 (when gnus-use-trees
6765 (gnus-tree-close group))
6766 (gnus-async-prefetch-remove-group group)
6767 (when (get-buffer gnus-article-buffer)
6768 (bury-buffer gnus-article-buffer))
6769 ;; Return to the group buffer.
6770 (gnus-configure-windows 'group 'force)
6771 ;; Clear the current group name.
6772 (setq gnus-newsgroup-name nil)
6773 (unless (gnus-ephemeral-group-p group)
6774 (gnus-group-update-group group))
6775 (when (equal (gnus-group-group-name) group)
6776 (gnus-group-next-unread-group 1))
6778 (gnus-handle-ephemeral-exit quit-config)))))
6780 (defun gnus-handle-ephemeral-exit (quit-config)
6781 "Handle movement when leaving an ephemeral group.
6782 The state which existed when entering the ephemeral is reset."
6783 (if (not (buffer-name (car quit-config)))
6784 (gnus-configure-windows 'group 'force)
6785 (set-buffer (car quit-config))
6786 (cond ((eq major-mode 'gnus-summary-mode)
6787 (gnus-set-global-variables))
6788 ((eq major-mode 'gnus-article-mode)
6790 ;; The `gnus-summary-buffer' variable may point
6791 ;; to the old summary buffer when using a single
6793 (unless (gnus-buffer-live-p gnus-summary-buffer)
6794 (set-buffer gnus-group-buffer))
6795 (set-buffer gnus-summary-buffer)
6796 (gnus-set-global-variables))))
6797 (if (or (eq (cdr quit-config) 'article)
6798 (eq (cdr quit-config) 'pick))
6800 ;; The current article may be from the ephemeral group
6801 ;; thus it is best that we reload this article
6803 ;; If we're exiting from a large digest, this can be
6804 ;; extremely slow. So, it's better not to reload it. -- jh.
6805 ;;(gnus-summary-show-article)
6806 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6807 (gnus-configure-windows 'pick 'force)
6808 (gnus-configure-windows (cdr quit-config) 'force)))
6809 (gnus-configure-windows (cdr quit-config) 'force))
6810 (when (eq major-mode 'gnus-summary-mode)
6811 (gnus-summary-next-subject 1 nil t)
6812 (gnus-summary-recenter)
6813 (gnus-summary-position-point))))
6815 (defun gnus-summary-preview-mime-message ()
6816 "MIME decode and play this message."
6818 (let ((gnus-break-pages nil)
6820 (gnus-summary-select-article gnus-show-all-headers t))
6821 (let ((w (get-buffer-window gnus-article-buffer)))
6823 (select-window (get-buffer-window gnus-article-buffer)))))
6827 (defvar gnus-dead-summary-mode-map nil)
6829 (unless gnus-dead-summary-mode-map
6830 (setq gnus-dead-summary-mode-map (make-keymap))
6831 (suppress-keymap gnus-dead-summary-mode-map)
6832 (substitute-key-definition
6833 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6834 (dolist (key '("\C-d" "\r" "\177" [delete]))
6835 (define-key gnus-dead-summary-mode-map
6836 key 'gnus-summary-wake-up-the-dead))
6837 (dolist (key '("q" "Q"))
6838 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6840 (defvar gnus-dead-summary-mode nil
6841 "Minor mode for Gnus summary buffers.")
6843 (defun gnus-dead-summary-mode (&optional arg)
6844 "Minor mode for Gnus summary buffers."
6846 (when (eq major-mode 'gnus-summary-mode)
6847 (make-local-variable 'gnus-dead-summary-mode)
6848 (setq gnus-dead-summary-mode
6849 (if (null arg) (not gnus-dead-summary-mode)
6850 (> (prefix-numeric-value arg) 0)))
6851 (when gnus-dead-summary-mode
6853 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6855 (defun gnus-deaden-summary ()
6856 "Make the current summary buffer into a dead summary buffer."
6857 ;; Kill any previous dead summary buffer.
6858 (when (and gnus-dead-summary
6859 (buffer-name gnus-dead-summary))
6860 (with-current-buffer gnus-dead-summary
6861 (when gnus-dead-summary-mode
6862 (kill-buffer (current-buffer)))))
6863 ;; Make this the current dead summary.
6864 (setq gnus-dead-summary (current-buffer))
6865 (gnus-dead-summary-mode 1)
6866 (let ((name (buffer-name)))
6867 (when (string-match "Summary" name)
6869 (concat (substring name 0 (match-beginning 0)) "Dead "
6870 (substring name (match-beginning 0)))
6874 (defun gnus-kill-or-deaden-summary (buffer)
6875 "Kill or deaden the summary BUFFER."
6877 (when (and (buffer-name buffer)
6878 (not gnus-single-article-buffer))
6879 (with-current-buffer buffer
6880 (gnus-kill-buffer gnus-article-buffer)
6881 (gnus-kill-buffer gnus-original-article-buffer)))
6884 (gnus-kill-summary-on-exit
6885 (when (and gnus-use-trees
6886 (gnus-buffer-exists-p buffer))
6889 (gnus-tree-close gnus-newsgroup-name)))
6890 (gnus-kill-buffer buffer))
6891 ;; Deaden the buffer.
6892 ((gnus-buffer-exists-p buffer)
6895 (gnus-deaden-summary))))))
6897 (defun gnus-summary-wake-up-the-dead (&rest args)
6898 "Wake up the dead summary buffer."
6900 (gnus-dead-summary-mode -1)
6901 (let ((name (buffer-name)))
6902 (when (string-match "Dead " name)
6904 (concat (substring name 0 (match-beginning 0))
6905 (substring name (match-end 0)))
6907 (gnus-message 3 "This dead summary is now alive again"))
6909 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6910 (defun gnus-summary-fetch-faq (&optional faq-dir)
6911 "Fetch the FAQ for the current group.
6912 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6916 (when current-prefix-arg
6918 "FAQ dir: " (and (listp gnus-group-faq-directory)
6920 gnus-group-faq-directory))))))
6921 (let (gnus-faq-buffer)
6922 (when (setq gnus-faq-buffer
6923 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6924 (gnus-configure-windows 'summary-faq))))
6926 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6927 (defun gnus-summary-describe-group (&optional force)
6928 "Describe the current newsgroup."
6930 (gnus-group-describe-group force gnus-newsgroup-name))
6932 (defun gnus-summary-describe-briefly ()
6933 "Describe summary mode commands briefly."
6935 (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")))
6937 ;; Walking around group mode buffer from summary mode.
6939 (defun gnus-summary-next-group (&optional no-article target-group backward)
6940 "Exit current newsgroup and then select next unread newsgroup.
6941 If prefix argument NO-ARTICLE is non-nil, no article is selected
6942 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6943 previous group instead."
6945 ;; Stop pre-fetching.
6946 (gnus-async-halt-prefetch)
6947 (let ((current-group gnus-newsgroup-name)
6948 (current-buffer (current-buffer))
6950 ;; First we semi-exit this group to update Xrefs and all variables.
6951 ;; We can't do a real exit, because the window conf must remain
6952 ;; the same in case the user is prompted for info, and we don't
6953 ;; want the window conf to change before that...
6954 (gnus-summary-exit t)
6955 (while (not entered)
6956 ;; Then we find what group we are supposed to enter.
6957 (set-buffer gnus-group-buffer)
6958 (gnus-group-jump-to-group current-group)
6961 (if (eq gnus-keep-same-level 'best)
6962 (gnus-summary-best-group gnus-newsgroup-name)
6963 (gnus-summary-search-group backward gnus-keep-same-level))))
6964 (if (not target-group)
6965 ;; There are no further groups, so we return to the group
6968 (gnus-message 5 "Returning to the group buffer")
6970 (when (gnus-buffer-live-p current-buffer)
6971 (set-buffer current-buffer)
6972 (gnus-summary-exit))
6973 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6974 ;; We try to enter the target group.
6975 (gnus-group-jump-to-group target-group)
6976 (let ((unreads (gnus-group-group-unread)))
6977 (if (and (or (eq t unreads)
6978 (and unreads (not (zerop unreads))))
6979 (gnus-summary-read-group
6980 target-group nil no-article
6981 (and (buffer-name current-buffer) current-buffer)
6984 (setq current-group target-group
6985 target-group nil)))))))
6987 (defun gnus-summary-prev-group (&optional no-article)
6988 "Exit current newsgroup and then select previous unread newsgroup.
6989 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6991 (gnus-summary-next-group no-article nil t))
6993 ;; Walking around summary lines.
6995 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6996 "Go to the first subject satisfying any non-nil constraint.
6997 If UNREAD is non-nil, the article should be unread.
6998 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6999 If UNSEEN is non-nil, the article should be unseen.
7000 Returns the article selected or nil if there are no matching articles."
7004 ((null gnus-newsgroup-data)
7005 (gnus-message 3 "No articles in the group")
7007 ;; Pick the first article.
7008 ((not (or unread undownloaded unseen))
7009 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7010 (gnus-data-number (car gnus-newsgroup-data)))
7011 ;; Find the first unread article.
7013 (let ((data gnus-newsgroup-data))
7015 (let ((num (gnus-data-number (car data))))
7016 (or (memq num gnus-newsgroup-unfetched)
7017 (not (or (and unread
7018 (memq num gnus-newsgroup-unreads))
7020 (memq num gnus-newsgroup-undownloaded))
7022 (memq num gnus-newsgroup-unseen)))))))
7023 (setq data (cdr data)))
7027 (goto-char (gnus-data-pos (car data)))
7028 (gnus-data-number (car data)))
7029 (gnus-message 3 "No more%s articles"
7030 (let* ((r (when unread " unread"))
7031 (d (when undownloaded " undownloaded"))
7032 (s (when unseen " unseen"))
7033 (l (delq nil (list r d s))))
7034 (cond ((= 3 (length l))
7035 (concat r "," d ", or" s))
7037 (concat (car l) ", or" (cadr l)))
7044 (gnus-summary-position-point))))))
7046 (defun gnus-summary-next-subject (n &optional unread dont-display)
7047 "Go to next N'th summary line.
7048 If N is negative, go to the previous N'th subject line.
7049 If UNREAD is non-nil, only unread articles are selected.
7050 The difference between N and the actual number of steps taken is
7053 (let ((backward (< n 0))
7057 (gnus-summary-find-prev unread)
7058 (gnus-summary-find-next unread)))
7059 (unless (zerop (setq n (1- n)))
7060 (gnus-summary-show-thread)))
7062 (gnus-message 7 "No more%s articles"
7063 (if unread " unread" "")))
7064 (unless dont-display
7065 (gnus-summary-recenter)
7066 (gnus-summary-position-point))
7069 (defun gnus-summary-next-unread-subject (n)
7070 "Go to next N'th unread summary line."
7072 (gnus-summary-next-subject n t))
7074 (defun gnus-summary-prev-subject (n &optional unread)
7075 "Go to previous N'th summary line.
7076 If optional argument UNREAD is non-nil, only unread article is selected."
7078 (gnus-summary-next-subject (- n) unread))
7080 (defun gnus-summary-prev-unread-subject (n)
7081 "Go to previous N'th unread summary line."
7083 (gnus-summary-next-subject (- n) t))
7085 (defun gnus-summary-goto-subjects (articles)
7086 "Insert the subject header for ARTICLES in the current buffer."
7088 (dolist (article articles)
7089 (gnus-summary-goto-subject article t)))
7090 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7091 (gnus-summary-position-point))
7093 (defun gnus-summary-goto-subject (article &optional force silent)
7094 "Go the subject line of ARTICLE.
7095 If FORCE, also allow jumping to articles not currently shown."
7096 (interactive "nArticle number: ")
7097 (unless (numberp article)
7098 (error "Article %s is not a number" article))
7100 (data (gnus-data-find article)))
7101 ;; We read in the article if we have to.
7104 (gnus-summary-insert-subject
7106 (if (or (numberp force) (vectorp force)) force)
7108 (setq data (gnus-data-find article)))
7113 (gnus-message 3 "Can't find article %d" article))
7115 (let ((pt (gnus-data-pos data)))
7117 (gnus-summary-set-article-display-arrow pt))
7118 (gnus-summary-position-point)
7121 ;; Walking around summary lines with displaying articles.
7123 (defun gnus-summary-expand-window (&optional arg)
7124 "Make the summary buffer take up the entire Emacs frame.
7125 Given a prefix, will force an `article' buffer configuration."
7128 (gnus-configure-windows 'article 'force)
7129 (gnus-configure-windows 'summary 'force)))
7131 (defun gnus-summary-display-article (article &optional all-header)
7132 "Display ARTICLE in article buffer."
7133 (when (gnus-buffer-live-p gnus-article-buffer)
7134 (with-current-buffer gnus-article-buffer
7135 (set-buffer-multibyte t)))
7136 (gnus-set-global-variables)
7137 (when (gnus-buffer-live-p gnus-article-buffer)
7138 (with-current-buffer gnus-article-buffer
7139 (setq gnus-article-charset gnus-newsgroup-charset)
7140 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7141 (set-buffer-multibyte t)))
7145 (if gnus-summary-display-article-function
7146 (funcall gnus-summary-display-article-function article all-header)
7147 (gnus-article-prepare article all-header))
7148 (with-current-buffer gnus-article-buffer
7149 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7151 (gnus-run-hooks 'gnus-select-article-hook)
7152 (when (and gnus-current-article
7153 (not (zerop gnus-current-article)))
7154 (gnus-summary-goto-subject gnus-current-article))
7155 (gnus-summary-recenter)
7156 (when (and gnus-use-trees gnus-show-threads)
7157 (gnus-possibly-generate-tree article)
7158 (gnus-highlight-selected-tree article))
7159 ;; Successfully display article.
7160 (gnus-article-set-window-start
7161 (cdr (assq article gnus-newsgroup-bookmarks))))))
7163 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7164 "Select the current article.
7165 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7166 non-nil, the article will be re-fetched even if it already present in
7167 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7169 ;; Make sure we are in the summary buffer to work around bbdb bug.
7170 (unless (eq major-mode 'gnus-summary-mode)
7171 (set-buffer gnus-summary-buffer))
7172 (let ((article (or article (gnus-summary-article-number)))
7173 (all-headers (not (not all-headers))) ;Must be T or NIL.
7174 gnus-summary-display-article-function)
7176 (gnus-summary-article-pseudo-p article)
7177 (error "This is a pseudo-article"))
7179 (set-buffer gnus-summary-buffer)
7180 (if (or (and gnus-single-article-buffer
7181 (or (null gnus-current-article)
7182 (null gnus-article-current)
7183 (null (get-buffer gnus-article-buffer))
7184 (not (eq article (cdr gnus-article-current)))
7185 (not (equal (car gnus-article-current)
7186 gnus-newsgroup-name))))
7187 (and (not gnus-single-article-buffer)
7188 (or (null gnus-current-article)
7189 (not (eq gnus-current-article article))))
7191 ;; The requested article is different from the current article.
7193 (gnus-summary-display-article article all-headers)
7194 (gnus-article-set-window-start
7195 (cdr (assq article gnus-newsgroup-bookmarks)))
7199 (defun gnus-summary-force-verify-and-decrypt ()
7200 "Display buttons for signed/encrypted parts and verify/decrypt them."
7202 (let ((mm-verify-option 'known)
7203 (mm-decrypt-option 'known)
7204 (gnus-article-emulate-mime t)
7205 (gnus-buttonized-mime-types (append (list "multipart/signed"
7206 "multipart/encrypted")
7207 gnus-buttonized-mime-types)))
7208 (gnus-summary-select-article nil 'force)))
7210 (defun gnus-summary-set-current-mark (&optional current-mark)
7211 "Obsolete function."
7214 (defun gnus-summary-next-article (&optional unread subject backward push)
7215 "Select the next article.
7216 If UNREAD, only unread articles are selected.
7217 If SUBJECT, only articles with SUBJECT are selected.
7218 If BACKWARD, the previous article is selected instead of the next."
7221 ;; Is there such an article?
7222 ((and (gnus-summary-search-forward unread subject backward)
7223 (or (gnus-summary-display-article (gnus-summary-article-number))
7224 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7225 (gnus-summary-position-point))
7226 ;; If not, we try the first unread, if that is wanted.
7228 gnus-auto-select-same
7229 (gnus-summary-first-unread-article))
7230 (gnus-summary-position-point)
7231 (gnus-message 6 "Wrapped"))
7232 ;; Try to get next/previous article not displayed in this group.
7233 ((and gnus-auto-extend-newsgroup
7234 (not unread) (not subject))
7235 (gnus-summary-goto-article
7236 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7237 nil (count-lines (point-min) (point))))
7238 ;; Go to next/previous group.
7240 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7241 (gnus-summary-jump-to-group gnus-newsgroup-name))
7242 (let ((cmd last-command-char)
7244 (with-current-buffer gnus-group-buffer
7247 (if (eq gnus-keep-same-level 'best)
7248 (gnus-summary-best-group gnus-newsgroup-name)
7249 (gnus-summary-search-group backward gnus-keep-same-level))))
7250 ;; For some reason, the group window gets selected. We change
7252 (select-window (get-buffer-window (current-buffer)))
7253 ;; Select next unread newsgroup automagically.
7255 ((or (not gnus-auto-select-next)
7257 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7258 ((or (eq gnus-auto-select-next 'quietly)
7259 (and (eq gnus-auto-select-next 'slightly-quietly)
7261 (and (eq gnus-auto-select-next 'almost-quietly)
7262 (gnus-summary-last-article-p)))
7264 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7266 (gnus-message 7 "No more%s articles (%s)..."
7267 (if unread " unread" "")
7268 (if group (concat "selecting " group)
7270 (gnus-summary-next-group nil group backward)))
7272 (when (gnus-key-press-event-p last-input-event)
7273 (gnus-summary-walk-group-buffer
7274 gnus-newsgroup-name cmd unread backward point))))))))
7276 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7277 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7278 (?\C-p (gnus-group-prev-unread-group 1))))
7279 (cursor-in-echo-area t)
7280 keve key group ended prompt)
7282 (set-buffer gnus-group-buffer)
7285 (if (eq gnus-keep-same-level 'best)
7286 (gnus-summary-best-group gnus-newsgroup-name)
7287 (gnus-summary-search-group backward gnus-keep-same-level))))
7291 "No more%s articles%s " (if unread " unread" "")
7293 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7294 (format " (Type %s for %s [%s])"
7295 (single-key-description cmd) group
7296 (gnus-group-unread group))
7297 (format " (Type %s to exit %s)"
7298 (single-key-description cmd)
7299 gnus-newsgroup-name))))
7300 ;; Confirm auto selection.
7301 (setq key (car (setq keve (gnus-read-event-char prompt)))
7304 ((assq key keystrokes)
7305 (let ((obuf (current-buffer)))
7306 (switch-to-buffer gnus-group-buffer)
7308 (gnus-group-jump-to-group group))
7309 (eval (cadr (assq key keystrokes)))
7310 (setq group (gnus-group-group-name))
7311 (switch-to-buffer obuf))
7315 (gnus-ephemeral-group-p gnus-newsgroup-name))
7317 (gnus-summary-next-group nil group backward)))
7319 (push (cdr keve) unread-command-events))))))
7321 (defun gnus-summary-next-unread-article ()
7322 "Select unread article after current one."
7324 (gnus-summary-next-article
7325 (or (not (eq gnus-summary-goto-unread 'never))
7326 (gnus-summary-last-article-p (gnus-summary-article-number)))
7327 (and gnus-auto-select-same
7328 (gnus-summary-article-subject))))
7330 (defun gnus-summary-prev-article (&optional unread subject)
7331 "Select the article after the current one.
7332 If UNREAD is non-nil, only unread articles are selected."
7334 (gnus-summary-next-article unread subject t))
7336 (defun gnus-summary-prev-unread-article ()
7337 "Select unread article before current one."
7339 (gnus-summary-prev-article
7340 (or (not (eq gnus-summary-goto-unread 'never))
7341 (gnus-summary-first-article-p (gnus-summary-article-number)))
7342 (and gnus-auto-select-same
7343 (gnus-summary-article-subject))))
7345 (defun gnus-summary-next-page (&optional lines circular stop)
7346 "Show next page of the selected article.
7347 If at the end of the current article, select the next article.
7348 LINES says how many lines should be scrolled up.
7350 If CIRCULAR is non-nil, go to the start of the article instead of
7351 selecting the next article when reaching the end of the current
7354 If STOP is non-nil, just stop when reaching the end of the message.
7356 Also see the variable `gnus-article-skip-boring'."
7358 (setq gnus-summary-buffer (current-buffer))
7359 (gnus-set-global-variables)
7360 (let ((article (gnus-summary-article-number))
7361 (article-window (get-buffer-window gnus-article-buffer t))
7363 ;; If the buffer is empty, we have no article.
7365 (error "No article to select"))
7366 (gnus-configure-windows 'article)
7367 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7368 (if (and (eq gnus-summary-goto-unread 'never)
7369 (not (gnus-summary-last-article-p article)))
7370 (gnus-summary-next-article)
7371 (gnus-summary-next-unread-article))
7372 (if (or (null gnus-current-article)
7373 (null gnus-article-current)
7374 (/= article (cdr gnus-article-current))
7375 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7376 ;; Selected subject is different from current article's.
7377 (gnus-summary-display-article article)
7378 (when article-window
7379 (gnus-eval-in-buffer-window gnus-article-buffer
7380 (setq endp (or (gnus-article-next-page lines)
7381 (gnus-article-only-boring-p))))
7384 (gnus-message 3 "End of message"))
7386 (gnus-summary-beginning-of-article))
7388 (gnus-message 3 "End of message"))
7390 (if (and (eq gnus-summary-goto-unread 'never)
7391 (not (gnus-summary-last-article-p article)))
7392 (gnus-summary-next-article)
7393 (gnus-summary-next-unread-article))))))))
7394 (gnus-summary-recenter)
7395 (gnus-summary-position-point)))
7397 (defun gnus-summary-prev-page (&optional lines move)
7398 "Show previous page of selected article.
7399 Argument LINES specifies lines to be scrolled down.
7400 If MOVE, move to the previous unread article if point is at
7401 the beginning of the buffer."
7403 (let ((article (gnus-summary-article-number))
7404 (article-window (get-buffer-window gnus-article-buffer t))
7406 (gnus-configure-windows 'article)
7407 (if (or (null gnus-current-article)
7408 (null gnus-article-current)
7409 (/= article (cdr gnus-article-current))
7410 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7411 ;; Selected subject is different from current article's.
7412 (gnus-summary-display-article article)
7413 (gnus-summary-recenter)
7414 (when article-window
7415 (gnus-eval-in-buffer-window gnus-article-buffer
7416 (setq endp (gnus-article-prev-page lines)))
7417 (when (and move endp)
7419 (gnus-message 3 "Beginning of message"))
7421 (if (and (eq gnus-summary-goto-unread 'never)
7422 (not (gnus-summary-first-article-p article)))
7423 (gnus-summary-prev-article)
7424 (gnus-summary-prev-unread-article))))))))
7425 (gnus-summary-position-point))
7427 (defun gnus-summary-prev-page-or-article (&optional lines)
7428 "Show previous page of selected article.
7429 Argument LINES specifies lines to be scrolled down.
7430 If at the beginning of the article, go to the next article."
7432 (gnus-summary-prev-page lines t))
7434 (defun gnus-summary-scroll-up (lines)
7435 "Scroll up (or down) one line current article.
7436 Argument LINES specifies lines to be scrolled up (or down if negative)."
7438 (gnus-configure-windows 'article)
7439 (gnus-summary-show-thread)
7440 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7441 (gnus-eval-in-buffer-window gnus-article-buffer
7443 (when (gnus-article-next-page lines)
7444 (gnus-message 3 "End of message")))
7446 (gnus-article-prev-page (- lines))))))
7447 (gnus-summary-recenter)
7448 (gnus-summary-position-point))
7450 (defun gnus-summary-scroll-down (lines)
7451 "Scroll down (or up) one line current article.
7452 Argument LINES specifies lines to be scrolled down (or up if negative)."
7454 (gnus-summary-scroll-up (- lines)))
7456 (defun gnus-summary-next-same-subject ()
7457 "Select next article which has the same subject as current one."
7459 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7461 (defun gnus-summary-prev-same-subject ()
7462 "Select previous article which has the same subject as current one."
7464 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7466 (defun gnus-summary-next-unread-same-subject ()
7467 "Select next unread article which has the same subject as current one."
7469 (gnus-summary-next-article t (gnus-summary-article-subject)))
7471 (defun gnus-summary-prev-unread-same-subject ()
7472 "Select previous unread article which has the same subject as current one."
7474 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7476 (defun gnus-summary-first-unread-article ()
7477 "Select the first unread article.
7478 Return nil if there are no unread articles."
7481 (when (gnus-summary-first-subject t)
7482 (gnus-summary-show-thread)
7483 (gnus-summary-first-subject t)
7484 (gnus-summary-display-article (gnus-summary-article-number)))
7485 (gnus-summary-position-point)))
7487 (defun gnus-summary-first-unread-subject ()
7488 "Place the point on the subject line of the first unread article.
7489 Return nil if there are no unread articles."
7492 (when (gnus-summary-first-subject t)
7493 (gnus-summary-show-thread)
7494 (gnus-summary-first-subject t))
7495 (gnus-summary-position-point)))
7497 (defun gnus-summary-first-unseen-subject ()
7498 "Place the point on the subject line of the first unseen article.
7499 Return nil if there are no unseen articles."
7502 (when (gnus-summary-first-subject nil nil t)
7503 (gnus-summary-show-thread)
7504 (gnus-summary-first-subject nil nil t))
7505 (gnus-summary-position-point)))
7507 (defun gnus-summary-first-unseen-or-unread-subject ()
7508 "Place the point on the subject line of the first unseen article or,
7509 if all article have been seen, on the subject line of the first unread
7513 (unless (when (gnus-summary-first-subject nil nil t)
7514 (gnus-summary-show-thread)
7515 (gnus-summary-first-subject nil nil t))
7516 (when (gnus-summary-first-subject t)
7517 (gnus-summary-show-thread)
7518 (gnus-summary-first-subject t)))
7519 (gnus-summary-position-point)))
7521 (defun gnus-summary-first-article ()
7522 "Select the first article.
7523 Return nil if there are no articles."
7526 (when (gnus-summary-first-subject)
7527 (gnus-summary-show-thread)
7528 (gnus-summary-first-subject)
7529 (gnus-summary-display-article (gnus-summary-article-number)))
7530 (gnus-summary-position-point)))
7532 (defun gnus-summary-best-unread-article (&optional arg)
7533 "Select the unread article with the highest score.
7534 If given a prefix argument, select the next unread article that has a
7535 score higher than the default score."
7537 (let ((article (if arg
7538 (gnus-summary-better-unread-subject)
7539 (gnus-summary-best-unread-subject))))
7541 (gnus-summary-goto-article article)
7542 (error "No unread articles"))))
7544 (defun gnus-summary-best-unread-subject ()
7545 "Select the unread subject with the highest score."
7547 (let ((best -1000000)
7548 (data gnus-newsgroup-data)
7551 (and (gnus-data-unread-p (car data))
7553 (gnus-summary-article-score (gnus-data-number (car data))))
7556 article (gnus-data-number (car data))))
7557 (setq data (cdr data)))
7559 (gnus-summary-goto-subject article))
7560 (gnus-summary-position-point)
7563 (defun gnus-summary-better-unread-subject ()
7564 "Select the first unread subject that has a score over the default score."
7566 (let ((data gnus-newsgroup-data)
7568 (while (and (setq article (gnus-data-number (car data)))
7569 (or (gnus-data-read-p (car data))
7570 (not (> (gnus-summary-article-score article)
7571 gnus-summary-default-score))))
7572 (setq data (cdr data)))
7574 (gnus-summary-goto-subject article))
7575 (gnus-summary-position-point)
7578 (defun gnus-summary-last-subject ()
7579 "Go to the last displayed subject line in the group."
7580 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7582 (gnus-summary-goto-subject article))))
7584 (defun gnus-summary-goto-article (article &optional all-headers force)
7585 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7586 If ALL-HEADERS is non-nil, no header lines are hidden.
7587 If FORCE, go to the article even if it isn't displayed. If FORCE
7588 is a number, it is the line the article is to be displayed on."
7592 "Article number or Message-ID: "
7593 (mapcar (lambda (number) (list (int-to-string number)))
7594 gnus-newsgroup-limit))
7598 (if (and (stringp article)
7599 (string-match "@\\|%40" article))
7600 (gnus-summary-refer-article article)
7601 (when (stringp article)
7602 (setq article (string-to-number article)))
7603 (if (gnus-summary-goto-subject article force)
7604 (gnus-summary-display-article article all-headers)
7605 (gnus-message 4 "Couldn't go to article %s" article) nil))
7606 (gnus-summary-position-point)))
7608 (defun gnus-summary-goto-last-article ()
7609 "Go to the previously read article."
7612 (when gnus-last-article
7613 (gnus-summary-goto-article gnus-last-article nil t))
7614 (gnus-summary-position-point)))
7616 (defun gnus-summary-pop-article (number)
7617 "Pop one article off the history and go to the previous.
7618 NUMBER articles will be popped off."
7621 (setq gnus-newsgroup-history
7622 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7624 (gnus-summary-goto-article (car to) nil t)
7625 (error "Article history empty")))
7626 (gnus-summary-position-point))
7628 ;; Summary commands and functions for limiting the summary buffer.
7630 (defun gnus-summary-limit-to-articles (n)
7631 "Limit the summary buffer to the next N articles.
7632 If not given a prefix, use the process marked articles instead."
7635 (let ((articles (gnus-summary-work-articles n)))
7636 (setq gnus-newsgroup-processable nil)
7637 (gnus-summary-limit articles))
7638 (gnus-summary-position-point)))
7640 (defun gnus-summary-pop-limit (&optional total)
7641 "Restore the previous limit.
7642 If given a prefix, remove all limits."
7645 (setq gnus-newsgroup-limits
7646 (list (mapcar (lambda (h) (mail-header-number h))
7647 gnus-newsgroup-headers))))
7648 (unless gnus-newsgroup-limits
7649 (error "No limit to pop"))
7651 (gnus-summary-limit nil 'pop)
7652 (gnus-summary-position-point)))
7654 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7655 "Limit the summary buffer to articles that have subjects that match a regexp.
7656 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7658 (list (read-string (if current-prefix-arg
7659 "Exclude subject (regexp): "
7660 "Limit to subject (regexp): "))
7661 nil current-prefix-arg))
7663 (setq header "subject"))
7664 (when (not (equal "" subject))
7666 (let ((articles (gnus-summary-find-matching
7667 (or header "subject") subject 'all nil nil
7670 (error "Found no matches for \"%s\"" subject))
7671 (gnus-summary-limit articles))
7672 (gnus-summary-position-point))))
7674 (defun gnus-summary-limit-to-author (from &optional not-matching)
7675 "Limit the summary buffer to articles that have authors that match a regexp.
7676 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7678 (list (read-string (if current-prefix-arg
7679 "Exclude author (regexp): "
7680 "Limit to author (regexp): "))
7681 current-prefix-arg))
7682 (gnus-summary-limit-to-subject from "from" not-matching))
7684 (defun gnus-summary-limit-to-age (age &optional younger-p)
7685 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7686 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7687 articles that are younger than AGE days."
7689 (let ((younger current-prefix-arg)
7692 (while (not days-got)
7693 (setq days (if younger
7694 (read-string "Limit to articles younger than (in days, older when negative): ")
7696 "Limit to articles older than (in days, younger when negative): ")))
7697 (when (> (length days) 0)
7698 (setq days (read days)))
7703 (setq younger (not younger))
7704 (setq days (* days -1))))
7705 (message "Please enter a number.")
7707 (list days younger)))
7709 (let ((data gnus-newsgroup-data)
7710 (cutoff (days-to-time age))
7711 articles d date is-younger)
7712 (while (setq d (pop data))
7713 (when (and (vectorp (gnus-data-header d))
7714 (setq date (mail-header-date (gnus-data-header d))))
7715 (setq is-younger (time-less-p
7716 (time-since (condition-case ()
7723 (push (gnus-data-number d) articles))))
7724 (gnus-summary-limit (nreverse articles)))
7725 (gnus-summary-position-point)))
7727 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7728 "Limit the summary buffer to articles that match an 'extra' header."
7732 (gnus-completing-read-with-default
7733 (symbol-name (car gnus-extra-headers))
7734 (if current-prefix-arg
7735 "Exclude extra header:"
7736 "Limit extra header:")
7738 (cons (symbol-name x) x))
7743 (read-string (format "%s header %s (regexp): "
7744 (if current-prefix-arg "Exclude" "Limit to")
7746 current-prefix-arg)))
7747 (when (not (equal "" regexp))
7749 (let ((articles (gnus-summary-find-matching
7750 (cons 'extra header) regexp 'all nil nil
7753 (error "Found no matches for \"%s\"" regexp))
7754 (gnus-summary-limit articles))
7755 (gnus-summary-position-point))))
7757 (defun gnus-summary-limit-to-display-predicate ()
7758 "Limit the summary buffer to the predicated in the `display' group parameter."
7760 (unless gnus-newsgroup-display
7761 (error "There is no `display' group parameter"))
7763 (dolist (number gnus-newsgroup-articles)
7764 (when (funcall gnus-newsgroup-display)
7765 (push number articles)))
7766 (gnus-summary-limit articles))
7767 (gnus-summary-position-point))
7769 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7771 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7773 (defun gnus-summary-limit-to-unread (&optional all)
7774 "Limit the summary buffer to articles that are not marked as read.
7775 If ALL is non-nil, limit strictly to unread articles."
7778 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7779 (gnus-summary-limit-to-marks
7780 ;; Concat all the marks that say that an article is read and have
7782 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7783 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7784 gnus-low-score-mark gnus-expirable-mark
7785 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7786 gnus-duplicate-mark gnus-souped-mark)
7789 (defun gnus-summary-limit-to-replied (&optional unreplied)
7790 "Limit the summary buffer to replied articles.
7791 If UNREPLIED (the prefix), limit to unreplied articles."
7795 (gnus-set-difference gnus-newsgroup-articles
7796 gnus-newsgroup-replied))
7797 (gnus-summary-limit gnus-newsgroup-replied))
7798 (gnus-summary-position-point))
7800 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7801 (make-obsolete 'gnus-summary-delete-marked-with
7802 'gnus-summary-limit-exclude-marks)
7804 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7805 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7806 If REVERSE, limit the summary buffer to articles that are marked
7807 with MARKS. MARKS can either be a string of marks or a list of marks.
7808 Returns how many articles were removed."
7809 (interactive "sMarks: ")
7810 (gnus-summary-limit-to-marks marks t))
7812 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7813 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7814 If REVERSE (the prefix), limit the summary buffer to articles that are
7815 not marked with MARKS. MARKS can either be a string of marks or a
7817 Returns how many articles were removed."
7818 (interactive "sMarks: \nP")
7820 (let ((data gnus-newsgroup-data)
7821 (marks (if (listp marks) marks
7822 (append marks nil))) ; Transform to list.
7825 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7826 (memq (gnus-data-mark (car data)) marks))
7827 (push (gnus-data-number (car data)) articles))
7828 (setq data (cdr data)))
7829 (gnus-summary-limit articles))
7830 (gnus-summary-position-point)))
7832 (defun gnus-summary-limit-to-score (score)
7833 "Limit to articles with score at or above SCORE."
7834 (interactive "NLimit to articles with score of at least: ")
7835 (let ((data gnus-newsgroup-data)
7838 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7840 (push (gnus-data-number (car data)) articles))
7841 (setq data (cdr data)))
7843 (gnus-summary-limit articles)
7844 (gnus-summary-position-point))))
7846 (defun gnus-summary-limit-to-unseen ()
7847 "Limit to unseen articles."
7850 (gnus-summary-limit gnus-newsgroup-unseen)
7851 (gnus-summary-position-point)))
7853 (defun gnus-summary-limit-include-thread (id)
7854 "Display all the hidden articles that is in the thread with ID in it.
7855 When called interactively, ID is the Message-ID of the current
7857 (interactive (list (mail-header-id (gnus-summary-article-header))))
7858 (let ((articles (gnus-articles-in-thread
7859 (gnus-id-to-thread (gnus-root-id id)))))
7861 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7862 (gnus-summary-limit-include-matching-articles
7864 (regexp-quote (gnus-simplify-subject-re
7865 (mail-header-subject (gnus-id-to-header id)))))
7866 (gnus-summary-position-point))))
7868 (defun gnus-summary-limit-include-matching-articles (header regexp)
7869 "Display all the hidden articles that have HEADERs that match REGEXP."
7870 (interactive (list (read-string "Match on header: ")
7871 (read-string "Regexp: ")))
7872 (let ((articles (gnus-find-matching-articles header regexp)))
7874 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7875 (gnus-summary-position-point))))
7877 (defun gnus-summary-insert-dormant-articles ()
7878 "Insert all the dormant articles for this group into the current buffer."
7880 (let ((gnus-verbose (max 6 gnus-verbose)))
7881 (if (not gnus-newsgroup-dormant)
7882 (gnus-message 3 "No cached articles for this group")
7883 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7885 (defun gnus-summary-limit-include-dormant ()
7886 "Display all the hidden articles that are marked as dormant.
7887 Note that this command only works on a subset of the articles currently
7888 fetched for this group."
7890 (unless gnus-newsgroup-dormant
7891 (error "There are no dormant articles in this group"))
7893 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7894 (gnus-summary-position-point)))
7896 (defun gnus-summary-limit-exclude-dormant ()
7897 "Hide all dormant articles."
7900 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7901 (gnus-summary-position-point)))
7903 (defun gnus-summary-limit-exclude-childless-dormant ()
7904 "Hide all dormant articles that have no children."
7906 (let ((data (gnus-data-list t))
7907 articles d children)
7908 ;; Find all articles that are either not dormant or have
7910 (while (setq d (pop data))
7911 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7913 (gnus-article-children (gnus-data-number d)))
7916 (when (memq (car children) articles)
7921 (push (gnus-data-number d) articles)))
7924 (gnus-summary-limit articles)
7925 (gnus-summary-position-point))))
7927 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7928 "Mark all unread excluded articles as read.
7929 If ALL, mark even excluded ticked and dormants as read."
7931 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7932 (let ((articles (gnus-sorted-ndifference
7934 (mapcar (lambda (h) (mail-header-number h))
7935 gnus-newsgroup-headers)
7937 gnus-newsgroup-limit))
7939 (setq gnus-newsgroup-unreads
7940 (gnus-sorted-intersection gnus-newsgroup-unreads
7941 gnus-newsgroup-limit))
7943 (setq gnus-newsgroup-dormant nil
7944 gnus-newsgroup-marked nil
7945 gnus-newsgroup-reads
7947 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7948 gnus-newsgroup-reads))
7949 (while (setq article (pop articles))
7950 (unless (or (memq article gnus-newsgroup-dormant)
7951 (memq article gnus-newsgroup-marked))
7952 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7954 (defun gnus-summary-limit (articles &optional pop)
7956 ;; We pop the previous limit off the stack and use that.
7957 (setq articles (car gnus-newsgroup-limits)
7958 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7959 ;; We use the new limit, so we push the old limit on the stack.
7960 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7962 (setq gnus-newsgroup-limit articles)
7963 (let ((total (length gnus-newsgroup-data))
7964 (data (gnus-data-find-list (gnus-summary-article-number)))
7965 (gnus-summary-mark-below nil) ; Inhibit this.
7967 ;; This will do all the work of generating the new summary buffer
7968 ;; according to the new limit.
7969 (gnus-summary-prepare)
7970 ;; Hide any threads, possibly.
7971 (gnus-summary-maybe-hide-threads)
7972 ;; Try to return to the article you were at, or one in the
7975 ;; We try to find some article after the current one.
7977 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7980 (setq data (cdr data))))
7982 ;; If there is no data, that means that we were after the last
7983 ;; article. The same goes when we can't find any articles
7984 ;; after the current one.
7985 (goto-char (point-max))
7986 (gnus-summary-find-prev))
7987 (gnus-set-mode-line 'summary)
7988 ;; We return how many articles were removed from the summary
7989 ;; buffer as a result of the new limit.
7990 (- total (length gnus-newsgroup-data))))
7992 (defsubst gnus-invisible-cut-children (threads)
7995 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8000 (defsubst gnus-cut-thread (thread)
8001 "Go forwards in the thread until we find an article that we want to display."
8002 (when (or (eq gnus-fetch-old-headers 'some)
8003 (eq gnus-fetch-old-headers 'invisible)
8004 (numberp gnus-fetch-old-headers)
8005 (eq gnus-build-sparse-threads 'some)
8006 (eq gnus-build-sparse-threads 'more))
8007 ;; Deal with old-fetched headers and sparse threads.
8011 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8012 (gnus-summary-article-ancient-p
8013 (mail-header-number (car thread))))
8014 (if (or (<= (length (cdr thread)) 1)
8015 (eq gnus-fetch-old-headers 'invisible))
8016 (setq gnus-newsgroup-limit
8017 (delq (mail-header-number (car thread))
8018 gnus-newsgroup-limit)
8019 thread (cadr thread))
8020 (when (gnus-invisible-cut-children (cdr thread))
8021 (let ((th (cdr thread)))
8023 (if (memq (mail-header-number (caar th))
8024 gnus-newsgroup-limit)
8025 (setq thread (car th)
8027 (setq th (cdr th))))))))))
8030 (defun gnus-cut-threads (threads)
8031 "Cut off all uninteresting articles from the beginning of THREADS."
8032 (when (or (eq gnus-fetch-old-headers 'some)
8033 (eq gnus-fetch-old-headers 'invisible)
8034 (numberp gnus-fetch-old-headers)
8035 (eq gnus-build-sparse-threads 'some)
8036 (eq gnus-build-sparse-threads 'more))
8039 (setcar th (gnus-cut-thread (car th)))
8040 (setq th (cdr th)))))
8041 ;; Remove nixed out threads.
8044 (defun gnus-summary-initial-limit (&optional show-if-empty)
8045 "Figure out what the initial limit is supposed to be on group entry.
8046 This entails weeding out unwanted dormants, low-scored articles,
8047 fetch-old-headers verbiage, and so on."
8048 ;; Most groups have nothing to remove.
8049 (if (or gnus-inhibit-limiting
8050 (and (null gnus-newsgroup-dormant)
8051 (eq gnus-newsgroup-display 'gnus-not-ignore)
8052 (not (eq gnus-fetch-old-headers 'some))
8053 (not (numberp gnus-fetch-old-headers))
8054 (not (eq gnus-fetch-old-headers 'invisible))
8055 (null gnus-summary-expunge-below)
8056 (not (eq gnus-build-sparse-threads 'some))
8057 (not (eq gnus-build-sparse-threads 'more))
8058 (null gnus-thread-expunge-below)
8059 (not gnus-use-nocem)))
8061 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8062 (setq gnus-newsgroup-limit nil)
8065 (unless (car (symbol-value node))
8066 ;; These threads have no parents -- they are roots.
8067 (let ((nodes (cdr (symbol-value node)))
8070 (if (and gnus-thread-expunge-below
8071 (< (gnus-thread-total-score (car nodes))
8072 gnus-thread-expunge-below))
8073 (gnus-expunge-thread (pop nodes))
8074 (setq thread (pop nodes))
8075 (gnus-summary-limit-children thread))))))
8076 gnus-newsgroup-dependencies)
8077 ;; If this limitation resulted in an empty group, we might
8078 ;; pop the previous limit and use it instead.
8079 (when (and (not gnus-newsgroup-limit)
8081 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8082 gnus-newsgroup-limit))
8084 (defun gnus-summary-limit-children (thread)
8085 "Return 1 if this subthread is visible and 0 if it is not."
8086 ;; First we get the number of visible children to this thread. This
8087 ;; is done by recursing down the thread using this function, so this
8088 ;; will really go down to a leaf article first, before slowly
8089 ;; working its way up towards the root.
8091 (let* ((max-lisp-eval-depth 5000)
8094 (apply '+ (mapcar 'gnus-summary-limit-children
8097 (number (mail-header-number (car thread)))
8100 (not (memq number gnus-newsgroup-marked))
8102 ;; If this article is dormant and has absolutely no visible
8103 ;; children, then this article isn't visible.
8104 (and (memq number gnus-newsgroup-dormant)
8106 ;; If this is "fetch-old-headered" and there is no
8107 ;; visible children, then we don't want this article.
8108 (and (or (eq gnus-fetch-old-headers 'some)
8109 (numberp gnus-fetch-old-headers))
8110 (gnus-summary-article-ancient-p number)
8112 ;; If this is "fetch-old-headered" and `invisible', then
8113 ;; we don't want this article.
8114 (and (eq gnus-fetch-old-headers 'invisible)
8115 (gnus-summary-article-ancient-p number))
8116 ;; If this is a sparsely inserted article with no children,
8117 ;; we don't want it.
8118 (and (eq gnus-build-sparse-threads 'some)
8119 (gnus-summary-article-sparse-p number)
8121 ;; If we use expunging, and this article is really
8122 ;; low-scored, then we don't want this article.
8123 (when (and gnus-summary-expunge-below
8125 (or (cdr (assq number gnus-newsgroup-scored))
8126 gnus-summary-default-score))
8127 gnus-summary-expunge-below))
8128 ;; We increase the expunge-tally here, but that has
8129 ;; nothing to do with the limits, really.
8130 (incf gnus-newsgroup-expunged-tally)
8131 ;; We also mark as read here, if that's wanted.
8132 (when (and gnus-summary-mark-below
8133 (< score gnus-summary-mark-below))
8134 (setq gnus-newsgroup-unreads
8135 (delq number gnus-newsgroup-unreads))
8136 (if gnus-newsgroup-auto-expire
8137 (push number gnus-newsgroup-expirable)
8138 (push (cons number gnus-low-score-mark)
8139 gnus-newsgroup-reads)))
8141 ;; Do the `display' group parameter.
8142 (and gnus-newsgroup-display
8143 (not (funcall gnus-newsgroup-display)))
8144 ;; Check NoCeM things.
8145 (when (and gnus-use-nocem
8146 (gnus-nocem-unwanted-article-p
8147 (mail-header-id (car thread))))
8148 (setq gnus-newsgroup-unreads
8149 (delq number gnus-newsgroup-unreads))
8151 ;; Nope, invisible article.
8153 ;; Ok, this article is to be visible, so we add it to the limit
8155 (push number gnus-newsgroup-limit)
8158 (defun gnus-expunge-thread (thread)
8159 "Mark all articles in THREAD as read."
8160 (let* ((number (mail-header-number (car thread))))
8161 (incf gnus-newsgroup-expunged-tally)
8162 ;; We also mark as read here, if that's wanted.
8163 (setq gnus-newsgroup-unreads
8164 (delq number gnus-newsgroup-unreads))
8165 (if gnus-newsgroup-auto-expire
8166 (push number gnus-newsgroup-expirable)
8167 (push (cons number gnus-low-score-mark)
8168 gnus-newsgroup-reads)))
8169 ;; Go recursively through all subthreads.
8170 (mapcar 'gnus-expunge-thread (cdr thread)))
8172 ;; Summary article oriented commands
8174 (defun gnus-summary-refer-parent-article (n)
8175 "Refer parent article N times.
8176 If N is negative, go to ancestor -N instead.
8177 The difference between N and the number of articles fetched is returned."
8181 (when (not (natnump n))
8186 (setq header (gnus-summary-article-header))
8187 (if (and (eq (mail-header-number header)
8188 (cdr gnus-article-current))
8189 (equal gnus-newsgroup-name
8190 (car gnus-article-current)))
8191 ;; If we try to find the parent of the currently
8192 ;; displayed article, then we take a look at the actual
8193 ;; References header, since this is slightly more
8194 ;; reliable than the References field we got from the
8197 (set-buffer gnus-original-article-buffer)
8198 (nnheader-narrow-to-headers)
8199 (unless (setq ref (message-fetch-field "references"))
8200 (when (setq ref (message-fetch-field "in-reply-to"))
8201 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8204 ;; It's not the current article, so we take a bet on
8205 ;; the value we got from the server.
8206 (mail-header-references header)))
8208 (not (equal ref "")))
8209 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8210 (gnus-message 1 "Couldn't find parent"))
8211 (gnus-message 1 "No references in article %d"
8212 (gnus-summary-article-number))
8215 (gnus-summary-position-point)
8218 (defun gnus-summary-refer-references ()
8219 "Fetch all articles mentioned in the References header.
8220 Return the number of articles fetched."
8222 (let ((ref (mail-header-references (gnus-summary-article-header)))
8223 (current (gnus-summary-article-number))
8227 (error "No References in the current article")
8228 ;; For each Message-ID in the References header...
8229 (while (string-match "<[^>]*>" ref)
8231 ;; ... fetch that article.
8232 (gnus-summary-refer-article
8233 (prog1 (match-string 0 ref)
8234 (setq ref (substring ref (match-end 0))))))
8235 (gnus-summary-goto-subject current)
8236 (gnus-summary-position-point)
8239 (defun gnus-summary-refer-thread (&optional limit)
8240 "Fetch all articles in the current thread.
8241 If LIMIT (the numerical prefix), fetch that many old headers instead
8242 of what's specified by the `gnus-refer-thread-limit' variable."
8244 (let ((id (mail-header-id (gnus-summary-article-header)))
8245 (limit (if limit (prefix-numeric-value limit)
8246 gnus-refer-thread-limit)))
8247 (unless (eq gnus-fetch-old-headers 'invisible)
8248 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8249 ;; Retrieve the headers and read them in.
8250 (if (eq (if (numberp limit)
8251 (gnus-retrieve-headers
8253 (+ (mail-header-number
8254 (gnus-summary-article-header))
8256 gnus-newsgroup-end))
8257 gnus-newsgroup-name (* limit 2))
8258 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8260 (gnus-retrieve-headers (list gnus-newsgroup-end)
8261 gnus-newsgroup-name limit))
8263 (gnus-build-all-threads)
8264 (error "Can't fetch thread from back ends that don't support NOV"))
8265 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8266 (gnus-summary-limit-include-thread id)))
8268 (defun gnus-summary-refer-article (message-id)
8269 "Fetch an article specified by MESSAGE-ID."
8270 (interactive "sMessage-ID: ")
8271 (when (and (stringp message-id)
8272 (not (zerop (length message-id))))
8273 (setq message-id (gnus-replace-in-string message-id " " ""))
8274 ;; Construct the correct Message-ID if necessary.
8275 ;; Suggested by tale@pawl.rpi.edu.
8276 (unless (string-match "^<" message-id)
8277 (setq message-id (concat "<" message-id)))
8278 (unless (string-match ">$" message-id)
8279 (setq message-id (concat message-id ">")))
8280 ;; People often post MIDs from URLs, so unhex it:
8281 (unless (string-match "@" message-id)
8282 (setq message-id (gnus-url-unhex-string message-id)))
8283 (let* ((header (gnus-id-to-header message-id))
8285 (gnus-summary-article-sparse-p
8286 (mail-header-number header))
8287 (memq (mail-header-number header)
8288 gnus-newsgroup-limit)))
8291 ;; If the article is present in the buffer we just go to it.
8293 (or (not (gnus-summary-article-sparse-p
8294 (mail-header-number header)))
8297 (gnus-summary-goto-article
8298 (mail-header-number header) nil t)
8300 (gnus-summary-update-article (mail-header-number header)))))
8302 ;; We fetch the article.
8304 (dolist (gnus-override-method (gnus-refer-article-methods))
8305 (when (and (gnus-check-server gnus-override-method)
8306 ;; Fetch the header,
8307 (setq number (gnus-summary-insert-subject message-id)))
8308 ;; and display the article.
8309 (gnus-summary-select-article nil nil nil number)
8311 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8313 (defun gnus-refer-article-methods ()
8314 "Return a list of referable methods."
8316 ;; No method, so we default to current and native.
8317 ((null gnus-refer-article-method)
8318 (list gnus-current-select-method gnus-select-method))
8320 ((eq 'current gnus-refer-article-method)
8321 (list gnus-current-select-method))
8322 ;; List of select methods.
8323 ((not (and (symbolp (car gnus-refer-article-method))
8324 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8326 (dolist (method gnus-refer-article-method)
8327 (push (if (eq 'current method)
8328 gnus-current-select-method
8332 ;; One single select method.
8334 (list gnus-refer-article-method))))
8336 (defun gnus-summary-edit-parameters ()
8337 "Edit the group parameters of the current group."
8339 (gnus-group-edit-group gnus-newsgroup-name 'params))
8341 (defun gnus-summary-customize-parameters ()
8342 "Customize the group parameters of the current group."
8344 (gnus-group-customize gnus-newsgroup-name))
8346 (defun gnus-summary-enter-digest-group (&optional force)
8347 "Enter an nndoc group based on the current article.
8348 If FORCE, force a digest interpretation. If not, try
8349 to guess what the document format is."
8351 (let ((conf gnus-current-window-configuration))
8352 (save-window-excursion
8354 (let (gnus-article-prepare-hook
8355 gnus-display-mime-function
8357 (gnus-summary-select-article))))
8358 (setq gnus-current-window-configuration conf)
8359 (let* ((name (format "%s-%d"
8360 (gnus-group-prefixed-name
8361 gnus-newsgroup-name (list 'nndoc ""))
8362 (with-current-buffer gnus-summary-buffer
8363 gnus-current-article)))
8364 (ogroup gnus-newsgroup-name)
8365 (params (append (gnus-info-params (gnus-get-info ogroup))
8366 (list (cons 'to-group ogroup))
8367 (list (cons 'parent-group ogroup))
8368 (list (cons 'save-article-group ogroup))))
8369 (case-fold-search t)
8370 (buf (current-buffer))
8373 (set-buffer gnus-original-article-buffer)
8374 ;; Have the digest group inherit the main mail address of
8375 ;; the parent article.
8376 (when (setq to-address (or (gnus-fetch-field "reply-to")
8377 (gnus-fetch-field "from")))
8378 (setq params (append
8379 (list (cons 'to-address
8380 (funcall gnus-decode-encoded-word-function
8382 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8383 (insert-buffer-substring gnus-original-article-buffer)
8384 ;; Remove lines that may lead nndoc to misinterpret the
8387 (goto-char (point-min))
8388 (or (search-forward "\n\n" nil t) (point)))
8389 (goto-char (point-min))
8390 (delete-matching-lines "^Path:\\|^From ")
8393 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8394 (gnus-newsgroup-ephemeral-ignored-charsets
8395 gnus-newsgroup-ignored-charsets))
8396 (gnus-group-read-ephemeral-group
8397 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8399 ,(if force 'mbox 'guess)))
8401 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8403 ;; Make all postings to this group go to the parent group.
8404 (nconc (gnus-info-params (gnus-get-info name))
8406 ;; Couldn't select this doc group.
8407 (switch-to-buffer buf)
8408 (gnus-set-global-variables)
8409 (gnus-configure-windows 'summary)
8410 (gnus-message 3 "Article couldn't be entered?"))
8411 (kill-buffer dig)))))
8413 (defun gnus-summary-read-document (n)
8414 "Open a new group based on the current article(s).
8415 This will allow you to read digests and other similar
8416 documents as newsgroups.
8417 Obeys the standard process/prefix convention."
8419 (let* ((ogroup gnus-newsgroup-name)
8420 (params (append (gnus-info-params (gnus-get-info ogroup))
8421 (list (cons 'to-group ogroup))))
8422 group egroup groups vgroup)
8423 (dolist (article (gnus-summary-work-articles n))
8424 (setq group (format "%s-%d" gnus-newsgroup-name article))
8425 (gnus-summary-remove-process-mark article)
8426 (when (gnus-summary-display-article article)
8429 (insert-buffer-substring gnus-original-article-buffer)
8430 ;; Remove some headers that may lead nndoc to make
8432 (message-narrow-to-head)
8433 (goto-char (point-min))
8434 (delete-matching-lines "^Path:\\|^From ")
8437 (gnus-group-read-ephemeral-group
8438 group `(nndoc ,group (nndoc-address ,(current-buffer))
8439 (nndoc-article-type guess))
8442 ;; Make all postings to this group go to the parent group.
8443 (nconc (gnus-info-params (gnus-get-info egroup))
8445 (push egroup groups))
8446 ;; Couldn't select this doc group.
8447 (gnus-error 3 "Article couldn't be entered"))))))
8448 ;; Now we have selected all the documents.
8451 (error "None of the articles could be interpreted as documents"))
8452 ((gnus-group-read-ephemeral-group
8453 (setq vgroup (format
8454 "nnvirtual:%s-%s" gnus-newsgroup-name
8455 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8456 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8458 (cons (current-buffer) 'summary)))
8460 (error "Couldn't select virtual nndoc group")))))
8462 (defun gnus-summary-isearch-article (&optional regexp-p)
8463 "Do incremental search forward on the current article.
8464 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8466 (let* ((gnus-inhibit-treatment t)
8467 (old (gnus-summary-select-article)))
8468 (gnus-configure-windows 'article)
8469 (gnus-eval-in-buffer-window gnus-article-buffer
8473 (gnus-article-show-all-headers))
8474 (goto-char (point-min))
8475 (isearch-forward regexp-p)))))
8477 (defun gnus-summary-search-article-forward (regexp &optional backward)
8478 "Search for an article containing REGEXP forward.
8479 If BACKWARD, search backward instead."
8482 (format "Search article %s (regexp%s): "
8483 (if current-prefix-arg "backward" "forward")
8484 (if gnus-last-search-regexp
8485 (concat ", default " gnus-last-search-regexp)
8487 current-prefix-arg))
8488 (if (string-equal regexp "")
8489 (setq regexp (or gnus-last-search-regexp ""))
8490 (setq gnus-last-search-regexp regexp)
8491 (setq gnus-article-before-search gnus-current-article))
8492 ;; Intentionally set gnus-last-article.
8493 (setq gnus-last-article gnus-article-before-search)
8494 (let ((gnus-last-article gnus-last-article))
8495 (if (gnus-summary-search-article regexp backward)
8496 (gnus-summary-show-thread)
8497 (signal 'search-failed (list regexp)))))
8499 (defun gnus-summary-search-article-backward (regexp)
8500 "Search for an article containing REGEXP backward."
8503 (format "Search article backward (regexp%s): "
8504 (if gnus-last-search-regexp
8505 (concat ", default " gnus-last-search-regexp)
8507 (gnus-summary-search-article-forward regexp 'backward))
8510 (defmacro gnus-summary-search-article-position-point (regexp backward)
8511 "Dehighlight the last matched text and goto the beginning position."
8512 (` (if (and gnus-summary-search-article-matched-data
8513 (let ((text (caddr gnus-summary-search-article-matched-data))
8514 (inhibit-read-only t)
8517 (goto-char (car gnus-summary-search-article-matched-data))
8518 (cadr gnus-summary-search-article-matched-data))
8520 (string-match (, regexp) text)))
8521 (if (, backward) (beginning-of-line) (end-of-line))
8522 (goto-char (if (, backward) (point-max) (point-min))))))
8524 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8525 "Place point where X-Face image is displayed."
8526 (if (featurep 'xemacs)
8527 (` (let ((end (if (search-forward "\n\n" nil t)
8528 (goto-char (1- (point)))
8531 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8532 (unless (and (re-search-forward "^From:" end t)
8533 (setq extent (extent-at (point)))
8534 (extent-begin-glyph extent))
8535 (goto-char (, opoint)))))
8536 (` (let ((end (if (search-forward "\n\n" nil t)
8537 (goto-char (1- (point)))
8539 (start (or (search-backward "\n\n" nil t) (point-min))))
8541 (or (text-property-any start end 'x-face-image t);; x-face-e21
8542 (text-property-any start end 'x-face-mule-bitmap-image t)
8545 (defmacro gnus-summary-search-article-highlight-matched-text
8546 (backward treated x-face)
8547 "Highlight matched text in the function `gnus-summary-search-article'."
8548 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8549 (end (set-marker (make-marker) (match-end 0)))
8550 (inhibit-read-only t)
8554 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8556 (lambda (item) (setq items (delq item items)))
8557 '(gnus-treat-buttonize
8558 gnus-treat-fill-article
8559 gnus-treat-fill-long-lines
8560 gnus-treat-emphasize
8561 gnus-treat-highlight-headers
8562 gnus-treat-highlight-citation
8563 gnus-treat-highlight-signature
8564 gnus-treat-overstrike
8565 gnus-treat-display-x-face
8566 gnus-treat-buttonize-head
8567 gnus-treat-decode-article-as-default-mime-charset))
8568 (static-if (featurep 'xemacs)
8570 (cons '(x-face-mule-delete-x-face-field
8573 (gnus-treat-display-x-face
8574 (when (, x-face) gnus-treat-display-x-face)))
8575 (gnus-article-prepare-mime-display)))
8576 (goto-char (if (, backward) start end))
8578 (gnus-summary-search-article-highlight-goto-x-face (point)))
8579 (setq gnus-summary-search-article-matched-data
8580 (list start end (buffer-substring start end)))
8581 (unless (eq start end);; matched text has been deleted. :-<
8582 (put-text-property start end 'face
8583 (or (find-face 'isearch)
8584 'secondary-selection))))))
8587 (defun gnus-summary-search-article (regexp &optional backward)
8588 "Search for an article containing REGEXP.
8589 Optional argument BACKWARD means do search for backward.
8590 `gnus-select-article-hook' is not called during the search."
8591 ;; We have to require this here to make sure that the following
8592 ;; dynamic binding isn't shadowed by autoloading.
8593 (require 'gnus-async)
8595 (let ((gnus-select-article-hook nil) ;Disable hook.
8596 (gnus-article-prepare-hook nil)
8597 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8598 (gnus-use-article-prefetch nil)
8599 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8600 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8602 (gnus-keep-backlog nil)
8603 (gnus-break-pages nil)
8604 (gnus-summary-display-arrow nil)
8605 (gnus-updated-mode-lines nil)
8606 (gnus-auto-center-summary nil)
8607 (sum (current-buffer))
8610 (gnus-save-hidden-threads
8611 (static-if (featurep 'xemacs)
8612 (let ((gnus-inhibit-treatment t))
8613 (setq treated (eq 'old (gnus-summary-select-article)))
8615 (not (and (gnus-buffer-live-p gnus-article-buffer)
8616 (window-live-p (get-buffer-window
8617 gnus-article-buffer t)))))
8618 (gnus-summary-select-article nil t)
8619 (setq treated nil)))
8620 (let ((gnus-inhibit-treatment t)
8621 (x-face-mule-delete-x-face-field 'never))
8622 (setq treated (eq 'old (gnus-summary-select-article)))
8625 (and (gnus-buffer-live-p gnus-article-buffer)
8626 (window-live-p (get-buffer-window
8627 gnus-article-buffer t))
8628 (or (not (string-match "^\\^X-Face:" regexp))
8629 (with-current-buffer gnus-article-buffer
8630 gnus-summary-search-article-matched-data)))))
8631 (gnus-summary-select-article nil t)
8632 (setq treated nil))))
8633 (set-buffer gnus-article-buffer)
8637 (gnus-article-show-all-headers)
8638 (gnus-summary-search-article-position-point regexp backward))
8639 (goto-char (if backward (point-max) (point-min))))
8641 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8643 (re-search-backward regexp nil t)
8644 (re-search-forward regexp nil t))
8645 ;; We found the regexp.
8647 (gnus-summary-search-article-highlight-matched-text
8648 backward treated (string-match "^\\^X-Face:" regexp))
8651 (/ (- 2 (window-height
8652 (get-buffer-window gnus-article-buffer t)))
8655 (get-buffer-window (current-buffer))
8658 (setq point (point)))
8659 ;; We didn't find it, so we go to the next article.
8662 (while (eq found 'not)
8663 (if (not (if backward (gnus-summary-find-prev)
8664 (gnus-summary-find-next)))
8665 ;; No more articles.
8667 ;; Select the next article and adjust point.
8668 (unless (gnus-summary-article-sparse-p
8669 (gnus-summary-article-number))
8671 (let ((gnus-inhibit-treatment t))
8672 (gnus-summary-select-article))
8674 (set-buffer gnus-article-buffer)
8676 (goto-char (if backward (point-max) (point-min))))))))
8677 (gnus-message 7 ""))
8678 ;; Return whether we found the regexp.
8679 (when (eq found 'found)
8681 (gnus-summary-show-thread)
8682 (gnus-summary-goto-subject gnus-current-article)
8683 (gnus-summary-position-point)
8686 (defun gnus-find-matching-articles (header regexp)
8687 "Return a list of all articles that match REGEXP on HEADER.
8688 This search includes all articles in the current group that Gnus has
8689 fetched headers for, whether they are displayed or not."
8690 (let ((articles nil)
8691 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8692 (case-fold-search t))
8693 (dolist (header gnus-newsgroup-headers)
8694 (when (string-match regexp (funcall func header))
8695 (push (mail-header-number header) articles)))
8696 (nreverse articles)))
8698 (defun gnus-summary-find-matching (header regexp &optional backward unread
8699 not-case-fold not-matching)
8700 "Return a list of all articles that match REGEXP on HEADER.
8701 The search stars on the current article and goes forwards unless
8702 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8703 If UNREAD is non-nil, only unread articles will
8704 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8705 in the comparisons. If NOT-MATCHING, return a list of all articles that
8706 not match REGEXP on HEADER."
8707 (let ((case-fold-search (not not-case-fold))
8710 (if (eq (car header) 'extra)
8713 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8715 (error "%s is an invalid header" header))
8716 (unless (fboundp (intern (concat "mail-header-" header)))
8717 (error "%s is not a valid header" header))
8718 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8719 (dolist (d (if (eq backward 'all)
8721 (gnus-data-find-list
8722 (gnus-summary-article-number)
8723 (gnus-data-list backward))))
8724 (when (and (or (not unread) ; We want all articles...
8725 (gnus-data-unread-p d)) ; Or just unreads.
8726 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8730 (funcall func (gnus-data-header d))))
8731 (string-match regexp
8732 (funcall func (gnus-data-header d)))))
8733 (push (gnus-data-number d) articles))) ; Success!
8734 (nreverse articles)))
8736 (defun gnus-summary-execute-command (header regexp command &optional backward)
8737 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8738 If HEADER is an empty string (or nil), the match is done on the entire
8739 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8741 (list (let ((completion-ignore-case t))
8744 (mapcar (lambda (header) (list (format "%s" header)))
8746 '("Number" "Subject" "From" "Lines" "Date"
8747 "Message-ID" "Xref" "References" "Body")
8748 gnus-extra-headers))
8749 nil 'require-match))
8750 (read-string "Regexp: ")
8751 (read-key-sequence "Command: ")
8752 current-prefix-arg))
8753 (when (equal header "Body")
8755 ;; Hidden thread subtrees must be searched as well.
8756 (gnus-summary-show-all-threads)
8757 ;; We don't want to change current point nor window configuration.
8759 (save-window-excursion
8761 gnus-treat-strip-trailing-blank-lines
8762 gnus-treat-strip-leading-blank-lines
8763 gnus-treat-strip-multiple-blank-lines
8764 gnus-treat-hide-boring-headers
8765 gnus-treat-fold-newsgroups
8766 gnus-article-prepare-hook)
8767 (gnus-message 6 "Executing %s..." (key-description command))
8768 ;; We'd like to execute COMMAND interactively so as to give arguments.
8769 (gnus-execute header regexp
8770 `(call-interactively ',(key-binding command))
8772 (gnus-message 6 "Executing %s...done" (key-description command))))))
8774 (defun gnus-summary-beginning-of-article ()
8775 "Scroll the article back to the beginning."
8777 (gnus-summary-select-article)
8778 (gnus-configure-windows 'article)
8779 (gnus-eval-in-buffer-window gnus-article-buffer
8781 (goto-char (point-min))
8782 (when gnus-break-pages
8783 (gnus-narrow-to-page))))
8785 (defun gnus-summary-end-of-article ()
8786 "Scroll to the end of the article."
8788 (gnus-summary-select-article)
8789 (gnus-configure-windows 'article)
8790 (gnus-eval-in-buffer-window gnus-article-buffer
8792 (goto-char (point-max))
8794 (when gnus-break-pages
8795 (when (re-search-backward page-delimiter nil t)
8796 (narrow-to-region (match-end 0) (point-max)))
8797 (gnus-narrow-to-page))))
8799 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8800 "Truncate to LEN and quote all \"(\"'s in STRING."
8801 (gnus-replace-in-string (if (and len (> (length string) len))
8802 (substring string 0 len)
8806 (defun gnus-summary-print-article (&optional filename n)
8807 "Generate and print a PostScript image of the process-marked (mail) articles.
8809 If used interactively, print the current article if none are
8810 process-marked. With prefix arg, prompt the user for the name of the
8813 When used from Lisp, accept two optional args FILENAME and N. N means
8814 to print the next N articles. If N is negative, print the N previous
8815 articles. If N is nil and articles have been marked with the process
8816 mark, print these instead.
8818 If the optional first argument FILENAME is nil, send the image to the
8819 printer. If FILENAME is a string, save the PostScript image in a file with
8820 that name. If FILENAME is a number, prompt the user for the name of the file
8822 (interactive (list (ps-print-preprint current-prefix-arg)))
8823 (dolist (article (gnus-summary-work-articles n))
8824 (gnus-summary-select-article nil nil 'pseudo article)
8825 (gnus-eval-in-buffer-window gnus-article-buffer
8826 (gnus-print-buffer))
8827 (gnus-summary-remove-process-mark article))
8828 (ps-despool filename))
8830 (defun gnus-print-buffer ()
8831 (let ((buffer (generate-new-buffer " *print*")))
8834 (copy-to-buffer buffer (point-min) (point-max))
8836 (gnus-remove-text-with-property 'gnus-decoration)
8837 (when (gnus-visual-p 'article-highlight 'highlight)
8838 ;; Copy-to-buffer doesn't copy overlay. So redo
8840 (let ((gnus-article-buffer buffer))
8841 (gnus-article-highlight-citation t)
8842 (gnus-article-highlight-signature)
8843 (gnus-article-emphasize)
8844 (gnus-article-delete-invisible-text)))
8845 (let ((ps-left-header
8848 (gnus-summary-print-truncate-and-quote
8849 (mail-header-subject gnus-current-headers)
8852 (gnus-summary-print-truncate-and-quote
8853 (mail-header-from gnus-current-headers)
8857 "/pagenumberstring load"
8859 (mail-header-date gnus-current-headers) ")"))))
8860 (gnus-run-hooks 'gnus-ps-print-hook)
8863 (ps-spool-buffer-with-faces)
8864 (ps-spool-buffer)))))
8865 (kill-buffer buffer))))
8867 (defun gnus-summary-show-article (&optional arg)
8868 "Force redisplaying of the current article.
8869 If ARG (the prefix) is a number, show the article with the charset
8870 defined in `gnus-summary-show-article-charset-alist', or the charset
8872 If ARG (the prefix) is non-nil and not a number, show the raw article
8873 without any article massaging functions being run. Normally, the key
8874 strokes are `C-u g'."
8878 (gnus-summary-show-article t)
8879 (let* ((gnus-newsgroup-charset
8880 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8881 (mm-read-coding-system
8882 "View as charset: " ;; actually it is coding system.
8883 (with-current-buffer gnus-article-buffer
8884 (mm-detect-coding-region (point) (point-max))))))
8885 (default-mime-charset gnus-newsgroup-charset)
8886 (gnus-newsgroup-ignored-charsets 'gnus-all))
8887 (gnus-summary-select-article nil 'force)
8888 (let ((deps gnus-newsgroup-dependencies)
8891 (set-buffer gnus-original-article-buffer)
8893 (message-narrow-to-head)
8894 (setq head (buffer-string))
8895 (goto-char (point-min))
8896 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8897 (goto-char (point-max))
8899 (setq lines (1- (count-lines (point) (point-max))))))
8901 (insert (format "211 %d Article retrieved.\n"
8902 (cdr gnus-article-current)))
8904 (if lines (insert (format "Lines: %d\n" lines)))
8906 (let ((nntp-server-buffer (current-buffer)))
8907 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8908 (gnus-data-set-header
8909 (gnus-data-find (cdr gnus-article-current))
8911 (gnus-summary-update-article-line
8912 (cdr gnus-article-current) header)
8913 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8914 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8916 ;; Select the article the normal way.
8917 (gnus-summary-select-article nil 'force))
8919 ;; We have to require this here to make sure that the following
8920 ;; dynamic binding isn't shadowed by autoloading.
8921 (require 'gnus-async)
8923 ;; Bind the article treatment functions to nil.
8924 (let ((gnus-have-all-headers t)
8925 gnus-article-prepare-hook
8926 gnus-article-decode-hook
8929 (gnus-inhibit-treatment t))
8930 (gnus-summary-select-article nil 'force))))
8931 (gnus-summary-goto-subject gnus-current-article)
8932 (gnus-summary-position-point))
8934 (defun gnus-summary-show-raw-article ()
8935 "Show the raw article without any article massaging functions being run."
8937 (gnus-summary-show-article t))
8939 (defun gnus-summary-verbose-headers (&optional arg)
8940 "Toggle permanent full header display.
8941 If ARG is a positive number, turn header display on.
8942 If ARG is a negative number, turn header display off."
8944 (setq gnus-show-all-headers
8945 (cond ((or (not (numberp arg))
8947 (not gnus-show-all-headers))
8950 (gnus-summary-show-article))
8952 (defun gnus-summary-toggle-header (&optional arg)
8953 "Show the headers if they are hidden, or hide them if they are shown.
8954 If ARG is a positive number, show the entire header.
8955 If ARG is a negative number, hide the unwanted header lines."
8957 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8958 (get-buffer-window gnus-article-buffer t))))
8959 (with-current-buffer gnus-article-buffer
8961 (article-narrow-to-head)
8962 (let* ((buffer-read-only nil)
8963 (inhibit-point-motion-hooks t)
8964 (hidden (if (numberp arg)
8966 (or (not (looking-at "[^ \t\n]+:"))
8967 (gnus-article-hidden-text-p 'headers))))
8969 (delete-region (point-min) (point-max))
8970 (with-current-buffer gnus-original-article-buffer
8971 (goto-char (setq s (point-min)))
8972 (setq e (if (search-forward "\n\n" nil t)
8975 (insert-buffer-substring gnus-original-article-buffer s e)
8976 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8977 ;; article-decode-encoded-words by default.
8978 (article-decode-encoded-words)
8979 (run-hooks 'gnus-article-decode-hook)
8981 (let ((gnus-treat-hide-headers nil)
8982 (gnus-treat-hide-boring-headers nil))
8983 (gnus-delete-wash-type 'headers)
8984 (gnus-treat-article 'head))
8985 (gnus-treat-article 'head))
8988 (set-window-start window (goto-char (point-min))))
8989 (if gnus-break-pages
8990 (gnus-narrow-to-page)
8991 (when (gnus-visual-p 'page-marker)
8992 (let ((buffer-read-only nil))
8993 (gnus-remove-text-with-property 'gnus-prev)
8994 (gnus-remove-text-with-property 'gnus-next))))
8995 (gnus-set-mode-line 'article)))))
8997 (defun gnus-summary-show-all-headers ()
8998 "Make all header lines visible."
9000 (gnus-summary-toggle-header 1))
9002 (defun gnus-summary-toggle-mime (&optional arg)
9003 "Toggle MIME processing.
9004 If ARG is a positive number, turn MIME processing on."
9006 (setq gnus-show-mime
9008 (not gnus-show-mime)
9009 (> (prefix-numeric-value arg) 0)))
9010 (gnus-summary-select-article t 'force))
9012 (defun gnus-summary-caesar-message (&optional arg)
9013 "Caesar rotate the current article by 13.
9014 The numerical prefix specifies how many places to rotate each letter
9017 (gnus-summary-select-article)
9018 (let ((mail-header-separator ""))
9019 (gnus-eval-in-buffer-window gnus-article-buffer
9022 (let ((start (window-start))
9024 (message-caesar-buffer-body arg)
9025 (set-window-start (get-buffer-window (current-buffer)) start))))))
9027 (autoload 'unmorse-region "morse"
9028 "Convert morse coded text in region to ordinary ASCII text."
9031 (defun gnus-summary-morse-message (&optional arg)
9032 "Morse decode the current article."
9034 (gnus-summary-select-article)
9035 (let ((mail-header-separator ""))
9036 (gnus-eval-in-buffer-window gnus-article-buffer
9040 (let ((pos (window-start))
9042 (goto-char (point-min))
9043 (when (message-goto-body)
9044 (gnus-narrow-to-body))
9045 (goto-char (point-min))
9046 (while (search-forward "·" (point-max) t)
9047 (replace-match "."))
9048 (unmorse-region (point-min) (point-max))
9050 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9052 (defun gnus-summary-stop-page-breaking ()
9053 "Stop page breaking in the current article."
9055 (gnus-summary-select-article)
9056 (gnus-eval-in-buffer-window gnus-article-buffer
9058 (when (gnus-visual-p 'page-marker)
9059 (let ((buffer-read-only nil))
9060 (gnus-remove-text-with-property 'gnus-prev)
9061 (gnus-remove-text-with-property 'gnus-next))
9062 (setq gnus-page-broken nil))))
9064 (defun gnus-summary-move-article (&optional n to-newsgroup
9065 select-method action)
9066 "Move the current article to a different newsgroup.
9067 If N is a positive number, move the N next articles.
9068 If N is a negative number, move the N previous articles.
9069 If N is nil and any articles have been marked with the process mark,
9070 move those articles instead.
9071 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9072 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9073 re-spool using this method.
9075 When called interactively with TO-NEWSGROUP being nil, the value of
9076 the variable `gnus-move-split-methods' is used for finding a default
9077 for the target newsgroup.
9079 For this function to work, both the current newsgroup and the
9080 newsgroup that you want to move to have to support the `request-move'
9081 and `request-accept' functions.
9083 ACTION can be either `move' (the default), `crosspost' or `copy'."
9086 (setq action 'move))
9087 ;; Check whether the source group supports the required functions.
9088 (cond ((and (eq action 'move)
9089 (not (gnus-check-backend-function
9090 'request-move-article gnus-newsgroup-name)))
9091 (error "The current group does not support article moving"))
9092 ((and (eq action 'crosspost)
9093 (not (gnus-check-backend-function
9094 'request-replace-article gnus-newsgroup-name)))
9095 (error "The current group does not support article editing")))
9096 (let ((articles (gnus-summary-work-articles n))
9097 (prefix (if (gnus-check-backend-function
9098 'request-move-article gnus-newsgroup-name)
9099 (funcall gnus-move-group-prefix-function
9100 gnus-newsgroup-name)
9102 (names '((move "Move" "Moving")
9103 (copy "Copy" "Copying")
9104 (crosspost "Crosspost" "Crossposting")))
9105 (copy-buf (save-excursion
9106 (nnheader-set-temp-buffer " *copy article*")))
9107 art-group to-method new-xref article to-groups)
9108 (unless (assq action names)
9109 (error "Unknown action %s" action))
9110 ;; Read the newsgroup name.
9111 (when (and (not to-newsgroup)
9112 (not select-method))
9113 (if (and gnus-move-split-methods
9115 (and (memq gnus-current-article articles)
9116 (gnus-buffer-live-p gnus-original-article-buffer))))
9117 ;; When `gnus-move-split-methods' is non-nil, we have to
9118 ;; select an article to give `gnus-read-move-group-name' an
9119 ;; opportunity to suggest an appropriate default. However,
9120 ;; we needn't render or mark the article.
9121 (let ((gnus-display-mime-function nil)
9122 (gnus-article-prepare-hook nil)
9123 (gnus-mark-article-hook nil))
9124 (gnus-summary-select-article nil nil nil (car articles))))
9126 (gnus-read-move-group-name
9127 (cadr (assq action names))
9128 (symbol-value (intern (format "gnus-current-%s-group" action)))
9130 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9131 (setq to-method (or select-method
9132 (gnus-server-to-method
9133 (gnus-group-method to-newsgroup))))
9134 ;; Check the method we are to move this article to...
9135 (unless (gnus-check-backend-function
9136 'request-accept-article (car to-method))
9137 (error "%s does not support article copying" (car to-method)))
9138 (unless (gnus-check-server to-method)
9139 (error "Can't open server %s" (car to-method)))
9140 (gnus-message 6 "%s to %s: %s..."
9141 (caddr (assq action names))
9142 (or (car select-method) to-newsgroup) articles)
9144 (setq article (pop articles))
9148 ;; Move the article.
9150 ;; Remove this article from future suppression.
9151 (gnus-dup-unsuppress-article article)
9152 (gnus-request-move-article
9153 article ; Article to move
9154 gnus-newsgroup-name ; From newsgroup
9155 (nth 1 (gnus-find-method-for-group
9156 gnus-newsgroup-name)) ; Server
9157 (list 'gnus-request-accept-article
9158 to-newsgroup (list 'quote select-method)
9159 (not articles) t) ; Accept form
9160 (not articles))) ; Only save nov last time
9161 ;; Copy the article.
9164 (set-buffer copy-buf)
9165 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9167 (nnheader-narrow-to-headers)
9168 (dolist (hdr gnus-copy-article-ignored-headers)
9169 (message-remove-header hdr t)))
9170 (gnus-request-accept-article
9171 to-newsgroup select-method (not articles) t))))
9172 ;; Crosspost the article.
9173 ((eq action 'crosspost)
9174 (let ((xref (message-tokenize-header
9175 (mail-header-xref (gnus-summary-article-header article))
9177 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9178 ":" (number-to-string article)))
9180 (setq xref (list (system-name))))
9183 (mapconcat 'identity
9184 (delete "Xref:" (delete new-xref xref))
9188 (set-buffer copy-buf)
9189 ;; First put the article in the destination group.
9190 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9191 (when (consp (setq art-group
9192 (gnus-request-accept-article
9193 to-newsgroup select-method (not articles))))
9194 (setq new-xref (concat new-xref " " (car art-group)
9196 (number-to-string (cdr art-group))))
9197 ;; Now we have the new Xrefs header, so we insert
9198 ;; it and replace the new article.
9199 (nnheader-replace-header "Xref" new-xref)
9200 (gnus-request-replace-article
9201 (cdr art-group) to-newsgroup (current-buffer))
9205 (gnus-message 1 "Couldn't %s article %s: %s"
9206 (cadr (assq action names)) article
9207 (nnheader-get-report (car to-method))))
9208 ((eq art-group 'junk)
9209 (when (eq action 'move)
9210 (gnus-summary-mark-article article gnus-canceled-mark)
9211 (gnus-message 4 "Deleted article %s" article)
9212 ;; run the delete hook
9213 (run-hook-with-args 'gnus-summary-article-delete-hook
9216 (assoc article (gnus-data-list nil)))
9217 gnus-newsgroup-name nil
9220 (let* ((pto-group (gnus-group-prefixed-name
9221 (car art-group) to-method))
9222 (info (gnus-get-info pto-group))
9223 (to-group (gnus-info-group info))
9225 ;; Update the group that has been moved to.
9227 (memq action '(move copy)))
9228 (unless (member to-group to-groups)
9229 (push to-group to-groups))
9231 (unless (memq article gnus-newsgroup-unreads)
9232 (push 'read to-marks)
9234 info (gnus-add-to-range (gnus-info-read info)
9235 (list (cdr art-group)))))
9237 ;; See whether the article is to be put in the cache.
9238 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9239 gnus-article-mark-lists
9240 (delete '(expirable . expire)
9241 (copy-sequence gnus-article-mark-lists))))
9242 (to-article (cdr art-group)))
9244 ;; Enter the article into the cache in the new group,
9245 ;; if that is required.
9246 (when gnus-use-cache
9247 (gnus-cache-possibly-enter-article
9249 (let ((header (copy-sequence
9250 (gnus-summary-article-header article))))
9251 (mail-header-set-number header to-article)
9253 (memq article gnus-newsgroup-marked)
9254 (memq article gnus-newsgroup-dormant)
9255 (memq article gnus-newsgroup-unreads)))
9257 (when gnus-preserve-marks
9258 ;; Copy any marks over to the new group.
9259 (when (and (equal to-group gnus-newsgroup-name)
9260 (not (memq article gnus-newsgroup-unreads)))
9261 ;; Mark this article as read in this group.
9262 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9263 (setcdr (gnus-active to-group) to-article)
9264 (setcdr gnus-newsgroup-active to-article))
9267 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9268 (when (memq article (symbol-value
9269 (intern (format "gnus-newsgroup-%s"
9271 (push (cdar marks) to-marks)
9272 ;; If the other group is the same as this group,
9273 ;; then we have to add the mark to the list.
9274 (when (equal to-group gnus-newsgroup-name)
9275 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9278 (intern (format "gnus-newsgroup-%s"
9280 ;; Copy the marks to other group.
9281 (gnus-add-marked-articles
9282 to-group (cdar marks) (list to-article) info)))
9283 (setq marks (cdr marks)))
9285 (gnus-request-set-mark
9286 to-group (list (list (list to-article) 'add to-marks))))
9289 (concat "(gnus-group-set-info '"
9290 (gnus-prin1-to-string (gnus-get-info to-group))
9293 ;; Update the Xref header in this article to point to
9294 ;; the new crossposted article we have just created.
9295 (when (eq action 'crosspost)
9297 (set-buffer copy-buf)
9298 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9299 (nnheader-replace-header "Xref" new-xref)
9300 (gnus-request-replace-article
9301 article gnus-newsgroup-name (current-buffer))))
9303 ;; run the move/copy/crosspost/respool hook
9304 (run-hook-with-args 'gnus-summary-article-move-hook
9307 (assoc article (gnus-data-list nil)))
9312 ;;;!!!Why is this necessary?
9313 (set-buffer gnus-summary-buffer)
9315 (gnus-summary-goto-subject article)
9316 (when (eq action 'move)
9317 (gnus-summary-mark-article article gnus-canceled-mark))))
9318 (gnus-summary-remove-process-mark article))
9319 ;; Re-activate all groups that have been moved to.
9321 (set-buffer gnus-group-buffer)
9322 (let ((gnus-group-marked to-groups))
9323 (gnus-group-get-new-news-this-group nil t)))
9325 (gnus-kill-buffer copy-buf)
9326 (gnus-summary-position-point)
9327 (gnus-set-mode-line 'summary)))
9329 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9330 "Copy the current article to some other group.
9331 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9332 When called interactively, if TO-NEWSGROUP is nil, use the value of
9333 the variable `gnus-move-split-methods' for finding a default target
9335 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9336 re-spool using this method."
9338 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9340 (defun gnus-summary-crosspost-article (&optional n)
9341 "Crosspost the current article to some other group."
9343 (gnus-summary-move-article n nil nil 'crosspost))
9345 (defcustom gnus-summary-respool-default-method nil
9346 "Default method type for respooling an article.
9347 If nil, use to the current newsgroup method."
9349 :group 'gnus-summary-mail)
9351 (defcustom gnus-summary-display-while-building nil
9352 "If non-nil, show and update the summary buffer as it's being built.
9353 If the value is t, update the buffer after every line is inserted. If
9354 the value is an integer (N), update the display every N lines."
9357 :type '(choice (const :tag "off" nil)
9359 (const :tag "frequently" t)))
9361 (defun gnus-summary-respool-article (&optional n method)
9362 "Respool the current article.
9363 The article will be squeezed through the mail spooling process again,
9364 which means that it will be put in some mail newsgroup or other
9365 depending on `nnmail-split-methods'.
9366 If N is a positive number, respool the N next articles.
9367 If N is a negative number, respool the N previous articles.
9368 If N is nil and any articles have been marked with the process mark,
9369 respool those articles instead.
9371 Respooling can be done both from mail groups and \"real\" newsgroups.
9372 In the former case, the articles in question will be moved from the
9373 current group into whatever groups they are destined to. In the
9374 latter case, they will be copied into the relevant groups."
9376 (list current-prefix-arg
9377 (let* ((methods (gnus-methods-using 'respool))
9379 (symbol-name (or gnus-summary-respool-default-method
9380 (car (gnus-find-method-for-group
9381 gnus-newsgroup-name)))))
9383 (gnus-completing-read-with-default
9384 methname "What backend do you want to use when respooling?"
9385 methods nil t nil 'gnus-mail-method-history))
9388 ((zerop (length (setq ms (gnus-servers-using-backend
9390 (list (intern method) ""))
9394 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9395 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9398 (error "No method given for respooling"))
9399 (if (assoc (symbol-name
9400 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9401 (gnus-methods-using 'respool))
9402 (gnus-summary-move-article n nil method)
9403 (gnus-summary-copy-article n nil method)))
9405 (defun gnus-summary-import-article (file &optional edit)
9406 "Import an arbitrary file into a mail newsgroup."
9407 (interactive "fImport file: \nP")
9408 (let ((group gnus-newsgroup-name)
9409 (now (current-time))
9410 atts lines group-art)
9411 (unless (gnus-check-backend-function 'request-accept-article group)
9412 (error "%s does not support article importing" group))
9413 (or (file-readable-p file)
9414 (not (file-regular-p file))
9415 (error "Can't read %s" file))
9417 (set-buffer (gnus-get-buffer-create " *import file*"))
9419 (nnheader-insert-file-contents file)
9420 (goto-char (point-min))
9421 (if (nnheader-article-p)
9423 (goto-char (point-min))
9424 (search-forward "\n\n" nil t)
9425 (narrow-to-region (point-min) (1- (point)))
9426 (goto-char (point-min))
9427 (unless (re-search-forward "^date:" nil t)
9428 (goto-char (point-max))
9429 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9430 ;; This doesn't look like an article, so we fudge some headers.
9431 (setq atts (file-attributes file)
9432 lines (count-lines (point-min) (point-max)))
9433 (insert "From: " (read-string "From: ") "\n"
9434 "Subject: " (read-string "Subject: ") "\n"
9435 "Date: " (message-make-date (nth 5 atts)) "\n"
9436 "Message-ID: " (message-make-message-id) "\n"
9437 "Lines: " (int-to-string lines) "\n"
9438 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9439 (setq group-art (gnus-request-accept-article group nil t))
9440 (kill-buffer (current-buffer)))
9441 (setq gnus-newsgroup-active (gnus-activate-group group))
9443 (gnus-summary-goto-article (cdr group-art) nil t)
9445 (gnus-summary-edit-article))))
9447 (defun gnus-summary-create-article ()
9448 "Create an article in a mail newsgroup."
9450 (let ((group gnus-newsgroup-name)
9451 (now (current-time))
9453 (unless (gnus-check-backend-function 'request-accept-article group)
9454 (error "%s does not support article importing" group))
9456 (set-buffer (gnus-get-buffer-create " *import file*"))
9458 (goto-char (point-min))
9459 ;; This doesn't look like an article, so we fudge some headers.
9460 (insert "From: " (read-string "From: ") "\n"
9461 "Subject: " (read-string "Subject: ") "\n"
9462 "Date: " (message-make-date now) "\n"
9463 "Message-ID: " (message-make-message-id) "\n")
9464 (setq group-art (gnus-request-accept-article group nil t))
9465 (kill-buffer (current-buffer)))
9466 (setq gnus-newsgroup-active (gnus-activate-group group))
9468 (gnus-summary-goto-article (cdr group-art) nil t)
9469 (gnus-summary-edit-article)))
9471 (defun gnus-summary-article-posted-p ()
9472 "Say whether the current (mail) article is available from news as well.
9473 This will be the case if the article has both been mailed and posted."
9475 (let ((id (mail-header-references (gnus-summary-article-header)))
9476 (gnus-override-method (car (gnus-refer-article-methods))))
9477 (if (gnus-request-head id "")
9478 (gnus-message 2 "The current message was found on %s"
9479 gnus-override-method)
9480 (gnus-message 2 "The current message couldn't be found on %s"
9481 gnus-override-method)
9484 (defun gnus-summary-expire-articles (&optional now)
9485 "Expire all articles that are marked as expirable in the current group."
9487 (when (and (not gnus-group-is-exiting-without-update-p)
9488 (gnus-check-backend-function
9489 'request-expire-articles gnus-newsgroup-name))
9490 ;; This backend supports expiry.
9491 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9492 (expirable (if total
9494 ;; We need to update the info for
9495 ;; this group for `gnus-list-of-read-articles'
9496 ;; to give us the right answer.
9497 (gnus-run-hooks 'gnus-exit-group-hook)
9498 (gnus-summary-update-info)
9499 (gnus-list-of-read-articles gnus-newsgroup-name))
9500 (setq gnus-newsgroup-expirable
9501 (sort gnus-newsgroup-expirable '<))))
9502 (expiry-wait (if now 'immediate
9503 (gnus-group-find-parameter
9504 gnus-newsgroup-name 'expiry-wait)))
9505 (nnmail-expiry-target
9506 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9507 nnmail-expiry-target))
9510 ;; There are expirable articles in this group, so we run them
9511 ;; through the expiry process.
9512 (gnus-message 6 "Expiring articles...")
9513 (unless (gnus-check-group gnus-newsgroup-name)
9514 (error "Can't open server for %s" gnus-newsgroup-name))
9515 ;; The list of articles that weren't expired is returned.
9518 (let ((nnmail-expiry-wait-function nil)
9519 (nnmail-expiry-wait expiry-wait))
9520 (setq es (gnus-request-expire-articles
9521 expirable gnus-newsgroup-name)))
9522 (setq es (gnus-request-expire-articles
9523 expirable gnus-newsgroup-name)))
9525 (setq gnus-newsgroup-expirable es))
9526 ;; We go through the old list of expirable, and mark all
9527 ;; really expired articles as nonexistent.
9528 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9529 (let ((gnus-use-cache nil))
9530 (dolist (article expirable)
9531 (when (and (not (memq article es))
9532 (gnus-data-find article))
9533 (gnus-summary-mark-article article gnus-canceled-mark)
9534 (run-hook-with-args 'gnus-summary-article-expire-hook
9537 (assoc article (gnus-data-list nil)))
9541 (gnus-message 6 "Expiring articles...done")))))
9543 (defun gnus-summary-expire-articles-now ()
9544 "Expunge all expirable articles in the current group.
9545 This means that *all* articles that are marked as expirable will be
9546 deleted forever, right now."
9548 (or gnus-expert-user
9550 "Are you really, really, really sure you want to delete all these messages? ")
9552 (gnus-summary-expire-articles t))
9554 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9555 (defun gnus-summary-delete-article (&optional n)
9556 "Delete the N next (mail) articles.
9557 This command actually deletes articles. This is not a marking
9558 command. The article will disappear forever from your life, never to
9561 If N is negative, delete backwards.
9562 If N is nil and articles have been marked with the process mark,
9563 delete these instead.
9565 If `gnus-novice-user' is non-nil you will be asked for
9566 confirmation before the articles are deleted."
9568 (unless (gnus-check-backend-function 'request-expire-articles
9569 gnus-newsgroup-name)
9570 (error "The current newsgroup does not support article deletion"))
9571 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9572 (error "Couldn't open server"))
9573 ;; Compute the list of articles to delete.
9574 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9575 (nnmail-expiry-target 'delete)
9577 (if (and gnus-novice-user
9578 (not (gnus-yes-or-no-p
9579 (format "Do you really want to delete %s forever? "
9580 (if (> (length articles) 1)
9581 (format "these %s articles" (length articles))
9584 ;; Delete the articles.
9585 (setq not-deleted (gnus-request-expire-articles
9586 articles gnus-newsgroup-name 'force))
9588 (gnus-summary-remove-process-mark (car articles))
9589 ;; The backend might not have been able to delete the article
9591 (unless (memq (car articles) not-deleted)
9592 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9593 (let* ((article (car articles))
9594 (ghead (gnus-data-header
9595 (assoc article (gnus-data-list nil)))))
9596 (run-hook-with-args 'gnus-summary-article-delete-hook
9597 'delete ghead gnus-newsgroup-name nil
9599 (setq articles (cdr articles)))
9601 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9602 (gnus-summary-position-point)
9603 (gnus-set-mode-line 'summary)
9606 (defun gnus-summary-edit-article (&optional force)
9607 "Edit the current article.
9608 This will have permanent effect only in mail groups.
9609 If FORCE is non-nil, allow editing of articles even in read-only
9613 (set-buffer gnus-summary-buffer)
9614 (let ((mail-parse-charset gnus-newsgroup-charset)
9615 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9616 (gnus-set-global-variables)
9617 (when (and (not force)
9618 (gnus-group-read-only-p))
9619 (error "The current newsgroup does not support article editing"))
9620 (gnus-summary-show-article t)
9621 (gnus-article-edit-article
9623 `(lambda (no-highlight)
9624 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9625 (message-options message-options)
9626 (message-options-set-recipient)
9627 (mail-parse-ignored-charsets
9628 ',gnus-newsgroup-ignored-charsets))
9629 (gnus-summary-edit-article-done
9630 ,(or (mail-header-references gnus-current-headers) "")
9631 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9633 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9635 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9637 "Make edits to the current article permanent."
9640 ;; The buffer restriction contains the entire article if it exists.
9641 (when (article-goto-body)
9642 (let ((lines (count-lines (point) (point-max)))
9643 (length (- (point-max) (point)))
9644 (case-fold-search t)
9645 (body (copy-marker (point))))
9646 (goto-char (point-min))
9647 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9648 (delete-region (match-beginning 1) (match-end 1))
9649 (insert (number-to-string length)))
9650 (goto-char (point-min))
9651 (when (re-search-forward
9652 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9653 (delete-region (match-beginning 1) (match-end 1))
9654 (insert (number-to-string length)))
9655 (goto-char (point-min))
9656 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9657 (delete-region (match-beginning 1) (match-end 1))
9658 (insert (number-to-string lines))))))
9659 ;; Replace the article.
9660 (let ((buf (current-buffer)))
9662 (insert-buffer-substring buf)
9664 (if (and (not read-only)
9665 (not (gnus-request-replace-article
9666 (cdr gnus-article-current) (car gnus-article-current)
9667 (current-buffer) t)))
9668 (error "Couldn't replace article")
9669 ;; Update the summary buffer.
9671 (equal (message-tokenize-header references " ")
9672 (message-tokenize-header
9673 (or (message-fetch-field "references") "") " ")))
9674 ;; We only have to update this line.
9677 (message-narrow-to-head)
9678 (let ((head (buffer-string))
9681 (insert (format "211 %d Article retrieved.\n"
9682 (cdr gnus-article-current)))
9685 (let ((nntp-server-buffer (current-buffer)))
9686 (setq header (car (gnus-get-newsgroup-headers
9689 (set-buffer gnus-summary-buffer)
9690 (gnus-data-set-header
9691 (gnus-data-find (cdr gnus-article-current))
9693 (gnus-summary-update-article-line
9694 (cdr gnus-article-current) header)
9695 (if (gnus-summary-goto-subject
9696 (cdr gnus-article-current) nil t)
9697 (gnus-summary-update-secondary-mark
9698 (cdr gnus-article-current))))))))
9700 (set-buffer (or buffer gnus-summary-buffer))
9701 (gnus-summary-update-article (cdr gnus-article-current))
9702 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9703 (gnus-summary-update-secondary-mark
9704 (cdr gnus-article-current))))
9705 ;; Prettify the article buffer again.
9706 (unless no-highlight
9708 (set-buffer gnus-article-buffer)
9709 ;;;!!! Fix this -- article should be rehighlighted.
9710 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9711 (set-buffer gnus-original-article-buffer)
9712 (gnus-request-article
9713 (cdr gnus-article-current)
9714 (car gnus-article-current) (current-buffer))))
9715 ;; Prettify the summary buffer line.
9716 (when (gnus-visual-p 'summary-highlight 'highlight)
9717 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9719 (defun gnus-summary-edit-wash (key)
9720 "Perform editing command KEY in the article buffer."
9724 (message "%s" (concat (this-command-keys) "- "))
9727 (gnus-summary-edit-article)
9728 (execute-kbd-macro (concat (this-command-keys) key))
9729 (gnus-article-edit-done))
9733 (defun gnus-summary-respool-query (&optional silent trace)
9734 "Query where the respool algorithm would put this article."
9736 (let (gnus-mark-article-hook)
9737 (gnus-summary-select-article)
9739 (set-buffer gnus-original-article-buffer)
9740 (let ((groups (nnmail-article-group 'identity trace)))
9743 (message "This message would go to %s"
9744 (mapconcat 'car groups ", "))
9745 (message "This message would go to no groups"))
9748 (defun gnus-summary-respool-trace ()
9749 "Trace where the respool algorithm would put this article.
9750 Display a buffer showing all fancy splitting patterns which matched."
9752 (gnus-summary-respool-query nil t))
9754 ;; Summary marking commands.
9756 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9757 "Mark articles which has the same subject as read, and then select the next.
9758 If UNMARK is positive, remove any kind of mark.
9759 If UNMARK is negative, tick articles."
9762 (setq unmark (prefix-numeric-value unmark)))
9764 (gnus-summary-mark-same-subject
9765 (gnus-summary-article-subject) unmark)))
9766 ;; Select next unread article. If auto-select-same mode, should
9767 ;; select the first unread article.
9768 (gnus-summary-next-article t (and gnus-auto-select-same
9769 (gnus-summary-article-subject)))
9770 (gnus-message 7 "%d article%s marked as %s"
9771 count (if (= count 1) " is" "s are")
9772 (if unmark "unread" "read"))))
9774 (defun gnus-summary-kill-same-subject (&optional unmark)
9775 "Mark articles which has the same subject as read.
9776 If UNMARK is positive, remove any kind of mark.
9777 If UNMARK is negative, tick articles."
9780 (setq unmark (prefix-numeric-value unmark)))
9782 (gnus-summary-mark-same-subject
9783 (gnus-summary-article-subject) unmark)))
9784 ;; If marked as read, go to next unread subject.
9786 ;; Go to next unread subject.
9787 (gnus-summary-next-subject 1 t))
9788 (gnus-message 7 "%d articles are marked as %s"
9789 count (if unmark "unread" "read"))))
9791 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9792 "Mark articles with same SUBJECT as read, and return marked number.
9793 If optional argument UNMARK is positive, remove any kinds of marks.
9794 If optional argument UNMARK is negative, mark articles as unread instead."
9798 ((null unmark) ; Mark as read.
9801 (gnus-summary-mark-article-as-read gnus-killed-mark)
9802 (gnus-summary-show-thread) t)
9803 (gnus-summary-find-subject subject))
9804 (setq count (1+ count))))
9805 ((> unmark 0) ; Tick.
9808 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9809 (gnus-summary-show-thread) t)
9810 (gnus-summary-find-subject subject))
9811 (setq count (1+ count))))
9812 (t ; Mark as unread.
9815 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9816 (gnus-summary-show-thread) t)
9817 (gnus-summary-find-subject subject))
9818 (setq count (1+ count)))))
9819 (gnus-set-mode-line 'summary)
9820 ;; Return the number of marked articles.
9823 (defun gnus-summary-mark-as-processable (n &optional unmark)
9824 "Set the process mark on the next N articles.
9825 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9826 the process mark instead. The difference between N and the actual
9827 number of articles marked is returned."
9829 (if (and (null n) (gnus-region-active-p))
9830 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9831 (setq n (prefix-numeric-value n))
9832 (let ((backward (< n 0))
9837 (gnus-summary-remove-process-mark
9838 (gnus-summary-article-number))
9839 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9840 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9843 (gnus-message 7 "No more articles"))
9844 (gnus-summary-recenter)
9845 (gnus-summary-position-point)
9848 (defun gnus-summary-unmark-as-processable (n)
9849 "Remove the process mark from the next N articles.
9850 If N is negative, unmark backward instead. The difference between N and
9851 the actual number of articles unmarked is returned."
9853 (gnus-summary-mark-as-processable n t))
9855 (defun gnus-summary-unmark-all-processable ()
9856 "Remove the process mark from all articles."
9859 (while gnus-newsgroup-processable
9860 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9861 (gnus-summary-position-point))
9863 (defun gnus-summary-add-mark (article type)
9864 "Mark ARTICLE with a mark of TYPE."
9865 (let ((vtype (car (assq type gnus-article-mark-lists)))
9868 (error "No such mark type: %s" type)
9869 (setq var (intern (format "gnus-newsgroup-%s" type)))
9870 (set var (cons article (symbol-value var)))
9871 (if (memq type '(processable cached replied forwarded recent saved))
9872 (gnus-summary-update-secondary-mark article)
9873 ;;; !!! This is bogus. We should find out what primary
9874 ;;; !!! mark we want to set.
9875 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9877 (defun gnus-summary-mark-as-expirable (n)
9878 "Mark N articles forward as expirable.
9879 If N is negative, mark backward instead. The difference between N and
9880 the actual number of articles marked is returned."
9882 (gnus-summary-mark-forward n gnus-expirable-mark))
9884 (defun gnus-summary-mark-as-spam (n)
9885 "Mark N articles forward as spam.
9886 If N is negative, mark backward instead. The difference between N and
9887 the actual number of articles marked is returned."
9889 (gnus-summary-mark-forward n gnus-spam-mark))
9891 (defun gnus-summary-mark-article-as-replied (article)
9892 "Mark ARTICLE as replied to and update the summary line.
9893 ARTICLE can also be a list of articles."
9894 (interactive (list (gnus-summary-article-number)))
9895 (let ((articles (if (listp article) article (list article))))
9896 (dolist (article articles)
9897 (unless (numberp article)
9898 (error "%s is not a number" article))
9899 (push article gnus-newsgroup-replied)
9900 (let ((buffer-read-only nil))
9901 (when (gnus-summary-goto-subject article nil t)
9902 (gnus-summary-update-secondary-mark article))))))
9904 (defun gnus-summary-mark-article-as-forwarded (article)
9905 "Mark ARTICLE as forwarded and update the summary line.
9906 ARTICLE can also be a list of articles."
9907 (let ((articles (if (listp article) article (list article))))
9908 (dolist (article articles)
9909 (push article gnus-newsgroup-forwarded)
9910 (let ((buffer-read-only nil))
9911 (when (gnus-summary-goto-subject article nil t)
9912 (gnus-summary-update-secondary-mark article))))))
9914 (defun gnus-summary-set-bookmark (article)
9915 "Set a bookmark in current article."
9916 (interactive (list (gnus-summary-article-number)))
9917 (when (or (not (get-buffer gnus-article-buffer))
9918 (not gnus-current-article)
9919 (not gnus-article-current)
9920 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9921 (error "No current article selected"))
9922 ;; Remove old bookmark, if one exists.
9923 (gnus-pull article gnus-newsgroup-bookmarks)
9924 ;; Set the new bookmark, which is on the form
9925 ;; (article-number . line-number-in-body).
9928 (with-current-buffer gnus-article-buffer
9935 gnus-newsgroup-bookmarks)
9936 (gnus-message 6 "A bookmark has been added to the current article."))
9938 (defun gnus-summary-remove-bookmark (article)
9939 "Remove the bookmark from the current article."
9940 (interactive (list (gnus-summary-article-number)))
9941 ;; Remove old bookmark, if one exists.
9942 (if (not (assq article gnus-newsgroup-bookmarks))
9943 (gnus-message 6 "No bookmark in current article.")
9944 (gnus-pull article gnus-newsgroup-bookmarks)
9945 (gnus-message 6 "Removed bookmark.")))
9947 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9948 (defun gnus-summary-mark-as-dormant (n)
9949 "Mark N articles forward as dormant.
9950 If N is negative, mark backward instead. The difference between N and
9951 the actual number of articles marked is returned."
9953 (gnus-summary-mark-forward n gnus-dormant-mark))
9955 (defun gnus-summary-set-process-mark (article)
9956 "Set the process mark on ARTICLE and update the summary line."
9957 (setq gnus-newsgroup-processable
9959 (delq article gnus-newsgroup-processable)))
9960 (when (gnus-summary-goto-subject article)
9961 (gnus-summary-show-thread)
9962 (gnus-summary-goto-subject article)
9963 (gnus-summary-update-secondary-mark article)))
9965 (defun gnus-summary-remove-process-mark (article)
9966 "Remove the process mark from ARTICLE and update the summary line."
9967 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9968 (when (gnus-summary-goto-subject article)
9969 (gnus-summary-show-thread)
9970 (gnus-summary-goto-subject article)
9971 (gnus-summary-update-secondary-mark article)))
9973 (defun gnus-summary-set-saved-mark (article)
9974 "Set the process mark on ARTICLE and update the summary line."
9975 (push article gnus-newsgroup-saved)
9976 (when (gnus-summary-goto-subject article)
9977 (gnus-summary-update-secondary-mark article)))
9979 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9980 "Mark N articles as read forwards.
9981 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9982 The difference between N and the actual number of articles marked is
9984 If NO-EXPIRE, auto-expiry will be inhibited."
9986 (gnus-summary-show-thread)
9987 (let ((backward (< n 0))
9988 (gnus-summary-goto-unread
9989 (and gnus-summary-goto-unread
9990 (not (eq gnus-summary-goto-unread 'never))
9991 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9992 gnus-ticked-mark gnus-dormant-mark)))))
9994 (mark (or mark gnus-del-mark)))
9996 (gnus-summary-mark-article nil mark no-expire)
9997 (zerop (gnus-summary-next-subject
9999 (and gnus-summary-goto-unread
10000 (not (eq gnus-summary-goto-unread 'never)))
10004 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10005 (gnus-summary-recenter)
10006 (gnus-summary-position-point)
10007 (gnus-set-mode-line 'summary)
10010 (defun gnus-summary-mark-article-as-read (mark)
10011 "Mark the current article quickly as read with MARK."
10012 (let ((article (gnus-summary-article-number)))
10013 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10014 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10015 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10016 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10017 (push (cons article mark) gnus-newsgroup-reads)
10018 ;; Possibly remove from cache, if that is used.
10019 (when gnus-use-cache
10020 (gnus-cache-enter-remove-article article))
10021 ;; Allow the backend to change the mark.
10022 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10023 ;; Check for auto-expiry.
10024 (when (and gnus-newsgroup-auto-expire
10025 (memq mark gnus-auto-expirable-marks))
10026 (setq mark gnus-expirable-mark)
10027 ;; Let the backend know about the mark change.
10028 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10029 (push article gnus-newsgroup-expirable))
10030 ;; Set the mark in the buffer.
10031 (gnus-summary-update-mark mark 'unread)
10034 (defun gnus-summary-mark-article-as-unread (mark)
10035 "Mark the current article quickly as unread with MARK."
10036 (let* ((article (gnus-summary-article-number))
10037 (old-mark (gnus-summary-article-mark article)))
10038 ;; Allow the backend to change the mark.
10039 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10040 (if (eq mark old-mark)
10044 (gnus-error 1 "Can't mark negative article numbers")
10046 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10047 (setq gnus-newsgroup-spam-marked
10048 (delq article gnus-newsgroup-spam-marked))
10049 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10050 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10051 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10052 (cond ((= mark gnus-ticked-mark)
10053 (setq gnus-newsgroup-marked
10054 (gnus-add-to-sorted-list gnus-newsgroup-marked
10056 ((= mark gnus-spam-mark)
10057 (setq gnus-newsgroup-spam-marked
10058 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10060 ((= mark gnus-dormant-mark)
10061 (setq gnus-newsgroup-dormant
10062 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10065 (setq gnus-newsgroup-unreads
10066 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10068 (gnus-pull article gnus-newsgroup-reads)
10070 ;; See whether the article is to be put in the cache.
10071 (and gnus-use-cache
10072 (vectorp (gnus-summary-article-header article))
10074 (gnus-cache-possibly-enter-article
10075 gnus-newsgroup-name article
10076 (gnus-summary-article-header article)
10077 (= mark gnus-ticked-mark)
10078 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10081 (gnus-summary-update-mark mark 'unread)
10084 (defun gnus-summary-mark-article (&optional article mark no-expire)
10085 "Mark ARTICLE with MARK. MARK can be any character.
10086 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10087 `??' (dormant) and `?E' (expirable).
10088 If MARK is nil, then the default character `?r' is used.
10089 If ARTICLE is nil, then the article on the current line will be
10091 If NO-EXPIRE, auto-expiry will be inhibited."
10092 ;; The mark might be a string.
10093 (when (stringp mark)
10094 (setq mark (aref mark 0)))
10095 ;; If no mark is given, then we check auto-expiring.
10097 (setq mark gnus-del-mark))
10098 (when (and (not no-expire)
10099 gnus-newsgroup-auto-expire
10100 (memq mark gnus-auto-expirable-marks))
10101 (setq mark gnus-expirable-mark))
10102 (let ((article (or article (gnus-summary-article-number)))
10103 (old-mark (gnus-summary-article-mark article)))
10104 ;; Allow the backend to change the mark.
10105 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10106 (if (eq mark old-mark)
10109 (error "No article on current line"))
10110 (if (not (if (or (= mark gnus-unread-mark)
10111 (= mark gnus-ticked-mark)
10112 (= mark gnus-spam-mark)
10113 (= mark gnus-dormant-mark))
10114 (gnus-mark-article-as-unread article mark)
10115 (gnus-mark-article-as-read article mark)))
10117 ;; See whether the article is to be put in the cache.
10118 (and gnus-use-cache
10119 (not (= mark gnus-canceled-mark))
10120 (vectorp (gnus-summary-article-header article))
10122 (gnus-cache-possibly-enter-article
10123 gnus-newsgroup-name article
10124 (gnus-summary-article-header article)
10125 (= mark gnus-ticked-mark)
10126 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10128 (when (gnus-summary-goto-subject article nil t)
10129 (let ((buffer-read-only nil))
10130 (gnus-summary-show-thread)
10132 (gnus-summary-update-mark mark 'unread)
10135 (defun gnus-summary-update-secondary-mark (article)
10136 "Update the secondary (read, process, cache) mark."
10137 (gnus-summary-update-mark
10138 (cond ((memq article gnus-newsgroup-processable)
10140 ((memq article gnus-newsgroup-cached)
10142 ((memq article gnus-newsgroup-replied)
10144 ((memq article gnus-newsgroup-forwarded)
10145 gnus-forwarded-mark)
10146 ((memq article gnus-newsgroup-saved)
10148 ((memq article gnus-newsgroup-recent)
10150 ((memq article gnus-newsgroup-unseen)
10154 (when (gnus-visual-p 'summary-highlight 'highlight)
10155 (gnus-run-hooks 'gnus-summary-update-hook))
10158 (defun gnus-summary-update-download-mark (article)
10159 "Update the download mark."
10160 (gnus-summary-update-mark
10161 (cond ((memq article gnus-newsgroup-undownloaded)
10162 gnus-undownloaded-mark)
10163 (gnus-newsgroup-agentized
10164 gnus-downloaded-mark)
10168 (gnus-summary-update-line t)
10171 (defun gnus-summary-update-mark (mark type)
10172 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10173 (buffer-read-only nil))
10174 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10176 (when (looking-at "\r")
10178 (when (<= (+ forward (point)) (point-max))
10179 ;; Go to the right position on the line.
10180 (goto-char (+ forward (point)))
10181 ;; Replace the old mark with the new mark.
10182 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10183 ;; Optionally update the marks by some user rule.
10184 (when (eq type 'unread)
10185 (gnus-data-set-mark
10186 (gnus-data-find (gnus-summary-article-number)) mark)
10187 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10189 (defun gnus-mark-article-as-read (article &optional mark)
10190 "Enter ARTICLE in the pertinent lists and remove it from others."
10191 ;; Make the article expirable.
10192 (let ((mark (or mark gnus-del-mark)))
10193 (setq gnus-newsgroup-expirable
10194 (if (= mark gnus-expirable-mark)
10195 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10196 (delq article gnus-newsgroup-expirable)))
10197 ;; Remove from unread and marked lists.
10198 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10199 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10200 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10201 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10202 (push (cons article mark) gnus-newsgroup-reads)
10203 ;; Possibly remove from cache, if that is used.
10204 (when gnus-use-cache
10205 (gnus-cache-enter-remove-article article))
10208 (defun gnus-mark-article-as-unread (article &optional mark)
10209 "Enter ARTICLE in the pertinent lists and remove it from others."
10210 (let ((mark (or mark gnus-ticked-mark)))
10213 (gnus-error 1 "Can't mark negative article numbers")
10215 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10216 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10217 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10218 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10219 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10221 ;; Unsuppress duplicates?
10222 (when gnus-suppress-duplicates
10223 (gnus-dup-unsuppress-article article))
10225 (cond ((= mark gnus-ticked-mark)
10226 (setq gnus-newsgroup-marked
10227 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10228 ((= mark gnus-spam-mark)
10229 (setq gnus-newsgroup-spam-marked
10230 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10232 ((= mark gnus-dormant-mark)
10233 (setq gnus-newsgroup-dormant
10234 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10236 (setq gnus-newsgroup-unreads
10237 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10238 (gnus-pull article gnus-newsgroup-reads)
10241 (defalias 'gnus-summary-mark-as-unread-forward
10242 'gnus-summary-tick-article-forward)
10243 (make-obsolete 'gnus-summary-mark-as-unread-forward
10244 'gnus-summary-tick-article-forward)
10245 (defun gnus-summary-tick-article-forward (n)
10246 "Tick N articles forwards.
10247 If N is negative, tick backwards instead.
10248 The difference between N and the number of articles ticked is returned."
10250 (gnus-summary-mark-forward n gnus-ticked-mark))
10252 (defalias 'gnus-summary-mark-as-unread-backward
10253 'gnus-summary-tick-article-backward)
10254 (make-obsolete 'gnus-summary-mark-as-unread-backward
10255 'gnus-summary-tick-article-backward)
10256 (defun gnus-summary-tick-article-backward (n)
10257 "Tick N articles backwards.
10258 The difference between N and the number of articles ticked is returned."
10260 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10262 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10263 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10264 (defun gnus-summary-tick-article (&optional article clear-mark)
10265 "Mark current article as unread.
10266 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10267 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10269 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10270 gnus-ticked-mark)))
10272 (defun gnus-summary-mark-as-read-forward (n)
10273 "Mark N articles as read forwards.
10274 If N is negative, mark backwards instead.
10275 The difference between N and the actual number of articles marked is
10278 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10280 (defun gnus-summary-mark-as-read-backward (n)
10281 "Mark the N articles as read backwards.
10282 The difference between N and the actual number of articles marked is
10285 (gnus-summary-mark-forward
10286 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10288 (defun gnus-summary-mark-as-read (&optional article mark)
10289 "Mark current article as read.
10290 ARTICLE specifies the article to be marked as read.
10291 MARK specifies a string to be inserted at the beginning of the line."
10292 (gnus-summary-mark-article article mark))
10294 (defun gnus-summary-clear-mark-forward (n)
10295 "Clear marks from N articles forward.
10296 If N is negative, clear backward instead.
10297 The difference between N and the number of marks cleared is returned."
10299 (gnus-summary-mark-forward n gnus-unread-mark))
10301 (defun gnus-summary-clear-mark-backward (n)
10302 "Clear marks from N articles backward.
10303 The difference between N and the number of marks cleared is returned."
10305 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10307 (defun gnus-summary-mark-unread-as-read ()
10308 "Intended to be used by `gnus-summary-mark-article-hook'."
10309 (when (memq gnus-current-article gnus-newsgroup-unreads)
10310 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10312 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10313 "Intended to be used by `gnus-summary-mark-article-hook'."
10314 (let ((mark (gnus-summary-article-mark)))
10315 (when (or (gnus-unread-mark-p mark)
10316 (gnus-read-mark-p mark))
10317 (gnus-summary-mark-article gnus-current-article
10318 (or new-mark gnus-read-mark)))))
10320 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10321 "Intended to be used by `gnus-summary-mark-article-hook'."
10322 (let ((mark (gnus-summary-article-mark)))
10323 (when (or (gnus-unread-mark-p mark)
10324 (gnus-read-mark-p mark))
10325 (gnus-summary-mark-article (gnus-summary-article-number)
10326 (or new-mark gnus-read-mark)))))
10328 (defun gnus-summary-mark-unread-as-ticked ()
10329 "Intended to be used by `gnus-summary-mark-article-hook'."
10330 (when (memq gnus-current-article gnus-newsgroup-unreads)
10331 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10333 (defun gnus-summary-mark-region-as-read (point mark all)
10334 "Mark all unread articles between point and mark as read.
10335 If given a prefix, mark all articles between point and mark as read,
10336 even ticked and dormant ones."
10337 (interactive "r\nP")
10341 (beginning-of-line)
10346 (memq (setq article (gnus-summary-article-number))
10347 gnus-newsgroup-unreads))
10348 (gnus-summary-mark-article article gnus-del-mark))
10350 (gnus-summary-find-next))))))
10352 (defun gnus-summary-mark-below (score mark)
10353 "Mark articles with score less than SCORE with MARK."
10354 (interactive "P\ncMark: ")
10355 (setq score (if score
10356 (prefix-numeric-value score)
10357 (or gnus-summary-default-score 0)))
10359 (set-buffer gnus-summary-buffer)
10360 (goto-char (point-min))
10363 (and (< (gnus-summary-article-score) score)
10364 (gnus-summary-mark-article nil mark))
10365 (gnus-summary-find-next)))))
10367 (defun gnus-summary-kill-below (&optional score)
10368 "Mark articles with score below SCORE as read."
10370 (gnus-summary-mark-below score gnus-killed-mark))
10372 (defun gnus-summary-clear-above (&optional score)
10373 "Clear all marks from articles with score above SCORE."
10375 (gnus-summary-mark-above score gnus-unread-mark))
10377 (defun gnus-summary-tick-above (&optional score)
10378 "Tick all articles with score above SCORE."
10380 (gnus-summary-mark-above score gnus-ticked-mark))
10382 (defun gnus-summary-mark-above (score mark)
10383 "Mark articles with score over SCORE with MARK."
10384 (interactive "P\ncMark: ")
10385 (setq score (if score
10386 (prefix-numeric-value score)
10387 (or gnus-summary-default-score 0)))
10389 (set-buffer gnus-summary-buffer)
10390 (goto-char (point-min))
10392 (when (> (gnus-summary-article-score) score)
10393 (gnus-summary-mark-article nil mark))
10395 (gnus-summary-find-next)))))
10397 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10398 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10399 (defun gnus-summary-limit-include-expunged (&optional no-error)
10400 "Display all the hidden articles that were expunged for low scores."
10402 (let ((buffer-read-only nil))
10403 (let ((scored gnus-newsgroup-scored)
10406 (unless (gnus-summary-article-header (caar scored))
10407 (and (setq h (gnus-number-to-header (caar scored)))
10408 (< (cdar scored) gnus-summary-expunge-below)
10410 (setq scored (cdr scored)))
10412 (when (not no-error)
10413 (error "No expunged articles hidden"))
10414 (goto-char (point-min))
10415 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10416 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10417 (mapcar (lambda (x) (push (mail-header-number x)
10418 gnus-newsgroup-limit))
10420 (gnus-summary-prepare-unthreaded (nreverse headers))
10421 (goto-char (point-min))
10422 (gnus-summary-position-point)
10425 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10426 "Mark all unread articles in this newsgroup as read.
10427 If prefix argument ALL is non-nil, ticked and dormant articles will
10428 also be marked as read.
10429 If QUIETLY is non-nil, no questions will be asked.
10431 If TO-HERE is non-nil, it should be a point in the buffer. All
10432 articles before (after, if REVERSE is set) this point will be marked
10435 Note that this function will only catch up the unread article
10436 in the current summary buffer limitation.
10438 The number of articles marked as read is returned."
10443 (not gnus-interactive-catchup) ;Without confirmation?
10447 "Mark absolutely all articles as read? "
10448 "Mark all unread articles as read? ")))
10450 (not gnus-newsgroup-adaptive)
10451 (not gnus-newsgroup-auto-expire)
10452 (not gnus-suppress-duplicates)
10453 (or (not gnus-use-cache)
10454 (eq gnus-use-cache 'passive)))
10457 (setq gnus-newsgroup-marked nil
10458 gnus-newsgroup-spam-marked nil
10459 gnus-newsgroup-dormant nil))
10460 (setq gnus-newsgroup-unreads
10461 (gnus-sorted-nunion
10462 (gnus-intersection gnus-newsgroup-unreads
10463 gnus-newsgroup-downloadable)
10464 gnus-newsgroup-unfetched)))
10465 ;; We actually mark all articles as canceled, which we
10466 ;; have to do when using auto-expiry or adaptive scoring.
10467 (gnus-summary-show-all-threads)
10468 (if (and to-here reverse)
10470 (goto-char to-here)
10471 (gnus-summary-mark-current-read-and-unread-as-read
10473 (while (gnus-summary-find-next (not all))
10474 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10475 (when (gnus-summary-first-subject (not all))
10477 (if to-here (< (point) to-here) t)
10478 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10479 (gnus-summary-find-next (not all))))))
10480 (gnus-set-mode-line 'summary))
10482 (gnus-summary-position-point)))
10484 (defun gnus-summary-catchup-to-here (&optional all)
10485 "Mark all unticked articles before the current one as read.
10486 If ALL is non-nil, also mark ticked and dormant articles as read."
10489 (gnus-save-hidden-threads
10490 (let ((beg (point)))
10491 ;; We check that there are unread articles.
10492 (when (or all (gnus-summary-find-prev))
10493 (gnus-summary-catchup all t beg)))))
10494 (gnus-summary-position-point))
10496 (defun gnus-summary-catchup-from-here (&optional all)
10497 "Mark all unticked articles after (and including) the current one as read.
10498 If ALL is non-nil, also mark ticked and dormant articles as read."
10501 (gnus-save-hidden-threads
10502 (let ((beg (point)))
10503 ;; We check that there are unread articles.
10504 (when (or all (gnus-summary-find-next))
10505 (gnus-summary-catchup all t beg nil t)))))
10506 (gnus-summary-position-point))
10508 (defun gnus-summary-catchup-all (&optional quietly)
10509 "Mark all articles in this newsgroup as read.
10510 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10511 instead, which marks only unread articles as read."
10513 (gnus-summary-catchup t quietly))
10515 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10516 "Mark all unread articles in this group as read, then exit.
10517 If prefix argument ALL is non-nil, all articles are marked as read.
10518 If QUIETLY is non-nil, no questions will be asked."
10520 (when (gnus-summary-catchup all quietly nil 'fast)
10521 ;; Select next newsgroup or exit.
10522 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10523 (eq gnus-auto-select-next 'quietly))
10524 (gnus-summary-next-group nil)
10525 (gnus-summary-exit))))
10527 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10528 "Mark all articles in this newsgroup as read, and then exit.
10529 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10530 instead, which marks only unread articles as read."
10532 (gnus-summary-catchup-and-exit t quietly))
10534 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10535 "Mark all articles in this group as read and select the next group.
10536 If given a prefix, mark all articles, unread as well as ticked, as
10540 (gnus-summary-catchup all))
10541 (gnus-summary-next-group))
10547 (defmacro gnus-with-article (article &rest forms)
10548 "Select ARTICLE and perform FORMS in the original article buffer.
10549 Then replace the article with the result."
10551 ;; We don't want the article to be marked as read.
10552 (let (gnus-mark-article-hook)
10553 (gnus-summary-select-article t t nil ,article))
10554 (set-buffer gnus-original-article-buffer)
10556 (if (not (gnus-check-backend-function
10557 'request-replace-article (car gnus-article-current)))
10558 (gnus-message 5 "Read-only group; not replacing")
10559 (unless (gnus-request-replace-article
10560 ,article (car gnus-article-current)
10561 (current-buffer) t)
10562 (error "Couldn't replace article")))
10563 ;; The cache and backlog have to be flushed somewhat.
10564 (when gnus-keep-backlog
10565 (gnus-backlog-remove-article
10566 (car gnus-article-current) (cdr gnus-article-current)))
10567 (when gnus-use-cache
10568 (gnus-cache-update-article
10569 (car gnus-article-current) (cdr gnus-article-current)))))
10571 (put 'gnus-with-article 'lisp-indent-function 1)
10572 (put 'gnus-with-article 'edebug-form-spec '(form body))
10574 ;; Thread-based commands.
10576 (defun gnus-summary-articles-in-thread (&optional article)
10577 "Return a list of all articles in the current thread.
10578 If ARTICLE is non-nil, return all articles in the thread that starts
10579 with that article."
10580 (let* ((article (or article (gnus-summary-article-number)))
10581 (data (gnus-data-find-list article))
10582 (top-level (gnus-data-level (car data)))
10584 (cond ((null gnus-thread-operation-ignore-subject)
10585 (gnus-simplify-subject-re
10586 (mail-header-subject (gnus-data-header (car data)))))
10587 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10588 (gnus-simplify-subject-fuzzy
10589 (mail-header-subject (gnus-data-header (car data)))))
10591 (end-point (save-excursion
10592 (if (gnus-summary-go-to-next-thread)
10593 (point) (point-max))))
10596 (< (gnus-data-pos (car data)) end-point))
10597 (when (or (not top-subject)
10598 (string= top-subject
10599 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10600 (gnus-simplify-subject-fuzzy
10601 (mail-header-subject
10602 (gnus-data-header (car data))))
10603 (gnus-simplify-subject-re
10604 (mail-header-subject
10605 (gnus-data-header (car data)))))))
10606 (push (gnus-data-number (car data)) articles))
10607 (unless (and (setq data (cdr data))
10608 (> (gnus-data-level (car data)) top-level))
10610 ;; Return the list of articles.
10611 (nreverse articles)))
10613 (defun gnus-summary-rethread-current ()
10614 "Rethread the thread the current article is part of."
10616 (let* ((gnus-show-threads t)
10617 (article (gnus-summary-article-number))
10618 (id (mail-header-id (gnus-summary-article-header)))
10619 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10621 (error "No article on the current line"))
10622 (gnus-rebuild-thread id)
10623 (gnus-summary-goto-subject article)))
10625 (defun gnus-summary-reparent-thread ()
10626 "Make the current article child of the marked (or previous) article.
10628 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10629 is non-nil or the Subject: of both articles are the same."
10631 (unless (not (gnus-group-read-only-p))
10632 (error "The current newsgroup does not support article editing"))
10633 (unless (<= (length gnus-newsgroup-processable) 1)
10634 (error "No more than one article may be marked"))
10635 (save-window-excursion
10636 (let ((gnus-article-buffer " *reparent*")
10637 (current-article (gnus-summary-article-number))
10638 ;; First grab the marked article, otherwise one line up.
10639 (parent-article (if (not (null gnus-newsgroup-processable))
10640 (car gnus-newsgroup-processable)
10642 (if (eq (forward-line -1) 0)
10643 (gnus-summary-article-number)
10644 (error "Beginning of summary buffer"))))))
10645 (unless (not (eq current-article parent-article))
10646 (error "An article may not be self-referential"))
10647 (let ((message-id (mail-header-id
10648 (gnus-summary-article-header parent-article))))
10649 (unless (and message-id (not (equal message-id "")))
10650 (error "No message-id in desired parent"))
10651 (gnus-with-article current-article
10653 (goto-char (point-min))
10654 (message-narrow-to-head)
10655 (if (re-search-forward "^References: " nil t)
10657 (re-search-forward "^[^ \t]" nil t)
10660 (insert " " message-id))
10661 (insert "References: " message-id "\n"))))
10662 (set-buffer gnus-summary-buffer)
10663 (gnus-summary-unmark-all-processable)
10664 (gnus-summary-update-article current-article)
10665 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10666 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10667 (gnus-summary-rethread-current)
10668 (gnus-message 3 "Article %d is now the child of article %d"
10669 current-article parent-article)))))
10671 (defun gnus-summary-toggle-threads (&optional arg)
10672 "Toggle showing conversation threads.
10673 If ARG is positive number, turn showing conversation threads on."
10675 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10676 (setq gnus-show-threads
10677 (if (null arg) (not gnus-show-threads)
10678 (> (prefix-numeric-value arg) 0)))
10679 (gnus-summary-prepare)
10680 (gnus-summary-goto-subject current)
10681 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10682 (gnus-summary-position-point)))
10684 (defun gnus-summary-show-all-threads ()
10685 "Show all threads."
10688 (let ((buffer-read-only nil))
10689 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10690 (gnus-summary-position-point))
10692 (defun gnus-summary-show-thread ()
10693 "Show thread subtrees.
10694 Returns nil if no thread was there to be shown."
10696 (let ((buffer-read-only nil)
10698 (end (point-at-eol))
10699 ;; Leave point at bol
10700 (beg (progn (beginning-of-line) (point))))
10702 ;; Any hidden lines here?
10703 (search-forward "\r" end t)
10704 (subst-char-in-region beg end ?\^M ?\n t)
10706 (gnus-summary-position-point))))
10708 (defun gnus-summary-maybe-hide-threads ()
10709 "If requested, hide the threads that should be hidden."
10710 (when (and gnus-show-threads
10711 gnus-thread-hide-subtree)
10712 (gnus-summary-hide-all-threads
10713 (if (or (consp gnus-thread-hide-subtree)
10714 (functionp gnus-thread-hide-subtree))
10715 (gnus-make-predicate gnus-thread-hide-subtree)
10718 ;;; Hiding predicates.
10720 (defun gnus-article-unread-p (header)
10721 (memq (mail-header-number header) gnus-newsgroup-unreads))
10723 (defun gnus-article-unseen-p (header)
10724 (memq (mail-header-number header) gnus-newsgroup-unseen))
10726 (defun gnus-map-articles (predicate articles)
10727 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10728 (apply 'gnus-or (mapcar predicate
10729 (mapcar 'gnus-summary-article-header articles))))
10731 (defun gnus-summary-hide-all-threads (&optional predicate)
10732 "Hide all thread subtrees.
10733 If PREDICATE is supplied, threads that satisfy this predicate
10734 will not be hidden."
10737 (goto-char (point-min))
10740 (when (or (not predicate)
10742 predicate (gnus-summary-article-children)))
10743 (gnus-summary-hide-thread))
10744 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10745 (gnus-summary-position-point))
10747 (defun gnus-summary-hide-thread ()
10748 "Hide thread subtrees.
10749 If PREDICATE is supplied, threads that satisfy this predicate
10750 will not be hidden.
10751 Returns nil if no threads were there to be hidden."
10753 (let ((buffer-read-only nil)
10755 (article (gnus-summary-article-number)))
10757 ;; Go forward until either the buffer ends or the subthread
10759 (when (and (not (eobp))
10760 (or (zerop (gnus-summary-next-thread 1 t))
10761 (goto-char (point-max))))
10763 (if (and (> (point) start)
10764 (search-backward "\n" start t))
10766 (subst-char-in-region start (point) ?\n ?\^M)
10767 (gnus-summary-goto-subject article))
10771 (defun gnus-summary-go-to-next-thread (&optional previous)
10772 "Go to the same level (or less) next thread.
10773 If PREVIOUS is non-nil, go to previous thread instead.
10774 Return the article number moved to, or nil if moving was impossible."
10775 (let ((level (gnus-summary-thread-level))
10776 (way (if previous -1 1))
10779 (while (and (not (eobp))
10780 (< level (gnus-summary-thread-level)))
10781 (forward-line way))
10788 (gnus-summary-article-number)
10789 (goto-char beg)))))
10791 (defun gnus-summary-next-thread (n &optional silent)
10792 "Go to the same level next N'th thread.
10793 If N is negative, search backward instead.
10794 Returns the difference between N and the number of skips actually
10797 If SILENT, don't output messages."
10799 (let ((backward (< n 0))
10801 (while (and (> n 0)
10802 (gnus-summary-go-to-next-thread backward))
10805 (gnus-summary-position-point))
10806 (when (and (not silent) (/= 0 n))
10807 (gnus-message 7 "No more threads"))
10810 (defun gnus-summary-prev-thread (n)
10811 "Go to the same level previous N'th thread.
10812 Returns the difference between N and the number of skips actually
10815 (gnus-summary-next-thread (- n)))
10817 (defun gnus-summary-go-down-thread ()
10818 "Go down one level in the current thread."
10819 (let ((children (gnus-summary-article-children)))
10821 (gnus-summary-goto-subject (car children)))))
10823 (defun gnus-summary-go-up-thread ()
10824 "Go up one level in the current thread."
10825 (let ((parent (gnus-summary-article-parent)))
10827 (gnus-summary-goto-subject parent))))
10829 (defun gnus-summary-down-thread (n)
10830 "Go down thread N steps.
10831 If N is negative, go up instead.
10832 Returns the difference between N and how many steps down that were
10837 (while (and (> n 0)
10838 (if up (gnus-summary-go-up-thread)
10839 (gnus-summary-go-down-thread)))
10841 (gnus-summary-position-point)
10843 (gnus-message 7 "Can't go further"))
10846 (defun gnus-summary-up-thread (n)
10847 "Go up thread N steps.
10848 If N is negative, go down instead.
10849 Returns the difference between N and how many steps down that were
10852 (gnus-summary-down-thread (- n)))
10854 (defun gnus-summary-top-thread ()
10855 "Go to the top of the thread."
10857 (while (gnus-summary-go-up-thread))
10858 (gnus-summary-article-number))
10860 (defun gnus-summary-kill-thread (&optional unmark)
10861 "Mark articles under current thread as read.
10862 If the prefix argument is positive, remove any kinds of marks.
10863 If the prefix argument is negative, tick articles instead."
10866 (setq unmark (prefix-numeric-value unmark)))
10867 (let ((articles (gnus-summary-articles-in-thread)))
10869 ;; Expand the thread.
10870 (gnus-summary-show-thread)
10871 ;; Mark all the articles.
10873 (gnus-summary-goto-subject (car articles))
10874 (cond ((null unmark)
10875 (gnus-summary-mark-article-as-read gnus-killed-mark))
10877 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10879 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10880 (setq articles (cdr articles))))
10881 ;; Hide killed subtrees.
10883 gnus-thread-hide-killed
10884 (gnus-summary-hide-thread))
10885 ;; If marked as read, go to next unread subject.
10886 (when (null unmark)
10887 ;; Go to next unread subject.
10888 (gnus-summary-next-subject 1 t)))
10889 (gnus-set-mode-line 'summary))
10891 ;; Summary sorting commands
10893 (defun gnus-summary-sort-by-number (&optional reverse)
10894 "Sort the summary buffer by article number.
10895 Argument REVERSE means reverse order."
10897 (gnus-summary-sort 'number reverse))
10899 (defun gnus-summary-sort-by-random (&optional reverse)
10900 "Randomize the order in the summary buffer.
10901 Argument REVERSE means to randomize in reverse order."
10903 (gnus-summary-sort 'random reverse))
10905 (defun gnus-summary-sort-by-author (&optional reverse)
10906 "Sort the summary buffer by author name alphabetically.
10907 If `case-fold-search' is non-nil, case of letters is ignored.
10908 Argument REVERSE means reverse order."
10910 (gnus-summary-sort 'author reverse))
10912 (defun gnus-summary-sort-by-subject (&optional reverse)
10913 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10914 If `case-fold-search' is non-nil, case of letters is ignored.
10915 Argument REVERSE means reverse order."
10917 (gnus-summary-sort 'subject reverse))
10919 (defun gnus-summary-sort-by-date (&optional reverse)
10920 "Sort the summary buffer by date.
10921 Argument REVERSE means reverse order."
10923 (gnus-summary-sort 'date reverse))
10925 (defun gnus-summary-sort-by-score (&optional reverse)
10926 "Sort the summary buffer by score.
10927 Argument REVERSE means reverse order."
10929 (gnus-summary-sort 'score reverse))
10931 (defun gnus-summary-sort-by-lines (&optional reverse)
10932 "Sort the summary buffer by the number of lines.
10933 Argument REVERSE means reverse order."
10935 (gnus-summary-sort 'lines reverse))
10937 (defun gnus-summary-sort-by-chars (&optional reverse)
10938 "Sort the summary buffer by article length.
10939 Argument REVERSE means reverse order."
10941 (gnus-summary-sort 'chars reverse))
10943 (defun gnus-summary-sort-by-original (&optional reverse)
10944 "Sort the summary buffer using the default sorting method.
10945 Argument REVERSE means reverse order."
10947 (let* ((buffer-read-only)
10948 (gnus-summary-prepare-hook nil))
10949 ;; We do the sorting by regenerating the threads.
10950 (gnus-summary-prepare)
10951 ;; Hide subthreads if needed.
10952 (gnus-summary-maybe-hide-threads)))
10954 (defun gnus-summary-sort (predicate reverse)
10955 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10956 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10957 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10958 (gnus-thread-sort-functions
10963 (gnus-sort-gathered-threads-function
10964 gnus-thread-sort-functions)
10965 (gnus-article-sort-functions
10969 (,article t2 t1))))
10971 (gnus-summary-prepare-hook nil))
10972 ;; We do the sorting by regenerating the threads.
10973 (gnus-summary-prepare)
10974 ;; Hide subthreads if needed.
10975 (gnus-summary-maybe-hide-threads)))
10977 ;; Summary saving commands.
10979 (defun gnus-summary-save-article (&optional n not-saved)
10980 "Save the current article using the default saver function.
10981 If N is a positive number, save the N next articles.
10982 If N is a negative number, save the N previous articles.
10983 If N is nil and any articles have been marked with the process mark,
10984 save those articles instead.
10985 The variable `gnus-default-article-saver' specifies the saver function."
10987 (let* ((articles (gnus-summary-work-articles n))
10988 (save-buffer (save-excursion
10989 (nnheader-set-temp-buffer " *Gnus Save*")))
10990 (num (length articles))
10992 (dolist (article articles)
10993 (setq header (gnus-summary-article-header article))
10994 (if (not (vectorp header))
10995 ;; This is a pseudo-article.
10996 (if (assq 'name header)
10997 (gnus-copy-file (cdr (assq 'name header)))
10998 (gnus-message 1 "Article %d is unsaveable" article))
10999 ;; This is a real article.
11000 (save-window-excursion
11001 (let ((gnus-display-mime-function nil)
11002 (gnus-article-prepare-hook nil))
11003 (gnus-summary-select-article t nil nil article)))
11005 (set-buffer save-buffer)
11007 (insert-buffer-substring gnus-original-article-buffer))
11008 (setq file (gnus-article-save save-buffer file num))
11009 (gnus-summary-remove-process-mark article)
11011 (gnus-summary-set-saved-mark article))))
11012 (gnus-kill-buffer save-buffer)
11013 (gnus-summary-position-point)
11014 (gnus-set-mode-line 'summary)
11017 (defun gnus-summary-pipe-output (&optional arg headers)
11018 "Pipe the current article to a subprocess.
11019 If N is a positive number, pipe the N next articles.
11020 If N is a negative number, pipe the N previous articles.
11021 If N is nil and any articles have been marked with the process mark,
11022 pipe those articles instead.
11023 If HEADERS (the symbolic prefix), include the headers, too."
11024 (interactive (gnus-interactive "P\ny"))
11025 (require 'gnus-art)
11026 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11027 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11028 (gnus-summary-save-article arg t))
11029 (let ((buffer (get-buffer "*Shell Command Output*")))
11031 (not (zerop (buffer-size buffer))))
11032 (gnus-configure-windows 'pipe))))
11034 (defun gnus-summary-save-article-mail (&optional arg)
11035 "Append the current article to an mail file.
11036 If N is a positive number, save the N next articles.
11037 If N is a negative number, save the N previous articles.
11038 If N is nil and any articles have been marked with the process mark,
11039 save those articles instead."
11041 (require 'gnus-art)
11042 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11043 (gnus-summary-save-article arg)))
11045 (defun gnus-summary-save-article-rmail (&optional arg)
11046 "Append the current article to an rmail file.
11047 If N is a positive number, save the N next articles.
11048 If N is a negative number, save the N previous articles.
11049 If N is nil and any articles have been marked with the process mark,
11050 save those articles instead."
11052 (require 'gnus-art)
11053 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11054 (gnus-summary-save-article arg)))
11056 (defun gnus-summary-save-article-file (&optional arg)
11057 "Append the current article to a file.
11058 If N is a positive number, save the N next articles.
11059 If N is a negative number, save the N previous articles.
11060 If N is nil and any articles have been marked with the process mark,
11061 save those articles instead."
11063 (require 'gnus-art)
11064 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11065 (gnus-summary-save-article arg)))
11067 (defun gnus-summary-write-article-file (&optional arg)
11068 "Write the current article to a file, deleting the previous file.
11069 If N is a positive number, save the N next articles.
11070 If N is a negative number, save the N previous articles.
11071 If N is nil and any articles have been marked with the process mark,
11072 save those articles instead."
11074 (require 'gnus-art)
11075 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11076 (gnus-summary-save-article arg)))
11078 (defun gnus-summary-save-article-body-file (&optional arg)
11079 "Append the current article body to a file.
11080 If N is a positive number, save the N next articles.
11081 If N is a negative number, save the N previous articles.
11082 If N is nil and any articles have been marked with the process mark,
11083 save those articles instead."
11085 (require 'gnus-art)
11086 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11087 (gnus-summary-save-article arg)))
11089 (defun gnus-summary-muttprint (&optional arg)
11090 "Print the current article using Muttprint.
11091 If N is a positive number, save the N next articles.
11092 If N is a negative number, save the N previous articles.
11093 If N is nil and any articles have been marked with the process mark,
11094 save those articles instead."
11096 (require 'gnus-art)
11097 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11098 (gnus-summary-save-article arg t)))
11100 (defun gnus-summary-pipe-message (program)
11101 "Pipe the current article through PROGRAM."
11102 (interactive "sProgram: ")
11103 (gnus-summary-select-article)
11104 (let ((mail-header-separator ""))
11105 (gnus-eval-in-buffer-window gnus-article-buffer
11108 (let ((start (window-start))
11110 (message-pipe-buffer-body program)
11111 (set-window-start (get-buffer-window (current-buffer)) start))))))
11113 (defun gnus-get-split-value (methods)
11114 "Return a value based on the split METHODS."
11115 (let (split-name method result match)
11118 (set-buffer gnus-original-article-buffer)
11120 (nnheader-narrow-to-headers)
11121 (while (and methods (not split-name))
11122 (goto-char (point-min))
11123 (setq method (pop methods))
11124 (setq match (car method))
11127 ;; Regular expression.
11129 (re-search-forward match nil t)))
11134 (setq result (funcall match gnus-newsgroup-name))))
11139 (setq result (eval match)))))
11140 (setq split-name (cdr method))
11141 (cond ((stringp result)
11142 (push (expand-file-name
11143 result gnus-article-save-directory)
11146 (setq split-name (append result split-name)))))))))
11147 (nreverse split-name)))
11149 (defun gnus-valid-move-group-p (group)
11150 (and (boundp group)
11151 (symbol-name group)
11152 (symbol-value group)
11153 (gnus-get-function (gnus-find-method-for-group
11154 (symbol-name group)) 'request-accept-article t)))
11156 (defun gnus-read-move-group-name (prompt default articles prefix)
11157 "Read a group name."
11158 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11159 (minibuffer-confirm-incomplete nil) ; XEmacs
11161 (format "%s %s to:"
11163 (if (> (length articles) 1)
11164 (format "these %d articles" (length articles))
11169 (gnus-completing-read-with-default
11172 'gnus-valid-move-group-p
11174 'gnus-group-history))
11175 ((= 1 (length split-name))
11176 (gnus-completing-read-with-default
11177 (car split-name) prom
11179 'gnus-valid-move-group-p
11181 'gnus-group-history))
11183 (gnus-completing-read-with-default
11185 (mapcar 'list (nreverse split-name))
11187 'gnus-group-history))))
11188 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11190 (if (or (string= to-newsgroup "")
11191 (string= to-newsgroup prefix))
11192 (setq to-newsgroup default))
11193 (unless to-newsgroup
11194 (error "No group name entered"))
11195 (or (gnus-active to-newsgroup)
11196 (gnus-activate-group to-newsgroup nil nil to-method)
11197 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11199 (or (and (gnus-request-create-group to-newsgroup to-method)
11200 (gnus-activate-group
11201 to-newsgroup nil nil to-method)
11202 (gnus-subscribe-group to-newsgroup))
11203 (error "Couldn't create group %s" to-newsgroup)))
11204 (error "No such group: %s" to-newsgroup)))
11207 (defun gnus-summary-save-parts (type dir n &optional reverse)
11208 "Save parts matching TYPE to DIR.
11209 If REVERSE, save parts that do not match TYPE."
11211 (list (read-string "Save parts of type: "
11212 (or (car gnus-summary-save-parts-type-history)
11213 gnus-summary-save-parts-default-mime)
11214 'gnus-summary-save-parts-type-history)
11215 (setq gnus-summary-save-parts-last-directory
11216 (read-file-name "Save to directory: "
11217 gnus-summary-save-parts-last-directory
11219 current-prefix-arg))
11220 (gnus-summary-iterate n
11221 (let ((gnus-display-mime-function nil)
11222 (gnus-inhibit-treatment t))
11223 (gnus-summary-select-article))
11225 (set-buffer gnus-article-buffer)
11226 (let ((handles (or gnus-article-mime-handles
11227 (mm-dissect-buffer nil gnus-article-loose-mime)
11228 (and gnus-article-emulate-mime
11229 (mm-uu-dissect)))))
11231 (gnus-summary-save-parts-1 type dir handles reverse)
11232 (unless gnus-article-mime-handles ;; Don't destroy this case.
11233 (mm-destroy-parts handles)))))))
11235 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11236 (if (stringp (car handle))
11237 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11240 (not (string-match type (mm-handle-media-type handle)))
11241 (string-match type (mm-handle-media-type handle)))
11242 (let ((file (expand-file-name
11244 mm-file-name-rewrite-functions
11245 (file-name-nondirectory
11247 (mail-content-type-get
11248 (mm-handle-disposition handle) 'filename)
11249 (mail-content-type-get
11250 (mm-handle-type handle) 'name)
11251 (concat gnus-newsgroup-name
11252 "." (number-to-string
11253 (cdr gnus-article-current))))))
11255 (unless (file-exists-p file)
11256 (mm-save-part-to-file handle file))))))
11258 ;; Summary extract commands
11260 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11261 (let ((buffer-read-only nil)
11262 (article (gnus-summary-article-number))
11264 (unless (gnus-summary-goto-subject article)
11265 (error "No such article: %d" article))
11266 (gnus-summary-position-point)
11267 ;; If all commands are to be bunched up on one line, we collect
11269 (unless gnus-view-pseudos-separately
11270 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11273 (setq action (cdr (assq 'action (car ps))))
11274 (setq files (list (cdr (assq 'name (car ps)))))
11275 (while (and ps (cdr ps)
11276 (string= (or action "1")
11277 (or (cdr (assq 'action (cadr ps))) "2")))
11278 (push (cdr (assq 'name (cadr ps))) files)
11279 (setcdr ps (cddr ps)))
11281 (when (not (string-match "%s" action))
11284 (when (assq 'execute (car ps))
11285 (setcdr (assq 'execute (car ps))
11286 (funcall (if (string-match "%s" action)
11293 (shell-quote-argument f)))
11295 (setq ps (cdr ps)))))
11296 (if (and gnus-view-pseudos (not not-view))
11298 (when (assq 'execute (car pslist))
11299 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11300 (eq gnus-view-pseudos 'not-confirm)))
11301 (setq pslist (cdr pslist)))
11304 (setq after-article (or (cdr (assq 'article (car pslist)))
11305 (gnus-summary-article-number)))
11306 (gnus-summary-goto-subject after-article)
11309 (insert " " (file-name-nondirectory
11310 (cdr (assq 'name (car pslist))))
11311 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11313 (forward-line -1) ; back to `b'
11314 (gnus-add-text-properties
11315 b (1- e) (list 'gnus-number gnus-reffed-article-number
11316 gnus-mouse-face-prop gnus-mouse-face))
11318 after-article gnus-reffed-article-number
11319 gnus-unread-mark b (car pslist) 0 (- e b))
11320 (setq gnus-newsgroup-unreads
11321 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11322 gnus-reffed-article-number))
11323 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11324 (setq pslist (cdr pslist)))))))
11326 (defun gnus-pseudos< (p1 p2)
11327 (let ((c1 (cdr (assq 'action p1)))
11328 (c2 (cdr (assq 'action p2))))
11329 (and c1 c2 (string< c1 c2))))
11331 (defun gnus-request-pseudo-article (props)
11332 (cond ((assq 'execute props)
11333 (gnus-execute-command (cdr (assq 'execute props)))))
11334 (let ((gnus-current-article (gnus-summary-article-number)))
11335 (gnus-run-hooks 'gnus-mark-article-hook)))
11337 (defun gnus-execute-command (command &optional automatic)
11339 (gnus-article-setup-buffer)
11340 (set-buffer gnus-article-buffer)
11341 (setq buffer-read-only nil)
11342 (let ((command (if automatic command
11343 (read-string "Command: " (cons command 0)))))
11345 (insert "$ " command "\n\n")
11346 (if gnus-view-pseudo-asynchronously
11347 (start-process "gnus-execute" (current-buffer) shell-file-name
11348 shell-command-switch command)
11349 (call-process shell-file-name nil t nil
11350 shell-command-switch command)))))
11352 ;; Summary kill commands.
11354 (defun gnus-summary-edit-global-kill (article)
11355 "Edit the \"global\" kill file."
11356 (interactive (list (gnus-summary-article-number)))
11357 (gnus-group-edit-global-kill article))
11359 (defun gnus-summary-edit-local-kill ()
11360 "Edit a local kill file applied to the current newsgroup."
11362 (setq gnus-current-headers (gnus-summary-article-header))
11363 (gnus-group-edit-local-kill
11364 (gnus-summary-article-number) gnus-newsgroup-name))
11366 ;;; Header reading.
11368 (defun gnus-read-header (id &optional header)
11369 "Read the headers of article ID and enter them into the Gnus system."
11370 (let ((group gnus-newsgroup-name)
11371 (gnus-override-method
11373 gnus-override-method
11374 (and (gnus-news-group-p gnus-newsgroup-name)
11375 (car (gnus-refer-article-methods)))))
11377 ;; First we check to see whether the header in question is already
11380 ;; This is a Message-ID.
11381 (setq header (or header (gnus-id-to-header id)))
11382 ;; This is an article number.
11383 (setq header (or header (gnus-summary-article-header id))))
11385 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11386 ;; We have found the header.
11388 ;; We have to really fetch the header to this article.
11390 (set-buffer nntp-server-buffer)
11391 (when (setq where (gnus-request-head id group))
11392 (nnheader-fold-continuation-lines)
11393 (goto-char (point-max))
11395 (goto-char (point-min))
11399 ((cdr where) (cdr where))
11400 (header (mail-header-number header))
11401 (t gnus-reffed-article-number))
11403 (insert " Article retrieved.\n"))
11404 (if (or (not where)
11405 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11406 () ; Malformed head.
11407 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11408 (when (and (stringp id)
11409 (not (string= (gnus-group-real-name group)
11411 ;; If we fetched by Message-ID and the article came
11412 ;; from a different group, we fudge some bogus article
11413 ;; numbers for this article.
11414 (mail-header-set-number header gnus-reffed-article-number))
11416 (set-buffer gnus-summary-buffer)
11417 (decf gnus-reffed-article-number)
11418 (gnus-remove-header (mail-header-number header))
11419 (push header gnus-newsgroup-headers)
11420 (setq gnus-current-headers header)
11421 (push (mail-header-number header) gnus-newsgroup-limit)))
11424 (defun gnus-remove-header (number)
11425 "Remove header NUMBER from `gnus-newsgroup-headers'."
11426 (if (and gnus-newsgroup-headers
11427 (= number (mail-header-number (car gnus-newsgroup-headers))))
11428 (pop gnus-newsgroup-headers)
11429 (let ((headers gnus-newsgroup-headers))
11430 (while (and (cdr headers)
11431 (not (= number (mail-header-number (cadr headers)))))
11433 (when (cdr headers)
11434 (setcdr headers (cddr headers))))))
11437 ;;; summary highlights
11440 (defun gnus-highlight-selected-summary ()
11441 "Highlight selected article in summary buffer."
11442 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11443 (when gnus-summary-selected-face
11445 (let* ((beg (point-at-bol))
11446 (end (point-at-eol))
11447 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11448 (from (if (get-text-property beg gnus-mouse-face-prop)
11450 (or (next-single-property-change
11451 beg gnus-mouse-face-prop nil end)
11456 (or (next-single-property-change
11457 from gnus-mouse-face-prop nil end)
11459 ;; If no mouse-face prop on line we will have to = from = end,
11460 ;; so we highlight the entire line instead.
11461 (when (= (+ to 2) from)
11464 (if gnus-newsgroup-selected-overlay
11465 ;; Move old overlay.
11467 gnus-newsgroup-selected-overlay from to (current-buffer))
11468 ;; Create new overlay.
11470 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11471 'face gnus-summary-selected-face))))))
11473 (defvar gnus-summary-highlight-line-cached nil)
11474 (defvar gnus-summary-highlight-line-trigger nil)
11476 (defun gnus-summary-highlight-line-0 ()
11477 (if (and (eq gnus-summary-highlight-line-trigger
11478 gnus-summary-highlight)
11479 gnus-summary-highlight-line-cached)
11480 gnus-summary-highlight-line-cached
11481 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11482 gnus-summary-highlight-line-cached
11483 (let* ((cond (list 'cond))
11485 (list gnus-summary-highlight))
11487 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11491 (gnus-byte-compile (list 'lambda nil cond))))))
11493 (defun gnus-summary-highlight-line ()
11494 "Highlight current line according to `gnus-summary-highlight'."
11495 (let* ((beg (point-at-bol))
11496 (article (or (gnus-summary-article-number) gnus-current-article))
11497 (score (or (cdr (assq article
11498 gnus-newsgroup-scored))
11499 gnus-summary-default-score 0))
11500 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11501 (inhibit-read-only t)
11502 (default gnus-summary-default-score)
11503 (default-high gnus-summary-default-high-score)
11504 (default-low gnus-summary-default-low-score)
11505 (uncached (and gnus-summary-use-undownloaded-faces
11506 (memq article gnus-newsgroup-undownloaded)
11507 (not (memq article gnus-newsgroup-cached)))))
11508 (let ((face (funcall (gnus-summary-highlight-line-0))))
11509 (unless (eq face (get-text-property beg 'face))
11510 (gnus-put-text-property-excluding-characters-with-faces
11511 beg (point-at-eol) 'face
11512 (setq face (if (boundp face) (symbol-value face) face)))
11513 (when gnus-summary-highlight-line-function
11514 (funcall gnus-summary-highlight-line-function article face))))))
11516 (defun gnus-update-read-articles (group unread &optional compute)
11517 "Update the list of read articles in GROUP.
11518 UNREAD is a sorted list."
11519 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11520 (info (gnus-get-info group))
11523 (if (or (not info) (not active))
11524 ;; There is no info on this group if it was, in fact,
11525 ;; killed. Gnus stores no information on killed groups, so
11526 ;; there's nothing to be done.
11527 ;; One could store the information somewhere temporarily,
11528 ;; perhaps... Hmmm...
11530 ;; Remove any negative articles numbers.
11531 (while (and unread (< (car unread) 0))
11532 (setq unread (cdr unread)))
11533 ;; Remove any expired article numbers
11534 (while (and unread (< (car unread) (car active)))
11535 (setq unread (cdr unread)))
11536 ;; Compute the ranges of read articles by looking at the list of
11537 ;; unread articles.
11539 (when (/= (car unread) prev)
11540 (push (if (= prev (1- (car unread))) prev
11541 (cons prev (1- (car unread))))
11543 (setq prev (1+ (car unread)))
11544 (setq unread (cdr unread)))
11545 (when (<= prev (cdr active))
11546 (push (cons prev (cdr active)) read))
11547 (setq read (if (> (length read) 1) (nreverse read) read))
11552 ;; Propagate the read marks to the backend.
11553 (when (gnus-check-backend-function 'request-set-mark group)
11554 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11555 (add (gnus-remove-from-range read (gnus-info-read info))))
11557 (unless (gnus-check-group group)
11558 (error "Can't open server for %s" group))
11559 (gnus-request-set-mark
11560 group (delq nil (list (if add (list add 'add '(read)))
11561 (if del (list del 'del '(read))))))
11563 `(gnus-request-set-mark
11566 (if del (list del 'add '(read)))
11567 (if add (list add 'del '(read))))))))))
11568 (set-buffer gnus-group-buffer)
11569 (gnus-undo-register
11571 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11572 (gnus-info-set-read ',info ',(gnus-info-read info))
11573 (gnus-get-unread-articles-in-group ',info
11574 (gnus-active ,group))
11575 (gnus-group-update-group ,group t)
11577 ;; Enter this list into the group info.
11578 (gnus-info-set-read info read)
11579 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11580 (gnus-get-unread-articles-in-group info (gnus-active group))
11583 (defun gnus-offer-save-summaries ()
11584 "Offer to save all active summary buffers."
11586 ;; Go through all buffers and find all summaries.
11587 (dolist (buffer (buffer-list))
11588 (when (and (setq buffer (buffer-name buffer))
11589 (string-match "Summary" buffer)
11590 (with-current-buffer buffer
11591 ;; We check that this is, indeed, a summary buffer.
11592 (and (eq major-mode 'gnus-summary-mode)
11593 ;; Also make sure this isn't bogus.
11594 gnus-newsgroup-prepared
11595 ;; Also make sure that this isn't a
11596 ;; dead summary buffer.
11597 (not gnus-dead-summary-mode))))
11598 (push buffer buffers)))
11599 ;; Go through all these summary buffers and offer to save them.
11603 "Update summary buffer %s? "
11605 (switch-to-buffer buf)
11606 (gnus-summary-exit))
11610 ;;; @ for mime-partial
11613 (defun gnus-request-partial-message ()
11615 (let ((number (gnus-summary-article-number))
11616 (group gnus-newsgroup-name)
11617 (mother gnus-article-buffer))
11618 (set-buffer (get-buffer-create " *Partial Article*"))
11620 (setq mime-preview-buffer mother)
11621 (gnus-request-article-this-buffer number group)
11622 (mime-parse-buffer)
11625 (autoload 'mime-combine-message/partial-pieces-automatically
11627 "Internal method to combine message/partial messages automatically.")
11629 (mime-add-condition
11630 'action '((type . message)(subtype . partial)
11631 (major-mode . gnus-original-article-mode)
11632 (method . mime-combine-message/partial-pieces-automatically)
11633 (summary-buffer-exp . gnus-summary-buffer)
11634 (request-partial-message-method . gnus-request-partial-message)
11638 ;;; @ for message/rfc822
11641 (defun gnus-mime-extract-message/rfc822 (entity situation)
11642 "Burst a forwarded article."
11644 (set-buffer gnus-summary-buffer)
11645 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11646 gnus-newsgroup-name 'gnus-group-history))
11647 (gnus-group-marked (list group))
11650 (mime-insert-entity-content entity)
11651 (setq article (gnus-request-accept-article group)))
11652 (when (and (consp article)
11653 (numberp (setq article (cdr article))))
11654 (setq info (gnus-get-info group))
11655 (gnus-info-set-read info
11656 (gnus-remove-from-range (gnus-info-read info)
11658 (when (string-equal group gnus-newsgroup-name)
11660 (let (gnus-show-threads)
11661 (gnus-summary-goto-subject article t))
11662 (gnus-summary-clear-mark-forward 1))
11663 (set-buffer gnus-group-buffer)
11664 (gnus-group-get-new-news-this-group nil t)))))
11666 (mime-add-condition
11667 'action '((type . message)(subtype . rfc822)
11668 (major-mode . gnus-original-article-mode)
11669 (method . gnus-mime-extract-message/rfc822)
11673 (mime-add-condition
11674 'action '((type . message)(subtype . news)
11675 (major-mode . gnus-original-article-mode)
11676 (method . gnus-mime-extract-message/rfc822)
11680 (defun gnus-mime-extract-multipart (entity situation)
11681 (let ((children (mime-entity-children entity))
11682 mime-acting-situation-to-override
11685 (mime-play-entity (car children)
11686 (cons (assq 'mode situation)
11687 mime-acting-situation-to-override))
11688 (setq children (cdr children)))
11689 (if (setq f (cdr (assq 'after-method
11690 mime-acting-situation-to-override)))
11694 (mime-add-condition
11695 'action '((type . multipart)
11696 (method . gnus-mime-extract-multipart)
11705 (defun gnus-summary-inherit-default-charset ()
11706 "Import `default-mime-charset' from summary buffer.
11707 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11709 (if (buffer-live-p gnus-summary-buffer)
11710 (let (d-m-c d-m-c-u)
11711 (with-current-buffer gnus-summary-buffer
11712 (setq d-m-c (if (local-variable-p 'default-mime-charset
11713 gnus-summary-buffer)
11714 default-mime-charset
11717 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11718 gnus-summary-buffer)
11719 (symbol-value 'default-mime-charset-unlimited)
11722 (kill-local-variable 'default-mime-charset)
11723 (set (make-local-variable 'default-mime-charset) d-m-c))
11725 (kill-local-variable 'default-mime-charset-unlimited)
11726 (set (make-local-variable 'default-mime-charset-unlimited)
11729 (defun gnus-summary-setup-default-charset ()
11730 "Setup newsgroup default charset."
11731 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11733 (setq gnus-newsgroup-charset nil)
11734 (set (make-local-variable 'default-mime-charset) nil)
11735 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11736 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11737 (let ((ignored-charsets
11738 (or gnus-newsgroup-ephemeral-ignored-charsets
11740 (and gnus-newsgroup-name
11741 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11742 gnus-newsgroup-ignored-charsets)))
11744 (setq gnus-newsgroup-charset
11745 (or gnus-newsgroup-ephemeral-charset
11746 (when (and gnus-newsgroup-name
11747 (setq charset (gnus-parameter-charset
11748 gnus-newsgroup-name)))
11749 (make-local-variable 'default-mime-charset)
11750 (setq default-mime-charset charset))
11751 gnus-default-charset))
11752 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11753 ignored-charsets))))
11759 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11760 "Display the current article buffer fully MIME-buttonized.
11761 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11762 treated as multipart/mixed."
11764 (require 'gnus-art)
11765 (let ((gnus-unbuttonized-mime-types nil)
11766 (gnus-mime-display-multipart-as-mixed show-all-parts))
11767 (gnus-summary-show-article)))
11769 (defun gnus-summary-repair-multipart (article)
11770 "Add a Content-Type header to a multipart article without one."
11771 (interactive (list (gnus-summary-article-number)))
11772 (gnus-with-article article
11773 (message-narrow-to-head)
11774 (message-remove-header "Mime-Version")
11775 (goto-char (point-max))
11776 (insert "Mime-Version: 1.0\n")
11778 (when (search-forward "\n--" nil t)
11779 (let ((separator (buffer-substring (point) (point-at-eol))))
11780 (message-narrow-to-head)
11781 (message-remove-header "Content-Type")
11782 (goto-char (point-max))
11783 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11786 (let (gnus-mark-article-hook)
11787 (gnus-summary-select-article t t nil article)))
11789 (defun gnus-summary-toggle-display-buttonized ()
11790 "Toggle the buttonizing of the article buffer."
11792 (require 'gnus-art)
11793 (if (setq gnus-inhibit-mime-unbuttonizing
11794 (not gnus-inhibit-mime-unbuttonizing))
11795 (let ((gnus-unbuttonized-mime-types nil))
11796 (gnus-summary-show-article))
11797 (gnus-summary-show-article)))
11800 ;;; Intelli-mouse commmands
11803 (defun gnus-wheel-summary-scroll (event)
11805 (let ((amount (if (memq 'shift (event-modifiers event))
11806 (car gnus-wheel-scroll-amount)
11807 (cdr gnus-wheel-scroll-amount)))
11808 (direction (- (* (static-if (featurep 'xemacs)
11809 (event-button event)
11810 (cond ((eq 'mouse-4 (event-basic-type event))
11812 ((eq 'mouse-5 (event-basic-type event))
11816 (gnus-summary-scroll-up (* amount direction))
11817 (when (gnus-eval-in-buffer-window gnus-article-buffer
11820 (and (if (< 0 direction)
11821 (gnus-article-next-page 0)
11822 (gnus-article-prev-page 0)
11824 (if (setq edge (get-text-property
11825 (point-min) 'gnus-wheel-edge))
11826 (setq edge (* edge direction))
11829 (let ((buffer-read-only nil)
11830 (inhibit-read-only t))
11831 (put-text-property (point-min) (point-max)
11832 'gnus-wheel-edge direction)
11834 (or (> edge gnus-wheel-edge-resistance)
11835 (let ((buffer-read-only nil)
11836 (inhibit-read-only t))
11837 (put-text-property (point-min) (point-max)
11839 (* (1+ edge) direction))
11841 (eq last-command 'gnus-wheel-summary-scroll))))
11842 (gnus-summary-next-article nil nil (minusp direction)))))
11844 (defun gnus-wheel-install ()
11845 "Enable mouse wheel support on summary window."
11846 (when gnus-use-wheel
11848 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11850 (define-key gnus-summary-mode-map key
11851 'gnus-wheel-summary-scroll)))))
11853 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11856 ;;; Traditional PGP commmands
11859 (defun gnus-summary-decrypt-article (&optional force)
11860 "Decrypt the current article in traditional PGP way.
11861 This will have permanent effect only in mail groups.
11862 If FORCE is non-nil, allow editing of articles even in read-only
11865 (gnus-summary-select-article t)
11866 (gnus-eval-in-buffer-window gnus-article-buffer
11870 (goto-char (point-min))
11871 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11872 (error "Not a traditional PGP message!"))
11873 (let ((armor-start (match-beginning 0)))
11874 (if (and (pgg-decrypt-region armor-start (point-max))
11875 (or force (not (gnus-group-read-only-p))))
11876 (let ((inhibit-read-only t)
11878 (delete-region armor-start
11880 (re-search-forward "^-+END PGP" nil t)
11881 (beginning-of-line 2)
11883 (insert-buffer-substring pgg-output-buffer))))))))
11885 (defun gnus-summary-verify-article ()
11886 "Verify the current article in traditional PGP way."
11889 (set-buffer gnus-original-article-buffer)
11890 (goto-char (point-min))
11891 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11892 (error "Not a traditional PGP message!"))
11893 (re-search-forward "^-+END PGP" nil t)
11894 (beginning-of-line 2)
11895 (call-interactively (function pgg-verify-region))))
11898 ;;; Generic summary marking commands
11901 (defvar gnus-summary-marking-alist
11902 '((read gnus-del-mark "d")
11903 (unread gnus-unread-mark "u")
11904 (ticked gnus-ticked-mark "!")
11905 (dormant gnus-dormant-mark "?")
11906 (expirable gnus-expirable-mark "e"))
11907 "An alist of names/marks/keystrokes.")
11909 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11910 (defvar gnus-summary-mark-map)
11912 (defun gnus-summary-make-all-marking-commands ()
11913 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11914 (dolist (elem gnus-summary-marking-alist)
11915 (apply 'gnus-summary-make-marking-command elem)))
11917 (defun gnus-summary-make-marking-command (name mark keystroke)
11918 (let ((map (make-sparse-keymap)))
11919 (define-key gnus-summary-generic-mark-map keystroke map)
11920 (dolist (lway `((next "next" next nil "n")
11921 (next-unread "next unread" next t "N")
11922 (prev "previous" prev nil "p")
11923 (prev-unread "previous unread" prev t "P")
11924 (nomove "" nil nil ,keystroke)))
11925 (let ((func (gnus-summary-make-marking-command-1
11926 mark (car lway) lway name)))
11927 (setq func (eval func))
11928 (define-key map (nth 4 lway) func)))))
11930 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11932 (format "gnus-summary-put-mark-as-%s%s"
11933 name (if (eq way 'nomove)
11935 (concat "-" (symbol-name way)))))
11938 "Mark the current article as %s%s.
11939 If N, the prefix, then repeat N times.
11940 If N is negative, move in reverse order.
11941 The difference between N and the actual number of articles marked is
11943 name (car (cdr lway)))
11945 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11947 (defun gnus-summary-generic-mark (n mark move unread)
11948 "Mark N articles with MARK."
11949 (unless (eq major-mode 'gnus-summary-mode)
11950 (error "This command can only be used in the summary buffer"))
11951 (gnus-summary-show-thread)
11954 ((eq move 'next) 1)
11955 ((eq move 'prev) -1)
11957 (if (zerop nummove)
11961 nummove (* -1 nummove))))
11962 (while (and (> n 0)
11963 (gnus-summary-mark-article nil mark)
11964 (zerop (gnus-summary-next-subject nummove unread t)))
11967 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11968 (gnus-summary-recenter)
11969 (gnus-summary-position-point)
11970 (gnus-set-mode-line 'summary)
11973 (defun gnus-summary-insert-articles (articles)
11974 (when (setq articles
11975 (gnus-sorted-difference articles
11976 (mapcar (lambda (h)
11977 (mail-header-number h))
11978 gnus-newsgroup-headers)))
11979 (setq gnus-newsgroup-headers
11981 gnus-newsgroup-headers
11982 (gnus-fetch-headers articles)
11983 'gnus-article-sort-by-number))
11984 ;; Suppress duplicates?
11985 (when gnus-suppress-duplicates
11986 (gnus-dup-suppress-articles))
11988 ;; We might want to build some more threads first.
11989 (when (and gnus-fetch-old-headers
11990 (eq gnus-headers-retrieved-by 'nov))
11991 (if (eq gnus-fetch-old-headers 'invisible)
11992 (gnus-build-all-threads)
11993 (gnus-build-old-threads)))
11994 ;; Let the Gnus agent mark articles as read.
11996 (gnus-agent-get-undownloaded-list))
11997 ;; Remove list identifiers from subject
11998 (when gnus-list-identifiers
11999 (gnus-summary-remove-list-identifiers))
12000 ;; First and last article in this newsgroup.
12001 (when gnus-newsgroup-headers
12002 (setq gnus-newsgroup-begin
12003 (mail-header-number (car gnus-newsgroup-headers))
12005 (mail-header-number
12006 (gnus-last-element gnus-newsgroup-headers))))
12007 (when gnus-use-scoring
12008 (gnus-possibly-score-headers))))
12010 (defun gnus-summary-insert-old-articles (&optional all)
12011 "Insert all old articles in this group.
12012 If ALL is non-nil, already read articles become readable.
12013 If ALL is a number, fetch this number of articles."
12016 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12019 ;; Some nntp servers lie about their active range. When
12020 ;; this happens, the active range can be in the millions.
12021 ;; Use a compressed range to avoid creating a huge list.
12022 (gnus-range-difference (list gnus-newsgroup-active) old))
12023 (setq len (gnus-range-length older))
12028 (let ((older-range (nreverse older)))
12032 (let* ((r (pop older-range))
12033 (min (if (numberp r) r (car r)))
12034 (max (if (numberp r) r (cdr r))))
12035 (while (and (<= min max)
12040 (setq older (gnus-uncompress-range older))))
12042 (setq older (gnus-uncompress-range older)))
12044 (when (and (numberp gnus-large-newsgroup)
12045 (> len gnus-large-newsgroup))
12046 (let* ((cursor-in-echo-area nil)
12047 (initial (gnus-parameter-large-newsgroup-initial
12048 gnus-newsgroup-name))
12052 "How many articles from %s (%s %d): "
12054 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12055 (if initial "max" "default")
12058 (cons (number-to-string initial)
12060 (unless (string-match "^[ \t]*$" input)
12061 (setq all (string-to-number input))
12063 (let ((older-range (nreverse older)))
12067 (let* ((r (pop older-range))
12068 (min (if (numberp r) r (car r)))
12069 (max (if (numberp r) r (cdr r))))
12070 (while (and (<= min max)
12074 max (1- max))))))))))
12075 (setq older (gnus-uncompress-range older))))
12077 (message "No old news.")
12078 (gnus-summary-insert-articles older)
12079 (gnus-summary-limit (gnus-sorted-nunion old older))))
12080 (gnus-summary-position-point)))
12082 (defun gnus-summary-insert-new-articles ()
12083 "Insert all new articles in this group."
12086 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12087 (old-active gnus-newsgroup-active)
12088 (nnmail-fetched-sources (list t))
12090 (setq gnus-newsgroup-active
12091 (gnus-activate-group gnus-newsgroup-name 'scan))
12092 (setq i (cdr gnus-newsgroup-active))
12093 (while (> i (cdr old-active))
12097 (message "No gnus is bad news")
12098 (gnus-summary-insert-articles new)
12099 (setq gnus-newsgroup-unreads
12100 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12101 (gnus-summary-limit (gnus-sorted-nunion old new))))
12102 (gnus-summary-position-point)))
12104 (gnus-summary-make-all-marking-commands)
12106 (gnus-ems-redefine)
12108 (provide 'gnus-sum)
12110 (run-hooks 'gnus-sum-load-hook)
12112 ;; Local Variables:
12113 ;; coding: iso-8859-1
12116 ;;; gnus-sum.el ends here