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 non-nil, 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)
89 (sexp :menu-tag "other" t)))
91 (defcustom gnus-refer-thread-limit 200
92 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
93 If t, fetch all the available old headers."
96 (sexp :menu-tag "other" t)))
98 (defcustom gnus-summary-make-false-root 'adopt
99 "*nil means that Gnus won't gather loose threads.
100 If the root of a thread has expired or been read in a previous
101 session, the information necessary to build a complete thread has been
102 lost. Instead of having many small sub-threads from this original thread
103 scattered all over the summary buffer, Gnus can gather them.
105 If non-nil, Gnus will try to gather all loose sub-threads from an
106 original thread into one large thread.
108 If this variable is non-nil, it should be one of `none', `adopt',
111 If this variable is `none', Gnus will not make a false root, but just
112 present the sub-threads after another.
113 If this variable is `dummy', Gnus will create a dummy root that will
114 have all the sub-threads as children.
115 If this variable is `adopt', Gnus will make one of the \"children\"
116 the parent and mark all the step-children as such.
117 If this variable is `empty', the \"children\" are printed with empty
118 subject fields. (Or rather, they will be printed with a string
119 given by the `gnus-summary-same-subject' variable.)"
121 :type '(choice (const :tag "off" nil)
127 (defcustom gnus-summary-make-false-root-always nil
128 "Always make a false dummy root."
132 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
133 "*A regexp to match subjects to be excluded from loose thread gathering.
134 As loose thread gathering is done on subjects only, that means that
135 there can be many false gatherings performed. By rooting out certain
136 common subjects, gathering might become saner."
140 (defcustom gnus-summary-gather-subject-limit nil
141 "*Maximum length of subject comparisons when gathering loose threads.
142 Use nil to compare full subjects. Setting this variable to a low
143 number will help gather threads that have been corrupted by
144 newsreaders chopping off subject lines, but it might also mean that
145 unrelated articles that have subject that happen to begin with the
146 same few characters will be incorrectly gathered.
148 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
151 :type '(choice (const :tag "off" nil)
153 (sexp :menu-tag "on" t)))
155 (defcustom gnus-simplify-subject-functions nil
156 "List of functions taking a string argument that simplify subjects.
157 The functions are applied recursively.
159 Useful functions to put in this list include:
160 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
161 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
163 :type '(repeat function))
165 (defcustom gnus-simplify-ignored-prefixes nil
166 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
168 :type '(choice (const :tag "off" nil)
171 (defcustom gnus-build-sparse-threads nil
172 "*If non-nil, fill in the gaps in threads.
173 If `some', only fill in the gaps that are needed to tie loose threads
174 together. If `more', fill in all leaf nodes that Gnus can find. If
175 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
177 :type '(choice (const :tag "off" nil)
180 (sexp :menu-tag "all" t)))
182 (defcustom gnus-summary-thread-gathering-function
183 'gnus-gather-threads-by-subject
184 "*Function used for gathering loose threads.
185 There are two pre-defined functions: `gnus-gather-threads-by-subject',
186 which only takes Subjects into consideration; and
187 `gnus-gather-threads-by-references', which compared the References
188 headers of the articles to find matches."
190 :type '(radio (function-item gnus-gather-threads-by-subject)
191 (function-item gnus-gather-threads-by-references)
192 (function :tag "other")))
194 (defcustom gnus-summary-same-subject ""
195 "*String indicating that the current article has the same subject as the previous.
196 This variable will only be used if the value of
197 `gnus-summary-make-false-root' is `empty'."
198 :group 'gnus-summary-format
201 (defcustom gnus-summary-goto-unread t
202 "*If t, many commands will go to the next unread article.
203 This applies to marking commands as well as other commands that
204 \"naturally\" select the next article, like, for instance, `SPC' at
205 the end of an article.
207 If nil, the marking commands do NOT go to the next unread article
208 \(they go to the next article instead). If `never', commands that
209 usually go to the next unread article, will go to the next article,
210 whether it is read or not."
211 :group 'gnus-summary-marks
212 :link '(custom-manual "(gnus)Setting Marks")
213 :type '(choice (const :tag "off" nil)
215 (sexp :menu-tag "on" t)))
217 (defcustom gnus-summary-default-score 0
218 "*Default article score level.
219 All scores generated by the score files will be added to this score.
220 If this variable is nil, scoring will be disabled."
221 :group 'gnus-score-default
222 :type '(choice (const :tag "disable")
225 (defcustom gnus-summary-default-high-score 0
226 "*Default threshold for a high scored article.
227 An article will be highlighted as high scored if its score is greater
229 :group 'gnus-score-default
232 (defcustom gnus-summary-default-low-score 0
233 "*Default threshold for a low scored article.
234 An article will be highlighted as low scored if its score is smaller
236 :group 'gnus-score-default
239 (defcustom gnus-summary-zcore-fuzz 0
240 "*Fuzziness factor for the zcore in the summary buffer.
241 Articles with scores closer than this to `gnus-summary-default-score'
243 :group 'gnus-summary-format
246 (defcustom gnus-simplify-subject-fuzzy-regexp nil
247 "*Strings to be removed when doing fuzzy matches.
248 This can either be a regular expression or list of regular expressions
249 that will be removed from subject strings if fuzzy subject
250 simplification is selected."
252 :type '(repeat regexp))
254 (defcustom gnus-show-threads t
255 "*If non-nil, display threads in summary mode."
259 (defcustom gnus-thread-hide-subtree nil
260 "*If non-nil, hide all threads initially.
261 This can be a predicate specifier which says which threads to hide.
262 If threads are hidden, you have to run the command
263 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
264 to expose hidden threads."
266 :type '(radio (sexp :format "Non-nil\n"
267 :match (lambda (widget value)
268 (not (or (consp value) (functionp value))))
271 (sexp :tag "Predicate specifier" :size 0)))
273 (defcustom gnus-thread-hide-killed t
274 "*If non-nil, hide killed threads automatically."
278 (defcustom gnus-thread-ignore-subject t
279 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
280 If nil, articles that have different subjects from their parents will
281 start separate threads."
285 (defcustom gnus-thread-operation-ignore-subject t
286 "*If non-nil, subjects will be ignored when doing thread commands.
287 This affects commands like `gnus-summary-kill-thread' and
288 `gnus-summary-lower-thread'.
290 If this variable is nil, articles in the same thread with different
291 subjects will not be included in the operation in question. If this
292 variable is `fuzzy', only articles that have subjects that are fuzzily
293 equal will be included."
295 :type '(choice (const :tag "off" nil)
299 (defcustom gnus-thread-indent-level 4
300 "*Number that says how much each sub-thread should be indented."
304 (defcustom gnus-auto-extend-newsgroup t
305 "*If non-nil, extend newsgroup forward and backward when requested."
306 :group 'gnus-summary-choose
309 (defcustom gnus-auto-select-first t
310 "*If non-nil, select the article under point.
311 Which article this is is controlled by the `gnus-auto-select-subject'
314 If you want to prevent automatic selection of articles in some
315 newsgroups, set the variable to nil in `gnus-select-group-hook'."
316 :group 'gnus-group-select
317 :type '(choice (const :tag "none" nil)
318 (sexp :menu-tag "first" t)))
320 (defcustom gnus-auto-select-subject 'unread
321 "*Says what subject to place under point when entering a group.
323 This variable can either be the symbols `first' (place point on the
324 first subject), `unread' (place point on the subject line of the first
325 unread article), `best' (place point on the subject line of the
326 higest-scored article), `unseen' (place point on the subject line of
327 the first unseen article), 'unseen-or-unread' (place point on the subject
328 line of the first unseen article or, if all article have been seen, on the
329 subject line of the first unread article), or a function to be called to
330 place point on some subject line."
331 :group 'gnus-group-select
332 :type '(choice (const best)
336 (const unseen-or-unread)))
338 (defcustom gnus-dont-select-after-jump-to-other-group nil
339 "If non-nil, don't select the first unread article after entering the
340 other group by the command `gnus-summary-jump-to-other-group'. If nil,
341 it is depend on the value of `gnus-auto-select-first' whether to select
343 :group 'gnus-group-select
346 (defcustom gnus-auto-select-next t
347 "*If non-nil, offer to go to the next group from the end of the previous.
348 If the value is t and the next newsgroup is empty, Gnus will exit
349 summary mode and go back to group mode. If the value is neither nil
350 nor t, Gnus will select the following unread newsgroup. In
351 particular, if the value is the symbol `quietly', the next unread
352 newsgroup will be selected without any confirmation, and if it is
353 `almost-quietly', the next group will be selected without any
354 confirmation if you are located on the last article in the group.
355 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
356 will go to the next group without confirmation."
357 :group 'gnus-summary-maneuvering
358 :type '(choice (const :tag "off" nil)
360 (const almost-quietly)
361 (const slightly-quietly)
362 (sexp :menu-tag "on" t)))
364 (defcustom gnus-auto-select-same nil
365 "*If non-nil, select the next article with the same subject.
366 If there are no more articles with the same subject, go to
367 the first unread article."
368 :group 'gnus-summary-maneuvering
371 (defcustom gnus-auto-goto-ignores 'unfetched
372 "*Says how to handle unfetched articles when maneuvering.
374 This variable can either be the symbols nil (maneuver to any
375 article), `undownloaded' (maneuvering while unplugged ignores articles
376 that have not been fetched), `always-undownloaded' (maneuvering always
377 ignores articles that have not been fetched), `unfetched' (maneuvering
378 ignores articles whose headers have not been fetched).
380 NOTE: The list of unfetched articles will always be nil when plugged
381 and, when unplugged, a subset of the undownloaded article list."
382 :group 'gnus-summary-maneuvering
383 :type '(choice (const :tag "None" nil)
384 (const :tag "Undownloaded when unplugged" undownloaded)
385 (const :tag "Undownloaded" always-undownloaded)
386 (const :tag "Unfetched" unfetched)))
388 (defcustom gnus-summary-check-current nil
389 "*If non-nil, consider the current article when moving.
390 The \"unread\" movement commands will stay on the same line if the
391 current article is unread."
392 :group 'gnus-summary-maneuvering
395 (defcustom gnus-auto-center-summary 2
396 "*If non-nil, always center the current summary buffer.
397 In particular, if `vertical' do only vertical recentering. If non-nil
398 and non-`vertical', do both horizontal and vertical recentering."
399 :group 'gnus-summary-maneuvering
400 :type '(choice (const :tag "none" nil)
402 (integer :tag "height")
403 (sexp :menu-tag "both" t)))
405 (defvar gnus-auto-center-group t
406 "*If non-nil, always center the group buffer.")
408 (defcustom gnus-show-all-headers nil
409 "*If non-nil, don't hide any headers."
410 :group 'gnus-article-hiding
411 :group 'gnus-article-headers
414 (defcustom gnus-summary-ignore-duplicates nil
415 "*If non-nil, ignore articles with identical Message-ID headers."
419 (defcustom gnus-single-article-buffer t
420 "*If non-nil, display all articles in the same buffer.
421 If nil, each group will get its own article buffer."
422 :group 'gnus-article-various
425 (defcustom gnus-break-pages t
426 "*If non-nil, do page breaking on articles.
427 The page delimiter is specified by the `gnus-page-delimiter'
429 :group 'gnus-article-various
432 (defcustom gnus-show-mime t
433 "*If non-nil, do mime processing of articles.
434 The articles will simply be fed to the function given by
435 `gnus-article-display-method-for-mime'."
436 :group 'gnus-article-mime
439 (defcustom gnus-move-split-methods nil
440 "*Variable used to suggest where articles are to be moved to.
441 It uses the same syntax as the `gnus-split-methods' variable.
442 However, whereas `gnus-split-methods' specifies file names as targets,
443 this variable specifies group names."
444 :group 'gnus-summary-mail
445 :type '(repeat (choice (list :value (fun) function)
446 (cons :value ("" "") regexp (repeat string))
449 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
450 "Function used to compute default prefix for article move/copy/etc prompts.
451 The function should take one argument, a group name, and return a
452 string with the suggested prefix."
453 :group 'gnus-summary-mail
456 (defcustom gnus-unread-mark ?\ ;;;Whitespace
457 "*Mark used for unread articles."
458 :group 'gnus-summary-marks
461 (defcustom gnus-ticked-mark ?!
462 "*Mark used for ticked articles."
463 :group 'gnus-summary-marks
466 (defcustom gnus-dormant-mark ??
467 "*Mark used for dormant articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-del-mark ?r
472 "*Mark used for del'd articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-read-mark ?R
477 "*Mark used for read articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-expirable-mark ?E
482 "*Mark used for expirable articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-killed-mark ?K
487 "*Mark used for killed articles."
488 :group 'gnus-summary-marks
491 (defcustom gnus-spam-mark ?$
492 "*Mark used for spam articles."
493 :group 'gnus-summary-marks
496 (defcustom gnus-souped-mark ?F
497 "*Mark used for souped articles."
498 :group 'gnus-summary-marks
501 (defcustom gnus-kill-file-mark ?X
502 "*Mark used for articles killed by kill files."
503 :group 'gnus-summary-marks
506 (defcustom gnus-low-score-mark ?Y
507 "*Mark used for articles with a low score."
508 :group 'gnus-summary-marks
511 (defcustom gnus-catchup-mark ?C
512 "*Mark used for articles that are caught up."
513 :group 'gnus-summary-marks
516 (defcustom gnus-replied-mark ?A
517 "*Mark used for articles that have been replied to."
518 :group 'gnus-summary-marks
521 (defcustom gnus-forwarded-mark ?F
522 "*Mark used for articles that have been forwarded."
523 :group 'gnus-summary-marks
526 (defcustom gnus-recent-mark ?N
527 "*Mark used for articles that are recent."
528 :group 'gnus-summary-marks
531 (defcustom gnus-cached-mark ?*
532 "*Mark used for articles that are in the cache."
533 :group 'gnus-summary-marks
536 (defcustom gnus-saved-mark ?S
537 "*Mark used for articles that have been saved."
538 :group 'gnus-summary-marks
541 (defcustom gnus-unseen-mark ?.
542 "*Mark used for articles that haven't been seen."
543 :group 'gnus-summary-marks
546 (defcustom gnus-no-mark ?\ ;;;Whitespace
547 "*Mark used for articles that have no other secondary mark."
548 :group 'gnus-summary-marks
551 (defcustom gnus-ancient-mark ?O
552 "*Mark used for ancient articles."
553 :group 'gnus-summary-marks
556 (defcustom gnus-sparse-mark ?Q
557 "*Mark used for sparsely reffed articles."
558 :group 'gnus-summary-marks
561 (defcustom gnus-canceled-mark ?G
562 "*Mark used for canceled articles."
563 :group 'gnus-summary-marks
566 (defcustom gnus-duplicate-mark ?M
567 "*Mark used for duplicate articles."
568 :group 'gnus-summary-marks
571 (defcustom gnus-undownloaded-mark ?-
572 "*Mark used for articles that weren't downloaded."
573 :group 'gnus-summary-marks
576 (defcustom gnus-downloaded-mark ?+
577 "*Mark used for articles that were downloaded."
578 :group 'gnus-summary-marks
581 (defcustom gnus-downloadable-mark ?%
582 "*Mark used for articles that are to be downloaded."
583 :group 'gnus-summary-marks
586 (defcustom gnus-unsendable-mark ?=
587 "*Mark used for articles that won't be sent."
588 :group 'gnus-summary-marks
591 (defcustom gnus-score-over-mark ?+
592 "*Score mark used for articles with high scores."
593 :group 'gnus-summary-marks
596 (defcustom gnus-score-below-mark ?-
597 "*Score mark used for articles with low scores."
598 :group 'gnus-summary-marks
601 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
602 "*There is no thread under the article."
603 :group 'gnus-summary-marks
606 (defcustom gnus-not-empty-thread-mark ?=
607 "*There is a thread under the article."
608 :group 'gnus-summary-marks
611 (defcustom gnus-view-pseudo-asynchronously nil
612 "*If non-nil, Gnus will view pseudo-articles asynchronously."
613 :group 'gnus-extract-view
616 (defcustom gnus-auto-expirable-marks
617 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
618 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
619 gnus-souped-mark gnus-duplicate-mark)
620 "*The list of marks converted into expiration if a group is auto-expirable."
623 :type '(repeat character))
625 (defcustom gnus-inhibit-user-auto-expire t
626 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
631 (defcustom gnus-view-pseudos nil
632 "*If `automatic', pseudo-articles will be viewed automatically.
633 If `not-confirm', pseudos will be viewed automatically, and the user
634 will not be asked to confirm the command."
635 :group 'gnus-extract-view
636 :type '(choice (const :tag "off" nil)
638 (const not-confirm)))
640 (defcustom gnus-view-pseudos-separately t
641 "*If non-nil, one pseudo-article will be created for each file to be viewed.
642 If nil, all files that use the same viewing command will be given as a
643 list of parameters to that command."
644 :group 'gnus-extract-view
647 (defcustom gnus-insert-pseudo-articles t
648 "*If non-nil, insert pseudo-articles when decoding articles."
649 :group 'gnus-extract-view
652 (defcustom gnus-summary-dummy-line-format
654 "*The format specification for the dummy roots in the summary buffer.
655 It works along the same lines as a normal formatting string,
656 with some simple extensions.
660 General format specifiers can also be used.
661 See `(gnus)Formatting Variables'."
662 :link '(custom-manual "(gnus)Formatting Variables")
663 :group 'gnus-threading
666 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
667 "*The format specification for the summary mode line.
668 It works along the same lines as a normal formatting string,
669 with some simple extensions:
672 %p Unprefixed group name
673 %A Current article number
674 %z Current article score
676 %U Number of unread articles in the group
677 %e Number of unselected articles in the group
678 %Z A string with unread/unselected article counts
679 %g Shortish group name
680 %S Subject of the current article
682 %s Current score file name
683 %d Number of dormant articles
684 %r Number of articles that have been marked as read in this session
685 %E Number of articles expunged by the score files"
686 :group 'gnus-summary-format
689 (defcustom gnus-list-identifiers nil
690 "Regexp that matches list identifiers to be removed from subject.
691 This can also be a list of regexps."
693 :group 'gnus-summary-format
694 :group 'gnus-article-hiding
695 :type '(choice (const :tag "none" nil)
697 (repeat :value (".*") regexp)))
699 (defcustom gnus-summary-mark-below 0
700 "*Mark all articles with a score below this variable as read.
701 This variable is local to each summary buffer and usually set by the
703 :group 'gnus-score-default
706 (defun gnus-widget-reversible-match (widget value)
707 "Ignoring WIDGET, convert VALUE to internal form.
708 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
712 (eq (length value) 2)
713 (eq (nth 0 value) 'not)
714 (symbolp (nth 1 value)))))
716 (defun gnus-widget-reversible-to-internal (widget value)
717 "Ignoring WIDGET, convert VALUE to internal form.
718 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
719 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
723 (list (nth 1 value) t)))
725 (defun gnus-widget-reversible-to-external (widget value)
726 "Ignoring WIDGET, convert VALUE to external form.
727 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
728 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
731 (list 'not (nth 0 value))
734 (define-widget 'gnus-widget-reversible 'group
735 "A `group' that convert values."
736 :match 'gnus-widget-reversible-match
737 :value-to-internal 'gnus-widget-reversible-to-internal
738 :value-to-external 'gnus-widget-reversible-to-external)
740 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
741 "*List of functions used for sorting articles in the summary buffer.
743 Each function takes two articles and returns non-nil if the first
744 article should be sorted before the other. If you use more than one
745 function, the primary sort function should be the last. You should
746 probably always include `gnus-article-sort-by-number' in the list of
747 sorting functions -- preferably first. Also note that sorting by date
748 is often much slower than sorting by number, and the sorting order is
749 very similar. (Sorting by date means sorting by the time the message
750 was sent, sorting by number means sorting by arrival time.)
752 Each item can also be a list `(not F)' where F is a function;
753 this reverses the sort order.
755 Ready-made functions include `gnus-article-sort-by-number',
756 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
757 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
758 and `gnus-article-sort-by-score'.
760 When threading is turned on, the variable `gnus-thread-sort-functions'
761 controls how articles are sorted."
762 :group 'gnus-summary-sort
763 :type '(repeat (gnus-widget-reversible
764 (choice (function-item gnus-article-sort-by-number)
765 (function-item gnus-article-sort-by-author)
766 (function-item gnus-article-sort-by-subject)
767 (function-item gnus-article-sort-by-date)
768 (function-item gnus-article-sort-by-score)
769 (function-item gnus-article-sort-by-random)
770 (function :tag "other"))
771 (boolean :tag "Reverse order"))))
774 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
775 "*List of functions used for sorting threads in the summary buffer.
776 By default, threads are sorted by article number.
778 Each function takes two threads and returns non-nil if the first
779 thread should be sorted before the other. If you use more than one
780 function, the primary sort function should be the last. You should
781 probably always include `gnus-thread-sort-by-number' in the list of
782 sorting functions -- preferably first. Also note that sorting by date
783 is often much slower than sorting by number, and the sorting order is
784 very similar. (Sorting by date means sorting by the time the message
785 was sent, sorting by number means sorting by arrival time.)
787 Each list item can also be a list `(not F)' where F is a
788 function; this specifies reversed sort order.
790 Ready-made functions include `gnus-thread-sort-by-number',
791 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
792 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
793 `gnus-thread-sort-by-most-recent-number',
794 `gnus-thread-sort-by-most-recent-date',
795 `gnus-thread-sort-by-random', and
796 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
798 When threading is turned off, the variable
799 `gnus-article-sort-functions' controls how articles are sorted."
800 :group 'gnus-summary-sort
802 (gnus-widget-reversible
803 (choice (function-item gnus-thread-sort-by-number)
804 (function-item gnus-thread-sort-by-author)
805 (function-item gnus-thread-sort-by-subject)
806 (function-item gnus-thread-sort-by-date)
807 (function-item gnus-thread-sort-by-score)
808 (function-item gnus-thread-sort-by-most-recent-number)
809 (function-item gnus-thread-sort-by-most-recent-date)
810 (function-item gnus-thread-sort-by-random)
811 (function-item gnus-thread-sort-by-total-score)
812 (function :tag "other"))
813 (boolean :tag "Reverse order"))))
815 (defcustom gnus-thread-score-function '+
816 "*Function used for calculating the total score of a thread.
818 The function is called with the scores of the article and each
819 subthread and should then return the score of the thread.
821 Some functions you can use are `+', `max', or `min'."
822 :group 'gnus-summary-sort
825 (defcustom gnus-summary-expunge-below nil
826 "All articles that have a score less than this variable will be expunged.
827 This variable is local to the summary buffers."
828 :group 'gnus-score-default
829 :type '(choice (const :tag "off" nil)
832 (defcustom gnus-thread-expunge-below nil
833 "All threads that have a total score less than this variable will be expunged.
834 See `gnus-thread-score-function' for en explanation of what a
837 This variable is local to the summary buffers."
838 :group 'gnus-threading
839 :group 'gnus-score-default
840 :type '(choice (const :tag "off" nil)
843 (defcustom gnus-summary-mode-hook nil
844 "*A hook for Gnus summary mode.
845 This hook is run before any variables are set in the summary buffer."
846 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
847 :group 'gnus-summary-various
850 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
851 (when (featurep 'xemacs)
852 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
853 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
854 (add-hook 'gnus-summary-mode-hook
855 'gnus-xmas-switch-horizontal-scrollbar-off))
857 (defcustom gnus-summary-menu-hook nil
858 "*Hook run after the creation of the summary mode menu."
859 :group 'gnus-summary-visual
862 (defcustom gnus-summary-exit-hook nil
863 "*A hook called on exit from the summary buffer.
864 It will be called with point in the group buffer."
865 :group 'gnus-summary-exit
868 (defcustom gnus-summary-prepare-hook nil
869 "*A hook called after the summary buffer has been generated.
870 If you want to modify the summary buffer, you can use this hook."
871 :group 'gnus-summary-various
874 (defcustom gnus-summary-prepared-hook nil
875 "*A hook called as the last thing after the summary buffer has been generated."
876 :group 'gnus-summary-various
879 (defcustom gnus-summary-generate-hook nil
880 "*A hook run just before generating the summary buffer.
881 This hook is commonly used to customize threading variables and the
883 :group 'gnus-summary-various
886 (defcustom gnus-select-group-hook nil
887 "*A hook called when a newsgroup is selected.
889 If you'd like to simplify subjects like the
890 `gnus-summary-next-same-subject' command does, you can use the
893 (add-hook gnus-select-group-hook
895 (mapcar (lambda (header)
896 (mail-header-set-subject
898 (gnus-simplify-subject
899 (mail-header-subject header) 're-only)))
900 gnus-newsgroup-headers)))"
901 :group 'gnus-group-select
904 (defcustom gnus-select-article-hook nil
905 "*A hook called when an article is selected."
906 :group 'gnus-summary-choose
907 :options '(gnus-agent-fetch-selected-article)
910 (defcustom gnus-visual-mark-article-hook
911 (list 'gnus-highlight-selected-summary)
912 "*Hook run after selecting an article in the summary buffer.
913 It is meant to be used for highlighting the article in some way. It
914 is not run if `gnus-visual' is nil."
915 :group 'gnus-summary-visual
918 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
919 "*A hook called before parsing the headers."
923 (defcustom gnus-exit-group-hook nil
924 "*A hook called when exiting summary mode.
925 This hook is not called from the non-updating exit commands like `Q'."
929 (defcustom gnus-summary-update-hook
930 (list 'gnus-summary-highlight-line)
931 "*A hook called when a summary line is changed.
932 The hook will not be called if `gnus-visual' is nil.
934 The default function `gnus-summary-highlight-line' will
935 highlight the line according to the `gnus-summary-highlight'
937 :group 'gnus-summary-visual
940 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
941 "*A hook called when an article is selected for the first time.
942 The hook is intended to mark an article as read (or unread)
943 automatically when it is selected."
944 :group 'gnus-summary-choose
947 (defcustom gnus-group-no-more-groups-hook nil
948 "*A hook run when returning to group mode having no more (unread) groups."
949 :group 'gnus-group-select
952 (defcustom gnus-ps-print-hook nil
953 "*A hook run before ps-printing something from Gnus."
957 (defcustom gnus-summary-article-move-hook nil
958 "*A hook called after an article is moved, copied, respooled, or crossposted."
962 (defcustom gnus-summary-article-delete-hook nil
963 "*A hook called after an article is deleted."
967 (defcustom gnus-summary-article-expire-hook nil
968 "*A hook called after an article is expired."
972 (defcustom gnus-summary-display-arrow
973 (and (fboundp 'display-graphic-p)
975 "*If non-nil, display an arrow highlighting the current article."
980 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
981 "Face used for highlighting the current article in the summary buffer."
982 :group 'gnus-summary-visual
985 (defvar gnus-tmp-downloaded nil)
987 (defcustom gnus-summary-highlight
988 '(((eq mark gnus-canceled-mark)
989 . gnus-summary-cancelled-face)
990 ((and uncached (> score default-high))
991 . gnus-summary-high-undownloaded-face)
992 ((and uncached (< score default-low))
993 . gnus-summary-low-undownloaded-face)
995 . gnus-summary-normal-undownloaded-face)
996 ((and (> score default-high)
997 (or (eq mark gnus-dormant-mark)
998 (eq mark gnus-ticked-mark)))
999 . gnus-summary-high-ticked-face)
1000 ((and (< score default-low)
1001 (or (eq mark gnus-dormant-mark)
1002 (eq mark gnus-ticked-mark)))
1003 . gnus-summary-low-ticked-face)
1004 ((or (eq mark gnus-dormant-mark)
1005 (eq mark gnus-ticked-mark))
1006 . gnus-summary-normal-ticked-face)
1007 ((and (> score default-high) (eq mark gnus-ancient-mark))
1008 . gnus-summary-high-ancient-face)
1009 ((and (< score default-low) (eq mark gnus-ancient-mark))
1010 . gnus-summary-low-ancient-face)
1011 ((eq mark gnus-ancient-mark)
1012 . gnus-summary-normal-ancient-face)
1013 ((and (> score default-high) (eq mark gnus-unread-mark))
1014 . gnus-summary-high-unread-face)
1015 ((and (< score default-low) (eq mark gnus-unread-mark))
1016 . gnus-summary-low-unread-face)
1017 ((eq mark gnus-unread-mark)
1018 . gnus-summary-normal-unread-face)
1019 ((> score default-high)
1020 . gnus-summary-high-read-face)
1021 ((< score default-low)
1022 . gnus-summary-low-read-face)
1024 . gnus-summary-normal-read-face))
1025 "*Controls the highlighting of summary buffer lines.
1027 A list of (FORM . FACE) pairs. When deciding how a a particular
1028 summary line should be displayed, each form is evaluated. The content
1029 of the face field after the first true form is used. You can change
1030 how those summary lines are displayed, by editing the face field.
1032 You can use the following variables in the FORM field.
1034 score: The article's score
1035 default: The default article score.
1036 default-high: The default score for high scored articles.
1037 default-low: The default score for low scored articles.
1038 below: The score below which articles are automatically marked as read.
1039 mark: The article's mark.
1040 uncached: Non-nil if the article is uncached."
1041 :group 'gnus-summary-visual
1042 :type '(repeat (cons (sexp :tag "Form" nil)
1045 (defcustom gnus-alter-header-function nil
1046 "Function called to allow alteration of article header structures.
1047 The function is called with one parameter, the article header vector,
1048 which it may alter in any way."
1049 :type '(choice (const :tag "None" nil)
1051 :group 'gnus-summary)
1053 (defvar gnus-decode-encoded-word-function
1054 (mime-find-field-decoder 'From 'nov)
1055 "Variable that says which function should be used to decode a string with encoded words.")
1057 (defcustom gnus-extra-headers '(To Newsgroups)
1058 "*Extra headers to parse."
1060 :group 'gnus-summary
1061 :type '(repeat symbol))
1063 (defcustom gnus-ignored-from-addresses
1064 (and user-mail-address (regexp-quote user-mail-address))
1065 "*Regexp of From headers that may be suppressed in favor of To headers."
1067 :group 'gnus-summary
1070 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1071 "List of charsets that should be ignored.
1072 When these charsets are used in the \"charset\" parameter, the
1073 default charset will be used instead."
1075 :type '(repeat symbol)
1076 :group 'gnus-charset)
1078 (gnus-define-group-parameter
1082 "Return the ignored charsets of GROUP."
1083 :variable gnus-group-ignored-charsets-alist
1085 '(("alt\\.chinese\\.text" iso-8859-1))
1087 "Alist of regexps (to match group names) and charsets that should be ignored.
1088 When these charsets are used in the \"charset\" parameter, the
1089 default charset will be used instead."
1090 :variable-group gnus-charset
1091 :variable-type '(repeat (cons (regexp :tag "Group")
1093 :parameter-type '(choice :tag "Ignored charsets"
1096 :parameter-document "\
1097 List of charsets that should be ignored.
1099 When these charsets are used in the \"charset\" parameter, the
1100 default charset will be used instead.")
1102 (defcustom gnus-group-highlight-words-alist nil
1103 "Alist of group regexps and highlight regexps.
1104 This variable uses the same syntax as `gnus-emphasis-alist'."
1106 :type '(repeat (cons (regexp :tag "Group")
1107 (repeat (list (regexp :tag "Highlight regexp")
1108 (number :tag "Group for entire word" 0)
1109 (number :tag "Group for displayed part" 0)
1111 gnus-emphasis-highlight-words)))))
1112 :group 'gnus-summary-visual)
1114 (defcustom gnus-use-wheel nil
1115 "Use Intelli-mouse on summary movement"
1117 :group 'gnus-summary-maneuvering)
1119 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1120 "Amount to scroll messages by spinning the mouse wheel.
1121 This is actually a cons cell, where the first item is the amount to scroll
1122 on a normal wheel event, and the second is the amount to scroll when the
1123 wheel is moved with the shift key depressed."
1124 :type '(cons (integer :tag "Shift") integer)
1125 :group 'gnus-summary-maneuvering)
1127 (defcustom gnus-wheel-edge-resistance 2
1128 "How hard it should be to change the current article
1129 by moving the mouse over the edge of the article window."
1131 :group 'gnus-summary-maneuvering)
1133 (defcustom gnus-summary-show-article-charset-alist
1135 "Alist of number and charset.
1136 The article will be shown with the charset corresponding to the
1138 For example: ((1 . cn-gb-2312) (2 . big5))."
1140 :type '(repeat (cons (number :tag "Argument" 1)
1141 (symbol :tag "Charset")))
1142 :group 'gnus-charset)
1144 (defcustom gnus-preserve-marks t
1145 "Whether marks are preserved when moving, copying and respooling messages."
1148 :group 'gnus-summary-marks)
1150 (defcustom gnus-alter-articles-to-read-function nil
1151 "Function to be called to alter the list of articles to be selected."
1152 :type '(choice (const nil) function)
1153 :group 'gnus-summary)
1155 (defcustom gnus-orphan-score nil
1156 "*All orphans get this score added. Set in the score file."
1157 :group 'gnus-score-default
1158 :type '(choice (const nil)
1161 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1162 "*A regexp to match MIME parts when saving multiple parts of a
1163 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1164 This regexp will be used by default when prompting the user for which
1165 type of files to save."
1166 :group 'gnus-summary
1169 (defcustom gnus-read-all-available-headers nil
1170 "Whether Gnus should parse all headers made available to it.
1171 This is mostly relevant for slow back ends where the user may
1172 wish to widen the summary buffer to include all headers
1173 that were fetched. Say, for nnultimate groups."
1174 :group 'gnus-summary
1175 :type '(choice boolean regexp))
1177 (defcustom gnus-summary-muttprint-program "muttprint"
1178 "Command (and optional arguments) used to run Muttprint."
1180 :group 'gnus-summary
1183 (defcustom gnus-article-loose-mime t
1184 "If non-nil, don't require MIME-Version header.
1185 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1186 supply the MIME-Version header or deliberately strip it from the mail.
1187 If non-nil (the default), Gnus will treat some articles as MIME
1188 even if the MIME-Version header is missing."
1191 :group 'gnus-article-mime)
1193 (defcustom gnus-article-emulate-mime t
1194 "If non-nil, use MIME emulation for uuencode and the like.
1195 This means that Gnus will search message bodies for text that look
1196 like uuencoded bits, yEncoded bits, and so on, and present that using
1197 the normal Gnus MIME machinery."
1199 :group 'gnus-article-mime)
1201 ;;; Internal variables
1203 (defvar gnus-summary-display-cache nil)
1204 (defvar gnus-article-mime-handles nil)
1205 (defvar gnus-article-decoded-p nil)
1206 (defvar gnus-article-charset nil)
1207 (defvar gnus-article-ignored-charsets nil)
1208 (defvar gnus-scores-exclude-files nil)
1209 (defvar gnus-page-broken nil)
1211 (defvar gnus-original-article nil)
1212 (defvar gnus-article-internal-prepare-hook nil)
1213 (defvar gnus-newsgroup-process-stack nil)
1215 (defvar gnus-thread-indent-array nil)
1216 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1217 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1218 "Function called to sort the articles within a thread after it has been gathered together.")
1220 (defvar gnus-summary-save-parts-type-history nil)
1221 (defvar gnus-summary-save-parts-last-directory nil)
1223 ;; Avoid highlighting in kill files.
1224 (defvar gnus-summary-inhibit-highlight nil)
1225 (defvar gnus-newsgroup-selected-overlay nil)
1226 (defvar gnus-inhibit-limiting nil)
1227 (defvar gnus-newsgroup-adaptive-score-file nil)
1228 (defvar gnus-current-score-file nil)
1229 (defvar gnus-current-move-group nil)
1230 (defvar gnus-current-copy-group nil)
1231 (defvar gnus-current-crosspost-group nil)
1232 (defvar gnus-newsgroup-display nil)
1234 (defvar gnus-newsgroup-dependencies nil)
1235 (defvar gnus-newsgroup-adaptive nil)
1236 (defvar gnus-summary-display-article-function nil)
1237 (defvar gnus-summary-highlight-line-function nil
1238 "Function called after highlighting a summary line.")
1240 (defvar gnus-summary-line-format-alist
1241 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1242 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1243 (?s gnus-tmp-subject-or-nil ?s)
1244 (?n gnus-tmp-name ?s)
1245 (?A (std11-address-string
1246 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1247 (?a (or (std11-full-name-string
1248 (car (mime-entity-read-field gnus-tmp-header 'From)))
1250 (?F gnus-tmp-from ?s)
1251 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1252 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1253 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1254 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1255 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1256 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1257 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1258 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1259 (?L gnus-tmp-lines ?s)
1260 (?O gnus-tmp-downloaded ?c)
1261 (?I gnus-tmp-indentation ?s)
1262 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1263 (?R gnus-tmp-replied ?c)
1264 (?\[ gnus-tmp-opening-bracket ?c)
1265 (?\] gnus-tmp-closing-bracket ?c)
1266 (?\> (make-string gnus-tmp-level ? ) ?s)
1267 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1268 (?i gnus-tmp-score ?d)
1269 (?z gnus-tmp-score-char ?c)
1270 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1271 (?U gnus-tmp-unread ?c)
1272 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1274 (?t (gnus-summary-number-of-articles-in-thread
1275 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1277 (?e (gnus-summary-number-of-articles-in-thread
1278 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1280 (?u gnus-tmp-user-defined ?s)
1281 (?P (gnus-pick-line-number) ?d)
1282 (?B gnus-tmp-thread-tree-header-string ?s)
1283 (user-date (gnus-user-date
1284 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1285 "An alist of format specifications that can appear in summary lines.
1286 These are paired with what variables they correspond with, along with
1287 the type of the variable (string, integer, character, etc).")
1289 (defvar gnus-summary-dummy-line-format-alist
1290 `((?S gnus-tmp-subject ?s)
1291 (?N gnus-tmp-number ?d)
1292 (?u gnus-tmp-user-defined ?s)))
1294 (defvar gnus-summary-mode-line-format-alist
1295 `((?G gnus-tmp-group-name ?s)
1296 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1297 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1298 (?A gnus-tmp-article-number ?d)
1299 (?Z gnus-tmp-unread-and-unselected ?s)
1300 (?V gnus-version ?s)
1301 (?U gnus-tmp-unread-and-unticked ?d)
1302 (?S gnus-tmp-subject ?s)
1303 (?e gnus-tmp-unselected ?d)
1304 (?u gnus-tmp-user-defined ?s)
1305 (?d (length gnus-newsgroup-dormant) ?d)
1306 (?t (length gnus-newsgroup-marked) ?d)
1307 (?h (length gnus-newsgroup-spam-marked) ?d)
1308 (?r (length gnus-newsgroup-reads) ?d)
1309 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1310 (?E gnus-newsgroup-expunged-tally ?d)
1311 (?s (gnus-current-score-file-nondirectory) ?s)))
1313 (defvar gnus-last-search-regexp nil
1314 "Default regexp for article search command.")
1316 (defvar gnus-summary-search-article-matched-data nil
1317 "Last matched data of article search command. It is the local variable
1318 in `gnus-article-buffer' which consists of the list of start position,
1319 end position and text.")
1321 (defvar gnus-last-shell-command nil
1322 "Default shell command on article.")
1324 (defvar gnus-newsgroup-agentized nil
1325 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1326 (defvar gnus-newsgroup-begin nil)
1327 (defvar gnus-newsgroup-end nil)
1328 (defvar gnus-newsgroup-last-rmail nil)
1329 (defvar gnus-newsgroup-last-mail nil)
1330 (defvar gnus-newsgroup-last-folder nil)
1331 (defvar gnus-newsgroup-last-file nil)
1332 (defvar gnus-newsgroup-auto-expire nil)
1333 (defvar gnus-newsgroup-active nil)
1335 (defvar gnus-newsgroup-data nil)
1336 (defvar gnus-newsgroup-data-reverse nil)
1337 (defvar gnus-newsgroup-limit nil)
1338 (defvar gnus-newsgroup-limits nil)
1339 (defvar gnus-summary-use-undownloaded-faces nil)
1341 (defvar gnus-newsgroup-unreads nil
1342 "Sorted list of unread articles in the current newsgroup.")
1344 (defvar gnus-newsgroup-unselected nil
1345 "Sorted list of unselected unread articles in the current newsgroup.")
1347 (defvar gnus-newsgroup-reads nil
1348 "Alist of read articles and article marks in the current newsgroup.")
1350 (defvar gnus-newsgroup-expunged-tally nil)
1352 (defvar gnus-newsgroup-marked nil
1353 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1355 (defvar gnus-newsgroup-spam-marked nil
1356 "List of ranges of articles that have been marked as spam.")
1358 (defvar gnus-newsgroup-killed nil
1359 "List of ranges of articles that have been through the scoring process.")
1361 (defvar gnus-newsgroup-cached nil
1362 "Sorted list of articles that come from the article cache.")
1364 (defvar gnus-newsgroup-saved nil
1365 "List of articles that have been saved.")
1367 (defvar gnus-newsgroup-kill-headers nil)
1369 (defvar gnus-newsgroup-replied nil
1370 "List of articles that have been replied to in the current newsgroup.")
1372 (defvar gnus-newsgroup-forwarded nil
1373 "List of articles that have been forwarded in the current newsgroup.")
1375 (defvar gnus-newsgroup-recent nil
1376 "List of articles that have are recent in the current newsgroup.")
1378 (defvar gnus-newsgroup-expirable nil
1379 "Sorted list of articles in the current newsgroup that can be expired.")
1381 (defvar gnus-newsgroup-processable nil
1382 "List of articles in the current newsgroup that can be processed.")
1384 (defvar gnus-newsgroup-downloadable nil
1385 "Sorted list of articles in the current newsgroup that can be processed.")
1387 (defvar gnus-newsgroup-unfetched nil
1388 "Sorted list of articles in the current newsgroup whose headers have
1389 not been fetched into the agent.
1391 This list will always be a subset of gnus-newsgroup-undownloaded.")
1393 (defvar gnus-newsgroup-undownloaded nil
1394 "List of articles in the current newsgroup that haven't been downloaded.")
1396 (defvar gnus-newsgroup-unsendable nil
1397 "List of articles in the current newsgroup that won't be sent.")
1399 (defvar gnus-newsgroup-bookmarks nil
1400 "List of articles in the current newsgroup that have bookmarks.")
1402 (defvar gnus-newsgroup-dormant nil
1403 "Sorted list of dormant articles in the current newsgroup.")
1405 (defvar gnus-newsgroup-unseen nil
1406 "List of unseen articles in the current newsgroup.")
1408 (defvar gnus-newsgroup-seen nil
1409 "Range of seen articles in the current newsgroup.")
1411 (defvar gnus-newsgroup-articles nil
1412 "List of articles in the current newsgroup.")
1414 (defvar gnus-newsgroup-scored nil
1415 "List of scored articles in the current newsgroup.")
1417 (defvar gnus-newsgroup-incorporated nil
1418 "List of incorporated articles in the current newsgroup.")
1420 (defvar gnus-newsgroup-headers nil
1421 "List of article headers in the current newsgroup.")
1423 (defvar gnus-newsgroup-threads nil)
1425 (defvar gnus-newsgroup-prepared nil
1426 "Whether the current group has been prepared properly.")
1428 (defvar gnus-newsgroup-ancient nil
1429 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1431 (defvar gnus-newsgroup-sparse nil)
1433 (defvar gnus-current-article nil)
1434 (defvar gnus-article-current nil)
1435 (defvar gnus-current-headers nil)
1436 (defvar gnus-have-all-headers nil)
1437 (defvar gnus-last-article nil)
1438 (defvar gnus-newsgroup-history nil)
1439 (defvar gnus-newsgroup-charset nil)
1440 (defvar gnus-newsgroup-ephemeral-charset nil)
1441 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1443 (defvar gnus-article-before-search nil)
1445 (defvar gnus-summary-local-variables
1446 '(gnus-newsgroup-name
1447 gnus-newsgroup-begin gnus-newsgroup-end
1448 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1449 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1450 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1451 gnus-newsgroup-unselected gnus-newsgroup-marked
1452 gnus-newsgroup-spam-marked
1453 gnus-newsgroup-reads gnus-newsgroup-saved
1454 gnus-newsgroup-replied gnus-newsgroup-forwarded
1455 gnus-newsgroup-recent
1456 gnus-newsgroup-expirable
1457 gnus-newsgroup-processable gnus-newsgroup-killed
1458 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1459 gnus-newsgroup-unfetched
1460 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1461 gnus-newsgroup-seen gnus-newsgroup-articles
1462 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1463 gnus-newsgroup-headers gnus-newsgroup-threads
1464 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1465 gnus-current-article gnus-current-headers gnus-have-all-headers
1466 gnus-last-article gnus-article-internal-prepare-hook
1467 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1468 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1469 gnus-thread-expunge-below
1470 gnus-score-alist gnus-current-score-file
1471 (gnus-summary-expunge-below . global)
1472 (gnus-summary-mark-below . global)
1473 (gnus-orphan-score . global)
1474 gnus-newsgroup-active gnus-scores-exclude-files
1475 gnus-newsgroup-history gnus-newsgroup-ancient
1476 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1477 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1478 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1479 (gnus-newsgroup-expunged-tally . 0)
1480 gnus-cache-removable-articles gnus-newsgroup-cached
1481 gnus-newsgroup-data gnus-newsgroup-data-reverse
1482 gnus-newsgroup-limit gnus-newsgroup-limits
1483 gnus-newsgroup-charset gnus-newsgroup-display
1484 gnus-summary-use-undownloaded-faces
1485 gnus-newsgroup-incorporated)
1486 "Variables that are buffer-local to the summary buffers.")
1488 (defvar gnus-newsgroup-variables nil
1489 "A list of variables that have separate values in different newsgroups.
1490 A list of newsgroup (summary buffer) local variables, or cons of
1491 variables and their default expressions to be evalled (when the default
1492 values are not nil), that should be made global while the summary buffer
1495 Note: The default expressions will be evaluated (using function `eval')
1496 before assignment to the local variable rather than just assigned to it.
1497 If the default expression is the symbol `global', that symbol will not
1498 be evaluated but the global value of the local variable will be used
1501 These variables can be used to set variables in the group parameters
1502 while still allowing them to affect operations done in other buffers.
1505 \(setq gnus-newsgroup-variables
1506 '(message-use-followup-to
1507 (gnus-visible-headers .
1508 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1511 ;; Byte-compiler warning.
1513 ;; Bind features so that require will believe that gnus-sum has
1514 ;; already been loaded (avoids infinite recursion)
1515 (let ((features (cons 'gnus-sum features)))
1516 ;; Several of the declarations in gnus-sum are needed to load the
1517 ;; following files. Right now, these definitions have been
1518 ;; compiled but not defined (evaluated). We could either do a
1519 ;; eval-and-compile about all of the declarations or evaluate the
1521 (if (boundp 'gnus-newsgroup-variables)
1523 (load "gnus-sum.el" t t t))
1525 (require 'gnus-agent)
1526 (require 'gnus-art)))
1528 ;; Subject simplification.
1530 (defun gnus-simplify-whitespace (str)
1531 "Remove excessive whitespace from STR."
1533 (while (string-match "[ \t][ \t]+" str)
1534 (setq str (concat (substring str 0 (match-beginning 0))
1536 (substring str (match-end 0)))))
1538 (when (string-match "^[ \t]+" str)
1539 (setq str (substring str (match-end 0))))
1541 (when (string-match "[ \t]+$" str)
1542 (setq str (substring str 0 (match-beginning 0))))
1545 (defun gnus-simplify-all-whitespace (str)
1546 "Remove all whitespace from STR."
1547 (while (string-match "[ \t\n]+" str)
1548 (setq str (replace-match "" nil nil str)))
1551 (defsubst gnus-simplify-subject-re (subject)
1552 "Remove \"Re:\" from subject lines."
1553 (if (string-match message-subject-re-regexp subject)
1554 (substring subject (match-end 0))
1557 (defun gnus-simplify-subject (subject &optional re-only)
1558 "Remove `Re:' and words in parentheses.
1559 If RE-ONLY is non-nil, strip leading `Re:'s only."
1560 (let ((case-fold-search t)) ;Ignore case.
1561 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1562 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1563 (setq subject (substring subject (match-end 0))))
1564 ;; Remove uninteresting prefixes.
1565 (when (and (not re-only)
1566 gnus-simplify-ignored-prefixes
1567 (string-match gnus-simplify-ignored-prefixes subject))
1568 (setq subject (substring subject (match-end 0))))
1569 ;; Remove words in parentheses from end.
1571 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1572 (setq subject (substring subject 0 (match-beginning 0)))))
1573 ;; Return subject string.
1576 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1578 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1579 (goto-char (point-min))
1580 (while (re-search-forward regexp nil t)
1581 (replace-match (or newtext ""))))
1583 (defun gnus-simplify-buffer-fuzzy ()
1584 "Simplify string in the buffer fuzzily.
1585 The string in the accessible portion of the current buffer is simplified.
1586 It is assumed to be a single-line subject.
1587 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1588 matter is removed. Additional things can be deleted by setting
1589 `gnus-simplify-subject-fuzzy-regexp'."
1590 (let ((case-fold-search t)
1592 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1594 (while (not (eq modified-tick (buffer-modified-tick)))
1595 (setq modified-tick (buffer-modified-tick))
1597 ((listp gnus-simplify-subject-fuzzy-regexp)
1598 (mapcar 'gnus-simplify-buffer-fuzzy-step
1599 gnus-simplify-subject-fuzzy-regexp))
1600 (gnus-simplify-subject-fuzzy-regexp
1601 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1602 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1603 (gnus-simplify-buffer-fuzzy-step
1604 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1605 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1607 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1608 (gnus-simplify-buffer-fuzzy-step " +" " ")
1609 (gnus-simplify-buffer-fuzzy-step " $")
1610 (gnus-simplify-buffer-fuzzy-step "^ +")))
1612 (defun gnus-simplify-subject-fuzzy (subject)
1613 "Simplify a subject string fuzzily.
1614 See `gnus-simplify-buffer-fuzzy' for details."
1616 (gnus-set-work-buffer)
1617 (let ((case-fold-search t))
1618 ;; Remove uninteresting prefixes.
1619 (when (and gnus-simplify-ignored-prefixes
1620 (string-match gnus-simplify-ignored-prefixes subject))
1621 (setq subject (substring subject (match-end 0))))
1623 (inline (gnus-simplify-buffer-fuzzy))
1626 (defsubst gnus-simplify-subject-fully (subject)
1627 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1629 (gnus-simplify-subject-functions
1630 (gnus-map-function gnus-simplify-subject-functions subject))
1631 ((null gnus-summary-gather-subject-limit)
1632 (gnus-simplify-subject-re subject))
1633 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1634 (gnus-simplify-subject-fuzzy subject))
1635 ((numberp gnus-summary-gather-subject-limit)
1636 (gnus-limit-string (gnus-simplify-subject-re subject)
1637 gnus-summary-gather-subject-limit))
1641 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1642 "Check whether two subjects are equal.
1643 If optional argument SIMPLE-FIRST is t, first argument is already
1646 ((null simple-first)
1647 (equal (gnus-simplify-subject-fully s1)
1648 (gnus-simplify-subject-fully s2)))
1651 (gnus-simplify-subject-fully s2)))))
1653 (defun gnus-summary-bubble-group ()
1654 "Increase the score of the current group.
1655 This is a handy function to add to `gnus-summary-exit-hook' to
1656 increase the score of each group you read."
1657 (gnus-group-add-score gnus-newsgroup-name))
1661 ;;; Gnus summary mode
1664 (put 'gnus-summary-mode 'mode-class 'special)
1666 (defvar gnus-article-commands-menu)
1668 ;; Non-orthogonal keys
1670 (gnus-define-keys gnus-summary-mode-map
1671 " " gnus-summary-next-page
1672 "\177" gnus-summary-prev-page
1673 [delete] gnus-summary-prev-page
1674 [backspace] gnus-summary-prev-page
1675 "\r" gnus-summary-scroll-up
1676 "\M-\r" gnus-summary-scroll-down
1677 "n" gnus-summary-next-unread-article
1678 "p" gnus-summary-prev-unread-article
1679 "N" gnus-summary-next-article
1680 "P" gnus-summary-prev-article
1681 "\M-\C-n" gnus-summary-next-same-subject
1682 "\M-\C-p" gnus-summary-prev-same-subject
1683 "\M-n" gnus-summary-next-unread-subject
1684 "\M-p" gnus-summary-prev-unread-subject
1685 "." gnus-summary-first-unread-article
1686 "," gnus-summary-best-unread-article
1687 "\M-s" gnus-summary-search-article-forward
1688 "\M-r" gnus-summary-search-article-backward
1689 "<" gnus-summary-beginning-of-article
1690 ">" gnus-summary-end-of-article
1691 "j" gnus-summary-goto-article
1692 "^" gnus-summary-refer-parent-article
1693 "\M-^" gnus-summary-refer-article
1694 "u" gnus-summary-tick-article-forward
1695 "!" gnus-summary-tick-article-forward
1696 "U" gnus-summary-tick-article-backward
1697 "d" gnus-summary-mark-as-read-forward
1698 "D" gnus-summary-mark-as-read-backward
1699 "E" gnus-summary-mark-as-expirable
1700 "\M-u" gnus-summary-clear-mark-forward
1701 "\M-U" gnus-summary-clear-mark-backward
1702 "k" gnus-summary-kill-same-subject-and-select
1703 "\C-k" gnus-summary-kill-same-subject
1704 "\M-\C-k" gnus-summary-kill-thread
1705 "\M-\C-l" gnus-summary-lower-thread
1706 "e" gnus-summary-edit-article
1707 "#" gnus-summary-mark-as-processable
1708 "\M-#" gnus-summary-unmark-as-processable
1709 "\M-\C-t" gnus-summary-toggle-threads
1710 "\M-\C-s" gnus-summary-show-thread
1711 "\M-\C-h" gnus-summary-hide-thread
1712 "\M-\C-f" gnus-summary-next-thread
1713 "\M-\C-b" gnus-summary-prev-thread
1714 [(meta down)] gnus-summary-next-thread
1715 [(meta up)] gnus-summary-prev-thread
1716 "\M-\C-u" gnus-summary-up-thread
1717 "\M-\C-d" gnus-summary-down-thread
1718 "&" gnus-summary-execute-command
1719 "c" gnus-summary-catchup-and-exit
1720 "\C-w" gnus-summary-mark-region-as-read
1721 "\C-t" gnus-summary-toggle-truncation
1722 "?" gnus-summary-mark-as-dormant
1723 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1724 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1725 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1726 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1727 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1728 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1729 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1730 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1731 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1732 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1733 "=" gnus-summary-expand-window
1734 "\C-x\C-s" gnus-summary-reselect-current-group
1735 "\M-g" gnus-summary-rescan-group
1736 "w" gnus-summary-stop-page-breaking
1737 "\C-c\C-r" gnus-summary-caesar-message
1738 "\M-t" gnus-summary-toggle-mime
1739 "f" gnus-summary-followup
1740 "F" gnus-summary-followup-with-original
1741 "C" gnus-summary-cancel-article
1742 "r" gnus-summary-reply
1743 "R" gnus-summary-reply-with-original
1744 "\C-c\C-f" gnus-summary-mail-forward
1745 "o" gnus-summary-save-article
1746 "\C-o" gnus-summary-save-article-mail
1747 "|" gnus-summary-pipe-output
1748 "\M-k" gnus-summary-edit-local-kill
1749 "\M-K" gnus-summary-edit-global-kill
1751 "\C-c\C-d" gnus-summary-describe-group
1752 "q" gnus-summary-exit
1753 "Q" gnus-summary-exit-no-update
1754 "\C-c\C-i" gnus-info-find-node
1755 gnus-mouse-2 gnus-mouse-pick-article
1756 "m" gnus-summary-mail-other-window
1757 "a" gnus-summary-post-news
1758 "i" gnus-summary-news-other-window
1759 "x" gnus-summary-limit-to-unread
1760 "s" gnus-summary-isearch-article
1761 "t" gnus-summary-toggle-header
1762 "g" gnus-summary-show-article
1763 "l" gnus-summary-goto-last-article
1764 "v" gnus-summary-preview-mime-message
1765 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1766 "\C-d" gnus-summary-enter-digest-group
1767 "\M-\C-d" gnus-summary-read-document
1768 "\M-\C-e" gnus-summary-edit-parameters
1769 "\M-\C-a" gnus-summary-customize-parameters
1771 "\C-c\C-n" gnus-namazu-search
1772 "*" gnus-cache-enter-article
1773 "\M-*" gnus-cache-remove-article
1774 "\M-&" gnus-summary-universal-argument
1775 "\C-l" gnus-recenter
1776 "I" gnus-summary-increase-score
1777 "L" gnus-summary-lower-score
1778 "\M-i" gnus-symbolic-argument
1779 "h" gnus-summary-select-article-buffer
1781 "V" gnus-summary-score-map
1782 "X" gnus-uu-extract-map
1783 "S" gnus-summary-send-map)
1785 ;; Sort of orthogonal keymap
1786 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1787 "t" gnus-summary-tick-article-forward
1788 "!" gnus-summary-tick-article-forward
1789 "d" gnus-summary-mark-as-read-forward
1790 "r" gnus-summary-mark-as-read-forward
1791 "c" gnus-summary-clear-mark-forward
1792 " " gnus-summary-clear-mark-forward
1793 "e" gnus-summary-mark-as-expirable
1794 "x" gnus-summary-mark-as-expirable
1795 "?" gnus-summary-mark-as-dormant
1796 "b" gnus-summary-set-bookmark
1797 "B" gnus-summary-remove-bookmark
1798 "#" gnus-summary-mark-as-processable
1799 "\M-#" gnus-summary-unmark-as-processable
1800 "S" gnus-summary-limit-include-expunged
1801 "C" gnus-summary-catchup
1802 "H" gnus-summary-catchup-to-here
1803 "h" gnus-summary-catchup-from-here
1804 "\C-c" gnus-summary-catchup-all
1805 "k" gnus-summary-kill-same-subject-and-select
1806 "K" gnus-summary-kill-same-subject
1807 "P" gnus-uu-mark-map)
1809 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1810 "c" gnus-summary-clear-above
1811 "u" gnus-summary-tick-above
1812 "m" gnus-summary-mark-above
1813 "k" gnus-summary-kill-below)
1815 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1816 "/" gnus-summary-limit-to-subject
1817 "n" gnus-summary-limit-to-articles
1818 "w" gnus-summary-pop-limit
1819 "s" gnus-summary-limit-to-subject
1820 "a" gnus-summary-limit-to-author
1821 "u" gnus-summary-limit-to-unread
1822 "m" gnus-summary-limit-to-marks
1823 "M" gnus-summary-limit-exclude-marks
1824 "v" gnus-summary-limit-to-score
1825 "*" gnus-summary-limit-include-cached
1826 "D" gnus-summary-limit-include-dormant
1827 "T" gnus-summary-limit-include-thread
1828 "d" gnus-summary-limit-exclude-dormant
1829 "t" gnus-summary-limit-to-age
1830 "." gnus-summary-limit-to-unseen
1831 "x" gnus-summary-limit-to-extra
1832 "p" gnus-summary-limit-to-display-predicate
1833 "E" gnus-summary-limit-include-expunged
1834 "c" gnus-summary-limit-exclude-childless-dormant
1835 "C" gnus-summary-limit-mark-excluded-as-read
1836 "o" gnus-summary-insert-old-articles
1837 "N" gnus-summary-insert-new-articles
1838 "r" gnus-summary-limit-to-replied)
1840 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1841 "n" gnus-summary-next-unread-article
1842 "p" gnus-summary-prev-unread-article
1843 "N" gnus-summary-next-article
1844 "P" gnus-summary-prev-article
1845 "\C-n" gnus-summary-next-same-subject
1846 "\C-p" gnus-summary-prev-same-subject
1847 "\M-n" gnus-summary-next-unread-subject
1848 "\M-p" gnus-summary-prev-unread-subject
1849 "f" gnus-summary-first-unread-article
1850 "b" gnus-summary-best-unread-article
1851 "j" gnus-summary-goto-article
1852 "g" gnus-summary-goto-subject
1853 "l" gnus-summary-goto-last-article
1854 "o" gnus-summary-pop-article)
1856 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1857 "k" gnus-summary-kill-thread
1858 "l" gnus-summary-lower-thread
1859 "i" gnus-summary-raise-thread
1860 "T" gnus-summary-toggle-threads
1861 "t" gnus-summary-rethread-current
1862 "^" gnus-summary-reparent-thread
1863 "s" gnus-summary-show-thread
1864 "S" gnus-summary-show-all-threads
1865 "h" gnus-summary-hide-thread
1866 "H" gnus-summary-hide-all-threads
1867 "n" gnus-summary-next-thread
1868 "p" gnus-summary-prev-thread
1869 "u" gnus-summary-up-thread
1870 "o" gnus-summary-top-thread
1871 "d" gnus-summary-down-thread
1872 "#" gnus-uu-mark-thread
1873 "\M-#" gnus-uu-unmark-thread)
1875 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1876 "g" gnus-summary-prepare
1877 "c" gnus-summary-insert-cached-articles
1878 "d" gnus-summary-insert-dormant-articles)
1880 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1881 "c" gnus-summary-catchup-and-exit
1882 "C" gnus-summary-catchup-all-and-exit
1883 "E" gnus-summary-exit-no-update
1884 "J" gnus-summary-jump-to-other-group
1885 "Q" gnus-summary-exit
1886 "Z" gnus-summary-exit
1887 "n" gnus-summary-catchup-and-goto-next-group
1888 "R" gnus-summary-reselect-current-group
1889 "G" gnus-summary-rescan-group
1890 "N" gnus-summary-next-group
1891 "s" gnus-summary-save-newsrc
1892 "P" gnus-summary-prev-group)
1894 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1895 " " gnus-summary-next-page
1896 "n" gnus-summary-next-page
1897 "\177" gnus-summary-prev-page
1898 [delete] gnus-summary-prev-page
1899 "p" gnus-summary-prev-page
1900 "\r" gnus-summary-scroll-up
1901 "\M-\r" gnus-summary-scroll-down
1902 "<" gnus-summary-beginning-of-article
1903 ">" gnus-summary-end-of-article
1904 "b" gnus-summary-beginning-of-article
1905 "e" gnus-summary-end-of-article
1906 "^" gnus-summary-refer-parent-article
1907 "r" gnus-summary-refer-parent-article
1908 "D" gnus-summary-enter-digest-group
1909 "R" gnus-summary-refer-references
1910 "T" gnus-summary-refer-thread
1911 "g" gnus-summary-show-article
1912 "s" gnus-summary-isearch-article
1913 "P" gnus-summary-print-article
1914 "M" gnus-mailing-list-insinuate
1915 "t" gnus-article-babel)
1917 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1918 "b" gnus-article-add-buttons
1919 "B" gnus-article-add-buttons-to-head
1920 "o" gnus-article-treat-overstrike
1921 "e" gnus-article-emphasize
1922 "w" gnus-article-fill-cited-article
1923 "Q" gnus-article-fill-long-lines
1924 "C" gnus-article-capitalize-sentences
1925 "c" gnus-article-remove-cr
1926 "Z" gnus-article-decode-HZ
1927 "A" gnus-article-treat-ansi-sequences
1928 "h" gnus-article-wash-html
1929 "u" gnus-article-unsplit-urls
1930 "f" gnus-article-display-x-face
1931 "l" gnus-summary-stop-page-breaking
1932 "r" gnus-summary-caesar-message
1933 "m" gnus-summary-morse-message
1934 "t" gnus-summary-toggle-header
1935 "g" gnus-treat-smiley
1936 "v" gnus-summary-verbose-headers
1937 "m" gnus-summary-toggle-mime
1938 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1939 "p" gnus-article-verify-x-pgp-sig
1940 "d" gnus-article-treat-dumbquotes)
1942 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1943 ;; mnemonic: deuglif*Y*
1944 "u" gnus-article-outlook-unwrap-lines
1945 "a" gnus-article-outlook-repair-attribution
1946 "c" gnus-article-outlook-rearrange-citation
1947 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1949 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1950 "a" gnus-article-hide
1951 "h" gnus-article-hide-headers
1952 "b" gnus-article-hide-boring-headers
1953 "s" gnus-article-hide-signature
1954 "c" gnus-article-hide-citation
1955 "C" gnus-article-hide-citation-in-followups
1956 "l" gnus-article-hide-list-identifiers
1957 "B" gnus-article-strip-banner
1958 "P" gnus-article-hide-pem
1959 "\C-c" gnus-article-hide-citation-maybe)
1961 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1962 "a" gnus-article-highlight
1963 "h" gnus-article-highlight-headers
1964 "c" gnus-article-highlight-citation
1965 "s" gnus-article-highlight-signature)
1967 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1968 "f" gnus-article-treat-fold-headers
1969 "u" gnus-article-treat-unfold-headers
1970 "n" gnus-article-treat-fold-newsgroups)
1972 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1973 "x" gnus-article-display-x-face
1974 "d" gnus-article-display-face
1975 "s" gnus-treat-smiley
1976 "D" gnus-article-remove-images
1977 "f" gnus-treat-from-picon
1978 "m" gnus-treat-mail-picon
1979 "n" gnus-treat-newsgroups-picon)
1981 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1982 "z" gnus-article-date-ut
1983 "u" gnus-article-date-ut
1984 "l" gnus-article-date-local
1985 "p" gnus-article-date-english
1986 "e" gnus-article-date-lapsed
1987 "o" gnus-article-date-original
1988 "i" gnus-article-date-iso8601
1989 "s" gnus-article-date-user)
1991 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1992 "t" gnus-article-remove-trailing-blank-lines
1993 "l" gnus-article-strip-leading-blank-lines
1994 "m" gnus-article-strip-multiple-blank-lines
1995 "a" gnus-article-strip-blank-lines
1996 "A" gnus-article-strip-all-blank-lines
1997 "s" gnus-article-strip-leading-space
1998 "e" gnus-article-strip-trailing-space
1999 "w" gnus-article-remove-leading-whitespace)
2001 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2003 "f" gnus-summary-fetch-faq
2004 "d" gnus-summary-describe-group
2005 "h" gnus-summary-describe-briefly
2006 "i" gnus-info-find-node
2007 "c" gnus-group-fetch-charter
2008 "C" gnus-group-fetch-control)
2010 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2011 "e" gnus-summary-expire-articles
2012 "\M-\C-e" gnus-summary-expire-articles-now
2013 "\177" gnus-summary-delete-article
2014 [delete] gnus-summary-delete-article
2015 [backspace] gnus-summary-delete-article
2016 "m" gnus-summary-move-article
2017 "r" gnus-summary-respool-article
2018 "w" gnus-summary-edit-article
2019 "c" gnus-summary-copy-article
2020 "B" gnus-summary-crosspost-article
2021 "q" gnus-summary-respool-query
2022 "t" gnus-summary-respool-trace
2023 "i" gnus-summary-import-article
2024 "I" gnus-summary-create-article
2025 "p" gnus-summary-article-posted-p)
2027 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2028 "o" gnus-summary-save-article
2029 "m" gnus-summary-save-article-mail
2030 "F" gnus-summary-write-article-file
2031 "r" gnus-summary-save-article-rmail
2032 "f" gnus-summary-save-article-file
2033 "b" gnus-summary-save-article-body-file
2034 "h" gnus-summary-save-article-folder
2035 "v" gnus-summary-save-article-vm
2036 "p" gnus-summary-pipe-output
2037 "P" gnus-summary-muttprint
2038 "s" gnus-soup-add-article)
2040 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2041 "b" gnus-summary-display-buttonized
2042 "m" gnus-summary-repair-multipart
2043 "v" gnus-article-view-part
2044 "o" gnus-article-save-part
2045 "c" gnus-article-copy-part
2046 "C" gnus-article-view-part-as-charset
2047 "e" gnus-article-view-part-externally
2048 "E" gnus-article-encrypt-body
2049 "i" gnus-article-inline-part
2050 "|" gnus-article-pipe-part)
2052 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2053 "p" gnus-summary-mark-as-processable
2054 "u" gnus-summary-unmark-as-processable
2055 "U" gnus-summary-unmark-all-processable
2056 "v" gnus-uu-mark-over
2057 "s" gnus-uu-mark-series
2058 "r" gnus-uu-mark-region
2059 "g" gnus-uu-unmark-region
2060 "R" gnus-uu-mark-by-regexp
2061 "G" gnus-uu-unmark-by-regexp
2062 "t" gnus-uu-mark-thread
2063 "T" gnus-uu-unmark-thread
2064 "a" gnus-uu-mark-all
2065 "b" gnus-uu-mark-buffer
2066 "S" gnus-uu-mark-sparse
2067 "k" gnus-summary-kill-process-mark
2068 "y" gnus-summary-yank-process-mark
2069 "w" gnus-summary-save-process-mark
2070 "i" gnus-uu-invert-processable)
2072 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2073 ;;"x" gnus-uu-extract-any
2074 "m" gnus-summary-save-parts
2075 "u" gnus-uu-decode-uu
2076 "U" gnus-uu-decode-uu-and-save
2077 "s" gnus-uu-decode-unshar
2078 "S" gnus-uu-decode-unshar-and-save
2079 "o" gnus-uu-decode-save
2080 "O" gnus-uu-decode-save
2081 "b" gnus-uu-decode-binhex
2082 "B" gnus-uu-decode-binhex
2083 "p" gnus-uu-decode-postscript
2084 "P" gnus-uu-decode-postscript-and-save)
2087 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2088 "u" gnus-uu-decode-uu-view
2089 "U" gnus-uu-decode-uu-and-save-view
2090 "s" gnus-uu-decode-unshar-view
2091 "S" gnus-uu-decode-unshar-and-save-view
2092 "o" gnus-uu-decode-save-view
2093 "O" gnus-uu-decode-save-view
2094 "b" gnus-uu-decode-binhex-view
2095 "B" gnus-uu-decode-binhex-view
2096 "p" gnus-uu-decode-postscript-view
2097 "P" gnus-uu-decode-postscript-and-save-view)
2099 (defvar gnus-article-post-menu nil)
2101 (defconst gnus-summary-menu-maxlen 20)
2103 (defun gnus-summary-menu-split (menu)
2104 ;; If we have lots of elements, divide them into groups of 20
2105 ;; and make a pane (or submenu) for each one.
2106 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2107 (let ((menu menu) sublists next
2110 ;; Pull off the next gnus-summary-menu-maxlen elements
2111 ;; and make them the next element of sublist.
2112 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2114 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2116 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2117 (aref (car (last menu)) 0)) menu)
2121 (nreverse sublists))
2122 ;; Few elements--put them all in one pane.
2125 (defun gnus-summary-make-menu-bar ()
2126 (gnus-turn-off-edit-menu 'summary)
2128 (unless (boundp 'gnus-summary-misc-menu)
2131 gnus-summary-kill-menu gnus-summary-mode-map ""
2136 ["Customize" gnus-score-customize t])
2137 (gnus-make-score-map 'increase)
2138 (gnus-make-score-map 'lower)
2140 ["Kill below" gnus-summary-kill-below t]
2141 ["Mark above" gnus-summary-mark-above t]
2142 ["Tick above" gnus-summary-tick-above t]
2143 ["Clear above" gnus-summary-clear-above t])
2144 ["Current score" gnus-summary-current-score t]
2145 ["Set score" gnus-summary-set-score t]
2146 ["Switch current score file..." gnus-score-change-score-file t]
2147 ["Set mark below..." gnus-score-set-mark-below t]
2148 ["Set expunge below..." gnus-score-set-expunge-below t]
2149 ["Edit current score file" gnus-score-edit-current-scores t]
2150 ["Edit score file" gnus-score-edit-file t]
2151 ["Trace score" gnus-score-find-trace t]
2152 ["Find words" gnus-score-find-favourite-words t]
2153 ["Rescore buffer" gnus-summary-rescore t]
2154 ["Increase score..." gnus-summary-increase-score t]
2155 ["Lower score..." gnus-summary-lower-score t]))))
2157 ;; Define both the Article menu in the summary buffer and the
2158 ;; equivalent Commands menu in the article buffer here for
2162 ["All" gnus-article-hide t]
2163 ["Headers" gnus-article-hide-headers t]
2164 ["Signature" gnus-article-hide-signature t]
2165 ["Citation" gnus-article-hide-citation t]
2166 ["List identifiers" gnus-article-hide-list-identifiers t]
2167 ["Banner" gnus-article-strip-banner t]
2168 ["Boring headers" gnus-article-hide-boring-headers t])
2170 ["All" gnus-article-highlight t]
2171 ["Headers" gnus-article-highlight-headers t]
2172 ["Signature" gnus-article-highlight-signature t]
2173 ["Citation" gnus-article-highlight-citation t])
2175 ["Local" gnus-article-date-local t]
2176 ["ISO8601" gnus-article-date-iso8601 t]
2177 ["UT" gnus-article-date-ut t]
2178 ["Original" gnus-article-date-original t]
2179 ["Lapsed" gnus-article-date-lapsed t]
2180 ["User-defined" gnus-article-date-user t])
2182 ["Remove images" gnus-article-remove-images t]
2183 ["Toggle smiley" gnus-treat-smiley t]
2184 ["Show X-Face" gnus-article-display-x-face t]
2185 ["Show picons in From" gnus-treat-from-picon t]
2186 ["Show picons in mail headers" gnus-treat-mail-picon t]
2187 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2188 ("View as different encoding"
2189 ,@(gnus-summary-menu-split
2192 ;; Since easymenu under Emacs doesn't allow
2193 ;; lambda forms for menu commands, we should
2194 ;; provide intern'ed function symbols.
2195 (let ((command (intern (format "\
2196 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2200 (let ((gnus-summary-show-article-charset-alist
2202 (gnus-summary-show-article 1))))
2203 `[,(symbol-name cs) ,command t]))
2204 (sort (if (fboundp 'coding-system-list)
2205 (coding-system-list)
2206 ;;(mapcar 'car mm-mime-mule-charset-alist)
2211 ["Leading" gnus-article-strip-leading-blank-lines t]
2212 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2213 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2214 ["All of the above" gnus-article-strip-blank-lines t]
2215 ["All" gnus-article-strip-all-blank-lines t]
2216 ["Leading space" gnus-article-strip-leading-space t]
2217 ["Trailing space" gnus-article-strip-trailing-space t]
2218 ["Leading space in headers"
2219 gnus-article-remove-leading-whitespace t])
2220 ["Overstrike" gnus-article-treat-overstrike t]
2221 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2222 ["Emphasis" gnus-article-emphasize t]
2223 ["Word wrap" gnus-article-fill-cited-article t]
2224 ["Fill long lines" gnus-article-fill-long-lines t]
2225 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2226 ["Remove CR" gnus-article-remove-cr t]
2227 ["Rot 13" gnus-summary-caesar-message
2228 ,@(if (featurep 'xemacs) '(t)
2229 '(:help "\"Caesar rotate\" article by 13"))]
2230 ["Morse decode" gnus-summary-morse-message t]
2231 ["Unix pipe..." gnus-summary-pipe-message t]
2232 ["Add buttons" gnus-article-add-buttons t]
2233 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2234 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2235 ["Toggle MIME" gnus-summary-toggle-mime t]
2236 ["Verbose header" gnus-summary-verbose-headers t]
2237 ["Toggle header" gnus-summary-toggle-header t]
2238 ["Unfold headers" gnus-article-treat-unfold-headers t]
2239 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2240 ["Html" gnus-article-wash-html t]
2241 ["Unsplit URLs" gnus-article-unsplit-urls t]
2242 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2243 ["Decode HZ" gnus-article-decode-HZ t]
2244 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2245 ("(Outlook) Deuglify"
2246 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2247 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2248 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2249 ["Full (Outlook) deuglify"
2250 gnus-article-outlook-deuglify-article t])
2253 ["Save in default format..." gnus-summary-save-article
2254 ,@(if (featurep 'xemacs) '(t)
2255 '(:help "Save article using default method"))]
2256 ["Save in file..." gnus-summary-save-article-file
2257 ,@(if (featurep 'xemacs) '(t)
2258 '(:help "Save article in file"))]
2259 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2260 ["Save in MH folder..." gnus-summary-save-article-folder t]
2261 ["Save in VM folder..." gnus-summary-save-article-vm t]
2262 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2263 ["Save body in file..." gnus-summary-save-article-body-file t]
2264 ["Pipe through a filter..." gnus-summary-pipe-output t]
2265 ["Add to SOUP packet" gnus-soup-add-article t]
2266 ["Print with Muttprint..." gnus-summary-muttprint t]
2267 ["Print" gnus-summary-print-article
2268 ,@(if (featurep 'xemacs) '(t)
2269 '(:help "Generate and print a PostScript image"))])
2270 ("Copy, move,... (Backend)"
2271 ,@(if (featurep 'xemacs) nil
2272 '(:help "Copying, moving, expiring articles..."))
2273 ["Respool article..." gnus-summary-respool-article t]
2274 ["Move article..." gnus-summary-move-article
2275 (gnus-check-backend-function
2276 'request-move-article gnus-newsgroup-name)]
2277 ["Copy article..." gnus-summary-copy-article t]
2278 ["Crosspost article..." gnus-summary-crosspost-article
2279 (gnus-check-backend-function
2280 'request-replace-article gnus-newsgroup-name)]
2281 ["Import file..." gnus-summary-import-article
2282 (gnus-check-backend-function
2283 'request-accept-article gnus-newsgroup-name)]
2284 ["Create article..." gnus-summary-create-article
2285 (gnus-check-backend-function
2286 'request-accept-article gnus-newsgroup-name)]
2287 ["Check if posted" gnus-summary-article-posted-p t]
2288 ["Edit article" gnus-summary-edit-article
2289 (not (gnus-group-read-only-p))]
2290 ["Delete article" gnus-summary-delete-article
2291 (gnus-check-backend-function
2292 'request-expire-articles gnus-newsgroup-name)]
2293 ["Query respool" gnus-summary-respool-query t]
2294 ["Trace respool" gnus-summary-respool-trace t]
2295 ["Delete expirable articles" gnus-summary-expire-articles-now
2296 (gnus-check-backend-function
2297 'request-expire-articles gnus-newsgroup-name)])
2299 ["Uudecode" gnus-uu-decode-uu
2300 ,@(if (featurep 'xemacs) '(t)
2301 '(:help "Decode uuencoded article(s)"))]
2302 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2303 ["Unshar" gnus-uu-decode-unshar t]
2304 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2305 ["Save" gnus-uu-decode-save t]
2306 ["Binhex" gnus-uu-decode-binhex t]
2307 ["Postscript" gnus-uu-decode-postscript t])
2309 ["Enter article" gnus-cache-enter-article t]
2310 ["Remove article" gnus-cache-remove-article t])
2311 ["Translate" gnus-article-babel t]
2312 ["Select article buffer" gnus-summary-select-article-buffer t]
2313 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2314 ["Isearch article..." gnus-summary-isearch-article t]
2315 ["Beginning of the article" gnus-summary-beginning-of-article t]
2316 ["End of the article" gnus-summary-end-of-article t]
2317 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2318 ["Fetch referenced articles" gnus-summary-refer-references t]
2319 ["Fetch current thread" gnus-summary-refer-thread t]
2320 ["Fetch article with id..." gnus-summary-refer-article t]
2321 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2322 ["Redisplay" gnus-summary-show-article t]
2323 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2325 gnus-summary-article-menu gnus-summary-mode-map ""
2326 (cons "Article" innards))
2328 (if (not (keymapp gnus-summary-article-menu))
2330 gnus-article-commands-menu gnus-article-mode-map ""
2331 (cons "Commands" innards))
2332 ;; in Emacs, don't share menu.
2333 (setq gnus-article-commands-menu
2334 (copy-keymap gnus-summary-article-menu))
2335 (define-key gnus-article-mode-map [menu-bar commands]
2336 (cons "Commands" gnus-article-commands-menu))))
2339 gnus-summary-thread-menu gnus-summary-mode-map ""
2341 ["Find all messages in thread" gnus-summary-refer-thread t]
2342 ["Toggle threading" gnus-summary-toggle-threads t]
2343 ["Hide threads" gnus-summary-hide-all-threads t]
2344 ["Show threads" gnus-summary-show-all-threads t]
2345 ["Hide thread" gnus-summary-hide-thread t]
2346 ["Show thread" gnus-summary-show-thread t]
2347 ["Go to next thread" gnus-summary-next-thread t]
2348 ["Go to previous thread" gnus-summary-prev-thread t]
2349 ["Go down thread" gnus-summary-down-thread t]
2350 ["Go up thread" gnus-summary-up-thread t]
2351 ["Top of thread" gnus-summary-top-thread t]
2352 ["Mark thread as read" gnus-summary-kill-thread t]
2353 ["Lower thread score" gnus-summary-lower-thread t]
2354 ["Raise thread score" gnus-summary-raise-thread t]
2355 ["Rethread current" gnus-summary-rethread-current t]))
2358 gnus-summary-post-menu gnus-summary-mode-map ""
2360 ["Send a message (mail or news)" gnus-summary-post-news
2361 ,@(if (featurep 'xemacs) '(t)
2362 '(:help "Compose a new message (mail or news)"))]
2363 ["Followup" gnus-summary-followup
2364 ,@(if (featurep 'xemacs) '(t)
2365 '(:help "Post followup to this article"))]
2366 ["Followup and yank" gnus-summary-followup-with-original
2367 ,@(if (featurep 'xemacs) '(t)
2368 '(:help "Post followup to this article, quoting its contents"))]
2369 ["Supersede article" gnus-summary-supersede-article t]
2370 ["Cancel article" gnus-summary-cancel-article
2371 ,@(if (featurep 'xemacs) '(t)
2372 '(:help "Cancel an article you posted"))]
2373 ["Reply" gnus-summary-reply t]
2374 ["Reply and yank" gnus-summary-reply-with-original t]
2375 ["Wide reply" gnus-summary-wide-reply t]
2376 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2377 ,@(if (featurep 'xemacs) '(t)
2378 '(:help "Mail a reply, quoting this article"))]
2379 ["Very wide reply" gnus-summary-very-wide-reply t]
2380 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2381 ,@(if (featurep 'xemacs) '(t)
2382 '(:help "Mail a very wide reply, quoting this article"))]
2383 ["Mail forward" gnus-summary-mail-forward t]
2384 ["Post forward" gnus-summary-post-forward t]
2385 ["Digest and mail" gnus-summary-digest-mail-forward t]
2386 ["Digest and post" gnus-summary-digest-post-forward t]
2387 ["Resend message" gnus-summary-resend-message t]
2388 ["Resend message edit" gnus-summary-resend-message-edit t]
2389 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2390 ["Send a mail" gnus-summary-mail-other-window t]
2391 ["Create a local message" gnus-summary-news-other-window t]
2392 ["Uuencode and post" gnus-uu-post-news
2393 ,@(if (featurep 'xemacs) '(t)
2394 '(:help "Post a uuencoded article"))]
2395 ["Followup via news" gnus-summary-followup-to-mail t]
2396 ["Followup via news and yank"
2397 gnus-summary-followup-to-mail-with-original t]
2399 ;;["Send" gnus-summary-send-draft t]
2400 ;;["Send bounced" gnus-resend-bounced-mail t])
2404 ((not (keymapp gnus-summary-post-menu))
2405 (setq gnus-article-post-menu gnus-summary-post-menu))
2406 ((not gnus-article-post-menu)
2407 ;; Don't share post menu.
2408 (setq gnus-article-post-menu
2409 (copy-keymap gnus-summary-post-menu))))
2410 (define-key gnus-article-mode-map [menu-bar post]
2411 (cons "Post" gnus-article-post-menu))
2414 gnus-summary-misc-menu gnus-summary-mode-map ""
2417 ["Mark as read" gnus-summary-mark-as-read-forward t]
2418 ["Mark same subject and select"
2419 gnus-summary-kill-same-subject-and-select t]
2420 ["Mark same subject" gnus-summary-kill-same-subject t]
2421 ["Catchup" gnus-summary-catchup
2422 ,@(if (featurep 'xemacs) '(t)
2423 '(:help "Mark unread articles in this group as read"))]
2424 ["Catchup all" gnus-summary-catchup-all t]
2425 ["Catchup to here" gnus-summary-catchup-to-here t]
2426 ["Catchup from here" gnus-summary-catchup-from-here t]
2427 ["Catchup region" gnus-summary-mark-region-as-read
2428 (gnus-mark-active-p)]
2429 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2431 ["Tick" gnus-summary-tick-article-forward t]
2432 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2433 ["Remove marks" gnus-summary-clear-mark-forward t]
2434 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2435 ["Set bookmark" gnus-summary-set-bookmark t]
2436 ["Remove bookmark" gnus-summary-remove-bookmark t])
2438 ["Marks..." gnus-summary-limit-to-marks t]
2439 ["Subject..." gnus-summary-limit-to-subject t]
2440 ["Author..." gnus-summary-limit-to-author t]
2441 ["Age..." gnus-summary-limit-to-age t]
2442 ["Extra..." gnus-summary-limit-to-extra t]
2443 ["Score..." gnus-summary-limit-to-score t]
2444 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2445 ["Unread" gnus-summary-limit-to-unread t]
2446 ["Unseen" gnus-summary-limit-to-unseen t]
2447 ["Replied" gnus-summary-limit-to-replied t]
2448 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2449 ["Next articles" gnus-summary-limit-to-articles t]
2450 ["Pop limit" gnus-summary-pop-limit t]
2451 ["Show dormant" gnus-summary-limit-include-dormant t]
2452 ["Hide childless dormant"
2453 gnus-summary-limit-exclude-childless-dormant t]
2454 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2455 ["Hide marked" gnus-summary-limit-exclude-marks t]
2456 ["Show expunged" gnus-summary-limit-include-expunged t])
2458 ["Set mark" gnus-summary-mark-as-processable t]
2459 ["Remove mark" gnus-summary-unmark-as-processable t]
2460 ["Remove all marks" gnus-summary-unmark-all-processable t]
2461 ["Invert marks" gnus-uu-invert-processable t]
2462 ["Mark above" gnus-uu-mark-over t]
2463 ["Mark series" gnus-uu-mark-series t]
2464 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2465 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2466 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2467 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2468 ["Mark all" gnus-uu-mark-all t]
2469 ["Mark buffer" gnus-uu-mark-buffer t]
2470 ["Mark sparse" gnus-uu-mark-sparse t]
2471 ["Mark thread" gnus-uu-mark-thread t]
2472 ["Unmark thread" gnus-uu-unmark-thread t]
2473 ("Process Mark Sets"
2474 ["Kill" gnus-summary-kill-process-mark t]
2475 ["Yank" gnus-summary-yank-process-mark
2476 gnus-newsgroup-process-stack]
2477 ["Save" gnus-summary-save-process-mark t]
2478 ["Run command on marked..." gnus-summary-universal-argument t]))
2480 ["Page forward" gnus-summary-next-page
2481 ,@(if (featurep 'xemacs) '(t)
2482 '(:help "Show next page of article"))]
2483 ["Page backward" gnus-summary-prev-page
2484 ,@(if (featurep 'xemacs) '(t)
2485 '(:help "Show previous page of article"))]
2486 ["Line forward" gnus-summary-scroll-up t])
2488 ["Next unread article" gnus-summary-next-unread-article t]
2489 ["Previous unread article" gnus-summary-prev-unread-article t]
2490 ["Next article" gnus-summary-next-article t]
2491 ["Previous article" gnus-summary-prev-article t]
2492 ["Next unread subject" gnus-summary-next-unread-subject t]
2493 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2494 ["Next article same subject" gnus-summary-next-same-subject t]
2495 ["Previous article same subject" gnus-summary-prev-same-subject t]
2496 ["First unread article" gnus-summary-first-unread-article t]
2497 ["Best unread article" gnus-summary-best-unread-article t]
2498 ["Go to subject number..." gnus-summary-goto-subject t]
2499 ["Go to article number..." gnus-summary-goto-article t]
2500 ["Go to the last article" gnus-summary-goto-last-article t]
2501 ["Pop article off history" gnus-summary-pop-article t])
2503 ["Sort by number" gnus-summary-sort-by-number t]
2504 ["Sort by author" gnus-summary-sort-by-author t]
2505 ["Sort by subject" gnus-summary-sort-by-subject t]
2506 ["Sort by date" gnus-summary-sort-by-date t]
2507 ["Sort by score" gnus-summary-sort-by-score t]
2508 ["Sort by lines" gnus-summary-sort-by-lines t]
2509 ["Sort by characters" gnus-summary-sort-by-chars t]
2510 ["Randomize" gnus-summary-sort-by-random t]
2511 ["Original sort" gnus-summary-sort-by-original t])
2513 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2514 ["Describe group" gnus-summary-describe-group t]
2515 ["Fetch charter" gnus-group-fetch-charter
2516 ,@(if (featurep 'xemacs) nil
2517 '(:help "Display the charter of the current group"))]
2518 ["Fetch control message" gnus-group-fetch-control
2519 ,@(if (featurep 'xemacs) nil
2520 '(:help "Display the archived control message for the current group"))]
2521 ["Read manual" gnus-info-find-node t])
2523 ["Pick and read" gnus-pick-mode t]
2524 ["Binary" gnus-binary-mode t])
2526 ["Regenerate" gnus-summary-prepare t]
2527 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2528 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2529 ["Toggle threading" gnus-summary-toggle-threads t])
2530 ["See old articles" gnus-summary-insert-old-articles t]
2531 ["See new articles" gnus-summary-insert-new-articles t]
2532 ["Filter articles..." gnus-summary-execute-command t]
2533 ["Run command on articles..." gnus-summary-universal-argument t]
2534 ["Search articles forward..." gnus-summary-search-article-forward t]
2535 ["Search articles backward..." gnus-summary-search-article-backward t]
2536 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2537 ["Expand window" gnus-summary-expand-window t]
2538 ["Expire expirable articles" gnus-summary-expire-articles
2539 (gnus-check-backend-function
2540 'request-expire-articles gnus-newsgroup-name)]
2541 ["Edit local kill file" gnus-summary-edit-local-kill t]
2542 ["Edit main kill file" gnus-summary-edit-global-kill t]
2543 ["Edit group parameters" gnus-summary-edit-parameters t]
2544 ["Customize group parameters" gnus-summary-customize-parameters t]
2545 ["Send a bug report" gnus-bug t]
2547 ["Catchup and exit" gnus-summary-catchup-and-exit
2548 ,@(if (featurep 'xemacs) '(t)
2549 '(:help "Mark unread articles in this group as read, then exit"))]
2550 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2551 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2552 ["Exit group" gnus-summary-exit
2553 ,@(if (featurep 'xemacs) '(t)
2554 '(:help "Exit current group, return to group selection mode"))]
2555 ["Exit group without updating" gnus-summary-exit-no-update t]
2556 ["Exit and goto next group" gnus-summary-next-group t]
2557 ["Exit and goto prev group" gnus-summary-prev-group t]
2558 ["Reselect group" gnus-summary-reselect-current-group t]
2559 ["Rescan group" gnus-summary-rescan-group t]
2560 ["Update dribble" gnus-summary-save-newsrc t])))
2562 (gnus-run-hooks 'gnus-summary-menu-hook)))
2564 (defvar gnus-summary-tool-bar-map nil)
2566 ;; Emacs 21 tool bar. Should be no-op otherwise.
2567 (defun gnus-summary-make-tool-bar ()
2568 (if (and (fboundp 'tool-bar-add-item-from-menu)
2569 (default-value 'tool-bar-mode)
2570 (not gnus-summary-tool-bar-map))
2571 (setq gnus-summary-tool-bar-map
2572 (let ((tool-bar-map (make-sparse-keymap))
2573 (load-path (mm-image-load-path)))
2574 (tool-bar-add-item-from-menu
2575 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2576 (tool-bar-add-item-from-menu
2577 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2578 (tool-bar-add-item-from-menu
2579 'gnus-summary-post-news "post" gnus-summary-mode-map)
2580 (tool-bar-add-item-from-menu
2581 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2582 (tool-bar-add-item-from-menu
2583 'gnus-summary-followup "followup" gnus-summary-mode-map)
2584 (tool-bar-add-item-from-menu
2585 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2586 (tool-bar-add-item-from-menu
2587 'gnus-summary-reply "reply" gnus-summary-mode-map)
2588 (tool-bar-add-item-from-menu
2589 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2590 (tool-bar-add-item-from-menu
2591 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2592 (tool-bar-add-item-from-menu
2593 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2594 (tool-bar-add-item-from-menu
2595 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2596 (tool-bar-add-item-from-menu
2597 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2598 (tool-bar-add-item-from-menu
2599 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2600 (tool-bar-add-item-from-menu
2601 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2602 (tool-bar-add-item-from-menu
2603 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2604 (tool-bar-add-item-from-menu
2605 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2607 (if gnus-summary-tool-bar-map
2608 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2610 (defun gnus-score-set-default (var value)
2611 "A version of set that updates the GNU Emacs menu-bar."
2613 ;; It is the message that forces the active status to be updated.
2616 (defun gnus-make-score-map (type)
2617 "Make a summary score map of type TYPE."
2620 (let ((headers '(("author" "from" string)
2621 ("subject" "subject" string)
2622 ("article body" "body" string)
2623 ("article head" "head" string)
2624 ("xref" "xref" string)
2625 ("extra header" "extra" string)
2626 ("lines" "lines" number)
2627 ("followups to author" "followup" string)))
2628 (types '((number ("less than" <)
2631 (string ("substring" s)
2635 (perms '(("temporary" (current-time-string))
2643 (if (eq type 'lower)
2648 (setq header (car headers))
2654 (let ((ts (cdr (assoc (nth 2 header) types)))
2670 'gnus-summary-score-entry
2672 (if (or (string= (nth 1 header)
2674 (string= (nth 1 header)
2677 (list 'gnus-summary-header
2679 (list 'quote (nth 1 (car ts)))
2680 (list 'gnus-score-delta-default
2687 (list (nreverse outp))))
2690 (list (nreverse outt))))
2692 (setq headers (cdr headers)))
2693 (list (nreverse outh))))))))
2697 (defun gnus-summary-mode (&optional group)
2698 "Major mode for reading articles.
2700 All normal editing commands are switched off.
2701 \\<gnus-summary-mode-map>
2702 Each line in this buffer represents one article. To read an
2703 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2704 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2707 You can also post articles and send mail from this buffer. To
2708 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2709 of an article, type `\\[gnus-summary-reply]'.
2711 There are approx. one gazillion commands you can execute in this
2712 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2714 The following commands are available:
2716 \\{gnus-summary-mode-map}"
2718 (kill-all-local-variables)
2719 (when (gnus-visual-p 'summary-menu 'menu)
2720 (gnus-summary-make-menu-bar)
2721 (gnus-summary-make-tool-bar))
2722 (gnus-summary-make-local-variables)
2723 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2724 (gnus-summary-make-local-variables))
2725 (gnus-make-thread-indent-array)
2726 (gnus-simplify-mode-line)
2727 (setq major-mode 'gnus-summary-mode)
2728 (setq mode-name "Summary")
2729 (make-local-variable 'minor-mode-alist)
2730 (use-local-map gnus-summary-mode-map)
2731 (buffer-disable-undo)
2732 (setq buffer-read-only t ;Disable modification
2733 show-trailing-whitespace nil)
2734 (setq truncate-lines t)
2735 (setq selective-display t)
2736 (setq selective-display-ellipses t) ;Display `...'
2737 (gnus-summary-set-display-table)
2738 (gnus-set-default-directory)
2739 (setq gnus-newsgroup-name group)
2740 (unless (gnus-news-group-p group)
2741 (setq gnus-newsgroup-incorporated
2742 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2743 (make-local-variable 'gnus-summary-line-format)
2744 (make-local-variable 'gnus-summary-line-format-spec)
2745 (make-local-variable 'gnus-summary-dummy-line-format)
2746 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2747 (make-local-variable 'gnus-summary-mark-positions)
2748 (gnus-make-local-hook 'pre-command-hook)
2749 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2750 (gnus-run-hooks 'gnus-summary-mode-hook)
2751 (turn-on-gnus-mailing-list-mode)
2752 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2753 (gnus-update-summary-mark-positions))
2755 (defun gnus-summary-make-local-variables ()
2756 "Make all the local summary buffer variables."
2758 (dolist (local gnus-summary-local-variables)
2761 (if (eq (cdr local) 'global)
2762 ;; Copy the global value of the variable.
2763 (setq global (symbol-value (car local)))
2764 ;; Use the value from the list.
2765 (setq global (eval (cdr local))))
2766 (set (make-local-variable (car local)) global))
2767 ;; Simple nil-valued local variable.
2768 (set (make-local-variable local) nil)))))
2770 (defun gnus-summary-clear-local-variables ()
2771 (let ((locals gnus-summary-local-variables))
2773 (if (consp (car locals))
2774 (and (vectorp (caar locals))
2775 (set (caar locals) nil))
2776 (and (vectorp (car locals))
2777 (set (car locals) nil)))
2778 (setq locals (cdr locals)))))
2780 ;; Summary data functions.
2782 (defmacro gnus-data-number (data)
2785 (defmacro gnus-data-set-number (data number)
2786 `(setcar ,data ,number))
2788 (defmacro gnus-data-mark (data)
2791 (defmacro gnus-data-set-mark (data mark)
2792 `(setcar (nthcdr 1 ,data) ,mark))
2794 (defmacro gnus-data-pos (data)
2797 (defmacro gnus-data-set-pos (data pos)
2798 `(setcar (nthcdr 2 ,data) ,pos))
2800 (defmacro gnus-data-header (data)
2803 (defmacro gnus-data-set-header (data header)
2804 `(setcar (nthcdr 3 ,data) ,header))
2806 (defmacro gnus-data-level (data)
2809 (defmacro gnus-data-unread-p (data)
2810 `(= (nth 1 ,data) gnus-unread-mark))
2812 (defmacro gnus-data-read-p (data)
2813 `(/= (nth 1 ,data) gnus-unread-mark))
2815 (defmacro gnus-data-pseudo-p (data)
2816 `(consp (nth 3 ,data)))
2818 (defmacro gnus-data-find (number)
2819 `(assq ,number gnus-newsgroup-data))
2821 (defmacro gnus-data-find-list (number &optional data)
2822 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2823 (memq (assq ,number bdata)
2826 (defmacro gnus-data-make (number mark pos header level)
2827 `(list ,number ,mark ,pos ,header ,level))
2829 (defun gnus-data-enter (after-article number mark pos header level offset)
2830 (let ((data (gnus-data-find-list after-article)))
2832 (error "No such article: %d" after-article))
2833 (setcdr data (cons (gnus-data-make number mark pos header level)
2835 (setq gnus-newsgroup-data-reverse nil)
2836 (gnus-data-update-list (cddr data) offset)))
2838 (defun gnus-data-enter-list (after-article list &optional offset)
2840 (let ((data (and after-article (gnus-data-find-list after-article)))
2844 (let ((odata gnus-newsgroup-data))
2845 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2847 (gnus-data-update-list odata offset)))
2848 ;; Find the last element in the list to be spliced into the main
2851 (setq list (cdr list)))
2854 (setcdr list gnus-newsgroup-data)
2855 (setq gnus-newsgroup-data ilist)
2857 (gnus-data-update-list (cdr list) offset)))
2858 (setcdr list (cdr data))
2861 (gnus-data-update-list (cdr list) offset))))
2862 (setq gnus-newsgroup-data-reverse nil))))
2864 (defun gnus-data-remove (article &optional offset)
2865 (let ((data gnus-newsgroup-data))
2866 (if (= (gnus-data-number (car data)) article)
2868 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2869 gnus-newsgroup-data-reverse nil)
2871 (gnus-data-update-list gnus-newsgroup-data offset)))
2873 (when (= (gnus-data-number (cadr data)) article)
2874 (setcdr data (cddr data))
2876 (gnus-data-update-list (cdr data) offset))
2878 gnus-newsgroup-data-reverse nil))
2879 (setq data (cdr data))))))
2881 (defmacro gnus-data-list (backward)
2883 (or gnus-newsgroup-data-reverse
2884 (setq gnus-newsgroup-data-reverse
2885 (reverse gnus-newsgroup-data)))
2886 gnus-newsgroup-data))
2888 (defun gnus-data-update-list (data offset)
2889 "Add OFFSET to the POS of all data entries in DATA."
2890 (setq gnus-newsgroup-data-reverse nil)
2892 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2893 (setq data (cdr data))))
2895 (defun gnus-summary-article-pseudo-p (article)
2896 "Say whether this article is a pseudo article or not."
2897 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2899 (defmacro gnus-summary-article-sparse-p (article)
2900 "Say whether this article is a sparse article or not."
2901 `(memq ,article gnus-newsgroup-sparse))
2903 (defmacro gnus-summary-article-ancient-p (article)
2904 "Say whether this article is a sparse article or not."
2905 `(memq ,article gnus-newsgroup-ancient))
2907 (defun gnus-article-parent-p (number)
2908 "Say whether this article is a parent or not."
2909 (let ((data (gnus-data-find-list number)))
2910 (and (cdr data) ; There has to be an article after...
2911 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2912 (gnus-data-level (nth 1 data))))))
2914 (defun gnus-article-children (number)
2915 "Return a list of all children to NUMBER."
2916 (let* ((data (gnus-data-find-list number))
2917 (level (gnus-data-level (car data)))
2919 (setq data (cdr data))
2921 (= (gnus-data-level (car data)) (1+ level)))
2922 (push (gnus-data-number (car data)) children)
2923 (setq data (cdr data)))
2926 (defmacro gnus-summary-skip-intangible ()
2927 "If the current article is intangible, then jump to a different article."
2928 '(let ((to (get-text-property (point) 'gnus-intangible)))
2929 (and to (gnus-summary-goto-subject to))))
2931 (defmacro gnus-summary-article-intangible-p ()
2932 "Say whether this article is intangible or not."
2933 '(get-text-property (point) 'gnus-intangible))
2935 (defun gnus-article-read-p (article)
2936 "Say whether ARTICLE is read or not."
2937 (not (or (memq article gnus-newsgroup-marked)
2938 (memq article gnus-newsgroup-spam-marked)
2939 (memq article gnus-newsgroup-unreads)
2940 (memq article gnus-newsgroup-unselected)
2941 (memq article gnus-newsgroup-dormant))))
2943 ;; Some summary mode macros.
2945 (defmacro gnus-summary-article-number ()
2946 "The article number of the article on the current line.
2947 If there isn't an article number here, then we return the current
2950 (gnus-summary-skip-intangible)
2951 (or (get-text-property (point) 'gnus-number)
2952 (gnus-summary-last-subject))))
2954 (defmacro gnus-summary-article-header (&optional number)
2955 "Return the header of article NUMBER."
2956 `(gnus-data-header (gnus-data-find
2957 ,(or number '(gnus-summary-article-number)))))
2959 (defmacro gnus-summary-thread-level (&optional number)
2960 "Return the level of thread that starts with article NUMBER."
2961 `(if (and (eq gnus-summary-make-false-root 'dummy)
2962 (get-text-property (point) 'gnus-intangible))
2964 (gnus-data-level (gnus-data-find
2965 ,(or number '(gnus-summary-article-number))))))
2967 (defmacro gnus-summary-article-mark (&optional number)
2968 "Return the mark of article NUMBER."
2969 `(gnus-data-mark (gnus-data-find
2970 ,(or number '(gnus-summary-article-number)))))
2972 (defmacro gnus-summary-article-pos (&optional number)
2973 "Return the position of the line of article NUMBER."
2974 `(gnus-data-pos (gnus-data-find
2975 ,(or number '(gnus-summary-article-number)))))
2977 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2978 (defmacro gnus-summary-article-subject (&optional number)
2979 "Return current subject string or nil if nothing."
2982 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2983 '(gnus-data-header (assq (gnus-summary-article-number)
2984 gnus-newsgroup-data)))))
2987 (mail-header-subject headers))))
2989 (defmacro gnus-summary-article-score (&optional number)
2990 "Return current article score."
2991 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2992 gnus-newsgroup-scored))
2993 gnus-summary-default-score 0))
2995 (defun gnus-summary-article-children (&optional number)
2996 "Return a list of article numbers that are children of article NUMBER."
2997 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2998 (level (gnus-data-level (car data)))
3000 (while (and (setq data (cdr data))
3001 (> (setq l (gnus-data-level (car data))) level))
3002 (and (= (1+ level) l)
3003 (push (gnus-data-number (car data))
3005 (nreverse children)))
3007 (defun gnus-summary-article-parent (&optional number)
3008 "Return the article number of the parent of article NUMBER."
3009 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3010 (gnus-data-list t)))
3011 (level (gnus-data-level (car data))))
3013 () ; This is a root.
3014 ;; We search until we find an article with a level less than
3015 ;; this one. That function has to be the parent.
3016 (while (and (setq data (cdr data))
3017 (not (< (gnus-data-level (car data)) level))))
3018 (and data (gnus-data-number (car data))))))
3020 (defun gnus-unread-mark-p (mark)
3021 "Say whether MARK is the unread mark."
3022 (= mark gnus-unread-mark))
3024 (defun gnus-read-mark-p (mark)
3025 "Say whether MARK is one of the marks that mark as read.
3026 This is all marks except unread, ticked, dormant, and expirable."
3027 (not (or (= mark gnus-unread-mark)
3028 (= mark gnus-ticked-mark)
3029 (= mark gnus-spam-mark)
3030 (= mark gnus-dormant-mark)
3031 (= mark gnus-expirable-mark))))
3033 (defmacro gnus-article-mark (number)
3034 "Return the MARK of article NUMBER.
3035 This macro should only be used when computing the mark the \"first\"
3036 time; i.e., when generating the summary lines. After that,
3037 `gnus-summary-article-mark' should be used to examine the
3040 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3041 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3042 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3043 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3044 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3045 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3046 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3047 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3048 gnus-ancient-mark))))
3050 ;; Saving hidden threads.
3052 (defmacro gnus-save-hidden-threads (&rest forms)
3053 "Save hidden threads, eval FORMS, and restore the hidden threads."
3054 (let ((config (make-symbol "config")))
3055 `(let ((,config (gnus-hidden-threads-configuration)))
3059 (gnus-restore-hidden-threads-configuration ,config)))))
3060 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3061 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3063 (defun gnus-data-compute-positions ()
3064 "Compute the positions of all articles."
3065 (setq gnus-newsgroup-data-reverse nil)
3066 (let ((data gnus-newsgroup-data))
3068 (gnus-save-hidden-threads
3069 (gnus-summary-show-all-threads)
3070 (goto-char (point-min))
3072 (while (get-text-property (point) 'gnus-intangible)
3074 (gnus-data-set-pos (car data) (+ (point) 3))
3075 (setq data (cdr data))
3076 (forward-line 1))))))
3078 (defun gnus-hidden-threads-configuration ()
3079 "Return the current hidden threads configuration."
3082 (goto-char (point-min))
3083 (while (search-forward "\r" nil t)
3084 (push (1- (point)) config))
3087 (defun gnus-restore-hidden-threads-configuration (config)
3088 "Restore hidden threads configuration from CONFIG."
3090 (let (point buffer-read-only)
3091 (while (setq point (pop config))
3092 (when (and (< point (point-max))
3094 (eq (char-after) ?\n))
3095 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3097 ;; Various summary mode internalish functions.
3099 (defun gnus-mouse-pick-article (e)
3102 (gnus-summary-next-page nil t))
3104 (defun gnus-summary-set-display-table ()
3105 "Change the display table.
3106 Odd characters have a tendency to mess
3107 up nicely formatted displays - we make all possible glyphs
3108 display only a single character."
3110 ;; We start from the standard display table, if any.
3111 (let ((table (or (copy-sequence standard-display-table)
3112 (make-display-table)))
3114 ;; Nix out all the control chars...
3115 (while (>= (setq i (1- i)) 0)
3116 (aset table i [??]))
3117 ;; ... but not newline and cr, of course. (cr is necessary for the
3118 ;; selective display).
3119 (aset table ?\n nil)
3120 (aset table ?\r nil)
3121 ;; We keep TAB as well.
3122 (aset table ?\t nil)
3123 ;; We nix out any glyphs over 126 that are not set already.
3125 (while (>= (setq i (1- i)) 127)
3126 ;; Only modify if the entry is nil.
3127 (unless (aref table i)
3128 (aset table i [??]))))
3129 (setq buffer-display-table table)))
3131 (defun gnus-summary-set-article-display-arrow (pos)
3132 "Update the overlay arrow to point to line at position POS."
3133 (when (and gnus-summary-display-arrow
3134 (boundp 'overlay-arrow-position)
3135 (boundp 'overlay-arrow-string))
3139 (unless overlay-arrow-position
3140 (setq overlay-arrow-position (make-marker)))
3141 (setq overlay-arrow-string "=>"
3142 overlay-arrow-position (set-marker overlay-arrow-position
3144 (current-buffer))))))
3146 (defun gnus-summary-setup-buffer (group)
3147 "Initialize summary buffer."
3148 (let ((buffer (gnus-summary-buffer-name group))
3149 (dead-name (concat "*Dead Summary "
3150 (gnus-group-decoded-name group) "*")))
3151 ;; If a dead summary buffer exists, we kill it.
3152 (when (gnus-buffer-live-p dead-name)
3153 (gnus-kill-buffer dead-name))
3154 (if (get-buffer buffer)
3157 (setq gnus-summary-buffer (current-buffer))
3158 (not gnus-newsgroup-prepared))
3159 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3160 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3161 (gnus-summary-mode group)
3163 (gnus-carpal-setup-buffer 'summary))
3164 (unless gnus-single-article-buffer
3165 (make-local-variable 'gnus-article-buffer)
3166 (make-local-variable 'gnus-article-current)
3167 (make-local-variable 'gnus-original-article-buffer))
3168 (setq gnus-newsgroup-name group)
3169 ;; Set any local variables in the group parameters.
3170 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3173 (defun gnus-set-global-variables ()
3174 "Set the global equivalents of the buffer-local variables.
3175 They are set to the latest values they had. These reflect the summary
3176 buffer that was in action when the last article was fetched."
3177 (when (eq major-mode 'gnus-summary-mode)
3178 (setq gnus-summary-buffer (current-buffer))
3179 (let ((name gnus-newsgroup-name)
3180 (marked gnus-newsgroup-marked)
3181 (spam gnus-newsgroup-spam-marked)
3182 (unread gnus-newsgroup-unreads)
3183 (headers gnus-current-headers)
3184 (data gnus-newsgroup-data)
3185 (summary gnus-summary-buffer)
3186 (article-buffer gnus-article-buffer)
3187 (original gnus-original-article-buffer)
3188 (gac gnus-article-current)
3189 (reffed gnus-reffed-article-number)
3190 (score-file gnus-current-score-file)
3191 (default-charset gnus-newsgroup-charset)
3193 (let ((locals gnus-newsgroup-variables))
3195 (if (consp (car locals))
3196 (push (eval (caar locals)) vlist)
3197 (push (eval (car locals)) vlist))
3198 (setq locals (cdr locals)))
3199 (setq vlist (nreverse vlist)))
3200 (with-current-buffer gnus-group-buffer
3201 (setq gnus-newsgroup-name name
3202 gnus-newsgroup-marked marked
3203 gnus-newsgroup-spam-marked spam
3204 gnus-newsgroup-unreads unread
3205 gnus-current-headers headers
3206 gnus-newsgroup-data data
3207 gnus-article-current gac
3208 gnus-summary-buffer summary
3209 gnus-article-buffer article-buffer
3210 gnus-original-article-buffer original
3211 gnus-reffed-article-number reffed
3212 gnus-current-score-file score-file
3213 gnus-newsgroup-charset default-charset)
3214 (let ((locals gnus-newsgroup-variables))
3216 (if (consp (car locals))
3217 (set (caar locals) (pop vlist))
3218 (set (car locals) (pop vlist)))
3219 (setq locals (cdr locals))))
3220 ;; The article buffer also has local variables.
3221 (when (gnus-buffer-live-p gnus-article-buffer)
3222 (set-buffer gnus-article-buffer)
3223 (setq gnus-summary-buffer summary))))))
3225 (defun gnus-summary-article-unread-p (article)
3226 "Say whether ARTICLE is unread or not."
3227 (memq article gnus-newsgroup-unreads))
3229 (defun gnus-summary-first-article-p (&optional article)
3230 "Return whether ARTICLE is the first article in the buffer."
3231 (if (not (setq article (or article (gnus-summary-article-number))))
3233 (eq article (caar gnus-newsgroup-data))))
3235 (defun gnus-summary-last-article-p (&optional article)
3236 "Return whether ARTICLE is the last article in the buffer."
3237 (if (not (setq article (or article (gnus-summary-article-number))))
3238 ;; All non-existent numbers are the last article. :-)
3240 (not (cdr (gnus-data-find-list article)))))
3242 (defun gnus-make-thread-indent-array ()
3244 (unless (and gnus-thread-indent-array
3245 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3246 (setq gnus-thread-indent-array (make-vector 201 "")
3247 gnus-thread-indent-array-level gnus-thread-indent-level)
3249 (aset gnus-thread-indent-array n
3250 (make-string (* n gnus-thread-indent-level) ? ))
3253 (defun gnus-update-summary-mark-positions ()
3254 "Compute where the summary marks are to go."
3256 (when (gnus-buffer-exists-p gnus-summary-buffer)
3257 (set-buffer gnus-summary-buffer))
3258 (let ((gnus-replied-mark 129)
3259 (gnus-score-below-mark 130)
3260 (gnus-score-over-mark 130)
3261 (gnus-undownloaded-mark 131)
3262 (spec gnus-summary-line-format-spec)
3265 (gnus-set-work-buffer)
3266 (let ((gnus-summary-line-format-spec spec)
3267 (gnus-newsgroup-downloadable '(0)))
3268 (gnus-summary-insert-line
3269 (make-full-mail-header 0 "" "nobody"
3270 "05 Apr 2001 23:33:09 +0400"
3272 0 nil t 128 t nil "" nil 1)
3273 (goto-char (point-min))
3274 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3275 (- (point) (point-min) 1)))))
3276 (goto-char (point-min))
3277 (push (cons 'replied (and (search-forward "\201" nil t)
3278 (- (point) (point-min) 1)))
3280 (goto-char (point-min))
3281 (push (cons 'score (and (search-forward "\202" nil t)
3282 (- (point) (point-min) 1)))
3284 (goto-char (point-min))
3285 (push (cons 'download
3286 (and (search-forward "\203" nil t)
3287 (- (point) (point-min) 1)))
3289 (setq gnus-summary-mark-positions pos))))
3291 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3292 "Insert a dummy root in the summary buffer."
3294 (gnus-add-text-properties
3295 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3296 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3298 (defun gnus-summary-extract-address-component (from)
3299 (or (car (funcall gnus-extract-address-components from))
3302 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3303 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3304 default-mime-charset)))
3305 ;; Is it really necessary to do this next part for each summary line?
3306 ;; Luckily, doesn't seem to slow things down much.
3308 (and gnus-ignored-from-addresses
3309 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3310 (let ((extra-headers (mail-header-extra header))
3314 ((setq to (cdr (assq 'To extra-headers)))
3317 (gnus-summary-extract-address-component
3318 (funcall gnus-decode-encoded-word-function to)))))
3319 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3320 (concat "=> " newsgroups)))))
3321 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3323 (defun gnus-summary-insert-line (gnus-tmp-header
3324 gnus-tmp-level gnus-tmp-current
3325 undownloaded gnus-tmp-unread gnus-tmp-replied
3326 gnus-tmp-expirable gnus-tmp-subject-or-nil
3327 &optional gnus-tmp-dummy gnus-tmp-score
3329 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3330 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3331 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3332 (gnus-tmp-score-char
3333 (if (or (null gnus-summary-default-score)
3334 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3335 gnus-summary-zcore-fuzz))
3337 (if (< gnus-tmp-score gnus-summary-default-score)
3338 gnus-score-below-mark gnus-score-over-mark)))
3339 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3341 (cond (gnus-tmp-process gnus-process-mark)
3342 ((memq gnus-tmp-current gnus-newsgroup-cached)
3344 (gnus-tmp-replied gnus-replied-mark)
3345 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3346 gnus-forwarded-mark)
3347 ((memq gnus-tmp-current gnus-newsgroup-saved)
3349 ((memq gnus-tmp-number gnus-newsgroup-recent)
3351 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3354 (gnus-tmp-downloaded
3356 gnus-undownloaded-mark)
3357 (gnus-newsgroup-agentized
3358 gnus-downloaded-mark)
3361 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3364 ((string-match "<[^>]+> *$" gnus-tmp-from)
3365 (let ((beg (match-beginning 0)))
3366 (or (and (string-match "^\".+\"" gnus-tmp-from)
3367 (substring gnus-tmp-from 1 (1- (match-end 0))))
3368 (substring gnus-tmp-from 0 beg))))
3369 ((string-match "(.+)" gnus-tmp-from)
3370 (substring gnus-tmp-from
3371 (1+ (match-beginning 0)) (1- (match-end 0))))
3373 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3374 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3375 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3376 (buffer-read-only nil))
3377 (when (string= gnus-tmp-name "")
3378 (setq gnus-tmp-name gnus-tmp-from))
3379 (unless (numberp gnus-tmp-lines)
3380 (setq gnus-tmp-lines -1))
3381 (if (= gnus-tmp-lines -1)
3382 (setq gnus-tmp-lines "?")
3383 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3384 (gnus-put-text-property-excluding-characters-with-faces
3386 (progn (eval gnus-summary-line-format-spec) (point))
3387 'gnus-number gnus-tmp-number)
3388 (when (gnus-visual-p 'summary-highlight 'highlight)
3390 (gnus-run-hooks 'gnus-summary-update-hook)
3393 (defun gnus-summary-update-line (&optional dont-update)
3394 "Update summary line after change."
3395 (when (and gnus-summary-default-score
3396 (not gnus-summary-inhibit-highlight))
3397 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3398 (article (gnus-summary-article-number))
3399 (score (gnus-summary-article-score article)))
3401 (if (and gnus-summary-mark-below
3402 (< (gnus-summary-article-score)
3403 gnus-summary-mark-below))
3404 ;; This article has a low score, so we mark it as read.
3405 (when (memq article gnus-newsgroup-unreads)
3406 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3407 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3408 ;; This article was previously marked as read on account
3409 ;; of a low score, but now it has risen, so we mark it as
3411 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3412 (gnus-summary-update-mark
3413 (if (or (null gnus-summary-default-score)
3414 (<= (abs (- score gnus-summary-default-score))
3415 gnus-summary-zcore-fuzz))
3417 (if (< score gnus-summary-default-score)
3418 gnus-score-below-mark gnus-score-over-mark))
3420 ;; Do visual highlighting.
3421 (when (gnus-visual-p 'summary-highlight 'highlight)
3422 (gnus-run-hooks 'gnus-summary-update-hook)))))
3424 (defvar gnus-tmp-new-adopts nil)
3426 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3427 "Return the number of articles in THREAD.
3428 This may be 0 in some cases -- if none of the articles in
3429 the thread are to be displayed."
3431 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3433 ((not (listp thread))
3435 ((and (consp thread) (cdr thread))
3438 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3441 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3444 (when (and level (zerop level) gnus-tmp-new-adopts)
3447 'gnus-summary-number-of-articles-in-thread
3448 gnus-tmp-new-adopts))))
3450 (if (> number 1) gnus-not-empty-thread-mark
3451 gnus-empty-thread-mark)
3454 (defsubst gnus-summary-line-message-size (head)
3455 "Return pretty-printed version of message size.
3456 This function is intended to be used in
3457 `gnus-summary-line-format-alist'."
3458 (let ((c (or (mail-header-chars head) -1)))
3459 (cond ((< c 0) "n/a") ; chars not available
3460 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3461 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3462 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3463 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3466 (defun gnus-summary-set-local-parameters (group)
3467 "Go through the local params of GROUP and set all variable specs in that list."
3468 (let ((params (gnus-group-find-parameter group))
3469 (vars '(quit-config)) ; Ignore quit-config.
3472 (setq elem (car params)
3473 params (cdr params))
3474 (and (consp elem) ; Has to be a cons.
3475 (consp (cdr elem)) ; The cdr has to be a list.
3476 (symbolp (car elem)) ; Has to be a symbol in there.
3477 (not (memq (car elem) vars))
3478 (ignore-errors ; So we set it.
3479 (push (car elem) vars)
3480 (make-local-variable (car elem))
3481 (set (car elem) (eval (nth 1 elem))))))))
3483 (defun gnus-summary-read-group (group &optional show-all no-article
3484 kill-buffer no-display backward
3486 "Start reading news in newsgroup GROUP.
3487 If SHOW-ALL is non-nil, already read articles are also listed.
3488 If NO-ARTICLE is non-nil, no article is selected initially.
3489 If NO-DISPLAY, don't generate a summary buffer."
3493 (let ((gnus-auto-select-next nil))
3494 (or (gnus-summary-read-group-1
3495 group show-all no-article
3496 kill-buffer no-display
3499 select-articles nil)))))
3500 (eq gnus-auto-select-next 'quietly))
3501 (set-buffer gnus-group-buffer)
3502 ;; The entry function called above goes to the next
3503 ;; group automatically, so we go two groups back
3504 ;; if we are searching for the previous group.
3506 (gnus-group-prev-unread-group 2))
3507 (if (not (equal group (gnus-group-group-name)))
3508 (setq group (gnus-group-group-name))
3512 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3513 "Directly jump to the other GROUP from summary buffer.
3514 If SHOW-ALL is non-nil, already read articles are also listed."
3516 (if (eq gnus-summary-buffer (current-buffer))
3517 (list (completing-read
3518 "Group: " gnus-active-hashtb nil t
3519 (when (and gnus-newsgroup-name
3520 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3521 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3522 'gnus-group-history)
3524 (error "%s must be invoked from a gnus summary buffer." this-command)))
3525 (unless (or (zerop (length group))
3526 (and gnus-newsgroup-name
3527 (string-equal gnus-newsgroup-name group)))
3529 (gnus-summary-read-group group show-all
3530 gnus-dont-select-after-jump-to-other-group)))
3532 (defun gnus-summary-read-group-1 (group show-all no-article
3533 kill-buffer no-display
3534 &optional select-articles)
3535 ;; Killed foreign groups can't be entered.
3536 ;; (when (and (not (gnus-group-native-p group))
3537 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3538 ;; (error "Dead non-native groups can't be entered"))
3539 (gnus-message 5 "Retrieving newsgroup: %s..."
3540 (gnus-group-decoded-name group))
3541 (let* ((new-group (gnus-summary-setup-buffer group))
3542 (quit-config (gnus-group-quit-config group))
3543 (did-select (and new-group (gnus-select-newsgroup
3544 group show-all select-articles))))
3546 ;; This summary buffer exists already, so we just select it.
3548 (gnus-set-global-variables)
3550 (gnus-kill-or-deaden-summary kill-buffer))
3551 (gnus-configure-windows 'summary 'force)
3552 (gnus-set-mode-line 'summary)
3553 (gnus-summary-position-point)
3556 ;; We couldn't select this group.
3558 (when (and (eq major-mode 'gnus-summary-mode)
3559 (not (equal (current-buffer) kill-buffer)))
3560 (kill-buffer (current-buffer))
3561 (if (not quit-config)
3563 ;; Update the info -- marks might need to be removed,
3565 (gnus-summary-update-info)
3566 (set-buffer gnus-group-buffer)
3567 (gnus-group-jump-to-group group)
3568 (gnus-group-next-unread-group 1))
3569 (gnus-handle-ephemeral-exit quit-config)))
3570 (let ((grpinfo (gnus-get-info group)))
3571 (if (null (gnus-info-read grpinfo))
3572 (gnus-message 3 "Group %s contains no messages"
3573 (gnus-group-decoded-name group))
3574 (gnus-message 3 "Can't select group")))
3576 ;; The user did a `C-g' while prompting for number of articles,
3577 ;; so we exit this group.
3578 ((eq did-select 'quit)
3579 (and (eq major-mode 'gnus-summary-mode)
3580 (not (equal (current-buffer) kill-buffer))
3581 (kill-buffer (current-buffer)))
3583 (gnus-kill-or-deaden-summary kill-buffer))
3584 (if (not quit-config)
3586 (set-buffer gnus-group-buffer)
3587 (gnus-group-jump-to-group group)
3588 (gnus-group-next-unread-group 1)
3589 (gnus-configure-windows 'group 'force))
3590 (gnus-handle-ephemeral-exit quit-config))
3591 ;; Finally signal the quit.
3593 ;; The group was successfully selected.
3595 (gnus-set-global-variables)
3596 ;; Save the active value in effect when the group was entered.
3597 (setq gnus-newsgroup-active
3599 (gnus-active gnus-newsgroup-name)))
3600 ;; You can change the summary buffer in some way with this hook.
3601 (gnus-run-hooks 'gnus-select-group-hook)
3602 (gnus-update-format-specifications
3603 nil 'summary 'summary-mode 'summary-dummy)
3604 (gnus-update-summary-mark-positions)
3605 ;; Do score processing.
3606 (when gnus-use-scoring
3607 (gnus-possibly-score-headers))
3608 ;; Check whether to fill in the gaps in the threads.
3609 (when gnus-build-sparse-threads
3610 (gnus-build-sparse-threads))
3611 ;; Find the initial limit.
3613 (let ((gnus-newsgroup-dormant nil))
3614 (gnus-summary-initial-limit show-all))
3615 (gnus-summary-initial-limit show-all))
3616 ;; Generate the summary buffer.
3618 (gnus-summary-prepare))
3619 (when gnus-use-trees
3620 (gnus-tree-open group)
3621 (setq gnus-summary-highlight-line-function
3622 'gnus-tree-highlight-article))
3623 ;; If the summary buffer is empty, but there are some low-scored
3624 ;; articles or some excluded dormants, we include these in the
3626 (when (and (zerop (buffer-size))
3628 (cond (gnus-newsgroup-dormant
3629 (gnus-summary-limit-include-dormant))
3630 ((and gnus-newsgroup-scored show-all)
3631 (gnus-summary-limit-include-expunged t))))
3632 ;; Function `gnus-apply-kill-file' must be called in this hook.
3633 (gnus-run-hooks 'gnus-apply-kill-hook)
3634 (if (and (zerop (buffer-size))
3637 ;; This newsgroup is empty.
3638 (gnus-summary-catchup-and-exit nil t)
3639 (gnus-message 6 "No unread news")
3641 (gnus-kill-or-deaden-summary kill-buffer))
3642 ;; Return nil from this function.
3644 ;; Hide conversation thread subtrees. We cannot do this in
3645 ;; gnus-summary-prepare-hook since kill processing may not
3646 ;; work with hidden articles.
3647 (gnus-summary-maybe-hide-threads)
3649 (gnus-kill-or-deaden-summary kill-buffer))
3650 (gnus-summary-auto-select-subject)
3651 ;; Show first unread article if requested.
3652 (if (and (not no-article)
3654 gnus-newsgroup-unreads
3655 gnus-auto-select-first)
3657 (gnus-configure-windows 'summary)
3658 (let ((art (gnus-summary-article-number)))
3659 (unless (and (not gnus-plugged)
3660 (or (memq art gnus-newsgroup-undownloaded)
3661 (memq art gnus-newsgroup-downloadable)))
3662 (gnus-summary-goto-article art))))
3663 ;; Don't select any articles.
3664 (gnus-summary-position-point)
3665 (gnus-configure-windows 'summary 'force)
3666 (gnus-set-mode-line 'summary))
3667 (when (and gnus-auto-center-group
3668 (get-buffer-window gnus-group-buffer t))
3669 ;; Gotta use windows, because recenter does weird stuff if
3670 ;; the current buffer ain't the displayed window.
3671 (let ((owin (selected-window)))
3672 (select-window (get-buffer-window gnus-group-buffer t))
3673 (when (gnus-group-goto-group group)
3675 (select-window owin)))
3676 ;; Mark this buffer as "prepared".
3677 (setq gnus-newsgroup-prepared t)
3678 (gnus-run-hooks 'gnus-summary-prepared-hook)
3679 (unless (gnus-ephemeral-group-p group)
3680 (gnus-group-update-group group))
3683 (defun gnus-summary-auto-select-subject ()
3684 "Select the subject line on initial group entry."
3685 (goto-char (point-min))
3687 ((eq gnus-auto-select-subject 'best)
3688 (gnus-summary-best-unread-subject))
3689 ((eq gnus-auto-select-subject 'unread)
3690 (gnus-summary-first-unread-subject))
3691 ((eq gnus-auto-select-subject 'unseen)
3692 (gnus-summary-first-unseen-subject))
3693 ((eq gnus-auto-select-subject 'unseen-or-unread)
3694 (gnus-summary-first-unseen-or-unread-subject))
3695 ((eq gnus-auto-select-subject 'first)
3698 ((functionp gnus-auto-select-subject)
3699 (funcall gnus-auto-select-subject))))
3701 (defun gnus-summary-prepare ()
3702 "Generate the summary buffer."
3704 (let ((buffer-read-only nil))
3706 (setq gnus-newsgroup-data nil
3707 gnus-newsgroup-data-reverse nil)
3708 (gnus-run-hooks 'gnus-summary-generate-hook)
3709 ;; Generate the buffer, either with threads or without.
3710 (when gnus-newsgroup-headers
3711 (gnus-summary-prepare-threads
3712 (if gnus-show-threads
3713 (gnus-sort-gathered-threads
3714 (funcall gnus-summary-thread-gathering-function
3716 (gnus-cut-threads (gnus-make-threads)))))
3717 ;; Unthreaded display.
3718 (gnus-sort-articles gnus-newsgroup-headers))))
3719 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3720 ;; Call hooks for modifying summary buffer.
3721 (goto-char (point-min))
3722 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3724 (defsubst gnus-general-simplify-subject (subject)
3725 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3728 ;; Truncate the subject.
3729 (gnus-simplify-subject-functions
3730 (gnus-map-function gnus-simplify-subject-functions subject))
3731 ((numberp gnus-summary-gather-subject-limit)
3732 (setq subject (gnus-simplify-subject-re subject))
3733 (if (> (length subject) gnus-summary-gather-subject-limit)
3734 (substring subject 0 gnus-summary-gather-subject-limit)
3736 ;; Fuzzily simplify it.
3737 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3738 (gnus-simplify-subject-fuzzy subject))
3739 ;; Just remove the leading "Re:".
3741 (gnus-simplify-subject-re subject))))
3743 (if (and gnus-summary-gather-exclude-subject
3744 (string-match gnus-summary-gather-exclude-subject subject))
3745 nil ; This article shouldn't be gathered
3748 (defun gnus-summary-simplify-subject-query ()
3749 "Query where the respool algorithm would put this article."
3751 (gnus-summary-select-article)
3753 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3755 (defun gnus-gather-threads-by-subject (threads)
3756 "Gather threads by looking at Subject headers."
3757 (if (not gnus-summary-make-false-root)
3759 (let ((hashtb (gnus-make-hashtable 1024))
3762 subject hthread whole-subject)
3764 (setq subject (gnus-general-simplify-subject
3765 (setq whole-subject (mail-header-subject
3768 (if (setq hthread (gnus-gethash subject hashtb))
3770 ;; We enter a dummy root into the thread, if we
3771 ;; haven't done that already.
3772 (unless (stringp (caar hthread))
3773 (setcar hthread (list whole-subject (car hthread))))
3774 ;; We add this new gathered thread to this gathered
3776 (setcdr (car hthread)
3777 (nconc (cdar hthread) (list (car threads))))
3778 ;; Remove it from the list of threads.
3779 (setcdr prev (cdr threads))
3780 (setq threads prev))
3781 ;; Enter this thread into the hash table.
3782 (gnus-sethash subject
3783 (if gnus-summary-make-false-root-always
3785 ;; If you want a dummy root above all
3787 (setcar threads (list whole-subject
3793 (setq threads (cdr threads)))
3796 (defun gnus-gather-threads-by-references (threads)
3797 "Gather threads by looking at References headers."
3798 (let ((idhashtb (gnus-make-hashtable 1024))
3799 (thhashtb (gnus-make-hashtable 1024))
3802 ids references id gthread gid entered ref)
3804 (when (setq references (mail-header-references (caar threads)))
3805 (setq id (mail-header-id (caar threads))
3806 ids (inline (gnus-split-references references))
3808 (while (setq ref (pop ids))
3809 (setq ids (delete ref ids))
3810 (if (not (setq gid (gnus-gethash ref idhashtb)))
3812 (gnus-sethash ref id idhashtb)
3813 (gnus-sethash id threads thhashtb))
3814 (setq gthread (gnus-gethash gid thhashtb))
3816 ;; We enter a dummy root into the thread, if we
3817 ;; haven't done that already.
3818 (unless (stringp (caar gthread))
3819 (setcar gthread (list (mail-header-subject (caar gthread))
3821 ;; We add this new gathered thread to this gathered
3823 (setcdr (car gthread)
3824 (nconc (cdar gthread) (list (car threads)))))
3825 ;; Add it into the thread hash table.
3826 (gnus-sethash id gthread thhashtb)
3828 ;; Remove it from the list of threads.
3829 (setcdr prev (cdr threads))
3830 (setq threads prev))))
3832 (setq threads (cdr threads)))
3835 (defun gnus-sort-gathered-threads (threads)
3836 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3837 (let ((result threads))
3839 (when (stringp (caar threads))
3840 (setcdr (car threads)
3841 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3842 (setq threads (cdr threads)))
3845 (defun gnus-thread-loop-p (root thread)
3846 "Say whether ROOT is in THREAD."
3847 (let ((stack (list thread))
3850 (while (setq thread (pop stack))
3851 (setq th (cdr thread))
3853 (not (eq (caar th) root)))
3856 ;; We have found a loop.
3858 (setcdr thread (delq (car th) (cdr thread)))
3859 (if (boundp (setq ref-dep (intern "none"
3860 gnus-newsgroup-dependencies)))
3861 (setcdr (symbol-value ref-dep)
3862 (nconc (cdr (symbol-value ref-dep))
3864 (set ref-dep (list nil (car th))))
3867 ;; Push all the subthreads onto the stack.
3868 (push (cdr thread) stack)))
3871 (defun gnus-make-threads ()
3872 "Go through the dependency hashtb and find the roots. Return all threads."
3874 (while (catch 'infloop
3877 ;; Deal with self-referencing References loops.
3878 (when (and (car (symbol-value refs))
3885 (car (symbol-value refs)) thread))
3886 (cdr (symbol-value refs)))))))
3889 (unless (car (symbol-value refs))
3890 ;; These threads do not refer back to any other articles,
3891 ;; so they're roots.
3892 (setq threads (append (cdr (symbol-value refs)) threads))))
3893 gnus-newsgroup-dependencies)))
3896 ;; Build the thread tree.
3897 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3898 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3900 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3901 if it was already present.
3903 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3904 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3905 Message-IDs will be renamed to a unique Message-ID before being
3908 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3909 (let* ((id (mail-header-id header))
3910 (id-dep (and id (intern id dependencies)))
3911 parent-id ref ref-dep ref-header replaced)
3912 ;; Enter this `header' in the `dependencies' table.
3916 ;; The first two cases do the normal part: enter a new `header'
3917 ;; in the `dependencies' table.
3918 ((not (boundp id-dep))
3919 (set id-dep (list header)))
3920 ((null (car (symbol-value id-dep)))
3921 (setcar (symbol-value id-dep) header))
3923 ;; From here the `header' was already present in the
3924 ;; `dependencies' table.
3926 ;; Overrides an existing entry;
3927 ;; just set the header part of the entry.
3928 (setcar (symbol-value id-dep) header)
3931 ;; Renames the existing `header' to a unique Message-ID.
3932 ((not gnus-summary-ignore-duplicates)
3933 ;; An article with this Message-ID has already been seen.
3934 ;; We rename the Message-ID.
3935 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3937 (mail-header-set-id header id))
3939 ;; The last case ignores an existing entry, except it adds any
3940 ;; additional Xrefs (in case the two articles came from different
3942 ;; Also sets `header' to `nil' meaning that the `dependencies'
3943 ;; table was *not* modified.
3945 (mail-header-set-xref
3946 (car (symbol-value id-dep))
3947 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3949 (or (mail-header-xref header) "")))
3952 (when (and header (not replaced))
3953 ;; First check that we are not creating a References loop.
3954 (setq parent-id (gnus-parent-id (mail-header-references header)))
3955 (setq ref parent-id)
3957 (setq ref-dep (intern-soft ref dependencies))
3959 (setq ref-header (car (symbol-value ref-dep))))
3960 (if (string= id ref)
3961 ;; Yuk! This is a reference loop. Make the article be a
3964 (mail-header-set-references (car (symbol-value id-dep)) "none")
3966 (setq parent-id nil))
3967 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3968 (setq ref-dep (intern (or parent-id "none") dependencies))
3969 (if (boundp ref-dep)
3970 (setcdr (symbol-value ref-dep)
3971 (nconc (cdr (symbol-value ref-dep))
3972 (list (symbol-value id-dep))))
3973 (set ref-dep (list nil (symbol-value id-dep)))))
3976 (defun gnus-extract-message-id-from-in-reply-to (string)
3977 (if (string-match "<[^>]+>" string)
3978 (substring string (match-beginning 0) (match-end 0))
3981 (defun gnus-build-sparse-threads ()
3982 (let ((headers gnus-newsgroup-headers)
3983 (mail-parse-charset gnus-newsgroup-charset)
3984 (gnus-summary-ignore-duplicates t)
3985 header references generation relations
3986 subject child end new-child date)
3987 ;; First we create an alist of generations/relations, where
3988 ;; generations is how much we trust the relation, and the relation
3990 (gnus-message 7 "Making sparse threads...")
3992 (nnheader-set-temp-buffer " *gnus sparse threads*")
3993 (while (setq header (pop headers))
3994 (when (and (setq references (mail-header-references header))
3995 (not (string= references "")))
3997 (setq child (mail-header-id header)
3998 subject (mail-header-subject header)
3999 date (mail-header-date header)
4001 (while (search-backward ">" nil t)
4002 (setq end (1+ (point)))
4003 (when (search-backward "<" nil t)
4004 (setq new-child (buffer-substring (point) end))
4005 (push (list (incf generation)
4006 child (setq child new-child)
4010 (push (list (1+ generation) child nil subject) relations))
4012 (kill-buffer (current-buffer)))
4013 ;; Sort over trustworthiness.
4016 (when (gnus-dependencies-add-header
4017 (make-full-mail-header-from-decoded-header
4018 gnus-reffed-article-number
4019 (nth 3 relation) "" (or (nth 4 relation) "")
4021 (or (nth 2 relation) "") 0 0 "")
4022 gnus-newsgroup-dependencies nil)
4023 (push gnus-reffed-article-number gnus-newsgroup-limit)
4024 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4025 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4026 gnus-newsgroup-reads)
4027 (decf gnus-reffed-article-number)))
4028 (sort relations 'car-less-than-car))
4029 (gnus-message 7 "Making sparse threads...done")))
4031 (defun gnus-build-old-threads ()
4032 ;; Look at all the articles that refer back to old articles, and
4033 ;; fetch the headers for the articles that aren't there. This will
4034 ;; build complete threads - if the roots haven't been expired by the
4036 (let ((mail-parse-charset gnus-newsgroup-charset)
4040 (when (not (car (symbol-value refs)))
4041 (setq heads (cdr (symbol-value refs)))
4043 (if (memq (mail-header-number (caar heads))
4044 gnus-newsgroup-dormant)
4045 (setq heads (cdr heads))
4046 (setq id (symbol-name refs))
4047 (while (and (setq id (gnus-build-get-header id))
4048 (not (car (gnus-id-to-thread id)))))
4049 (setq heads nil)))))
4050 gnus-newsgroup-dependencies)))
4052 (defsubst gnus-remove-odd-characters (string)
4053 "Translate STRING into something that doesn't contain weird characters."
4054 (mm-subst-char-in-string
4056 (mm-subst-char-in-string ?\n ?\- string t) t))
4058 ;; This function has to be called with point after the article number
4059 ;; on the beginning of the line.
4060 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4061 (let ((eol (point-at-eol))
4062 (buffer (current-buffer))
4063 header references in-reply-to)
4065 ;; overview: [num subject from date id refs chars lines misc]
4068 (narrow-to-region (point) eol)
4073 (make-full-mail-header
4075 (nnheader-nov-field) ; subject
4076 (nnheader-nov-field) ; from
4077 (nnheader-nov-field) ; date
4078 (nnheader-nov-read-message-id number) ; id
4079 (setq references (nnheader-nov-field)) ; refs
4080 (nnheader-nov-read-integer) ; chars
4081 (nnheader-nov-read-integer) ; lines
4083 (if (looking-at "Xref: ")
4084 (goto-char (match-end 0)))
4085 (nnheader-nov-field)) ; Xref
4086 (nnheader-nov-parse-extra)))) ; extra
4090 (when (and (string= references "")
4091 (setq in-reply-to (mail-header-extra header))
4092 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4093 (mail-header-set-references
4094 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4096 (when gnus-alter-header-function
4097 (funcall gnus-alter-header-function header))
4098 (gnus-dependencies-add-header header dependencies force-new)))
4100 (defun gnus-build-get-header (id)
4101 "Look through the buffer of NOV lines and find the header to ID.
4102 Enter this line into the dependencies hash table, and return
4103 the id of the parent article (if any)."
4104 (let ((deps gnus-newsgroup-dependencies)
4108 (set-buffer nntp-server-buffer)
4109 (let ((case-fold-search nil))
4110 (goto-char (point-min))
4111 (while (and (not found)
4112 (search-forward id nil t))
4114 (setq found (looking-at
4115 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4116 (regexp-quote id))))
4117 (or found (beginning-of-line 2)))
4121 (setq header (gnus-nov-parse-line
4122 (read (current-buffer)) deps))
4123 (gnus-parent-id (mail-header-references header))))))
4125 (let ((number (mail-header-number header)))
4126 (push number gnus-newsgroup-limit)
4127 (push header gnus-newsgroup-headers)
4128 (if (memq number gnus-newsgroup-unselected)
4130 (setq gnus-newsgroup-unreads
4131 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4133 (setq gnus-newsgroup-unselected
4134 (delq number gnus-newsgroup-unselected)))
4135 (push number gnus-newsgroup-ancient)))))))
4137 (defun gnus-build-all-threads ()
4138 "Read all the headers."
4139 (let ((gnus-summary-ignore-duplicates t)
4140 (mail-parse-charset gnus-newsgroup-charset)
4141 (dependencies gnus-newsgroup-dependencies)
4144 (set-buffer nntp-server-buffer)
4145 (let ((case-fold-search nil))
4146 (goto-char (point-min))
4149 (setq article (read (current-buffer))
4150 header (gnus-nov-parse-line article dependencies)))
4152 (with-current-buffer gnus-summary-buffer
4153 (push header gnus-newsgroup-headers)
4154 (if (memq (setq article (mail-header-number header))
4155 gnus-newsgroup-unselected)
4157 (setq gnus-newsgroup-unreads
4158 (gnus-add-to-sorted-list
4159 gnus-newsgroup-unreads article))
4160 (setq gnus-newsgroup-unselected
4161 (delq article gnus-newsgroup-unselected)))
4162 (push article gnus-newsgroup-ancient)))
4163 (forward-line 1)))))))
4165 (defun gnus-summary-update-article-line (article header)
4166 "Update the line for ARTICLE using HEADER."
4167 (let* ((id (mail-header-id header))
4168 (thread (gnus-id-to-thread id)))
4170 (error "Article in no thread"))
4171 ;; Update the thread.
4172 (setcar thread header)
4173 (gnus-summary-goto-subject article)
4174 (let* ((datal (gnus-data-find-list article))
4176 (buffer-read-only nil)
4177 (level (gnus-summary-thread-level)))
4179 (let ((inserted (- (point)
4181 (gnus-summary-insert-line
4183 (memq article gnus-newsgroup-undownloaded)
4184 (gnus-article-mark article)
4185 (memq article gnus-newsgroup-replied)
4186 (memq article gnus-newsgroup-expirable)
4187 ;; Only insert the Subject string when it's different
4188 ;; from the previous Subject string.
4193 (mail-header-subject
4196 (gnus-data-find-list
4198 (gnus-data-list t)))))
4199 ;; Error on the side of excessive subjects.
4201 (mail-header-subject header)))
4203 (mail-header-subject header))
4204 nil (cdr (assq article gnus-newsgroup-scored))
4205 (memq article gnus-newsgroup-processable))
4208 (gnus-data-update-list
4210 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4212 (defun gnus-summary-update-article (article &optional iheader)
4213 "Update ARTICLE in the summary buffer."
4214 (set-buffer gnus-summary-buffer)
4215 (let* ((header (gnus-summary-article-header article))
4216 (id (mail-header-id header))
4217 (data (gnus-data-find article))
4218 (thread (gnus-id-to-thread id))
4219 (references (mail-header-references header))
4223 (when (and references
4224 (not (equal "" references)))
4227 (buffer-read-only nil)
4233 (delq thread parent)))
4234 (if (gnus-summary-insert-subject id header)
4235 ;; Set the (possibly) new article number in the data structure.
4236 (gnus-data-set-number data (gnus-id-to-article id))
4240 (defun gnus-rebuild-thread (id &optional line)
4241 "Rebuild the thread containing ID.
4242 If LINE, insert the rebuilt thread starting on line LINE."
4243 (let ((buffer-read-only nil)
4244 old-pos current thread data)
4245 (if (not gnus-show-threads)
4246 (setq thread (list (car (gnus-id-to-thread id))))
4247 ;; Get the thread this article is part of.
4248 (setq thread (gnus-remove-thread id)))
4249 (setq old-pos (point-at-bol))
4250 (setq current (save-excursion
4251 (and (re-search-backward "[\r\n]" nil t)
4252 (gnus-summary-article-number))))
4253 ;; If this is a gathered thread, we have to go some re-gathering.
4254 (when (stringp (car thread))
4255 (let ((subject (car thread))
4257 (setq thread (cdr thread))
4259 (unless (memq (setq thr (gnus-id-to-thread
4261 (mail-header-id (caar thread)))))
4264 (setq thread (cdr thread)))
4265 ;; We now have all (unique) roots.
4266 (if (= (length roots) 1)
4267 ;; All the loose roots are now one solid root.
4268 (setq thread (car roots))
4269 (setq thread (cons subject (gnus-sort-threads roots))))))
4271 ;; We then insert this thread into the summary buffer.
4273 (goto-char (point-min))
4274 (forward-line (1- line)))
4275 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4276 (if gnus-show-threads
4277 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4278 (gnus-summary-prepare-unthreaded thread))
4279 (setq data (nreverse gnus-newsgroup-data))
4280 (setq threads gnus-newsgroup-threads))
4281 ;; We splice the new data into the data structure.
4282 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4283 ;;!!! then we want to insert at the beginning of the buffer.
4284 ;;!!! That happens to be true with Gnus now, but that may
4285 ;;!!! change in the future. Perhaps.
4286 (gnus-data-enter-list
4287 (if line nil current) data (- (point) old-pos))
4288 (setq gnus-newsgroup-threads
4289 (nconc threads gnus-newsgroup-threads))
4290 (gnus-data-compute-positions))))
4292 (defun gnus-number-to-header (number)
4293 "Return the header for article NUMBER."
4294 (let ((headers gnus-newsgroup-headers))
4296 (not (= number (mail-header-number (car headers)))))
4301 (defun gnus-parent-headers (in-headers &optional generation)
4302 "Return the headers of the GENERATIONeth parent of HEADERS."
4304 (setq generation 1))
4306 (headers in-headers)
4309 (not (zerop generation))
4310 (setq references (mail-header-references headers)))
4311 (setq headers (if (and references
4312 (setq parent (gnus-parent-id references)))
4313 (car (gnus-id-to-thread parent))
4316 (and (not (eq headers in-headers))
4319 (defun gnus-id-to-thread (id)
4320 "Return the (sub-)thread where ID appears."
4321 (gnus-gethash id gnus-newsgroup-dependencies))
4323 (defun gnus-id-to-article (id)
4324 "Return the article number of ID."
4325 (let ((thread (gnus-id-to-thread id)))
4328 (mail-header-number (car thread)))))
4330 (defun gnus-id-to-header (id)
4331 "Return the article headers of ID."
4332 (car (gnus-id-to-thread id)))
4334 (defun gnus-article-displayed-root-p (article)
4335 "Say whether ARTICLE is a root(ish) article."
4336 (let ((level (gnus-summary-thread-level article))
4337 (refs (mail-header-references (gnus-summary-article-header article)))
4343 ((null (gnus-parent-id refs)) t)
4345 (null (setq particle (gnus-id-to-article
4346 (gnus-parent-id refs))))
4347 (null (gnus-summary-thread-level particle)))))))
4349 (defun gnus-root-id (id)
4350 "Return the id of the root of the thread where ID appears."
4352 (while (and id (setq prev (car (gnus-id-to-thread id))))
4354 id (gnus-parent-id (mail-header-references prev))))
4357 (defun gnus-articles-in-thread (thread)
4358 "Return the list of articles in THREAD."
4359 (cons (mail-header-number (car thread))
4360 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4362 (defun gnus-remove-thread (id &optional dont-remove)
4363 "Remove the thread that has ID in it."
4364 (let (headers thread last-id)
4365 ;; First go up in this thread until we find the root.
4366 (setq last-id (gnus-root-id id)
4367 headers (message-flatten-list (gnus-id-to-thread last-id)))
4368 ;; We have now found the real root of this thread. It might have
4369 ;; been gathered into some loose thread, so we have to search
4370 ;; through the threads to find the thread we wanted.
4371 (let ((threads gnus-newsgroup-threads)
4374 (setq sub (car threads))
4375 (if (stringp (car sub))
4376 ;; This is a gathered thread, so we look at the roots
4377 ;; below it to find whether this article is in this
4380 (setq sub (cdr sub))
4382 (when (member (caar sub) headers)
4383 (setq thread (car threads)
4386 (setq sub (cdr sub))))
4387 ;; It's an ordinary thread, so we check it.
4388 (when (eq (car sub) (car headers))
4391 (setq threads (cdr threads)))
4392 ;; If this article is in no thread, then it's a root.
4395 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4396 (setq thread (gnus-id-to-thread last-id)))
4399 thread ; We return this thread.
4401 (if (stringp (car thread))
4403 ;; If we use dummy roots, then we have to remove the
4404 ;; dummy root as well.
4405 (when (eq gnus-summary-make-false-root 'dummy)
4406 ;; We go to the dummy root by going to
4407 ;; the first sub-"thread", and then one line up.
4408 (gnus-summary-goto-article
4409 (mail-header-number (caadr thread)))
4412 (gnus-data-compute-positions))
4413 (setq thread (cdr thread))
4415 (gnus-remove-thread-1 (car thread))
4416 (setq thread (cdr thread))))
4417 (gnus-remove-thread-1 thread))))))))
4419 (defun gnus-remove-thread-1 (thread)
4420 "Remove the thread THREAD recursively."
4421 (let ((number (mail-header-number (pop thread)))
4423 (setq thread (reverse thread))
4425 (gnus-remove-thread-1 (pop thread)))
4426 (when (setq d (gnus-data-find number))
4427 (goto-char (gnus-data-pos d))
4428 (gnus-summary-show-thread)
4434 (gnus-delete-line)))))))
4436 (defun gnus-sort-threads-1 (threads func)
4437 (sort (mapcar (lambda (thread)
4440 (gnus-sort-threads-1 (cdr thread) func))))
4443 (defun gnus-sort-threads (threads)
4445 (if (not gnus-thread-sort-functions)
4447 (gnus-message 8 "Sorting threads...")
4448 (let ((max-lisp-eval-depth 5000))
4449 (prog1 (gnus-sort-threads-1
4451 (gnus-make-sort-function gnus-thread-sort-functions))
4452 (gnus-message 8 "Sorting threads...done")))))
4454 (defun gnus-sort-articles (articles)
4456 (when gnus-article-sort-functions
4457 (gnus-message 7 "Sorting articles...")
4459 (setq gnus-newsgroup-headers
4460 (sort articles (gnus-make-sort-function
4461 gnus-article-sort-functions)))
4462 (gnus-message 7 "Sorting articles...done"))))
4464 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4465 (defmacro gnus-thread-header (thread)
4466 "Return header of first article in THREAD.
4467 Note that THREAD must never, ever be anything else than a variable -
4468 using some other form will lead to serious barfage."
4469 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4470 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4471 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4474 (defsubst gnus-article-sort-by-number (h1 h2)
4475 "Sort articles by article number."
4476 (< (mail-header-number h1)
4477 (mail-header-number h2)))
4479 (defun gnus-thread-sort-by-number (h1 h2)
4480 "Sort threads by root article number."
4481 (gnus-article-sort-by-number
4482 (gnus-thread-header h1) (gnus-thread-header h2)))
4484 (defsubst gnus-article-sort-by-random (h1 h2)
4485 "Sort articles by article number."
4488 (defun gnus-thread-sort-by-random (h1 h2)
4489 "Sort threads by root article number."
4490 (gnus-article-sort-by-random
4491 (gnus-thread-header h1) (gnus-thread-header h2)))
4493 (defsubst gnus-article-sort-by-lines (h1 h2)
4494 "Sort articles by article Lines header."
4495 (< (mail-header-lines h1)
4496 (mail-header-lines h2)))
4498 (defun gnus-thread-sort-by-lines (h1 h2)
4499 "Sort threads by root article Lines header."
4500 (gnus-article-sort-by-lines
4501 (gnus-thread-header h1) (gnus-thread-header h2)))
4503 (defsubst gnus-article-sort-by-chars (h1 h2)
4504 "Sort articles by octet length."
4505 (< (mail-header-chars h1)
4506 (mail-header-chars h2)))
4508 (defun gnus-thread-sort-by-chars (h1 h2)
4509 "Sort threads by root article octet length."
4510 (gnus-article-sort-by-chars
4511 (gnus-thread-header h1) (gnus-thread-header h2)))
4513 (defsubst gnus-article-sort-by-author (h1 h2)
4514 "Sort articles by root author."
4516 (let ((addr (car (mime-entity-read-field h1 'From))))
4517 (or (std11-full-name-string addr)
4518 (std11-address-string addr)
4520 (let ((addr (car (mime-entity-read-field h2 'From))))
4521 (or (std11-full-name-string addr)
4522 (std11-address-string addr)
4526 (defun gnus-thread-sort-by-author (h1 h2)
4527 "Sort threads by root author."
4528 (gnus-article-sort-by-author
4529 (gnus-thread-header h1) (gnus-thread-header h2)))
4531 (defsubst gnus-article-sort-by-subject (h1 h2)
4532 "Sort articles by root subject."
4534 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4535 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4537 (defun gnus-thread-sort-by-subject (h1 h2)
4538 "Sort threads by root subject."
4539 (gnus-article-sort-by-subject
4540 (gnus-thread-header h1) (gnus-thread-header h2)))
4542 (defsubst gnus-article-sort-by-date (h1 h2)
4543 "Sort articles by root article date."
4545 (gnus-date-get-time (mail-header-date h1))
4546 (gnus-date-get-time (mail-header-date h2))))
4548 (defun gnus-thread-sort-by-date (h1 h2)
4549 "Sort threads by root article date."
4550 (gnus-article-sort-by-date
4551 (gnus-thread-header h1) (gnus-thread-header h2)))
4553 (defsubst gnus-article-sort-by-score (h1 h2)
4554 "Sort articles by root article score.
4555 Unscored articles will be counted as having a score of zero."
4556 (> (or (cdr (assq (mail-header-number h1)
4557 gnus-newsgroup-scored))
4558 gnus-summary-default-score 0)
4559 (or (cdr (assq (mail-header-number h2)
4560 gnus-newsgroup-scored))
4561 gnus-summary-default-score 0)))
4563 (defun gnus-thread-sort-by-score (h1 h2)
4564 "Sort threads by root article score."
4565 (gnus-article-sort-by-score
4566 (gnus-thread-header h1) (gnus-thread-header h2)))
4568 (defun gnus-thread-sort-by-total-score (h1 h2)
4569 "Sort threads by the sum of all scores in the thread.
4570 Unscored articles will be counted as having a score of zero."
4571 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4573 (defun gnus-thread-total-score (thread)
4574 ;; This function find the total score of THREAD.
4579 (if (stringp (car thread))
4580 (apply gnus-thread-score-function 0
4581 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4582 (gnus-thread-total-score-1 thread)))
4584 (gnus-thread-total-score-1 (list thread)))))
4586 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4587 "Sort threads such that the thread with the most recently arrived article comes first."
4588 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4590 (defun gnus-thread-highest-number (thread)
4591 "Return the highest article number in THREAD."
4592 (apply 'max (mapcar (lambda (header)
4593 (mail-header-number header))
4594 (message-flatten-list thread))))
4596 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4597 "Sort threads such that the thread with the most recently dated article comes first."
4598 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4600 (defun gnus-thread-latest-date (thread)
4601 "Return the highest article date in THREAD."
4602 (let ((previous-time 0))
4608 (time-to-seconds (mail-header-parse-date
4609 (mail-header-date header)))
4610 (error previous-time))))
4612 (message-flatten-list thread)
4614 (< (mail-header-number h1)
4615 (mail-header-number h2))))))))
4617 (defun gnus-thread-total-score-1 (root)
4618 ;; This function find the total score of the thread below ROOT.
4619 (setq root (car root))
4620 (apply gnus-thread-score-function
4622 (mapcar 'gnus-thread-total-score
4623 (cdr (gnus-id-to-thread (mail-header-id root))))
4624 (when (> (mail-header-number root) 0)
4625 (list (or (cdr (assq (mail-header-number root)
4626 gnus-newsgroup-scored))
4627 gnus-summary-default-score 0))))
4628 (list gnus-summary-default-score)
4631 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4632 (defvar gnus-tmp-prev-subject nil)
4633 (defvar gnus-tmp-false-parent nil)
4634 (defvar gnus-tmp-root-expunged nil)
4635 (defvar gnus-tmp-dummy-line nil)
4637 (eval-when-compile (defvar gnus-tmp-header))
4638 (defun gnus-extra-header (type &optional header)
4639 "Return the extra header of TYPE."
4640 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4643 (defvar gnus-tmp-thread-tree-header-string "")
4645 (defcustom gnus-sum-thread-tree-root "> "
4646 "With %B spec, used for the root of a thread.
4647 If nil, use subject instead."
4648 :type '(radio (const :format "%v " nil) (string :size 0))
4649 :group 'gnus-thread)
4650 (defcustom gnus-sum-thread-tree-false-root "> "
4651 "With %B spec, used for a false root of a thread.
4652 If nil, use subject instead."
4653 :type '(radio (const :format "%v " nil) (string :size 0))
4654 :group 'gnus-thread)
4655 (defcustom gnus-sum-thread-tree-single-indent ""
4656 "With %B spec, used for a thread with just one message.
4657 If nil, use subject instead."
4658 :type '(radio (const :format "%v " nil) (string :size 0))
4659 :group 'gnus-thread)
4660 (defcustom gnus-sum-thread-tree-vertical "| "
4661 "With %B spec, used for drawing a vertical line."
4663 :group 'gnus-thread)
4664 (defcustom gnus-sum-thread-tree-indent " "
4665 "With %B spec, used for indenting."
4667 :group 'gnus-thread)
4668 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4669 "With %B spec, used for a leaf with brothers."
4671 :group 'gnus-thread)
4672 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4673 "With %B spec, used for a leaf without brothers."
4675 :group 'gnus-thread)
4677 (defun gnus-summary-prepare-threads (threads)
4678 "Prepare summary buffer from THREADS and indentation LEVEL.
4679 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4680 or a straight list of headers."
4681 (gnus-message 7 "Generating summary...")
4683 (setq gnus-newsgroup-threads threads)
4686 (let ((gnus-tmp-level 0)
4687 (default-score (or gnus-summary-default-score 0))
4688 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4689 (building-line-count gnus-summary-display-while-building)
4690 (building-count (integerp gnus-summary-display-while-building))
4691 thread number subject stack state gnus-tmp-gathered beg-match
4692 new-roots gnus-tmp-new-adopts thread-end simp-subject
4693 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4694 gnus-tmp-replied gnus-tmp-subject-or-nil
4695 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4696 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4697 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4700 (setq gnus-tmp-prev-subject nil
4701 gnus-tmp-thread-tree-header-string "")
4703 (if (vectorp (car threads))
4704 ;; If this is a straight (sic) list of headers, then a
4705 ;; threaded summary display isn't required, so we just create
4706 ;; an unthreaded one.
4707 (gnus-summary-prepare-unthreaded threads)
4709 ;; Do the threaded display.
4711 (if gnus-summary-display-while-building
4712 (switch-to-buffer (buffer-name)))
4713 (while (or threads stack gnus-tmp-new-adopts new-roots)
4715 (if (and (= gnus-tmp-level 0)
4718 (not gnus-tmp-false-parent)
4719 (or gnus-tmp-new-adopts new-roots))
4720 (if gnus-tmp-new-adopts
4721 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4722 thread (list (car gnus-tmp-new-adopts))
4723 gnus-tmp-header (caar thread)
4724 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4726 (setq thread (list (car new-roots))
4727 gnus-tmp-header (caar thread)
4728 new-roots (cdr new-roots))))
4731 ;; If there are some threads, we do them before the
4732 ;; threads on the stack.
4733 (setq thread threads
4734 gnus-tmp-header (caar thread))
4735 ;; There were no current threads, so we pop something off
4737 (setq state (car stack)
4738 gnus-tmp-level (car state)
4739 tree-stack (cadr state)
4740 thread (caddr state)
4742 gnus-tmp-header (caar thread))))
4744 (setq gnus-tmp-false-parent nil)
4745 (setq gnus-tmp-root-expunged nil)
4746 (setq thread-end nil)
4748 (if (stringp gnus-tmp-header)
4749 ;; The header is a dummy root.
4751 ((eq gnus-summary-make-false-root 'adopt)
4752 ;; We let the first article adopt the rest.
4753 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4755 (setq gnus-tmp-gathered
4757 (lambda (h) (mail-header-number (car h)))
4760 (setq thread (cons (list (caar thread)
4763 (setq gnus-tmp-level -1
4764 gnus-tmp-false-parent t))
4765 ((eq gnus-summary-make-false-root 'empty)
4766 ;; We print adopted articles with empty subject fields.
4767 (setq gnus-tmp-gathered
4769 (lambda (h) (mail-header-number (car h)))
4772 (setq gnus-tmp-level -1))
4773 ((eq gnus-summary-make-false-root 'dummy)
4774 ;; We remember that we probably want to output a dummy
4776 (setq gnus-tmp-dummy-line gnus-tmp-header)
4777 (setq gnus-tmp-prev-subject gnus-tmp-header))
4779 ;; We do not make a root for the gathered
4780 ;; sub-threads at all.
4781 (setq gnus-tmp-level -1)))
4783 (setq number (mail-header-number gnus-tmp-header)
4784 subject (mail-header-subject gnus-tmp-header)
4785 simp-subject (gnus-simplify-subject-fully subject))
4788 ;; If the thread has changed subject, we might want to make
4789 ;; this subthread into a root.
4790 ((and (null gnus-thread-ignore-subject)
4791 (not (zerop gnus-tmp-level))
4792 gnus-tmp-prev-subject
4793 (not (string= gnus-tmp-prev-subject simp-subject)))
4794 (setq new-roots (nconc new-roots (list (car thread)))
4796 gnus-tmp-header nil))
4797 ;; If the article lies outside the current limit,
4798 ;; then we do not display it.
4799 ((not (memq number gnus-newsgroup-limit))
4800 (setq gnus-tmp-gathered
4802 (lambda (h) (mail-header-number (car h)))
4805 (setq gnus-tmp-new-adopts (if (cdar thread)
4806 (append gnus-tmp-new-adopts
4808 gnus-tmp-new-adopts)
4810 gnus-tmp-header nil)
4811 (when (zerop gnus-tmp-level)
4812 (setq gnus-tmp-root-expunged t)))
4813 ;; Perhaps this article is to be marked as read?
4814 ((and gnus-summary-mark-below
4815 (< (or (cdr (assq number gnus-newsgroup-scored))
4817 gnus-summary-mark-below)
4818 ;; Don't touch sparse articles.
4819 (not (gnus-summary-article-sparse-p number))
4820 (not (gnus-summary-article-ancient-p number)))
4821 (setq gnus-newsgroup-unreads
4822 (delq number gnus-newsgroup-unreads))
4823 (if gnus-newsgroup-auto-expire
4824 (setq gnus-newsgroup-expirable
4825 (gnus-add-to-sorted-list
4826 gnus-newsgroup-expirable number))
4827 (push (cons number gnus-low-score-mark)
4828 gnus-newsgroup-reads))))
4830 (when gnus-tmp-header
4831 ;; We may have an old dummy line to output before this
4833 (when (and gnus-tmp-dummy-line
4836 (mail-header-subject gnus-tmp-header)))
4837 (gnus-summary-insert-dummy-line
4838 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4839 (setq gnus-tmp-dummy-line nil))
4841 ;; Compute the mark.
4842 (setq gnus-tmp-unread (gnus-article-mark number))
4844 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4845 gnus-tmp-header gnus-tmp-level)
4846 gnus-newsgroup-data)
4848 ;; Actually insert the line.
4850 gnus-tmp-subject-or-nil
4852 ((and gnus-thread-ignore-subject
4853 gnus-tmp-prev-subject
4854 (not (string= gnus-tmp-prev-subject simp-subject)))
4856 ((zerop gnus-tmp-level)
4857 (if (and (eq gnus-summary-make-false-root 'empty)
4858 (memq number gnus-tmp-gathered)
4859 gnus-tmp-prev-subject
4860 (string= gnus-tmp-prev-subject simp-subject))
4861 gnus-summary-same-subject
4863 (t gnus-summary-same-subject)))
4864 (if (and (eq gnus-summary-make-false-root 'adopt)
4865 (= gnus-tmp-level 1)
4866 (memq number gnus-tmp-gathered))
4867 (setq gnus-tmp-opening-bracket ?\<
4868 gnus-tmp-closing-bracket ?\>)
4869 (setq gnus-tmp-opening-bracket ?\[
4870 gnus-tmp-closing-bracket ?\]))
4872 gnus-tmp-indentation
4873 (aref gnus-thread-indent-array gnus-tmp-level)
4874 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4875 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4876 gnus-summary-default-score 0)
4878 (if (or (null gnus-summary-default-score)
4879 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4880 gnus-summary-zcore-fuzz))
4882 (if (< gnus-tmp-score gnus-summary-default-score)
4883 gnus-score-below-mark gnus-score-over-mark))
4885 (cond ((memq number gnus-newsgroup-processable)
4887 ((memq number gnus-newsgroup-cached)
4889 ((memq number gnus-newsgroup-replied)
4891 ((memq number gnus-newsgroup-forwarded)
4892 gnus-forwarded-mark)
4893 ((memq number gnus-newsgroup-saved)
4895 ((memq number gnus-newsgroup-recent)
4897 ((memq number gnus-newsgroup-unseen)
4901 (cond ((memq number gnus-newsgroup-undownloaded)
4902 gnus-undownloaded-mark)
4903 (gnus-newsgroup-agentized
4904 gnus-downloaded-mark)
4907 gnus-tmp-from (mail-header-from gnus-tmp-header)
4910 ((string-match "<[^>]+> *$" gnus-tmp-from)
4911 (setq beg-match (match-beginning 0))
4912 (or (and (string-match "^\".+\"" gnus-tmp-from)
4913 (substring gnus-tmp-from 1 (1- (match-end 0))))
4914 (substring gnus-tmp-from 0 beg-match)))
4915 ((string-match "(.+)" gnus-tmp-from)
4916 (substring gnus-tmp-from
4917 (1+ (match-beginning 0)) (1- (match-end 0))))
4921 gnus-tmp-thread-tree-header-string
4923 ((not gnus-show-threads) "")
4924 ((zerop gnus-tmp-level)
4925 (cond ((cdar thread)
4926 (or gnus-sum-thread-tree-root subject))
4927 (gnus-tmp-new-adopts
4928 (or gnus-sum-thread-tree-false-root subject))
4930 (or gnus-sum-thread-tree-single-indent subject))))
4932 (concat (apply 'concat
4933 (mapcar (lambda (item)
4935 gnus-sum-thread-tree-vertical
4936 gnus-sum-thread-tree-indent))
4937 (cdr (reverse tree-stack))))
4939 gnus-sum-thread-tree-leaf-with-other
4940 gnus-sum-thread-tree-single-leaf)))))
4941 (when (string= gnus-tmp-name "")
4942 (setq gnus-tmp-name gnus-tmp-from))
4943 (unless (numberp gnus-tmp-lines)
4944 (setq gnus-tmp-lines -1))
4945 (if (= gnus-tmp-lines -1)
4946 (setq gnus-tmp-lines "?")
4947 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4948 (gnus-put-text-property
4950 (progn (eval gnus-summary-line-format-spec) (point))
4951 'gnus-number number)
4954 (gnus-run-hooks 'gnus-summary-update-hook)
4957 (setq gnus-tmp-prev-subject simp-subject)))
4959 (when (nth 1 thread)
4960 (push (list (max 0 gnus-tmp-level)
4961 (copy-sequence tree-stack)
4964 (push (if (nth 1 thread) 1 0) tree-stack)
4965 (incf gnus-tmp-level)
4966 (setq threads (if thread-end nil (cdar thread)))
4967 (if gnus-summary-display-while-building
4970 ;; use a set frequency
4971 (setq building-line-count (1- building-line-count))
4972 (when (= building-line-count 0)
4974 (setq building-line-count
4975 gnus-summary-display-while-building)))
4979 (setq gnus-tmp-level 0)))))
4980 (gnus-message 7 "Generating summary...done"))
4982 (defun gnus-summary-prepare-unthreaded (headers)
4983 "Generate an unthreaded summary buffer based on HEADERS."
4984 (let (header number mark)
4989 ;; We may have to root out some bad articles...
4990 (when (memq (setq number (mail-header-number
4991 (setq header (pop headers))))
4992 gnus-newsgroup-limit)
4993 ;; Mark article as read when it has a low score.
4994 (when (and gnus-summary-mark-below
4995 (< (or (cdr (assq number gnus-newsgroup-scored))
4996 gnus-summary-default-score 0)
4997 gnus-summary-mark-below)
4998 (not (gnus-summary-article-ancient-p number)))
4999 (setq gnus-newsgroup-unreads
5000 (delq number gnus-newsgroup-unreads))
5001 (if gnus-newsgroup-auto-expire
5002 (push number gnus-newsgroup-expirable)
5003 (push (cons number gnus-low-score-mark)
5004 gnus-newsgroup-reads)))
5006 (setq mark (gnus-article-mark number))
5007 (push (gnus-data-make number mark (1+ (point)) header 0)
5008 gnus-newsgroup-data)
5009 (gnus-summary-insert-line
5011 (memq number gnus-newsgroup-undownloaded)
5012 mark (memq number gnus-newsgroup-replied)
5013 (memq number gnus-newsgroup-expirable)
5014 (mail-header-subject header) nil
5015 (cdr (assq number gnus-newsgroup-scored))
5016 (memq number gnus-newsgroup-processable))))))
5018 (defun gnus-summary-remove-list-identifiers ()
5019 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5020 (let ((regexp (if (consp gnus-list-identifiers)
5021 (mapconcat 'identity gnus-list-identifiers " *\\|")
5022 gnus-list-identifiers))
5025 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5026 (dolist (header gnus-newsgroup-headers)
5027 (setq subject (mail-header-subject header)
5029 (while (string-match regexp subject)
5031 (concat (substring subject 0 (match-beginning 1))
5032 (substring subject (match-end 0)))
5035 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5037 (concat (substring subject 0 (match-beginning 1))
5038 (substring subject (match-end 1)))))
5039 (mail-header-set-subject header subject))))))
5041 (defun gnus-fetch-headers (articles)
5042 "Fetch headers of ARTICLES."
5043 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5044 (gnus-message 5 "Fetching headers for %s..." name)
5047 (setq gnus-headers-retrieved-by
5048 (gnus-retrieve-headers
5049 articles gnus-newsgroup-name
5050 ;; We might want to fetch old headers, but
5051 ;; not if there is only 1 article.
5053 (not (eq gnus-fetch-old-headers 'some))
5054 (not (numberp gnus-fetch-old-headers)))
5055 (> (length articles) 1))
5056 gnus-fetch-old-headers))))
5057 (gnus-get-newsgroup-headers-xover
5058 articles nil nil gnus-newsgroup-name t)
5059 (gnus-get-newsgroup-headers))
5060 (gnus-message 5 "Fetching headers for %s...done" name))))
5062 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5063 "Select newsgroup GROUP.
5064 If READ-ALL is non-nil, all articles in the group are selected.
5065 If SELECT-ARTICLES, only select those articles from GROUP."
5066 (let* ((entry (gnus-group-entry group))
5067 ;;!!! Dirty hack; should be removed.
5068 (gnus-summary-ignore-duplicates
5069 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5071 gnus-summary-ignore-duplicates))
5072 (info (nth 2 entry))
5073 articles fetched-articles cached)
5075 (unless (gnus-check-server
5076 (set (make-local-variable 'gnus-current-select-method)
5077 (gnus-find-method-for-group group)))
5078 (error "Couldn't open server"))
5080 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5081 (gnus-activate-group group) ; Or we can activate it...
5082 (progn ; Or we bug out.
5083 (when (equal major-mode 'gnus-summary-mode)
5084 (gnus-kill-buffer (current-buffer)))
5085 (error "Couldn't activate group %s: %s"
5086 group (gnus-status-message group))))
5088 (unless (gnus-request-group group t)
5089 (when (equal major-mode 'gnus-summary-mode)
5090 (gnus-kill-buffer (current-buffer)))
5091 (error "Couldn't request group %s: %s"
5092 group (gnus-status-message group)))
5095 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5097 (setq gnus-summary-use-undownloaded-faces
5098 (gnus-agent-find-parameter
5100 'agent-enable-undownloaded-faces)))
5102 (setq gnus-newsgroup-name group
5103 gnus-newsgroup-unselected nil
5104 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5106 (let ((display (gnus-group-find-parameter group 'display)))
5107 (setq gnus-newsgroup-display
5109 ((not (zerop (or (car-safe read-all) 0)))
5110 ;; The user entered the group with C-u SPC/RET, let's show
5116 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5118 ;; The following is probably the "correct" solution, but
5119 ;; it makes Gnus fetch all headers and then limit the
5120 ;; articles (which is slow), so instead we hack the
5121 ;; select-articles parameter instead. -- Simon Josefsson
5124 ;; (gnus-byte-compile
5125 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5127 (setq select-articles
5128 (gnus-uncompress-range
5129 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5133 (cdr (gnus-active group)))))
5138 (gnus-summary-setup-default-charset)
5140 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5141 (when (gnus-virtual-group-p group)
5142 (setq cached gnus-newsgroup-cached))
5144 (setq gnus-newsgroup-unreads
5145 (gnus-sorted-ndifference
5146 (gnus-sorted-ndifference gnus-newsgroup-unreads
5147 gnus-newsgroup-marked)
5148 gnus-newsgroup-dormant))
5150 (setq gnus-newsgroup-processable nil)
5152 (gnus-update-read-articles group gnus-newsgroup-unreads)
5154 ;; Adjust and set lists of article marks.
5156 (gnus-adjust-marked-articles info))
5157 (if (setq articles select-articles)
5158 (setq gnus-newsgroup-unselected
5159 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5160 (setq articles (gnus-articles-to-read group read-all)))
5164 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5166 ((eq articles 0) nil)
5168 ;; Init the dependencies hash table.
5169 (setq gnus-newsgroup-dependencies
5170 (gnus-make-hashtable (length articles)))
5171 (gnus-set-global-variables)
5172 ;; Retrieve the headers and read them in.
5174 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5176 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5178 (setq gnus-newsgroup-cached cached))
5180 ;; Suppress duplicates?
5181 (when gnus-suppress-duplicates
5182 (gnus-dup-suppress-articles))
5184 ;; Set the initial limit.
5185 (setq gnus-newsgroup-limit (copy-sequence articles))
5186 ;; Remove canceled articles from the list of unread articles.
5187 (setq fetched-articles
5188 (mapcar (lambda (headers) (mail-header-number headers))
5189 gnus-newsgroup-headers))
5190 (setq gnus-newsgroup-articles fetched-articles)
5191 (setq gnus-newsgroup-unreads
5192 (gnus-sorted-nintersection
5193 gnus-newsgroup-unreads fetched-articles))
5194 (gnus-compute-unseen-list)
5196 ;; Removed marked articles that do not exist.
5197 (gnus-update-missing-marks
5198 (gnus-sorted-difference articles fetched-articles))
5199 ;; We might want to build some more threads first.
5200 (when (and gnus-fetch-old-headers
5201 (eq gnus-headers-retrieved-by 'nov))
5202 (if (eq gnus-fetch-old-headers 'invisible)
5203 (gnus-build-all-threads)
5204 (gnus-build-old-threads)))
5205 ;; Let the Gnus agent mark articles as read.
5207 (gnus-agent-get-undownloaded-list))
5208 ;; Remove list identifiers from subject
5209 (when gnus-list-identifiers
5210 (gnus-summary-remove-list-identifiers))
5211 ;; Check whether auto-expire is to be done in this group.
5212 (setq gnus-newsgroup-auto-expire
5213 (gnus-group-auto-expirable-p group))
5214 ;; Set up the article buffer now, if necessary.
5215 (unless gnus-single-article-buffer
5216 (gnus-article-setup-buffer))
5217 ;; First and last article in this newsgroup.
5218 (when gnus-newsgroup-headers
5219 (setq gnus-newsgroup-begin
5220 (mail-header-number (car gnus-newsgroup-headers))
5223 (gnus-last-element gnus-newsgroup-headers))))
5224 ;; GROUP is successfully selected.
5225 (or gnus-newsgroup-headers t)))))
5227 (defun gnus-compute-unseen-list ()
5228 ;; The `seen' marks are treated specially.
5229 (if (not gnus-newsgroup-seen)
5230 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5231 (setq gnus-newsgroup-unseen
5232 (gnus-inverse-list-range-intersection
5233 gnus-newsgroup-articles gnus-newsgroup-seen))))
5235 (defun gnus-summary-display-make-predicate (display)
5236 (require 'gnus-agent)
5237 (when (= (length display) 1)
5238 (setq display (car display)))
5239 (unless gnus-summary-display-cache
5240 (dolist (elem (append '((unread . unread)
5243 gnus-article-mark-lists))
5244 (push (cons (cdr elem)
5246 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5247 gnus-summary-display-cache)))
5248 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5249 (gnus-category-predicate-cache gnus-summary-display-cache))
5250 (gnus-get-predicate display)))
5252 ;; Uses the dynamically bound `number' variable.
5255 (defun gnus-article-marked-p (type &optional article)
5256 (let ((article (or article number)))
5259 (memq article gnus-newsgroup-marked))
5261 (memq article gnus-newsgroup-spam-marked))
5263 (memq article gnus-newsgroup-unsendable))
5264 ((eq type 'undownload)
5265 (memq article gnus-newsgroup-undownloaded))
5266 ((eq type 'download)
5267 (memq article gnus-newsgroup-downloadable))
5269 (memq article gnus-newsgroup-unreads))
5271 (memq article gnus-newsgroup-reads))
5273 (memq article gnus-newsgroup-dormant) )
5275 (memq article gnus-newsgroup-expirable))
5277 (memq article gnus-newsgroup-replied))
5279 (memq article gnus-newsgroup-killed))
5280 ((eq type 'bookmark)
5281 (assq article gnus-newsgroup-bookmarks))
5283 (assq article gnus-newsgroup-scored))
5285 (memq article gnus-newsgroup-saved))
5287 (memq article gnus-newsgroup-cached))
5289 (memq article gnus-newsgroup-forwarded))
5291 (not (memq article gnus-newsgroup-unseen)))
5293 (memq article gnus-newsgroup-recent))
5296 (defun gnus-articles-to-read (group &optional read-all)
5297 "Find out what articles the user wants to read."
5299 ;; Select all articles if `read-all' is non-nil, or if there
5300 ;; are no unread articles.
5302 (and (zerop (length gnus-newsgroup-marked))
5303 (zerop (length gnus-newsgroup-unreads)))
5304 ;; Fetch all if the predicate is non-nil.
5305 gnus-newsgroup-display)
5306 ;; We want to select the headers for all the articles in
5307 ;; the group, so we select either all the active
5308 ;; articles in the group, or (if that's nil), the
5309 ;; articles in the cache.
5311 (gnus-uncompress-range (gnus-active group))
5312 (gnus-cache-articles-in-group group))
5313 ;; Select only the "normal" subset of articles.
5315 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5316 gnus-newsgroup-unreads)))
5317 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5318 (scored (length scored-list))
5319 (number (length articles))
5320 (marked (+ (length gnus-newsgroup-marked)
5321 (length gnus-newsgroup-dormant)))
5326 ((numberp gnus-newsgroup-display)
5327 gnus-newsgroup-display)
5331 ((and (or (<= scored marked) (= scored number))
5332 (numberp gnus-large-newsgroup)
5333 (> number gnus-large-newsgroup))
5334 (let* ((cursor-in-echo-area nil)
5335 (initial (gnus-parameter-large-newsgroup-initial
5336 gnus-newsgroup-name))
5340 "How many articles from %s (%s %d): "
5342 (gnus-group-decoded-name gnus-newsgroup-name)
5344 (if initial "max" "default")
5347 (cons (number-to-string initial)
5349 (if (string-match "^[ \t]*$" input) number input)))
5350 ((and (> scored marked) (< scored number)
5351 (> (- scored number) 20))
5354 (format "%s %s (%d scored, %d total): "
5355 "How many articles from"
5356 (gnus-group-decoded-name group)
5358 (if (string-match "^[ \t]*$" input)
5362 (message "Quit getting the articles to read")
5364 (setq select (if (stringp select) (string-to-number select) select))
5365 (if (or (null select) (zerop select))
5367 (if (and (not (zerop scored)) (<= (abs select) scored))
5369 (setq articles (sort scored-list '<))
5370 (setq number (length articles)))
5371 (setq articles (copy-sequence articles)))
5373 (when (< (abs select) number)
5375 ;; Select the N oldest articles.
5376 (setcdr (nthcdr (1- (abs select)) articles) nil)
5377 ;; Select the N most recent articles.
5378 (setq articles (nthcdr (- number select) articles))))
5379 (setq gnus-newsgroup-unselected
5380 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5381 (when gnus-alter-articles-to-read-function
5384 (funcall gnus-alter-articles-to-read-function
5385 gnus-newsgroup-name articles)
5389 (defun gnus-killed-articles (killed articles)
5392 (when (inline (gnus-member-of-range (car articles) killed))
5393 (push (car articles) out))
5394 (setq articles (cdr articles)))
5397 (defun gnus-uncompress-marks (marks)
5398 "Uncompress the mark ranges in MARKS."
5399 (let ((uncompressed '(score bookmark))
5402 (if (memq (caar marks) uncompressed)
5403 (push (car marks) out)
5404 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5405 (setq marks (cdr marks)))
5408 (defun gnus-article-mark-to-type (mark)
5409 "Return the type of MARK."
5410 (or (cadr (assq mark gnus-article-special-mark-lists))
5413 (defun gnus-article-unpropagatable-p (mark)
5414 "Return whether MARK should be propagated to back end."
5415 (memq mark gnus-article-unpropagated-mark-lists))
5417 (defun gnus-adjust-marked-articles (info)
5418 "Set all article lists and remove all marks that are no longer valid."
5419 (let* ((marked-lists (gnus-info-marks info))
5420 (active (gnus-active (gnus-info-group info)))
5423 (types gnus-article-mark-lists)
5424 marks var articles article mark mark-type
5427 (dolist (marks marked-lists)
5428 (setq mark (car marks)
5429 mark-type (gnus-article-mark-to-type mark)
5430 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5432 ;; We set the variable according to the type of the marks list,
5433 ;; and then adjust the marks to a subset of the active articles.
5435 ;; Adjust "simple" lists - compressed yet unsorted
5436 ((eq mark-type 'list)
5437 ;; Simultaneously uncompress and clip to active range
5438 ;; See gnus-uncompress-range for a description of possible marks
5440 (if (not (cadr marks))
5442 (setq articles (if (numberp (cddr marks))
5448 (while (setq article (pop articles))
5449 (cond ((consp article)
5450 (setq bgn (max (car article) min)
5451 end (min (cdr article) max))
5453 (setq l (setcdr l (cons bgn nil))
5455 ((and (<= min article)
5457 (setq l (setcdr l (cons article nil))))))
5458 (set var (cdr lh)))))
5460 ((eq mark-type 'tuple)
5461 (set var (setq articles (cdr marks)))
5462 (when (not (listp (cdr (symbol-value var))))
5463 (set var (list (symbol-value var))))
5464 (when (not (listp (cdr articles)))
5465 (setq articles (list articles)))
5467 (when (or (not (consp (setq article (pop articles))))
5468 (< (car article) min)
5469 (> (car article) max))
5470 (set var (delq article (symbol-value var))))))
5471 ;; Adjust ranges (sloppily).
5472 ((eq mark-type 'range)
5475 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5476 ;; It should be (seen (NUM1 . NUM2)).
5477 (when (numberp (cddr marks))
5478 (setcdr marks (list (cdr marks))))
5479 (setq articles (cdr marks))
5480 (while (and articles
5481 (or (and (consp (car articles))
5482 (> min (cdar articles)))
5483 (and (numberp (car articles))
5484 (> min (car articles)))))
5486 (set var articles))))))))
5488 (defun gnus-update-missing-marks (missing)
5489 "Go through the list of MISSING articles and remove them from the mark lists."
5492 ;; Go through all types.
5493 (dolist (elem gnus-article-mark-lists)
5494 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5495 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5496 (when (symbol-value var)
5497 ;; This list has articles. So we delete all missing
5498 ;; articles from it.
5501 (set var (delq (pop m) (symbol-value var))))))))))
5503 (defun gnus-update-marks ()
5504 "Enter the various lists of marked articles into the newsgroup info list."
5505 (let ((types gnus-article-mark-lists)
5506 (info (gnus-get-info gnus-newsgroup-name))
5507 type list newmarked symbol delta-marks)
5509 ;; Add all marks lists to the list of marks lists.
5510 (while (setq type (pop types))
5511 (setq list (symbol-value
5513 (intern (format "gnus-newsgroup-%s" (car type))))))
5516 ;; Get rid of the entries of the articles that have the
5518 (when (and (eq (cdr type) 'score)
5522 (prev (cons nil list))
5525 (if (or (not (consp (car arts)))
5526 (= (cdar arts) gnus-summary-default-score))
5527 (setcdr prev (cdr arts))
5529 (setq arts (cdr arts)))
5530 (setq list (cdr all)))))
5532 (when (eq (cdr type) 'seen)
5533 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5535 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5536 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5538 (when (and (gnus-check-backend-function
5539 'request-set-mark gnus-newsgroup-name)
5540 (not (gnus-article-unpropagatable-p (cdr type))))
5541 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5542 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5543 (add (gnus-remove-from-range
5544 (gnus-copy-sequence list) old)))
5546 (push (list add 'add (list (cdr type))) delta-marks))
5548 (push (list del 'del (list (cdr type))) delta-marks))))
5551 (push (cons (cdr type) list) newmarked)))
5554 (unless (gnus-check-group gnus-newsgroup-name)
5555 (error "Can't open server for %s" gnus-newsgroup-name))
5556 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5558 ;; Enter these new marks into the info of the group.
5560 (setcar (nthcdr 3 info) newmarked)
5561 ;; Add the marks lists to the end of the info.
5563 (setcdr (nthcdr 2 info) (list newmarked))))
5565 ;; Cut off the end of the info if there's nothing else there.
5569 (when (nthcdr (decf i) info)
5570 (setcdr (nthcdr i info) nil)))))))
5572 (defun gnus-set-mode-line (where)
5573 "Set the mode line of the article or summary buffers.
5574 If WHERE is `summary', the summary mode line format will be used."
5575 ;; Is this mode line one we keep updated?
5576 (when (and (memq where gnus-updated-mode-lines)
5578 (intern (format "gnus-%s-mode-line-format-spec" where))))
5581 ;; We evaluate this in the summary buffer since these
5582 ;; variables are buffer-local to that buffer.
5583 (set-buffer gnus-summary-buffer)
5584 ;; We bind all these variables that are used in the `eval' form
5586 (let* ((mformat (symbol-value
5588 (format "gnus-%s-mode-line-format-spec" where))))
5589 (gnus-tmp-group-name (gnus-group-decoded-name
5590 gnus-newsgroup-name))
5591 (gnus-tmp-article-number (or gnus-current-article 0))
5592 (gnus-tmp-unread gnus-newsgroup-unreads)
5593 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5594 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5595 (gnus-tmp-unread-and-unselected
5596 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5597 (zerop gnus-tmp-unselected))
5599 ((zerop gnus-tmp-unselected)
5600 (format "{%d more}" gnus-tmp-unread-and-unticked))
5601 (t (format "{%d(+%d) more}"
5602 gnus-tmp-unread-and-unticked
5603 gnus-tmp-unselected))))
5605 (if (and gnus-current-headers
5606 (vectorp gnus-current-headers))
5607 (gnus-mode-string-quote
5608 (mail-header-subject gnus-current-headers))
5610 bufname-length max-len
5611 gnus-tmp-header);; passed as argument to any user-format-funcs
5612 (setq mode-string (eval mformat))
5613 (setq bufname-length (if (string-match "%b" mode-string)
5616 (if (eq where 'summary)
5618 (get-buffer gnus-article-buffer))))
5621 (setq max-len (max 4 (if gnus-mode-non-string-length
5623 gnus-mode-non-string-length
5625 (length mode-string))))
5626 ;; We might have to chop a bit of the string off...
5627 (when (> (length mode-string) max-len)
5629 (concat (gnus-truncate-string mode-string (- max-len 3))
5631 ;; Pad the mode string a bit.
5632 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5633 ;; Update the mode line.
5634 (setq mode-line-buffer-identification
5635 (gnus-mode-line-buffer-identification (list mode-string)))
5636 (set-buffer-modified-p t))))
5638 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5639 "Go through the HEADERS list and add all Xrefs to a hash table.
5640 The resulting hash table is returned, or nil if no Xrefs were found."
5641 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5642 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5643 (xref-hashtb (gnus-make-hashtable))
5644 start group entry number xrefs header)
5646 (setq header (pop headers))
5647 (when (and (setq xrefs (mail-header-xref header))
5648 (not (memq (setq number (mail-header-number header))
5651 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5652 (setq start (match-end 0))
5653 (setq group (if prefix
5654 (concat prefix (substring xrefs (match-beginning 1)
5656 (substring xrefs (match-beginning 1) (match-end 1))))
5658 (string-to-int (substring xrefs (match-beginning 2)
5660 (if (setq entry (gnus-gethash group xref-hashtb))
5661 (setcdr entry (cons number (cdr entry)))
5662 (gnus-sethash group (cons number nil) xref-hashtb)))))
5663 (and start xref-hashtb)))
5665 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5666 "Look through all the headers and mark the Xrefs as read."
5667 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5668 name info xref-hashtb idlist method nth4)
5670 (set-buffer gnus-group-buffer)
5671 (when (setq xref-hashtb
5672 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5675 (unless (string= from-newsgroup (setq name (symbol-name group)))
5676 (setq idlist (symbol-value group))
5677 ;; Dead groups are not updated.
5679 (setq info (gnus-get-info name))
5680 (when (stringp (setq nth4 (gnus-info-method info)))
5681 (setq nth4 (gnus-server-to-method nth4))))
5682 ;; Only do the xrefs if the group has the same
5683 ;; select method as the group we have just read.
5684 (or (gnus-methods-equal-p
5685 nth4 (gnus-find-method-for-group from-newsgroup))
5687 (equal nth4 (setq method (gnus-find-method-for-group
5689 (and (equal (car nth4) (car method))
5690 (equal (nth 1 nth4) (nth 1 method))))
5691 gnus-use-cross-reference
5692 (or (not (eq gnus-use-cross-reference t))
5694 ;; Only do cross-references on subscribed
5695 ;; groups, if that is what is wanted.
5696 (<= (gnus-info-level info) gnus-level-subscribed))
5697 (gnus-group-make-articles-read name idlist))))
5700 (defun gnus-compute-read-articles (group articles)
5701 (let* ((entry (gnus-group-entry group))
5702 (info (nth 2 entry))
5703 (active (gnus-active group))
5706 ;; First peel off all invalid article numbers.
5708 (let ((ids articles)
5710 (while (setq id (pop ids))
5711 (when (and first (> id (cdr active)))
5712 ;; We'll end up in this situation in one particular
5713 ;; obscure situation. If you re-scan a group and get
5714 ;; a new article that is cross-posted to a different
5715 ;; group that has not been re-scanned, you might get
5716 ;; crossposted article that has a higher number than
5717 ;; Gnus believes possible. So we re-activate this
5718 ;; group as well. This might mean doing the
5719 ;; crossposting thingy will *increase* the number
5720 ;; of articles in some groups. Tsk, tsk.
5721 (setq active (or (gnus-activate-group group) active)))
5722 (when (or (> id (cdr active))
5723 (< id (car active)))
5724 (setq articles (delq id articles))))))
5725 ;; If the read list is nil, we init it.
5727 (null (gnus-info-read info))
5729 (setq ninfo (cons 1 (1- (car active))))
5730 (setq ninfo (gnus-info-read info)))
5731 ;; Then we add the read articles to the range.
5733 ninfo (setq articles (sort articles '<))))))
5735 (defun gnus-group-make-articles-read (group articles)
5736 "Update the info of GROUP to say that ARTICLES are read."
5738 (entry (gnus-group-entry group))
5739 (info (nth 2 entry))
5740 (active (gnus-active group))
5743 (setq range (gnus-compute-read-articles group articles))
5744 (with-current-buffer gnus-group-buffer
5747 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5748 (gnus-info-set-read ',info ',(gnus-info-read info))
5749 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5750 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5751 (gnus-group-update-group ,group t))))
5752 ;; Add the read articles to the range.
5753 (gnus-info-set-read info range)
5754 (gnus-request-set-mark group (list (list range 'add '(read))))
5755 ;; Then we have to re-compute how many unread
5756 ;; articles there are in this group.
5760 (setq num (- (1+ (cdr active)) (car active))))
5761 ((not (listp (cdr range)))
5762 (setq num (- (cdr active) (- (1+ (cdr range))
5766 (if (numberp (car range))
5768 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5769 (setq range (cdr range)))
5770 (setq num (- (cdr active) num))))
5771 ;; Update the number of unread articles.
5773 ;; Update the group buffer.
5774 (unless (gnus-ephemeral-group-p group)
5775 (gnus-group-update-group group t))))))
5777 (defvar gnus-newsgroup-none-id 0)
5779 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5780 (let ((cur nntp-server-buffer)
5783 (with-current-buffer gnus-summary-buffer
5784 gnus-newsgroup-dependencies)))
5785 headers id end ref number
5786 (mail-parse-charset gnus-newsgroup-charset)
5787 (mail-parse-ignored-charsets
5788 (save-excursion (condition-case nil
5789 (set-buffer gnus-summary-buffer)
5791 gnus-newsgroup-ignored-charsets)))
5793 (set-buffer nntp-server-buffer)
5794 ;; Translate all TAB characters into SPACE characters.
5795 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5796 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5797 (ietf-drums-unfold-fws)
5798 (gnus-run-hooks 'gnus-parse-headers-hook)
5799 (let ((case-fold-search t)
5800 in-reply-to header p lines chars ctype)
5801 (goto-char (point-min))
5802 ;; Search to the beginning of the next header. Error messages
5803 ;; do not begin with 2 or 3.
5804 (while (re-search-forward "^[23][0-9]+ " nil t)
5807 ;; This implementation of this function, with nine
5808 ;; search-forwards instead of the one re-search-forward and
5809 ;; a case (which basically was the old function) is actually
5810 ;; about twice as fast, even though it looks messier. You
5811 ;; can't have everything, I guess. Speed and elegance
5812 ;; doesn't always go hand in hand.
5815 (make-full-mail-header
5818 (setq number (read cur))
5821 (narrow-to-region (point)
5822 (or (and (search-forward "\n.\n" nil t)
5828 (if (search-forward "\nsubject:" nil t)
5829 (nnheader-header-value)
5834 (if (search-forward "\nfrom:" nil t)
5835 (nnheader-header-value)
5840 (if (search-forward "\ndate:" nil t)
5841 (nnheader-header-value) ""))
5845 (setq id (if (re-search-forward
5846 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5847 ;; We do it this way to make sure the Message-ID
5848 ;; is (somewhat) syntactically valid.
5849 (buffer-substring (match-beginning 1)
5851 ;; If there was no message-id, we just fake one
5852 ;; to make subsequent routines simpler.
5853 (nnheader-generate-fake-message-id number))))
5857 (if (search-forward "\nreferences:" nil t)
5861 (nnheader-header-value)
5866 (search-backward ">" end t)
5869 (search-backward "<" end t)
5871 ;; Get the references from the in-reply-to header if there
5872 ;; were no references and the in-reply-to header looks
5874 (if (and (search-forward "\nin-reply-to:" nil t)
5875 (setq in-reply-to (nnheader-header-value))
5876 (string-match "<[^>]+>" in-reply-to))
5878 (setq ref (substring in-reply-to (match-beginning 0)
5880 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5881 (setq ref2 (substring in-reply-to (match-beginning 0)
5883 (when (> (length ref2) (length ref))
5890 (if (search-forward "\nchars: " nil t)
5891 (if (numberp (setq chars (ignore-errors (read cur))))
5897 (if (search-forward "\nlines: " nil t)
5898 (if (numberp (setq lines (ignore-errors (read cur))))
5904 (and (search-forward "\nxref:" nil t)
5905 (nnheader-header-value)))
5907 (when gnus-extra-headers
5908 (let ((extra gnus-extra-headers)
5912 (when (search-forward
5913 (concat "\n" (symbol-name (car extra)) ":") nil t)
5914 (push (cons (car extra) (nnheader-header-value)) out))
5918 (if (and (search-forward "\ncontent-type: " nil t)
5919 (setq ctype (nnheader-header-value)))
5920 (mime-entity-set-content-type-internal
5921 header (mime-parse-Content-Type ctype)))
5922 (when (equal id ref)
5925 (when gnus-alter-header-function
5926 (funcall gnus-alter-header-function header)
5927 (setq id (mail-header-id header)
5928 ref (gnus-parent-id (mail-header-references header))))
5931 (gnus-dependencies-add-header
5932 header dependencies force-new))
5933 (push header headers))
5934 (goto-char (point-max))
5936 (nreverse headers)))))
5938 ;; Goes through the xover lines and returns a list of vectors
5939 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5940 force-new dependencies
5941 group also-fetch-heads)
5942 "Parse the news overview data in the server buffer.
5943 Return a list of headers that match SEQUENCE (see
5944 `nntp-retrieve-headers')."
5945 ;; Get the Xref when the users reads the articles since most/some
5946 ;; NNTP servers do not include Xrefs when using XOVER.
5947 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5948 (let ((mail-parse-charset gnus-newsgroup-charset)
5949 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5950 (cur nntp-server-buffer)
5951 (dependencies (or dependencies gnus-newsgroup-dependencies))
5953 ((eq gnus-read-all-available-headers t)
5955 ((stringp gnus-read-all-available-headers)
5956 (string-match gnus-read-all-available-headers group))
5959 number headers header)
5961 (set-buffer nntp-server-buffer)
5962 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5963 ;; Allow the user to mangle the headers before parsing them.
5964 (gnus-run-hooks 'gnus-parse-headers-hook)
5965 (goto-char (point-min))
5966 (gnus-parse-without-error
5967 (while (and (or sequence allp)
5969 (setq number (read cur))
5971 (while (and sequence
5972 (< (car sequence) number))
5973 (setq sequence (cdr sequence))))
5976 (eq number (car sequence))))
5978 (setq sequence (cdr sequence))
5979 (setq header (inline
5980 (gnus-nov-parse-line
5981 number dependencies force-new)))))
5982 (push header headers))
5984 ;; A common bug in inn is that if you have posted an article and
5985 ;; then retrieves the active file, it will answer correctly --
5986 ;; the new article is included. However, a NOV entry for the
5987 ;; article may not have been generated yet, so this may fail.
5988 ;; We work around this problem by retrieving the last few
5989 ;; headers using HEAD.
5990 (if (or (not also-fetch-heads)
5992 ;; We (probably) got all the headers.
5994 (let ((gnus-nov-is-evil t))
5997 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5998 (gnus-get-newsgroup-headers))))))))
6000 (defun gnus-article-get-xrefs ()
6001 "Fill in the Xref value in `gnus-current-headers', if necessary.
6002 This is meant to be called in `gnus-article-internal-prepare-hook'."
6003 (let ((headers (with-current-buffer gnus-summary-buffer
6004 gnus-current-headers)))
6005 (or (not gnus-use-cross-reference)
6007 (and (mail-header-xref headers)
6008 (not (string= (mail-header-xref headers) "")))
6009 (let ((case-fold-search t)
6012 (nnheader-narrow-to-headers)
6013 (goto-char (point-min))
6014 (when (or (and (not (eobp))
6015 (eq (downcase (char-after)) ?x)
6016 (looking-at "Xref:"))
6017 (search-forward "\nXref:" nil t))
6018 (goto-char (1+ (match-end 0)))
6019 (setq xref (buffer-substring (point) (point-at-eol)))
6020 (mail-header-set-xref headers xref)))))))
6022 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6023 "Find article ID and insert the summary line for that article.
6024 OLD-HEADER can either be a header or a line number to insert
6025 the subject line on."
6026 (let* ((line (and (numberp old-header) old-header))
6027 (old-header (and (vectorp old-header) old-header))
6028 (header (cond ((and old-header use-old-header)
6031 (gnus-number-to-header id))
6032 (gnus-number-to-header id))
6034 (gnus-read-header id))))
6035 (number (and (numberp id) id))
6038 ;; Rebuild the thread that this article is part of and go to the
6039 ;; article we have fetched.
6040 (when (and (not gnus-show-threads)
6043 (setq d (gnus-data-find (mail-header-number old-header))))
6044 (goto-char (gnus-data-pos d))
6050 (gnus-delete-line))))))
6051 ;; Remove list identifiers from subject.
6052 (when gnus-list-identifiers
6053 (let ((gnus-newsgroup-headers (list header)))
6054 (gnus-summary-remove-list-identifiers)
6055 (setq header (car gnus-newsgroup-headers))))
6057 (mail-header-set-number header (mail-header-number old-header)))
6058 (setq gnus-newsgroup-sparse
6059 (delq (setq number (mail-header-number header))
6060 gnus-newsgroup-sparse))
6061 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6062 (push number gnus-newsgroup-limit)
6063 (gnus-rebuild-thread (mail-header-id header) line)
6064 (gnus-summary-goto-subject number nil t))
6065 (when (and (numberp number)
6067 ;; We have to update the boundaries even if we can't fetch the
6068 ;; article if ID is a number -- so that the next `P' or `N'
6069 ;; command will fetch the previous (or next) article even
6070 ;; if the one we tried to fetch this time has been canceled.
6071 (when (> number gnus-newsgroup-end)
6072 (setq gnus-newsgroup-end number))
6073 (when (< number gnus-newsgroup-begin)
6074 (setq gnus-newsgroup-begin number))
6075 (setq gnus-newsgroup-unselected
6076 (delq number gnus-newsgroup-unselected)))
6077 ;; Report back a success?
6078 (and header (mail-header-number header))))
6080 ;;; Process/prefix in the summary buffer
6082 (defun gnus-summary-work-articles (n)
6083 "Return a list of articles to be worked upon.
6084 The prefix argument, the list of process marked articles, and the
6085 current article will be taken into consideration."
6087 (set-buffer gnus-summary-buffer)
6090 ;; A numerical prefix has been given.
6091 (setq n (prefix-numeric-value n))
6092 (let ((backward (< n 0))
6093 (n (abs (prefix-numeric-value n)))
6098 (push (setq article (gnus-summary-article-number))
6101 (gnus-summary-find-prev nil article)
6102 (gnus-summary-find-next nil article)))
6104 (nreverse articles)))
6105 ((and (gnus-region-active-p) (mark))
6106 (message "region active")
6107 ;; Work on the region between point and mark.
6108 (let ((max (max (point) (mark)))
6111 (goto-char (min (point) (mark)))
6114 (push (setq article (gnus-summary-article-number)) articles)
6115 (gnus-summary-find-next nil article)
6117 (nreverse articles))))
6118 (gnus-newsgroup-processable
6119 ;; There are process-marked articles present.
6120 ;; Save current state.
6121 (gnus-summary-save-process-mark)
6123 (reverse gnus-newsgroup-processable))
6125 ;; Just return the current article.
6126 (list (gnus-summary-article-number))))))
6128 (defmacro gnus-summary-iterate (arg &rest forms)
6129 "Iterate over the process/prefixed articles and do FORMS.
6130 ARG is the interactive prefix given to the command. FORMS will be
6131 executed with point over the summary line of the articles."
6132 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6133 `(let ((,articles (gnus-summary-work-articles ,arg)))
6135 (gnus-summary-goto-subject (car ,articles))
6139 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6140 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6142 (defun gnus-summary-save-process-mark ()
6143 "Push the current set of process marked articles on the stack."
6145 (push (copy-sequence gnus-newsgroup-processable)
6146 gnus-newsgroup-process-stack))
6148 (defun gnus-summary-kill-process-mark ()
6149 "Push the current set of process marked articles on the stack and unmark."
6151 (gnus-summary-save-process-mark)
6152 (gnus-summary-unmark-all-processable))
6154 (defun gnus-summary-yank-process-mark ()
6155 "Pop the last process mark state off the stack and restore it."
6157 (unless gnus-newsgroup-process-stack
6158 (error "Empty mark stack"))
6159 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6161 (defun gnus-summary-process-mark-set (set)
6162 "Make SET into the current process marked articles."
6163 (gnus-summary-unmark-all-processable)
6165 (gnus-summary-set-process-mark (pop set))))
6167 ;;; Searching and stuff
6169 (defun gnus-summary-search-group (&optional backward use-level)
6170 "Search for next unread newsgroup.
6171 If optional argument BACKWARD is non-nil, search backward instead."
6173 (set-buffer gnus-group-buffer)
6174 (when (gnus-group-search-forward
6175 backward nil (if use-level (gnus-group-group-level) nil))
6176 (gnus-group-group-name))))
6178 (defun gnus-summary-best-group (&optional exclude-group)
6179 "Find the name of the best unread group.
6180 If EXCLUDE-GROUP, do not go to this group."
6181 (with-current-buffer gnus-group-buffer
6183 (gnus-group-best-unread-group exclude-group))))
6185 (defun gnus-summary-find-next (&optional unread article backward)
6187 (gnus-summary-find-prev unread article)
6188 (let* ((dummy (gnus-summary-article-intangible-p))
6189 (article (or article (gnus-summary-article-number)))
6190 (data (gnus-data-find-list article))
6192 (when (and (not dummy)
6193 (or (not gnus-summary-check-current)
6195 (not (gnus-data-unread-p (car data)))))
6196 (setq data (cdr data)))
6201 (unless (memq (gnus-data-number (car data))
6203 ((eq gnus-auto-goto-ignores
6204 'always-undownloaded)
6205 gnus-newsgroup-undownloaded)
6208 ((eq gnus-auto-goto-ignores
6210 gnus-newsgroup-unfetched)
6211 ((eq gnus-auto-goto-ignores
6213 gnus-newsgroup-undownloaded)))
6214 (when (gnus-data-unread-p (car data))
6215 (setq result (car data)
6217 (setq data (cdr data)))
6220 (goto-char (gnus-data-pos result))
6221 (gnus-data-number result)))))
6223 (defun gnus-summary-find-prev (&optional unread article)
6224 (let* ((eobp (eobp))
6225 (article (or article (gnus-summary-article-number)))
6226 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6228 (when (and (not eobp)
6229 (or (not gnus-summary-check-current)
6231 (not (gnus-data-unread-p (car data)))))
6232 (setq data (cdr data)))
6237 (unless (memq (gnus-data-number (car data))
6239 ((eq gnus-auto-goto-ignores
6240 'always-undownloaded)
6241 gnus-newsgroup-undownloaded)
6244 ((eq gnus-auto-goto-ignores
6246 gnus-newsgroup-unfetched)
6247 ((eq gnus-auto-goto-ignores
6249 gnus-newsgroup-undownloaded)))
6250 (when (gnus-data-unread-p (car data))
6251 (setq result (car data)
6253 (setq data (cdr data)))
6256 (goto-char (gnus-data-pos result))
6257 (gnus-data-number result))))
6259 (defun gnus-summary-find-subject (subject &optional unread backward article)
6260 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6261 (article (or article (gnus-summary-article-number)))
6262 (articles (gnus-data-list backward))
6263 (arts (gnus-data-find-list article articles))
6265 (when (or (not gnus-summary-check-current)
6267 (not (gnus-data-unread-p (car arts))))
6268 (setq arts (cdr arts)))
6270 (and (or (not unread)
6271 (gnus-data-unread-p (car arts)))
6272 (vectorp (gnus-data-header (car arts)))
6274 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6275 (setq result (car arts)
6277 (setq arts (cdr arts)))
6279 (goto-char (gnus-data-pos result))
6280 (gnus-data-number result))))
6282 (defun gnus-summary-search-forward (&optional unread subject backward)
6283 "Search forward for an article.
6284 If UNREAD, look for unread articles. If SUBJECT, look for
6285 articles with that subject. If BACKWARD, search backward instead."
6286 (cond (subject (gnus-summary-find-subject subject unread backward))
6287 (backward (gnus-summary-find-prev unread))
6288 (t (gnus-summary-find-next unread))))
6290 (defun gnus-recenter (&optional n)
6291 "Center point in window and redisplay frame.
6292 Also do horizontal recentering."
6294 (when (and gnus-auto-center-summary
6295 (not (eq gnus-auto-center-summary 'vertical)))
6296 (gnus-horizontal-recenter))
6299 (defun gnus-summary-recenter ()
6300 "Center point in the summary window.
6301 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6302 displayed, no centering will be performed."
6303 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6304 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6306 ;; The user has to want it.
6307 (when gnus-auto-center-summary
6308 (let* ((top (cond ((< (window-height) 4) 0)
6309 ((< (window-height) 7) 1)
6310 (t (if (numberp gnus-auto-center-summary)
6311 gnus-auto-center-summary
6312 (/ (1- (window-height)) 2)))))
6313 (height (1- (window-height)))
6314 (bottom (save-excursion (goto-char (point-max))
6315 (forward-line (- height))
6317 (window (get-buffer-window (current-buffer))))
6318 (when (get-buffer-window gnus-article-buffer)
6319 ;; Only do recentering when the article buffer is displayed,
6320 ;; Set the window start to either `bottom', which is the biggest
6321 ;; possible valid number, or the second line from the top,
6322 ;; whichever is the least.
6323 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6324 (if (> bottom top-pos)
6325 ;; Keep the second line from the top visible
6326 (set-window-start window top-pos t)
6327 ;; Try to keep the bottom line visible; if it's partially
6328 ;; obscured, either scroll one more line to make it fully
6329 ;; visible, or revert to using TOP-POS.
6331 (goto-char (point-max))
6333 (let ((last-line-start (point)))
6335 (set-window-start window (point) t)
6336 (when (not (pos-visible-in-window-p last-line-start window))
6338 (set-window-start window (min (point) top-pos) t)))))))
6339 ;; Do horizontal recentering while we're at it.
6340 (when (and (get-buffer-window (current-buffer) t)
6341 (not (eq gnus-auto-center-summary 'vertical)))
6342 (let ((selected (selected-window)))
6343 (select-window (get-buffer-window (current-buffer) t))
6344 (gnus-summary-position-point)
6345 (gnus-horizontal-recenter)
6346 (select-window selected))))))
6348 (defun gnus-summary-jump-to-group (newsgroup)
6349 "Move point to NEWSGROUP in group mode buffer."
6350 ;; Keep update point of group mode buffer if visible.
6351 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6352 (save-window-excursion
6353 ;; Take care of tree window mode.
6354 (when (get-buffer-window gnus-group-buffer)
6355 (pop-to-buffer gnus-group-buffer))
6356 (gnus-group-jump-to-group newsgroup))
6358 ;; Take care of tree window mode.
6359 (if (get-buffer-window gnus-group-buffer)
6360 (pop-to-buffer gnus-group-buffer)
6361 (set-buffer gnus-group-buffer))
6362 (gnus-group-jump-to-group newsgroup))))
6364 ;; This function returns a list of article numbers based on the
6365 ;; difference between the ranges of read articles in this group and
6366 ;; the range of active articles.
6367 (defun gnus-list-of-unread-articles (group)
6368 (let* ((read (gnus-info-read (gnus-get-info group)))
6369 (active (or (gnus-active group) (gnus-activate-group group)))
6372 ;; If none are read, then all are unread.
6374 (setq first (car active))
6375 ;; If the range of read articles is a single range, then the
6376 ;; first unread article is the article after the last read
6377 ;; article. Sounds logical, doesn't it?
6378 (if (and (not (listp (cdr read)))
6379 (or (< (car read) (car active))
6380 (progn (setq read (list read))
6382 (setq first (max (car active) (1+ (cdr read))))
6383 ;; `read' is a list of ranges.
6384 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6387 (setq first (car active)))
6390 (while (< first nlast)
6391 (setq unread (cons first unread)
6393 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6394 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6395 (setq read (cdr read)))))
6396 ;; And add the last unread articles.
6397 (while (<= first last)
6398 (setq unread (cons first unread)
6400 ;; Return the list of unread articles.
6401 (delq 0 (nreverse unread))))
6403 (defun gnus-list-of-read-articles (group)
6404 "Return a list of unread, unticked and non-dormant articles."
6405 (let* ((info (gnus-get-info group))
6406 (marked (gnus-info-marks info))
6407 (active (gnus-active group)))
6409 (gnus-list-range-difference
6410 (gnus-list-range-difference
6411 (gnus-sorted-complement
6412 (gnus-uncompress-range active)
6413 (gnus-list-of-unread-articles group))
6414 (cdr (assq 'dormant marked)))
6415 (cdr (assq 'tick marked))))))
6417 ;; This function returns a sequence of article numbers based on the
6418 ;; difference between the ranges of read articles in this group and
6419 ;; the range of active articles.
6420 (defun gnus-sequence-of-unread-articles (group)
6421 (let* ((read (gnus-info-read (gnus-get-info group)))
6422 (active (or (gnus-active group) (gnus-activate-group group)))
6425 ;; If none are read, then all are unread.
6427 (setq first (car active))
6428 ;; If the range of read articles is a single range, then the
6429 ;; first unread article is the article after the last read
6430 ;; article. Sounds logical, doesn't it?
6431 (if (and (not (listp (cdr read)))
6432 (or (< (car read) (car active))
6433 (progn (setq read (list read))
6435 (setq first (max (car active) (1+ (cdr read))))
6436 ;; `read' is a list of ranges.
6437 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6440 (setq first (car active)))
6443 (push (cons first nlast) unread))
6444 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6445 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6446 (setq read (cdr read)))))
6447 ;; And add the last unread articles.
6448 (cond ((< first last)
6449 (push (cons first last) unread))
6451 (push first unread)))
6452 ;; Return the sequence of unread articles.
6453 (delq 0 (nreverse unread))))
6455 ;; Various summary commands
6457 (defun gnus-summary-select-article-buffer ()
6458 "Reconfigure windows to show article buffer."
6460 (if (not (gnus-buffer-live-p gnus-article-buffer))
6461 (error "There is no article buffer for this summary buffer")
6462 (gnus-configure-windows 'article)
6463 (select-window (get-buffer-window gnus-article-buffer))))
6465 (defun gnus-summary-universal-argument (arg)
6466 "Perform any operation on all articles that are process/prefixed."
6468 (let ((articles (gnus-summary-work-articles arg))
6475 (substitute-command-keys
6476 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6478 (gnus-error 1 "Undefined key")
6481 (gnus-summary-goto-subject (setq article (pop articles)))
6482 (let (gnus-newsgroup-processable)
6483 (command-execute func))
6484 (gnus-summary-remove-process-mark article)))))
6485 (gnus-summary-position-point))
6487 (defun gnus-summary-toggle-truncation (&optional arg)
6488 "Toggle truncation of summary lines.
6489 With ARG, turn line truncation on if ARG is positive."
6491 (setq truncate-lines
6492 (if (null arg) (not truncate-lines)
6493 (> (prefix-numeric-value arg) 0)))
6496 (defun gnus-summary-find-for-reselect ()
6497 "Return the number of an article to stay on across a reselect.
6498 The current article is considered, then following articles, then previous
6499 articles. An article is sought which is not cancelled and isn't a temporary
6500 insertion from another group. If there's no such then return a dummy 0."
6502 (dolist (rev '(nil t))
6503 (unless found ; don't demand the reverse list if we don't need it
6504 (let ((data (gnus-data-find-list
6505 (gnus-summary-article-number) (gnus-data-list rev))))
6506 (while (and data (not found))
6507 (if (and (< 0 (gnus-data-number (car data)))
6508 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6509 (setq found (gnus-data-number (car data))))
6510 (setq data (cdr data))))))
6513 (defun gnus-summary-reselect-current-group (&optional all rescan)
6514 "Exit and then reselect the current newsgroup.
6515 The prefix argument ALL means to select all articles."
6517 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6518 (error "Ephemeral groups can't be reselected"))
6519 (let ((current-subject (gnus-summary-find-for-reselect))
6520 (group gnus-newsgroup-name))
6521 (setq gnus-newsgroup-begin nil)
6522 (gnus-summary-exit nil 'leave-hidden)
6523 ;; We have to adjust the point of group mode buffer because
6524 ;; point was moved to the next unread newsgroup by exiting.
6525 (gnus-summary-jump-to-group group)
6528 (save-window-excursion
6529 ;; Don't show group contents.
6530 (set-window-start (selected-window) (point-max))
6531 (gnus-group-get-new-news-this-group 1))))
6532 (gnus-group-read-group all t)
6533 (gnus-summary-goto-subject current-subject nil t)))
6535 (defun gnus-summary-rescan-group (&optional all)
6536 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6538 (gnus-summary-reselect-current-group all t))
6540 (defun gnus-summary-update-info (&optional non-destructive)
6542 (let ((group gnus-newsgroup-name))
6544 (when gnus-newsgroup-kill-headers
6545 (setq gnus-newsgroup-killed
6546 (gnus-compress-sequence
6548 (gnus-list-range-intersection
6549 gnus-newsgroup-unselected gnus-newsgroup-killed)
6550 gnus-newsgroup-unreads)
6552 (unless (listp (cdr gnus-newsgroup-killed))
6553 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6554 (let ((headers gnus-newsgroup-headers))
6555 ;; Set the new ranges of read articles.
6556 (with-current-buffer gnus-group-buffer
6557 (gnus-undo-force-boundary))
6558 (gnus-update-read-articles
6559 group (gnus-sorted-union
6560 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6561 ;; Set the current article marks.
6562 (let ((gnus-newsgroup-scored
6563 (if (and (not gnus-save-score)
6564 (not non-destructive))
6566 gnus-newsgroup-scored)))
6568 (gnus-update-marks)))
6569 ;; Do the cross-ref thing.
6570 (when gnus-use-cross-reference
6571 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6572 ;; Do not switch windows but change the buffer to work.
6573 (set-buffer gnus-group-buffer)
6574 (unless (gnus-ephemeral-group-p group)
6575 (gnus-group-update-group group)))))))
6577 (defun gnus-summary-save-newsrc (&optional force)
6578 "Save the current number of read/marked articles in the dribble buffer.
6579 The dribble buffer will then be saved.
6580 If FORCE (the prefix), also save the .newsrc file(s)."
6582 (gnus-summary-update-info t)
6584 (gnus-save-newsrc-file)
6585 (gnus-dribble-save)))
6587 (defun gnus-summary-exit (&optional temporary leave-hidden)
6588 "Exit reading current newsgroup, and then return to group selection mode.
6589 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6591 (gnus-set-global-variables)
6592 (gnus-kill-save-kill-buffer)
6593 (gnus-async-halt-prefetch)
6594 (let* ((group gnus-newsgroup-name)
6595 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6596 (gnus-group-is-exiting-p t)
6599 (buf (current-buffer)))
6601 ;; Do adaptive scoring, and possibly save score files.
6602 (when gnus-newsgroup-adaptive
6603 (gnus-score-adaptive))
6604 (when gnus-use-scoring
6606 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6607 ;; If we have several article buffers, we kill them at exit.
6608 (unless gnus-single-article-buffer
6609 (gnus-kill-buffer gnus-original-article-buffer)
6610 (setq gnus-article-current nil))
6611 (when gnus-use-cache
6612 (gnus-cache-possibly-remove-articles)
6613 (gnus-cache-save-buffers))
6614 (gnus-async-prefetch-remove-group group)
6615 (when gnus-suppress-duplicates
6616 (gnus-dup-enter-articles))
6617 (when gnus-use-trees
6618 (gnus-tree-close group))
6619 (when gnus-use-cache
6620 (gnus-cache-write-active))
6621 ;; Remove entries for this group.
6622 (nnmail-purge-split-history (gnus-group-real-name group))
6623 ;; Make all changes in this group permanent.
6625 (gnus-run-hooks 'gnus-exit-group-hook)
6626 (gnus-summary-update-info))
6627 (gnus-close-group group)
6628 ;; Make sure where we were, and go to next newsgroup.
6629 (set-buffer gnus-group-buffer)
6631 (gnus-group-jump-to-group group))
6632 (gnus-run-hooks 'gnus-summary-exit-hook)
6633 (unless (or quit-config
6634 ;; If this group has disappeared from the summary
6635 ;; buffer, don't skip forwards.
6636 (not (string= group (gnus-group-group-name))))
6637 (gnus-group-next-unread-group 1))
6638 (setq group-point (point))
6641 ;; If we have several article buffers, we kill them at exit.
6642 (unless gnus-single-article-buffer
6643 (gnus-kill-buffer gnus-article-buffer)
6644 (gnus-kill-buffer gnus-original-article-buffer)
6645 (setq gnus-article-current nil))
6647 (if (not gnus-kill-summary-on-exit)
6649 (gnus-deaden-summary)
6651 ;; We set all buffer-local variables to nil. It is unclear why
6652 ;; this is needed, but if we don't, buffer-local variables are
6653 ;; not garbage-collected, it seems. This would the lead to en
6654 ;; ever-growing Emacs.
6655 (gnus-summary-clear-local-variables)
6656 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6657 (gnus-summary-clear-local-variables))
6658 (when (get-buffer gnus-article-buffer)
6659 (bury-buffer gnus-article-buffer))
6660 ;; We clear the global counterparts of the buffer-local
6661 ;; variables as well, just to be on the safe side.
6662 (set-buffer gnus-group-buffer)
6663 (gnus-summary-clear-local-variables)
6664 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6665 (gnus-summary-clear-local-variables))
6666 ;; Return to group mode buffer.
6667 (when (eq mode 'gnus-summary-mode)
6668 (gnus-kill-buffer buf)))
6669 (setq gnus-current-select-method gnus-select-method)
6671 (set-buffer gnus-group-buffer)
6672 (pop-to-buffer gnus-group-buffer))
6673 (if (not quit-config)
6675 (goto-char group-point)
6676 (unless leave-hidden
6677 (gnus-configure-windows 'group 'force))
6678 (unless (pos-visible-in-window-p)
6679 (forward-line (/ (static-if (featurep 'xemacs)
6680 (window-displayed-height)
6681 (1- (window-height)))
6683 (set-window-start (selected-window) (point))
6684 (goto-char group-point)))
6685 (gnus-handle-ephemeral-exit quit-config))
6686 ;; Clear the current group name.
6688 (setq gnus-newsgroup-name nil)))))
6690 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6691 (defun gnus-summary-exit-no-update (&optional no-questions)
6692 "Quit reading current newsgroup without updating read article info."
6694 (let* ((group gnus-newsgroup-name)
6695 (gnus-group-is-exiting-p t)
6696 (gnus-group-is-exiting-without-update-p t)
6697 (quit-config (gnus-group-quit-config group)))
6698 (when (or no-questions
6700 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6701 (gnus-async-halt-prefetch)
6702 (run-hooks 'gnus-summary-prepare-exit-hook)
6703 ;; If we have several article buffers, we kill them at exit.
6704 (unless gnus-single-article-buffer
6705 (gnus-kill-buffer gnus-article-buffer)
6706 (gnus-kill-buffer gnus-original-article-buffer)
6707 (setq gnus-article-current nil))
6708 (if (not gnus-kill-summary-on-exit)
6709 (gnus-deaden-summary)
6710 (gnus-close-group group)
6711 (gnus-summary-clear-local-variables)
6712 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6713 (gnus-summary-clear-local-variables))
6714 (set-buffer gnus-group-buffer)
6715 (gnus-summary-clear-local-variables)
6716 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6717 (gnus-summary-clear-local-variables))
6718 (gnus-kill-buffer gnus-summary-buffer))
6719 (unless gnus-single-article-buffer
6720 (setq gnus-article-current nil))
6721 (when gnus-use-trees
6722 (gnus-tree-close group))
6723 (gnus-async-prefetch-remove-group group)
6724 (when (get-buffer gnus-article-buffer)
6725 (bury-buffer gnus-article-buffer))
6726 ;; Return to the group buffer.
6727 (gnus-configure-windows 'group 'force)
6728 ;; Clear the current group name.
6729 (setq gnus-newsgroup-name nil)
6730 (unless (gnus-ephemeral-group-p group)
6731 (gnus-group-update-group group))
6732 (when (equal (gnus-group-group-name) group)
6733 (gnus-group-next-unread-group 1))
6735 (gnus-handle-ephemeral-exit quit-config)))))
6737 (defun gnus-handle-ephemeral-exit (quit-config)
6738 "Handle movement when leaving an ephemeral group.
6739 The state which existed when entering the ephemeral is reset."
6740 (if (not (buffer-name (car quit-config)))
6741 (gnus-configure-windows 'group 'force)
6742 (set-buffer (car quit-config))
6743 (cond ((eq major-mode 'gnus-summary-mode)
6744 (gnus-set-global-variables))
6745 ((eq major-mode 'gnus-article-mode)
6747 ;; The `gnus-summary-buffer' variable may point
6748 ;; to the old summary buffer when using a single
6750 (unless (gnus-buffer-live-p gnus-summary-buffer)
6751 (set-buffer gnus-group-buffer))
6752 (set-buffer gnus-summary-buffer)
6753 (gnus-set-global-variables))))
6754 (if (or (eq (cdr quit-config) 'article)
6755 (eq (cdr quit-config) 'pick))
6757 ;; The current article may be from the ephemeral group
6758 ;; thus it is best that we reload this article
6760 ;; If we're exiting from a large digest, this can be
6761 ;; extremely slow. So, it's better not to reload it. -- jh.
6762 ;;(gnus-summary-show-article)
6763 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6764 (gnus-configure-windows 'pick 'force)
6765 (gnus-configure-windows (cdr quit-config) 'force)))
6766 (gnus-configure-windows (cdr quit-config) 'force))
6767 (when (eq major-mode 'gnus-summary-mode)
6768 (gnus-summary-next-subject 1 nil t)
6769 (gnus-summary-recenter)
6770 (gnus-summary-position-point))))
6772 (defun gnus-summary-preview-mime-message ()
6773 "MIME decode and play this message."
6775 (let ((gnus-break-pages nil)
6777 (gnus-summary-select-article gnus-show-all-headers t))
6778 (let ((w (get-buffer-window gnus-article-buffer)))
6780 (select-window (get-buffer-window gnus-article-buffer)))))
6784 (defvar gnus-dead-summary-mode-map nil)
6786 (unless gnus-dead-summary-mode-map
6787 (setq gnus-dead-summary-mode-map (make-keymap))
6788 (suppress-keymap gnus-dead-summary-mode-map)
6789 (substitute-key-definition
6790 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6791 (dolist (key '("\C-d" "\r" "\177" [delete]))
6792 (define-key gnus-dead-summary-mode-map
6793 key 'gnus-summary-wake-up-the-dead))
6794 (dolist (key '("q" "Q"))
6795 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6797 (defvar gnus-dead-summary-mode nil
6798 "Minor mode for Gnus summary buffers.")
6800 (defun gnus-dead-summary-mode (&optional arg)
6801 "Minor mode for Gnus summary buffers."
6803 (when (eq major-mode 'gnus-summary-mode)
6804 (make-local-variable 'gnus-dead-summary-mode)
6805 (setq gnus-dead-summary-mode
6806 (if (null arg) (not gnus-dead-summary-mode)
6807 (> (prefix-numeric-value arg) 0)))
6808 (when gnus-dead-summary-mode
6810 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6812 (defun gnus-deaden-summary ()
6813 "Make the current summary buffer into a dead summary buffer."
6814 ;; Kill any previous dead summary buffer.
6815 (when (and gnus-dead-summary
6816 (buffer-name gnus-dead-summary))
6817 (with-current-buffer gnus-dead-summary
6818 (when gnus-dead-summary-mode
6819 (kill-buffer (current-buffer)))))
6820 ;; Make this the current dead summary.
6821 (setq gnus-dead-summary (current-buffer))
6822 (gnus-dead-summary-mode 1)
6823 (let ((name (buffer-name)))
6824 (when (string-match "Summary" name)
6826 (concat (substring name 0 (match-beginning 0)) "Dead "
6827 (substring name (match-beginning 0)))
6831 (defun gnus-kill-or-deaden-summary (buffer)
6832 "Kill or deaden the summary BUFFER."
6834 (when (and (buffer-name buffer)
6835 (not gnus-single-article-buffer))
6836 (with-current-buffer buffer
6837 (gnus-kill-buffer gnus-article-buffer)
6838 (gnus-kill-buffer gnus-original-article-buffer)))
6841 (gnus-kill-summary-on-exit
6842 (when (and gnus-use-trees
6843 (gnus-buffer-exists-p buffer))
6846 (gnus-tree-close gnus-newsgroup-name)))
6847 (gnus-kill-buffer buffer))
6848 ;; Deaden the buffer.
6849 ((gnus-buffer-exists-p buffer)
6852 (gnus-deaden-summary))))))
6854 (defun gnus-summary-wake-up-the-dead (&rest args)
6855 "Wake up the dead summary buffer."
6857 (gnus-dead-summary-mode -1)
6858 (let ((name (buffer-name)))
6859 (when (string-match "Dead " name)
6861 (concat (substring name 0 (match-beginning 0))
6862 (substring name (match-end 0)))
6864 (gnus-message 3 "This dead summary is now alive again"))
6866 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6867 (defun gnus-summary-fetch-faq (&optional faq-dir)
6868 "Fetch the FAQ for the current group.
6869 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6873 (when current-prefix-arg
6875 "FAQ dir: " (and (listp gnus-group-faq-directory)
6877 gnus-group-faq-directory))))))
6878 (let (gnus-faq-buffer)
6879 (when (setq gnus-faq-buffer
6880 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6881 (gnus-configure-windows 'summary-faq))))
6883 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6884 (defun gnus-summary-describe-group (&optional force)
6885 "Describe the current newsgroup."
6887 (gnus-group-describe-group force gnus-newsgroup-name))
6889 (defun gnus-summary-describe-briefly ()
6890 "Describe summary mode commands briefly."
6892 (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")))
6894 ;; Walking around group mode buffer from summary mode.
6896 (defun gnus-summary-next-group (&optional no-article target-group backward)
6897 "Exit current newsgroup and then select next unread newsgroup.
6898 If prefix argument NO-ARTICLE is non-nil, no article is selected
6899 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6900 previous group instead."
6902 ;; Stop pre-fetching.
6903 (gnus-async-halt-prefetch)
6904 (let ((current-group gnus-newsgroup-name)
6905 (current-buffer (current-buffer))
6907 ;; First we semi-exit this group to update Xrefs and all variables.
6908 ;; We can't do a real exit, because the window conf must remain
6909 ;; the same in case the user is prompted for info, and we don't
6910 ;; want the window conf to change before that...
6911 (gnus-summary-exit t)
6912 (while (not entered)
6913 ;; Then we find what group we are supposed to enter.
6914 (set-buffer gnus-group-buffer)
6915 (gnus-group-jump-to-group current-group)
6918 (if (eq gnus-keep-same-level 'best)
6919 (gnus-summary-best-group gnus-newsgroup-name)
6920 (gnus-summary-search-group backward gnus-keep-same-level))))
6921 (if (not target-group)
6922 ;; There are no further groups, so we return to the group
6925 (gnus-message 5 "Returning to the group buffer")
6927 (when (gnus-buffer-live-p current-buffer)
6928 (set-buffer current-buffer)
6929 (gnus-summary-exit))
6930 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6931 ;; We try to enter the target group.
6932 (gnus-group-jump-to-group target-group)
6933 (let ((unreads (gnus-group-group-unread)))
6934 (if (and (or (eq t unreads)
6935 (and unreads (not (zerop unreads))))
6936 (gnus-summary-read-group
6937 target-group nil no-article
6938 (and (buffer-name current-buffer) current-buffer)
6941 (setq current-group target-group
6942 target-group nil)))))))
6944 (defun gnus-summary-prev-group (&optional no-article)
6945 "Exit current newsgroup and then select previous unread newsgroup.
6946 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6948 (gnus-summary-next-group no-article nil t))
6950 ;; Walking around summary lines.
6952 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6953 "Go to the first subject satisfying any non-nil constraint.
6954 If UNREAD is non-nil, the article should be unread.
6955 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6956 If UNSEEN is non-nil, the article should be unseen.
6957 Returns the article selected or nil if there are no matching articles."
6961 ((null gnus-newsgroup-data)
6962 (gnus-message 3 "No articles in the group")
6964 ;; Pick the first article.
6965 ((not (or unread undownloaded unseen))
6966 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6967 (gnus-data-number (car gnus-newsgroup-data)))
6968 ;; Find the first unread article.
6970 (let ((data gnus-newsgroup-data))
6972 (let ((num (gnus-data-number (car data))))
6973 (or (memq num gnus-newsgroup-unfetched)
6974 (not (or (and unread
6975 (memq num gnus-newsgroup-unreads))
6977 (memq num gnus-newsgroup-undownloaded))
6979 (memq num gnus-newsgroup-unseen)))))))
6980 (setq data (cdr data)))
6984 (goto-char (gnus-data-pos (car data)))
6985 (gnus-data-number (car data)))
6986 (gnus-message 3 "No more%s articles"
6987 (let* ((r (when unread " unread"))
6988 (d (when undownloaded " undownloaded"))
6989 (s (when unseen " unseen"))
6990 (l (delq nil (list r d s))))
6991 (cond ((= 3 (length l))
6992 (concat r "," d ", or" s))
6994 (concat (car l) ", or" (cadr l)))
7001 (gnus-summary-position-point))))))
7003 (defun gnus-summary-next-subject (n &optional unread dont-display)
7004 "Go to next N'th summary line.
7005 If N is negative, go to the previous N'th subject line.
7006 If UNREAD is non-nil, only unread articles are selected.
7007 The difference between N and the actual number of steps taken is
7010 (let ((backward (< n 0))
7014 (gnus-summary-find-prev unread)
7015 (gnus-summary-find-next unread)))
7016 (unless (zerop (setq n (1- n)))
7017 (gnus-summary-show-thread)))
7019 (gnus-message 7 "No more%s articles"
7020 (if unread " unread" "")))
7021 (unless dont-display
7022 (gnus-summary-recenter)
7023 (gnus-summary-position-point))
7026 (defun gnus-summary-next-unread-subject (n)
7027 "Go to next N'th unread summary line."
7029 (gnus-summary-next-subject n t))
7031 (defun gnus-summary-prev-subject (n &optional unread)
7032 "Go to previous N'th summary line.
7033 If optional argument UNREAD is non-nil, only unread article is selected."
7035 (gnus-summary-next-subject (- n) unread))
7037 (defun gnus-summary-prev-unread-subject (n)
7038 "Go to previous N'th unread summary line."
7040 (gnus-summary-next-subject (- n) t))
7042 (defun gnus-summary-goto-subjects (articles)
7043 "Insert the subject header for ARTICLES in the current buffer."
7045 (dolist (article articles)
7046 (gnus-summary-goto-subject article t)))
7047 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7048 (gnus-summary-position-point))
7050 (defun gnus-summary-goto-subject (article &optional force silent)
7051 "Go the subject line of ARTICLE.
7052 If FORCE, also allow jumping to articles not currently shown."
7053 (interactive "nArticle number: ")
7054 (unless (numberp article)
7055 (error "Article %s is not a number" article))
7057 (data (gnus-data-find article)))
7058 ;; We read in the article if we have to.
7061 (gnus-summary-insert-subject
7063 (if (or (numberp force) (vectorp force)) force)
7065 (setq data (gnus-data-find article)))
7070 (gnus-message 3 "Can't find article %d" article))
7072 (let ((pt (gnus-data-pos data)))
7074 (gnus-summary-set-article-display-arrow pt))
7075 (gnus-summary-position-point)
7078 ;; Walking around summary lines with displaying articles.
7080 (defun gnus-summary-expand-window (&optional arg)
7081 "Make the summary buffer take up the entire Emacs frame.
7082 Given a prefix, will force an `article' buffer configuration."
7085 (gnus-configure-windows 'article 'force)
7086 (gnus-configure-windows 'summary 'force)))
7088 (defun gnus-summary-display-article (article &optional all-header)
7089 "Display ARTICLE in article buffer."
7090 (when (gnus-buffer-live-p gnus-article-buffer)
7091 (with-current-buffer gnus-article-buffer
7092 (set-buffer-multibyte t)))
7093 (gnus-set-global-variables)
7094 (when (gnus-buffer-live-p gnus-article-buffer)
7095 (with-current-buffer gnus-article-buffer
7096 (setq gnus-article-charset gnus-newsgroup-charset)
7097 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7098 (set-buffer-multibyte t)))
7102 (if gnus-summary-display-article-function
7103 (funcall gnus-summary-display-article-function article all-header)
7104 (gnus-article-prepare article all-header))
7105 (with-current-buffer gnus-article-buffer
7106 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7108 (gnus-run-hooks 'gnus-select-article-hook)
7109 (when (and gnus-current-article
7110 (not (zerop gnus-current-article)))
7111 (gnus-summary-goto-subject gnus-current-article))
7112 (gnus-summary-recenter)
7113 (when (and gnus-use-trees gnus-show-threads)
7114 (gnus-possibly-generate-tree article)
7115 (gnus-highlight-selected-tree article))
7116 ;; Successfully display article.
7117 (gnus-article-set-window-start
7118 (cdr (assq article gnus-newsgroup-bookmarks))))))
7120 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7121 "Select the current article.
7122 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7123 non-nil, the article will be re-fetched even if it already present in
7124 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7126 ;; Make sure we are in the summary buffer to work around bbdb bug.
7127 (unless (eq major-mode 'gnus-summary-mode)
7128 (set-buffer gnus-summary-buffer))
7129 (let ((article (or article (gnus-summary-article-number)))
7130 (all-headers (not (not all-headers))) ;Must be T or NIL.
7131 gnus-summary-display-article-function)
7133 (gnus-summary-article-pseudo-p article)
7134 (error "This is a pseudo-article"))
7136 (set-buffer gnus-summary-buffer)
7137 (if (or (and gnus-single-article-buffer
7138 (or (null gnus-current-article)
7139 (null gnus-article-current)
7140 (null (get-buffer gnus-article-buffer))
7141 (not (eq article (cdr gnus-article-current)))
7142 (not (equal (car gnus-article-current)
7143 gnus-newsgroup-name))))
7144 (and (not gnus-single-article-buffer)
7145 (or (null gnus-current-article)
7146 (not (eq gnus-current-article article))))
7148 ;; The requested article is different from the current article.
7150 (gnus-summary-display-article article all-headers)
7151 (gnus-article-set-window-start
7152 (cdr (assq article gnus-newsgroup-bookmarks)))
7156 (defun gnus-summary-force-verify-and-decrypt ()
7157 "Display buttons for signed/encrypted parts and verify/decrypt them."
7159 (let ((mm-verify-option 'known)
7160 (mm-decrypt-option 'known)
7161 (gnus-article-emulate-mime t)
7162 (mm-fill-flowed nil)
7163 (gnus-buttonized-mime-types (append (list "multipart/signed"
7164 "multipart/encrypted")
7165 gnus-buttonized-mime-types)))
7166 (gnus-summary-select-article nil 'force)))
7168 (defun gnus-summary-set-current-mark (&optional current-mark)
7169 "Obsolete function."
7172 (defun gnus-summary-next-article (&optional unread subject backward push)
7173 "Select the next article.
7174 If UNREAD, only unread articles are selected.
7175 If SUBJECT, only articles with SUBJECT are selected.
7176 If BACKWARD, the previous article is selected instead of the next."
7179 ;; Is there such an article?
7180 ((and (gnus-summary-search-forward unread subject backward)
7181 (or (gnus-summary-display-article (gnus-summary-article-number))
7182 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7183 (gnus-summary-position-point))
7184 ;; If not, we try the first unread, if that is wanted.
7186 gnus-auto-select-same
7187 (gnus-summary-first-unread-article))
7188 (gnus-summary-position-point)
7189 (gnus-message 6 "Wrapped"))
7190 ;; Try to get next/previous article not displayed in this group.
7191 ((and gnus-auto-extend-newsgroup
7192 (not unread) (not subject))
7193 (gnus-summary-goto-article
7194 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7195 nil (count-lines (point-min) (point))))
7196 ;; Go to next/previous group.
7198 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7199 (gnus-summary-jump-to-group gnus-newsgroup-name))
7200 (let ((cmd last-command-char)
7202 (with-current-buffer gnus-group-buffer
7205 (if (eq gnus-keep-same-level 'best)
7206 (gnus-summary-best-group gnus-newsgroup-name)
7207 (gnus-summary-search-group backward gnus-keep-same-level))))
7208 ;; For some reason, the group window gets selected. We change
7210 (select-window (get-buffer-window (current-buffer)))
7211 ;; Select next unread newsgroup automagically.
7213 ((or (not gnus-auto-select-next)
7215 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7216 ((or (eq gnus-auto-select-next 'quietly)
7217 (and (eq gnus-auto-select-next 'slightly-quietly)
7219 (and (eq gnus-auto-select-next 'almost-quietly)
7220 (gnus-summary-last-article-p)))
7222 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7224 (gnus-message 7 "No more%s articles (%s)..."
7225 (if unread " unread" "")
7226 (if group (concat "selecting " group)
7228 (gnus-summary-next-group nil group backward)))
7230 (when (gnus-key-press-event-p last-input-event)
7231 (gnus-summary-walk-group-buffer
7232 gnus-newsgroup-name cmd unread backward point))))))))
7234 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7235 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7236 (?\C-p (gnus-group-prev-unread-group 1))))
7237 (cursor-in-echo-area t)
7238 keve key group ended prompt)
7240 (set-buffer gnus-group-buffer)
7243 (if (eq gnus-keep-same-level 'best)
7244 (gnus-summary-best-group gnus-newsgroup-name)
7245 (gnus-summary-search-group backward gnus-keep-same-level))))
7249 "No more%s articles%s " (if unread " unread" "")
7251 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7252 (format " (Type %s for %s [%s])"
7253 (single-key-description cmd) group
7254 (gnus-group-unread group))
7255 (format " (Type %s to exit %s)"
7256 (single-key-description cmd)
7257 gnus-newsgroup-name))))
7258 ;; Confirm auto selection.
7259 (setq key (car (setq keve (gnus-read-event-char prompt)))
7262 ((assq key keystrokes)
7263 (let ((obuf (current-buffer)))
7264 (switch-to-buffer gnus-group-buffer)
7266 (gnus-group-jump-to-group group))
7267 (eval (cadr (assq key keystrokes)))
7268 (setq group (gnus-group-group-name))
7269 (switch-to-buffer obuf))
7273 (gnus-ephemeral-group-p gnus-newsgroup-name))
7275 (gnus-summary-next-group nil group backward)))
7277 (push (cdr keve) unread-command-events))))))
7279 (defun gnus-summary-next-unread-article ()
7280 "Select unread article after current one."
7282 (gnus-summary-next-article
7283 (or (not (eq gnus-summary-goto-unread 'never))
7284 (gnus-summary-last-article-p (gnus-summary-article-number)))
7285 (and gnus-auto-select-same
7286 (gnus-summary-article-subject))))
7288 (defun gnus-summary-prev-article (&optional unread subject)
7289 "Select the article after the current one.
7290 If UNREAD is non-nil, only unread articles are selected."
7292 (gnus-summary-next-article unread subject t))
7294 (defun gnus-summary-prev-unread-article ()
7295 "Select unread article before current one."
7297 (gnus-summary-prev-article
7298 (or (not (eq gnus-summary-goto-unread 'never))
7299 (gnus-summary-first-article-p (gnus-summary-article-number)))
7300 (and gnus-auto-select-same
7301 (gnus-summary-article-subject))))
7303 (defun gnus-summary-next-page (&optional lines circular stop)
7304 "Show next page of the selected article.
7305 If at the end of the current article, select the next article.
7306 LINES says how many lines should be scrolled up.
7308 If CIRCULAR is non-nil, go to the start of the article instead of
7309 selecting the next article when reaching the end of the current
7312 If STOP is non-nil, just stop when reaching the end of the message.
7314 Also see the variable `gnus-article-skip-boring'."
7316 (setq gnus-summary-buffer (current-buffer))
7317 (gnus-set-global-variables)
7318 (let ((article (gnus-summary-article-number))
7319 (article-window (get-buffer-window gnus-article-buffer t))
7321 ;; If the buffer is empty, we have no article.
7323 (error "No article to select"))
7324 (gnus-configure-windows 'article)
7325 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7326 (if (and (eq gnus-summary-goto-unread 'never)
7327 (not (gnus-summary-last-article-p article)))
7328 (gnus-summary-next-article)
7329 (gnus-summary-next-unread-article))
7330 (if (or (null gnus-current-article)
7331 (null gnus-article-current)
7332 (/= article (cdr gnus-article-current))
7333 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7334 ;; Selected subject is different from current article's.
7335 (gnus-summary-display-article article)
7336 (when article-window
7337 (gnus-eval-in-buffer-window gnus-article-buffer
7338 (setq endp (or (gnus-article-next-page lines)
7339 (gnus-article-only-boring-p))))
7342 (gnus-message 3 "End of message"))
7344 (gnus-summary-beginning-of-article))
7346 (gnus-message 3 "End of message"))
7348 (if (and (eq gnus-summary-goto-unread 'never)
7349 (not (gnus-summary-last-article-p article)))
7350 (gnus-summary-next-article)
7351 (gnus-summary-next-unread-article))))))))
7352 (gnus-summary-recenter)
7353 (gnus-summary-position-point)))
7355 (defun gnus-summary-prev-page (&optional lines move)
7356 "Show previous page of selected article.
7357 Argument LINES specifies lines to be scrolled down.
7358 If MOVE, move to the previous unread article if point is at
7359 the beginning of the buffer."
7361 (let ((article (gnus-summary-article-number))
7362 (article-window (get-buffer-window gnus-article-buffer t))
7364 (gnus-configure-windows 'article)
7365 (if (or (null gnus-current-article)
7366 (null gnus-article-current)
7367 (/= article (cdr gnus-article-current))
7368 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7369 ;; Selected subject is different from current article's.
7370 (gnus-summary-display-article article)
7371 (gnus-summary-recenter)
7372 (when article-window
7373 (gnus-eval-in-buffer-window gnus-article-buffer
7374 (setq endp (gnus-article-prev-page lines)))
7375 (when (and move endp)
7377 (gnus-message 3 "Beginning of message"))
7379 (if (and (eq gnus-summary-goto-unread 'never)
7380 (not (gnus-summary-first-article-p article)))
7381 (gnus-summary-prev-article)
7382 (gnus-summary-prev-unread-article))))))))
7383 (gnus-summary-position-point))
7385 (defun gnus-summary-prev-page-or-article (&optional lines)
7386 "Show previous page of selected article.
7387 Argument LINES specifies lines to be scrolled down.
7388 If at the beginning of the article, go to the next article."
7390 (gnus-summary-prev-page lines t))
7392 (defun gnus-summary-scroll-up (lines)
7393 "Scroll up (or down) one line current article.
7394 Argument LINES specifies lines to be scrolled up (or down if negative)."
7396 (gnus-configure-windows 'article)
7397 (gnus-summary-show-thread)
7398 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7399 (gnus-eval-in-buffer-window gnus-article-buffer
7401 (when (gnus-article-next-page lines)
7402 (gnus-message 3 "End of message")))
7404 (gnus-article-prev-page (- lines))))))
7405 (gnus-summary-recenter)
7406 (gnus-summary-position-point))
7408 (defun gnus-summary-scroll-down (lines)
7409 "Scroll down (or up) one line current article.
7410 Argument LINES specifies lines to be scrolled down (or up if negative)."
7412 (gnus-summary-scroll-up (- lines)))
7414 (defun gnus-summary-next-same-subject ()
7415 "Select next article which has the same subject as current one."
7417 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7419 (defun gnus-summary-prev-same-subject ()
7420 "Select previous article which has the same subject as current one."
7422 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7424 (defun gnus-summary-next-unread-same-subject ()
7425 "Select next unread article which has the same subject as current one."
7427 (gnus-summary-next-article t (gnus-summary-article-subject)))
7429 (defun gnus-summary-prev-unread-same-subject ()
7430 "Select previous unread article which has the same subject as current one."
7432 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7434 (defun gnus-summary-first-unread-article ()
7435 "Select the first unread article.
7436 Return nil if there are no unread articles."
7439 (when (gnus-summary-first-subject t)
7440 (gnus-summary-show-thread)
7441 (gnus-summary-first-subject t)
7442 (gnus-summary-display-article (gnus-summary-article-number)))
7443 (gnus-summary-position-point)))
7445 (defun gnus-summary-first-unread-subject ()
7446 "Place the point on the subject line of the first unread article.
7447 Return nil if there are no unread articles."
7450 (when (gnus-summary-first-subject t)
7451 (gnus-summary-show-thread)
7452 (gnus-summary-first-subject t))
7453 (gnus-summary-position-point)))
7455 (defun gnus-summary-first-unseen-subject ()
7456 "Place the point on the subject line of the first unseen article.
7457 Return nil if there are no unseen articles."
7460 (when (gnus-summary-first-subject nil nil t)
7461 (gnus-summary-show-thread)
7462 (gnus-summary-first-subject nil nil t))
7463 (gnus-summary-position-point)))
7465 (defun gnus-summary-first-unseen-or-unread-subject ()
7466 "Place the point on the subject line of the first unseen article or,
7467 if all article have been seen, on the subject line of the first unread
7471 (unless (when (gnus-summary-first-subject nil nil t)
7472 (gnus-summary-show-thread)
7473 (gnus-summary-first-subject nil nil t))
7474 (when (gnus-summary-first-subject t)
7475 (gnus-summary-show-thread)
7476 (gnus-summary-first-subject t)))
7477 (gnus-summary-position-point)))
7479 (defun gnus-summary-first-article ()
7480 "Select the first article.
7481 Return nil if there are no articles."
7484 (when (gnus-summary-first-subject)
7485 (gnus-summary-show-thread)
7486 (gnus-summary-first-subject)
7487 (gnus-summary-display-article (gnus-summary-article-number)))
7488 (gnus-summary-position-point)))
7490 (defun gnus-summary-best-unread-article (&optional arg)
7491 "Select the unread article with the highest score.
7492 If given a prefix argument, select the next unread article that has a
7493 score higher than the default score."
7495 (let ((article (if arg
7496 (gnus-summary-better-unread-subject)
7497 (gnus-summary-best-unread-subject))))
7499 (gnus-summary-goto-article article)
7500 (error "No unread articles"))))
7502 (defun gnus-summary-best-unread-subject ()
7503 "Select the unread subject with the highest score."
7505 (let ((best -1000000)
7506 (data gnus-newsgroup-data)
7509 (and (gnus-data-unread-p (car data))
7511 (gnus-summary-article-score (gnus-data-number (car data))))
7514 article (gnus-data-number (car data))))
7515 (setq data (cdr data)))
7517 (gnus-summary-goto-subject article))
7518 (gnus-summary-position-point)
7521 (defun gnus-summary-better-unread-subject ()
7522 "Select the first unread subject that has a score over the default score."
7524 (let ((data gnus-newsgroup-data)
7526 (while (and (setq article (gnus-data-number (car data)))
7527 (or (gnus-data-read-p (car data))
7528 (not (> (gnus-summary-article-score article)
7529 gnus-summary-default-score))))
7530 (setq data (cdr data)))
7532 (gnus-summary-goto-subject article))
7533 (gnus-summary-position-point)
7536 (defun gnus-summary-last-subject ()
7537 "Go to the last displayed subject line in the group."
7538 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7540 (gnus-summary-goto-subject article))))
7542 (defun gnus-summary-goto-article (article &optional all-headers force)
7543 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7544 If ALL-HEADERS is non-nil, no header lines are hidden.
7545 If FORCE, go to the article even if it isn't displayed. If FORCE
7546 is a number, it is the line the article is to be displayed on."
7550 "Article number or Message-ID: "
7551 (mapcar (lambda (number) (list (int-to-string number)))
7552 gnus-newsgroup-limit))
7556 (if (and (stringp article)
7557 (string-match "@\\|%40" article))
7558 (gnus-summary-refer-article article)
7559 (when (stringp article)
7560 (setq article (string-to-number article)))
7561 (if (gnus-summary-goto-subject article force)
7562 (gnus-summary-display-article article all-headers)
7563 (gnus-message 4 "Couldn't go to article %s" article) nil))
7564 (gnus-summary-position-point)))
7566 (defun gnus-summary-goto-last-article ()
7567 "Go to the previously read article."
7570 (when gnus-last-article
7571 (gnus-summary-goto-article gnus-last-article nil t))
7572 (gnus-summary-position-point)))
7574 (defun gnus-summary-pop-article (number)
7575 "Pop one article off the history and go to the previous.
7576 NUMBER articles will be popped off."
7579 (setq gnus-newsgroup-history
7580 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7582 (gnus-summary-goto-article (car to) nil t)
7583 (error "Article history empty")))
7584 (gnus-summary-position-point))
7586 ;; Summary commands and functions for limiting the summary buffer.
7588 (defun gnus-summary-limit-to-articles (n)
7589 "Limit the summary buffer to the next N articles.
7590 If not given a prefix, use the process marked articles instead."
7593 (let ((articles (gnus-summary-work-articles n)))
7594 (setq gnus-newsgroup-processable nil)
7595 (gnus-summary-limit articles))
7596 (gnus-summary-position-point)))
7598 (defun gnus-summary-pop-limit (&optional total)
7599 "Restore the previous limit.
7600 If given a prefix, remove all limits."
7603 (setq gnus-newsgroup-limits
7604 (list (mapcar (lambda (h) (mail-header-number h))
7605 gnus-newsgroup-headers))))
7606 (unless gnus-newsgroup-limits
7607 (error "No limit to pop"))
7609 (gnus-summary-limit nil 'pop)
7610 (gnus-summary-position-point)))
7612 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7613 "Limit the summary buffer to articles that have subjects that match a regexp.
7614 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7616 (list (read-string (if current-prefix-arg
7617 "Exclude subject (regexp): "
7618 "Limit to subject (regexp): "))
7619 nil current-prefix-arg))
7621 (setq header "subject"))
7622 (when (not (equal "" subject))
7624 (let ((articles (gnus-summary-find-matching
7625 (or header "subject") subject 'all nil nil
7628 (error "Found no matches for \"%s\"" subject))
7629 (gnus-summary-limit articles))
7630 (gnus-summary-position-point))))
7632 (defun gnus-summary-limit-to-author (from &optional not-matching)
7633 "Limit the summary buffer to articles that have authors that match a regexp.
7634 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7636 (list (read-string (if current-prefix-arg
7637 "Exclude author (regexp): "
7638 "Limit to author (regexp): "))
7639 current-prefix-arg))
7640 (gnus-summary-limit-to-subject from "from" not-matching))
7642 (defun gnus-summary-limit-to-age (age &optional younger-p)
7643 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7644 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7645 articles that are younger than AGE days."
7647 (let ((younger current-prefix-arg)
7650 (while (not days-got)
7651 (setq days (if younger
7652 (read-string "Limit to articles younger than (in days, older when negative): ")
7654 "Limit to articles older than (in days, younger when negative): ")))
7655 (when (> (length days) 0)
7656 (setq days (read days)))
7661 (setq younger (not younger))
7662 (setq days (* days -1))))
7663 (message "Please enter a number.")
7665 (list days younger)))
7667 (let ((data gnus-newsgroup-data)
7668 (cutoff (days-to-time age))
7669 articles d date is-younger)
7670 (while (setq d (pop data))
7671 (when (and (vectorp (gnus-data-header d))
7672 (setq date (mail-header-date (gnus-data-header d))))
7673 (setq is-younger (time-less-p
7674 (time-since (condition-case ()
7681 (push (gnus-data-number d) articles))))
7682 (gnus-summary-limit (nreverse articles)))
7683 (gnus-summary-position-point)))
7685 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7686 "Limit the summary buffer to articles that match an 'extra' header."
7690 (gnus-completing-read-with-default
7691 (symbol-name (car gnus-extra-headers))
7692 (if current-prefix-arg
7693 "Exclude extra header:"
7694 "Limit extra header:")
7696 (cons (symbol-name x) x))
7701 (read-string (format "%s header %s (regexp): "
7702 (if current-prefix-arg "Exclude" "Limit to")
7704 current-prefix-arg)))
7705 (when (not (equal "" regexp))
7707 (let ((articles (gnus-summary-find-matching
7708 (cons 'extra header) regexp 'all nil nil
7711 (error "Found no matches for \"%s\"" regexp))
7712 (gnus-summary-limit articles))
7713 (gnus-summary-position-point))))
7715 (defun gnus-summary-limit-to-display-predicate ()
7716 "Limit the summary buffer to the predicated in the `display' group parameter."
7718 (unless gnus-newsgroup-display
7719 (error "There is no `display' group parameter"))
7721 (dolist (number gnus-newsgroup-articles)
7722 (when (funcall gnus-newsgroup-display)
7723 (push number articles)))
7724 (gnus-summary-limit articles))
7725 (gnus-summary-position-point))
7727 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7729 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7731 (defun gnus-summary-limit-to-unread (&optional all)
7732 "Limit the summary buffer to articles that are not marked as read.
7733 If ALL is non-nil, limit strictly to unread articles."
7736 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7737 (gnus-summary-limit-to-marks
7738 ;; Concat all the marks that say that an article is read and have
7740 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7741 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7742 gnus-low-score-mark gnus-expirable-mark
7743 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7744 gnus-duplicate-mark gnus-souped-mark)
7747 (defun gnus-summary-limit-to-replied (&optional unreplied)
7748 "Limit the summary buffer to replied articles.
7749 If UNREPLIED (the prefix), limit to unreplied articles."
7753 (gnus-set-difference gnus-newsgroup-articles
7754 gnus-newsgroup-replied))
7755 (gnus-summary-limit gnus-newsgroup-replied))
7756 (gnus-summary-position-point))
7758 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7759 (make-obsolete 'gnus-summary-delete-marked-with
7760 'gnus-summary-limit-exclude-marks)
7762 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7763 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7764 If REVERSE, limit the summary buffer to articles that are marked
7765 with MARKS. MARKS can either be a string of marks or a list of marks.
7766 Returns how many articles were removed."
7767 (interactive "sMarks: ")
7768 (gnus-summary-limit-to-marks marks t))
7770 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7771 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7772 If REVERSE (the prefix), limit the summary buffer to articles that are
7773 not marked with MARKS. MARKS can either be a string of marks or a
7775 Returns how many articles were removed."
7776 (interactive "sMarks: \nP")
7778 (let ((data gnus-newsgroup-data)
7779 (marks (if (listp marks) marks
7780 (append marks nil))) ; Transform to list.
7783 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7784 (memq (gnus-data-mark (car data)) marks))
7785 (push (gnus-data-number (car data)) articles))
7786 (setq data (cdr data)))
7787 (gnus-summary-limit articles))
7788 (gnus-summary-position-point)))
7790 (defun gnus-summary-limit-to-score (score)
7791 "Limit to articles with score at or above SCORE."
7792 (interactive "NLimit to articles with score of at least: ")
7793 (let ((data gnus-newsgroup-data)
7796 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7798 (push (gnus-data-number (car data)) articles))
7799 (setq data (cdr data)))
7801 (gnus-summary-limit articles)
7802 (gnus-summary-position-point))))
7804 (defun gnus-summary-limit-to-unseen ()
7805 "Limit to unseen articles."
7808 (gnus-summary-limit gnus-newsgroup-unseen)
7809 (gnus-summary-position-point)))
7811 (defun gnus-summary-limit-include-thread (id)
7812 "Display all the hidden articles that is in the thread with ID in it.
7813 When called interactively, ID is the Message-ID of the current
7815 (interactive (list (mail-header-id (gnus-summary-article-header))))
7816 (let ((articles (gnus-articles-in-thread
7817 (gnus-id-to-thread (gnus-root-id id)))))
7819 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7820 (gnus-summary-limit-include-matching-articles
7822 (regexp-quote (gnus-simplify-subject-re
7823 (mail-header-subject (gnus-id-to-header id)))))
7824 (gnus-summary-position-point))))
7826 (defun gnus-summary-limit-include-matching-articles (header regexp)
7827 "Display all the hidden articles that have HEADERs that match REGEXP."
7828 (interactive (list (read-string "Match on header: ")
7829 (read-string "Regexp: ")))
7830 (let ((articles (gnus-find-matching-articles header regexp)))
7832 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7833 (gnus-summary-position-point))))
7835 (defun gnus-summary-insert-dormant-articles ()
7836 "Insert all the dormant articles for this group into the current buffer."
7838 (let ((gnus-verbose (max 6 gnus-verbose)))
7839 (if (not gnus-newsgroup-dormant)
7840 (gnus-message 3 "No cached articles for this group")
7841 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7843 (defun gnus-summary-limit-include-dormant ()
7844 "Display all the hidden articles that are marked as dormant.
7845 Note that this command only works on a subset of the articles currently
7846 fetched for this group."
7848 (unless gnus-newsgroup-dormant
7849 (error "There are no dormant articles in this group"))
7851 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7852 (gnus-summary-position-point)))
7854 (defun gnus-summary-limit-exclude-dormant ()
7855 "Hide all dormant articles."
7858 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7859 (gnus-summary-position-point)))
7861 (defun gnus-summary-limit-exclude-childless-dormant ()
7862 "Hide all dormant articles that have no children."
7864 (let ((data (gnus-data-list t))
7865 articles d children)
7866 ;; Find all articles that are either not dormant or have
7868 (while (setq d (pop data))
7869 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7871 (gnus-article-children (gnus-data-number d)))
7874 (when (memq (car children) articles)
7879 (push (gnus-data-number d) articles)))
7882 (gnus-summary-limit articles)
7883 (gnus-summary-position-point))))
7885 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7886 "Mark all unread excluded articles as read.
7887 If ALL, mark even excluded ticked and dormants as read."
7889 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7890 (let ((articles (gnus-sorted-ndifference
7892 (mapcar (lambda (h) (mail-header-number h))
7893 gnus-newsgroup-headers)
7895 gnus-newsgroup-limit))
7897 (setq gnus-newsgroup-unreads
7898 (gnus-sorted-intersection gnus-newsgroup-unreads
7899 gnus-newsgroup-limit))
7901 (setq gnus-newsgroup-dormant nil
7902 gnus-newsgroup-marked nil
7903 gnus-newsgroup-reads
7905 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7906 gnus-newsgroup-reads))
7907 (while (setq article (pop articles))
7908 (unless (or (memq article gnus-newsgroup-dormant)
7909 (memq article gnus-newsgroup-marked))
7910 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7912 (defun gnus-summary-limit (articles &optional pop)
7914 ;; We pop the previous limit off the stack and use that.
7915 (setq articles (car gnus-newsgroup-limits)
7916 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7917 ;; We use the new limit, so we push the old limit on the stack.
7918 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7920 (setq gnus-newsgroup-limit articles)
7921 (let ((total (length gnus-newsgroup-data))
7922 (data (gnus-data-find-list (gnus-summary-article-number)))
7923 (gnus-summary-mark-below nil) ; Inhibit this.
7925 ;; This will do all the work of generating the new summary buffer
7926 ;; according to the new limit.
7927 (gnus-summary-prepare)
7928 ;; Hide any threads, possibly.
7929 (gnus-summary-maybe-hide-threads)
7930 ;; Try to return to the article you were at, or one in the
7933 ;; We try to find some article after the current one.
7935 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7938 (setq data (cdr data))))
7940 ;; If there is no data, that means that we were after the last
7941 ;; article. The same goes when we can't find any articles
7942 ;; after the current one.
7943 (goto-char (point-max))
7944 (gnus-summary-find-prev))
7945 (gnus-set-mode-line 'summary)
7946 ;; We return how many articles were removed from the summary
7947 ;; buffer as a result of the new limit.
7948 (- total (length gnus-newsgroup-data))))
7950 (defsubst gnus-invisible-cut-children (threads)
7953 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7958 (defsubst gnus-cut-thread (thread)
7959 "Go forwards in the thread until we find an article that we want to display."
7960 (when (or (eq gnus-fetch-old-headers 'some)
7961 (eq gnus-fetch-old-headers 'invisible)
7962 (numberp gnus-fetch-old-headers)
7963 (eq gnus-build-sparse-threads 'some)
7964 (eq gnus-build-sparse-threads 'more))
7965 ;; Deal with old-fetched headers and sparse threads.
7969 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7970 (gnus-summary-article-ancient-p
7971 (mail-header-number (car thread))))
7972 (if (or (<= (length (cdr thread)) 1)
7973 (eq gnus-fetch-old-headers 'invisible))
7974 (setq gnus-newsgroup-limit
7975 (delq (mail-header-number (car thread))
7976 gnus-newsgroup-limit)
7977 thread (cadr thread))
7978 (when (gnus-invisible-cut-children (cdr thread))
7979 (let ((th (cdr thread)))
7981 (if (memq (mail-header-number (caar th))
7982 gnus-newsgroup-limit)
7983 (setq thread (car th)
7985 (setq th (cdr th))))))))))
7988 (defun gnus-cut-threads (threads)
7989 "Cut off all uninteresting articles from the beginning of THREADS."
7990 (when (or (eq gnus-fetch-old-headers 'some)
7991 (eq gnus-fetch-old-headers 'invisible)
7992 (numberp gnus-fetch-old-headers)
7993 (eq gnus-build-sparse-threads 'some)
7994 (eq gnus-build-sparse-threads 'more))
7997 (setcar th (gnus-cut-thread (car th)))
7998 (setq th (cdr th)))))
7999 ;; Remove nixed out threads.
8002 (defun gnus-summary-initial-limit (&optional show-if-empty)
8003 "Figure out what the initial limit is supposed to be on group entry.
8004 This entails weeding out unwanted dormants, low-scored articles,
8005 fetch-old-headers verbiage, and so on."
8006 ;; Most groups have nothing to remove.
8007 (if (or gnus-inhibit-limiting
8008 (and (null gnus-newsgroup-dormant)
8009 (eq gnus-newsgroup-display 'gnus-not-ignore)
8010 (not (eq gnus-fetch-old-headers 'some))
8011 (not (numberp gnus-fetch-old-headers))
8012 (not (eq gnus-fetch-old-headers 'invisible))
8013 (null gnus-summary-expunge-below)
8014 (not (eq gnus-build-sparse-threads 'some))
8015 (not (eq gnus-build-sparse-threads 'more))
8016 (null gnus-thread-expunge-below)
8017 (not gnus-use-nocem)))
8019 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8020 (setq gnus-newsgroup-limit nil)
8023 (unless (car (symbol-value node))
8024 ;; These threads have no parents -- they are roots.
8025 (let ((nodes (cdr (symbol-value node)))
8028 (if (and gnus-thread-expunge-below
8029 (< (gnus-thread-total-score (car nodes))
8030 gnus-thread-expunge-below))
8031 (gnus-expunge-thread (pop nodes))
8032 (setq thread (pop nodes))
8033 (gnus-summary-limit-children thread))))))
8034 gnus-newsgroup-dependencies)
8035 ;; If this limitation resulted in an empty group, we might
8036 ;; pop the previous limit and use it instead.
8037 (when (and (not gnus-newsgroup-limit)
8039 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8040 gnus-newsgroup-limit))
8042 (defun gnus-summary-limit-children (thread)
8043 "Return 1 if this subthread is visible and 0 if it is not."
8044 ;; First we get the number of visible children to this thread. This
8045 ;; is done by recursing down the thread using this function, so this
8046 ;; will really go down to a leaf article first, before slowly
8047 ;; working its way up towards the root.
8049 (let* ((max-lisp-eval-depth 5000)
8052 (apply '+ (mapcar 'gnus-summary-limit-children
8055 (number (mail-header-number (car thread)))
8058 (not (memq number gnus-newsgroup-marked))
8060 ;; If this article is dormant and has absolutely no visible
8061 ;; children, then this article isn't visible.
8062 (and (memq number gnus-newsgroup-dormant)
8064 ;; If this is "fetch-old-headered" and there is no
8065 ;; visible children, then we don't want this article.
8066 (and (or (eq gnus-fetch-old-headers 'some)
8067 (numberp gnus-fetch-old-headers))
8068 (gnus-summary-article-ancient-p number)
8070 ;; If this is "fetch-old-headered" and `invisible', then
8071 ;; we don't want this article.
8072 (and (eq gnus-fetch-old-headers 'invisible)
8073 (gnus-summary-article-ancient-p number))
8074 ;; If this is a sparsely inserted article with no children,
8075 ;; we don't want it.
8076 (and (eq gnus-build-sparse-threads 'some)
8077 (gnus-summary-article-sparse-p number)
8079 ;; If we use expunging, and this article is really
8080 ;; low-scored, then we don't want this article.
8081 (when (and gnus-summary-expunge-below
8083 (or (cdr (assq number gnus-newsgroup-scored))
8084 gnus-summary-default-score))
8085 gnus-summary-expunge-below))
8086 ;; We increase the expunge-tally here, but that has
8087 ;; nothing to do with the limits, really.
8088 (incf gnus-newsgroup-expunged-tally)
8089 ;; We also mark as read here, if that's wanted.
8090 (when (and gnus-summary-mark-below
8091 (< score gnus-summary-mark-below))
8092 (setq gnus-newsgroup-unreads
8093 (delq number gnus-newsgroup-unreads))
8094 (if gnus-newsgroup-auto-expire
8095 (push number gnus-newsgroup-expirable)
8096 (push (cons number gnus-low-score-mark)
8097 gnus-newsgroup-reads)))
8099 ;; Do the `display' group parameter.
8100 (and gnus-newsgroup-display
8101 (not (funcall gnus-newsgroup-display)))
8102 ;; Check NoCeM things.
8103 (when (and gnus-use-nocem
8104 (gnus-nocem-unwanted-article-p
8105 (mail-header-id (car thread))))
8106 (setq gnus-newsgroup-unreads
8107 (delq number gnus-newsgroup-unreads))
8109 ;; Nope, invisible article.
8111 ;; Ok, this article is to be visible, so we add it to the limit
8113 (push number gnus-newsgroup-limit)
8116 (defun gnus-expunge-thread (thread)
8117 "Mark all articles in THREAD as read."
8118 (let* ((number (mail-header-number (car thread))))
8119 (incf gnus-newsgroup-expunged-tally)
8120 ;; We also mark as read here, if that's wanted.
8121 (setq gnus-newsgroup-unreads
8122 (delq number gnus-newsgroup-unreads))
8123 (if gnus-newsgroup-auto-expire
8124 (push number gnus-newsgroup-expirable)
8125 (push (cons number gnus-low-score-mark)
8126 gnus-newsgroup-reads)))
8127 ;; Go recursively through all subthreads.
8128 (mapcar 'gnus-expunge-thread (cdr thread)))
8130 ;; Summary article oriented commands
8132 (defun gnus-summary-refer-parent-article (n)
8133 "Refer parent article N times.
8134 If N is negative, go to ancestor -N instead.
8135 The difference between N and the number of articles fetched is returned."
8139 (when (not (natnump n))
8144 (setq header (gnus-summary-article-header))
8145 (if (and (eq (mail-header-number header)
8146 (cdr gnus-article-current))
8147 (equal gnus-newsgroup-name
8148 (car gnus-article-current)))
8149 ;; If we try to find the parent of the currently
8150 ;; displayed article, then we take a look at the actual
8151 ;; References header, since this is slightly more
8152 ;; reliable than the References field we got from the
8155 (set-buffer gnus-original-article-buffer)
8156 (nnheader-narrow-to-headers)
8157 (unless (setq ref (message-fetch-field "references"))
8158 (when (setq ref (message-fetch-field "in-reply-to"))
8159 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8162 ;; It's not the current article, so we take a bet on
8163 ;; the value we got from the server.
8164 (mail-header-references header)))
8166 (not (equal ref "")))
8167 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8168 (gnus-message 1 "Couldn't find parent"))
8169 (gnus-message 1 "No references in article %d"
8170 (gnus-summary-article-number))
8173 (gnus-summary-position-point)
8176 (defun gnus-summary-refer-references ()
8177 "Fetch all articles mentioned in the References header.
8178 Return the number of articles fetched."
8180 (let ((ref (mail-header-references (gnus-summary-article-header)))
8181 (current (gnus-summary-article-number))
8185 (error "No References in the current article")
8186 ;; For each Message-ID in the References header...
8187 (while (string-match "<[^>]*>" ref)
8189 ;; ... fetch that article.
8190 (gnus-summary-refer-article
8191 (prog1 (match-string 0 ref)
8192 (setq ref (substring ref (match-end 0))))))
8193 (gnus-summary-goto-subject current)
8194 (gnus-summary-position-point)
8197 (defun gnus-summary-refer-thread (&optional limit)
8198 "Fetch all articles in the current thread.
8199 If LIMIT (the numerical prefix), fetch that many old headers instead
8200 of what's specified by the `gnus-refer-thread-limit' variable."
8202 (let ((id (mail-header-id (gnus-summary-article-header)))
8203 (limit (if limit (prefix-numeric-value limit)
8204 gnus-refer-thread-limit)))
8205 (unless (eq gnus-fetch-old-headers 'invisible)
8206 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8207 ;; Retrieve the headers and read them in.
8208 (if (eq (if (numberp limit)
8209 (gnus-retrieve-headers
8211 (+ (mail-header-number
8212 (gnus-summary-article-header))
8214 gnus-newsgroup-end))
8215 gnus-newsgroup-name (* limit 2))
8216 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8218 (gnus-retrieve-headers (list gnus-newsgroup-end)
8219 gnus-newsgroup-name limit))
8221 (gnus-build-all-threads)
8222 (error "Can't fetch thread from back ends that don't support NOV"))
8223 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8224 (gnus-summary-limit-include-thread id)))
8226 (defun gnus-summary-refer-article (message-id)
8227 "Fetch an article specified by MESSAGE-ID."
8228 (interactive "sMessage-ID: ")
8229 (when (and (stringp message-id)
8230 (not (zerop (length message-id))))
8231 (setq message-id (gnus-replace-in-string message-id " " ""))
8232 ;; Construct the correct Message-ID if necessary.
8233 ;; Suggested by tale@pawl.rpi.edu.
8234 (unless (string-match "^<" message-id)
8235 (setq message-id (concat "<" message-id)))
8236 (unless (string-match ">$" message-id)
8237 (setq message-id (concat message-id ">")))
8238 ;; People often post MIDs from URLs, so unhex it:
8239 (unless (string-match "@" message-id)
8240 (setq message-id (gnus-url-unhex-string message-id)))
8241 (let* ((header (gnus-id-to-header message-id))
8243 (gnus-summary-article-sparse-p
8244 (mail-header-number header))
8245 (memq (mail-header-number header)
8246 gnus-newsgroup-limit)))
8249 ;; If the article is present in the buffer we just go to it.
8251 (or (not (gnus-summary-article-sparse-p
8252 (mail-header-number header)))
8255 (gnus-summary-goto-article
8256 (mail-header-number header) nil t)
8258 (gnus-summary-update-article (mail-header-number header)))))
8260 ;; We fetch the article.
8262 (dolist (gnus-override-method (gnus-refer-article-methods))
8263 (when (and (gnus-check-server gnus-override-method)
8264 ;; Fetch the header,
8265 (setq number (gnus-summary-insert-subject message-id)))
8266 ;; and display the article.
8267 (gnus-summary-select-article nil nil nil number)
8269 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8271 (defun gnus-refer-article-methods ()
8272 "Return a list of referable methods."
8274 ;; No method, so we default to current and native.
8275 ((null gnus-refer-article-method)
8276 (list gnus-current-select-method gnus-select-method))
8278 ((eq 'current gnus-refer-article-method)
8279 (list gnus-current-select-method))
8280 ;; List of select methods.
8281 ((not (and (symbolp (car gnus-refer-article-method))
8282 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8284 (dolist (method gnus-refer-article-method)
8285 (push (if (eq 'current method)
8286 gnus-current-select-method
8290 ;; One single select method.
8292 (list gnus-refer-article-method))))
8294 (defun gnus-summary-edit-parameters ()
8295 "Edit the group parameters of the current group."
8297 (gnus-group-edit-group gnus-newsgroup-name 'params))
8299 (defun gnus-summary-customize-parameters ()
8300 "Customize the group parameters of the current group."
8302 (gnus-group-customize gnus-newsgroup-name))
8304 (defun gnus-summary-enter-digest-group (&optional force)
8305 "Enter an nndoc group based on the current article.
8306 If FORCE, force a digest interpretation. If not, try
8307 to guess what the document format is."
8309 (let ((conf gnus-current-window-configuration))
8310 (save-window-excursion
8312 (let (gnus-article-prepare-hook
8313 gnus-display-mime-function
8315 (gnus-summary-select-article))))
8316 (setq gnus-current-window-configuration conf)
8317 (let* ((name (format "%s-%d"
8318 (gnus-group-prefixed-name
8319 gnus-newsgroup-name (list 'nndoc ""))
8320 (with-current-buffer gnus-summary-buffer
8321 gnus-current-article)))
8322 (ogroup gnus-newsgroup-name)
8323 (params (append (gnus-info-params (gnus-get-info ogroup))
8324 (list (cons 'to-group ogroup))
8325 (list (cons 'parent-group ogroup))
8326 (list (cons 'save-article-group ogroup))))
8327 (case-fold-search t)
8328 (buf (current-buffer))
8331 (set-buffer gnus-original-article-buffer)
8332 ;; Have the digest group inherit the main mail address of
8333 ;; the parent article.
8334 (when (setq to-address (or (gnus-fetch-field "reply-to")
8335 (gnus-fetch-field "from")))
8336 (setq params (append
8337 (list (cons 'to-address
8338 (funcall gnus-decode-encoded-word-function
8340 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8341 (insert-buffer-substring gnus-original-article-buffer)
8342 ;; Remove lines that may lead nndoc to misinterpret the
8345 (goto-char (point-min))
8346 (or (search-forward "\n\n" nil t) (point)))
8347 (goto-char (point-min))
8348 (delete-matching-lines "^Path:\\|^From ")
8351 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8352 (gnus-newsgroup-ephemeral-ignored-charsets
8353 gnus-newsgroup-ignored-charsets))
8354 (gnus-group-read-ephemeral-group
8355 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8357 ,(if force 'mbox 'guess)))
8359 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8361 ;; Make all postings to this group go to the parent group.
8362 (nconc (gnus-info-params (gnus-get-info name))
8364 ;; Couldn't select this doc group.
8365 (switch-to-buffer buf)
8366 (gnus-set-global-variables)
8367 (gnus-configure-windows 'summary)
8368 (gnus-message 3 "Article couldn't be entered?"))
8369 (kill-buffer dig)))))
8371 (defun gnus-summary-read-document (n)
8372 "Open a new group based on the current article(s).
8373 This will allow you to read digests and other similar
8374 documents as newsgroups.
8375 Obeys the standard process/prefix convention."
8377 (let* ((articles (gnus-summary-work-articles n))
8378 (ogroup gnus-newsgroup-name)
8379 (params (append (gnus-info-params (gnus-get-info ogroup))
8380 (list (cons 'to-group ogroup))))
8381 article group egroup groups vgroup)
8382 (while (setq article (pop articles))
8383 (setq group (format "%s-%d" gnus-newsgroup-name article))
8384 (gnus-summary-remove-process-mark article)
8385 (when (gnus-summary-display-article article)
8388 (insert-buffer-substring gnus-original-article-buffer)
8389 ;; Remove some headers that may lead nndoc to make
8391 (message-narrow-to-head)
8392 (goto-char (point-min))
8393 (delete-matching-lines "^Path:\\|^From ")
8396 (gnus-group-read-ephemeral-group
8397 group `(nndoc ,group (nndoc-address ,(current-buffer))
8398 (nndoc-article-type guess))
8401 ;; Make all postings to this group go to the parent group.
8402 (nconc (gnus-info-params (gnus-get-info egroup))
8404 (push egroup groups))
8405 ;; Couldn't select this doc group.
8406 (gnus-error 3 "Article couldn't be entered"))))))
8407 ;; Now we have selected all the documents.
8410 (error "None of the articles could be interpreted as documents"))
8411 ((gnus-group-read-ephemeral-group
8412 (setq vgroup (format
8413 "nnvirtual:%s-%s" gnus-newsgroup-name
8414 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8415 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8417 (cons (current-buffer) 'summary)))
8419 (error "Couldn't select virtual nndoc group")))))
8421 (defun gnus-summary-isearch-article (&optional regexp-p)
8422 "Do incremental search forward on the current article.
8423 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8425 (let* ((gnus-inhibit-treatment t)
8426 (old (gnus-summary-select-article)))
8427 (gnus-configure-windows 'article)
8428 (gnus-eval-in-buffer-window gnus-article-buffer
8432 (gnus-article-show-all-headers))
8433 (goto-char (point-min))
8434 (isearch-forward regexp-p)))))
8436 (defun gnus-summary-search-article-forward (regexp &optional backward)
8437 "Search for an article containing REGEXP forward.
8438 If BACKWARD, search backward instead."
8441 (format "Search article %s (regexp%s): "
8442 (if current-prefix-arg "backward" "forward")
8443 (if gnus-last-search-regexp
8444 (concat ", default " gnus-last-search-regexp)
8446 current-prefix-arg))
8447 (if (string-equal regexp "")
8448 (setq regexp (or gnus-last-search-regexp ""))
8449 (setq gnus-last-search-regexp regexp)
8450 (setq gnus-article-before-search gnus-current-article))
8451 ;; Intentionally set gnus-last-article.
8452 (setq gnus-last-article gnus-article-before-search)
8453 (let ((gnus-last-article gnus-last-article))
8454 (if (gnus-summary-search-article regexp backward)
8455 (gnus-summary-show-thread)
8456 (error "Search failed: \"%s\"" regexp))))
8458 (defun gnus-summary-search-article-backward (regexp)
8459 "Search for an article containing REGEXP backward."
8462 (format "Search article backward (regexp%s): "
8463 (if gnus-last-search-regexp
8464 (concat ", default " gnus-last-search-regexp)
8466 (gnus-summary-search-article-forward regexp 'backward))
8469 (defmacro gnus-summary-search-article-position-point (regexp backward)
8470 "Dehighlight the last matched text and goto the beginning position."
8471 (` (if (and gnus-summary-search-article-matched-data
8472 (let ((text (caddr gnus-summary-search-article-matched-data))
8473 (inhibit-read-only t)
8476 (goto-char (car gnus-summary-search-article-matched-data))
8477 (cadr gnus-summary-search-article-matched-data))
8479 (string-match (, regexp) text)))
8480 (if (, backward) (beginning-of-line) (end-of-line))
8481 (goto-char (if (, backward) (point-max) (point-min))))))
8483 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8484 "Place point where X-Face image is displayed."
8485 (if (featurep 'xemacs)
8486 (` (let ((end (if (search-forward "\n\n" nil t)
8487 (goto-char (1- (point)))
8490 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8491 (unless (and (re-search-forward "^From:" end t)
8492 (setq extent (extent-at (point)))
8493 (extent-begin-glyph extent))
8494 (goto-char (, opoint)))))
8495 (` (let ((end (if (search-forward "\n\n" nil t)
8496 (goto-char (1- (point)))
8498 (start (or (search-backward "\n\n" nil t) (point-min))))
8500 (or (text-property-any start end 'x-face-image t);; x-face-e21
8501 (text-property-any start end 'x-face-mule-bitmap-image t)
8504 (defmacro gnus-summary-search-article-highlight-matched-text
8505 (backward treated x-face)
8506 "Highlight matched text in the function `gnus-summary-search-article'."
8507 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8508 (end (set-marker (make-marker) (match-end 0)))
8509 (inhibit-read-only t)
8513 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8515 (lambda (item) (setq items (delq item items)))
8516 '(gnus-treat-buttonize
8517 gnus-treat-fill-article
8518 gnus-treat-fill-long-lines
8519 gnus-treat-emphasize
8520 gnus-treat-highlight-headers
8521 gnus-treat-highlight-citation
8522 gnus-treat-highlight-signature
8523 gnus-treat-overstrike
8524 gnus-treat-display-x-face
8525 gnus-treat-buttonize-head
8526 gnus-treat-decode-article-as-default-mime-charset))
8527 (static-if (featurep 'xemacs)
8529 (cons '(x-face-mule-delete-x-face-field
8532 (gnus-treat-display-x-face
8533 (when (, x-face) gnus-treat-display-x-face)))
8534 (gnus-article-prepare-mime-display)))
8535 (goto-char (if (, backward) start end))
8537 (gnus-summary-search-article-highlight-goto-x-face (point)))
8538 (setq gnus-summary-search-article-matched-data
8539 (list start end (buffer-substring start end)))
8540 (unless (eq start end);; matched text has been deleted. :-<
8541 (put-text-property start end 'face
8542 (or (find-face 'isearch)
8543 'secondary-selection))))))
8546 (defun gnus-summary-search-article (regexp &optional backward)
8547 "Search for an article containing REGEXP.
8548 Optional argument BACKWARD means do search for backward.
8549 `gnus-select-article-hook' is not called during the search."
8550 ;; We have to require this here to make sure that the following
8551 ;; dynamic binding isn't shadowed by autoloading.
8552 (require 'gnus-async)
8554 (let ((gnus-select-article-hook nil) ;Disable hook.
8555 (gnus-article-prepare-hook nil)
8556 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8557 (gnus-use-article-prefetch nil)
8558 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8559 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8561 (gnus-keep-backlog nil)
8562 (gnus-break-pages nil)
8563 (gnus-summary-display-arrow nil)
8564 (gnus-updated-mode-lines nil)
8565 (gnus-auto-center-summary nil)
8566 (sum (current-buffer))
8569 (gnus-save-hidden-threads
8570 (static-if (featurep 'xemacs)
8571 (let ((gnus-inhibit-treatment t))
8572 (setq treated (eq 'old (gnus-summary-select-article)))
8574 (not (and (gnus-buffer-live-p gnus-article-buffer)
8575 (window-live-p (get-buffer-window
8576 gnus-article-buffer t)))))
8577 (gnus-summary-select-article nil t)
8578 (setq treated nil)))
8579 (let ((gnus-inhibit-treatment t)
8580 (x-face-mule-delete-x-face-field 'never))
8581 (setq treated (eq 'old (gnus-summary-select-article)))
8584 (and (gnus-buffer-live-p gnus-article-buffer)
8585 (window-live-p (get-buffer-window
8586 gnus-article-buffer t))
8587 (or (not (string-match "^\\^X-Face:" regexp))
8588 (with-current-buffer gnus-article-buffer
8589 gnus-summary-search-article-matched-data)))))
8590 (gnus-summary-select-article nil t)
8591 (setq treated nil))))
8592 (set-buffer gnus-article-buffer)
8596 (gnus-article-show-all-headers)
8597 (gnus-summary-search-article-position-point regexp backward))
8598 (goto-char (if backward (point-max) (point-min))))
8600 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8602 (re-search-backward regexp nil t)
8603 (re-search-forward regexp nil t))
8604 ;; We found the regexp.
8606 (gnus-summary-search-article-highlight-matched-text
8607 backward treated (string-match "^\\^X-Face:" regexp))
8610 (/ (- 2 (window-height
8611 (get-buffer-window gnus-article-buffer t)))
8614 (get-buffer-window (current-buffer))
8617 (setq point (point)))
8618 ;; We didn't find it, so we go to the next article.
8621 (while (eq found 'not)
8622 (if (not (if backward (gnus-summary-find-prev)
8623 (gnus-summary-find-next)))
8624 ;; No more articles.
8626 ;; Select the next article and adjust point.
8627 (unless (gnus-summary-article-sparse-p
8628 (gnus-summary-article-number))
8630 (let ((gnus-inhibit-treatment t))
8631 (gnus-summary-select-article))
8633 (set-buffer gnus-article-buffer)
8635 (goto-char (if backward (point-max) (point-min))))))))
8636 (gnus-message 7 ""))
8637 ;; Return whether we found the regexp.
8638 (when (eq found 'found)
8640 (gnus-summary-show-thread)
8641 (gnus-summary-goto-subject gnus-current-article)
8642 (gnus-summary-position-point)
8645 (defun gnus-find-matching-articles (header regexp)
8646 "Return a list of all articles that match REGEXP on HEADER.
8647 This search includes all articles in the current group that Gnus has
8648 fetched headers for, whether they are displayed or not."
8649 (let ((articles nil)
8650 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8651 (case-fold-search t))
8652 (dolist (header gnus-newsgroup-headers)
8653 (when (string-match regexp (funcall func header))
8654 (push (mail-header-number header) articles)))
8655 (nreverse articles)))
8657 (defun gnus-summary-find-matching (header regexp &optional backward unread
8658 not-case-fold not-matching)
8659 "Return a list of all articles that match REGEXP on HEADER.
8660 The search stars on the current article and goes forwards unless
8661 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8662 If UNREAD is non-nil, only unread articles will
8663 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8664 in the comparisons. If NOT-MATCHING, return a list of all articles that
8665 not match REGEXP on HEADER."
8666 (let ((case-fold-search (not not-case-fold))
8669 (if (eq (car header) 'extra)
8672 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8674 (error "%s is an invalid header" header))
8675 (unless (fboundp (intern (concat "mail-header-" header)))
8676 (error "%s is not a valid header" header))
8677 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8678 (dolist (d (if (eq backward 'all)
8680 (gnus-data-find-list
8681 (gnus-summary-article-number)
8682 (gnus-data-list backward))))
8683 (when (and (or (not unread) ; We want all articles...
8684 (gnus-data-unread-p d)) ; Or just unreads.
8685 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8689 (funcall func (gnus-data-header d))))
8690 (string-match regexp
8691 (funcall func (gnus-data-header d)))))
8692 (push (gnus-data-number d) articles))) ; Success!
8693 (nreverse articles)))
8695 (defun gnus-summary-execute-command (header regexp command &optional backward)
8696 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8697 If HEADER is an empty string (or nil), the match is done on the entire
8698 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8700 (list (let ((completion-ignore-case t))
8703 (mapcar (lambda (header) (list (format "%s" header)))
8705 '("Number" "Subject" "From" "Lines" "Date"
8706 "Message-ID" "Xref" "References" "Body")
8707 gnus-extra-headers))
8708 nil 'require-match))
8709 (read-string "Regexp: ")
8710 (read-key-sequence "Command: ")
8711 current-prefix-arg))
8712 (when (equal header "Body")
8714 ;; Hidden thread subtrees must be searched as well.
8715 (gnus-summary-show-all-threads)
8716 ;; We don't want to change current point nor window configuration.
8718 (save-window-excursion
8720 gnus-treat-strip-trailing-blank-lines
8721 gnus-treat-strip-leading-blank-lines
8722 gnus-treat-strip-multiple-blank-lines
8723 gnus-treat-hide-boring-headers
8724 gnus-treat-fold-newsgroups
8725 gnus-article-prepare-hook)
8726 (gnus-message 6 "Executing %s..." (key-description command))
8727 ;; We'd like to execute COMMAND interactively so as to give arguments.
8728 (gnus-execute header regexp
8729 `(call-interactively ',(key-binding command))
8731 (gnus-message 6 "Executing %s...done" (key-description command))))))
8733 (defun gnus-summary-beginning-of-article ()
8734 "Scroll the article back to the beginning."
8736 (gnus-summary-select-article)
8737 (gnus-configure-windows 'article)
8738 (gnus-eval-in-buffer-window gnus-article-buffer
8740 (goto-char (point-min))
8741 (when gnus-break-pages
8742 (gnus-narrow-to-page))))
8744 (defun gnus-summary-end-of-article ()
8745 "Scroll to the end of the article."
8747 (gnus-summary-select-article)
8748 (gnus-configure-windows 'article)
8749 (gnus-eval-in-buffer-window gnus-article-buffer
8751 (goto-char (point-max))
8753 (when gnus-break-pages
8754 (when (re-search-backward page-delimiter nil t)
8755 (narrow-to-region (match-end 0) (point-max)))
8756 (gnus-narrow-to-page))))
8758 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8759 "Truncate to LEN and quote all \"(\"'s in STRING."
8760 (gnus-replace-in-string (if (and len (> (length string) len))
8761 (substring string 0 len)
8765 (defun gnus-summary-print-article (&optional filename n)
8766 "Generate and print a PostScript image of the process-marked (mail) articles.
8768 If used interactively, print the current article if none are
8769 process-marked. With prefix arg, prompt the user for the name of the
8772 When used from Lisp, accept two optional args FILENAME and N. N means
8773 to print the next N articles. If N is negative, print the N previous
8774 articles. If N is nil and articles have been marked with the process
8775 mark, print these instead.
8777 If the optional first argument FILENAME is nil, send the image to the
8778 printer. If FILENAME is a string, save the PostScript image in a file with
8779 that name. If FILENAME is a number, prompt the user for the name of the file
8781 (interactive (list (ps-print-preprint current-prefix-arg)))
8782 (dolist (article (gnus-summary-work-articles n))
8783 (gnus-summary-select-article nil nil 'pseudo article)
8784 (gnus-eval-in-buffer-window gnus-article-buffer
8785 (gnus-print-buffer))
8786 (gnus-summary-remove-process-mark article))
8787 (ps-despool filename))
8789 (defun gnus-print-buffer ()
8790 (let ((buffer (generate-new-buffer " *print*")))
8793 (copy-to-buffer buffer (point-min) (point-max))
8795 (gnus-remove-text-with-property 'gnus-decoration)
8796 (when (gnus-visual-p 'article-highlight 'highlight)
8797 ;; Copy-to-buffer doesn't copy overlay. So redo
8799 (let ((gnus-article-buffer buffer))
8800 (gnus-article-highlight-citation t)
8801 (gnus-article-highlight-signature)
8802 (gnus-article-emphasize)
8803 (gnus-article-delete-invisible-text)))
8804 (let ((ps-left-header
8807 (gnus-summary-print-truncate-and-quote
8808 (mail-header-subject gnus-current-headers)
8811 (gnus-summary-print-truncate-and-quote
8812 (mail-header-from gnus-current-headers)
8816 "/pagenumberstring load"
8818 (mail-header-date gnus-current-headers) ")"))))
8819 (gnus-run-hooks 'gnus-ps-print-hook)
8822 (ps-spool-buffer-with-faces)
8823 (ps-spool-buffer)))))
8824 (kill-buffer buffer))))
8826 (defun gnus-summary-show-article (&optional arg)
8827 "Force redisplaying of the current article.
8828 If ARG (the prefix) is a number, show the article with the charset
8829 defined in `gnus-summary-show-article-charset-alist', or the charset
8831 If ARG (the prefix) is non-nil and not a number, show the raw article
8832 without any article massaging functions being run. Normally, the key
8833 strokes are `C-u g'."
8837 (gnus-summary-show-article t)
8838 (let* ((gnus-newsgroup-charset
8839 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8840 (mm-read-coding-system
8841 "View as charset: " ;; actually it is coding system.
8843 (set-buffer gnus-article-buffer)
8844 (mm-detect-coding-region (point) (point-max))))))
8845 (default-mime-charset gnus-newsgroup-charset)
8846 (gnus-newsgroup-ignored-charsets 'gnus-all))
8847 (gnus-summary-select-article nil 'force)
8848 (let ((deps gnus-newsgroup-dependencies)
8851 (set-buffer gnus-original-article-buffer)
8853 (message-narrow-to-head)
8854 (setq head (buffer-string))
8855 (goto-char (point-min))
8856 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8857 (goto-char (point-max))
8859 (setq lines (1- (count-lines (point) (point-max))))))
8861 (insert (format "211 %d Article retrieved.\n"
8862 (cdr gnus-article-current)))
8864 (if lines (insert (format "Lines: %d\n" lines)))
8866 (let ((nntp-server-buffer (current-buffer)))
8867 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8868 (gnus-data-set-header
8869 (gnus-data-find (cdr gnus-article-current))
8871 (gnus-summary-update-article-line
8872 (cdr gnus-article-current) header)
8873 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8874 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8876 ;; Select the article the normal way.
8877 (gnus-summary-select-article nil 'force))
8879 ;; We have to require this here to make sure that the following
8880 ;; dynamic binding isn't shadowed by autoloading.
8881 (require 'gnus-async)
8883 ;; Bind the article treatment functions to nil.
8884 (let ((gnus-have-all-headers t)
8885 gnus-article-prepare-hook
8886 gnus-article-decode-hook
8889 (gnus-inhibit-treatment t))
8890 (gnus-summary-select-article nil 'force))))
8891 (gnus-summary-goto-subject gnus-current-article)
8892 (gnus-summary-position-point))
8894 (defun gnus-summary-show-raw-article ()
8895 "Show the raw article without any article massaging functions being run."
8897 (gnus-summary-show-article t))
8899 (defun gnus-summary-verbose-headers (&optional arg)
8900 "Toggle permanent full header display.
8901 If ARG is a positive number, turn header display on.
8902 If ARG is a negative number, turn header display off."
8904 (setq gnus-show-all-headers
8905 (cond ((or (not (numberp arg))
8907 (not gnus-show-all-headers))
8910 (gnus-summary-show-article))
8912 (defun gnus-summary-toggle-header (&optional arg)
8913 "Show the headers if they are hidden, or hide them if they are shown.
8914 If ARG is a positive number, show the entire header.
8915 If ARG is a negative number, hide the unwanted header lines."
8917 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8918 (get-buffer-window gnus-article-buffer t))))
8919 (with-current-buffer gnus-article-buffer
8921 (article-narrow-to-head)
8922 (let* ((buffer-read-only nil)
8923 (inhibit-point-motion-hooks t)
8924 (hidden (if (numberp arg)
8926 (gnus-article-hidden-text-p 'headers)))
8928 (delete-region (point-min) (point-max))
8929 (with-current-buffer gnus-original-article-buffer
8930 (goto-char (setq s (point-min)))
8931 (setq e (if (search-forward "\n\n" nil t)
8934 (insert-buffer-substring gnus-original-article-buffer s e)
8935 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8936 ;; article-decode-encoded-words by default.
8937 (article-decode-encoded-words)
8938 (run-hooks 'gnus-article-decode-hook)
8940 (let ((gnus-treat-hide-headers nil)
8941 (gnus-treat-hide-boring-headers nil))
8942 (gnus-delete-wash-type 'headers)
8943 (gnus-treat-article 'head))
8944 (gnus-treat-article 'head))
8947 (set-window-start window (goto-char (point-min))))
8948 (if gnus-break-pages
8949 (gnus-narrow-to-page)
8950 (when (gnus-visual-p 'page-marker)
8951 (let ((buffer-read-only nil))
8952 (gnus-remove-text-with-property 'gnus-prev)
8953 (gnus-remove-text-with-property 'gnus-next))))
8954 (gnus-set-mode-line 'article)))))
8956 (defun gnus-summary-show-all-headers ()
8957 "Make all header lines visible."
8959 (gnus-summary-toggle-header 1))
8961 (defun gnus-summary-toggle-mime (&optional arg)
8962 "Toggle MIME processing.
8963 If ARG is a positive number, turn MIME processing on."
8965 (setq gnus-show-mime
8967 (not gnus-show-mime)
8968 (> (prefix-numeric-value arg) 0)))
8969 (gnus-summary-select-article t 'force))
8971 (defun gnus-summary-caesar-message (&optional arg)
8972 "Caesar rotate the current article by 13.
8973 The numerical prefix specifies how many places to rotate each letter
8976 (gnus-summary-select-article)
8977 (let ((mail-header-separator ""))
8978 (gnus-eval-in-buffer-window gnus-article-buffer
8981 (let ((start (window-start))
8983 (message-caesar-buffer-body arg)
8984 (set-window-start (get-buffer-window (current-buffer)) start))))))
8986 (autoload 'unmorse-region "morse"
8987 "Convert morse coded text in region to ordinary ASCII text."
8990 (defun gnus-summary-morse-message (&optional arg)
8991 "Morse decode the current article."
8993 (gnus-summary-select-article)
8994 (let ((mail-header-separator ""))
8995 (gnus-eval-in-buffer-window gnus-article-buffer
8999 (let ((pos (window-start))
9001 (goto-char (point-min))
9002 (when (message-goto-body)
9003 (gnus-narrow-to-body))
9004 (goto-char (point-min))
9005 (while (search-forward "·" (point-max) t)
9006 (replace-match "."))
9007 (unmorse-region (point-min) (point-max))
9009 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9011 (defun gnus-summary-stop-page-breaking ()
9012 "Stop page breaking in the current article."
9014 (gnus-summary-select-article)
9015 (gnus-eval-in-buffer-window gnus-article-buffer
9017 (when (gnus-visual-p 'page-marker)
9018 (let ((buffer-read-only nil))
9019 (gnus-remove-text-with-property 'gnus-prev)
9020 (gnus-remove-text-with-property 'gnus-next))
9021 (setq gnus-page-broken nil))))
9023 (defun gnus-summary-move-article (&optional n to-newsgroup
9024 select-method action)
9025 "Move the current article to a different newsgroup.
9026 If N is a positive number, move the N next articles.
9027 If N is a negative number, move the N previous articles.
9028 If N is nil and any articles have been marked with the process mark,
9029 move those articles instead.
9030 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9031 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9032 re-spool using this method.
9034 When called interactively with TO-NEWSGROUP being nil, the value of
9035 the variable `gnus-move-split-methods' is used for finding a default
9036 for the target newsgroup.
9038 For this function to work, both the current newsgroup and the
9039 newsgroup that you want to move to have to support the `request-move'
9040 and `request-accept' functions.
9042 ACTION can be either `move' (the default), `crosspost' or `copy'."
9045 (setq action 'move))
9046 ;; Check whether the source group supports the required functions.
9047 (cond ((and (eq action 'move)
9048 (not (gnus-check-backend-function
9049 'request-move-article gnus-newsgroup-name)))
9050 (error "The current group does not support article moving"))
9051 ((and (eq action 'crosspost)
9052 (not (gnus-check-backend-function
9053 'request-replace-article gnus-newsgroup-name)))
9054 (error "The current group does not support article editing")))
9055 (let ((articles (gnus-summary-work-articles n))
9056 (prefix (if (gnus-check-backend-function
9057 'request-move-article gnus-newsgroup-name)
9058 (funcall gnus-move-group-prefix-function
9059 gnus-newsgroup-name)
9061 (names '((move "Move" "Moving")
9062 (copy "Copy" "Copying")
9063 (crosspost "Crosspost" "Crossposting")))
9064 (copy-buf (save-excursion
9065 (nnheader-set-temp-buffer " *copy article*")))
9066 art-group to-method new-xref article to-groups)
9067 (unless (assq action names)
9068 (error "Unknown action %s" action))
9069 ;; Read the newsgroup name.
9070 (when (and (not to-newsgroup)
9071 (not select-method))
9072 (if (and gnus-move-split-methods
9074 (and (memq gnus-current-article articles)
9075 (gnus-buffer-live-p gnus-original-article-buffer))))
9076 ;; When `gnus-move-split-methods' is non-nil, we have to
9077 ;; select an article to give `gnus-read-move-group-name' an
9078 ;; opportunity to suggest an appropriate default. However,
9079 ;; we needn't render or mark the article.
9080 (let ((gnus-display-mime-function nil)
9081 (gnus-article-prepare-hook nil)
9082 (gnus-mark-article-hook nil))
9083 (gnus-summary-select-article nil nil nil (car articles))))
9085 (gnus-read-move-group-name
9086 (cadr (assq action names))
9087 (symbol-value (intern (format "gnus-current-%s-group" action)))
9089 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9090 (setq to-method (or select-method
9091 (gnus-server-to-method
9092 (gnus-group-method to-newsgroup))))
9093 ;; Check the method we are to move this article to...
9094 (unless (gnus-check-backend-function
9095 'request-accept-article (car to-method))
9096 (error "%s does not support article copying" (car to-method)))
9097 (unless (gnus-check-server to-method)
9098 (error "Can't open server %s" (car to-method)))
9099 (gnus-message 6 "%s to %s: %s..."
9100 (caddr (assq action names))
9101 (or (car select-method) to-newsgroup) articles)
9103 (setq article (pop articles))
9107 ;; Move the article.
9109 ;; Remove this article from future suppression.
9110 (gnus-dup-unsuppress-article article)
9111 (gnus-request-move-article
9112 article ; Article to move
9113 gnus-newsgroup-name ; From newsgroup
9114 (nth 1 (gnus-find-method-for-group
9115 gnus-newsgroup-name)) ; Server
9116 (list 'gnus-request-accept-article
9117 to-newsgroup (list 'quote select-method)
9118 (not articles) t) ; Accept form
9119 (not articles))) ; Only save nov last time
9120 ;; Copy the article.
9123 (set-buffer copy-buf)
9124 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9125 (gnus-request-accept-article
9126 to-newsgroup select-method (not articles) t))))
9127 ;; Crosspost the article.
9128 ((eq action 'crosspost)
9129 (let ((xref (message-tokenize-header
9130 (mail-header-xref (gnus-summary-article-header article))
9132 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9133 ":" (number-to-string article)))
9135 (setq xref (list (system-name))))
9138 (mapconcat 'identity
9139 (delete "Xref:" (delete new-xref xref))
9143 (set-buffer copy-buf)
9144 ;; First put the article in the destination group.
9145 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9146 (when (consp (setq art-group
9147 (gnus-request-accept-article
9148 to-newsgroup select-method (not articles))))
9149 (setq new-xref (concat new-xref " " (car art-group)
9151 (number-to-string (cdr art-group))))
9152 ;; Now we have the new Xrefs header, so we insert
9153 ;; it and replace the new article.
9154 (nnheader-replace-header "Xref" new-xref)
9155 (gnus-request-replace-article
9156 (cdr art-group) to-newsgroup (current-buffer))
9160 (gnus-message 1 "Couldn't %s article %s: %s"
9161 (cadr (assq action names)) article
9162 (nnheader-get-report (car to-method))))
9163 ((eq art-group 'junk)
9164 (when (eq action 'move)
9165 (gnus-summary-mark-article article gnus-canceled-mark)
9166 (gnus-message 4 "Deleted article %s" article)
9167 ;; run the delete hook
9168 (run-hook-with-args 'gnus-summary-article-delete-hook
9171 (assoc article (gnus-data-list nil)))
9172 gnus-newsgroup-name nil
9175 (let* ((pto-group (gnus-group-prefixed-name
9176 (car art-group) to-method))
9177 (info (gnus-get-info pto-group))
9178 (to-group (gnus-info-group info))
9180 ;; Update the group that has been moved to.
9182 (memq action '(move copy)))
9183 (unless (member to-group to-groups)
9184 (push to-group to-groups))
9186 (unless (memq article gnus-newsgroup-unreads)
9187 (push 'read to-marks)
9189 info (gnus-add-to-range (gnus-info-read info)
9190 (list (cdr art-group)))))
9192 ;; See whether the article is to be put in the cache.
9193 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9194 gnus-article-mark-lists
9195 (delete '(expirable . expire)
9196 (copy-sequence gnus-article-mark-lists))))
9197 (to-article (cdr art-group)))
9199 ;; Enter the article into the cache in the new group,
9200 ;; if that is required.
9201 (when gnus-use-cache
9202 (gnus-cache-possibly-enter-article
9204 (let ((header (copy-sequence
9205 (gnus-summary-article-header article))))
9206 (mail-header-set-number header to-article)
9208 (memq article gnus-newsgroup-marked)
9209 (memq article gnus-newsgroup-dormant)
9210 (memq article gnus-newsgroup-unreads)))
9212 (when gnus-preserve-marks
9213 ;; Copy any marks over to the new group.
9214 (when (and (equal to-group gnus-newsgroup-name)
9215 (not (memq article gnus-newsgroup-unreads)))
9216 ;; Mark this article as read in this group.
9217 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9218 (setcdr (gnus-active to-group) to-article)
9219 (setcdr gnus-newsgroup-active to-article))
9222 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9223 (when (memq article (symbol-value
9224 (intern (format "gnus-newsgroup-%s"
9226 (push (cdar marks) to-marks)
9227 ;; If the other group is the same as this group,
9228 ;; then we have to add the mark to the list.
9229 (when (equal to-group gnus-newsgroup-name)
9230 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9233 (intern (format "gnus-newsgroup-%s"
9235 ;; Copy the marks to other group.
9236 (gnus-add-marked-articles
9237 to-group (cdar marks) (list to-article) info)))
9238 (setq marks (cdr marks)))
9240 (gnus-request-set-mark
9241 to-group (list (list (list to-article) 'add to-marks))))
9244 (concat "(gnus-group-set-info '"
9245 (gnus-prin1-to-string (gnus-get-info to-group))
9248 ;; Update the Xref header in this article to point to
9249 ;; the new crossposted article we have just created.
9250 (when (eq action 'crosspost)
9252 (set-buffer copy-buf)
9253 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9254 (nnheader-replace-header "Xref" new-xref)
9255 (gnus-request-replace-article
9256 article gnus-newsgroup-name (current-buffer))))
9258 ;; run the move/copy/crosspost/respool hook
9259 (run-hook-with-args 'gnus-summary-article-move-hook
9262 (assoc article (gnus-data-list nil)))
9267 ;;;!!!Why is this necessary?
9268 (set-buffer gnus-summary-buffer)
9270 (gnus-summary-goto-subject article)
9271 (when (eq action 'move)
9272 (gnus-summary-mark-article article gnus-canceled-mark))))
9273 (gnus-summary-remove-process-mark article))
9274 ;; Re-activate all groups that have been moved to.
9276 (set-buffer gnus-group-buffer)
9277 (let ((gnus-group-marked to-groups))
9278 (gnus-group-get-new-news-this-group nil t)))
9280 (gnus-kill-buffer copy-buf)
9281 (gnus-summary-position-point)
9282 (gnus-set-mode-line 'summary)))
9284 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9285 "Move the current article to a different newsgroup.
9286 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9287 When called interactively, if TO-NEWSGROUP is nil, use the value of
9288 the variable `gnus-move-split-methods' for finding a default target
9290 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9291 re-spool using this method."
9293 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9295 (defun gnus-summary-crosspost-article (&optional n)
9296 "Crosspost the current article to some other group."
9298 (gnus-summary-move-article n nil nil 'crosspost))
9300 (defcustom gnus-summary-respool-default-method nil
9301 "Default method type for respooling an article.
9302 If nil, use to the current newsgroup method."
9304 :group 'gnus-summary-mail)
9306 (defcustom gnus-summary-display-while-building nil
9307 "If non-nil, show and update the summary buffer as it's being built.
9308 If the value is t, update the buffer after every line is inserted. If
9309 the value is an integer (N), update the display every N lines."
9311 :type '(choice (const :tag "off" nil)
9313 (const :tag "frequently" t)))
9315 (defun gnus-summary-respool-article (&optional n method)
9316 "Respool the current article.
9317 The article will be squeezed through the mail spooling process again,
9318 which means that it will be put in some mail newsgroup or other
9319 depending on `nnmail-split-methods'.
9320 If N is a positive number, respool the N next articles.
9321 If N is a negative number, respool the N previous articles.
9322 If N is nil and any articles have been marked with the process mark,
9323 respool those articles instead.
9325 Respooling can be done both from mail groups and \"real\" newsgroups.
9326 In the former case, the articles in question will be moved from the
9327 current group into whatever groups they are destined to. In the
9328 latter case, they will be copied into the relevant groups."
9330 (list current-prefix-arg
9331 (let* ((methods (gnus-methods-using 'respool))
9333 (symbol-name (or gnus-summary-respool-default-method
9334 (car (gnus-find-method-for-group
9335 gnus-newsgroup-name)))))
9337 (gnus-completing-read-with-default
9338 methname "What backend do you want to use when respooling?"
9339 methods nil t nil 'gnus-mail-method-history))
9342 ((zerop (length (setq ms (gnus-servers-using-backend
9344 (list (intern method) ""))
9348 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9349 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9352 (error "No method given for respooling"))
9353 (if (assoc (symbol-name
9354 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9355 (gnus-methods-using 'respool))
9356 (gnus-summary-move-article n nil method)
9357 (gnus-summary-copy-article n nil method)))
9359 (defun gnus-summary-import-article (file &optional edit)
9360 "Import an arbitrary file into a mail newsgroup."
9361 (interactive "fImport file: \nP")
9362 (let ((group gnus-newsgroup-name)
9363 (now (current-time))
9364 atts lines group-art)
9365 (unless (gnus-check-backend-function 'request-accept-article group)
9366 (error "%s does not support article importing" group))
9367 (or (file-readable-p file)
9368 (not (file-regular-p file))
9369 (error "Can't read %s" file))
9371 (set-buffer (gnus-get-buffer-create " *import file*"))
9373 (nnheader-insert-file-contents file)
9374 (goto-char (point-min))
9375 (if (nnheader-article-p)
9377 (goto-char (point-min))
9378 (search-forward "\n\n" nil t)
9379 (narrow-to-region (point-min) (1- (point)))
9380 (goto-char (point-min))
9381 (unless (re-search-forward "^date:" nil t)
9382 (goto-char (point-max))
9383 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9384 ;; This doesn't look like an article, so we fudge some headers.
9385 (setq atts (file-attributes file)
9386 lines (count-lines (point-min) (point-max)))
9387 (insert "From: " (read-string "From: ") "\n"
9388 "Subject: " (read-string "Subject: ") "\n"
9389 "Date: " (message-make-date (nth 5 atts)) "\n"
9390 "Message-ID: " (message-make-message-id) "\n"
9391 "Lines: " (int-to-string lines) "\n"
9392 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9393 (setq group-art (gnus-request-accept-article group nil t))
9394 (kill-buffer (current-buffer)))
9395 (setq gnus-newsgroup-active (gnus-activate-group group))
9397 (gnus-summary-goto-article (cdr group-art) nil t)
9399 (gnus-summary-edit-article))))
9401 (defun gnus-summary-create-article ()
9402 "Create an article in a mail newsgroup."
9404 (let ((group gnus-newsgroup-name)
9405 (now (current-time))
9407 (unless (gnus-check-backend-function 'request-accept-article group)
9408 (error "%s does not support article importing" group))
9410 (set-buffer (gnus-get-buffer-create " *import file*"))
9412 (goto-char (point-min))
9413 ;; This doesn't look like an article, so we fudge some headers.
9414 (insert "From: " (read-string "From: ") "\n"
9415 "Subject: " (read-string "Subject: ") "\n"
9416 "Date: " (message-make-date now) "\n"
9417 "Message-ID: " (message-make-message-id) "\n")
9418 (setq group-art (gnus-request-accept-article group nil t))
9419 (kill-buffer (current-buffer)))
9420 (setq gnus-newsgroup-active (gnus-activate-group group))
9422 (gnus-summary-goto-article (cdr group-art) nil t)
9423 (gnus-summary-edit-article)))
9425 (defun gnus-summary-article-posted-p ()
9426 "Say whether the current (mail) article is available from news as well.
9427 This will be the case if the article has both been mailed and posted."
9429 (let ((id (mail-header-references (gnus-summary-article-header)))
9430 (gnus-override-method (car (gnus-refer-article-methods))))
9431 (if (gnus-request-head id "")
9432 (gnus-message 2 "The current message was found on %s"
9433 gnus-override-method)
9434 (gnus-message 2 "The current message couldn't be found on %s"
9435 gnus-override-method)
9438 (defun gnus-summary-expire-articles (&optional now)
9439 "Expire all articles that are marked as expirable in the current group."
9441 (when (and (not gnus-group-is-exiting-without-update-p)
9442 (gnus-check-backend-function
9443 'request-expire-articles gnus-newsgroup-name))
9444 ;; This backend supports expiry.
9445 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9446 (expirable (if total
9448 ;; We need to update the info for
9449 ;; this group for `gnus-list-of-read-articles'
9450 ;; to give us the right answer.
9451 (gnus-run-hooks 'gnus-exit-group-hook)
9452 (gnus-summary-update-info)
9453 (gnus-list-of-read-articles gnus-newsgroup-name))
9454 (setq gnus-newsgroup-expirable
9455 (sort gnus-newsgroup-expirable '<))))
9456 (expiry-wait (if now 'immediate
9457 (gnus-group-find-parameter
9458 gnus-newsgroup-name 'expiry-wait)))
9459 (nnmail-expiry-target
9460 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9461 nnmail-expiry-target))
9464 ;; There are expirable articles in this group, so we run them
9465 ;; through the expiry process.
9466 (gnus-message 6 "Expiring articles...")
9467 (unless (gnus-check-group gnus-newsgroup-name)
9468 (error "Can't open server for %s" gnus-newsgroup-name))
9469 ;; The list of articles that weren't expired is returned.
9472 (let ((nnmail-expiry-wait-function nil)
9473 (nnmail-expiry-wait expiry-wait))
9474 (setq es (gnus-request-expire-articles
9475 expirable gnus-newsgroup-name)))
9476 (setq es (gnus-request-expire-articles
9477 expirable gnus-newsgroup-name)))
9479 (setq gnus-newsgroup-expirable es))
9480 ;; We go through the old list of expirable, and mark all
9481 ;; really expired articles as nonexistent.
9482 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9483 (let ((gnus-use-cache nil))
9484 (dolist (article expirable)
9485 (when (and (not (memq article es))
9486 (gnus-data-find article))
9487 (gnus-summary-mark-article article gnus-canceled-mark)
9488 (run-hook-with-args 'gnus-summary-article-expire-hook
9491 (assoc article (gnus-data-list nil)))
9495 (gnus-message 6 "Expiring articles...done")))))
9497 (defun gnus-summary-expire-articles-now ()
9498 "Expunge all expirable articles in the current group.
9499 This means that *all* articles that are marked as expirable will be
9500 deleted forever, right now."
9502 (or gnus-expert-user
9504 "Are you really, really, really sure you want to delete all these messages? ")
9506 (gnus-summary-expire-articles t))
9508 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9509 (defun gnus-summary-delete-article (&optional n)
9510 "Delete the N next (mail) articles.
9511 This command actually deletes articles. This is not a marking
9512 command. The article will disappear forever from your life, never to
9515 If N is negative, delete backwards.
9516 If N is nil and articles have been marked with the process mark,
9517 delete these instead.
9519 If `gnus-novice-user' is non-nil you will be asked for
9520 confirmation before the articles are deleted."
9522 (unless (gnus-check-backend-function 'request-expire-articles
9523 gnus-newsgroup-name)
9524 (error "The current newsgroup does not support article deletion"))
9525 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9526 (error "Couldn't open server"))
9527 ;; Compute the list of articles to delete.
9528 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9529 (nnmail-expiry-target 'delete)
9531 (if (and gnus-novice-user
9532 (not (gnus-yes-or-no-p
9533 (format "Do you really want to delete %s forever? "
9534 (if (> (length articles) 1)
9535 (format "these %s articles" (length articles))
9538 ;; Delete the articles.
9539 (setq not-deleted (gnus-request-expire-articles
9540 articles gnus-newsgroup-name 'force))
9542 (gnus-summary-remove-process-mark (car articles))
9543 ;; The backend might not have been able to delete the article
9545 (unless (memq (car articles) not-deleted)
9546 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9547 (let* ((article (car articles))
9548 (ghead (gnus-data-header
9549 (assoc article (gnus-data-list nil)))))
9550 (run-hook-with-args 'gnus-summary-article-delete-hook
9551 'delete ghead gnus-newsgroup-name nil
9553 (setq articles (cdr articles)))
9555 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9556 (gnus-summary-position-point)
9557 (gnus-set-mode-line 'summary)
9560 (defun gnus-summary-edit-article (&optional force)
9561 "Edit the current article.
9562 This will have permanent effect only in mail groups.
9563 If FORCE is non-nil, allow editing of articles even in read-only
9567 (set-buffer gnus-summary-buffer)
9568 (let ((mail-parse-charset gnus-newsgroup-charset)
9569 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9570 (gnus-set-global-variables)
9571 (when (and (not force)
9572 (gnus-group-read-only-p))
9573 (error "The current newsgroup does not support article editing"))
9574 (gnus-summary-show-article t)
9575 (gnus-article-edit-article
9577 `(lambda (no-highlight)
9578 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9579 (message-options message-options)
9580 (message-options-set-recipient)
9581 (mail-parse-ignored-charsets
9582 ',gnus-newsgroup-ignored-charsets))
9583 (gnus-summary-edit-article-done
9584 ,(or (mail-header-references gnus-current-headers) "")
9585 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9587 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9589 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9591 "Make edits to the current article permanent."
9594 ;; The buffer restriction contains the entire article if it exists.
9595 (when (article-goto-body)
9596 (let ((lines (count-lines (point) (point-max)))
9597 (length (- (point-max) (point)))
9598 (case-fold-search t)
9599 (body (copy-marker (point))))
9600 (goto-char (point-min))
9601 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9602 (delete-region (match-beginning 1) (match-end 1))
9603 (insert (number-to-string length)))
9604 (goto-char (point-min))
9605 (when (re-search-forward
9606 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9607 (delete-region (match-beginning 1) (match-end 1))
9608 (insert (number-to-string length)))
9609 (goto-char (point-min))
9610 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9611 (delete-region (match-beginning 1) (match-end 1))
9612 (insert (number-to-string lines))))))
9613 ;; Replace the article.
9614 (let ((buf (current-buffer)))
9616 (insert-buffer-substring buf)
9618 (if (and (not read-only)
9619 (not (gnus-request-replace-article
9620 (cdr gnus-article-current) (car gnus-article-current)
9621 (current-buffer) t)))
9622 (error "Couldn't replace article")
9623 ;; Update the summary buffer.
9625 (equal (message-tokenize-header references " ")
9626 (message-tokenize-header
9627 (or (message-fetch-field "references") "") " ")))
9628 ;; We only have to update this line.
9631 (message-narrow-to-head)
9632 (let ((head (buffer-string))
9635 (insert (format "211 %d Article retrieved.\n"
9636 (cdr gnus-article-current)))
9639 (let ((nntp-server-buffer (current-buffer)))
9640 (setq header (car (gnus-get-newsgroup-headers
9643 (set-buffer gnus-summary-buffer)
9644 (gnus-data-set-header
9645 (gnus-data-find (cdr gnus-article-current))
9647 (gnus-summary-update-article-line
9648 (cdr gnus-article-current) header)
9649 (if (gnus-summary-goto-subject
9650 (cdr gnus-article-current) nil t)
9651 (gnus-summary-update-secondary-mark
9652 (cdr gnus-article-current))))))))
9654 (set-buffer (or buffer gnus-summary-buffer))
9655 (gnus-summary-update-article (cdr gnus-article-current))
9656 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9657 (gnus-summary-update-secondary-mark
9658 (cdr gnus-article-current))))
9659 ;; Prettify the article buffer again.
9660 (unless no-highlight
9662 (set-buffer gnus-article-buffer)
9663 ;;;!!! Fix this -- article should be rehighlighted.
9664 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9665 (set-buffer gnus-original-article-buffer)
9666 (gnus-request-article
9667 (cdr gnus-article-current)
9668 (car gnus-article-current) (current-buffer))))
9669 ;; Prettify the summary buffer line.
9670 (when (gnus-visual-p 'summary-highlight 'highlight)
9671 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9673 (defun gnus-summary-edit-wash (key)
9674 "Perform editing command KEY in the article buffer."
9678 (message "%s" (concat (this-command-keys) "- "))
9681 (gnus-summary-edit-article)
9682 (execute-kbd-macro (concat (this-command-keys) key))
9683 (gnus-article-edit-done))
9687 (defun gnus-summary-respool-query (&optional silent trace)
9688 "Query where the respool algorithm would put this article."
9690 (let (gnus-mark-article-hook)
9691 (gnus-summary-select-article)
9693 (set-buffer gnus-original-article-buffer)
9694 (let ((groups (nnmail-article-group 'identity trace)))
9697 (message "This message would go to %s"
9698 (mapconcat 'car groups ", "))
9699 (message "This message would go to no groups"))
9702 (defun gnus-summary-respool-trace ()
9703 "Trace where the respool algorithm would put this article.
9704 Display a buffer showing all fancy splitting patterns which matched."
9706 (gnus-summary-respool-query nil t))
9708 ;; Summary marking commands.
9710 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9711 "Mark articles which has the same subject as read, and then select the next.
9712 If UNMARK is positive, remove any kind of mark.
9713 If UNMARK is negative, tick articles."
9716 (setq unmark (prefix-numeric-value unmark)))
9718 (gnus-summary-mark-same-subject
9719 (gnus-summary-article-subject) unmark)))
9720 ;; Select next unread article. If auto-select-same mode, should
9721 ;; select the first unread article.
9722 (gnus-summary-next-article t (and gnus-auto-select-same
9723 (gnus-summary-article-subject)))
9724 (gnus-message 7 "%d article%s marked as %s"
9725 count (if (= count 1) " is" "s are")
9726 (if unmark "unread" "read"))))
9728 (defun gnus-summary-kill-same-subject (&optional unmark)
9729 "Mark articles which has the same subject as read.
9730 If UNMARK is positive, remove any kind of mark.
9731 If UNMARK is negative, tick articles."
9734 (setq unmark (prefix-numeric-value unmark)))
9736 (gnus-summary-mark-same-subject
9737 (gnus-summary-article-subject) unmark)))
9738 ;; If marked as read, go to next unread subject.
9740 ;; Go to next unread subject.
9741 (gnus-summary-next-subject 1 t))
9742 (gnus-message 7 "%d articles are marked as %s"
9743 count (if unmark "unread" "read"))))
9745 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9746 "Mark articles with same SUBJECT as read, and return marked number.
9747 If optional argument UNMARK is positive, remove any kinds of marks.
9748 If optional argument UNMARK is negative, mark articles as unread instead."
9752 ((null unmark) ; Mark as read.
9755 (gnus-summary-mark-article-as-read gnus-killed-mark)
9756 (gnus-summary-show-thread) t)
9757 (gnus-summary-find-subject subject))
9758 (setq count (1+ count))))
9759 ((> unmark 0) ; Tick.
9762 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9763 (gnus-summary-show-thread) t)
9764 (gnus-summary-find-subject subject))
9765 (setq count (1+ count))))
9766 (t ; Mark as unread.
9769 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9770 (gnus-summary-show-thread) t)
9771 (gnus-summary-find-subject subject))
9772 (setq count (1+ count)))))
9773 (gnus-set-mode-line 'summary)
9774 ;; Return the number of marked articles.
9777 (defun gnus-summary-mark-as-processable (n &optional unmark)
9778 "Set the process mark on the next N articles.
9779 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9780 the process mark instead. The difference between N and the actual
9781 number of articles marked is returned."
9783 (if (and (null n) (gnus-region-active-p))
9784 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9785 (setq n (prefix-numeric-value n))
9786 (let ((backward (< n 0))
9791 (gnus-summary-remove-process-mark
9792 (gnus-summary-article-number))
9793 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9794 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9797 (gnus-message 7 "No more articles"))
9798 (gnus-summary-recenter)
9799 (gnus-summary-position-point)
9802 (defun gnus-summary-unmark-as-processable (n)
9803 "Remove the process mark from the next N articles.
9804 If N is negative, unmark backward instead. The difference between N and
9805 the actual number of articles unmarked is returned."
9807 (gnus-summary-mark-as-processable n t))
9809 (defun gnus-summary-unmark-all-processable ()
9810 "Remove the process mark from all articles."
9813 (while gnus-newsgroup-processable
9814 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9815 (gnus-summary-position-point))
9817 (defun gnus-summary-add-mark (article type)
9818 "Mark ARTICLE with a mark of TYPE."
9819 (let ((vtype (car (assq type gnus-article-mark-lists)))
9822 (error "No such mark type: %s" type)
9823 (setq var (intern (format "gnus-newsgroup-%s" type)))
9824 (set var (cons article (symbol-value var)))
9825 (if (memq type '(processable cached replied forwarded recent saved))
9826 (gnus-summary-update-secondary-mark article)
9827 ;;; !!! This is bogus. We should find out what primary
9828 ;;; !!! mark we want to set.
9829 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9831 (defun gnus-summary-mark-as-expirable (n)
9832 "Mark N articles forward as expirable.
9833 If N is negative, mark backward instead. The difference between N and
9834 the actual number of articles marked is returned."
9836 (gnus-summary-mark-forward n gnus-expirable-mark))
9838 (defun gnus-summary-mark-as-spam (n)
9839 "Mark N articles forward as spam.
9840 If N is negative, mark backward instead. The difference between N and
9841 the actual number of articles marked is returned."
9843 (gnus-summary-mark-forward n gnus-spam-mark))
9845 (defun gnus-summary-mark-article-as-replied (article)
9846 "Mark ARTICLE as replied to and update the summary line.
9847 ARTICLE can also be a list of articles."
9848 (interactive (list (gnus-summary-article-number)))
9849 (let ((articles (if (listp article) article (list article))))
9850 (dolist (article articles)
9851 (unless (numberp article)
9852 (error "%s is not a number" article))
9853 (push article gnus-newsgroup-replied)
9854 (let ((buffer-read-only nil))
9855 (when (gnus-summary-goto-subject article nil t)
9856 (gnus-summary-update-secondary-mark article))))))
9858 (defun gnus-summary-mark-article-as-forwarded (article)
9859 "Mark ARTICLE as forwarded and update the summary line.
9860 ARTICLE can also be a list of articles."
9861 (let ((articles (if (listp article) article (list article))))
9862 (dolist (article articles)
9863 (push article gnus-newsgroup-forwarded)
9864 (let ((buffer-read-only nil))
9865 (when (gnus-summary-goto-subject article nil t)
9866 (gnus-summary-update-secondary-mark article))))))
9868 (defun gnus-summary-set-bookmark (article)
9869 "Set a bookmark in current article."
9870 (interactive (list (gnus-summary-article-number)))
9871 (when (or (not (get-buffer gnus-article-buffer))
9872 (not gnus-current-article)
9873 (not gnus-article-current)
9874 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9875 (error "No current article selected"))
9876 ;; Remove old bookmark, if one exists.
9877 (gnus-pull article gnus-newsgroup-bookmarks)
9878 ;; Set the new bookmark, which is on the form
9879 ;; (article-number . line-number-in-body).
9882 (with-current-buffer gnus-article-buffer
9889 gnus-newsgroup-bookmarks)
9890 (gnus-message 6 "A bookmark has been added to the current article."))
9892 (defun gnus-summary-remove-bookmark (article)
9893 "Remove the bookmark from the current article."
9894 (interactive (list (gnus-summary-article-number)))
9895 ;; Remove old bookmark, if one exists.
9896 (if (not (assq article gnus-newsgroup-bookmarks))
9897 (gnus-message 6 "No bookmark in current article.")
9898 (gnus-pull article gnus-newsgroup-bookmarks)
9899 (gnus-message 6 "Removed bookmark.")))
9901 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9902 (defun gnus-summary-mark-as-dormant (n)
9903 "Mark N articles forward as dormant.
9904 If N is negative, mark backward instead. The difference between N and
9905 the actual number of articles marked is returned."
9907 (gnus-summary-mark-forward n gnus-dormant-mark))
9909 (defun gnus-summary-set-process-mark (article)
9910 "Set the process mark on ARTICLE and update the summary line."
9911 (setq gnus-newsgroup-processable
9913 (delq article gnus-newsgroup-processable)))
9914 (when (gnus-summary-goto-subject article)
9915 (gnus-summary-show-thread)
9916 (gnus-summary-goto-subject article)
9917 (gnus-summary-update-secondary-mark article)))
9919 (defun gnus-summary-remove-process-mark (article)
9920 "Remove the process mark from ARTICLE and update the summary line."
9921 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9922 (when (gnus-summary-goto-subject article)
9923 (gnus-summary-show-thread)
9924 (gnus-summary-goto-subject article)
9925 (gnus-summary-update-secondary-mark article)))
9927 (defun gnus-summary-set-saved-mark (article)
9928 "Set the process mark on ARTICLE and update the summary line."
9929 (push article gnus-newsgroup-saved)
9930 (when (gnus-summary-goto-subject article)
9931 (gnus-summary-update-secondary-mark article)))
9933 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9934 "Mark N articles as read forwards.
9935 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9936 The difference between N and the actual number of articles marked is
9938 If NO-EXPIRE, auto-expiry will be inhibited."
9940 (gnus-summary-show-thread)
9941 (let ((backward (< n 0))
9942 (gnus-summary-goto-unread
9943 (and gnus-summary-goto-unread
9944 (not (eq gnus-summary-goto-unread 'never))
9945 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9946 gnus-ticked-mark gnus-dormant-mark)))))
9948 (mark (or mark gnus-del-mark)))
9950 (gnus-summary-mark-article nil mark no-expire)
9951 (zerop (gnus-summary-next-subject
9953 (and gnus-summary-goto-unread
9954 (not (eq gnus-summary-goto-unread 'never)))
9958 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9959 (gnus-summary-recenter)
9960 (gnus-summary-position-point)
9961 (gnus-set-mode-line 'summary)
9964 (defun gnus-summary-mark-article-as-read (mark)
9965 "Mark the current article quickly as read with MARK."
9966 (let ((article (gnus-summary-article-number)))
9967 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9968 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9969 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9970 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9971 (push (cons article mark) gnus-newsgroup-reads)
9972 ;; Possibly remove from cache, if that is used.
9973 (when gnus-use-cache
9974 (gnus-cache-enter-remove-article article))
9975 ;; Allow the backend to change the mark.
9976 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9977 ;; Check for auto-expiry.
9978 (when (and gnus-newsgroup-auto-expire
9979 (memq mark gnus-auto-expirable-marks))
9980 (setq mark gnus-expirable-mark)
9981 ;; Let the backend know about the mark change.
9982 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9983 (push article gnus-newsgroup-expirable))
9984 ;; Set the mark in the buffer.
9985 (gnus-summary-update-mark mark 'unread)
9988 (defun gnus-summary-mark-article-as-unread (mark)
9989 "Mark the current article quickly as unread with MARK."
9990 (let* ((article (gnus-summary-article-number))
9991 (old-mark (gnus-summary-article-mark article)))
9992 ;; Allow the backend to change the mark.
9993 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9994 (if (eq mark old-mark)
9998 (gnus-error 1 "Can't mark negative article numbers")
10000 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10001 (setq gnus-newsgroup-spam-marked
10002 (delq article gnus-newsgroup-spam-marked))
10003 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10004 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10005 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10006 (cond ((= mark gnus-ticked-mark)
10007 (setq gnus-newsgroup-marked
10008 (gnus-add-to-sorted-list gnus-newsgroup-marked
10010 ((= mark gnus-spam-mark)
10011 (setq gnus-newsgroup-spam-marked
10012 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10014 ((= mark gnus-dormant-mark)
10015 (setq gnus-newsgroup-dormant
10016 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10019 (setq gnus-newsgroup-unreads
10020 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10022 (gnus-pull article gnus-newsgroup-reads)
10024 ;; See whether the article is to be put in the cache.
10025 (and gnus-use-cache
10026 (vectorp (gnus-summary-article-header article))
10028 (gnus-cache-possibly-enter-article
10029 gnus-newsgroup-name article
10030 (gnus-summary-article-header article)
10031 (= mark gnus-ticked-mark)
10032 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10035 (gnus-summary-update-mark mark 'unread)
10038 (defun gnus-summary-mark-article (&optional article mark no-expire)
10039 "Mark ARTICLE with MARK. MARK can be any character.
10040 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10041 `??' (dormant) and `?E' (expirable).
10042 If MARK is nil, then the default character `?r' is used.
10043 If ARTICLE is nil, then the article on the current line will be
10045 If NO-EXPIRE, auto-expiry will be inhibited."
10046 ;; The mark might be a string.
10047 (when (stringp mark)
10048 (setq mark (aref mark 0)))
10049 ;; If no mark is given, then we check auto-expiring.
10051 (setq mark gnus-del-mark))
10052 (when (and (not no-expire)
10053 gnus-newsgroup-auto-expire
10054 (memq mark gnus-auto-expirable-marks))
10055 (setq mark gnus-expirable-mark))
10056 (let ((article (or article (gnus-summary-article-number)))
10057 (old-mark (gnus-summary-article-mark article)))
10058 ;; Allow the backend to change the mark.
10059 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10060 (if (eq mark old-mark)
10063 (error "No article on current line"))
10064 (if (not (if (or (= mark gnus-unread-mark)
10065 (= mark gnus-ticked-mark)
10066 (= mark gnus-spam-mark)
10067 (= mark gnus-dormant-mark))
10068 (gnus-mark-article-as-unread article mark)
10069 (gnus-mark-article-as-read article mark)))
10071 ;; See whether the article is to be put in the cache.
10072 (and gnus-use-cache
10073 (not (= mark gnus-canceled-mark))
10074 (vectorp (gnus-summary-article-header article))
10076 (gnus-cache-possibly-enter-article
10077 gnus-newsgroup-name article
10078 (gnus-summary-article-header article)
10079 (= mark gnus-ticked-mark)
10080 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10082 (when (gnus-summary-goto-subject article nil t)
10083 (let ((buffer-read-only nil))
10084 (gnus-summary-show-thread)
10086 (gnus-summary-update-mark mark 'unread)
10089 (defun gnus-summary-update-secondary-mark (article)
10090 "Update the secondary (read, process, cache) mark."
10091 (gnus-summary-update-mark
10092 (cond ((memq article gnus-newsgroup-processable)
10094 ((memq article gnus-newsgroup-cached)
10096 ((memq article gnus-newsgroup-replied)
10098 ((memq article gnus-newsgroup-forwarded)
10099 gnus-forwarded-mark)
10100 ((memq article gnus-newsgroup-saved)
10102 ((memq article gnus-newsgroup-recent)
10104 ((memq article gnus-newsgroup-unseen)
10108 (when (gnus-visual-p 'summary-highlight 'highlight)
10109 (gnus-run-hooks 'gnus-summary-update-hook))
10112 (defun gnus-summary-update-download-mark (article)
10113 "Update the download mark."
10114 (gnus-summary-update-mark
10115 (cond ((memq article gnus-newsgroup-undownloaded)
10116 gnus-undownloaded-mark)
10117 (gnus-newsgroup-agentized
10118 gnus-downloaded-mark)
10122 (gnus-summary-update-line t)
10125 (defun gnus-summary-update-mark (mark type)
10126 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10127 (buffer-read-only nil))
10128 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10130 (when (looking-at "\r")
10132 (when (<= (+ forward (point)) (point-max))
10133 ;; Go to the right position on the line.
10134 (goto-char (+ forward (point)))
10135 ;; Replace the old mark with the new mark.
10136 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10137 ;; Optionally update the marks by some user rule.
10138 (when (eq type 'unread)
10139 (gnus-data-set-mark
10140 (gnus-data-find (gnus-summary-article-number)) mark)
10141 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10143 (defun gnus-mark-article-as-read (article &optional mark)
10144 "Enter ARTICLE in the pertinent lists and remove it from others."
10145 ;; Make the article expirable.
10146 (let ((mark (or mark gnus-del-mark)))
10147 (setq gnus-newsgroup-expirable
10148 (if (= mark gnus-expirable-mark)
10149 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10150 (delq article gnus-newsgroup-expirable)))
10151 ;; Remove from unread and marked lists.
10152 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10153 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10154 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10155 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10156 (push (cons article mark) gnus-newsgroup-reads)
10157 ;; Possibly remove from cache, if that is used.
10158 (when gnus-use-cache
10159 (gnus-cache-enter-remove-article article))
10162 (defun gnus-mark-article-as-unread (article &optional mark)
10163 "Enter ARTICLE in the pertinent lists and remove it from others."
10164 (let ((mark (or mark gnus-ticked-mark)))
10167 (gnus-error 1 "Can't mark negative article numbers")
10169 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10170 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10171 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10172 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10173 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10175 ;; Unsuppress duplicates?
10176 (when gnus-suppress-duplicates
10177 (gnus-dup-unsuppress-article article))
10179 (cond ((= mark gnus-ticked-mark)
10180 (setq gnus-newsgroup-marked
10181 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10182 ((= mark gnus-spam-mark)
10183 (setq gnus-newsgroup-spam-marked
10184 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10186 ((= mark gnus-dormant-mark)
10187 (setq gnus-newsgroup-dormant
10188 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10190 (setq gnus-newsgroup-unreads
10191 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10192 (gnus-pull article gnus-newsgroup-reads)
10195 (defalias 'gnus-summary-mark-as-unread-forward
10196 'gnus-summary-tick-article-forward)
10197 (make-obsolete 'gnus-summary-mark-as-unread-forward
10198 'gnus-summary-tick-article-forward)
10199 (defun gnus-summary-tick-article-forward (n)
10200 "Tick N articles forwards.
10201 If N is negative, tick backwards instead.
10202 The difference between N and the number of articles ticked is returned."
10204 (gnus-summary-mark-forward n gnus-ticked-mark))
10206 (defalias 'gnus-summary-mark-as-unread-backward
10207 'gnus-summary-tick-article-backward)
10208 (make-obsolete 'gnus-summary-mark-as-unread-backward
10209 'gnus-summary-tick-article-backward)
10210 (defun gnus-summary-tick-article-backward (n)
10211 "Tick N articles backwards.
10212 The difference between N and the number of articles ticked is returned."
10214 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10216 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10217 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10218 (defun gnus-summary-tick-article (&optional article clear-mark)
10219 "Mark current article as unread.
10220 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10221 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10223 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10224 gnus-ticked-mark)))
10226 (defun gnus-summary-mark-as-read-forward (n)
10227 "Mark N articles as read forwards.
10228 If N is negative, mark backwards instead.
10229 The difference between N and the actual number of articles marked is
10232 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10234 (defun gnus-summary-mark-as-read-backward (n)
10235 "Mark the N articles as read backwards.
10236 The difference between N and the actual number of articles marked is
10239 (gnus-summary-mark-forward
10240 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10242 (defun gnus-summary-mark-as-read (&optional article mark)
10243 "Mark current article as read.
10244 ARTICLE specifies the article to be marked as read.
10245 MARK specifies a string to be inserted at the beginning of the line."
10246 (gnus-summary-mark-article article mark))
10248 (defun gnus-summary-clear-mark-forward (n)
10249 "Clear marks from N articles forward.
10250 If N is negative, clear backward instead.
10251 The difference between N and the number of marks cleared is returned."
10253 (gnus-summary-mark-forward n gnus-unread-mark))
10255 (defun gnus-summary-clear-mark-backward (n)
10256 "Clear marks from N articles backward.
10257 The difference between N and the number of marks cleared is returned."
10259 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10261 (defun gnus-summary-mark-unread-as-read ()
10262 "Intended to be used by `gnus-summary-mark-article-hook'."
10263 (when (memq gnus-current-article gnus-newsgroup-unreads)
10264 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10266 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10267 "Intended to be used by `gnus-summary-mark-article-hook'."
10268 (let ((mark (gnus-summary-article-mark)))
10269 (when (or (gnus-unread-mark-p mark)
10270 (gnus-read-mark-p mark))
10271 (gnus-summary-mark-article gnus-current-article
10272 (or new-mark gnus-read-mark)))))
10274 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10275 "Intended to be used by `gnus-summary-mark-article-hook'."
10276 (let ((mark (gnus-summary-article-mark)))
10277 (when (or (gnus-unread-mark-p mark)
10278 (gnus-read-mark-p mark))
10279 (gnus-summary-mark-article (gnus-summary-article-number)
10280 (or new-mark gnus-read-mark)))))
10282 (defun gnus-summary-mark-unread-as-ticked ()
10283 "Intended to be used by `gnus-summary-mark-article-hook'."
10284 (when (memq gnus-current-article gnus-newsgroup-unreads)
10285 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10287 (defun gnus-summary-mark-region-as-read (point mark all)
10288 "Mark all unread articles between point and mark as read.
10289 If given a prefix, mark all articles between point and mark as read,
10290 even ticked and dormant ones."
10291 (interactive "r\nP")
10295 (beginning-of-line)
10300 (memq (setq article (gnus-summary-article-number))
10301 gnus-newsgroup-unreads))
10302 (gnus-summary-mark-article article gnus-del-mark))
10304 (gnus-summary-find-next))))))
10306 (defun gnus-summary-mark-below (score mark)
10307 "Mark articles with score less than SCORE with MARK."
10308 (interactive "P\ncMark: ")
10309 (setq score (if score
10310 (prefix-numeric-value score)
10311 (or gnus-summary-default-score 0)))
10313 (set-buffer gnus-summary-buffer)
10314 (goto-char (point-min))
10317 (and (< (gnus-summary-article-score) score)
10318 (gnus-summary-mark-article nil mark))
10319 (gnus-summary-find-next)))))
10321 (defun gnus-summary-kill-below (&optional score)
10322 "Mark articles with score below SCORE as read."
10324 (gnus-summary-mark-below score gnus-killed-mark))
10326 (defun gnus-summary-clear-above (&optional score)
10327 "Clear all marks from articles with score above SCORE."
10329 (gnus-summary-mark-above score gnus-unread-mark))
10331 (defun gnus-summary-tick-above (&optional score)
10332 "Tick all articles with score above SCORE."
10334 (gnus-summary-mark-above score gnus-ticked-mark))
10336 (defun gnus-summary-mark-above (score mark)
10337 "Mark articles with score over SCORE with MARK."
10338 (interactive "P\ncMark: ")
10339 (setq score (if score
10340 (prefix-numeric-value score)
10341 (or gnus-summary-default-score 0)))
10343 (set-buffer gnus-summary-buffer)
10344 (goto-char (point-min))
10346 (when (> (gnus-summary-article-score) score)
10347 (gnus-summary-mark-article nil mark))
10349 (gnus-summary-find-next)))))
10351 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10352 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10353 (defun gnus-summary-limit-include-expunged (&optional no-error)
10354 "Display all the hidden articles that were expunged for low scores."
10356 (let ((buffer-read-only nil))
10357 (let ((scored gnus-newsgroup-scored)
10360 (unless (gnus-summary-article-header (caar scored))
10361 (and (setq h (gnus-number-to-header (caar scored)))
10362 (< (cdar scored) gnus-summary-expunge-below)
10364 (setq scored (cdr scored)))
10366 (when (not no-error)
10367 (error "No expunged articles hidden"))
10368 (goto-char (point-min))
10369 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10370 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10371 (mapcar (lambda (x) (push (mail-header-number x)
10372 gnus-newsgroup-limit))
10374 (gnus-summary-prepare-unthreaded (nreverse headers))
10375 (goto-char (point-min))
10376 (gnus-summary-position-point)
10379 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10380 "Mark all unread articles in this newsgroup as read.
10381 If prefix argument ALL is non-nil, ticked and dormant articles will
10382 also be marked as read.
10383 If QUIETLY is non-nil, no questions will be asked.
10385 If TO-HERE is non-nil, it should be a point in the buffer. All
10386 articles before (after, if REVERSE is set) this point will be marked
10389 Note that this function will only catch up the unread article
10390 in the current summary buffer limitation.
10392 The number of articles marked as read is returned."
10397 (not gnus-interactive-catchup) ;Without confirmation?
10401 "Mark absolutely all articles as read? "
10402 "Mark all unread articles as read? ")))
10404 (not gnus-newsgroup-adaptive)
10405 (not gnus-newsgroup-auto-expire)
10406 (not gnus-suppress-duplicates)
10407 (or (not gnus-use-cache)
10408 (eq gnus-use-cache 'passive)))
10411 (setq gnus-newsgroup-marked nil
10412 gnus-newsgroup-spam-marked nil
10413 gnus-newsgroup-dormant nil))
10414 (setq gnus-newsgroup-unreads
10415 (gnus-sorted-nunion
10416 (gnus-intersection gnus-newsgroup-unreads
10417 gnus-newsgroup-downloadable)
10418 gnus-newsgroup-unfetched)))
10419 ;; We actually mark all articles as canceled, which we
10420 ;; have to do when using auto-expiry or adaptive scoring.
10421 (gnus-summary-show-all-threads)
10422 (if (and to-here reverse)
10424 (goto-char to-here)
10425 (gnus-summary-mark-current-read-and-unread-as-read
10427 (while (gnus-summary-find-next (not all))
10428 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10429 (when (gnus-summary-first-subject (not all))
10431 (if to-here (< (point) to-here) t)
10432 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10433 (gnus-summary-find-next (not all))))))
10434 (gnus-set-mode-line 'summary))
10436 (gnus-summary-position-point)))
10438 (defun gnus-summary-catchup-to-here (&optional all)
10439 "Mark all unticked articles before the current one as read.
10440 If ALL is non-nil, also mark ticked and dormant articles as read."
10443 (gnus-save-hidden-threads
10444 (let ((beg (point)))
10445 ;; We check that there are unread articles.
10446 (when (or all (gnus-summary-find-prev))
10447 (gnus-summary-catchup all t beg)))))
10448 (gnus-summary-position-point))
10450 (defun gnus-summary-catchup-from-here (&optional all)
10451 "Mark all unticked articles after (and including) the current one as read.
10452 If ALL is non-nil, also mark ticked and dormant articles as read."
10455 (gnus-save-hidden-threads
10456 (let ((beg (point)))
10457 ;; We check that there are unread articles.
10458 (when (or all (gnus-summary-find-next))
10459 (gnus-summary-catchup all t beg nil t)))))
10460 (gnus-summary-position-point))
10462 (defun gnus-summary-catchup-all (&optional quietly)
10463 "Mark all articles in this newsgroup as read.
10464 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10465 instead, which marks only unread articles as read."
10467 (gnus-summary-catchup t quietly))
10469 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10470 "Mark all unread articles in this group as read, then exit.
10471 If prefix argument ALL is non-nil, all articles are marked as read.
10472 If QUIETLY is non-nil, no questions will be asked."
10474 (when (gnus-summary-catchup all quietly nil 'fast)
10475 ;; Select next newsgroup or exit.
10476 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10477 (eq gnus-auto-select-next 'quietly))
10478 (gnus-summary-next-group nil)
10479 (gnus-summary-exit))))
10481 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10482 "Mark all articles in this newsgroup as read, and then exit.
10483 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10484 instead, which marks only unread articles as read."
10486 (gnus-summary-catchup-and-exit t quietly))
10488 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10489 "Mark all articles in this group as read and select the next group.
10490 If given a prefix, mark all articles, unread as well as ticked, as
10494 (gnus-summary-catchup all))
10495 (gnus-summary-next-group))
10501 (defmacro gnus-with-article (article &rest forms)
10502 "Select ARTICLE and perform FORMS in the original article buffer.
10503 Then replace the article with the result."
10505 ;; We don't want the article to be marked as read.
10506 (let (gnus-mark-article-hook)
10507 (gnus-summary-select-article t t nil ,article))
10508 (set-buffer gnus-original-article-buffer)
10510 (if (not (gnus-check-backend-function
10511 'request-replace-article (car gnus-article-current)))
10512 (gnus-message 5 "Read-only group; not replacing")
10513 (unless (gnus-request-replace-article
10514 ,article (car gnus-article-current)
10515 (current-buffer) t)
10516 (error "Couldn't replace article")))
10517 ;; The cache and backlog have to be flushed somewhat.
10518 (when gnus-keep-backlog
10519 (gnus-backlog-remove-article
10520 (car gnus-article-current) (cdr gnus-article-current)))
10521 (when gnus-use-cache
10522 (gnus-cache-update-article
10523 (car gnus-article-current) (cdr gnus-article-current)))))
10525 (put 'gnus-with-article 'lisp-indent-function 1)
10526 (put 'gnus-with-article 'edebug-form-spec '(form body))
10528 ;; Thread-based commands.
10530 (defun gnus-summary-articles-in-thread (&optional article)
10531 "Return a list of all articles in the current thread.
10532 If ARTICLE is non-nil, return all articles in the thread that starts
10533 with that article."
10534 (let* ((article (or article (gnus-summary-article-number)))
10535 (data (gnus-data-find-list article))
10536 (top-level (gnus-data-level (car data)))
10538 (cond ((null gnus-thread-operation-ignore-subject)
10539 (gnus-simplify-subject-re
10540 (mail-header-subject (gnus-data-header (car data)))))
10541 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10542 (gnus-simplify-subject-fuzzy
10543 (mail-header-subject (gnus-data-header (car data)))))
10545 (end-point (save-excursion
10546 (if (gnus-summary-go-to-next-thread)
10547 (point) (point-max))))
10550 (< (gnus-data-pos (car data)) end-point))
10551 (when (or (not top-subject)
10552 (string= top-subject
10553 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10554 (gnus-simplify-subject-fuzzy
10555 (mail-header-subject
10556 (gnus-data-header (car data))))
10557 (gnus-simplify-subject-re
10558 (mail-header-subject
10559 (gnus-data-header (car data)))))))
10560 (push (gnus-data-number (car data)) articles))
10561 (unless (and (setq data (cdr data))
10562 (> (gnus-data-level (car data)) top-level))
10564 ;; Return the list of articles.
10565 (nreverse articles)))
10567 (defun gnus-summary-rethread-current ()
10568 "Rethread the thread the current article is part of."
10570 (let* ((gnus-show-threads t)
10571 (article (gnus-summary-article-number))
10572 (id (mail-header-id (gnus-summary-article-header)))
10573 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10575 (error "No article on the current line"))
10576 (gnus-rebuild-thread id)
10577 (gnus-summary-goto-subject article)))
10579 (defun gnus-summary-reparent-thread ()
10580 "Make the current article child of the marked (or previous) article.
10582 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10583 is non-nil or the Subject: of both articles are the same."
10585 (unless (not (gnus-group-read-only-p))
10586 (error "The current newsgroup does not support article editing"))
10587 (unless (<= (length gnus-newsgroup-processable) 1)
10588 (error "No more than one article may be marked"))
10589 (save-window-excursion
10590 (let ((gnus-article-buffer " *reparent*")
10591 (current-article (gnus-summary-article-number))
10592 ;; First grab the marked article, otherwise one line up.
10593 (parent-article (if (not (null gnus-newsgroup-processable))
10594 (car gnus-newsgroup-processable)
10596 (if (eq (forward-line -1) 0)
10597 (gnus-summary-article-number)
10598 (error "Beginning of summary buffer"))))))
10599 (unless (not (eq current-article parent-article))
10600 (error "An article may not be self-referential"))
10601 (let ((message-id (mail-header-id
10602 (gnus-summary-article-header parent-article))))
10603 (unless (and message-id (not (equal message-id "")))
10604 (error "No message-id in desired parent"))
10605 (gnus-with-article current-article
10607 (goto-char (point-min))
10608 (message-narrow-to-head)
10609 (if (re-search-forward "^References: " nil t)
10611 (re-search-forward "^[^ \t]" nil t)
10614 (insert " " message-id))
10615 (insert "References: " message-id "\n"))))
10616 (set-buffer gnus-summary-buffer)
10617 (gnus-summary-unmark-all-processable)
10618 (gnus-summary-update-article current-article)
10619 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10620 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10621 (gnus-summary-rethread-current)
10622 (gnus-message 3 "Article %d is now the child of article %d"
10623 current-article parent-article)))))
10625 (defun gnus-summary-toggle-threads (&optional arg)
10626 "Toggle showing conversation threads.
10627 If ARG is positive number, turn showing conversation threads on."
10629 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10630 (setq gnus-show-threads
10631 (if (null arg) (not gnus-show-threads)
10632 (> (prefix-numeric-value arg) 0)))
10633 (gnus-summary-prepare)
10634 (gnus-summary-goto-subject current)
10635 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10636 (gnus-summary-position-point)))
10638 (defun gnus-summary-show-all-threads ()
10639 "Show all threads."
10642 (let ((buffer-read-only nil))
10643 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10644 (gnus-summary-position-point))
10646 (defun gnus-summary-show-thread ()
10647 "Show thread subtrees.
10648 Returns nil if no thread was there to be shown."
10650 (let ((buffer-read-only nil)
10652 (end (point-at-eol))
10653 ;; Leave point at bol
10654 (beg (progn (beginning-of-line) (point))))
10656 ;; Any hidden lines here?
10657 (search-forward "\r" end t)
10658 (subst-char-in-region beg end ?\^M ?\n t)
10660 (gnus-summary-position-point))))
10662 (defun gnus-summary-maybe-hide-threads ()
10663 "If requested, hide the threads that should be hidden."
10664 (when (and gnus-show-threads
10665 gnus-thread-hide-subtree)
10666 (gnus-summary-hide-all-threads
10667 (if (or (consp gnus-thread-hide-subtree)
10668 (functionp gnus-thread-hide-subtree))
10669 (gnus-make-predicate gnus-thread-hide-subtree)
10672 ;;; Hiding predicates.
10674 (defun gnus-article-unread-p (header)
10675 (memq (mail-header-number header) gnus-newsgroup-unreads))
10677 (defun gnus-article-unseen-p (header)
10678 (memq (mail-header-number header) gnus-newsgroup-unseen))
10680 (defun gnus-map-articles (predicate articles)
10681 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10682 (apply 'gnus-or (mapcar predicate
10683 (mapcar 'gnus-summary-article-header articles))))
10685 (defun gnus-summary-hide-all-threads (&optional predicate)
10686 "Hide all thread subtrees.
10687 If PREDICATE is supplied, threads that satisfy this predicate
10688 will not be hidden."
10691 (goto-char (point-min))
10694 (when (or (not predicate)
10696 predicate (gnus-summary-article-children)))
10697 (gnus-summary-hide-thread))
10698 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10699 (gnus-summary-position-point))
10701 (defun gnus-summary-hide-thread ()
10702 "Hide thread subtrees.
10703 If PREDICATE is supplied, threads that satisfy this predicate
10704 will not be hidden.
10705 Returns nil if no threads were there to be hidden."
10707 (let ((buffer-read-only nil)
10709 (article (gnus-summary-article-number)))
10711 ;; Go forward until either the buffer ends or the subthread
10713 (when (and (not (eobp))
10714 (or (zerop (gnus-summary-next-thread 1 t))
10715 (goto-char (point-max))))
10717 (if (and (> (point) start)
10718 (search-backward "\n" start t))
10720 (subst-char-in-region start (point) ?\n ?\^M)
10721 (gnus-summary-goto-subject article))
10725 (defun gnus-summary-go-to-next-thread (&optional previous)
10726 "Go to the same level (or less) next thread.
10727 If PREVIOUS is non-nil, go to previous thread instead.
10728 Return the article number moved to, or nil if moving was impossible."
10729 (let ((level (gnus-summary-thread-level))
10730 (way (if previous -1 1))
10733 (while (and (not (eobp))
10734 (< level (gnus-summary-thread-level)))
10735 (forward-line way))
10742 (gnus-summary-article-number)
10743 (goto-char beg)))))
10745 (defun gnus-summary-next-thread (n &optional silent)
10746 "Go to the same level next N'th thread.
10747 If N is negative, search backward instead.
10748 Returns the difference between N and the number of skips actually
10751 If SILENT, don't output messages."
10753 (let ((backward (< n 0))
10755 (while (and (> n 0)
10756 (gnus-summary-go-to-next-thread backward))
10759 (gnus-summary-position-point))
10760 (when (and (not silent) (/= 0 n))
10761 (gnus-message 7 "No more threads"))
10764 (defun gnus-summary-prev-thread (n)
10765 "Go to the same level previous N'th thread.
10766 Returns the difference between N and the number of skips actually
10769 (gnus-summary-next-thread (- n)))
10771 (defun gnus-summary-go-down-thread ()
10772 "Go down one level in the current thread."
10773 (let ((children (gnus-summary-article-children)))
10775 (gnus-summary-goto-subject (car children)))))
10777 (defun gnus-summary-go-up-thread ()
10778 "Go up one level in the current thread."
10779 (let ((parent (gnus-summary-article-parent)))
10781 (gnus-summary-goto-subject parent))))
10783 (defun gnus-summary-down-thread (n)
10784 "Go down thread N steps.
10785 If N is negative, go up instead.
10786 Returns the difference between N and how many steps down that were
10791 (while (and (> n 0)
10792 (if up (gnus-summary-go-up-thread)
10793 (gnus-summary-go-down-thread)))
10795 (gnus-summary-position-point)
10797 (gnus-message 7 "Can't go further"))
10800 (defun gnus-summary-up-thread (n)
10801 "Go up thread N steps.
10802 If N is negative, go down instead.
10803 Returns the difference between N and how many steps down that were
10806 (gnus-summary-down-thread (- n)))
10808 (defun gnus-summary-top-thread ()
10809 "Go to the top of the thread."
10811 (while (gnus-summary-go-up-thread))
10812 (gnus-summary-article-number))
10814 (defun gnus-summary-kill-thread (&optional unmark)
10815 "Mark articles under current thread as read.
10816 If the prefix argument is positive, remove any kinds of marks.
10817 If the prefix argument is negative, tick articles instead."
10820 (setq unmark (prefix-numeric-value unmark)))
10821 (let ((articles (gnus-summary-articles-in-thread)))
10823 ;; Expand the thread.
10824 (gnus-summary-show-thread)
10825 ;; Mark all the articles.
10827 (gnus-summary-goto-subject (car articles))
10828 (cond ((null unmark)
10829 (gnus-summary-mark-article-as-read gnus-killed-mark))
10831 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10833 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10834 (setq articles (cdr articles))))
10835 ;; Hide killed subtrees.
10837 gnus-thread-hide-killed
10838 (gnus-summary-hide-thread))
10839 ;; If marked as read, go to next unread subject.
10840 (when (null unmark)
10841 ;; Go to next unread subject.
10842 (gnus-summary-next-subject 1 t)))
10843 (gnus-set-mode-line 'summary))
10845 ;; Summary sorting commands
10847 (defun gnus-summary-sort-by-number (&optional reverse)
10848 "Sort the summary buffer by article number.
10849 Argument REVERSE means reverse order."
10851 (gnus-summary-sort 'number reverse))
10853 (defun gnus-summary-sort-by-random (&optional reverse)
10854 "Randomize the order in the summary buffer.
10855 Argument REVERSE means to randomize in reverse order."
10857 (gnus-summary-sort 'random reverse))
10859 (defun gnus-summary-sort-by-author (&optional reverse)
10860 "Sort the summary buffer by author name alphabetically.
10861 If `case-fold-search' is non-nil, case of letters is ignored.
10862 Argument REVERSE means reverse order."
10864 (gnus-summary-sort 'author reverse))
10866 (defun gnus-summary-sort-by-subject (&optional reverse)
10867 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10868 If `case-fold-search' is non-nil, case of letters is ignored.
10869 Argument REVERSE means reverse order."
10871 (gnus-summary-sort 'subject reverse))
10873 (defun gnus-summary-sort-by-date (&optional reverse)
10874 "Sort the summary buffer by date.
10875 Argument REVERSE means reverse order."
10877 (gnus-summary-sort 'date reverse))
10879 (defun gnus-summary-sort-by-score (&optional reverse)
10880 "Sort the summary buffer by score.
10881 Argument REVERSE means reverse order."
10883 (gnus-summary-sort 'score reverse))
10885 (defun gnus-summary-sort-by-lines (&optional reverse)
10886 "Sort the summary buffer by the number of lines.
10887 Argument REVERSE means reverse order."
10889 (gnus-summary-sort 'lines reverse))
10891 (defun gnus-summary-sort-by-chars (&optional reverse)
10892 "Sort the summary buffer by article length.
10893 Argument REVERSE means reverse order."
10895 (gnus-summary-sort 'chars reverse))
10897 (defun gnus-summary-sort-by-original (&optional reverse)
10898 "Sort the summary buffer using the default sorting method.
10899 Argument REVERSE means reverse order."
10901 (let* ((buffer-read-only)
10902 (gnus-summary-prepare-hook nil))
10903 ;; We do the sorting by regenerating the threads.
10904 (gnus-summary-prepare)
10905 ;; Hide subthreads if needed.
10906 (gnus-summary-maybe-hide-threads)))
10908 (defun gnus-summary-sort (predicate reverse)
10909 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10910 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10911 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10912 (gnus-thread-sort-functions
10917 (gnus-sort-gathered-threads-function
10918 gnus-thread-sort-functions)
10919 (gnus-article-sort-functions
10923 (,article t2 t1))))
10925 (gnus-summary-prepare-hook nil))
10926 ;; We do the sorting by regenerating the threads.
10927 (gnus-summary-prepare)
10928 ;; Hide subthreads if needed.
10929 (gnus-summary-maybe-hide-threads)))
10931 ;; Summary saving commands.
10933 (defun gnus-summary-save-article (&optional n not-saved)
10934 "Save the current article using the default saver function.
10935 If N is a positive number, save the N next articles.
10936 If N is a negative number, save the N previous articles.
10937 If N is nil and any articles have been marked with the process mark,
10938 save those articles instead.
10939 The variable `gnus-default-article-saver' specifies the saver function."
10941 (let* ((articles (gnus-summary-work-articles n))
10942 (save-buffer (save-excursion
10943 (nnheader-set-temp-buffer " *Gnus Save*")))
10944 (num (length articles))
10946 (dolist (article articles)
10947 (setq header (gnus-summary-article-header article))
10948 (if (not (vectorp header))
10949 ;; This is a pseudo-article.
10950 (if (assq 'name header)
10951 (gnus-copy-file (cdr (assq 'name header)))
10952 (gnus-message 1 "Article %d is unsaveable" article))
10953 ;; This is a real article.
10954 (save-window-excursion
10955 (let ((gnus-display-mime-function nil)
10956 (gnus-article-prepare-hook nil))
10957 (gnus-summary-select-article t nil nil article)))
10959 (set-buffer save-buffer)
10961 (insert-buffer-substring gnus-original-article-buffer))
10962 (setq file (gnus-article-save save-buffer file num))
10963 (gnus-summary-remove-process-mark article)
10965 (gnus-summary-set-saved-mark article))))
10966 (gnus-kill-buffer save-buffer)
10967 (gnus-summary-position-point)
10968 (gnus-set-mode-line 'summary)
10971 (defun gnus-summary-pipe-output (&optional arg headers)
10972 "Pipe the current article to a subprocess.
10973 If N is a positive number, pipe the N next articles.
10974 If N is a negative number, pipe the N previous articles.
10975 If N is nil and any articles have been marked with the process mark,
10976 pipe those articles instead.
10977 If HEADERS (the symbolic prefix), include the headers, too."
10978 (interactive (gnus-interactive "P\ny"))
10979 (require 'gnus-art)
10980 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10981 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10982 (gnus-summary-save-article arg t))
10983 (let ((buffer (get-buffer "*Shell Command Output*")))
10985 (not (zerop (buffer-size buffer))))
10986 (gnus-configure-windows 'pipe))))
10988 (defun gnus-summary-save-article-mail (&optional arg)
10989 "Append the current article to an mail file.
10990 If N is a positive number, save the N next articles.
10991 If N is a negative number, save the N previous articles.
10992 If N is nil and any articles have been marked with the process mark,
10993 save those articles instead."
10995 (require 'gnus-art)
10996 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10997 (gnus-summary-save-article arg)))
10999 (defun gnus-summary-save-article-rmail (&optional arg)
11000 "Append the current article to an rmail file.
11001 If N is a positive number, save the N next articles.
11002 If N is a negative number, save the N previous articles.
11003 If N is nil and any articles have been marked with the process mark,
11004 save those articles instead."
11006 (require 'gnus-art)
11007 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11008 (gnus-summary-save-article arg)))
11010 (defun gnus-summary-save-article-file (&optional arg)
11011 "Append the current article to a file.
11012 If N is a positive number, save the N next articles.
11013 If N is a negative number, save the N previous articles.
11014 If N is nil and any articles have been marked with the process mark,
11015 save those articles instead."
11017 (require 'gnus-art)
11018 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11019 (gnus-summary-save-article arg)))
11021 (defun gnus-summary-write-article-file (&optional arg)
11022 "Write the current article to a file, deleting the previous file.
11023 If N is a positive number, save the N next articles.
11024 If N is a negative number, save the N previous articles.
11025 If N is nil and any articles have been marked with the process mark,
11026 save those articles instead."
11028 (require 'gnus-art)
11029 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11030 (gnus-summary-save-article arg)))
11032 (defun gnus-summary-save-article-body-file (&optional arg)
11033 "Append the current article body to a file.
11034 If N is a positive number, save the N next articles.
11035 If N is a negative number, save the N previous articles.
11036 If N is nil and any articles have been marked with the process mark,
11037 save those articles instead."
11039 (require 'gnus-art)
11040 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11041 (gnus-summary-save-article arg)))
11043 (defun gnus-summary-muttprint (&optional arg)
11044 "Print the current article using Muttprint.
11045 If N is a positive number, save the N next articles.
11046 If N is a negative number, save the N previous articles.
11047 If N is nil and any articles have been marked with the process mark,
11048 save those articles instead."
11050 (require 'gnus-art)
11051 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11052 (gnus-summary-save-article arg t)))
11054 (defun gnus-summary-pipe-message (program)
11055 "Pipe the current article through PROGRAM."
11056 (interactive "sProgram: ")
11057 (gnus-summary-select-article)
11058 (let ((mail-header-separator ""))
11059 (gnus-eval-in-buffer-window gnus-article-buffer
11062 (let ((start (window-start))
11064 (message-pipe-buffer-body program)
11065 (set-window-start (get-buffer-window (current-buffer)) start))))))
11067 (defun gnus-get-split-value (methods)
11068 "Return a value based on the split METHODS."
11069 (let (split-name method result match)
11072 (set-buffer gnus-original-article-buffer)
11074 (nnheader-narrow-to-headers)
11075 (while (and methods (not split-name))
11076 (goto-char (point-min))
11077 (setq method (pop methods))
11078 (setq match (car method))
11081 ;; Regular expression.
11083 (re-search-forward match nil t)))
11088 (setq result (funcall match gnus-newsgroup-name))))
11093 (setq result (eval match)))))
11094 (setq split-name (cdr method))
11095 (cond ((stringp result)
11096 (push (expand-file-name
11097 result gnus-article-save-directory)
11100 (setq split-name (append result split-name)))))))))
11101 (nreverse split-name)))
11103 (defun gnus-valid-move-group-p (group)
11104 (and (boundp group)
11105 (symbol-name group)
11106 (symbol-value group)
11107 (gnus-get-function (gnus-find-method-for-group
11108 (symbol-name group)) 'request-accept-article t)))
11110 (defun gnus-read-move-group-name (prompt default articles prefix)
11111 "Read a group name."
11112 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11113 (minibuffer-confirm-incomplete nil) ; XEmacs
11115 (format "%s %s to:"
11117 (if (> (length articles) 1)
11118 (format "these %d articles" (length articles))
11123 (gnus-completing-read-with-default
11126 'gnus-valid-move-group-p
11128 'gnus-group-history))
11129 ((= 1 (length split-name))
11130 (gnus-completing-read-with-default
11131 (car split-name) prom
11133 'gnus-valid-move-group-p
11135 'gnus-group-history))
11137 (gnus-completing-read-with-default
11139 (mapcar 'list (nreverse split-name))
11141 'gnus-group-history))))
11142 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11144 (if (or (string= to-newsgroup "")
11145 (string= to-newsgroup prefix))
11146 (setq to-newsgroup default))
11147 (unless to-newsgroup
11148 (error "No group name entered"))
11149 (or (gnus-active to-newsgroup)
11150 (gnus-activate-group to-newsgroup nil nil to-method)
11151 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11153 (or (and (gnus-request-create-group to-newsgroup to-method)
11154 (gnus-activate-group
11155 to-newsgroup nil nil to-method)
11156 (gnus-subscribe-group to-newsgroup))
11157 (error "Couldn't create group %s" to-newsgroup)))
11158 (error "No such group: %s" to-newsgroup)))
11161 (defun gnus-summary-save-parts (type dir n &optional reverse)
11162 "Save parts matching TYPE to DIR.
11163 If REVERSE, save parts that do not match TYPE."
11165 (list (read-string "Save parts of type: "
11166 (or (car gnus-summary-save-parts-type-history)
11167 gnus-summary-save-parts-default-mime)
11168 'gnus-summary-save-parts-type-history)
11169 (setq gnus-summary-save-parts-last-directory
11170 (read-file-name "Save to directory: "
11171 gnus-summary-save-parts-last-directory
11173 current-prefix-arg))
11174 (gnus-summary-iterate n
11175 (let ((gnus-display-mime-function nil)
11176 (gnus-inhibit-treatment t))
11177 (gnus-summary-select-article))
11179 (set-buffer gnus-article-buffer)
11180 (let ((handles (or gnus-article-mime-handles
11181 (mm-dissect-buffer nil gnus-article-loose-mime)
11182 (and gnus-article-emulate-mime
11183 (mm-uu-dissect)))))
11185 (gnus-summary-save-parts-1 type dir handles reverse)
11186 (unless gnus-article-mime-handles ;; Don't destroy this case.
11187 (mm-destroy-parts handles)))))))
11189 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11190 (if (stringp (car handle))
11191 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11194 (not (string-match type (mm-handle-media-type handle)))
11195 (string-match type (mm-handle-media-type handle)))
11196 (let ((file (expand-file-name
11198 mm-file-name-rewrite-functions
11199 (file-name-nondirectory
11201 (mail-content-type-get
11202 (mm-handle-disposition handle) 'filename)
11203 (mail-content-type-get
11204 (mm-handle-type handle) 'name)
11205 (concat gnus-newsgroup-name
11206 "." (number-to-string
11207 (cdr gnus-article-current))))))
11209 (unless (file-exists-p file)
11210 (mm-save-part-to-file handle file))))))
11212 ;; Summary extract commands
11214 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11215 (let ((buffer-read-only nil)
11216 (article (gnus-summary-article-number))
11218 (unless (gnus-summary-goto-subject article)
11219 (error "No such article: %d" article))
11220 (gnus-summary-position-point)
11221 ;; If all commands are to be bunched up on one line, we collect
11223 (unless gnus-view-pseudos-separately
11224 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11227 (setq action (cdr (assq 'action (car ps))))
11228 (setq files (list (cdr (assq 'name (car ps)))))
11229 (while (and ps (cdr ps)
11230 (string= (or action "1")
11231 (or (cdr (assq 'action (cadr ps))) "2")))
11232 (push (cdr (assq 'name (cadr ps))) files)
11233 (setcdr ps (cddr ps)))
11235 (when (not (string-match "%s" action))
11238 (when (assq 'execute (car ps))
11239 (setcdr (assq 'execute (car ps))
11240 (funcall (if (string-match "%s" action)
11247 (shell-quote-argument f)))
11249 (setq ps (cdr ps)))))
11250 (if (and gnus-view-pseudos (not not-view))
11252 (when (assq 'execute (car pslist))
11253 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11254 (eq gnus-view-pseudos 'not-confirm)))
11255 (setq pslist (cdr pslist)))
11258 (setq after-article (or (cdr (assq 'article (car pslist)))
11259 (gnus-summary-article-number)))
11260 (gnus-summary-goto-subject after-article)
11263 (insert " " (file-name-nondirectory
11264 (cdr (assq 'name (car pslist))))
11265 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11267 (forward-line -1) ; back to `b'
11268 (gnus-add-text-properties
11269 b (1- e) (list 'gnus-number gnus-reffed-article-number
11270 gnus-mouse-face-prop gnus-mouse-face))
11272 after-article gnus-reffed-article-number
11273 gnus-unread-mark b (car pslist) 0 (- e b))
11274 (setq gnus-newsgroup-unreads
11275 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11276 gnus-reffed-article-number))
11277 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11278 (setq pslist (cdr pslist)))))))
11280 (defun gnus-pseudos< (p1 p2)
11281 (let ((c1 (cdr (assq 'action p1)))
11282 (c2 (cdr (assq 'action p2))))
11283 (and c1 c2 (string< c1 c2))))
11285 (defun gnus-request-pseudo-article (props)
11286 (cond ((assq 'execute props)
11287 (gnus-execute-command (cdr (assq 'execute props)))))
11288 (let ((gnus-current-article (gnus-summary-article-number)))
11289 (gnus-run-hooks 'gnus-mark-article-hook)))
11291 (defun gnus-execute-command (command &optional automatic)
11293 (gnus-article-setup-buffer)
11294 (set-buffer gnus-article-buffer)
11295 (setq buffer-read-only nil)
11296 (let ((command (if automatic command
11297 (read-string "Command: " (cons command 0)))))
11299 (insert "$ " command "\n\n")
11300 (if gnus-view-pseudo-asynchronously
11301 (start-process "gnus-execute" (current-buffer) shell-file-name
11302 shell-command-switch command)
11303 (call-process shell-file-name nil t nil
11304 shell-command-switch command)))))
11306 ;; Summary kill commands.
11308 (defun gnus-summary-edit-global-kill (article)
11309 "Edit the \"global\" kill file."
11310 (interactive (list (gnus-summary-article-number)))
11311 (gnus-group-edit-global-kill article))
11313 (defun gnus-summary-edit-local-kill ()
11314 "Edit a local kill file applied to the current newsgroup."
11316 (setq gnus-current-headers (gnus-summary-article-header))
11317 (gnus-group-edit-local-kill
11318 (gnus-summary-article-number) gnus-newsgroup-name))
11320 ;;; Header reading.
11322 (defun gnus-read-header (id &optional header)
11323 "Read the headers of article ID and enter them into the Gnus system."
11324 (let ((group gnus-newsgroup-name)
11325 (gnus-override-method
11327 gnus-override-method
11328 (and (gnus-news-group-p gnus-newsgroup-name)
11329 (car (gnus-refer-article-methods)))))
11331 ;; First we check to see whether the header in question is already
11334 ;; This is a Message-ID.
11335 (setq header (or header (gnus-id-to-header id)))
11336 ;; This is an article number.
11337 (setq header (or header (gnus-summary-article-header id))))
11339 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11340 ;; We have found the header.
11342 ;; We have to really fetch the header to this article.
11344 (set-buffer nntp-server-buffer)
11345 (when (setq where (gnus-request-head id group))
11346 (nnheader-fold-continuation-lines)
11347 (goto-char (point-max))
11349 (goto-char (point-min))
11353 ((cdr where) (cdr where))
11354 (header (mail-header-number header))
11355 (t gnus-reffed-article-number))
11357 (insert " Article retrieved.\n"))
11358 (if (or (not where)
11359 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11360 () ; Malformed head.
11361 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11362 (when (and (stringp id)
11363 (not (string= (gnus-group-real-name group)
11365 ;; If we fetched by Message-ID and the article came
11366 ;; from a different group, we fudge some bogus article
11367 ;; numbers for this article.
11368 (mail-header-set-number header gnus-reffed-article-number))
11370 (set-buffer gnus-summary-buffer)
11371 (decf gnus-reffed-article-number)
11372 (gnus-remove-header (mail-header-number header))
11373 (push header gnus-newsgroup-headers)
11374 (setq gnus-current-headers header)
11375 (push (mail-header-number header) gnus-newsgroup-limit)))
11378 (defun gnus-remove-header (number)
11379 "Remove header NUMBER from `gnus-newsgroup-headers'."
11380 (if (and gnus-newsgroup-headers
11381 (= number (mail-header-number (car gnus-newsgroup-headers))))
11382 (pop gnus-newsgroup-headers)
11383 (let ((headers gnus-newsgroup-headers))
11384 (while (and (cdr headers)
11385 (not (= number (mail-header-number (cadr headers)))))
11387 (when (cdr headers)
11388 (setcdr headers (cddr headers))))))
11391 ;;; summary highlights
11394 (defun gnus-highlight-selected-summary ()
11395 "Highlight selected article in summary buffer."
11396 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11397 (when gnus-summary-selected-face
11399 (let* ((beg (point-at-bol))
11400 (end (point-at-eol))
11401 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11402 (from (if (get-text-property beg gnus-mouse-face-prop)
11404 (or (next-single-property-change
11405 beg gnus-mouse-face-prop nil end)
11410 (or (next-single-property-change
11411 from gnus-mouse-face-prop nil end)
11413 ;; If no mouse-face prop on line we will have to = from = end,
11414 ;; so we highlight the entire line instead.
11415 (when (= (+ to 2) from)
11418 (if gnus-newsgroup-selected-overlay
11419 ;; Move old overlay.
11421 gnus-newsgroup-selected-overlay from to (current-buffer))
11422 ;; Create new overlay.
11424 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11425 'face gnus-summary-selected-face))))))
11427 (defvar gnus-summary-highlight-line-cached nil)
11428 (defvar gnus-summary-highlight-line-trigger nil)
11430 (defun gnus-summary-highlight-line-0 ()
11431 (if (and (eq gnus-summary-highlight-line-trigger
11432 gnus-summary-highlight)
11433 gnus-summary-highlight-line-cached)
11434 gnus-summary-highlight-line-cached
11435 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11436 gnus-summary-highlight-line-cached
11437 (let* ((cond (list 'cond))
11439 (list gnus-summary-highlight))
11441 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11445 (gnus-byte-compile (list 'lambda nil cond))))))
11447 (defun gnus-summary-highlight-line ()
11448 "Highlight current line according to `gnus-summary-highlight'."
11449 (let* ((beg (point-at-bol))
11450 (article (or (gnus-summary-article-number) gnus-current-article))
11451 (score (or (cdr (assq article
11452 gnus-newsgroup-scored))
11453 gnus-summary-default-score 0))
11454 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11455 (inhibit-read-only t)
11456 (default gnus-summary-default-score)
11457 (default-high gnus-summary-default-high-score)
11458 (default-low gnus-summary-default-low-score)
11459 (uncached (and gnus-summary-use-undownloaded-faces
11460 (memq article gnus-newsgroup-undownloaded)
11461 (not (memq article gnus-newsgroup-cached)))))
11462 (let ((face (funcall (gnus-summary-highlight-line-0))))
11463 (unless (eq face (get-text-property beg 'face))
11464 (gnus-put-text-property-excluding-characters-with-faces
11465 beg (point-at-eol) 'face
11466 (setq face (if (boundp face) (symbol-value face) face)))
11467 (when gnus-summary-highlight-line-function
11468 (funcall gnus-summary-highlight-line-function article face))))))
11470 (defun gnus-update-read-articles (group unread &optional compute)
11471 "Update the list of read articles in GROUP.
11472 UNREAD is a sorted list."
11473 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11474 (info (gnus-get-info group))
11477 (if (or (not info) (not active))
11478 ;; There is no info on this group if it was, in fact,
11479 ;; killed. Gnus stores no information on killed groups, so
11480 ;; there's nothing to be done.
11481 ;; One could store the information somewhere temporarily,
11482 ;; perhaps... Hmmm...
11484 ;; Remove any negative articles numbers.
11485 (while (and unread (< (car unread) 0))
11486 (setq unread (cdr unread)))
11487 ;; Remove any expired article numbers
11488 (while (and unread (< (car unread) (car active)))
11489 (setq unread (cdr unread)))
11490 ;; Compute the ranges of read articles by looking at the list of
11491 ;; unread articles.
11493 (when (/= (car unread) prev)
11494 (push (if (= prev (1- (car unread))) prev
11495 (cons prev (1- (car unread))))
11497 (setq prev (1+ (car unread)))
11498 (setq unread (cdr unread)))
11499 (when (<= prev (cdr active))
11500 (push (cons prev (cdr active)) read))
11501 (setq read (if (> (length read) 1) (nreverse read) read))
11506 ;; Propagate the read marks to the backend.
11507 (when (gnus-check-backend-function 'request-set-mark group)
11508 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11509 (add (gnus-remove-from-range read (gnus-info-read info))))
11511 (unless (gnus-check-group group)
11512 (error "Can't open server for %s" group))
11513 (gnus-request-set-mark
11514 group (delq nil (list (if add (list add 'add '(read)))
11515 (if del (list del 'del '(read))))))
11517 `(gnus-request-set-mark
11520 (if del (list del 'add '(read)))
11521 (if add (list add 'del '(read))))))))))
11522 (set-buffer gnus-group-buffer)
11523 (gnus-undo-register
11525 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11526 (gnus-info-set-read ',info ',(gnus-info-read info))
11527 (gnus-get-unread-articles-in-group ',info
11528 (gnus-active ,group))
11529 (gnus-group-update-group ,group t)
11531 ;; Enter this list into the group info.
11532 (gnus-info-set-read info read)
11533 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11534 (gnus-get-unread-articles-in-group info (gnus-active group))
11537 (defun gnus-offer-save-summaries ()
11538 "Offer to save all active summary buffers."
11540 ;; Go through all buffers and find all summaries.
11541 (dolist (buffer (buffer-list))
11542 (when (and (setq buffer (buffer-name buffer))
11543 (string-match "Summary" buffer)
11544 (with-current-buffer buffer
11545 ;; We check that this is, indeed, a summary buffer.
11546 (and (eq major-mode 'gnus-summary-mode)
11547 ;; Also make sure this isn't bogus.
11548 gnus-newsgroup-prepared
11549 ;; Also make sure that this isn't a
11550 ;; dead summary buffer.
11551 (not gnus-dead-summary-mode))))
11552 (push buffer buffers)))
11553 ;; Go through all these summary buffers and offer to save them.
11557 "Update summary buffer %s? "
11559 (switch-to-buffer buf)
11560 (gnus-summary-exit))
11564 ;;; @ for mime-partial
11567 (defun gnus-request-partial-message ()
11569 (let ((number (gnus-summary-article-number))
11570 (group gnus-newsgroup-name)
11571 (mother gnus-article-buffer))
11572 (set-buffer (get-buffer-create " *Partial Article*"))
11574 (setq mime-preview-buffer mother)
11575 (gnus-request-article-this-buffer number group)
11576 (mime-parse-buffer)
11579 (autoload 'mime-combine-message/partial-pieces-automatically
11581 "Internal method to combine message/partial messages automatically.")
11583 (mime-add-condition
11584 'action '((type . message)(subtype . partial)
11585 (major-mode . gnus-original-article-mode)
11586 (method . mime-combine-message/partial-pieces-automatically)
11587 (summary-buffer-exp . gnus-summary-buffer)
11588 (request-partial-message-method . gnus-request-partial-message)
11592 ;;; @ for message/rfc822
11595 (defun gnus-mime-extract-message/rfc822 (entity situation)
11596 "Burst a forwarded article."
11598 (set-buffer gnus-summary-buffer)
11599 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11600 gnus-newsgroup-name 'gnus-group-history))
11601 (gnus-group-marked (list group))
11604 (mime-insert-entity-content entity)
11605 (setq article (gnus-request-accept-article group)))
11606 (when (and (consp article)
11607 (numberp (setq article (cdr article))))
11608 (setq info (gnus-get-info group))
11609 (gnus-info-set-read info
11610 (gnus-remove-from-range (gnus-info-read info)
11612 (when (string-equal group gnus-newsgroup-name)
11614 (let (gnus-show-threads)
11615 (gnus-summary-goto-subject article t))
11616 (gnus-summary-clear-mark-forward 1))
11617 (set-buffer gnus-group-buffer)
11618 (gnus-group-get-new-news-this-group nil t)))))
11620 (mime-add-condition
11621 'action '((type . message)(subtype . rfc822)
11622 (major-mode . gnus-original-article-mode)
11623 (method . gnus-mime-extract-message/rfc822)
11627 (mime-add-condition
11628 'action '((type . message)(subtype . news)
11629 (major-mode . gnus-original-article-mode)
11630 (method . gnus-mime-extract-message/rfc822)
11634 (defun gnus-mime-extract-multipart (entity situation)
11635 (let ((children (mime-entity-children entity))
11636 mime-acting-situation-to-override
11639 (mime-play-entity (car children)
11640 (cons (assq 'mode situation)
11641 mime-acting-situation-to-override))
11642 (setq children (cdr children)))
11643 (if (setq f (cdr (assq 'after-method
11644 mime-acting-situation-to-override)))
11648 (mime-add-condition
11649 'action '((type . multipart)
11650 (method . gnus-mime-extract-multipart)
11659 (defun gnus-summary-inherit-default-charset ()
11660 "Import `default-mime-charset' from summary buffer.
11661 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11663 (if (buffer-live-p gnus-summary-buffer)
11664 (let (d-m-c d-m-c-u)
11665 (with-current-buffer gnus-summary-buffer
11666 (setq d-m-c (if (local-variable-p 'default-mime-charset
11667 gnus-summary-buffer)
11668 default-mime-charset
11671 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11672 gnus-summary-buffer)
11673 (symbol-value 'default-mime-charset-unlimited)
11676 (kill-local-variable 'default-mime-charset)
11677 (set (make-local-variable 'default-mime-charset) d-m-c))
11679 (kill-local-variable 'default-mime-charset-unlimited)
11680 (set (make-local-variable 'default-mime-charset-unlimited)
11683 (defun gnus-summary-setup-default-charset ()
11684 "Setup newsgroup default charset."
11685 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11687 (setq gnus-newsgroup-charset nil)
11688 (set (make-local-variable 'default-mime-charset) nil)
11689 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11690 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11691 (let ((ignored-charsets
11692 (or gnus-newsgroup-ephemeral-ignored-charsets
11694 (and gnus-newsgroup-name
11695 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11696 gnus-newsgroup-ignored-charsets)))
11698 (setq gnus-newsgroup-charset
11699 (or gnus-newsgroup-ephemeral-charset
11700 (when (and gnus-newsgroup-name
11701 (setq charset (gnus-parameter-charset
11702 gnus-newsgroup-name)))
11703 (make-local-variable 'default-mime-charset)
11704 (setq default-mime-charset charset))
11705 gnus-default-charset))
11706 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11707 ignored-charsets))))
11713 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11714 "Display the current article buffer fully MIME-buttonized.
11715 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11716 treated as multipart/mixed."
11718 (require 'gnus-art)
11719 (let ((gnus-unbuttonized-mime-types nil)
11720 (gnus-mime-display-multipart-as-mixed show-all-parts))
11721 (gnus-summary-show-article)))
11723 (defun gnus-summary-repair-multipart (article)
11724 "Add a Content-Type header to a multipart article without one."
11725 (interactive (list (gnus-summary-article-number)))
11726 (gnus-with-article article
11727 (message-narrow-to-head)
11728 (message-remove-header "Mime-Version")
11729 (goto-char (point-max))
11730 (insert "Mime-Version: 1.0\n")
11732 (when (search-forward "\n--" nil t)
11733 (let ((separator (buffer-substring (point) (point-at-eol))))
11734 (message-narrow-to-head)
11735 (message-remove-header "Content-Type")
11736 (goto-char (point-max))
11737 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11740 (let (gnus-mark-article-hook)
11741 (gnus-summary-select-article t t nil article)))
11743 (defun gnus-summary-toggle-display-buttonized ()
11744 "Toggle the buttonizing of the article buffer."
11746 (require 'gnus-art)
11747 (if (setq gnus-inhibit-mime-unbuttonizing
11748 (not gnus-inhibit-mime-unbuttonizing))
11749 (let ((gnus-unbuttonized-mime-types nil))
11750 (gnus-summary-show-article))
11751 (gnus-summary-show-article)))
11754 ;;; Intelli-mouse commmands
11757 (defun gnus-wheel-summary-scroll (event)
11759 (let ((amount (if (memq 'shift (event-modifiers event))
11760 (car gnus-wheel-scroll-amount)
11761 (cdr gnus-wheel-scroll-amount)))
11762 (direction (- (* (static-if (featurep 'xemacs)
11763 (event-button event)
11764 (cond ((eq 'mouse-4 (event-basic-type event))
11766 ((eq 'mouse-5 (event-basic-type event))
11770 (gnus-summary-scroll-up (* amount direction))
11771 (when (gnus-eval-in-buffer-window gnus-article-buffer
11774 (and (if (< 0 direction)
11775 (gnus-article-next-page 0)
11776 (gnus-article-prev-page 0)
11778 (if (setq edge (get-text-property
11779 (point-min) 'gnus-wheel-edge))
11780 (setq edge (* edge direction))
11783 (let ((buffer-read-only nil)
11784 (inhibit-read-only t))
11785 (put-text-property (point-min) (point-max)
11786 'gnus-wheel-edge direction)
11788 (or (> edge gnus-wheel-edge-resistance)
11789 (let ((buffer-read-only nil)
11790 (inhibit-read-only t))
11791 (put-text-property (point-min) (point-max)
11793 (* (1+ edge) direction))
11795 (eq last-command 'gnus-wheel-summary-scroll))))
11796 (gnus-summary-next-article nil nil (minusp direction)))))
11798 (defun gnus-wheel-install ()
11799 "Enable mouse wheel support on summary window."
11800 (when gnus-use-wheel
11802 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11804 (define-key gnus-summary-mode-map key
11805 'gnus-wheel-summary-scroll)))))
11807 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11810 ;;; Traditional PGP commmands
11813 (defun gnus-summary-decrypt-article (&optional force)
11814 "Decrypt the current article in traditional PGP way.
11815 This will have permanent effect only in mail groups.
11816 If FORCE is non-nil, allow editing of articles even in read-only
11819 (gnus-summary-select-article t)
11820 (gnus-eval-in-buffer-window gnus-article-buffer
11824 (goto-char (point-min))
11825 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11826 (error "Not a traditional PGP message!"))
11827 (let ((armor-start (match-beginning 0)))
11828 (if (and (pgg-decrypt-region armor-start (point-max))
11829 (or force (not (gnus-group-read-only-p))))
11830 (let ((inhibit-read-only t)
11832 (delete-region armor-start
11834 (re-search-forward "^-+END PGP" nil t)
11835 (beginning-of-line 2)
11837 (insert-buffer-substring pgg-output-buffer))))))))
11839 (defun gnus-summary-verify-article ()
11840 "Verify the current article in traditional PGP way."
11843 (set-buffer gnus-original-article-buffer)
11844 (goto-char (point-min))
11845 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11846 (error "Not a traditional PGP message!"))
11847 (re-search-forward "^-+END PGP" nil t)
11848 (beginning-of-line 2)
11849 (call-interactively (function pgg-verify-region))))
11852 ;;; Generic summary marking commands
11855 (defvar gnus-summary-marking-alist
11856 '((read gnus-del-mark "d")
11857 (unread gnus-unread-mark "u")
11858 (ticked gnus-ticked-mark "!")
11859 (dormant gnus-dormant-mark "?")
11860 (expirable gnus-expirable-mark "e"))
11861 "An alist of names/marks/keystrokes.")
11863 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11864 (defvar gnus-summary-mark-map)
11866 (defun gnus-summary-make-all-marking-commands ()
11867 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11868 (dolist (elem gnus-summary-marking-alist)
11869 (apply 'gnus-summary-make-marking-command elem)))
11871 (defun gnus-summary-make-marking-command (name mark keystroke)
11872 (let ((map (make-sparse-keymap)))
11873 (define-key gnus-summary-generic-mark-map keystroke map)
11874 (dolist (lway `((next "next" next nil "n")
11875 (next-unread "next unread" next t "N")
11876 (prev "previous" prev nil "p")
11877 (prev-unread "previous unread" prev t "P")
11878 (nomove "" nil nil ,keystroke)))
11879 (let ((func (gnus-summary-make-marking-command-1
11880 mark (car lway) lway name)))
11881 (setq func (eval func))
11882 (define-key map (nth 4 lway) func)))))
11884 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11886 (format "gnus-summary-put-mark-as-%s%s"
11887 name (if (eq way 'nomove)
11889 (concat "-" (symbol-name way)))))
11892 "Mark the current article as %s%s.
11893 If N, the prefix, then repeat N times.
11894 If N is negative, move in reverse order.
11895 The difference between N and the actual number of articles marked is
11897 name (car (cdr lway)))
11899 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11901 (defun gnus-summary-generic-mark (n mark move unread)
11902 "Mark N articles with MARK."
11903 (unless (eq major-mode 'gnus-summary-mode)
11904 (error "This command can only be used in the summary buffer"))
11905 (gnus-summary-show-thread)
11908 ((eq move 'next) 1)
11909 ((eq move 'prev) -1)
11911 (if (zerop nummove)
11915 nummove (* -1 nummove))))
11916 (while (and (> n 0)
11917 (gnus-summary-mark-article nil mark)
11918 (zerop (gnus-summary-next-subject nummove unread t)))
11921 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11922 (gnus-summary-recenter)
11923 (gnus-summary-position-point)
11924 (gnus-set-mode-line 'summary)
11927 (defun gnus-summary-insert-articles (articles)
11928 (when (setq articles
11929 (gnus-sorted-difference articles
11930 (mapcar (lambda (h)
11931 (mail-header-number h))
11932 gnus-newsgroup-headers)))
11933 (setq gnus-newsgroup-headers
11935 gnus-newsgroup-headers
11936 (gnus-fetch-headers articles)
11937 'gnus-article-sort-by-number))
11938 ;; Suppress duplicates?
11939 (when gnus-suppress-duplicates
11940 (gnus-dup-suppress-articles))
11942 ;; We might want to build some more threads first.
11943 (when (and gnus-fetch-old-headers
11944 (eq gnus-headers-retrieved-by 'nov))
11945 (if (eq gnus-fetch-old-headers 'invisible)
11946 (gnus-build-all-threads)
11947 (gnus-build-old-threads)))
11948 ;; Let the Gnus agent mark articles as read.
11950 (gnus-agent-get-undownloaded-list))
11951 ;; Remove list identifiers from subject
11952 (when gnus-list-identifiers
11953 (gnus-summary-remove-list-identifiers))
11954 ;; First and last article in this newsgroup.
11955 (when gnus-newsgroup-headers
11956 (setq gnus-newsgroup-begin
11957 (mail-header-number (car gnus-newsgroup-headers))
11959 (mail-header-number
11960 (gnus-last-element gnus-newsgroup-headers))))
11961 (when gnus-use-scoring
11962 (gnus-possibly-score-headers))))
11964 (defun gnus-summary-insert-old-articles (&optional all)
11965 "Insert all old articles in this group.
11966 If ALL is non-nil, already read articles become readable.
11967 If ALL is a number, fetch this number of articles."
11970 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11973 ;; Some nntp servers lie about their active range. When
11974 ;; this happens, the active range can be in the millions.
11975 ;; Use a compressed range to avoid creating a huge list.
11976 (gnus-range-difference (list gnus-newsgroup-active) old))
11977 (setq len (gnus-range-length older))
11982 (let ((older-range (nreverse older)))
11986 (let* ((r (pop older-range))
11987 (min (if (numberp r) r (car r)))
11988 (max (if (numberp r) r (cdr r))))
11989 (while (and (<= min max)
11994 (setq older (gnus-uncompress-range older))))
11996 (setq older (gnus-uncompress-range older)))
11998 (when (and (numberp gnus-large-newsgroup)
11999 (> len gnus-large-newsgroup))
12000 (let* ((cursor-in-echo-area nil)
12001 (initial (gnus-parameter-large-newsgroup-initial
12002 gnus-newsgroup-name))
12006 "How many articles from %s (%s %d): "
12008 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12009 (if initial "max" "default")
12012 (cons (number-to-string initial)
12014 (unless (string-match "^[ \t]*$" input)
12015 (setq all (string-to-number input))
12017 (let ((older-range (nreverse older)))
12021 (let* ((r (pop older-range))
12022 (min (if (numberp r) r (car r)))
12023 (max (if (numberp r) r (cdr r))))
12024 (while (and (<= min max)
12028 max (1- max))))))))))
12029 (setq older (gnus-uncompress-range older))))
12031 (message "No old news.")
12032 (gnus-summary-insert-articles older)
12033 (gnus-summary-limit (gnus-sorted-nunion old older))))
12034 (gnus-summary-position-point)))
12036 (defun gnus-summary-insert-new-articles ()
12037 "Insert all new articles in this group."
12040 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12041 (old-active gnus-newsgroup-active)
12042 (nnmail-fetched-sources (list t))
12044 (setq gnus-newsgroup-active
12045 (gnus-activate-group gnus-newsgroup-name 'scan))
12046 (setq i (cdr gnus-newsgroup-active))
12047 (while (> i (cdr old-active))
12051 (message "No gnus is bad news")
12052 (gnus-summary-insert-articles new)
12053 (setq gnus-newsgroup-unreads
12054 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12055 (gnus-summary-limit (gnus-sorted-nunion old new))))
12056 (gnus-summary-position-point)))
12058 (gnus-summary-make-all-marking-commands)
12060 (gnus-ems-redefine)
12062 (provide 'gnus-sum)
12064 (run-hooks 'gnus-sum-load-hook)
12066 ;; Local Variables:
12067 ;; coding: iso-8859-1
12070 ;;; gnus-sum.el ends here