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)
741 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
742 "*List of functions used for sorting articles in the summary buffer.
744 Each function takes two articles and returns non-nil if the first
745 article should be sorted before the other. If you use more than one
746 function, the primary sort function should be the last. You should
747 probably always include `gnus-article-sort-by-number' in the list of
748 sorting functions -- preferably first. Also note that sorting by date
749 is often much slower than sorting by number, and the sorting order is
750 very similar. (Sorting by date means sorting by the time the message
751 was sent, sorting by number means sorting by arrival time.)
753 Each item can also be a list `(not F)' where F is a function;
754 this reverses the sort order.
756 Ready-made functions include `gnus-article-sort-by-number',
757 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
758 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
759 and `gnus-article-sort-by-score'.
761 When threading is turned on, the variable `gnus-thread-sort-functions'
762 controls how articles are sorted."
763 :group 'gnus-summary-sort
764 :type '(repeat (gnus-widget-reversible
765 (choice (function-item gnus-article-sort-by-number)
766 (function-item gnus-article-sort-by-author)
767 (function-item gnus-article-sort-by-subject)
768 (function-item gnus-article-sort-by-date)
769 (function-item gnus-article-sort-by-score)
770 (function-item gnus-article-sort-by-random)
771 (function :tag "other"))
772 (boolean :tag "Reverse order"))))
775 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
776 "*List of functions used for sorting threads in the summary buffer.
777 By default, threads are sorted by article number.
779 Each function takes two threads and returns non-nil if the first
780 thread should be sorted before the other. If you use more than one
781 function, the primary sort function should be the last. You should
782 probably always include `gnus-thread-sort-by-number' in the list of
783 sorting functions -- preferably first. Also note that sorting by date
784 is often much slower than sorting by number, and the sorting order is
785 very similar. (Sorting by date means sorting by the time the message
786 was sent, sorting by number means sorting by arrival time.)
788 Each list item can also be a list `(not F)' where F is a
789 function; this specifies reversed sort order.
791 Ready-made functions include `gnus-thread-sort-by-number',
792 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
793 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
794 `gnus-thread-sort-by-most-recent-number',
795 `gnus-thread-sort-by-most-recent-date',
796 `gnus-thread-sort-by-random', and
797 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
799 When threading is turned off, the variable
800 `gnus-article-sort-functions' controls how articles are sorted."
801 :group 'gnus-summary-sort
803 (gnus-widget-reversible
804 (choice (function-item gnus-thread-sort-by-number)
805 (function-item gnus-thread-sort-by-author)
806 (function-item gnus-thread-sort-by-subject)
807 (function-item gnus-thread-sort-by-date)
808 (function-item gnus-thread-sort-by-score)
809 (function-item gnus-thread-sort-by-most-recent-number)
810 (function-item gnus-thread-sort-by-most-recent-date)
811 (function-item gnus-thread-sort-by-random)
812 (function-item gnus-thread-sort-by-total-score)
813 (function :tag "other"))
814 (boolean :tag "Reverse order"))))
816 (defcustom gnus-thread-score-function '+
817 "*Function used for calculating the total score of a thread.
819 The function is called with the scores of the article and each
820 subthread and should then return the score of the thread.
822 Some functions you can use are `+', `max', or `min'."
823 :group 'gnus-summary-sort
826 (defcustom gnus-summary-expunge-below nil
827 "All articles that have a score less than this variable will be expunged.
828 This variable is local to the summary buffers."
829 :group 'gnus-score-default
830 :type '(choice (const :tag "off" nil)
833 (defcustom gnus-thread-expunge-below nil
834 "All threads that have a total score less than this variable will be expunged.
835 See `gnus-thread-score-function' for en explanation of what a
838 This variable is local to the summary buffers."
839 :group 'gnus-threading
840 :group 'gnus-score-default
841 :type '(choice (const :tag "off" nil)
844 (defcustom gnus-summary-mode-hook nil
845 "*A hook for Gnus summary mode.
846 This hook is run before any variables are set in the summary buffer."
847 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
848 :group 'gnus-summary-various
851 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
852 (when (featurep 'xemacs)
853 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
854 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
855 (add-hook 'gnus-summary-mode-hook
856 'gnus-xmas-switch-horizontal-scrollbar-off))
858 (defcustom gnus-summary-menu-hook nil
859 "*Hook run after the creation of the summary mode menu."
860 :group 'gnus-summary-visual
863 (defcustom gnus-summary-exit-hook nil
864 "*A hook called on exit from the summary buffer.
865 It will be called with point in the group buffer."
866 :group 'gnus-summary-exit
869 (defcustom gnus-summary-prepare-hook nil
870 "*A hook called after the summary buffer has been generated.
871 If you want to modify the summary buffer, you can use this hook."
872 :group 'gnus-summary-various
875 (defcustom gnus-summary-prepared-hook nil
876 "*A hook called as the last thing after the summary buffer has been generated."
877 :group 'gnus-summary-various
880 (defcustom gnus-summary-generate-hook nil
881 "*A hook run just before generating the summary buffer.
882 This hook is commonly used to customize threading variables and the
884 :group 'gnus-summary-various
887 (defcustom gnus-select-group-hook nil
888 "*A hook called when a newsgroup is selected.
890 If you'd like to simplify subjects like the
891 `gnus-summary-next-same-subject' command does, you can use the
894 (add-hook gnus-select-group-hook
896 (mapcar (lambda (header)
897 (mail-header-set-subject
899 (gnus-simplify-subject
900 (mail-header-subject header) 're-only)))
901 gnus-newsgroup-headers)))"
902 :group 'gnus-group-select
905 (defcustom gnus-select-article-hook nil
906 "*A hook called when an article is selected."
907 :group 'gnus-summary-choose
908 :options '(gnus-agent-fetch-selected-article)
911 (defcustom gnus-visual-mark-article-hook
912 (list 'gnus-highlight-selected-summary)
913 "*Hook run after selecting an article in the summary buffer.
914 It is meant to be used for highlighting the article in some way. It
915 is not run if `gnus-visual' is nil."
916 :group 'gnus-summary-visual
919 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
920 "*A hook called before parsing the headers."
924 (defcustom gnus-exit-group-hook nil
925 "*A hook called when exiting summary mode.
926 This hook is not called from the non-updating exit commands like `Q'."
930 (defcustom gnus-summary-update-hook
931 (list 'gnus-summary-highlight-line)
932 "*A hook called when a summary line is changed.
933 The hook will not be called if `gnus-visual' is nil.
935 The default function `gnus-summary-highlight-line' will
936 highlight the line according to the `gnus-summary-highlight'
938 :group 'gnus-summary-visual
941 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
942 "*A hook called when an article is selected for the first time.
943 The hook is intended to mark an article as read (or unread)
944 automatically when it is selected."
945 :group 'gnus-summary-choose
948 (defcustom gnus-group-no-more-groups-hook nil
949 "*A hook run when returning to group mode having no more (unread) groups."
950 :group 'gnus-group-select
953 (defcustom gnus-ps-print-hook nil
954 "*A hook run before ps-printing something from Gnus."
958 (defcustom gnus-summary-article-move-hook nil
959 "*A hook called after an article is moved, copied, respooled, or crossposted."
963 (defcustom gnus-summary-article-delete-hook nil
964 "*A hook called after an article is deleted."
968 (defcustom gnus-summary-article-expire-hook nil
969 "*A hook called after an article is expired."
973 (defcustom gnus-summary-display-arrow
974 (and (fboundp 'display-graphic-p)
976 "*If non-nil, display an arrow highlighting the current article."
981 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
982 "Face used for highlighting the current article in the summary buffer."
983 :group 'gnus-summary-visual
986 (defvar gnus-tmp-downloaded nil)
988 (defcustom gnus-summary-highlight
989 '(((eq mark gnus-canceled-mark)
990 . gnus-summary-cancelled-face)
991 ((and uncached (> score default-high))
992 . gnus-summary-high-undownloaded-face)
993 ((and uncached (< score default-low))
994 . gnus-summary-low-undownloaded-face)
996 . gnus-summary-normal-undownloaded-face)
997 ((and (> score default-high)
998 (or (eq mark gnus-dormant-mark)
999 (eq mark gnus-ticked-mark)))
1000 . gnus-summary-high-ticked-face)
1001 ((and (< score default-low)
1002 (or (eq mark gnus-dormant-mark)
1003 (eq mark gnus-ticked-mark)))
1004 . gnus-summary-low-ticked-face)
1005 ((or (eq mark gnus-dormant-mark)
1006 (eq mark gnus-ticked-mark))
1007 . gnus-summary-normal-ticked-face)
1008 ((and (> score default-high) (eq mark gnus-ancient-mark))
1009 . gnus-summary-high-ancient-face)
1010 ((and (< score default-low) (eq mark gnus-ancient-mark))
1011 . gnus-summary-low-ancient-face)
1012 ((eq mark gnus-ancient-mark)
1013 . gnus-summary-normal-ancient-face)
1014 ((and (> score default-high) (eq mark gnus-unread-mark))
1015 . gnus-summary-high-unread-face)
1016 ((and (< score default-low) (eq mark gnus-unread-mark))
1017 . gnus-summary-low-unread-face)
1018 ((eq mark gnus-unread-mark)
1019 . gnus-summary-normal-unread-face)
1020 ((> score default-high)
1021 . gnus-summary-high-read-face)
1022 ((< score default-low)
1023 . gnus-summary-low-read-face)
1025 . gnus-summary-normal-read-face))
1026 "*Controls the highlighting of summary buffer lines.
1028 A list of (FORM . FACE) pairs. When deciding how a a particular
1029 summary line should be displayed, each form is evaluated. The content
1030 of the face field after the first true form is used. You can change
1031 how those summary lines are displayed, by editing the face field.
1033 You can use the following variables in the FORM field.
1035 score: The article's score
1036 default: The default article score.
1037 default-high: The default score for high scored articles.
1038 default-low: The default score for low scored articles.
1039 below: The score below which articles are automatically marked as read.
1040 mark: The article's mark.
1041 uncached: Non-nil if the article is uncached."
1042 :group 'gnus-summary-visual
1043 :type '(repeat (cons (sexp :tag "Form" nil)
1046 (defcustom gnus-alter-header-function nil
1047 "Function called to allow alteration of article header structures.
1048 The function is called with one parameter, the article header vector,
1049 which it may alter in any way."
1050 :type '(choice (const :tag "None" nil)
1052 :group 'gnus-summary)
1054 (defvar gnus-decode-encoded-word-function
1055 (mime-find-field-decoder 'From 'nov)
1056 "Variable that says which function should be used to decode a string with encoded words.")
1058 (defcustom gnus-extra-headers '(To Newsgroups)
1059 "*Extra headers to parse."
1061 :group 'gnus-summary
1062 :type '(repeat symbol))
1064 (defcustom gnus-ignored-from-addresses
1065 (and user-mail-address (regexp-quote user-mail-address))
1066 "*Regexp of From headers that may be suppressed in favor of To headers."
1068 :group 'gnus-summary
1071 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1072 "List of charsets that should be ignored.
1073 When these charsets are used in the \"charset\" parameter, the
1074 default charset will be used instead."
1076 :type '(repeat symbol)
1077 :group 'gnus-charset)
1079 (gnus-define-group-parameter
1083 "Return the ignored charsets of GROUP."
1084 :variable gnus-group-ignored-charsets-alist
1086 '(("alt\\.chinese\\.text" iso-8859-1))
1088 "Alist of regexps (to match group names) and charsets that should be ignored.
1089 When these charsets are used in the \"charset\" parameter, the
1090 default charset will be used instead."
1091 :variable-group gnus-charset
1092 :variable-type '(repeat (cons (regexp :tag "Group")
1094 :parameter-type '(choice :tag "Ignored charsets"
1097 :parameter-document "\
1098 List of charsets that should be ignored.
1100 When these charsets are used in the \"charset\" parameter, the
1101 default charset will be used instead.")
1103 (defcustom gnus-group-highlight-words-alist nil
1104 "Alist of group regexps and highlight regexps.
1105 This variable uses the same syntax as `gnus-emphasis-alist'."
1107 :type '(repeat (cons (regexp :tag "Group")
1108 (repeat (list (regexp :tag "Highlight regexp")
1109 (number :tag "Group for entire word" 0)
1110 (number :tag "Group for displayed part" 0)
1112 gnus-emphasis-highlight-words)))))
1113 :group 'gnus-summary-visual)
1115 (defcustom gnus-use-wheel nil
1116 "Use Intelli-mouse on summary movement"
1118 :group 'gnus-summary-maneuvering)
1120 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1121 "Amount to scroll messages by spinning the mouse wheel.
1122 This is actually a cons cell, where the first item is the amount to scroll
1123 on a normal wheel event, and the second is the amount to scroll when the
1124 wheel is moved with the shift key depressed."
1125 :type '(cons (integer :tag "Shift") integer)
1126 :group 'gnus-summary-maneuvering)
1128 (defcustom gnus-wheel-edge-resistance 2
1129 "How hard it should be to change the current article
1130 by moving the mouse over the edge of the article window."
1132 :group 'gnus-summary-maneuvering)
1134 (defcustom gnus-summary-show-article-charset-alist
1136 "Alist of number and charset.
1137 The article will be shown with the charset corresponding to the
1139 For example: ((1 . cn-gb-2312) (2 . big5))."
1141 :type '(repeat (cons (number :tag "Argument" 1)
1142 (symbol :tag "Charset")))
1143 :group 'gnus-charset)
1145 (defcustom gnus-preserve-marks t
1146 "Whether marks are preserved when moving, copying and respooling messages."
1149 :group 'gnus-summary-marks)
1151 (defcustom gnus-alter-articles-to-read-function nil
1152 "Function to be called to alter the list of articles to be selected."
1153 :type '(choice (const nil) function)
1154 :group 'gnus-summary)
1156 (defcustom gnus-orphan-score nil
1157 "*All orphans get this score added. Set in the score file."
1158 :group 'gnus-score-default
1159 :type '(choice (const nil)
1162 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1163 "*A regexp to match MIME parts when saving multiple parts of a
1164 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1165 This regexp will be used by default when prompting the user for which
1166 type of files to save."
1167 :group 'gnus-summary
1170 (defcustom gnus-read-all-available-headers nil
1171 "Whether Gnus should parse all headers made available to it.
1172 This is mostly relevant for slow back ends where the user may
1173 wish to widen the summary buffer to include all headers
1174 that were fetched. Say, for nnultimate groups."
1175 :group 'gnus-summary
1176 :type '(choice boolean regexp))
1178 (defcustom gnus-summary-muttprint-program "muttprint"
1179 "Command (and optional arguments) used to run Muttprint."
1181 :group 'gnus-summary
1184 (defcustom gnus-article-loose-mime nil
1185 "If non-nil, don't require MIME-Version header.
1186 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1187 supply the MIME-Version header or deliberately strip it From the mail.
1188 Set it to non-nil, Gnus will treat some articles as MIME even if
1189 the MIME-Version header is missed."
1192 :group 'gnus-article-mime)
1194 (defcustom gnus-article-emulate-mime t
1195 "If non-nil, use MIME emulation for uuencode and the like.
1196 This means that Gnus will search message bodies for text that look
1197 like uuencoded bits, yEncoded bits, and so on, and present that using
1198 the normal Gnus MIME machinery."
1200 :group 'gnus-article-mime)
1202 ;;; Internal variables
1204 (defvar gnus-summary-display-cache nil)
1205 (defvar gnus-article-mime-handles nil)
1206 (defvar gnus-article-decoded-p nil)
1207 (defvar gnus-article-charset nil)
1208 (defvar gnus-article-ignored-charsets nil)
1209 (defvar gnus-scores-exclude-files nil)
1210 (defvar gnus-page-broken nil)
1212 (defvar gnus-original-article nil)
1213 (defvar gnus-article-internal-prepare-hook nil)
1214 (defvar gnus-newsgroup-process-stack nil)
1216 (defvar gnus-thread-indent-array nil)
1217 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1218 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1219 "Function called to sort the articles within a thread after it has been gathered together.")
1221 (defvar gnus-summary-save-parts-type-history nil)
1222 (defvar gnus-summary-save-parts-last-directory nil)
1224 ;; Avoid highlighting in kill files.
1225 (defvar gnus-summary-inhibit-highlight nil)
1226 (defvar gnus-newsgroup-selected-overlay nil)
1227 (defvar gnus-inhibit-limiting nil)
1228 (defvar gnus-newsgroup-adaptive-score-file nil)
1229 (defvar gnus-current-score-file nil)
1230 (defvar gnus-current-move-group nil)
1231 (defvar gnus-current-copy-group nil)
1232 (defvar gnus-current-crosspost-group nil)
1233 (defvar gnus-newsgroup-display nil)
1235 (defvar gnus-newsgroup-dependencies nil)
1236 (defvar gnus-newsgroup-adaptive nil)
1237 (defvar gnus-summary-display-article-function nil)
1238 (defvar gnus-summary-highlight-line-function nil
1239 "Function called after highlighting a summary line.")
1241 (defvar gnus-summary-line-format-alist
1242 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1243 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1244 (?s gnus-tmp-subject-or-nil ?s)
1245 (?n gnus-tmp-name ?s)
1246 (?A (std11-address-string
1247 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1248 (?a (or (std11-full-name-string
1249 (car (mime-entity-read-field gnus-tmp-header 'From)))
1251 (?F gnus-tmp-from ?s)
1252 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1253 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1254 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1255 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1256 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1257 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1258 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1259 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1260 (?L gnus-tmp-lines ?s)
1261 (?O gnus-tmp-downloaded ?c)
1262 (?I gnus-tmp-indentation ?s)
1263 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1264 (?R gnus-tmp-replied ?c)
1265 (?\[ gnus-tmp-opening-bracket ?c)
1266 (?\] gnus-tmp-closing-bracket ?c)
1267 (?\> (make-string gnus-tmp-level ? ) ?s)
1268 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1269 (?i gnus-tmp-score ?d)
1270 (?z gnus-tmp-score-char ?c)
1271 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1272 (?U gnus-tmp-unread ?c)
1273 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1275 (?t (gnus-summary-number-of-articles-in-thread
1276 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1278 (?e (gnus-summary-number-of-articles-in-thread
1279 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1281 (?u gnus-tmp-user-defined ?s)
1282 (?P (gnus-pick-line-number) ?d)
1283 (?B gnus-tmp-thread-tree-header-string ?s)
1284 (user-date (gnus-user-date
1285 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1286 "An alist of format specifications that can appear in summary lines.
1287 These are paired with what variables they correspond with, along with
1288 the type of the variable (string, integer, character, etc).")
1290 (defvar gnus-summary-dummy-line-format-alist
1291 `((?S gnus-tmp-subject ?s)
1292 (?N gnus-tmp-number ?d)
1293 (?u gnus-tmp-user-defined ?s)))
1295 (defvar gnus-summary-mode-line-format-alist
1296 `((?G gnus-tmp-group-name ?s)
1297 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1298 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1299 (?A gnus-tmp-article-number ?d)
1300 (?Z gnus-tmp-unread-and-unselected ?s)
1301 (?V gnus-version ?s)
1302 (?U gnus-tmp-unread-and-unticked ?d)
1303 (?S gnus-tmp-subject ?s)
1304 (?e gnus-tmp-unselected ?d)
1305 (?u gnus-tmp-user-defined ?s)
1306 (?d (length gnus-newsgroup-dormant) ?d)
1307 (?t (length gnus-newsgroup-marked) ?d)
1308 (?h (length gnus-newsgroup-spam-marked) ?d)
1309 (?r (length gnus-newsgroup-reads) ?d)
1310 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1311 (?E gnus-newsgroup-expunged-tally ?d)
1312 (?s (gnus-current-score-file-nondirectory) ?s)))
1314 (defvar gnus-last-search-regexp nil
1315 "Default regexp for article search command.")
1317 (defvar gnus-summary-search-article-matched-data nil
1318 "Last matched data of article search command. It is the local variable
1319 in `gnus-article-buffer' which consists of the list of start position,
1320 end position and text.")
1322 (defvar gnus-last-shell-command nil
1323 "Default shell command on article.")
1325 (defvar gnus-newsgroup-agentized nil
1326 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1327 (defvar gnus-newsgroup-begin nil)
1328 (defvar gnus-newsgroup-end nil)
1329 (defvar gnus-newsgroup-last-rmail nil)
1330 (defvar gnus-newsgroup-last-mail nil)
1331 (defvar gnus-newsgroup-last-folder nil)
1332 (defvar gnus-newsgroup-last-file nil)
1333 (defvar gnus-newsgroup-auto-expire nil)
1334 (defvar gnus-newsgroup-active nil)
1336 (defvar gnus-newsgroup-data nil)
1337 (defvar gnus-newsgroup-data-reverse nil)
1338 (defvar gnus-newsgroup-limit nil)
1339 (defvar gnus-newsgroup-limits nil)
1340 (defvar gnus-summary-use-undownloaded-faces nil)
1342 (defvar gnus-newsgroup-unreads nil
1343 "Sorted list of unread articles in the current newsgroup.")
1345 (defvar gnus-newsgroup-unselected nil
1346 "Sorted list of unselected unread articles in the current newsgroup.")
1348 (defvar gnus-newsgroup-reads nil
1349 "Alist of read articles and article marks in the current newsgroup.")
1351 (defvar gnus-newsgroup-expunged-tally nil)
1353 (defvar gnus-newsgroup-marked nil
1354 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1356 (defvar gnus-newsgroup-spam-marked nil
1357 "List of ranges of articles that have been marked as spam.")
1359 (defvar gnus-newsgroup-killed nil
1360 "List of ranges of articles that have been through the scoring process.")
1362 (defvar gnus-newsgroup-cached nil
1363 "Sorted list of articles that come from the article cache.")
1365 (defvar gnus-newsgroup-saved nil
1366 "List of articles that have been saved.")
1368 (defvar gnus-newsgroup-kill-headers nil)
1370 (defvar gnus-newsgroup-replied nil
1371 "List of articles that have been replied to in the current newsgroup.")
1373 (defvar gnus-newsgroup-forwarded nil
1374 "List of articles that have been forwarded in the current newsgroup.")
1376 (defvar gnus-newsgroup-recent nil
1377 "List of articles that have are recent in the current newsgroup.")
1379 (defvar gnus-newsgroup-expirable nil
1380 "Sorted list of articles in the current newsgroup that can be expired.")
1382 (defvar gnus-newsgroup-processable nil
1383 "List of articles in the current newsgroup that can be processed.")
1385 (defvar gnus-newsgroup-downloadable nil
1386 "Sorted list of articles in the current newsgroup that can be processed.")
1388 (defvar gnus-newsgroup-unfetched nil
1389 "Sorted list of articles in the current newsgroup whose headers have
1390 not been fetched into the agent.
1392 This list will always be a subset of gnus-newsgroup-undownloaded.")
1394 (defvar gnus-newsgroup-undownloaded nil
1395 "List of articles in the current newsgroup that haven't been downloaded.")
1397 (defvar gnus-newsgroup-unsendable nil
1398 "List of articles in the current newsgroup that won't be sent.")
1400 (defvar gnus-newsgroup-bookmarks nil
1401 "List of articles in the current newsgroup that have bookmarks.")
1403 (defvar gnus-newsgroup-dormant nil
1404 "Sorted list of dormant articles in the current newsgroup.")
1406 (defvar gnus-newsgroup-unseen nil
1407 "List of unseen articles in the current newsgroup.")
1409 (defvar gnus-newsgroup-seen nil
1410 "Range of seen articles in the current newsgroup.")
1412 (defvar gnus-newsgroup-articles nil
1413 "List of articles in the current newsgroup.")
1415 (defvar gnus-newsgroup-scored nil
1416 "List of scored articles in the current newsgroup.")
1418 (defvar gnus-newsgroup-incorporated nil
1419 "List of incorporated articles in the current newsgroup.")
1421 (defvar gnus-newsgroup-headers nil
1422 "List of article headers in the current newsgroup.")
1424 (defvar gnus-newsgroup-threads nil)
1426 (defvar gnus-newsgroup-prepared nil
1427 "Whether the current group has been prepared properly.")
1429 (defvar gnus-newsgroup-ancient nil
1430 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1432 (defvar gnus-newsgroup-sparse nil)
1434 (defvar gnus-current-article nil)
1435 (defvar gnus-article-current nil)
1436 (defvar gnus-current-headers nil)
1437 (defvar gnus-have-all-headers nil)
1438 (defvar gnus-last-article nil)
1439 (defvar gnus-newsgroup-history nil)
1440 (defvar gnus-newsgroup-charset nil)
1441 (defvar gnus-newsgroup-ephemeral-charset nil)
1442 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1444 (defvar gnus-article-before-search nil)
1446 (defvar gnus-summary-local-variables
1447 '(gnus-newsgroup-name
1448 gnus-newsgroup-begin gnus-newsgroup-end
1449 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1450 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1451 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1452 gnus-newsgroup-unselected gnus-newsgroup-marked
1453 gnus-newsgroup-spam-marked
1454 gnus-newsgroup-reads gnus-newsgroup-saved
1455 gnus-newsgroup-replied gnus-newsgroup-forwarded
1456 gnus-newsgroup-recent
1457 gnus-newsgroup-expirable
1458 gnus-newsgroup-processable gnus-newsgroup-killed
1459 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1460 gnus-newsgroup-unfetched
1461 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1462 gnus-newsgroup-seen gnus-newsgroup-articles
1463 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1464 gnus-newsgroup-headers gnus-newsgroup-threads
1465 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1466 gnus-current-article gnus-current-headers gnus-have-all-headers
1467 gnus-last-article gnus-article-internal-prepare-hook
1468 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1469 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1470 gnus-thread-expunge-below
1471 gnus-score-alist gnus-current-score-file
1472 (gnus-summary-expunge-below . global)
1473 (gnus-summary-mark-below . global)
1474 (gnus-orphan-score . global)
1475 gnus-newsgroup-active gnus-scores-exclude-files
1476 gnus-newsgroup-history gnus-newsgroup-ancient
1477 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1478 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1479 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1480 (gnus-newsgroup-expunged-tally . 0)
1481 gnus-cache-removable-articles gnus-newsgroup-cached
1482 gnus-newsgroup-data gnus-newsgroup-data-reverse
1483 gnus-newsgroup-limit gnus-newsgroup-limits
1484 gnus-newsgroup-charset gnus-newsgroup-display
1485 gnus-summary-use-undownloaded-faces
1486 gnus-newsgroup-incorporated)
1487 "Variables that are buffer-local to the summary buffers.")
1489 (defvar gnus-newsgroup-variables nil
1490 "A list of variables that have separate values in different newsgroups.
1491 A list of newsgroup (summary buffer) local variables, or cons of
1492 variables and their default expressions to be evalled (when the default
1493 values are not nil), that should be made global while the summary buffer
1496 Note: The default expressions will be evaluated (using function `eval')
1497 before assignment to the local variable rather than just assigned to it.
1498 If the default expression is the symbol `global', that symbol will not
1499 be evaluated but the global value of the local variable will be used
1502 These variables can be used to set variables in the group parameters
1503 while still allowing them to affect operations done in other buffers.
1506 \(setq gnus-newsgroup-variables
1507 '(message-use-followup-to
1508 (gnus-visible-headers .
1509 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1512 ;; Byte-compiler warning.
1514 ;; Bind features so that require will believe that gnus-sum has
1515 ;; already been loaded (avoids infinite recursion)
1516 (let ((features (cons 'gnus-sum features)))
1517 ;; Several of the declarations in gnus-sum are needed to load the
1518 ;; following files. Right now, these definitions have been
1519 ;; compiled but not defined (evaluated). We could either do a
1520 ;; eval-and-compile about all of the declarations or evaluate the
1522 (if (boundp 'gnus-newsgroup-variables)
1524 (load "gnus-sum.el" t t t))
1526 (require 'gnus-agent)
1527 (require 'gnus-art)))
1529 ;; Subject simplification.
1531 (defun gnus-simplify-whitespace (str)
1532 "Remove excessive whitespace from STR."
1534 (while (string-match "[ \t][ \t]+" str)
1535 (setq str (concat (substring str 0 (match-beginning 0))
1537 (substring str (match-end 0)))))
1539 (when (string-match "^[ \t]+" str)
1540 (setq str (substring str (match-end 0))))
1542 (when (string-match "[ \t]+$" str)
1543 (setq str (substring str 0 (match-beginning 0))))
1546 (defun gnus-simplify-all-whitespace (str)
1547 "Remove all whitespace from STR."
1548 (while (string-match "[ \t\n]+" str)
1549 (setq str (replace-match "" nil nil str)))
1552 (defsubst gnus-simplify-subject-re (subject)
1553 "Remove \"Re:\" from subject lines."
1554 (if (string-match message-subject-re-regexp subject)
1555 (substring subject (match-end 0))
1558 (defun gnus-simplify-subject (subject &optional re-only)
1559 "Remove `Re:' and words in parentheses.
1560 If RE-ONLY is non-nil, strip leading `Re:'s only."
1561 (let ((case-fold-search t)) ;Ignore case.
1562 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1563 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1564 (setq subject (substring subject (match-end 0))))
1565 ;; Remove uninteresting prefixes.
1566 (when (and (not re-only)
1567 gnus-simplify-ignored-prefixes
1568 (string-match gnus-simplify-ignored-prefixes subject))
1569 (setq subject (substring subject (match-end 0))))
1570 ;; Remove words in parentheses from end.
1572 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1573 (setq subject (substring subject 0 (match-beginning 0)))))
1574 ;; Return subject string.
1577 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1579 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1580 (goto-char (point-min))
1581 (while (re-search-forward regexp nil t)
1582 (replace-match (or newtext ""))))
1584 (defun gnus-simplify-buffer-fuzzy ()
1585 "Simplify string in the buffer fuzzily.
1586 The string in the accessible portion of the current buffer is simplified.
1587 It is assumed to be a single-line subject.
1588 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1589 matter is removed. Additional things can be deleted by setting
1590 `gnus-simplify-subject-fuzzy-regexp'."
1591 (let ((case-fold-search t)
1593 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1595 (while (not (eq modified-tick (buffer-modified-tick)))
1596 (setq modified-tick (buffer-modified-tick))
1598 ((listp gnus-simplify-subject-fuzzy-regexp)
1599 (mapcar 'gnus-simplify-buffer-fuzzy-step
1600 gnus-simplify-subject-fuzzy-regexp))
1601 (gnus-simplify-subject-fuzzy-regexp
1602 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1603 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1604 (gnus-simplify-buffer-fuzzy-step
1605 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1606 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1608 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1609 (gnus-simplify-buffer-fuzzy-step " +" " ")
1610 (gnus-simplify-buffer-fuzzy-step " $")
1611 (gnus-simplify-buffer-fuzzy-step "^ +")))
1613 (defun gnus-simplify-subject-fuzzy (subject)
1614 "Simplify a subject string fuzzily.
1615 See `gnus-simplify-buffer-fuzzy' for details."
1617 (gnus-set-work-buffer)
1618 (let ((case-fold-search t))
1619 ;; Remove uninteresting prefixes.
1620 (when (and gnus-simplify-ignored-prefixes
1621 (string-match gnus-simplify-ignored-prefixes subject))
1622 (setq subject (substring subject (match-end 0))))
1624 (inline (gnus-simplify-buffer-fuzzy))
1627 (defsubst gnus-simplify-subject-fully (subject)
1628 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1630 (gnus-simplify-subject-functions
1631 (gnus-map-function gnus-simplify-subject-functions subject))
1632 ((null gnus-summary-gather-subject-limit)
1633 (gnus-simplify-subject-re subject))
1634 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1635 (gnus-simplify-subject-fuzzy subject))
1636 ((numberp gnus-summary-gather-subject-limit)
1637 (gnus-limit-string (gnus-simplify-subject-re subject)
1638 gnus-summary-gather-subject-limit))
1642 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1643 "Check whether two subjects are equal.
1644 If optional argument SIMPLE-FIRST is t, first argument is already
1647 ((null simple-first)
1648 (equal (gnus-simplify-subject-fully s1)
1649 (gnus-simplify-subject-fully s2)))
1652 (gnus-simplify-subject-fully s2)))))
1654 (defun gnus-summary-bubble-group ()
1655 "Increase the score of the current group.
1656 This is a handy function to add to `gnus-summary-exit-hook' to
1657 increase the score of each group you read."
1658 (gnus-group-add-score gnus-newsgroup-name))
1662 ;;; Gnus summary mode
1665 (put 'gnus-summary-mode 'mode-class 'special)
1667 (defvar gnus-article-commands-menu)
1669 ;; Non-orthogonal keys
1671 (gnus-define-keys gnus-summary-mode-map
1672 " " gnus-summary-next-page
1673 "\177" gnus-summary-prev-page
1674 [delete] gnus-summary-prev-page
1675 [backspace] gnus-summary-prev-page
1676 "\r" gnus-summary-scroll-up
1677 "\M-\r" gnus-summary-scroll-down
1678 "n" gnus-summary-next-unread-article
1679 "p" gnus-summary-prev-unread-article
1680 "N" gnus-summary-next-article
1681 "P" gnus-summary-prev-article
1682 "\M-\C-n" gnus-summary-next-same-subject
1683 "\M-\C-p" gnus-summary-prev-same-subject
1684 "\M-n" gnus-summary-next-unread-subject
1685 "\M-p" gnus-summary-prev-unread-subject
1686 "." gnus-summary-first-unread-article
1687 "," gnus-summary-best-unread-article
1688 "\M-s" gnus-summary-search-article-forward
1689 "\M-r" gnus-summary-search-article-backward
1690 "<" gnus-summary-beginning-of-article
1691 ">" gnus-summary-end-of-article
1692 "j" gnus-summary-goto-article
1693 "^" gnus-summary-refer-parent-article
1694 "\M-^" gnus-summary-refer-article
1695 "u" gnus-summary-tick-article-forward
1696 "!" gnus-summary-tick-article-forward
1697 "U" gnus-summary-tick-article-backward
1698 "d" gnus-summary-mark-as-read-forward
1699 "D" gnus-summary-mark-as-read-backward
1700 "E" gnus-summary-mark-as-expirable
1701 "\M-u" gnus-summary-clear-mark-forward
1702 "\M-U" gnus-summary-clear-mark-backward
1703 "k" gnus-summary-kill-same-subject-and-select
1704 "\C-k" gnus-summary-kill-same-subject
1705 "\M-\C-k" gnus-summary-kill-thread
1706 "\M-\C-l" gnus-summary-lower-thread
1707 "e" gnus-summary-edit-article
1708 "#" gnus-summary-mark-as-processable
1709 "\M-#" gnus-summary-unmark-as-processable
1710 "\M-\C-t" gnus-summary-toggle-threads
1711 "\M-\C-s" gnus-summary-show-thread
1712 "\M-\C-h" gnus-summary-hide-thread
1713 "\M-\C-f" gnus-summary-next-thread
1714 "\M-\C-b" gnus-summary-prev-thread
1715 [(meta down)] gnus-summary-next-thread
1716 [(meta up)] gnus-summary-prev-thread
1717 "\M-\C-u" gnus-summary-up-thread
1718 "\M-\C-d" gnus-summary-down-thread
1719 "&" gnus-summary-execute-command
1720 "c" gnus-summary-catchup-and-exit
1721 "\C-w" gnus-summary-mark-region-as-read
1722 "\C-t" gnus-summary-toggle-truncation
1723 "?" gnus-summary-mark-as-dormant
1724 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1725 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1726 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1727 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1728 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1729 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1730 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1731 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1732 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1733 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1734 "=" gnus-summary-expand-window
1735 "\C-x\C-s" gnus-summary-reselect-current-group
1736 "\M-g" gnus-summary-rescan-group
1737 "w" gnus-summary-stop-page-breaking
1738 "\C-c\C-r" gnus-summary-caesar-message
1739 "\M-t" gnus-summary-toggle-mime
1740 "f" gnus-summary-followup
1741 "F" gnus-summary-followup-with-original
1742 "C" gnus-summary-cancel-article
1743 "r" gnus-summary-reply
1744 "R" gnus-summary-reply-with-original
1745 "\C-c\C-f" gnus-summary-mail-forward
1746 "o" gnus-summary-save-article
1747 "\C-o" gnus-summary-save-article-mail
1748 "|" gnus-summary-pipe-output
1749 "\M-k" gnus-summary-edit-local-kill
1750 "\M-K" gnus-summary-edit-global-kill
1752 "\C-c\C-d" gnus-summary-describe-group
1753 "q" gnus-summary-exit
1754 "Q" gnus-summary-exit-no-update
1755 "\C-c\C-i" gnus-info-find-node
1756 gnus-mouse-2 gnus-mouse-pick-article
1757 "m" gnus-summary-mail-other-window
1758 "a" gnus-summary-post-news
1759 "i" gnus-summary-news-other-window
1760 "x" gnus-summary-limit-to-unread
1761 "s" gnus-summary-isearch-article
1762 "t" gnus-summary-toggle-header
1763 "g" gnus-summary-show-article
1764 "l" gnus-summary-goto-last-article
1765 "v" gnus-summary-preview-mime-message
1766 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1767 "\C-d" gnus-summary-enter-digest-group
1768 "\M-\C-d" gnus-summary-read-document
1769 "\M-\C-e" gnus-summary-edit-parameters
1770 "\M-\C-a" gnus-summary-customize-parameters
1772 "\C-c\C-n" gnus-namazu-search
1773 "*" gnus-cache-enter-article
1774 "\M-*" gnus-cache-remove-article
1775 "\M-&" gnus-summary-universal-argument
1776 "\C-l" gnus-recenter
1777 "I" gnus-summary-increase-score
1778 "L" gnus-summary-lower-score
1779 "\M-i" gnus-symbolic-argument
1780 "h" gnus-summary-select-article-buffer
1782 "V" gnus-summary-score-map
1783 "X" gnus-uu-extract-map
1784 "S" gnus-summary-send-map)
1786 ;; Sort of orthogonal keymap
1787 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1788 "t" gnus-summary-tick-article-forward
1789 "!" gnus-summary-tick-article-forward
1790 "d" gnus-summary-mark-as-read-forward
1791 "r" gnus-summary-mark-as-read-forward
1792 "c" gnus-summary-clear-mark-forward
1793 " " gnus-summary-clear-mark-forward
1794 "e" gnus-summary-mark-as-expirable
1795 "x" gnus-summary-mark-as-expirable
1796 "?" gnus-summary-mark-as-dormant
1797 "b" gnus-summary-set-bookmark
1798 "B" gnus-summary-remove-bookmark
1799 "#" gnus-summary-mark-as-processable
1800 "\M-#" gnus-summary-unmark-as-processable
1801 "S" gnus-summary-limit-include-expunged
1802 "C" gnus-summary-catchup
1803 "H" gnus-summary-catchup-to-here
1804 "h" gnus-summary-catchup-from-here
1805 "\C-c" gnus-summary-catchup-all
1806 "k" gnus-summary-kill-same-subject-and-select
1807 "K" gnus-summary-kill-same-subject
1808 "P" gnus-uu-mark-map)
1810 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1811 "c" gnus-summary-clear-above
1812 "u" gnus-summary-tick-above
1813 "m" gnus-summary-mark-above
1814 "k" gnus-summary-kill-below)
1816 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1817 "/" gnus-summary-limit-to-subject
1818 "n" gnus-summary-limit-to-articles
1819 "w" gnus-summary-pop-limit
1820 "s" gnus-summary-limit-to-subject
1821 "a" gnus-summary-limit-to-author
1822 "u" gnus-summary-limit-to-unread
1823 "m" gnus-summary-limit-to-marks
1824 "M" gnus-summary-limit-exclude-marks
1825 "v" gnus-summary-limit-to-score
1826 "*" gnus-summary-limit-include-cached
1827 "D" gnus-summary-limit-include-dormant
1828 "T" gnus-summary-limit-include-thread
1829 "d" gnus-summary-limit-exclude-dormant
1830 "t" gnus-summary-limit-to-age
1831 "." gnus-summary-limit-to-unseen
1832 "x" gnus-summary-limit-to-extra
1833 "p" gnus-summary-limit-to-display-predicate
1834 "E" gnus-summary-limit-include-expunged
1835 "c" gnus-summary-limit-exclude-childless-dormant
1836 "C" gnus-summary-limit-mark-excluded-as-read
1837 "o" gnus-summary-insert-old-articles
1838 "N" gnus-summary-insert-new-articles
1839 "r" gnus-summary-limit-to-replied)
1841 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1842 "n" gnus-summary-next-unread-article
1843 "p" gnus-summary-prev-unread-article
1844 "N" gnus-summary-next-article
1845 "P" gnus-summary-prev-article
1846 "\C-n" gnus-summary-next-same-subject
1847 "\C-p" gnus-summary-prev-same-subject
1848 "\M-n" gnus-summary-next-unread-subject
1849 "\M-p" gnus-summary-prev-unread-subject
1850 "f" gnus-summary-first-unread-article
1851 "b" gnus-summary-best-unread-article
1852 "j" gnus-summary-goto-article
1853 "g" gnus-summary-goto-subject
1854 "l" gnus-summary-goto-last-article
1855 "o" gnus-summary-pop-article)
1857 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1858 "k" gnus-summary-kill-thread
1859 "l" gnus-summary-lower-thread
1860 "i" gnus-summary-raise-thread
1861 "T" gnus-summary-toggle-threads
1862 "t" gnus-summary-rethread-current
1863 "^" gnus-summary-reparent-thread
1864 "s" gnus-summary-show-thread
1865 "S" gnus-summary-show-all-threads
1866 "h" gnus-summary-hide-thread
1867 "H" gnus-summary-hide-all-threads
1868 "n" gnus-summary-next-thread
1869 "p" gnus-summary-prev-thread
1870 "u" gnus-summary-up-thread
1871 "o" gnus-summary-top-thread
1872 "d" gnus-summary-down-thread
1873 "#" gnus-uu-mark-thread
1874 "\M-#" gnus-uu-unmark-thread)
1876 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1877 "g" gnus-summary-prepare
1878 "c" gnus-summary-insert-cached-articles
1879 "d" gnus-summary-insert-dormant-articles)
1881 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1882 "c" gnus-summary-catchup-and-exit
1883 "C" gnus-summary-catchup-all-and-exit
1884 "E" gnus-summary-exit-no-update
1885 "J" gnus-summary-jump-to-other-group
1886 "Q" gnus-summary-exit
1887 "Z" gnus-summary-exit
1888 "n" gnus-summary-catchup-and-goto-next-group
1889 "R" gnus-summary-reselect-current-group
1890 "G" gnus-summary-rescan-group
1891 "N" gnus-summary-next-group
1892 "s" gnus-summary-save-newsrc
1893 "P" gnus-summary-prev-group)
1895 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1896 " " gnus-summary-next-page
1897 "n" gnus-summary-next-page
1898 "\177" gnus-summary-prev-page
1899 [delete] gnus-summary-prev-page
1900 "p" gnus-summary-prev-page
1901 "\r" gnus-summary-scroll-up
1902 "\M-\r" gnus-summary-scroll-down
1903 "<" gnus-summary-beginning-of-article
1904 ">" gnus-summary-end-of-article
1905 "b" gnus-summary-beginning-of-article
1906 "e" gnus-summary-end-of-article
1907 "^" gnus-summary-refer-parent-article
1908 "r" gnus-summary-refer-parent-article
1909 "D" gnus-summary-enter-digest-group
1910 "R" gnus-summary-refer-references
1911 "T" gnus-summary-refer-thread
1912 "g" gnus-summary-show-article
1913 "s" gnus-summary-isearch-article
1914 "P" gnus-summary-print-article
1915 "M" gnus-mailing-list-insinuate
1916 "t" gnus-article-babel)
1918 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1919 "b" gnus-article-add-buttons
1920 "B" gnus-article-add-buttons-to-head
1921 "o" gnus-article-treat-overstrike
1922 "e" gnus-article-emphasize
1923 "w" gnus-article-fill-cited-article
1924 "Q" gnus-article-fill-long-lines
1925 "C" gnus-article-capitalize-sentences
1926 "c" gnus-article-remove-cr
1927 "Z" gnus-article-decode-HZ
1928 "A" gnus-article-treat-ansi-sequences
1929 "h" gnus-article-wash-html
1930 "u" gnus-article-unsplit-urls
1931 "f" gnus-article-display-x-face
1932 "l" gnus-summary-stop-page-breaking
1933 "r" gnus-summary-caesar-message
1934 "m" gnus-summary-morse-message
1935 "t" gnus-summary-toggle-header
1936 "g" gnus-treat-smiley
1937 "v" gnus-summary-verbose-headers
1938 "m" gnus-summary-toggle-mime
1939 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1940 "p" gnus-article-verify-x-pgp-sig
1941 "d" gnus-article-treat-dumbquotes)
1943 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1944 ;; mnemonic: deuglif*Y*
1945 "u" gnus-article-outlook-unwrap-lines
1946 "a" gnus-article-outlook-repair-attribution
1947 "c" gnus-article-outlook-rearrange-citation
1948 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1950 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1951 "a" gnus-article-hide
1952 "h" gnus-article-hide-headers
1953 "b" gnus-article-hide-boring-headers
1954 "s" gnus-article-hide-signature
1955 "c" gnus-article-hide-citation
1956 "C" gnus-article-hide-citation-in-followups
1957 "l" gnus-article-hide-list-identifiers
1958 "B" gnus-article-strip-banner
1959 "P" gnus-article-hide-pem
1960 "\C-c" gnus-article-hide-citation-maybe)
1962 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1963 "a" gnus-article-highlight
1964 "h" gnus-article-highlight-headers
1965 "c" gnus-article-highlight-citation
1966 "s" gnus-article-highlight-signature)
1968 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1969 "f" gnus-article-treat-fold-headers
1970 "u" gnus-article-treat-unfold-headers
1971 "n" gnus-article-treat-fold-newsgroups)
1973 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1974 "x" gnus-article-display-x-face
1975 "d" gnus-article-display-face
1976 "s" gnus-treat-smiley
1977 "D" gnus-article-remove-images
1978 "f" gnus-treat-from-picon
1979 "m" gnus-treat-mail-picon
1980 "n" gnus-treat-newsgroups-picon)
1982 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1983 "z" gnus-article-date-ut
1984 "u" gnus-article-date-ut
1985 "l" gnus-article-date-local
1986 "p" gnus-article-date-english
1987 "e" gnus-article-date-lapsed
1988 "o" gnus-article-date-original
1989 "i" gnus-article-date-iso8601
1990 "s" gnus-article-date-user)
1992 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1993 "t" gnus-article-remove-trailing-blank-lines
1994 "l" gnus-article-strip-leading-blank-lines
1995 "m" gnus-article-strip-multiple-blank-lines
1996 "a" gnus-article-strip-blank-lines
1997 "A" gnus-article-strip-all-blank-lines
1998 "s" gnus-article-strip-leading-space
1999 "e" gnus-article-strip-trailing-space
2000 "w" gnus-article-remove-leading-whitespace)
2002 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2004 "f" gnus-summary-fetch-faq
2005 "d" gnus-summary-describe-group
2006 "h" gnus-summary-describe-briefly
2007 "i" gnus-info-find-node
2008 "c" gnus-group-fetch-charter
2009 "C" gnus-group-fetch-control)
2011 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2012 "e" gnus-summary-expire-articles
2013 "\M-\C-e" gnus-summary-expire-articles-now
2014 "\177" gnus-summary-delete-article
2015 [delete] gnus-summary-delete-article
2016 [backspace] gnus-summary-delete-article
2017 "m" gnus-summary-move-article
2018 "r" gnus-summary-respool-article
2019 "w" gnus-summary-edit-article
2020 "c" gnus-summary-copy-article
2021 "B" gnus-summary-crosspost-article
2022 "q" gnus-summary-respool-query
2023 "t" gnus-summary-respool-trace
2024 "i" gnus-summary-import-article
2025 "I" gnus-summary-create-article
2026 "p" gnus-summary-article-posted-p)
2028 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2029 "o" gnus-summary-save-article
2030 "m" gnus-summary-save-article-mail
2031 "F" gnus-summary-write-article-file
2032 "r" gnus-summary-save-article-rmail
2033 "f" gnus-summary-save-article-file
2034 "b" gnus-summary-save-article-body-file
2035 "h" gnus-summary-save-article-folder
2036 "v" gnus-summary-save-article-vm
2037 "p" gnus-summary-pipe-output
2038 "P" gnus-summary-muttprint
2039 "s" gnus-soup-add-article)
2041 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2042 "b" gnus-summary-display-buttonized
2043 "m" gnus-summary-repair-multipart
2044 "v" gnus-article-view-part
2045 "o" gnus-article-save-part
2046 "c" gnus-article-copy-part
2047 "C" gnus-article-view-part-as-charset
2048 "e" gnus-article-view-part-externally
2049 "E" gnus-article-encrypt-body
2050 "i" gnus-article-inline-part
2051 "|" gnus-article-pipe-part)
2053 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2054 "p" gnus-summary-mark-as-processable
2055 "u" gnus-summary-unmark-as-processable
2056 "U" gnus-summary-unmark-all-processable
2057 "v" gnus-uu-mark-over
2058 "s" gnus-uu-mark-series
2059 "r" gnus-uu-mark-region
2060 "g" gnus-uu-unmark-region
2061 "R" gnus-uu-mark-by-regexp
2062 "G" gnus-uu-unmark-by-regexp
2063 "t" gnus-uu-mark-thread
2064 "T" gnus-uu-unmark-thread
2065 "a" gnus-uu-mark-all
2066 "b" gnus-uu-mark-buffer
2067 "S" gnus-uu-mark-sparse
2068 "k" gnus-summary-kill-process-mark
2069 "y" gnus-summary-yank-process-mark
2070 "w" gnus-summary-save-process-mark
2071 "i" gnus-uu-invert-processable)
2073 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2074 ;;"x" gnus-uu-extract-any
2075 "m" gnus-summary-save-parts
2076 "u" gnus-uu-decode-uu
2077 "U" gnus-uu-decode-uu-and-save
2078 "s" gnus-uu-decode-unshar
2079 "S" gnus-uu-decode-unshar-and-save
2080 "o" gnus-uu-decode-save
2081 "O" gnus-uu-decode-save
2082 "b" gnus-uu-decode-binhex
2083 "B" gnus-uu-decode-binhex
2084 "p" gnus-uu-decode-postscript
2085 "P" gnus-uu-decode-postscript-and-save)
2088 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2089 "u" gnus-uu-decode-uu-view
2090 "U" gnus-uu-decode-uu-and-save-view
2091 "s" gnus-uu-decode-unshar-view
2092 "S" gnus-uu-decode-unshar-and-save-view
2093 "o" gnus-uu-decode-save-view
2094 "O" gnus-uu-decode-save-view
2095 "b" gnus-uu-decode-binhex-view
2096 "B" gnus-uu-decode-binhex-view
2097 "p" gnus-uu-decode-postscript-view
2098 "P" gnus-uu-decode-postscript-and-save-view)
2100 (defvar gnus-article-post-menu nil)
2102 (defconst gnus-summary-menu-maxlen 20)
2104 (defun gnus-summary-menu-split (menu)
2105 ;; If we have lots of elements, divide them into groups of 20
2106 ;; and make a pane (or submenu) for each one.
2107 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2108 (let ((menu menu) sublists next
2111 ;; Pull off the next gnus-summary-menu-maxlen elements
2112 ;; and make them the next element of sublist.
2113 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2115 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2117 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2118 (aref (car (last menu)) 0)) menu)
2122 (nreverse sublists))
2123 ;; Few elements--put them all in one pane.
2126 (defun gnus-summary-make-menu-bar ()
2127 (gnus-turn-off-edit-menu 'summary)
2129 (unless (boundp 'gnus-summary-misc-menu)
2132 gnus-summary-kill-menu gnus-summary-mode-map ""
2137 ["Customize" gnus-score-customize t])
2138 (gnus-make-score-map 'increase)
2139 (gnus-make-score-map 'lower)
2141 ["Kill below" gnus-summary-kill-below t]
2142 ["Mark above" gnus-summary-mark-above t]
2143 ["Tick above" gnus-summary-tick-above t]
2144 ["Clear above" gnus-summary-clear-above t])
2145 ["Current score" gnus-summary-current-score t]
2146 ["Set score" gnus-summary-set-score t]
2147 ["Switch current score file..." gnus-score-change-score-file t]
2148 ["Set mark below..." gnus-score-set-mark-below t]
2149 ["Set expunge below..." gnus-score-set-expunge-below t]
2150 ["Edit current score file" gnus-score-edit-current-scores t]
2151 ["Edit score file" gnus-score-edit-file t]
2152 ["Trace score" gnus-score-find-trace t]
2153 ["Find words" gnus-score-find-favourite-words t]
2154 ["Rescore buffer" gnus-summary-rescore t]
2155 ["Increase score..." gnus-summary-increase-score t]
2156 ["Lower score..." gnus-summary-lower-score t]))))
2158 ;; Define both the Article menu in the summary buffer and the
2159 ;; equivalent Commands menu in the article buffer here for
2163 ["All" gnus-article-hide t]
2164 ["Headers" gnus-article-hide-headers t]
2165 ["Signature" gnus-article-hide-signature t]
2166 ["Citation" gnus-article-hide-citation t]
2167 ["List identifiers" gnus-article-hide-list-identifiers t]
2168 ["Banner" gnus-article-strip-banner t]
2169 ["Boring headers" gnus-article-hide-boring-headers t])
2171 ["All" gnus-article-highlight t]
2172 ["Headers" gnus-article-highlight-headers t]
2173 ["Signature" gnus-article-highlight-signature t]
2174 ["Citation" gnus-article-highlight-citation t])
2176 ["Local" gnus-article-date-local t]
2177 ["ISO8601" gnus-article-date-iso8601 t]
2178 ["UT" gnus-article-date-ut t]
2179 ["Original" gnus-article-date-original t]
2180 ["Lapsed" gnus-article-date-lapsed t]
2181 ["User-defined" gnus-article-date-user t])
2183 ["Remove images" gnus-article-remove-images t]
2184 ["Toggle smiley" gnus-treat-smiley t]
2185 ["Show X-Face" gnus-article-display-x-face t]
2186 ["Show picons in From" gnus-treat-from-picon t]
2187 ["Show picons in mail headers" gnus-treat-mail-picon t]
2188 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2189 ("View as different encoding"
2190 ,@(gnus-summary-menu-split
2193 ;; Since easymenu under Emacs doesn't allow
2194 ;; lambda forms for menu commands, we should
2195 ;; provide intern'ed function symbols.
2196 (let ((command (intern (format "\
2197 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2201 (let ((gnus-summary-show-article-charset-alist
2203 (gnus-summary-show-article 1))))
2204 `[,(symbol-name cs) ,command t]))
2205 (sort (if (fboundp 'coding-system-list)
2206 (coding-system-list)
2207 ;;(mapcar 'car mm-mime-mule-charset-alist)
2212 ["Leading" gnus-article-strip-leading-blank-lines t]
2213 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2214 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2215 ["All of the above" gnus-article-strip-blank-lines t]
2216 ["All" gnus-article-strip-all-blank-lines t]
2217 ["Leading space" gnus-article-strip-leading-space t]
2218 ["Trailing space" gnus-article-strip-trailing-space t]
2219 ["Leading space in headers"
2220 gnus-article-remove-leading-whitespace t])
2221 ["Overstrike" gnus-article-treat-overstrike t]
2222 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2223 ["Emphasis" gnus-article-emphasize t]
2224 ["Word wrap" gnus-article-fill-cited-article t]
2225 ["Fill long lines" gnus-article-fill-long-lines t]
2226 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2227 ["Remove CR" gnus-article-remove-cr t]
2228 ["Rot 13" gnus-summary-caesar-message
2229 ,@(if (featurep 'xemacs) '(t)
2230 '(:help "\"Caesar rotate\" article by 13"))]
2231 ["Morse decode" gnus-summary-morse-message t]
2232 ["Unix pipe..." gnus-summary-pipe-message t]
2233 ["Add buttons" gnus-article-add-buttons t]
2234 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2235 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2236 ["Toggle MIME" gnus-summary-toggle-mime t]
2237 ["Verbose header" gnus-summary-verbose-headers t]
2238 ["Toggle header" gnus-summary-toggle-header t]
2239 ["Unfold headers" gnus-article-treat-unfold-headers t]
2240 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2241 ["Html" gnus-article-wash-html t]
2242 ["Unsplit URLs" gnus-article-unsplit-urls t]
2243 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2244 ["Decode HZ" gnus-article-decode-HZ t]
2245 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2246 ("(Outlook) Deuglify"
2247 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2248 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2249 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2250 ["Full (Outlook) deuglify"
2251 gnus-article-outlook-deuglify-article t])
2254 ["Save in default format..." gnus-summary-save-article
2255 ,@(if (featurep 'xemacs) '(t)
2256 '(:help "Save article using default method"))]
2257 ["Save in file..." gnus-summary-save-article-file
2258 ,@(if (featurep 'xemacs) '(t)
2259 '(:help "Save article in file"))]
2260 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2261 ["Save in MH folder..." gnus-summary-save-article-folder t]
2262 ["Save in VM folder..." gnus-summary-save-article-vm t]
2263 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2264 ["Save body in file..." gnus-summary-save-article-body-file t]
2265 ["Pipe through a filter..." gnus-summary-pipe-output t]
2266 ["Add to SOUP packet" gnus-soup-add-article t]
2267 ["Print with Muttprint..." gnus-summary-muttprint t]
2268 ["Print" gnus-summary-print-article t])
2270 ["Respool article..." gnus-summary-respool-article t]
2271 ["Move article..." gnus-summary-move-article
2272 (gnus-check-backend-function
2273 'request-move-article gnus-newsgroup-name)]
2274 ["Copy article..." gnus-summary-copy-article t]
2275 ["Crosspost article..." gnus-summary-crosspost-article
2276 (gnus-check-backend-function
2277 'request-replace-article gnus-newsgroup-name)]
2278 ["Import file..." gnus-summary-import-article
2279 (gnus-check-backend-function
2280 'request-accept-article gnus-newsgroup-name)]
2281 ["Create article..." gnus-summary-create-article
2282 (gnus-check-backend-function
2283 'request-accept-article gnus-newsgroup-name)]
2284 ["Check if posted" gnus-summary-article-posted-p t]
2285 ["Edit article" gnus-summary-edit-article
2286 (not (gnus-group-read-only-p))]
2287 ["Delete article" gnus-summary-delete-article
2288 (gnus-check-backend-function
2289 'request-expire-articles gnus-newsgroup-name)]
2290 ["Query respool" gnus-summary-respool-query t]
2291 ["Trace respool" gnus-summary-respool-trace t]
2292 ["Delete expirable articles" gnus-summary-expire-articles-now
2293 (gnus-check-backend-function
2294 'request-expire-articles gnus-newsgroup-name)])
2296 ["Uudecode" gnus-uu-decode-uu
2297 ,@(if (featurep 'xemacs) '(t)
2298 '(:help "Decode uuencoded article(s)"))]
2299 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2300 ["Unshar" gnus-uu-decode-unshar t]
2301 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2302 ["Save" gnus-uu-decode-save t]
2303 ["Binhex" gnus-uu-decode-binhex t]
2304 ["Postscript" gnus-uu-decode-postscript t])
2306 ["Enter article" gnus-cache-enter-article t]
2307 ["Remove article" gnus-cache-remove-article t])
2308 ["Translate" gnus-article-babel t]
2309 ["Select article buffer" gnus-summary-select-article-buffer t]
2310 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2311 ["Isearch article..." gnus-summary-isearch-article t]
2312 ["Beginning of the article" gnus-summary-beginning-of-article t]
2313 ["End of the article" gnus-summary-end-of-article t]
2314 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2315 ["Fetch referenced articles" gnus-summary-refer-references t]
2316 ["Fetch current thread" gnus-summary-refer-thread t]
2317 ["Fetch article with id..." gnus-summary-refer-article t]
2318 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2319 ["Redisplay" gnus-summary-show-article t]
2320 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2322 gnus-summary-article-menu gnus-summary-mode-map ""
2323 (cons "Article" innards))
2325 (if (not (keymapp gnus-summary-article-menu))
2327 gnus-article-commands-menu gnus-article-mode-map ""
2328 (cons "Commands" innards))
2329 ;; in Emacs, don't share menu.
2330 (setq gnus-article-commands-menu
2331 (copy-keymap gnus-summary-article-menu))
2332 (define-key gnus-article-mode-map [menu-bar commands]
2333 (cons "Commands" gnus-article-commands-menu))))
2336 gnus-summary-thread-menu gnus-summary-mode-map ""
2338 ["Find all messages in thread" gnus-summary-refer-thread t]
2339 ["Toggle threading" gnus-summary-toggle-threads t]
2340 ["Hide threads" gnus-summary-hide-all-threads t]
2341 ["Show threads" gnus-summary-show-all-threads t]
2342 ["Hide thread" gnus-summary-hide-thread t]
2343 ["Show thread" gnus-summary-show-thread t]
2344 ["Go to next thread" gnus-summary-next-thread t]
2345 ["Go to previous thread" gnus-summary-prev-thread t]
2346 ["Go down thread" gnus-summary-down-thread t]
2347 ["Go up thread" gnus-summary-up-thread t]
2348 ["Top of thread" gnus-summary-top-thread t]
2349 ["Mark thread as read" gnus-summary-kill-thread t]
2350 ["Lower thread score" gnus-summary-lower-thread t]
2351 ["Raise thread score" gnus-summary-raise-thread t]
2352 ["Rethread current" gnus-summary-rethread-current t]))
2355 gnus-summary-post-menu gnus-summary-mode-map ""
2357 ["Send a message (mail or news)" gnus-summary-post-news
2358 ,@(if (featurep 'xemacs) '(t)
2359 '(:help "Post an article"))]
2360 ["Followup" gnus-summary-followup
2361 ,@(if (featurep 'xemacs) '(t)
2362 '(:help "Post followup to this article"))]
2363 ["Followup and yank" gnus-summary-followup-with-original
2364 ,@(if (featurep 'xemacs) '(t)
2365 '(:help "Post followup to this article, quoting its contents"))]
2366 ["Supersede article" gnus-summary-supersede-article t]
2367 ["Cancel article" gnus-summary-cancel-article
2368 ,@(if (featurep 'xemacs) '(t)
2369 '(:help "Cancel an article you posted"))]
2370 ["Reply" gnus-summary-reply t]
2371 ["Reply and yank" gnus-summary-reply-with-original t]
2372 ["Wide reply" gnus-summary-wide-reply t]
2373 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2374 ,@(if (featurep 'xemacs) '(t)
2375 '(:help "Mail a reply, quoting this article"))]
2376 ["Very wide reply" gnus-summary-very-wide-reply t]
2377 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2378 ,@(if (featurep 'xemacs) '(t)
2379 '(:help "Mail a very wide reply, quoting this article"))]
2380 ["Mail forward" gnus-summary-mail-forward t]
2381 ["Post forward" gnus-summary-post-forward t]
2382 ["Digest and mail" gnus-summary-digest-mail-forward t]
2383 ["Digest and post" gnus-summary-digest-post-forward t]
2384 ["Resend message" gnus-summary-resend-message t]
2385 ["Resend message edit" gnus-summary-resend-message-edit t]
2386 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2387 ["Send a mail" gnus-summary-mail-other-window t]
2388 ["Create a local message" gnus-summary-news-other-window t]
2389 ["Uuencode and post" gnus-uu-post-news
2390 ,@(if (featurep 'xemacs) '(t)
2391 '(:help "Post a uuencoded article"))]
2392 ["Followup via news" gnus-summary-followup-to-mail t]
2393 ["Followup via news and yank"
2394 gnus-summary-followup-to-mail-with-original t]
2396 ;;["Send" gnus-summary-send-draft t]
2397 ;;["Send bounced" gnus-resend-bounced-mail t])
2401 ((not (keymapp gnus-summary-post-menu))
2402 (setq gnus-article-post-menu gnus-summary-post-menu))
2403 ((not gnus-article-post-menu)
2404 ;; Don't share post menu.
2405 (setq gnus-article-post-menu
2406 (copy-keymap gnus-summary-post-menu))))
2407 (define-key gnus-article-mode-map [menu-bar post]
2408 (cons "Post" gnus-article-post-menu))
2411 gnus-summary-misc-menu gnus-summary-mode-map ""
2414 ["Mark as read" gnus-summary-mark-as-read-forward t]
2415 ["Mark same subject and select"
2416 gnus-summary-kill-same-subject-and-select t]
2417 ["Mark same subject" gnus-summary-kill-same-subject t]
2418 ["Catchup" gnus-summary-catchup
2419 ,@(if (featurep 'xemacs) '(t)
2420 '(:help "Mark unread articles in this group as read"))]
2421 ["Catchup all" gnus-summary-catchup-all t]
2422 ["Catchup to here" gnus-summary-catchup-to-here t]
2423 ["Catchup from here" gnus-summary-catchup-from-here t]
2424 ["Catchup region" gnus-summary-mark-region-as-read
2425 (gnus-mark-active-p)]
2426 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2428 ["Tick" gnus-summary-tick-article-forward t]
2429 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2430 ["Remove marks" gnus-summary-clear-mark-forward t]
2431 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2432 ["Set bookmark" gnus-summary-set-bookmark t]
2433 ["Remove bookmark" gnus-summary-remove-bookmark t])
2435 ["Marks..." gnus-summary-limit-to-marks t]
2436 ["Subject..." gnus-summary-limit-to-subject t]
2437 ["Author..." gnus-summary-limit-to-author t]
2438 ["Age..." gnus-summary-limit-to-age t]
2439 ["Extra..." gnus-summary-limit-to-extra t]
2440 ["Score..." gnus-summary-limit-to-score t]
2441 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2442 ["Unread" gnus-summary-limit-to-unread t]
2443 ["Unseen" gnus-summary-limit-to-unseen t]
2444 ["Replied" gnus-summary-limit-to-replied t]
2445 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2446 ["Next articles" gnus-summary-limit-to-articles t]
2447 ["Pop limit" gnus-summary-pop-limit t]
2448 ["Show dormant" gnus-summary-limit-include-dormant t]
2449 ["Hide childless dormant"
2450 gnus-summary-limit-exclude-childless-dormant t]
2451 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2452 ["Hide marked" gnus-summary-limit-exclude-marks t]
2453 ["Show expunged" gnus-summary-limit-include-expunged t])
2455 ["Set mark" gnus-summary-mark-as-processable t]
2456 ["Remove mark" gnus-summary-unmark-as-processable t]
2457 ["Remove all marks" gnus-summary-unmark-all-processable t]
2458 ["Invert marks" gnus-uu-invert-processable t]
2459 ["Mark above" gnus-uu-mark-over t]
2460 ["Mark series" gnus-uu-mark-series t]
2461 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2462 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2463 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2464 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2465 ["Mark all" gnus-uu-mark-all t]
2466 ["Mark buffer" gnus-uu-mark-buffer t]
2467 ["Mark sparse" gnus-uu-mark-sparse t]
2468 ["Mark thread" gnus-uu-mark-thread t]
2469 ["Unmark thread" gnus-uu-unmark-thread t]
2470 ("Process Mark Sets"
2471 ["Kill" gnus-summary-kill-process-mark t]
2472 ["Yank" gnus-summary-yank-process-mark
2473 gnus-newsgroup-process-stack]
2474 ["Save" gnus-summary-save-process-mark t]
2475 ["Run command on marked..." gnus-summary-universal-argument t]))
2477 ["Page forward" gnus-summary-next-page
2478 ,@(if (featurep 'xemacs) '(t)
2479 '(:help "Show next page of article"))]
2480 ["Page backward" gnus-summary-prev-page
2481 ,@(if (featurep 'xemacs) '(t)
2482 '(:help "Show previous page of article"))]
2483 ["Line forward" gnus-summary-scroll-up t])
2485 ["Next unread article" gnus-summary-next-unread-article t]
2486 ["Previous unread article" gnus-summary-prev-unread-article t]
2487 ["Next article" gnus-summary-next-article t]
2488 ["Previous article" gnus-summary-prev-article t]
2489 ["Next unread subject" gnus-summary-next-unread-subject t]
2490 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2491 ["Next article same subject" gnus-summary-next-same-subject t]
2492 ["Previous article same subject" gnus-summary-prev-same-subject t]
2493 ["First unread article" gnus-summary-first-unread-article t]
2494 ["Best unread article" gnus-summary-best-unread-article t]
2495 ["Go to subject number..." gnus-summary-goto-subject t]
2496 ["Go to article number..." gnus-summary-goto-article t]
2497 ["Go to the last article" gnus-summary-goto-last-article t]
2498 ["Pop article off history" gnus-summary-pop-article t])
2500 ["Sort by number" gnus-summary-sort-by-number t]
2501 ["Sort by author" gnus-summary-sort-by-author t]
2502 ["Sort by subject" gnus-summary-sort-by-subject t]
2503 ["Sort by date" gnus-summary-sort-by-date t]
2504 ["Sort by score" gnus-summary-sort-by-score t]
2505 ["Sort by lines" gnus-summary-sort-by-lines t]
2506 ["Sort by characters" gnus-summary-sort-by-chars t]
2507 ["Randomize" gnus-summary-sort-by-random t]
2508 ["Original sort" gnus-summary-sort-by-original t])
2510 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2511 ["Describe group" gnus-summary-describe-group t]
2512 ["Fetch charter" gnus-group-fetch-charter
2513 ,@(if (featurep 'xemacs) nil
2514 '(:help "Display the charter of the current group"))]
2515 ["Fetch control message" gnus-group-fetch-control
2516 ,@(if (featurep 'xemacs) nil
2517 '(:help "Display the archived control message for the current group"))]
2518 ["Read manual" gnus-info-find-node t])
2520 ["Pick and read" gnus-pick-mode t]
2521 ["Binary" gnus-binary-mode t])
2523 ["Regenerate" gnus-summary-prepare t]
2524 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2525 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2526 ["Toggle threading" gnus-summary-toggle-threads t])
2527 ["See old articles" gnus-summary-insert-old-articles t]
2528 ["See new articles" gnus-summary-insert-new-articles t]
2529 ["Filter articles..." gnus-summary-execute-command t]
2530 ["Run command on articles..." gnus-summary-universal-argument t]
2531 ["Search articles forward..." gnus-summary-search-article-forward t]
2532 ["Search articles backward..." gnus-summary-search-article-backward t]
2533 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2534 ["Expand window" gnus-summary-expand-window t]
2535 ["Expire expirable articles" gnus-summary-expire-articles
2536 (gnus-check-backend-function
2537 'request-expire-articles gnus-newsgroup-name)]
2538 ["Edit local kill file" gnus-summary-edit-local-kill t]
2539 ["Edit main kill file" gnus-summary-edit-global-kill t]
2540 ["Edit group parameters" gnus-summary-edit-parameters t]
2541 ["Customize group parameters" gnus-summary-customize-parameters t]
2542 ["Send a bug report" gnus-bug t]
2544 ["Catchup and exit" gnus-summary-catchup-and-exit
2545 ,@(if (featurep 'xemacs) '(t)
2546 '(:help "Mark unread articles in this group as read, then exit"))]
2547 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2548 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2549 ["Exit group" gnus-summary-exit
2550 ,@(if (featurep 'xemacs) '(t)
2551 '(:help "Exit current group, return to group selection mode"))]
2552 ["Exit group without updating" gnus-summary-exit-no-update t]
2553 ["Exit and goto next group" gnus-summary-next-group t]
2554 ["Exit and goto prev group" gnus-summary-prev-group t]
2555 ["Reselect group" gnus-summary-reselect-current-group t]
2556 ["Rescan group" gnus-summary-rescan-group t]
2557 ["Update dribble" gnus-summary-save-newsrc t])))
2559 (gnus-run-hooks 'gnus-summary-menu-hook)))
2561 (defvar gnus-summary-tool-bar-map nil)
2563 ;; Emacs 21 tool bar. Should be no-op otherwise.
2564 (defun gnus-summary-make-tool-bar ()
2565 (if (and (fboundp 'tool-bar-add-item-from-menu)
2566 (default-value 'tool-bar-mode)
2567 (not gnus-summary-tool-bar-map))
2568 (setq gnus-summary-tool-bar-map
2569 (let ((tool-bar-map (make-sparse-keymap))
2570 (load-path (mm-image-load-path)))
2571 (tool-bar-add-item-from-menu
2572 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2573 (tool-bar-add-item-from-menu
2574 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2575 (tool-bar-add-item-from-menu
2576 'gnus-summary-post-news "post" gnus-summary-mode-map)
2577 (tool-bar-add-item-from-menu
2578 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2579 (tool-bar-add-item-from-menu
2580 'gnus-summary-followup "followup" gnus-summary-mode-map)
2581 (tool-bar-add-item-from-menu
2582 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2583 (tool-bar-add-item-from-menu
2584 'gnus-summary-reply "reply" gnus-summary-mode-map)
2585 (tool-bar-add-item-from-menu
2586 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2587 (tool-bar-add-item-from-menu
2588 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2589 (tool-bar-add-item-from-menu
2590 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2591 (tool-bar-add-item-from-menu
2592 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2593 (tool-bar-add-item-from-menu
2594 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2595 (tool-bar-add-item-from-menu
2596 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2597 (tool-bar-add-item-from-menu
2598 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2599 (tool-bar-add-item-from-menu
2600 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2601 (tool-bar-add-item-from-menu
2602 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2604 (if gnus-summary-tool-bar-map
2605 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2607 (defun gnus-score-set-default (var value)
2608 "A version of set that updates the GNU Emacs menu-bar."
2610 ;; It is the message that forces the active status to be updated.
2613 (defun gnus-make-score-map (type)
2614 "Make a summary score map of type TYPE."
2617 (let ((headers '(("author" "from" string)
2618 ("subject" "subject" string)
2619 ("article body" "body" string)
2620 ("article head" "head" string)
2621 ("xref" "xref" string)
2622 ("extra header" "extra" string)
2623 ("lines" "lines" number)
2624 ("followups to author" "followup" string)))
2625 (types '((number ("less than" <)
2628 (string ("substring" s)
2632 (perms '(("temporary" (current-time-string))
2640 (if (eq type 'lower)
2645 (setq header (car headers))
2651 (let ((ts (cdr (assoc (nth 2 header) types)))
2667 'gnus-summary-score-entry
2669 (if (or (string= (nth 1 header)
2671 (string= (nth 1 header)
2674 (list 'gnus-summary-header
2676 (list 'quote (nth 1 (car ts)))
2677 (list 'gnus-score-delta-default
2684 (list (nreverse outp))))
2687 (list (nreverse outt))))
2689 (setq headers (cdr headers)))
2690 (list (nreverse outh))))))))
2694 (defun gnus-summary-mode (&optional group)
2695 "Major mode for reading articles.
2697 All normal editing commands are switched off.
2698 \\<gnus-summary-mode-map>
2699 Each line in this buffer represents one article. To read an
2700 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2701 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2704 You can also post articles and send mail from this buffer. To
2705 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2706 of an article, type `\\[gnus-summary-reply]'.
2708 There are approx. one gazillion commands you can execute in this
2709 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2711 The following commands are available:
2713 \\{gnus-summary-mode-map}"
2715 (kill-all-local-variables)
2716 (when (gnus-visual-p 'summary-menu 'menu)
2717 (gnus-summary-make-menu-bar)
2718 (gnus-summary-make-tool-bar))
2719 (gnus-summary-make-local-variables)
2720 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2721 (gnus-summary-make-local-variables))
2722 (gnus-make-thread-indent-array)
2723 (gnus-simplify-mode-line)
2724 (setq major-mode 'gnus-summary-mode)
2725 (setq mode-name "Summary")
2726 (make-local-variable 'minor-mode-alist)
2727 (use-local-map gnus-summary-mode-map)
2728 (buffer-disable-undo)
2729 (setq buffer-read-only t ;Disable modification
2730 show-trailing-whitespace nil)
2731 (setq truncate-lines t)
2732 (setq selective-display t)
2733 (setq selective-display-ellipses t) ;Display `...'
2734 (gnus-summary-set-display-table)
2735 (gnus-set-default-directory)
2736 (setq gnus-newsgroup-name group)
2737 (unless (gnus-news-group-p group)
2738 (setq gnus-newsgroup-incorporated
2739 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2740 (make-local-variable 'gnus-summary-line-format)
2741 (make-local-variable 'gnus-summary-line-format-spec)
2742 (make-local-variable 'gnus-summary-dummy-line-format)
2743 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2744 (make-local-variable 'gnus-summary-mark-positions)
2745 (gnus-make-local-hook 'pre-command-hook)
2746 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2747 (gnus-run-hooks 'gnus-summary-mode-hook)
2748 (turn-on-gnus-mailing-list-mode)
2749 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2750 (gnus-update-summary-mark-positions))
2752 (defun gnus-summary-make-local-variables ()
2753 "Make all the local summary buffer variables."
2755 (dolist (local gnus-summary-local-variables)
2758 (if (eq (cdr local) 'global)
2759 ;; Copy the global value of the variable.
2760 (setq global (symbol-value (car local)))
2761 ;; Use the value from the list.
2762 (setq global (eval (cdr local))))
2763 (set (make-local-variable (car local)) global))
2764 ;; Simple nil-valued local variable.
2765 (set (make-local-variable local) nil)))))
2767 (defun gnus-summary-clear-local-variables ()
2768 (let ((locals gnus-summary-local-variables))
2770 (if (consp (car locals))
2771 (and (vectorp (caar locals))
2772 (set (caar locals) nil))
2773 (and (vectorp (car locals))
2774 (set (car locals) nil)))
2775 (setq locals (cdr locals)))))
2777 ;; Summary data functions.
2779 (defmacro gnus-data-number (data)
2782 (defmacro gnus-data-set-number (data number)
2783 `(setcar ,data ,number))
2785 (defmacro gnus-data-mark (data)
2788 (defmacro gnus-data-set-mark (data mark)
2789 `(setcar (nthcdr 1 ,data) ,mark))
2791 (defmacro gnus-data-pos (data)
2794 (defmacro gnus-data-set-pos (data pos)
2795 `(setcar (nthcdr 2 ,data) ,pos))
2797 (defmacro gnus-data-header (data)
2800 (defmacro gnus-data-set-header (data header)
2801 `(setcar (nthcdr 3 ,data) ,header))
2803 (defmacro gnus-data-level (data)
2806 (defmacro gnus-data-unread-p (data)
2807 `(= (nth 1 ,data) gnus-unread-mark))
2809 (defmacro gnus-data-read-p (data)
2810 `(/= (nth 1 ,data) gnus-unread-mark))
2812 (defmacro gnus-data-pseudo-p (data)
2813 `(consp (nth 3 ,data)))
2815 (defmacro gnus-data-find (number)
2816 `(assq ,number gnus-newsgroup-data))
2818 (defmacro gnus-data-find-list (number &optional data)
2819 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2820 (memq (assq ,number bdata)
2823 (defmacro gnus-data-make (number mark pos header level)
2824 `(list ,number ,mark ,pos ,header ,level))
2826 (defun gnus-data-enter (after-article number mark pos header level offset)
2827 (let ((data (gnus-data-find-list after-article)))
2829 (error "No such article: %d" after-article))
2830 (setcdr data (cons (gnus-data-make number mark pos header level)
2832 (setq gnus-newsgroup-data-reverse nil)
2833 (gnus-data-update-list (cddr data) offset)))
2835 (defun gnus-data-enter-list (after-article list &optional offset)
2837 (let ((data (and after-article (gnus-data-find-list after-article)))
2841 (let ((odata gnus-newsgroup-data))
2842 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2844 (gnus-data-update-list odata offset)))
2845 ;; Find the last element in the list to be spliced into the main
2848 (setq list (cdr list)))
2851 (setcdr list gnus-newsgroup-data)
2852 (setq gnus-newsgroup-data ilist)
2854 (gnus-data-update-list (cdr list) offset)))
2855 (setcdr list (cdr data))
2858 (gnus-data-update-list (cdr list) offset))))
2859 (setq gnus-newsgroup-data-reverse nil))))
2861 (defun gnus-data-remove (article &optional offset)
2862 (let ((data gnus-newsgroup-data))
2863 (if (= (gnus-data-number (car data)) article)
2865 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2866 gnus-newsgroup-data-reverse nil)
2868 (gnus-data-update-list gnus-newsgroup-data offset)))
2870 (when (= (gnus-data-number (cadr data)) article)
2871 (setcdr data (cddr data))
2873 (gnus-data-update-list (cdr data) offset))
2875 gnus-newsgroup-data-reverse nil))
2876 (setq data (cdr data))))))
2878 (defmacro gnus-data-list (backward)
2880 (or gnus-newsgroup-data-reverse
2881 (setq gnus-newsgroup-data-reverse
2882 (reverse gnus-newsgroup-data)))
2883 gnus-newsgroup-data))
2885 (defun gnus-data-update-list (data offset)
2886 "Add OFFSET to the POS of all data entries in DATA."
2887 (setq gnus-newsgroup-data-reverse nil)
2889 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2890 (setq data (cdr data))))
2892 (defun gnus-summary-article-pseudo-p (article)
2893 "Say whether this article is a pseudo article or not."
2894 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2896 (defmacro gnus-summary-article-sparse-p (article)
2897 "Say whether this article is a sparse article or not."
2898 `(memq ,article gnus-newsgroup-sparse))
2900 (defmacro gnus-summary-article-ancient-p (article)
2901 "Say whether this article is a sparse article or not."
2902 `(memq ,article gnus-newsgroup-ancient))
2904 (defun gnus-article-parent-p (number)
2905 "Say whether this article is a parent or not."
2906 (let ((data (gnus-data-find-list number)))
2907 (and (cdr data) ; There has to be an article after...
2908 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2909 (gnus-data-level (nth 1 data))))))
2911 (defun gnus-article-children (number)
2912 "Return a list of all children to NUMBER."
2913 (let* ((data (gnus-data-find-list number))
2914 (level (gnus-data-level (car data)))
2916 (setq data (cdr data))
2918 (= (gnus-data-level (car data)) (1+ level)))
2919 (push (gnus-data-number (car data)) children)
2920 (setq data (cdr data)))
2923 (defmacro gnus-summary-skip-intangible ()
2924 "If the current article is intangible, then jump to a different article."
2925 '(let ((to (get-text-property (point) 'gnus-intangible)))
2926 (and to (gnus-summary-goto-subject to))))
2928 (defmacro gnus-summary-article-intangible-p ()
2929 "Say whether this article is intangible or not."
2930 '(get-text-property (point) 'gnus-intangible))
2932 (defun gnus-article-read-p (article)
2933 "Say whether ARTICLE is read or not."
2934 (not (or (memq article gnus-newsgroup-marked)
2935 (memq article gnus-newsgroup-spam-marked)
2936 (memq article gnus-newsgroup-unreads)
2937 (memq article gnus-newsgroup-unselected)
2938 (memq article gnus-newsgroup-dormant))))
2940 ;; Some summary mode macros.
2942 (defmacro gnus-summary-article-number ()
2943 "The article number of the article on the current line.
2944 If there isn't an article number here, then we return the current
2947 (gnus-summary-skip-intangible)
2948 (or (get-text-property (point) 'gnus-number)
2949 (gnus-summary-last-subject))))
2951 (defmacro gnus-summary-article-header (&optional number)
2952 "Return the header of article NUMBER."
2953 `(gnus-data-header (gnus-data-find
2954 ,(or number '(gnus-summary-article-number)))))
2956 (defmacro gnus-summary-thread-level (&optional number)
2957 "Return the level of thread that starts with article NUMBER."
2958 `(if (and (eq gnus-summary-make-false-root 'dummy)
2959 (get-text-property (point) 'gnus-intangible))
2961 (gnus-data-level (gnus-data-find
2962 ,(or number '(gnus-summary-article-number))))))
2964 (defmacro gnus-summary-article-mark (&optional number)
2965 "Return the mark of article NUMBER."
2966 `(gnus-data-mark (gnus-data-find
2967 ,(or number '(gnus-summary-article-number)))))
2969 (defmacro gnus-summary-article-pos (&optional number)
2970 "Return the position of the line of article NUMBER."
2971 `(gnus-data-pos (gnus-data-find
2972 ,(or number '(gnus-summary-article-number)))))
2974 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2975 (defmacro gnus-summary-article-subject (&optional number)
2976 "Return current subject string or nil if nothing."
2979 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2980 '(gnus-data-header (assq (gnus-summary-article-number)
2981 gnus-newsgroup-data)))))
2984 (mail-header-subject headers))))
2986 (defmacro gnus-summary-article-score (&optional number)
2987 "Return current article score."
2988 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2989 gnus-newsgroup-scored))
2990 gnus-summary-default-score 0))
2992 (defun gnus-summary-article-children (&optional number)
2993 "Return a list of article numbers that are children of article NUMBER."
2994 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2995 (level (gnus-data-level (car data)))
2997 (while (and (setq data (cdr data))
2998 (> (setq l (gnus-data-level (car data))) level))
2999 (and (= (1+ level) l)
3000 (push (gnus-data-number (car data))
3002 (nreverse children)))
3004 (defun gnus-summary-article-parent (&optional number)
3005 "Return the article number of the parent of article NUMBER."
3006 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3007 (gnus-data-list t)))
3008 (level (gnus-data-level (car data))))
3010 () ; This is a root.
3011 ;; We search until we find an article with a level less than
3012 ;; this one. That function has to be the parent.
3013 (while (and (setq data (cdr data))
3014 (not (< (gnus-data-level (car data)) level))))
3015 (and data (gnus-data-number (car data))))))
3017 (defun gnus-unread-mark-p (mark)
3018 "Say whether MARK is the unread mark."
3019 (= mark gnus-unread-mark))
3021 (defun gnus-read-mark-p (mark)
3022 "Say whether MARK is one of the marks that mark as read.
3023 This is all marks except unread, ticked, dormant, and expirable."
3024 (not (or (= mark gnus-unread-mark)
3025 (= mark gnus-ticked-mark)
3026 (= mark gnus-spam-mark)
3027 (= mark gnus-dormant-mark)
3028 (= mark gnus-expirable-mark))))
3030 (defmacro gnus-article-mark (number)
3031 "Return the MARK of article NUMBER.
3032 This macro should only be used when computing the mark the \"first\"
3033 time; i.e., when generating the summary lines. After that,
3034 `gnus-summary-article-mark' should be used to examine the
3037 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3038 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3039 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3040 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3041 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3042 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3043 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3044 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3045 gnus-ancient-mark))))
3047 ;; Saving hidden threads.
3049 (defmacro gnus-save-hidden-threads (&rest forms)
3050 "Save hidden threads, eval FORMS, and restore the hidden threads."
3051 (let ((config (make-symbol "config")))
3052 `(let ((,config (gnus-hidden-threads-configuration)))
3056 (gnus-restore-hidden-threads-configuration ,config)))))
3057 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3058 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3060 (defun gnus-data-compute-positions ()
3061 "Compute the positions of all articles."
3062 (setq gnus-newsgroup-data-reverse nil)
3063 (let ((data gnus-newsgroup-data))
3065 (gnus-save-hidden-threads
3066 (gnus-summary-show-all-threads)
3067 (goto-char (point-min))
3069 (while (get-text-property (point) 'gnus-intangible)
3071 (gnus-data-set-pos (car data) (+ (point) 3))
3072 (setq data (cdr data))
3073 (forward-line 1))))))
3075 (defun gnus-hidden-threads-configuration ()
3076 "Return the current hidden threads configuration."
3079 (goto-char (point-min))
3080 (while (search-forward "\r" nil t)
3081 (push (1- (point)) config))
3084 (defun gnus-restore-hidden-threads-configuration (config)
3085 "Restore hidden threads configuration from CONFIG."
3087 (let (point buffer-read-only)
3088 (while (setq point (pop config))
3089 (when (and (< point (point-max))
3091 (eq (char-after) ?\n))
3092 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3094 ;; Various summary mode internalish functions.
3096 (defun gnus-mouse-pick-article (e)
3099 (gnus-summary-next-page nil t))
3101 (defun gnus-summary-set-display-table ()
3102 "Change the display table.
3103 Odd characters have a tendency to mess
3104 up nicely formatted displays - we make all possible glyphs
3105 display only a single character."
3107 ;; We start from the standard display table, if any.
3108 (let ((table (or (copy-sequence standard-display-table)
3109 (make-display-table)))
3111 ;; Nix out all the control chars...
3112 (while (>= (setq i (1- i)) 0)
3113 (aset table i [??]))
3114 ;; ... but not newline and cr, of course. (cr is necessary for the
3115 ;; selective display).
3116 (aset table ?\n nil)
3117 (aset table ?\r nil)
3118 ;; We keep TAB as well.
3119 (aset table ?\t nil)
3120 ;; We nix out any glyphs over 126 that are not set already.
3122 (while (>= (setq i (1- i)) 127)
3123 ;; Only modify if the entry is nil.
3124 (unless (aref table i)
3125 (aset table i [??]))))
3126 (setq buffer-display-table table)))
3128 (defun gnus-summary-set-article-display-arrow (pos)
3129 "Update the overlay arrow to point to line at position POS."
3130 (when (and gnus-summary-display-arrow
3131 (boundp 'overlay-arrow-position)
3132 (boundp 'overlay-arrow-string))
3136 (unless overlay-arrow-position
3137 (setq overlay-arrow-position (make-marker)))
3138 (setq overlay-arrow-string "=>"
3139 overlay-arrow-position (set-marker overlay-arrow-position
3141 (current-buffer))))))
3143 (defun gnus-summary-setup-buffer (group)
3144 "Initialize summary buffer."
3145 (let ((buffer (gnus-summary-buffer-name group))
3146 (dead-name (concat "*Dead Summary "
3147 (gnus-group-decoded-name group) "*")))
3148 ;; If a dead summary buffer exists, we kill it.
3149 (when (gnus-buffer-live-p dead-name)
3150 (gnus-kill-buffer dead-name))
3151 (if (get-buffer buffer)
3154 (setq gnus-summary-buffer (current-buffer))
3155 (not gnus-newsgroup-prepared))
3156 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3157 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3158 (gnus-summary-mode group)
3160 (gnus-carpal-setup-buffer 'summary))
3161 (unless gnus-single-article-buffer
3162 (make-local-variable 'gnus-article-buffer)
3163 (make-local-variable 'gnus-article-current)
3164 (make-local-variable 'gnus-original-article-buffer))
3165 (setq gnus-newsgroup-name group)
3166 ;; Set any local variables in the group parameters.
3167 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3170 (defun gnus-set-global-variables ()
3171 "Set the global equivalents of the buffer-local variables.
3172 They are set to the latest values they had. These reflect the summary
3173 buffer that was in action when the last article was fetched."
3174 (when (eq major-mode 'gnus-summary-mode)
3175 (setq gnus-summary-buffer (current-buffer))
3176 (let ((name gnus-newsgroup-name)
3177 (marked gnus-newsgroup-marked)
3178 (spam gnus-newsgroup-spam-marked)
3179 (unread gnus-newsgroup-unreads)
3180 (headers gnus-current-headers)
3181 (data gnus-newsgroup-data)
3182 (summary gnus-summary-buffer)
3183 (article-buffer gnus-article-buffer)
3184 (original gnus-original-article-buffer)
3185 (gac gnus-article-current)
3186 (reffed gnus-reffed-article-number)
3187 (score-file gnus-current-score-file)
3188 (default-charset gnus-newsgroup-charset)
3190 (let ((locals gnus-newsgroup-variables))
3192 (if (consp (car locals))
3193 (push (eval (caar locals)) vlist)
3194 (push (eval (car locals)) vlist))
3195 (setq locals (cdr locals)))
3196 (setq vlist (nreverse vlist)))
3197 (with-current-buffer gnus-group-buffer
3198 (setq gnus-newsgroup-name name
3199 gnus-newsgroup-marked marked
3200 gnus-newsgroup-spam-marked spam
3201 gnus-newsgroup-unreads unread
3202 gnus-current-headers headers
3203 gnus-newsgroup-data data
3204 gnus-article-current gac
3205 gnus-summary-buffer summary
3206 gnus-article-buffer article-buffer
3207 gnus-original-article-buffer original
3208 gnus-reffed-article-number reffed
3209 gnus-current-score-file score-file
3210 gnus-newsgroup-charset default-charset)
3211 (let ((locals gnus-newsgroup-variables))
3213 (if (consp (car locals))
3214 (set (caar locals) (pop vlist))
3215 (set (car locals) (pop vlist)))
3216 (setq locals (cdr locals))))
3217 ;; The article buffer also has local variables.
3218 (when (gnus-buffer-live-p gnus-article-buffer)
3219 (set-buffer gnus-article-buffer)
3220 (setq gnus-summary-buffer summary))))))
3222 (defun gnus-summary-article-unread-p (article)
3223 "Say whether ARTICLE is unread or not."
3224 (memq article gnus-newsgroup-unreads))
3226 (defun gnus-summary-first-article-p (&optional article)
3227 "Return whether ARTICLE is the first article in the buffer."
3228 (if (not (setq article (or article (gnus-summary-article-number))))
3230 (eq article (caar gnus-newsgroup-data))))
3232 (defun gnus-summary-last-article-p (&optional article)
3233 "Return whether ARTICLE is the last article in the buffer."
3234 (if (not (setq article (or article (gnus-summary-article-number))))
3235 ;; All non-existent numbers are the last article. :-)
3237 (not (cdr (gnus-data-find-list article)))))
3239 (defun gnus-make-thread-indent-array ()
3241 (unless (and gnus-thread-indent-array
3242 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3243 (setq gnus-thread-indent-array (make-vector 201 "")
3244 gnus-thread-indent-array-level gnus-thread-indent-level)
3246 (aset gnus-thread-indent-array n
3247 (make-string (* n gnus-thread-indent-level) ? ))
3250 (defun gnus-update-summary-mark-positions ()
3251 "Compute where the summary marks are to go."
3253 (when (gnus-buffer-exists-p gnus-summary-buffer)
3254 (set-buffer gnus-summary-buffer))
3255 (let ((gnus-replied-mark 129)
3256 (gnus-score-below-mark 130)
3257 (gnus-score-over-mark 130)
3258 (gnus-undownloaded-mark 131)
3259 (spec gnus-summary-line-format-spec)
3262 (gnus-set-work-buffer)
3263 (let ((gnus-summary-line-format-spec spec)
3264 (gnus-newsgroup-downloadable '(0)))
3265 (gnus-summary-insert-line
3266 (make-full-mail-header 0 "" "nobody"
3267 "05 Apr 2001 23:33:09 +0400"
3269 0 nil t 128 t nil "" nil 1)
3270 (goto-char (point-min))
3271 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3272 (- (point) (point-min) 1)))))
3273 (goto-char (point-min))
3274 (push (cons 'replied (and (search-forward "\201" nil t)
3275 (- (point) (point-min) 1)))
3277 (goto-char (point-min))
3278 (push (cons 'score (and (search-forward "\202" nil t)
3279 (- (point) (point-min) 1)))
3281 (goto-char (point-min))
3282 (push (cons 'download
3283 (and (search-forward "\203" nil t)
3284 (- (point) (point-min) 1)))
3286 (setq gnus-summary-mark-positions pos))))
3288 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3289 "Insert a dummy root in the summary buffer."
3291 (gnus-add-text-properties
3292 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3293 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3295 (defun gnus-summary-extract-address-component (from)
3296 (or (car (funcall gnus-extract-address-components from))
3299 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3300 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3301 default-mime-charset)))
3302 ;; Is it really necessary to do this next part for each summary line?
3303 ;; Luckily, doesn't seem to slow things down much.
3305 (and gnus-ignored-from-addresses
3306 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3307 (let ((extra-headers (mail-header-extra header))
3311 ((setq to (cdr (assq 'To extra-headers)))
3314 (gnus-summary-extract-address-component
3315 (funcall gnus-decode-encoded-word-function to)))))
3316 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3317 (concat "=> " newsgroups)))))
3318 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3320 (defun gnus-summary-insert-line (gnus-tmp-header
3321 gnus-tmp-level gnus-tmp-current
3322 undownloaded gnus-tmp-unread gnus-tmp-replied
3323 gnus-tmp-expirable gnus-tmp-subject-or-nil
3324 &optional gnus-tmp-dummy gnus-tmp-score
3326 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3327 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3328 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3329 (gnus-tmp-score-char
3330 (if (or (null gnus-summary-default-score)
3331 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3332 gnus-summary-zcore-fuzz))
3334 (if (< gnus-tmp-score gnus-summary-default-score)
3335 gnus-score-below-mark gnus-score-over-mark)))
3336 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3338 (cond (gnus-tmp-process gnus-process-mark)
3339 ((memq gnus-tmp-current gnus-newsgroup-cached)
3341 (gnus-tmp-replied gnus-replied-mark)
3342 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3343 gnus-forwarded-mark)
3344 ((memq gnus-tmp-current gnus-newsgroup-saved)
3346 ((memq gnus-tmp-number gnus-newsgroup-recent)
3348 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3351 (gnus-tmp-downloaded
3353 gnus-undownloaded-mark)
3354 (gnus-newsgroup-agentized
3355 gnus-downloaded-mark)
3358 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3361 ((string-match "<[^>]+> *$" gnus-tmp-from)
3362 (let ((beg (match-beginning 0)))
3363 (or (and (string-match "^\".+\"" gnus-tmp-from)
3364 (substring gnus-tmp-from 1 (1- (match-end 0))))
3365 (substring gnus-tmp-from 0 beg))))
3366 ((string-match "(.+)" gnus-tmp-from)
3367 (substring gnus-tmp-from
3368 (1+ (match-beginning 0)) (1- (match-end 0))))
3370 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3371 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3372 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3373 (buffer-read-only nil))
3374 (when (string= gnus-tmp-name "")
3375 (setq gnus-tmp-name gnus-tmp-from))
3376 (unless (numberp gnus-tmp-lines)
3377 (setq gnus-tmp-lines -1))
3378 (if (= gnus-tmp-lines -1)
3379 (setq gnus-tmp-lines "?")
3380 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3381 (gnus-put-text-property-excluding-characters-with-faces
3383 (progn (eval gnus-summary-line-format-spec) (point))
3384 'gnus-number gnus-tmp-number)
3385 (when (gnus-visual-p 'summary-highlight 'highlight)
3387 (gnus-run-hooks 'gnus-summary-update-hook)
3390 (defun gnus-summary-update-line (&optional dont-update)
3391 "Update summary line after change."
3392 (when (and gnus-summary-default-score
3393 (not gnus-summary-inhibit-highlight))
3394 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3395 (article (gnus-summary-article-number))
3396 (score (gnus-summary-article-score article)))
3398 (if (and gnus-summary-mark-below
3399 (< (gnus-summary-article-score)
3400 gnus-summary-mark-below))
3401 ;; This article has a low score, so we mark it as read.
3402 (when (memq article gnus-newsgroup-unreads)
3403 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3404 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3405 ;; This article was previously marked as read on account
3406 ;; of a low score, but now it has risen, so we mark it as
3408 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3409 (gnus-summary-update-mark
3410 (if (or (null gnus-summary-default-score)
3411 (<= (abs (- score gnus-summary-default-score))
3412 gnus-summary-zcore-fuzz))
3414 (if (< score gnus-summary-default-score)
3415 gnus-score-below-mark gnus-score-over-mark))
3417 ;; Do visual highlighting.
3418 (when (gnus-visual-p 'summary-highlight 'highlight)
3419 (gnus-run-hooks 'gnus-summary-update-hook)))))
3421 (defvar gnus-tmp-new-adopts nil)
3423 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3424 "Return the number of articles in THREAD.
3425 This may be 0 in some cases -- if none of the articles in
3426 the thread are to be displayed."
3428 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3430 ((not (listp thread))
3432 ((and (consp thread) (cdr thread))
3435 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3438 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3441 (when (and level (zerop level) gnus-tmp-new-adopts)
3444 'gnus-summary-number-of-articles-in-thread
3445 gnus-tmp-new-adopts))))
3447 (if (> number 1) gnus-not-empty-thread-mark
3448 gnus-empty-thread-mark)
3451 (defsubst gnus-summary-line-message-size (head)
3452 "Return pretty-printed version of message size.
3453 This function is intended to be used in
3454 `gnus-summary-line-format-alist'."
3455 (let ((c (or (mail-header-chars head) -1)))
3456 (cond ((< c 0) "n/a") ; chars not available
3457 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3458 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3459 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3460 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3463 (defun gnus-summary-set-local-parameters (group)
3464 "Go through the local params of GROUP and set all variable specs in that list."
3465 (let ((params (gnus-group-find-parameter group))
3466 (vars '(quit-config)) ; Ignore quit-config.
3469 (setq elem (car params)
3470 params (cdr params))
3471 (and (consp elem) ; Has to be a cons.
3472 (consp (cdr elem)) ; The cdr has to be a list.
3473 (symbolp (car elem)) ; Has to be a symbol in there.
3474 (not (memq (car elem) vars))
3475 (ignore-errors ; So we set it.
3476 (push (car elem) vars)
3477 (make-local-variable (car elem))
3478 (set (car elem) (eval (nth 1 elem))))))))
3480 (defun gnus-summary-read-group (group &optional show-all no-article
3481 kill-buffer no-display backward
3483 "Start reading news in newsgroup GROUP.
3484 If SHOW-ALL is non-nil, already read articles are also listed.
3485 If NO-ARTICLE is non-nil, no article is selected initially.
3486 If NO-DISPLAY, don't generate a summary buffer."
3490 (let ((gnus-auto-select-next nil))
3491 (or (gnus-summary-read-group-1
3492 group show-all no-article
3493 kill-buffer no-display
3496 select-articles nil)))))
3497 (eq gnus-auto-select-next 'quietly))
3498 (set-buffer gnus-group-buffer)
3499 ;; The entry function called above goes to the next
3500 ;; group automatically, so we go two groups back
3501 ;; if we are searching for the previous group.
3503 (gnus-group-prev-unread-group 2))
3504 (if (not (equal group (gnus-group-group-name)))
3505 (setq group (gnus-group-group-name))
3509 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3510 "Directly jump to the other GROUP from summary buffer.
3511 If SHOW-ALL is non-nil, already read articles are also listed."
3513 (if (eq gnus-summary-buffer (current-buffer))
3514 (list (completing-read
3515 "Group: " gnus-active-hashtb nil t
3516 (when (and gnus-newsgroup-name
3517 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3518 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3519 'gnus-group-history)
3521 (error "%s must be invoked from a gnus summary buffer." this-command)))
3522 (unless (or (zerop (length group))
3523 (and gnus-newsgroup-name
3524 (string-equal gnus-newsgroup-name group)))
3526 (gnus-summary-read-group group show-all
3527 gnus-dont-select-after-jump-to-other-group)))
3529 (defun gnus-summary-read-group-1 (group show-all no-article
3530 kill-buffer no-display
3531 &optional select-articles)
3532 ;; Killed foreign groups can't be entered.
3533 ;; (when (and (not (gnus-group-native-p group))
3534 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3535 ;; (error "Dead non-native groups can't be entered"))
3536 (gnus-message 5 "Retrieving newsgroup: %s..."
3537 (gnus-group-decoded-name group))
3538 (let* ((new-group (gnus-summary-setup-buffer group))
3539 (quit-config (gnus-group-quit-config group))
3540 (did-select (and new-group (gnus-select-newsgroup
3541 group show-all select-articles))))
3543 ;; This summary buffer exists already, so we just select it.
3545 (gnus-set-global-variables)
3547 (gnus-kill-or-deaden-summary kill-buffer))
3548 (gnus-configure-windows 'summary 'force)
3549 (gnus-set-mode-line 'summary)
3550 (gnus-summary-position-point)
3553 ;; We couldn't select this group.
3555 (when (and (eq major-mode 'gnus-summary-mode)
3556 (not (equal (current-buffer) kill-buffer)))
3557 (kill-buffer (current-buffer))
3558 (if (not quit-config)
3560 ;; Update the info -- marks might need to be removed,
3562 (gnus-summary-update-info)
3563 (set-buffer gnus-group-buffer)
3564 (gnus-group-jump-to-group group)
3565 (gnus-group-next-unread-group 1))
3566 (gnus-handle-ephemeral-exit quit-config)))
3567 (let ((grpinfo (gnus-get-info group)))
3568 (if (null (gnus-info-read grpinfo))
3569 (gnus-message 3 "Group %s contains no messages"
3570 (gnus-group-decoded-name group))
3571 (gnus-message 3 "Can't select group")))
3573 ;; The user did a `C-g' while prompting for number of articles,
3574 ;; so we exit this group.
3575 ((eq did-select 'quit)
3576 (and (eq major-mode 'gnus-summary-mode)
3577 (not (equal (current-buffer) kill-buffer))
3578 (kill-buffer (current-buffer)))
3580 (gnus-kill-or-deaden-summary kill-buffer))
3581 (if (not quit-config)
3583 (set-buffer gnus-group-buffer)
3584 (gnus-group-jump-to-group group)
3585 (gnus-group-next-unread-group 1)
3586 (gnus-configure-windows 'group 'force))
3587 (gnus-handle-ephemeral-exit quit-config))
3588 ;; Finally signal the quit.
3590 ;; The group was successfully selected.
3592 (gnus-set-global-variables)
3593 ;; Save the active value in effect when the group was entered.
3594 (setq gnus-newsgroup-active
3596 (gnus-active gnus-newsgroup-name)))
3597 ;; You can change the summary buffer in some way with this hook.
3598 (gnus-run-hooks 'gnus-select-group-hook)
3599 (gnus-update-format-specifications
3600 nil 'summary 'summary-mode 'summary-dummy)
3601 (gnus-update-summary-mark-positions)
3602 ;; Do score processing.
3603 (when gnus-use-scoring
3604 (gnus-possibly-score-headers))
3605 ;; Check whether to fill in the gaps in the threads.
3606 (when gnus-build-sparse-threads
3607 (gnus-build-sparse-threads))
3608 ;; Find the initial limit.
3610 (let ((gnus-newsgroup-dormant nil))
3611 (gnus-summary-initial-limit show-all))
3612 (gnus-summary-initial-limit show-all))
3613 ;; Generate the summary buffer.
3615 (gnus-summary-prepare))
3616 (when gnus-use-trees
3617 (gnus-tree-open group)
3618 (setq gnus-summary-highlight-line-function
3619 'gnus-tree-highlight-article))
3620 ;; If the summary buffer is empty, but there are some low-scored
3621 ;; articles or some excluded dormants, we include these in the
3623 (when (and (zerop (buffer-size))
3625 (cond (gnus-newsgroup-dormant
3626 (gnus-summary-limit-include-dormant))
3627 ((and gnus-newsgroup-scored show-all)
3628 (gnus-summary-limit-include-expunged t))))
3629 ;; Function `gnus-apply-kill-file' must be called in this hook.
3630 (gnus-run-hooks 'gnus-apply-kill-hook)
3631 (if (and (zerop (buffer-size))
3634 ;; This newsgroup is empty.
3635 (gnus-summary-catchup-and-exit nil t)
3636 (gnus-message 6 "No unread news")
3638 (gnus-kill-or-deaden-summary kill-buffer))
3639 ;; Return nil from this function.
3641 ;; Hide conversation thread subtrees. We cannot do this in
3642 ;; gnus-summary-prepare-hook since kill processing may not
3643 ;; work with hidden articles.
3644 (gnus-summary-maybe-hide-threads)
3646 (gnus-kill-or-deaden-summary kill-buffer))
3647 (gnus-summary-auto-select-subject)
3648 ;; Show first unread article if requested.
3649 (if (and (not no-article)
3651 gnus-newsgroup-unreads
3652 gnus-auto-select-first)
3654 (gnus-configure-windows 'summary)
3655 (let ((art (gnus-summary-article-number)))
3656 (unless (and (not gnus-plugged)
3657 (or (memq art gnus-newsgroup-undownloaded)
3658 (memq art gnus-newsgroup-downloadable)))
3659 (gnus-summary-goto-article art))))
3660 ;; Don't select any articles.
3661 (gnus-summary-position-point)
3662 (gnus-configure-windows 'summary 'force)
3663 (gnus-set-mode-line 'summary))
3664 (when (and gnus-auto-center-group
3665 (get-buffer-window gnus-group-buffer t))
3666 ;; Gotta use windows, because recenter does weird stuff if
3667 ;; the current buffer ain't the displayed window.
3668 (let ((owin (selected-window)))
3669 (select-window (get-buffer-window gnus-group-buffer t))
3670 (when (gnus-group-goto-group group)
3672 (select-window owin)))
3673 ;; Mark this buffer as "prepared".
3674 (setq gnus-newsgroup-prepared t)
3675 (gnus-run-hooks 'gnus-summary-prepared-hook)
3676 (unless (gnus-ephemeral-group-p group)
3677 (gnus-group-update-group group))
3680 (defun gnus-summary-auto-select-subject ()
3681 "Select the subject line on initial group entry."
3682 (goto-char (point-min))
3684 ((eq gnus-auto-select-subject 'best)
3685 (gnus-summary-best-unread-subject))
3686 ((eq gnus-auto-select-subject 'unread)
3687 (gnus-summary-first-unread-subject))
3688 ((eq gnus-auto-select-subject 'unseen)
3689 (gnus-summary-first-unseen-subject))
3690 ((eq gnus-auto-select-subject 'unseen-or-unread)
3691 (gnus-summary-first-unseen-or-unread-subject))
3692 ((eq gnus-auto-select-subject 'first)
3695 ((functionp gnus-auto-select-subject)
3696 (funcall gnus-auto-select-subject))))
3698 (defun gnus-summary-prepare ()
3699 "Generate the summary buffer."
3701 (let ((buffer-read-only nil))
3703 (setq gnus-newsgroup-data nil
3704 gnus-newsgroup-data-reverse nil)
3705 (gnus-run-hooks 'gnus-summary-generate-hook)
3706 ;; Generate the buffer, either with threads or without.
3707 (when gnus-newsgroup-headers
3708 (gnus-summary-prepare-threads
3709 (if gnus-show-threads
3710 (gnus-sort-gathered-threads
3711 (funcall gnus-summary-thread-gathering-function
3713 (gnus-cut-threads (gnus-make-threads)))))
3714 ;; Unthreaded display.
3715 (gnus-sort-articles gnus-newsgroup-headers))))
3716 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3717 ;; Call hooks for modifying summary buffer.
3718 (goto-char (point-min))
3719 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3721 (defsubst gnus-general-simplify-subject (subject)
3722 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3725 ;; Truncate the subject.
3726 (gnus-simplify-subject-functions
3727 (gnus-map-function gnus-simplify-subject-functions subject))
3728 ((numberp gnus-summary-gather-subject-limit)
3729 (setq subject (gnus-simplify-subject-re subject))
3730 (if (> (length subject) gnus-summary-gather-subject-limit)
3731 (substring subject 0 gnus-summary-gather-subject-limit)
3733 ;; Fuzzily simplify it.
3734 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3735 (gnus-simplify-subject-fuzzy subject))
3736 ;; Just remove the leading "Re:".
3738 (gnus-simplify-subject-re subject))))
3740 (if (and gnus-summary-gather-exclude-subject
3741 (string-match gnus-summary-gather-exclude-subject subject))
3742 nil ; This article shouldn't be gathered
3745 (defun gnus-summary-simplify-subject-query ()
3746 "Query where the respool algorithm would put this article."
3748 (gnus-summary-select-article)
3750 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3752 (defun gnus-gather-threads-by-subject (threads)
3753 "Gather threads by looking at Subject headers."
3754 (if (not gnus-summary-make-false-root)
3756 (let ((hashtb (gnus-make-hashtable 1024))
3759 subject hthread whole-subject)
3761 (setq subject (gnus-general-simplify-subject
3762 (setq whole-subject (mail-header-subject
3765 (if (setq hthread (gnus-gethash subject hashtb))
3767 ;; We enter a dummy root into the thread, if we
3768 ;; haven't done that already.
3769 (unless (stringp (caar hthread))
3770 (setcar hthread (list whole-subject (car hthread))))
3771 ;; We add this new gathered thread to this gathered
3773 (setcdr (car hthread)
3774 (nconc (cdar hthread) (list (car threads))))
3775 ;; Remove it from the list of threads.
3776 (setcdr prev (cdr threads))
3777 (setq threads prev))
3778 ;; Enter this thread into the hash table.
3779 (gnus-sethash subject
3780 (if gnus-summary-make-false-root-always
3782 ;; If you want a dummy root above all
3784 (setcar threads (list whole-subject
3790 (setq threads (cdr threads)))
3793 (defun gnus-gather-threads-by-references (threads)
3794 "Gather threads by looking at References headers."
3795 (let ((idhashtb (gnus-make-hashtable 1024))
3796 (thhashtb (gnus-make-hashtable 1024))
3799 ids references id gthread gid entered ref)
3801 (when (setq references (mail-header-references (caar threads)))
3802 (setq id (mail-header-id (caar threads))
3803 ids (inline (gnus-split-references references))
3805 (while (setq ref (pop ids))
3806 (setq ids (delete ref ids))
3807 (if (not (setq gid (gnus-gethash ref idhashtb)))
3809 (gnus-sethash ref id idhashtb)
3810 (gnus-sethash id threads thhashtb))
3811 (setq gthread (gnus-gethash gid thhashtb))
3813 ;; We enter a dummy root into the thread, if we
3814 ;; haven't done that already.
3815 (unless (stringp (caar gthread))
3816 (setcar gthread (list (mail-header-subject (caar gthread))
3818 ;; We add this new gathered thread to this gathered
3820 (setcdr (car gthread)
3821 (nconc (cdar gthread) (list (car threads)))))
3822 ;; Add it into the thread hash table.
3823 (gnus-sethash id gthread thhashtb)
3825 ;; Remove it from the list of threads.
3826 (setcdr prev (cdr threads))
3827 (setq threads prev))))
3829 (setq threads (cdr threads)))
3832 (defun gnus-sort-gathered-threads (threads)
3833 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3834 (let ((result threads))
3836 (when (stringp (caar threads))
3837 (setcdr (car threads)
3838 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3839 (setq threads (cdr threads)))
3842 (defun gnus-thread-loop-p (root thread)
3843 "Say whether ROOT is in THREAD."
3844 (let ((stack (list thread))
3847 (while (setq thread (pop stack))
3848 (setq th (cdr thread))
3850 (not (eq (caar th) root)))
3853 ;; We have found a loop.
3855 (setcdr thread (delq (car th) (cdr thread)))
3856 (if (boundp (setq ref-dep (intern "none"
3857 gnus-newsgroup-dependencies)))
3858 (setcdr (symbol-value ref-dep)
3859 (nconc (cdr (symbol-value ref-dep))
3861 (set ref-dep (list nil (car th))))
3864 ;; Push all the subthreads onto the stack.
3865 (push (cdr thread) stack)))
3868 (defun gnus-make-threads ()
3869 "Go through the dependency hashtb and find the roots. Return all threads."
3871 (while (catch 'infloop
3874 ;; Deal with self-referencing References loops.
3875 (when (and (car (symbol-value refs))
3882 (car (symbol-value refs)) thread))
3883 (cdr (symbol-value refs)))))))
3886 (unless (car (symbol-value refs))
3887 ;; These threads do not refer back to any other articles,
3888 ;; so they're roots.
3889 (setq threads (append (cdr (symbol-value refs)) threads))))
3890 gnus-newsgroup-dependencies)))
3893 ;; Build the thread tree.
3894 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3895 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3897 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3898 if it was already present.
3900 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3901 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3902 Message-IDs will be renamed to a unique Message-ID before being
3905 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3906 (let* ((id (mail-header-id header))
3907 (id-dep (and id (intern id dependencies)))
3908 parent-id ref ref-dep ref-header replaced)
3909 ;; Enter this `header' in the `dependencies' table.
3913 ;; The first two cases do the normal part: enter a new `header'
3914 ;; in the `dependencies' table.
3915 ((not (boundp id-dep))
3916 (set id-dep (list header)))
3917 ((null (car (symbol-value id-dep)))
3918 (setcar (symbol-value id-dep) header))
3920 ;; From here the `header' was already present in the
3921 ;; `dependencies' table.
3923 ;; Overrides an existing entry;
3924 ;; just set the header part of the entry.
3925 (setcar (symbol-value id-dep) header)
3928 ;; Renames the existing `header' to a unique Message-ID.
3929 ((not gnus-summary-ignore-duplicates)
3930 ;; An article with this Message-ID has already been seen.
3931 ;; We rename the Message-ID.
3932 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3934 (mail-header-set-id header id))
3936 ;; The last case ignores an existing entry, except it adds any
3937 ;; additional Xrefs (in case the two articles came from different
3939 ;; Also sets `header' to `nil' meaning that the `dependencies'
3940 ;; table was *not* modified.
3942 (mail-header-set-xref
3943 (car (symbol-value id-dep))
3944 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3946 (or (mail-header-xref header) "")))
3949 (when (and header (not replaced))
3950 ;; First check that we are not creating a References loop.
3951 (setq parent-id (gnus-parent-id (mail-header-references header)))
3952 (setq ref parent-id)
3954 (setq ref-dep (intern-soft ref dependencies))
3956 (setq ref-header (car (symbol-value ref-dep))))
3957 (if (string= id ref)
3958 ;; Yuk! This is a reference loop. Make the article be a
3961 (mail-header-set-references (car (symbol-value id-dep)) "none")
3963 (setq parent-id nil))
3964 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3965 (setq ref-dep (intern (or parent-id "none") dependencies))
3966 (if (boundp ref-dep)
3967 (setcdr (symbol-value ref-dep)
3968 (nconc (cdr (symbol-value ref-dep))
3969 (list (symbol-value id-dep))))
3970 (set ref-dep (list nil (symbol-value id-dep)))))
3973 (defun gnus-extract-message-id-from-in-reply-to (string)
3974 (if (string-match "<[^>]+>" string)
3975 (substring string (match-beginning 0) (match-end 0))
3978 (defun gnus-build-sparse-threads ()
3979 (let ((headers gnus-newsgroup-headers)
3980 (mail-parse-charset gnus-newsgroup-charset)
3981 (gnus-summary-ignore-duplicates t)
3982 header references generation relations
3983 subject child end new-child date)
3984 ;; First we create an alist of generations/relations, where
3985 ;; generations is how much we trust the relation, and the relation
3987 (gnus-message 7 "Making sparse threads...")
3989 (nnheader-set-temp-buffer " *gnus sparse threads*")
3990 (while (setq header (pop headers))
3991 (when (and (setq references (mail-header-references header))
3992 (not (string= references "")))
3994 (setq child (mail-header-id header)
3995 subject (mail-header-subject header)
3996 date (mail-header-date header)
3998 (while (search-backward ">" nil t)
3999 (setq end (1+ (point)))
4000 (when (search-backward "<" nil t)
4001 (setq new-child (buffer-substring (point) end))
4002 (push (list (incf generation)
4003 child (setq child new-child)
4007 (push (list (1+ generation) child nil subject) relations))
4009 (kill-buffer (current-buffer)))
4010 ;; Sort over trustworthiness.
4013 (when (gnus-dependencies-add-header
4014 (make-full-mail-header-from-decoded-header
4015 gnus-reffed-article-number
4016 (nth 3 relation) "" (or (nth 4 relation) "")
4018 (or (nth 2 relation) "") 0 0 "")
4019 gnus-newsgroup-dependencies nil)
4020 (push gnus-reffed-article-number gnus-newsgroup-limit)
4021 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4022 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4023 gnus-newsgroup-reads)
4024 (decf gnus-reffed-article-number)))
4025 (sort relations 'car-less-than-car))
4026 (gnus-message 7 "Making sparse threads...done")))
4028 (defun gnus-build-old-threads ()
4029 ;; Look at all the articles that refer back to old articles, and
4030 ;; fetch the headers for the articles that aren't there. This will
4031 ;; build complete threads - if the roots haven't been expired by the
4033 (let ((mail-parse-charset gnus-newsgroup-charset)
4037 (when (not (car (symbol-value refs)))
4038 (setq heads (cdr (symbol-value refs)))
4040 (if (memq (mail-header-number (caar heads))
4041 gnus-newsgroup-dormant)
4042 (setq heads (cdr heads))
4043 (setq id (symbol-name refs))
4044 (while (and (setq id (gnus-build-get-header id))
4045 (not (car (gnus-id-to-thread id)))))
4046 (setq heads nil)))))
4047 gnus-newsgroup-dependencies)))
4049 (defsubst gnus-remove-odd-characters (string)
4050 "Translate STRING into something that doesn't contain weird characters."
4051 (mm-subst-char-in-string
4053 (mm-subst-char-in-string ?\n ?\- string t) t))
4055 ;; This function has to be called with point after the article number
4056 ;; on the beginning of the line.
4057 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4058 (let ((eol (point-at-eol))
4059 (buffer (current-buffer))
4060 header references in-reply-to)
4062 ;; overview: [num subject from date id refs chars lines misc]
4065 (narrow-to-region (point) eol)
4070 (make-full-mail-header
4072 (nnheader-nov-field) ; subject
4073 (nnheader-nov-field) ; from
4074 (nnheader-nov-field) ; date
4075 (nnheader-nov-read-message-id number) ; id
4076 (setq references (nnheader-nov-field)) ; refs
4077 (nnheader-nov-read-integer) ; chars
4078 (nnheader-nov-read-integer) ; lines
4080 (if (looking-at "Xref: ")
4081 (goto-char (match-end 0)))
4082 (nnheader-nov-field)) ; Xref
4083 (nnheader-nov-parse-extra)))) ; extra
4087 (when (and (string= references "")
4088 (setq in-reply-to (mail-header-extra header))
4089 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4090 (mail-header-set-references
4091 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4093 (when gnus-alter-header-function
4094 (funcall gnus-alter-header-function header))
4095 (gnus-dependencies-add-header header dependencies force-new)))
4097 (defun gnus-build-get-header (id)
4098 "Look through the buffer of NOV lines and find the header to ID.
4099 Enter this line into the dependencies hash table, and return
4100 the id of the parent article (if any)."
4101 (let ((deps gnus-newsgroup-dependencies)
4105 (set-buffer nntp-server-buffer)
4106 (let ((case-fold-search nil))
4107 (goto-char (point-min))
4108 (while (and (not found)
4109 (search-forward id nil t))
4111 (setq found (looking-at
4112 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4113 (regexp-quote id))))
4114 (or found (beginning-of-line 2)))
4118 (setq header (gnus-nov-parse-line
4119 (read (current-buffer)) deps))
4120 (gnus-parent-id (mail-header-references header))))))
4122 (let ((number (mail-header-number header)))
4123 (push number gnus-newsgroup-limit)
4124 (push header gnus-newsgroup-headers)
4125 (if (memq number gnus-newsgroup-unselected)
4127 (setq gnus-newsgroup-unreads
4128 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4130 (setq gnus-newsgroup-unselected
4131 (delq number gnus-newsgroup-unselected)))
4132 (push number gnus-newsgroup-ancient)))))))
4134 (defun gnus-build-all-threads ()
4135 "Read all the headers."
4136 (let ((gnus-summary-ignore-duplicates t)
4137 (mail-parse-charset gnus-newsgroup-charset)
4138 (dependencies gnus-newsgroup-dependencies)
4141 (set-buffer nntp-server-buffer)
4142 (let ((case-fold-search nil))
4143 (goto-char (point-min))
4146 (setq article (read (current-buffer))
4147 header (gnus-nov-parse-line article dependencies)))
4149 (with-current-buffer gnus-summary-buffer
4150 (push header gnus-newsgroup-headers)
4151 (if (memq (setq article (mail-header-number header))
4152 gnus-newsgroup-unselected)
4154 (setq gnus-newsgroup-unreads
4155 (gnus-add-to-sorted-list
4156 gnus-newsgroup-unreads article))
4157 (setq gnus-newsgroup-unselected
4158 (delq article gnus-newsgroup-unselected)))
4159 (push article gnus-newsgroup-ancient)))
4160 (forward-line 1)))))))
4162 (defun gnus-summary-update-article-line (article header)
4163 "Update the line for ARTICLE using HEADER."
4164 (let* ((id (mail-header-id header))
4165 (thread (gnus-id-to-thread id)))
4167 (error "Article in no thread"))
4168 ;; Update the thread.
4169 (setcar thread header)
4170 (gnus-summary-goto-subject article)
4171 (let* ((datal (gnus-data-find-list article))
4173 (buffer-read-only nil)
4174 (level (gnus-summary-thread-level)))
4176 (let ((inserted (- (point)
4178 (gnus-summary-insert-line
4180 (memq article gnus-newsgroup-undownloaded)
4181 (gnus-article-mark article)
4182 (memq article gnus-newsgroup-replied)
4183 (memq article gnus-newsgroup-expirable)
4184 ;; Only insert the Subject string when it's different
4185 ;; from the previous Subject string.
4190 (mail-header-subject
4193 (gnus-data-find-list
4195 (gnus-data-list t)))))
4196 ;; Error on the side of excessive subjects.
4198 (mail-header-subject header)))
4200 (mail-header-subject header))
4201 nil (cdr (assq article gnus-newsgroup-scored))
4202 (memq article gnus-newsgroup-processable))
4205 (gnus-data-update-list
4207 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4209 (defun gnus-summary-update-article (article &optional iheader)
4210 "Update ARTICLE in the summary buffer."
4211 (set-buffer gnus-summary-buffer)
4212 (let* ((header (gnus-summary-article-header article))
4213 (id (mail-header-id header))
4214 (data (gnus-data-find article))
4215 (thread (gnus-id-to-thread id))
4216 (references (mail-header-references header))
4220 (when (and references
4221 (not (equal "" references)))
4224 (buffer-read-only nil)
4230 (delq thread parent)))
4231 (if (gnus-summary-insert-subject id header)
4232 ;; Set the (possibly) new article number in the data structure.
4233 (gnus-data-set-number data (gnus-id-to-article id))
4237 (defun gnus-rebuild-thread (id &optional line)
4238 "Rebuild the thread containing ID.
4239 If LINE, insert the rebuilt thread starting on line LINE."
4240 (let ((buffer-read-only nil)
4241 old-pos current thread data)
4242 (if (not gnus-show-threads)
4243 (setq thread (list (car (gnus-id-to-thread id))))
4244 ;; Get the thread this article is part of.
4245 (setq thread (gnus-remove-thread id)))
4246 (setq old-pos (point-at-bol))
4247 (setq current (save-excursion
4248 (and (re-search-backward "[\r\n]" nil t)
4249 (gnus-summary-article-number))))
4250 ;; If this is a gathered thread, we have to go some re-gathering.
4251 (when (stringp (car thread))
4252 (let ((subject (car thread))
4254 (setq thread (cdr thread))
4256 (unless (memq (setq thr (gnus-id-to-thread
4258 (mail-header-id (caar thread)))))
4261 (setq thread (cdr thread)))
4262 ;; We now have all (unique) roots.
4263 (if (= (length roots) 1)
4264 ;; All the loose roots are now one solid root.
4265 (setq thread (car roots))
4266 (setq thread (cons subject (gnus-sort-threads roots))))))
4268 ;; We then insert this thread into the summary buffer.
4270 (goto-char (point-min))
4271 (forward-line (1- line)))
4272 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4273 (if gnus-show-threads
4274 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4275 (gnus-summary-prepare-unthreaded thread))
4276 (setq data (nreverse gnus-newsgroup-data))
4277 (setq threads gnus-newsgroup-threads))
4278 ;; We splice the new data into the data structure.
4279 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4280 ;;!!! then we want to insert at the beginning of the buffer.
4281 ;;!!! That happens to be true with Gnus now, but that may
4282 ;;!!! change in the future. Perhaps.
4283 (gnus-data-enter-list
4284 (if line nil current) data (- (point) old-pos))
4285 (setq gnus-newsgroup-threads
4286 (nconc threads gnus-newsgroup-threads))
4287 (gnus-data-compute-positions))))
4289 (defun gnus-number-to-header (number)
4290 "Return the header for article NUMBER."
4291 (let ((headers gnus-newsgroup-headers))
4293 (not (= number (mail-header-number (car headers)))))
4298 (defun gnus-parent-headers (in-headers &optional generation)
4299 "Return the headers of the GENERATIONeth parent of HEADERS."
4301 (setq generation 1))
4303 (headers in-headers)
4306 (not (zerop generation))
4307 (setq references (mail-header-references headers)))
4308 (setq headers (if (and references
4309 (setq parent (gnus-parent-id references)))
4310 (car (gnus-id-to-thread parent))
4313 (and (not (eq headers in-headers))
4316 (defun gnus-id-to-thread (id)
4317 "Return the (sub-)thread where ID appears."
4318 (gnus-gethash id gnus-newsgroup-dependencies))
4320 (defun gnus-id-to-article (id)
4321 "Return the article number of ID."
4322 (let ((thread (gnus-id-to-thread id)))
4325 (mail-header-number (car thread)))))
4327 (defun gnus-id-to-header (id)
4328 "Return the article headers of ID."
4329 (car (gnus-id-to-thread id)))
4331 (defun gnus-article-displayed-root-p (article)
4332 "Say whether ARTICLE is a root(ish) article."
4333 (let ((level (gnus-summary-thread-level article))
4334 (refs (mail-header-references (gnus-summary-article-header article)))
4340 ((null (gnus-parent-id refs)) t)
4342 (null (setq particle (gnus-id-to-article
4343 (gnus-parent-id refs))))
4344 (null (gnus-summary-thread-level particle)))))))
4346 (defun gnus-root-id (id)
4347 "Return the id of the root of the thread where ID appears."
4349 (while (and id (setq prev (car (gnus-id-to-thread id))))
4351 id (gnus-parent-id (mail-header-references prev))))
4354 (defun gnus-articles-in-thread (thread)
4355 "Return the list of articles in THREAD."
4356 (cons (mail-header-number (car thread))
4357 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4359 (defun gnus-remove-thread (id &optional dont-remove)
4360 "Remove the thread that has ID in it."
4361 (let (headers thread last-id)
4362 ;; First go up in this thread until we find the root.
4363 (setq last-id (gnus-root-id id)
4364 headers (message-flatten-list (gnus-id-to-thread last-id)))
4365 ;; We have now found the real root of this thread. It might have
4366 ;; been gathered into some loose thread, so we have to search
4367 ;; through the threads to find the thread we wanted.
4368 (let ((threads gnus-newsgroup-threads)
4371 (setq sub (car threads))
4372 (if (stringp (car sub))
4373 ;; This is a gathered thread, so we look at the roots
4374 ;; below it to find whether this article is in this
4377 (setq sub (cdr sub))
4379 (when (member (caar sub) headers)
4380 (setq thread (car threads)
4383 (setq sub (cdr sub))))
4384 ;; It's an ordinary thread, so we check it.
4385 (when (eq (car sub) (car headers))
4388 (setq threads (cdr threads)))
4389 ;; If this article is in no thread, then it's a root.
4392 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4393 (setq thread (gnus-id-to-thread last-id)))
4396 thread ; We return this thread.
4398 (if (stringp (car thread))
4400 ;; If we use dummy roots, then we have to remove the
4401 ;; dummy root as well.
4402 (when (eq gnus-summary-make-false-root 'dummy)
4403 ;; We go to the dummy root by going to
4404 ;; the first sub-"thread", and then one line up.
4405 (gnus-summary-goto-article
4406 (mail-header-number (caadr thread)))
4409 (gnus-data-compute-positions))
4410 (setq thread (cdr thread))
4412 (gnus-remove-thread-1 (car thread))
4413 (setq thread (cdr thread))))
4414 (gnus-remove-thread-1 thread))))))))
4416 (defun gnus-remove-thread-1 (thread)
4417 "Remove the thread THREAD recursively."
4418 (let ((number (mail-header-number (pop thread)))
4420 (setq thread (reverse thread))
4422 (gnus-remove-thread-1 (pop thread)))
4423 (when (setq d (gnus-data-find number))
4424 (goto-char (gnus-data-pos d))
4425 (gnus-summary-show-thread)
4431 (gnus-delete-line)))))))
4433 (defun gnus-sort-threads-1 (threads func)
4434 (sort (mapcar (lambda (thread)
4437 (gnus-sort-threads-1 (cdr thread) func))))
4440 (defun gnus-sort-threads (threads)
4442 (if (not gnus-thread-sort-functions)
4444 (gnus-message 8 "Sorting threads...")
4445 (let ((max-lisp-eval-depth 5000))
4446 (prog1 (gnus-sort-threads-1
4448 (gnus-make-sort-function gnus-thread-sort-functions))
4449 (gnus-message 8 "Sorting threads...done")))))
4451 (defun gnus-sort-articles (articles)
4453 (when gnus-article-sort-functions
4454 (gnus-message 7 "Sorting articles...")
4456 (setq gnus-newsgroup-headers
4457 (sort articles (gnus-make-sort-function
4458 gnus-article-sort-functions)))
4459 (gnus-message 7 "Sorting articles...done"))))
4461 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4462 (defmacro gnus-thread-header (thread)
4463 "Return header of first article in THREAD.
4464 Note that THREAD must never, ever be anything else than a variable -
4465 using some other form will lead to serious barfage."
4466 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4467 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4468 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4471 (defsubst gnus-article-sort-by-number (h1 h2)
4472 "Sort articles by article number."
4473 (< (mail-header-number h1)
4474 (mail-header-number h2)))
4476 (defun gnus-thread-sort-by-number (h1 h2)
4477 "Sort threads by root article number."
4478 (gnus-article-sort-by-number
4479 (gnus-thread-header h1) (gnus-thread-header h2)))
4481 (defsubst gnus-article-sort-by-random (h1 h2)
4482 "Sort articles by article number."
4485 (defun gnus-thread-sort-by-random (h1 h2)
4486 "Sort threads by root article number."
4487 (gnus-article-sort-by-random
4488 (gnus-thread-header h1) (gnus-thread-header h2)))
4490 (defsubst gnus-article-sort-by-lines (h1 h2)
4491 "Sort articles by article Lines header."
4492 (< (mail-header-lines h1)
4493 (mail-header-lines h2)))
4495 (defun gnus-thread-sort-by-lines (h1 h2)
4496 "Sort threads by root article Lines header."
4497 (gnus-article-sort-by-lines
4498 (gnus-thread-header h1) (gnus-thread-header h2)))
4500 (defsubst gnus-article-sort-by-chars (h1 h2)
4501 "Sort articles by octet length."
4502 (< (mail-header-chars h1)
4503 (mail-header-chars h2)))
4505 (defun gnus-thread-sort-by-chars (h1 h2)
4506 "Sort threads by root article octet length."
4507 (gnus-article-sort-by-chars
4508 (gnus-thread-header h1) (gnus-thread-header h2)))
4510 (defsubst gnus-article-sort-by-author (h1 h2)
4511 "Sort articles by root author."
4513 (let ((addr (car (mime-entity-read-field h1 'From))))
4514 (or (std11-full-name-string addr)
4515 (std11-address-string addr)
4517 (let ((addr (car (mime-entity-read-field h2 'From))))
4518 (or (std11-full-name-string addr)
4519 (std11-address-string addr)
4523 (defun gnus-thread-sort-by-author (h1 h2)
4524 "Sort threads by root author."
4525 (gnus-article-sort-by-author
4526 (gnus-thread-header h1) (gnus-thread-header h2)))
4528 (defsubst gnus-article-sort-by-subject (h1 h2)
4529 "Sort articles by root subject."
4531 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4532 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4534 (defun gnus-thread-sort-by-subject (h1 h2)
4535 "Sort threads by root subject."
4536 (gnus-article-sort-by-subject
4537 (gnus-thread-header h1) (gnus-thread-header h2)))
4539 (defsubst gnus-article-sort-by-date (h1 h2)
4540 "Sort articles by root article date."
4542 (gnus-date-get-time (mail-header-date h1))
4543 (gnus-date-get-time (mail-header-date h2))))
4545 (defun gnus-thread-sort-by-date (h1 h2)
4546 "Sort threads by root article date."
4547 (gnus-article-sort-by-date
4548 (gnus-thread-header h1) (gnus-thread-header h2)))
4550 (defsubst gnus-article-sort-by-score (h1 h2)
4551 "Sort articles by root article score.
4552 Unscored articles will be counted as having a score of zero."
4553 (> (or (cdr (assq (mail-header-number h1)
4554 gnus-newsgroup-scored))
4555 gnus-summary-default-score 0)
4556 (or (cdr (assq (mail-header-number h2)
4557 gnus-newsgroup-scored))
4558 gnus-summary-default-score 0)))
4560 (defun gnus-thread-sort-by-score (h1 h2)
4561 "Sort threads by root article score."
4562 (gnus-article-sort-by-score
4563 (gnus-thread-header h1) (gnus-thread-header h2)))
4565 (defun gnus-thread-sort-by-total-score (h1 h2)
4566 "Sort threads by the sum of all scores in the thread.
4567 Unscored articles will be counted as having a score of zero."
4568 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4570 (defun gnus-thread-total-score (thread)
4571 ;; This function find the total score of THREAD.
4576 (if (stringp (car thread))
4577 (apply gnus-thread-score-function 0
4578 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4579 (gnus-thread-total-score-1 thread)))
4581 (gnus-thread-total-score-1 (list thread)))))
4583 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4584 "Sort threads such that the thread with the most recently arrived article comes first."
4585 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4587 (defun gnus-thread-highest-number (thread)
4588 "Return the highest article number in THREAD."
4589 (apply 'max (mapcar (lambda (header)
4590 (mail-header-number header))
4591 (message-flatten-list thread))))
4593 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4594 "Sort threads such that the thread with the most recently dated article comes first."
4595 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4597 (defun gnus-thread-latest-date (thread)
4598 "Return the highest article date in THREAD."
4599 (let ((previous-time 0))
4605 (time-to-seconds (mail-header-parse-date
4606 (mail-header-date header)))
4607 (error previous-time))))
4609 (message-flatten-list thread)
4611 (< (mail-header-number h1)
4612 (mail-header-number h2))))))))
4614 (defun gnus-thread-total-score-1 (root)
4615 ;; This function find the total score of the thread below ROOT.
4616 (setq root (car root))
4617 (apply gnus-thread-score-function
4619 (mapcar 'gnus-thread-total-score
4620 (cdr (gnus-id-to-thread (mail-header-id root))))
4621 (when (> (mail-header-number root) 0)
4622 (list (or (cdr (assq (mail-header-number root)
4623 gnus-newsgroup-scored))
4624 gnus-summary-default-score 0))))
4625 (list gnus-summary-default-score)
4628 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4629 (defvar gnus-tmp-prev-subject nil)
4630 (defvar gnus-tmp-false-parent nil)
4631 (defvar gnus-tmp-root-expunged nil)
4632 (defvar gnus-tmp-dummy-line nil)
4634 (eval-when-compile (defvar gnus-tmp-header))
4635 (defun gnus-extra-header (type &optional header)
4636 "Return the extra header of TYPE."
4637 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4640 (defvar gnus-tmp-thread-tree-header-string "")
4642 (defcustom gnus-sum-thread-tree-root "> "
4643 "With %B spec, used for the root of a thread.
4644 If nil, use subject instead."
4645 :type '(radio (const :format "%v " nil) (string :size 0))
4646 :group 'gnus-thread)
4647 (defcustom gnus-sum-thread-tree-false-root "> "
4648 "With %B spec, used for a false root of a thread.
4649 If nil, use subject instead."
4650 :type '(radio (const :format "%v " nil) (string :size 0))
4651 :group 'gnus-thread)
4652 (defcustom gnus-sum-thread-tree-single-indent ""
4653 "With %B spec, used for a thread with just one message.
4654 If nil, use subject instead."
4655 :type '(radio (const :format "%v " nil) (string :size 0))
4656 :group 'gnus-thread)
4657 (defcustom gnus-sum-thread-tree-vertical "| "
4658 "With %B spec, used for drawing a vertical line."
4660 :group 'gnus-thread)
4661 (defcustom gnus-sum-thread-tree-indent " "
4662 "With %B spec, used for indenting."
4664 :group 'gnus-thread)
4665 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4666 "With %B spec, used for a leaf with brothers."
4668 :group 'gnus-thread)
4669 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4670 "With %B spec, used for a leaf without brothers."
4672 :group 'gnus-thread)
4674 (defun gnus-summary-prepare-threads (threads)
4675 "Prepare summary buffer from THREADS and indentation LEVEL.
4676 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4677 or a straight list of headers."
4678 (gnus-message 7 "Generating summary...")
4680 (setq gnus-newsgroup-threads threads)
4683 (let ((gnus-tmp-level 0)
4684 (default-score (or gnus-summary-default-score 0))
4685 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4686 (building-line-count gnus-summary-display-while-building)
4687 (building-count (integerp gnus-summary-display-while-building))
4688 thread number subject stack state gnus-tmp-gathered beg-match
4689 new-roots gnus-tmp-new-adopts thread-end simp-subject
4690 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4691 gnus-tmp-replied gnus-tmp-subject-or-nil
4692 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4693 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4694 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4697 (setq gnus-tmp-prev-subject nil
4698 gnus-tmp-thread-tree-header-string "")
4700 (if (vectorp (car threads))
4701 ;; If this is a straight (sic) list of headers, then a
4702 ;; threaded summary display isn't required, so we just create
4703 ;; an unthreaded one.
4704 (gnus-summary-prepare-unthreaded threads)
4706 ;; Do the threaded display.
4708 (if gnus-summary-display-while-building
4709 (switch-to-buffer (buffer-name)))
4710 (while (or threads stack gnus-tmp-new-adopts new-roots)
4712 (if (and (= gnus-tmp-level 0)
4715 (not gnus-tmp-false-parent)
4716 (or gnus-tmp-new-adopts new-roots))
4717 (if gnus-tmp-new-adopts
4718 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4719 thread (list (car gnus-tmp-new-adopts))
4720 gnus-tmp-header (caar thread)
4721 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4723 (setq thread (list (car new-roots))
4724 gnus-tmp-header (caar thread)
4725 new-roots (cdr new-roots))))
4728 ;; If there are some threads, we do them before the
4729 ;; threads on the stack.
4730 (setq thread threads
4731 gnus-tmp-header (caar thread))
4732 ;; There were no current threads, so we pop something off
4734 (setq state (car stack)
4735 gnus-tmp-level (car state)
4736 tree-stack (cadr state)
4737 thread (caddr state)
4739 gnus-tmp-header (caar thread))))
4741 (setq gnus-tmp-false-parent nil)
4742 (setq gnus-tmp-root-expunged nil)
4743 (setq thread-end nil)
4745 (if (stringp gnus-tmp-header)
4746 ;; The header is a dummy root.
4748 ((eq gnus-summary-make-false-root 'adopt)
4749 ;; We let the first article adopt the rest.
4750 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4752 (setq gnus-tmp-gathered
4754 (lambda (h) (mail-header-number (car h)))
4757 (setq thread (cons (list (caar thread)
4760 (setq gnus-tmp-level -1
4761 gnus-tmp-false-parent t))
4762 ((eq gnus-summary-make-false-root 'empty)
4763 ;; We print adopted articles with empty subject fields.
4764 (setq gnus-tmp-gathered
4766 (lambda (h) (mail-header-number (car h)))
4769 (setq gnus-tmp-level -1))
4770 ((eq gnus-summary-make-false-root 'dummy)
4771 ;; We remember that we probably want to output a dummy
4773 (setq gnus-tmp-dummy-line gnus-tmp-header)
4774 (setq gnus-tmp-prev-subject gnus-tmp-header))
4776 ;; We do not make a root for the gathered
4777 ;; sub-threads at all.
4778 (setq gnus-tmp-level -1)))
4780 (setq number (mail-header-number gnus-tmp-header)
4781 subject (mail-header-subject gnus-tmp-header)
4782 simp-subject (gnus-simplify-subject-fully subject))
4785 ;; If the thread has changed subject, we might want to make
4786 ;; this subthread into a root.
4787 ((and (null gnus-thread-ignore-subject)
4788 (not (zerop gnus-tmp-level))
4789 gnus-tmp-prev-subject
4790 (not (string= gnus-tmp-prev-subject simp-subject)))
4791 (setq new-roots (nconc new-roots (list (car thread)))
4793 gnus-tmp-header nil))
4794 ;; If the article lies outside the current limit,
4795 ;; then we do not display it.
4796 ((not (memq number gnus-newsgroup-limit))
4797 (setq gnus-tmp-gathered
4799 (lambda (h) (mail-header-number (car h)))
4802 (setq gnus-tmp-new-adopts (if (cdar thread)
4803 (append gnus-tmp-new-adopts
4805 gnus-tmp-new-adopts)
4807 gnus-tmp-header nil)
4808 (when (zerop gnus-tmp-level)
4809 (setq gnus-tmp-root-expunged t)))
4810 ;; Perhaps this article is to be marked as read?
4811 ((and gnus-summary-mark-below
4812 (< (or (cdr (assq number gnus-newsgroup-scored))
4814 gnus-summary-mark-below)
4815 ;; Don't touch sparse articles.
4816 (not (gnus-summary-article-sparse-p number))
4817 (not (gnus-summary-article-ancient-p number)))
4818 (setq gnus-newsgroup-unreads
4819 (delq number gnus-newsgroup-unreads))
4820 (if gnus-newsgroup-auto-expire
4821 (setq gnus-newsgroup-expirable
4822 (gnus-add-to-sorted-list
4823 gnus-newsgroup-expirable number))
4824 (push (cons number gnus-low-score-mark)
4825 gnus-newsgroup-reads))))
4827 (when gnus-tmp-header
4828 ;; We may have an old dummy line to output before this
4830 (when (and gnus-tmp-dummy-line
4833 (mail-header-subject gnus-tmp-header)))
4834 (gnus-summary-insert-dummy-line
4835 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4836 (setq gnus-tmp-dummy-line nil))
4838 ;; Compute the mark.
4839 (setq gnus-tmp-unread (gnus-article-mark number))
4841 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4842 gnus-tmp-header gnus-tmp-level)
4843 gnus-newsgroup-data)
4845 ;; Actually insert the line.
4847 gnus-tmp-subject-or-nil
4849 ((and gnus-thread-ignore-subject
4850 gnus-tmp-prev-subject
4851 (not (string= gnus-tmp-prev-subject simp-subject)))
4853 ((zerop gnus-tmp-level)
4854 (if (and (eq gnus-summary-make-false-root 'empty)
4855 (memq number gnus-tmp-gathered)
4856 gnus-tmp-prev-subject
4857 (string= gnus-tmp-prev-subject simp-subject))
4858 gnus-summary-same-subject
4860 (t gnus-summary-same-subject)))
4861 (if (and (eq gnus-summary-make-false-root 'adopt)
4862 (= gnus-tmp-level 1)
4863 (memq number gnus-tmp-gathered))
4864 (setq gnus-tmp-opening-bracket ?\<
4865 gnus-tmp-closing-bracket ?\>)
4866 (setq gnus-tmp-opening-bracket ?\[
4867 gnus-tmp-closing-bracket ?\]))
4869 gnus-tmp-indentation
4870 (aref gnus-thread-indent-array gnus-tmp-level)
4871 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4872 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4873 gnus-summary-default-score 0)
4875 (if (or (null gnus-summary-default-score)
4876 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4877 gnus-summary-zcore-fuzz))
4879 (if (< gnus-tmp-score gnus-summary-default-score)
4880 gnus-score-below-mark gnus-score-over-mark))
4882 (cond ((memq number gnus-newsgroup-processable)
4884 ((memq number gnus-newsgroup-cached)
4886 ((memq number gnus-newsgroup-replied)
4888 ((memq number gnus-newsgroup-forwarded)
4889 gnus-forwarded-mark)
4890 ((memq number gnus-newsgroup-saved)
4892 ((memq number gnus-newsgroup-recent)
4894 ((memq number gnus-newsgroup-unseen)
4898 (cond ((memq number gnus-newsgroup-undownloaded)
4899 gnus-undownloaded-mark)
4900 (gnus-newsgroup-agentized
4901 gnus-downloaded-mark)
4904 gnus-tmp-from (mail-header-from gnus-tmp-header)
4907 ((string-match "<[^>]+> *$" gnus-tmp-from)
4908 (setq beg-match (match-beginning 0))
4909 (or (and (string-match "^\".+\"" gnus-tmp-from)
4910 (substring gnus-tmp-from 1 (1- (match-end 0))))
4911 (substring gnus-tmp-from 0 beg-match)))
4912 ((string-match "(.+)" gnus-tmp-from)
4913 (substring gnus-tmp-from
4914 (1+ (match-beginning 0)) (1- (match-end 0))))
4918 gnus-tmp-thread-tree-header-string
4920 ((not gnus-show-threads) "")
4921 ((zerop gnus-tmp-level)
4922 (cond ((cdar thread)
4923 (or gnus-sum-thread-tree-root subject))
4924 (gnus-tmp-new-adopts
4925 (or gnus-sum-thread-tree-false-root subject))
4927 (or gnus-sum-thread-tree-single-indent subject))))
4929 (concat (apply 'concat
4930 (mapcar (lambda (item)
4932 gnus-sum-thread-tree-vertical
4933 gnus-sum-thread-tree-indent))
4934 (cdr (reverse tree-stack))))
4936 gnus-sum-thread-tree-leaf-with-other
4937 gnus-sum-thread-tree-single-leaf)))))
4938 (when (string= gnus-tmp-name "")
4939 (setq gnus-tmp-name gnus-tmp-from))
4940 (unless (numberp gnus-tmp-lines)
4941 (setq gnus-tmp-lines -1))
4942 (if (= gnus-tmp-lines -1)
4943 (setq gnus-tmp-lines "?")
4944 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4945 (gnus-put-text-property
4947 (progn (eval gnus-summary-line-format-spec) (point))
4948 'gnus-number number)
4951 (gnus-run-hooks 'gnus-summary-update-hook)
4954 (setq gnus-tmp-prev-subject simp-subject)))
4956 (when (nth 1 thread)
4957 (push (list (max 0 gnus-tmp-level)
4958 (copy-sequence tree-stack)
4961 (push (if (nth 1 thread) 1 0) tree-stack)
4962 (incf gnus-tmp-level)
4963 (setq threads (if thread-end nil (cdar thread)))
4964 (if gnus-summary-display-while-building
4967 ;; use a set frequency
4968 (setq building-line-count (1- building-line-count))
4969 (when (= building-line-count 0)
4971 (setq building-line-count
4972 gnus-summary-display-while-building)))
4976 (setq gnus-tmp-level 0)))))
4977 (gnus-message 7 "Generating summary...done"))
4979 (defun gnus-summary-prepare-unthreaded (headers)
4980 "Generate an unthreaded summary buffer based on HEADERS."
4981 (let (header number mark)
4986 ;; We may have to root out some bad articles...
4987 (when (memq (setq number (mail-header-number
4988 (setq header (pop headers))))
4989 gnus-newsgroup-limit)
4990 ;; Mark article as read when it has a low score.
4991 (when (and gnus-summary-mark-below
4992 (< (or (cdr (assq number gnus-newsgroup-scored))
4993 gnus-summary-default-score 0)
4994 gnus-summary-mark-below)
4995 (not (gnus-summary-article-ancient-p number)))
4996 (setq gnus-newsgroup-unreads
4997 (delq number gnus-newsgroup-unreads))
4998 (if gnus-newsgroup-auto-expire
4999 (push number gnus-newsgroup-expirable)
5000 (push (cons number gnus-low-score-mark)
5001 gnus-newsgroup-reads)))
5003 (setq mark (gnus-article-mark number))
5004 (push (gnus-data-make number mark (1+ (point)) header 0)
5005 gnus-newsgroup-data)
5006 (gnus-summary-insert-line
5008 (memq number gnus-newsgroup-undownloaded)
5009 mark (memq number gnus-newsgroup-replied)
5010 (memq number gnus-newsgroup-expirable)
5011 (mail-header-subject header) nil
5012 (cdr (assq number gnus-newsgroup-scored))
5013 (memq number gnus-newsgroup-processable))))))
5015 (defun gnus-summary-remove-list-identifiers ()
5016 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5017 (let ((regexp (if (consp gnus-list-identifiers)
5018 (mapconcat 'identity gnus-list-identifiers " *\\|")
5019 gnus-list-identifiers))
5022 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5023 (dolist (header gnus-newsgroup-headers)
5024 (setq subject (mail-header-subject header)
5026 (while (string-match regexp subject)
5028 (concat (substring subject 0 (match-beginning 1))
5029 (substring subject (match-end 0)))
5032 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5034 (concat (substring subject 0 (match-beginning 1))
5035 (substring subject (match-end 1)))))
5036 (mail-header-set-subject header subject))))))
5038 (defun gnus-fetch-headers (articles)
5039 "Fetch headers of ARTICLES."
5040 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5041 (gnus-message 5 "Fetching headers for %s..." name)
5044 (setq gnus-headers-retrieved-by
5045 (gnus-retrieve-headers
5046 articles gnus-newsgroup-name
5047 ;; We might want to fetch old headers, but
5048 ;; not if there is only 1 article.
5050 (not (eq gnus-fetch-old-headers 'some))
5051 (not (numberp gnus-fetch-old-headers)))
5052 (> (length articles) 1))
5053 gnus-fetch-old-headers))))
5054 (gnus-get-newsgroup-headers-xover
5055 articles nil nil gnus-newsgroup-name t)
5056 (gnus-get-newsgroup-headers))
5057 (gnus-message 5 "Fetching headers for %s...done" name))))
5059 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5060 "Select newsgroup GROUP.
5061 If READ-ALL is non-nil, all articles in the group are selected.
5062 If SELECT-ARTICLES, only select those articles from GROUP."
5063 (let* ((entry (gnus-group-entry group))
5064 ;;!!! Dirty hack; should be removed.
5065 (gnus-summary-ignore-duplicates
5066 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5068 gnus-summary-ignore-duplicates))
5069 (info (nth 2 entry))
5070 articles fetched-articles cached)
5072 (unless (gnus-check-server
5073 (set (make-local-variable 'gnus-current-select-method)
5074 (gnus-find-method-for-group group)))
5075 (error "Couldn't open server"))
5077 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5078 (gnus-activate-group group) ; Or we can activate it...
5079 (progn ; Or we bug out.
5080 (when (equal major-mode 'gnus-summary-mode)
5081 (gnus-kill-buffer (current-buffer)))
5082 (error "Couldn't activate group %s: %s"
5083 group (gnus-status-message group))))
5085 (unless (gnus-request-group group t)
5086 (when (equal major-mode 'gnus-summary-mode)
5087 (gnus-kill-buffer (current-buffer)))
5088 (error "Couldn't request group %s: %s"
5089 group (gnus-status-message group)))
5092 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5094 (setq gnus-summary-use-undownloaded-faces
5095 (gnus-agent-find-parameter
5097 'agent-enable-undownloaded-faces)))
5099 (setq gnus-newsgroup-name group
5100 gnus-newsgroup-unselected nil
5101 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5103 (let ((display (gnus-group-find-parameter group 'display)))
5104 (setq gnus-newsgroup-display
5106 ((not (zerop (or (car-safe read-all) 0)))
5107 ;; The user entered the group with C-u SPC/RET, let's show
5113 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5115 ;; The following is probably the "correct" solution, but
5116 ;; it makes Gnus fetch all headers and then limit the
5117 ;; articles (which is slow), so instead we hack the
5118 ;; select-articles parameter instead. -- Simon Josefsson
5121 ;; (gnus-byte-compile
5122 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5124 (setq select-articles
5125 (gnus-uncompress-range
5126 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5130 (cdr (gnus-active group)))))
5135 (gnus-summary-setup-default-charset)
5137 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5138 (when (gnus-virtual-group-p group)
5139 (setq cached gnus-newsgroup-cached))
5141 (setq gnus-newsgroup-unreads
5142 (gnus-sorted-ndifference
5143 (gnus-sorted-ndifference gnus-newsgroup-unreads
5144 gnus-newsgroup-marked)
5145 gnus-newsgroup-dormant))
5147 (setq gnus-newsgroup-processable nil)
5149 (gnus-update-read-articles group gnus-newsgroup-unreads)
5151 ;; Adjust and set lists of article marks.
5153 (gnus-adjust-marked-articles info))
5154 (if (setq articles select-articles)
5155 (setq gnus-newsgroup-unselected
5156 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5157 (setq articles (gnus-articles-to-read group read-all)))
5161 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5163 ((eq articles 0) nil)
5165 ;; Init the dependencies hash table.
5166 (setq gnus-newsgroup-dependencies
5167 (gnus-make-hashtable (length articles)))
5168 (gnus-set-global-variables)
5169 ;; Retrieve the headers and read them in.
5171 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5173 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5175 (setq gnus-newsgroup-cached cached))
5177 ;; Suppress duplicates?
5178 (when gnus-suppress-duplicates
5179 (gnus-dup-suppress-articles))
5181 ;; Set the initial limit.
5182 (setq gnus-newsgroup-limit (copy-sequence articles))
5183 ;; Remove canceled articles from the list of unread articles.
5184 (setq fetched-articles
5185 (mapcar (lambda (headers) (mail-header-number headers))
5186 gnus-newsgroup-headers))
5187 (setq gnus-newsgroup-articles fetched-articles)
5188 (setq gnus-newsgroup-unreads
5189 (gnus-sorted-nintersection
5190 gnus-newsgroup-unreads fetched-articles))
5191 (gnus-compute-unseen-list)
5193 ;; Removed marked articles that do not exist.
5194 (gnus-update-missing-marks
5195 (gnus-sorted-difference articles fetched-articles))
5196 ;; We might want to build some more threads first.
5197 (when (and gnus-fetch-old-headers
5198 (eq gnus-headers-retrieved-by 'nov))
5199 (if (eq gnus-fetch-old-headers 'invisible)
5200 (gnus-build-all-threads)
5201 (gnus-build-old-threads)))
5202 ;; Let the Gnus agent mark articles as read.
5204 (gnus-agent-get-undownloaded-list))
5205 ;; Remove list identifiers from subject
5206 (when gnus-list-identifiers
5207 (gnus-summary-remove-list-identifiers))
5208 ;; Check whether auto-expire is to be done in this group.
5209 (setq gnus-newsgroup-auto-expire
5210 (gnus-group-auto-expirable-p group))
5211 ;; Set up the article buffer now, if necessary.
5212 (unless gnus-single-article-buffer
5213 (gnus-article-setup-buffer))
5214 ;; First and last article in this newsgroup.
5215 (when gnus-newsgroup-headers
5216 (setq gnus-newsgroup-begin
5217 (mail-header-number (car gnus-newsgroup-headers))
5220 (gnus-last-element gnus-newsgroup-headers))))
5221 ;; GROUP is successfully selected.
5222 (or gnus-newsgroup-headers t)))))
5224 (defun gnus-compute-unseen-list ()
5225 ;; The `seen' marks are treated specially.
5226 (if (not gnus-newsgroup-seen)
5227 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5228 (setq gnus-newsgroup-unseen
5229 (gnus-inverse-list-range-intersection
5230 gnus-newsgroup-articles gnus-newsgroup-seen))))
5232 (defun gnus-summary-display-make-predicate (display)
5233 (require 'gnus-agent)
5234 (when (= (length display) 1)
5235 (setq display (car display)))
5236 (unless gnus-summary-display-cache
5237 (dolist (elem (append '((unread . unread)
5240 gnus-article-mark-lists))
5241 (push (cons (cdr elem)
5243 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5244 gnus-summary-display-cache)))
5245 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5246 (gnus-category-predicate-cache gnus-summary-display-cache))
5247 (gnus-get-predicate display)))
5249 ;; Uses the dynamically bound `number' variable.
5252 (defun gnus-article-marked-p (type &optional article)
5253 (let ((article (or article number)))
5256 (memq article gnus-newsgroup-marked))
5258 (memq article gnus-newsgroup-spam-marked))
5260 (memq article gnus-newsgroup-unsendable))
5261 ((eq type 'undownload)
5262 (memq article gnus-newsgroup-undownloaded))
5263 ((eq type 'download)
5264 (memq article gnus-newsgroup-downloadable))
5266 (memq article gnus-newsgroup-unreads))
5268 (memq article gnus-newsgroup-reads))
5270 (memq article gnus-newsgroup-dormant) )
5272 (memq article gnus-newsgroup-expirable))
5274 (memq article gnus-newsgroup-replied))
5276 (memq article gnus-newsgroup-killed))
5277 ((eq type 'bookmark)
5278 (assq article gnus-newsgroup-bookmarks))
5280 (assq article gnus-newsgroup-scored))
5282 (memq article gnus-newsgroup-saved))
5284 (memq article gnus-newsgroup-cached))
5286 (memq article gnus-newsgroup-forwarded))
5288 (not (memq article gnus-newsgroup-unseen)))
5290 (memq article gnus-newsgroup-recent))
5293 (defun gnus-articles-to-read (group &optional read-all)
5294 "Find out what articles the user wants to read."
5296 ;; Select all articles if `read-all' is non-nil, or if there
5297 ;; are no unread articles.
5299 (and (zerop (length gnus-newsgroup-marked))
5300 (zerop (length gnus-newsgroup-unreads)))
5301 ;; Fetch all if the predicate is non-nil.
5302 gnus-newsgroup-display)
5303 ;; We want to select the headers for all the articles in
5304 ;; the group, so we select either all the active
5305 ;; articles in the group, or (if that's nil), the
5306 ;; articles in the cache.
5308 (gnus-uncompress-range (gnus-active group))
5309 (gnus-cache-articles-in-group group))
5310 ;; Select only the "normal" subset of articles.
5312 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5313 gnus-newsgroup-unreads)))
5314 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5315 (scored (length scored-list))
5316 (number (length articles))
5317 (marked (+ (length gnus-newsgroup-marked)
5318 (length gnus-newsgroup-dormant)))
5323 ((numberp gnus-newsgroup-display)
5324 gnus-newsgroup-display)
5328 ((and (or (<= scored marked) (= scored number))
5329 (numberp gnus-large-newsgroup)
5330 (> number gnus-large-newsgroup))
5331 (let* ((cursor-in-echo-area nil)
5332 (initial (gnus-parameter-large-newsgroup-initial
5333 gnus-newsgroup-name))
5337 "How many articles from %s (%s %d): "
5339 (gnus-group-decoded-name gnus-newsgroup-name)
5341 (if initial "max" "default")
5344 (cons (number-to-string initial)
5346 (if (string-match "^[ \t]*$" input) number input)))
5347 ((and (> scored marked) (< scored number)
5348 (> (- scored number) 20))
5351 (format "%s %s (%d scored, %d total): "
5352 "How many articles from"
5353 (gnus-group-decoded-name group)
5355 (if (string-match "^[ \t]*$" input)
5359 (message "Quit getting the articles to read")
5361 (setq select (if (stringp select) (string-to-number select) select))
5362 (if (or (null select) (zerop select))
5364 (if (and (not (zerop scored)) (<= (abs select) scored))
5366 (setq articles (sort scored-list '<))
5367 (setq number (length articles)))
5368 (setq articles (copy-sequence articles)))
5370 (when (< (abs select) number)
5372 ;; Select the N oldest articles.
5373 (setcdr (nthcdr (1- (abs select)) articles) nil)
5374 ;; Select the N most recent articles.
5375 (setq articles (nthcdr (- number select) articles))))
5376 (setq gnus-newsgroup-unselected
5377 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5378 (when gnus-alter-articles-to-read-function
5381 (funcall gnus-alter-articles-to-read-function
5382 gnus-newsgroup-name articles)
5386 (defun gnus-killed-articles (killed articles)
5389 (when (inline (gnus-member-of-range (car articles) killed))
5390 (push (car articles) out))
5391 (setq articles (cdr articles)))
5394 (defun gnus-uncompress-marks (marks)
5395 "Uncompress the mark ranges in MARKS."
5396 (let ((uncompressed '(score bookmark))
5399 (if (memq (caar marks) uncompressed)
5400 (push (car marks) out)
5401 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5402 (setq marks (cdr marks)))
5405 (defun gnus-article-mark-to-type (mark)
5406 "Return the type of MARK."
5407 (or (cadr (assq mark gnus-article-special-mark-lists))
5410 (defun gnus-article-unpropagatable-p (mark)
5411 "Return whether MARK should be propagated to back end."
5412 (memq mark gnus-article-unpropagated-mark-lists))
5414 (defun gnus-adjust-marked-articles (info)
5415 "Set all article lists and remove all marks that are no longer valid."
5416 (let* ((marked-lists (gnus-info-marks info))
5417 (active (gnus-active (gnus-info-group info)))
5420 (types gnus-article-mark-lists)
5421 marks var articles article mark mark-type
5424 (dolist (marks marked-lists)
5425 (setq mark (car marks)
5426 mark-type (gnus-article-mark-to-type mark)
5427 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5429 ;; We set the variable according to the type of the marks list,
5430 ;; and then adjust the marks to a subset of the active articles.
5432 ;; Adjust "simple" lists - compressed yet unsorted
5433 ((eq mark-type 'list)
5434 ;; Simultaneously uncompress and clip to active range
5435 ;; See gnus-uncompress-range for a description of possible marks
5437 (if (not (cadr marks))
5439 (setq articles (if (numberp (cddr marks))
5445 (while (setq article (pop articles))
5446 (cond ((consp article)
5447 (setq bgn (max (car article) min)
5448 end (min (cdr article) max))
5450 (setq l (setcdr l (cons bgn nil))
5452 ((and (<= min article)
5454 (setq l (setcdr l (cons article nil))))))
5455 (set var (cdr lh)))))
5457 ((eq mark-type 'tuple)
5458 (set var (setq articles (cdr marks)))
5459 (when (not (listp (cdr (symbol-value var))))
5460 (set var (list (symbol-value var))))
5461 (when (not (listp (cdr articles)))
5462 (setq articles (list articles)))
5464 (when (or (not (consp (setq article (pop articles))))
5465 (< (car article) min)
5466 (> (car article) max))
5467 (set var (delq article (symbol-value var))))))
5468 ;; Adjust ranges (sloppily).
5469 ((eq mark-type 'range)
5472 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5473 ;; It should be (seen (NUM1 . NUM2)).
5474 (when (numberp (cddr marks))
5475 (setcdr marks (list (cdr marks))))
5476 (setq articles (cdr marks))
5477 (while (and articles
5478 (or (and (consp (car articles))
5479 (> min (cdar articles)))
5480 (and (numberp (car articles))
5481 (> min (car articles)))))
5483 (set var articles))))))))
5485 (defun gnus-update-missing-marks (missing)
5486 "Go through the list of MISSING articles and remove them from the mark lists."
5489 ;; Go through all types.
5490 (dolist (elem gnus-article-mark-lists)
5491 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5492 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5493 (when (symbol-value var)
5494 ;; This list has articles. So we delete all missing
5495 ;; articles from it.
5498 (set var (delq (pop m) (symbol-value var))))))))))
5500 (defun gnus-update-marks ()
5501 "Enter the various lists of marked articles into the newsgroup info list."
5502 (let ((types gnus-article-mark-lists)
5503 (info (gnus-get-info gnus-newsgroup-name))
5504 type list newmarked symbol delta-marks)
5506 ;; Add all marks lists to the list of marks lists.
5507 (while (setq type (pop types))
5508 (setq list (symbol-value
5510 (intern (format "gnus-newsgroup-%s" (car type))))))
5513 ;; Get rid of the entries of the articles that have the
5515 (when (and (eq (cdr type) 'score)
5519 (prev (cons nil list))
5522 (if (or (not (consp (car arts)))
5523 (= (cdar arts) gnus-summary-default-score))
5524 (setcdr prev (cdr arts))
5526 (setq arts (cdr arts)))
5527 (setq list (cdr all)))))
5529 (when (eq (cdr type) 'seen)
5530 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5532 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5533 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5535 (when (and (gnus-check-backend-function
5536 'request-set-mark gnus-newsgroup-name)
5537 (not (gnus-article-unpropagatable-p (cdr type))))
5538 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5539 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5540 (add (gnus-remove-from-range
5541 (gnus-copy-sequence list) old)))
5543 (push (list add 'add (list (cdr type))) delta-marks))
5545 (push (list del 'del (list (cdr type))) delta-marks))))
5548 (push (cons (cdr type) list) newmarked)))
5551 (unless (gnus-check-group gnus-newsgroup-name)
5552 (error "Can't open server for %s" gnus-newsgroup-name))
5553 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5555 ;; Enter these new marks into the info of the group.
5557 (setcar (nthcdr 3 info) newmarked)
5558 ;; Add the marks lists to the end of the info.
5560 (setcdr (nthcdr 2 info) (list newmarked))))
5562 ;; Cut off the end of the info if there's nothing else there.
5566 (when (nthcdr (decf i) info)
5567 (setcdr (nthcdr i info) nil)))))))
5569 (defun gnus-set-mode-line (where)
5570 "Set the mode line of the article or summary buffers.
5571 If WHERE is `summary', the summary mode line format will be used."
5572 ;; Is this mode line one we keep updated?
5573 (when (and (memq where gnus-updated-mode-lines)
5575 (intern (format "gnus-%s-mode-line-format-spec" where))))
5578 ;; We evaluate this in the summary buffer since these
5579 ;; variables are buffer-local to that buffer.
5580 (set-buffer gnus-summary-buffer)
5581 ;; We bind all these variables that are used in the `eval' form
5583 (let* ((mformat (symbol-value
5585 (format "gnus-%s-mode-line-format-spec" where))))
5586 (gnus-tmp-group-name (gnus-group-decoded-name
5587 gnus-newsgroup-name))
5588 (gnus-tmp-article-number (or gnus-current-article 0))
5589 (gnus-tmp-unread gnus-newsgroup-unreads)
5590 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5591 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5592 (gnus-tmp-unread-and-unselected
5593 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5594 (zerop gnus-tmp-unselected))
5596 ((zerop gnus-tmp-unselected)
5597 (format "{%d more}" gnus-tmp-unread-and-unticked))
5598 (t (format "{%d(+%d) more}"
5599 gnus-tmp-unread-and-unticked
5600 gnus-tmp-unselected))))
5602 (if (and gnus-current-headers
5603 (vectorp gnus-current-headers))
5604 (gnus-mode-string-quote
5605 (mail-header-subject gnus-current-headers))
5607 bufname-length max-len
5608 gnus-tmp-header);; passed as argument to any user-format-funcs
5609 (setq mode-string (eval mformat))
5610 (setq bufname-length (if (string-match "%b" mode-string)
5613 (if (eq where 'summary)
5615 (get-buffer gnus-article-buffer))))
5618 (setq max-len (max 4 (if gnus-mode-non-string-length
5620 gnus-mode-non-string-length
5622 (length mode-string))))
5623 ;; We might have to chop a bit of the string off...
5624 (when (> (length mode-string) max-len)
5626 (concat (gnus-truncate-string mode-string (- max-len 3))
5628 ;; Pad the mode string a bit.
5629 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5630 ;; Update the mode line.
5631 (setq mode-line-buffer-identification
5632 (gnus-mode-line-buffer-identification (list mode-string)))
5633 (set-buffer-modified-p t))))
5635 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5636 "Go through the HEADERS list and add all Xrefs to a hash table.
5637 The resulting hash table is returned, or nil if no Xrefs were found."
5638 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5639 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5640 (xref-hashtb (gnus-make-hashtable))
5641 start group entry number xrefs header)
5643 (setq header (pop headers))
5644 (when (and (setq xrefs (mail-header-xref header))
5645 (not (memq (setq number (mail-header-number header))
5648 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5649 (setq start (match-end 0))
5650 (setq group (if prefix
5651 (concat prefix (substring xrefs (match-beginning 1)
5653 (substring xrefs (match-beginning 1) (match-end 1))))
5655 (string-to-int (substring xrefs (match-beginning 2)
5657 (if (setq entry (gnus-gethash group xref-hashtb))
5658 (setcdr entry (cons number (cdr entry)))
5659 (gnus-sethash group (cons number nil) xref-hashtb)))))
5660 (and start xref-hashtb)))
5662 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5663 "Look through all the headers and mark the Xrefs as read."
5664 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5665 name info xref-hashtb idlist method nth4)
5667 (set-buffer gnus-group-buffer)
5668 (when (setq xref-hashtb
5669 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5672 (unless (string= from-newsgroup (setq name (symbol-name group)))
5673 (setq idlist (symbol-value group))
5674 ;; Dead groups are not updated.
5676 (setq info (gnus-get-info name))
5677 (when (stringp (setq nth4 (gnus-info-method info)))
5678 (setq nth4 (gnus-server-to-method nth4))))
5679 ;; Only do the xrefs if the group has the same
5680 ;; select method as the group we have just read.
5681 (or (gnus-methods-equal-p
5682 nth4 (gnus-find-method-for-group from-newsgroup))
5684 (equal nth4 (setq method (gnus-find-method-for-group
5686 (and (equal (car nth4) (car method))
5687 (equal (nth 1 nth4) (nth 1 method))))
5688 gnus-use-cross-reference
5689 (or (not (eq gnus-use-cross-reference t))
5691 ;; Only do cross-references on subscribed
5692 ;; groups, if that is what is wanted.
5693 (<= (gnus-info-level info) gnus-level-subscribed))
5694 (gnus-group-make-articles-read name idlist))))
5697 (defun gnus-compute-read-articles (group articles)
5698 (let* ((entry (gnus-group-entry group))
5699 (info (nth 2 entry))
5700 (active (gnus-active group))
5703 ;; First peel off all invalid article numbers.
5705 (let ((ids articles)
5707 (while (setq id (pop ids))
5708 (when (and first (> id (cdr active)))
5709 ;; We'll end up in this situation in one particular
5710 ;; obscure situation. If you re-scan a group and get
5711 ;; a new article that is cross-posted to a different
5712 ;; group that has not been re-scanned, you might get
5713 ;; crossposted article that has a higher number than
5714 ;; Gnus believes possible. So we re-activate this
5715 ;; group as well. This might mean doing the
5716 ;; crossposting thingy will *increase* the number
5717 ;; of articles in some groups. Tsk, tsk.
5718 (setq active (or (gnus-activate-group group) active)))
5719 (when (or (> id (cdr active))
5720 (< id (car active)))
5721 (setq articles (delq id articles))))))
5722 ;; If the read list is nil, we init it.
5724 (null (gnus-info-read info))
5726 (setq ninfo (cons 1 (1- (car active))))
5727 (setq ninfo (gnus-info-read info)))
5728 ;; Then we add the read articles to the range.
5730 ninfo (setq articles (sort articles '<))))))
5732 (defun gnus-group-make-articles-read (group articles)
5733 "Update the info of GROUP to say that ARTICLES are read."
5735 (entry (gnus-group-entry group))
5736 (info (nth 2 entry))
5737 (active (gnus-active group))
5740 (setq range (gnus-compute-read-articles group articles))
5741 (with-current-buffer gnus-group-buffer
5744 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5745 (gnus-info-set-read ',info ',(gnus-info-read info))
5746 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5747 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5748 (gnus-group-update-group ,group t))))
5749 ;; Add the read articles to the range.
5750 (gnus-info-set-read info range)
5751 (gnus-request-set-mark group (list (list range 'add '(read))))
5752 ;; Then we have to re-compute how many unread
5753 ;; articles there are in this group.
5757 (setq num (- (1+ (cdr active)) (car active))))
5758 ((not (listp (cdr range)))
5759 (setq num (- (cdr active) (- (1+ (cdr range))
5763 (if (numberp (car range))
5765 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5766 (setq range (cdr range)))
5767 (setq num (- (cdr active) num))))
5768 ;; Update the number of unread articles.
5770 ;; Update the group buffer.
5771 (unless (gnus-ephemeral-group-p group)
5772 (gnus-group-update-group group t))))))
5774 (defvar gnus-newsgroup-none-id 0)
5776 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5777 (let ((cur nntp-server-buffer)
5780 (with-current-buffer gnus-summary-buffer
5781 gnus-newsgroup-dependencies)))
5782 headers id end ref number
5783 (mail-parse-charset gnus-newsgroup-charset)
5784 (mail-parse-ignored-charsets
5785 (save-excursion (condition-case nil
5786 (set-buffer gnus-summary-buffer)
5788 gnus-newsgroup-ignored-charsets)))
5790 (set-buffer nntp-server-buffer)
5791 ;; Translate all TAB characters into SPACE characters.
5792 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5793 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5794 (ietf-drums-unfold-fws)
5795 (gnus-run-hooks 'gnus-parse-headers-hook)
5796 (let ((case-fold-search t)
5797 in-reply-to header p lines chars ctype)
5798 (goto-char (point-min))
5799 ;; Search to the beginning of the next header. Error messages
5800 ;; do not begin with 2 or 3.
5801 (while (re-search-forward "^[23][0-9]+ " nil t)
5804 ;; This implementation of this function, with nine
5805 ;; search-forwards instead of the one re-search-forward and
5806 ;; a case (which basically was the old function) is actually
5807 ;; about twice as fast, even though it looks messier. You
5808 ;; can't have everything, I guess. Speed and elegance
5809 ;; doesn't always go hand in hand.
5812 (make-full-mail-header
5815 (setq number (read cur))
5818 (narrow-to-region (point)
5819 (or (and (search-forward "\n.\n" nil t)
5825 (if (search-forward "\nsubject:" nil t)
5826 (nnheader-header-value)
5831 (if (search-forward "\nfrom:" nil t)
5832 (nnheader-header-value)
5837 (if (search-forward "\ndate:" nil t)
5838 (nnheader-header-value) ""))
5842 (setq id (if (re-search-forward
5843 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5844 ;; We do it this way to make sure the Message-ID
5845 ;; is (somewhat) syntactically valid.
5846 (buffer-substring (match-beginning 1)
5848 ;; If there was no message-id, we just fake one
5849 ;; to make subsequent routines simpler.
5850 (nnheader-generate-fake-message-id number))))
5854 (if (search-forward "\nreferences:" nil t)
5858 (nnheader-header-value)
5863 (search-backward ">" end t)
5866 (search-backward "<" end t)
5868 ;; Get the references from the in-reply-to header if there
5869 ;; were no references and the in-reply-to header looks
5871 (if (and (search-forward "\nin-reply-to:" nil t)
5872 (setq in-reply-to (nnheader-header-value))
5873 (string-match "<[^>]+>" in-reply-to))
5875 (setq ref (substring in-reply-to (match-beginning 0)
5877 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5878 (setq ref2 (substring in-reply-to (match-beginning 0)
5880 (when (> (length ref2) (length ref))
5887 (if (search-forward "\nchars: " nil t)
5888 (if (numberp (setq chars (ignore-errors (read cur))))
5894 (if (search-forward "\nlines: " nil t)
5895 (if (numberp (setq lines (ignore-errors (read cur))))
5901 (and (search-forward "\nxref:" nil t)
5902 (nnheader-header-value)))
5904 (when gnus-extra-headers
5905 (let ((extra gnus-extra-headers)
5909 (when (search-forward
5910 (concat "\n" (symbol-name (car extra)) ":") nil t)
5911 (push (cons (car extra) (nnheader-header-value)) out))
5915 (if (and (search-forward "\ncontent-type: " nil t)
5916 (setq ctype (nnheader-header-value)))
5917 (mime-entity-set-content-type-internal
5918 header (mime-parse-Content-Type ctype)))
5919 (when (equal id ref)
5922 (when gnus-alter-header-function
5923 (funcall gnus-alter-header-function header)
5924 (setq id (mail-header-id header)
5925 ref (gnus-parent-id (mail-header-references header))))
5928 (gnus-dependencies-add-header
5929 header dependencies force-new))
5930 (push header headers))
5931 (goto-char (point-max))
5933 (nreverse headers)))))
5935 ;; Goes through the xover lines and returns a list of vectors
5936 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5937 force-new dependencies
5938 group also-fetch-heads)
5939 "Parse the news overview data in the server buffer.
5940 Return a list of headers that match SEQUENCE (see
5941 `nntp-retrieve-headers')."
5942 ;; Get the Xref when the users reads the articles since most/some
5943 ;; NNTP servers do not include Xrefs when using XOVER.
5944 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5945 (let ((mail-parse-charset gnus-newsgroup-charset)
5946 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5947 (cur nntp-server-buffer)
5948 (dependencies (or dependencies gnus-newsgroup-dependencies))
5950 ((eq gnus-read-all-available-headers t)
5952 ((stringp gnus-read-all-available-headers)
5953 (string-match gnus-read-all-available-headers group))
5956 number headers header)
5958 (set-buffer nntp-server-buffer)
5959 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5960 ;; Allow the user to mangle the headers before parsing them.
5961 (gnus-run-hooks 'gnus-parse-headers-hook)
5962 (goto-char (point-min))
5963 (gnus-parse-without-error
5964 (while (and (or sequence allp)
5966 (setq number (read cur))
5968 (while (and sequence
5969 (< (car sequence) number))
5970 (setq sequence (cdr sequence))))
5973 (eq number (car sequence))))
5975 (setq sequence (cdr sequence))
5976 (setq header (inline
5977 (gnus-nov-parse-line
5978 number dependencies force-new)))))
5979 (push header headers))
5981 ;; A common bug in inn is that if you have posted an article and
5982 ;; then retrieves the active file, it will answer correctly --
5983 ;; the new article is included. However, a NOV entry for the
5984 ;; article may not have been generated yet, so this may fail.
5985 ;; We work around this problem by retrieving the last few
5986 ;; headers using HEAD.
5987 (if (or (not also-fetch-heads)
5989 ;; We (probably) got all the headers.
5991 (let ((gnus-nov-is-evil t))
5994 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5995 (gnus-get-newsgroup-headers))))))))
5997 (defun gnus-article-get-xrefs ()
5998 "Fill in the Xref value in `gnus-current-headers', if necessary.
5999 This is meant to be called in `gnus-article-internal-prepare-hook'."
6000 (let ((headers (with-current-buffer gnus-summary-buffer
6001 gnus-current-headers)))
6002 (or (not gnus-use-cross-reference)
6004 (and (mail-header-xref headers)
6005 (not (string= (mail-header-xref headers) "")))
6006 (let ((case-fold-search t)
6009 (nnheader-narrow-to-headers)
6010 (goto-char (point-min))
6011 (when (or (and (not (eobp))
6012 (eq (downcase (char-after)) ?x)
6013 (looking-at "Xref:"))
6014 (search-forward "\nXref:" nil t))
6015 (goto-char (1+ (match-end 0)))
6016 (setq xref (buffer-substring (point) (point-at-eol)))
6017 (mail-header-set-xref headers xref)))))))
6019 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6020 "Find article ID and insert the summary line for that article.
6021 OLD-HEADER can either be a header or a line number to insert
6022 the subject line on."
6023 (let* ((line (and (numberp old-header) old-header))
6024 (old-header (and (vectorp old-header) old-header))
6025 (header (cond ((and old-header use-old-header)
6028 (gnus-number-to-header id))
6029 (gnus-number-to-header id))
6031 (gnus-read-header id))))
6032 (number (and (numberp id) id))
6035 ;; Rebuild the thread that this article is part of and go to the
6036 ;; article we have fetched.
6037 (when (and (not gnus-show-threads)
6040 (setq d (gnus-data-find (mail-header-number old-header))))
6041 (goto-char (gnus-data-pos d))
6047 (gnus-delete-line))))))
6049 (mail-header-set-number header (mail-header-number old-header)))
6050 (setq gnus-newsgroup-sparse
6051 (delq (setq number (mail-header-number header))
6052 gnus-newsgroup-sparse))
6053 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6054 (push number gnus-newsgroup-limit)
6055 (gnus-rebuild-thread (mail-header-id header) line)
6056 (gnus-summary-goto-subject number nil t))
6057 (when (and (numberp number)
6059 ;; We have to update the boundaries even if we can't fetch the
6060 ;; article if ID is a number -- so that the next `P' or `N'
6061 ;; command will fetch the previous (or next) article even
6062 ;; if the one we tried to fetch this time has been canceled.
6063 (when (> number gnus-newsgroup-end)
6064 (setq gnus-newsgroup-end number))
6065 (when (< number gnus-newsgroup-begin)
6066 (setq gnus-newsgroup-begin number))
6067 (setq gnus-newsgroup-unselected
6068 (delq number gnus-newsgroup-unselected)))
6069 ;; Report back a success?
6070 (and header (mail-header-number header))))
6072 ;;; Process/prefix in the summary buffer
6074 (defun gnus-summary-work-articles (n)
6075 "Return a list of articles to be worked upon.
6076 The prefix argument, the list of process marked articles, and the
6077 current article will be taken into consideration."
6079 (set-buffer gnus-summary-buffer)
6082 ;; A numerical prefix has been given.
6083 (setq n (prefix-numeric-value n))
6084 (let ((backward (< n 0))
6085 (n (abs (prefix-numeric-value n)))
6090 (push (setq article (gnus-summary-article-number))
6093 (gnus-summary-find-prev nil article)
6094 (gnus-summary-find-next nil article)))
6096 (nreverse articles)))
6097 ((and (gnus-region-active-p) (mark))
6098 (message "region active")
6099 ;; Work on the region between point and mark.
6100 (let ((max (max (point) (mark)))
6103 (goto-char (min (point) (mark)))
6106 (push (setq article (gnus-summary-article-number)) articles)
6107 (gnus-summary-find-next nil article)
6109 (nreverse articles))))
6110 (gnus-newsgroup-processable
6111 ;; There are process-marked articles present.
6112 ;; Save current state.
6113 (gnus-summary-save-process-mark)
6115 (reverse gnus-newsgroup-processable))
6117 ;; Just return the current article.
6118 (list (gnus-summary-article-number))))))
6120 (defmacro gnus-summary-iterate (arg &rest forms)
6121 "Iterate over the process/prefixed articles and do FORMS.
6122 ARG is the interactive prefix given to the command. FORMS will be
6123 executed with point over the summary line of the articles."
6124 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6125 `(let ((,articles (gnus-summary-work-articles ,arg)))
6127 (gnus-summary-goto-subject (car ,articles))
6131 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6132 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6134 (defun gnus-summary-save-process-mark ()
6135 "Push the current set of process marked articles on the stack."
6137 (push (copy-sequence gnus-newsgroup-processable)
6138 gnus-newsgroup-process-stack))
6140 (defun gnus-summary-kill-process-mark ()
6141 "Push the current set of process marked articles on the stack and unmark."
6143 (gnus-summary-save-process-mark)
6144 (gnus-summary-unmark-all-processable))
6146 (defun gnus-summary-yank-process-mark ()
6147 "Pop the last process mark state off the stack and restore it."
6149 (unless gnus-newsgroup-process-stack
6150 (error "Empty mark stack"))
6151 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6153 (defun gnus-summary-process-mark-set (set)
6154 "Make SET into the current process marked articles."
6155 (gnus-summary-unmark-all-processable)
6157 (gnus-summary-set-process-mark (pop set))))
6159 ;;; Searching and stuff
6161 (defun gnus-summary-search-group (&optional backward use-level)
6162 "Search for next unread newsgroup.
6163 If optional argument BACKWARD is non-nil, search backward instead."
6165 (set-buffer gnus-group-buffer)
6166 (when (gnus-group-search-forward
6167 backward nil (if use-level (gnus-group-group-level) nil))
6168 (gnus-group-group-name))))
6170 (defun gnus-summary-best-group (&optional exclude-group)
6171 "Find the name of the best unread group.
6172 If EXCLUDE-GROUP, do not go to this group."
6173 (with-current-buffer gnus-group-buffer
6175 (gnus-group-best-unread-group exclude-group))))
6177 (defun gnus-summary-find-next (&optional unread article backward)
6179 (gnus-summary-find-prev unread article)
6180 (let* ((dummy (gnus-summary-article-intangible-p))
6181 (article (or article (gnus-summary-article-number)))
6182 (data (gnus-data-find-list article))
6184 (when (and (not dummy)
6185 (or (not gnus-summary-check-current)
6187 (not (gnus-data-unread-p (car data)))))
6188 (setq data (cdr data)))
6193 (unless (memq (gnus-data-number (car data))
6195 ((eq gnus-auto-goto-ignores
6196 'always-undownloaded)
6197 gnus-newsgroup-undownloaded)
6200 ((eq gnus-auto-goto-ignores
6202 gnus-newsgroup-unfetched)
6203 ((eq gnus-auto-goto-ignores
6205 gnus-newsgroup-undownloaded)))
6206 (when (gnus-data-unread-p (car data))
6207 (setq result (car data)
6209 (setq data (cdr data)))
6212 (goto-char (gnus-data-pos result))
6213 (gnus-data-number result)))))
6215 (defun gnus-summary-find-prev (&optional unread article)
6216 (let* ((eobp (eobp))
6217 (article (or article (gnus-summary-article-number)))
6218 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6220 (when (and (not eobp)
6221 (or (not gnus-summary-check-current)
6223 (not (gnus-data-unread-p (car data)))))
6224 (setq data (cdr data)))
6229 (unless (memq (gnus-data-number (car data))
6231 ((eq gnus-auto-goto-ignores
6232 'always-undownloaded)
6233 gnus-newsgroup-undownloaded)
6236 ((eq gnus-auto-goto-ignores
6238 gnus-newsgroup-unfetched)
6239 ((eq gnus-auto-goto-ignores
6241 gnus-newsgroup-undownloaded)))
6242 (when (gnus-data-unread-p (car data))
6243 (setq result (car data)
6245 (setq data (cdr data)))
6248 (goto-char (gnus-data-pos result))
6249 (gnus-data-number result))))
6251 (defun gnus-summary-find-subject (subject &optional unread backward article)
6252 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6253 (article (or article (gnus-summary-article-number)))
6254 (articles (gnus-data-list backward))
6255 (arts (gnus-data-find-list article articles))
6257 (when (or (not gnus-summary-check-current)
6259 (not (gnus-data-unread-p (car arts))))
6260 (setq arts (cdr arts)))
6262 (and (or (not unread)
6263 (gnus-data-unread-p (car arts)))
6264 (vectorp (gnus-data-header (car arts)))
6266 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6267 (setq result (car arts)
6269 (setq arts (cdr arts)))
6271 (goto-char (gnus-data-pos result))
6272 (gnus-data-number result))))
6274 (defun gnus-summary-search-forward (&optional unread subject backward)
6275 "Search forward for an article.
6276 If UNREAD, look for unread articles. If SUBJECT, look for
6277 articles with that subject. If BACKWARD, search backward instead."
6278 (cond (subject (gnus-summary-find-subject subject unread backward))
6279 (backward (gnus-summary-find-prev unread))
6280 (t (gnus-summary-find-next unread))))
6282 (defun gnus-recenter (&optional n)
6283 "Center point in window and redisplay frame.
6284 Also do horizontal recentering."
6286 (when (and gnus-auto-center-summary
6287 (not (eq gnus-auto-center-summary 'vertical)))
6288 (gnus-horizontal-recenter))
6291 (defun gnus-summary-recenter ()
6292 "Center point in the summary window.
6293 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6294 displayed, no centering will be performed."
6295 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6296 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6298 ;; The user has to want it.
6299 (when gnus-auto-center-summary
6300 (let* ((top (cond ((< (window-height) 4) 0)
6301 ((< (window-height) 7) 1)
6302 (t (if (numberp gnus-auto-center-summary)
6303 gnus-auto-center-summary
6304 (/ (1- (window-height)) 2)))))
6305 (height (1- (window-height)))
6306 (bottom (save-excursion (goto-char (point-max))
6307 (forward-line (- height))
6309 (window (get-buffer-window (current-buffer))))
6310 (when (get-buffer-window gnus-article-buffer)
6311 ;; Only do recentering when the article buffer is displayed,
6312 ;; Set the window start to either `bottom', which is the biggest
6313 ;; possible valid number, or the second line from the top,
6314 ;; whichever is the least.
6315 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6316 (if (> bottom top-pos)
6317 ;; Keep the second line from the top visible
6318 (set-window-start window top-pos t)
6319 ;; Try to keep the bottom line visible; if it's partially
6320 ;; obscured, either scroll one more line to make it fully
6321 ;; visible, or revert to using TOP-POS.
6323 (goto-char (point-max))
6325 (let ((last-line-start (point)))
6327 (set-window-start window (point) t)
6328 (when (not (pos-visible-in-window-p last-line-start window))
6330 (set-window-start window (min (point) top-pos) t)))))))
6331 ;; Do horizontal recentering while we're at it.
6332 (when (and (get-buffer-window (current-buffer) t)
6333 (not (eq gnus-auto-center-summary 'vertical)))
6334 (let ((selected (selected-window)))
6335 (select-window (get-buffer-window (current-buffer) t))
6336 (gnus-summary-position-point)
6337 (gnus-horizontal-recenter)
6338 (select-window selected))))))
6340 (defun gnus-summary-jump-to-group (newsgroup)
6341 "Move point to NEWSGROUP in group mode buffer."
6342 ;; Keep update point of group mode buffer if visible.
6343 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6344 (save-window-excursion
6345 ;; Take care of tree window mode.
6346 (when (get-buffer-window gnus-group-buffer)
6347 (pop-to-buffer gnus-group-buffer))
6348 (gnus-group-jump-to-group newsgroup))
6350 ;; Take care of tree window mode.
6351 (if (get-buffer-window gnus-group-buffer)
6352 (pop-to-buffer gnus-group-buffer)
6353 (set-buffer gnus-group-buffer))
6354 (gnus-group-jump-to-group newsgroup))))
6356 ;; This function returns a list of article numbers based on the
6357 ;; difference between the ranges of read articles in this group and
6358 ;; the range of active articles.
6359 (defun gnus-list-of-unread-articles (group)
6360 (let* ((read (gnus-info-read (gnus-get-info group)))
6361 (active (or (gnus-active group) (gnus-activate-group group)))
6364 ;; If none are read, then all are unread.
6366 (setq first (car active))
6367 ;; If the range of read articles is a single range, then the
6368 ;; first unread article is the article after the last read
6369 ;; article. Sounds logical, doesn't it?
6370 (if (and (not (listp (cdr read)))
6371 (or (< (car read) (car active))
6372 (progn (setq read (list read))
6374 (setq first (max (car active) (1+ (cdr read))))
6375 ;; `read' is a list of ranges.
6376 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6379 (setq first (car active)))
6382 (while (< first nlast)
6383 (setq unread (cons first unread)
6385 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6386 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6387 (setq read (cdr read)))))
6388 ;; And add the last unread articles.
6389 (while (<= first last)
6390 (setq unread (cons first unread)
6392 ;; Return the list of unread articles.
6393 (delq 0 (nreverse unread))))
6395 (defun gnus-list-of-read-articles (group)
6396 "Return a list of unread, unticked and non-dormant articles."
6397 (let* ((info (gnus-get-info group))
6398 (marked (gnus-info-marks info))
6399 (active (gnus-active group)))
6401 (gnus-list-range-difference
6402 (gnus-list-range-difference
6403 (gnus-sorted-complement
6404 (gnus-uncompress-range active)
6405 (gnus-list-of-unread-articles group))
6406 (cdr (assq 'dormant marked)))
6407 (cdr (assq 'tick marked))))))
6409 ;; This function returns a sequence of article numbers based on the
6410 ;; difference between the ranges of read articles in this group and
6411 ;; the range of active articles.
6412 (defun gnus-sequence-of-unread-articles (group)
6413 (let* ((read (gnus-info-read (gnus-get-info group)))
6414 (active (or (gnus-active group) (gnus-activate-group group)))
6417 ;; If none are read, then all are unread.
6419 (setq first (car active))
6420 ;; If the range of read articles is a single range, then the
6421 ;; first unread article is the article after the last read
6422 ;; article. Sounds logical, doesn't it?
6423 (if (and (not (listp (cdr read)))
6424 (or (< (car read) (car active))
6425 (progn (setq read (list read))
6427 (setq first (max (car active) (1+ (cdr read))))
6428 ;; `read' is a list of ranges.
6429 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6432 (setq first (car active)))
6435 (push (cons first nlast) unread))
6436 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6437 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6438 (setq read (cdr read)))))
6439 ;; And add the last unread articles.
6440 (cond ((< first last)
6441 (push (cons first last) unread))
6443 (push first unread)))
6444 ;; Return the sequence of unread articles.
6445 (delq 0 (nreverse unread))))
6447 ;; Various summary commands
6449 (defun gnus-summary-select-article-buffer ()
6450 "Reconfigure windows to show article buffer."
6452 (if (not (gnus-buffer-live-p gnus-article-buffer))
6453 (error "There is no article buffer for this summary buffer")
6454 (gnus-configure-windows 'article)
6455 (select-window (get-buffer-window gnus-article-buffer))))
6457 (defun gnus-summary-universal-argument (arg)
6458 "Perform any operation on all articles that are process/prefixed."
6460 (let ((articles (gnus-summary-work-articles arg))
6467 (substitute-command-keys
6468 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6470 (gnus-error 1 "Undefined key")
6473 (gnus-summary-goto-subject (setq article (pop articles)))
6474 (let (gnus-newsgroup-processable)
6475 (command-execute func))
6476 (gnus-summary-remove-process-mark article)))))
6477 (gnus-summary-position-point))
6479 (defun gnus-summary-toggle-truncation (&optional arg)
6480 "Toggle truncation of summary lines.
6481 With ARG, turn line truncation on if ARG is positive."
6483 (setq truncate-lines
6484 (if (null arg) (not truncate-lines)
6485 (> (prefix-numeric-value arg) 0)))
6488 (defun gnus-summary-find-for-reselect ()
6489 "Return the number of an article to stay on across a reselect.
6490 The current article is considered, then following articles, then previous
6491 articles. An article is sought which is not cancelled and isn't a temporary
6492 insertion from another group. If there's no such then return a dummy 0."
6494 (dolist (rev '(nil t))
6495 (unless found ; don't demand the reverse list if we don't need it
6496 (let ((data (gnus-data-find-list
6497 (gnus-summary-article-number) (gnus-data-list rev))))
6498 (while (and data (not found))
6499 (if (and (< 0 (gnus-data-number (car data)))
6500 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6501 (setq found (gnus-data-number (car data))))
6502 (setq data (cdr data))))))
6505 (defun gnus-summary-reselect-current-group (&optional all rescan)
6506 "Exit and then reselect the current newsgroup.
6507 The prefix argument ALL means to select all articles."
6509 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6510 (error "Ephemeral groups can't be reselected"))
6511 (let ((current-subject (gnus-summary-find-for-reselect))
6512 (group gnus-newsgroup-name))
6513 (setq gnus-newsgroup-begin nil)
6514 (gnus-summary-exit nil 'leave-hidden)
6515 ;; We have to adjust the point of group mode buffer because
6516 ;; point was moved to the next unread newsgroup by exiting.
6517 (gnus-summary-jump-to-group group)
6520 (save-window-excursion
6521 ;; Don't show group contents.
6522 (set-window-start (selected-window) (point-max))
6523 (gnus-group-get-new-news-this-group 1))))
6524 (gnus-group-read-group all t)
6525 (gnus-summary-goto-subject current-subject nil t)))
6527 (defun gnus-summary-rescan-group (&optional all)
6528 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6530 (gnus-summary-reselect-current-group all t))
6532 (defun gnus-summary-update-info (&optional non-destructive)
6534 (let ((group gnus-newsgroup-name))
6536 (when gnus-newsgroup-kill-headers
6537 (setq gnus-newsgroup-killed
6538 (gnus-compress-sequence
6540 (gnus-list-range-intersection
6541 gnus-newsgroup-unselected gnus-newsgroup-killed)
6542 gnus-newsgroup-unreads)
6544 (unless (listp (cdr gnus-newsgroup-killed))
6545 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6546 (let ((headers gnus-newsgroup-headers))
6547 ;; Set the new ranges of read articles.
6548 (with-current-buffer gnus-group-buffer
6549 (gnus-undo-force-boundary))
6550 (gnus-update-read-articles
6551 group (gnus-sorted-union
6552 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6553 ;; Set the current article marks.
6554 (let ((gnus-newsgroup-scored
6555 (if (and (not gnus-save-score)
6556 (not non-destructive))
6558 gnus-newsgroup-scored)))
6560 (gnus-update-marks)))
6561 ;; Do the cross-ref thing.
6562 (when gnus-use-cross-reference
6563 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6564 ;; Do not switch windows but change the buffer to work.
6565 (set-buffer gnus-group-buffer)
6566 (unless (gnus-ephemeral-group-p group)
6567 (gnus-group-update-group group)))))))
6569 (defun gnus-summary-save-newsrc (&optional force)
6570 "Save the current number of read/marked articles in the dribble buffer.
6571 The dribble buffer will then be saved.
6572 If FORCE (the prefix), also save the .newsrc file(s)."
6574 (gnus-summary-update-info t)
6576 (gnus-save-newsrc-file)
6577 (gnus-dribble-save)))
6579 (defun gnus-summary-exit (&optional temporary leave-hidden)
6580 "Exit reading current newsgroup, and then return to group selection mode.
6581 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6583 (gnus-set-global-variables)
6584 (gnus-kill-save-kill-buffer)
6585 (gnus-async-halt-prefetch)
6586 (let* ((group gnus-newsgroup-name)
6587 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6588 (gnus-group-is-exiting-p t)
6591 (buf (current-buffer)))
6593 ;; Do adaptive scoring, and possibly save score files.
6594 (when gnus-newsgroup-adaptive
6595 (gnus-score-adaptive))
6596 (when gnus-use-scoring
6598 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6599 ;; If we have several article buffers, we kill them at exit.
6600 (unless gnus-single-article-buffer
6601 (gnus-kill-buffer gnus-original-article-buffer)
6602 (setq gnus-article-current nil))
6603 (when gnus-use-cache
6604 (gnus-cache-possibly-remove-articles)
6605 (gnus-cache-save-buffers))
6606 (gnus-async-prefetch-remove-group group)
6607 (when gnus-suppress-duplicates
6608 (gnus-dup-enter-articles))
6609 (when gnus-use-trees
6610 (gnus-tree-close group))
6611 (when gnus-use-cache
6612 (gnus-cache-write-active))
6613 ;; Remove entries for this group.
6614 (nnmail-purge-split-history (gnus-group-real-name group))
6615 ;; Make all changes in this group permanent.
6617 (gnus-run-hooks 'gnus-exit-group-hook)
6618 (gnus-summary-update-info))
6619 (gnus-close-group group)
6620 ;; Make sure where we were, and go to next newsgroup.
6621 (set-buffer gnus-group-buffer)
6623 (gnus-group-jump-to-group group))
6624 (gnus-run-hooks 'gnus-summary-exit-hook)
6625 (unless (or quit-config
6626 ;; If this group has disappeared from the summary
6627 ;; buffer, don't skip forwards.
6628 (not (string= group (gnus-group-group-name))))
6629 (gnus-group-next-unread-group 1))
6630 (setq group-point (point))
6633 ;; If we have several article buffers, we kill them at exit.
6634 (unless gnus-single-article-buffer
6635 (gnus-kill-buffer gnus-article-buffer)
6636 (gnus-kill-buffer gnus-original-article-buffer)
6637 (setq gnus-article-current nil))
6639 (if (not gnus-kill-summary-on-exit)
6641 (gnus-deaden-summary)
6643 ;; We set all buffer-local variables to nil. It is unclear why
6644 ;; this is needed, but if we don't, buffer-local variables are
6645 ;; not garbage-collected, it seems. This would the lead to en
6646 ;; ever-growing Emacs.
6647 (gnus-summary-clear-local-variables)
6648 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6649 (gnus-summary-clear-local-variables))
6650 (when (get-buffer gnus-article-buffer)
6651 (bury-buffer gnus-article-buffer))
6652 ;; We clear the global counterparts of the buffer-local
6653 ;; variables as well, just to be on the safe side.
6654 (set-buffer gnus-group-buffer)
6655 (gnus-summary-clear-local-variables)
6656 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6657 (gnus-summary-clear-local-variables))
6658 ;; Return to group mode buffer.
6659 (when (eq mode 'gnus-summary-mode)
6660 (gnus-kill-buffer buf)))
6661 (setq gnus-current-select-method gnus-select-method)
6663 (set-buffer gnus-group-buffer)
6664 (pop-to-buffer gnus-group-buffer))
6665 (if (not quit-config)
6667 (goto-char group-point)
6668 (unless leave-hidden
6669 (gnus-configure-windows 'group 'force))
6670 (unless (pos-visible-in-window-p)
6671 (forward-line (/ (static-if (featurep 'xemacs)
6672 (window-displayed-height)
6673 (1- (window-height)))
6675 (set-window-start (selected-window) (point))
6676 (goto-char group-point)))
6677 (gnus-handle-ephemeral-exit quit-config))
6678 ;; Clear the current group name.
6680 (setq gnus-newsgroup-name nil)))))
6682 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6683 (defun gnus-summary-exit-no-update (&optional no-questions)
6684 "Quit reading current newsgroup without updating read article info."
6686 (let* ((group gnus-newsgroup-name)
6687 (gnus-group-is-exiting-p t)
6688 (gnus-group-is-exiting-without-update-p t)
6689 (quit-config (gnus-group-quit-config group)))
6690 (when (or no-questions
6692 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6693 (gnus-async-halt-prefetch)
6694 (run-hooks 'gnus-summary-prepare-exit-hook)
6695 ;; If we have several article buffers, we kill them at exit.
6696 (unless gnus-single-article-buffer
6697 (gnus-kill-buffer gnus-article-buffer)
6698 (gnus-kill-buffer gnus-original-article-buffer)
6699 (setq gnus-article-current nil))
6700 (if (not gnus-kill-summary-on-exit)
6701 (gnus-deaden-summary)
6702 (gnus-close-group group)
6703 (gnus-summary-clear-local-variables)
6704 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6705 (gnus-summary-clear-local-variables))
6706 (set-buffer gnus-group-buffer)
6707 (gnus-summary-clear-local-variables)
6708 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6709 (gnus-summary-clear-local-variables))
6710 (gnus-kill-buffer gnus-summary-buffer))
6711 (unless gnus-single-article-buffer
6712 (setq gnus-article-current nil))
6713 (when gnus-use-trees
6714 (gnus-tree-close group))
6715 (gnus-async-prefetch-remove-group group)
6716 (when (get-buffer gnus-article-buffer)
6717 (bury-buffer gnus-article-buffer))
6718 ;; Return to the group buffer.
6719 (gnus-configure-windows 'group 'force)
6720 ;; Clear the current group name.
6721 (setq gnus-newsgroup-name nil)
6722 (unless (gnus-ephemeral-group-p group)
6723 (gnus-group-update-group group))
6724 (when (equal (gnus-group-group-name) group)
6725 (gnus-group-next-unread-group 1))
6727 (gnus-handle-ephemeral-exit quit-config)))))
6729 (defun gnus-handle-ephemeral-exit (quit-config)
6730 "Handle movement when leaving an ephemeral group.
6731 The state which existed when entering the ephemeral is reset."
6732 (if (not (buffer-name (car quit-config)))
6733 (gnus-configure-windows 'group 'force)
6734 (set-buffer (car quit-config))
6735 (cond ((eq major-mode 'gnus-summary-mode)
6736 (gnus-set-global-variables))
6737 ((eq major-mode 'gnus-article-mode)
6739 ;; The `gnus-summary-buffer' variable may point
6740 ;; to the old summary buffer when using a single
6742 (unless (gnus-buffer-live-p gnus-summary-buffer)
6743 (set-buffer gnus-group-buffer))
6744 (set-buffer gnus-summary-buffer)
6745 (gnus-set-global-variables))))
6746 (if (or (eq (cdr quit-config) 'article)
6747 (eq (cdr quit-config) 'pick))
6749 ;; The current article may be from the ephemeral group
6750 ;; thus it is best that we reload this article
6752 ;; If we're exiting from a large digest, this can be
6753 ;; extremely slow. So, it's better not to reload it. -- jh.
6754 ;;(gnus-summary-show-article)
6755 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6756 (gnus-configure-windows 'pick 'force)
6757 (gnus-configure-windows (cdr quit-config) 'force)))
6758 (gnus-configure-windows (cdr quit-config) 'force))
6759 (when (eq major-mode 'gnus-summary-mode)
6760 (gnus-summary-next-subject 1 nil t)
6761 (gnus-summary-recenter)
6762 (gnus-summary-position-point))))
6764 (defun gnus-summary-preview-mime-message ()
6765 "MIME decode and play this message."
6767 (let ((gnus-break-pages nil)
6769 (gnus-summary-select-article gnus-show-all-headers t))
6770 (let ((w (get-buffer-window gnus-article-buffer)))
6772 (select-window (get-buffer-window gnus-article-buffer)))))
6776 (defvar gnus-dead-summary-mode-map nil)
6778 (unless gnus-dead-summary-mode-map
6779 (setq gnus-dead-summary-mode-map (make-keymap))
6780 (suppress-keymap gnus-dead-summary-mode-map)
6781 (substitute-key-definition
6782 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6783 (dolist (key '("\C-d" "\r" "\177" [delete]))
6784 (define-key gnus-dead-summary-mode-map
6785 key 'gnus-summary-wake-up-the-dead))
6786 (dolist (key '("q" "Q"))
6787 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6789 (defvar gnus-dead-summary-mode nil
6790 "Minor mode for Gnus summary buffers.")
6792 (defun gnus-dead-summary-mode (&optional arg)
6793 "Minor mode for Gnus summary buffers."
6795 (when (eq major-mode 'gnus-summary-mode)
6796 (make-local-variable 'gnus-dead-summary-mode)
6797 (setq gnus-dead-summary-mode
6798 (if (null arg) (not gnus-dead-summary-mode)
6799 (> (prefix-numeric-value arg) 0)))
6800 (when gnus-dead-summary-mode
6802 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6804 (defun gnus-deaden-summary ()
6805 "Make the current summary buffer into a dead summary buffer."
6806 ;; Kill any previous dead summary buffer.
6807 (when (and gnus-dead-summary
6808 (buffer-name gnus-dead-summary))
6809 (with-current-buffer gnus-dead-summary
6810 (when gnus-dead-summary-mode
6811 (kill-buffer (current-buffer)))))
6812 ;; Make this the current dead summary.
6813 (setq gnus-dead-summary (current-buffer))
6814 (gnus-dead-summary-mode 1)
6815 (let ((name (buffer-name)))
6816 (when (string-match "Summary" name)
6818 (concat (substring name 0 (match-beginning 0)) "Dead "
6819 (substring name (match-beginning 0)))
6823 (defun gnus-kill-or-deaden-summary (buffer)
6824 "Kill or deaden the summary BUFFER."
6826 (when (and (buffer-name buffer)
6827 (not gnus-single-article-buffer))
6828 (with-current-buffer buffer
6829 (gnus-kill-buffer gnus-article-buffer)
6830 (gnus-kill-buffer gnus-original-article-buffer)))
6833 (gnus-kill-summary-on-exit
6834 (when (and gnus-use-trees
6835 (gnus-buffer-exists-p buffer))
6838 (gnus-tree-close gnus-newsgroup-name)))
6839 (gnus-kill-buffer buffer))
6840 ;; Deaden the buffer.
6841 ((gnus-buffer-exists-p buffer)
6844 (gnus-deaden-summary))))))
6846 (defun gnus-summary-wake-up-the-dead (&rest args)
6847 "Wake up the dead summary buffer."
6849 (gnus-dead-summary-mode -1)
6850 (let ((name (buffer-name)))
6851 (when (string-match "Dead " name)
6853 (concat (substring name 0 (match-beginning 0))
6854 (substring name (match-end 0)))
6856 (gnus-message 3 "This dead summary is now alive again"))
6858 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6859 (defun gnus-summary-fetch-faq (&optional faq-dir)
6860 "Fetch the FAQ for the current group.
6861 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6865 (when current-prefix-arg
6867 "FAQ dir: " (and (listp gnus-group-faq-directory)
6869 gnus-group-faq-directory))))))
6870 (let (gnus-faq-buffer)
6871 (when (setq gnus-faq-buffer
6872 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6873 (gnus-configure-windows 'summary-faq))))
6875 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6876 (defun gnus-summary-describe-group (&optional force)
6877 "Describe the current newsgroup."
6879 (gnus-group-describe-group force gnus-newsgroup-name))
6881 (defun gnus-summary-describe-briefly ()
6882 "Describe summary mode commands briefly."
6884 (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")))
6886 ;; Walking around group mode buffer from summary mode.
6888 (defun gnus-summary-next-group (&optional no-article target-group backward)
6889 "Exit current newsgroup and then select next unread newsgroup.
6890 If prefix argument NO-ARTICLE is non-nil, no article is selected
6891 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6892 previous group instead."
6894 ;; Stop pre-fetching.
6895 (gnus-async-halt-prefetch)
6896 (let ((current-group gnus-newsgroup-name)
6897 (current-buffer (current-buffer))
6899 ;; First we semi-exit this group to update Xrefs and all variables.
6900 ;; We can't do a real exit, because the window conf must remain
6901 ;; the same in case the user is prompted for info, and we don't
6902 ;; want the window conf to change before that...
6903 (gnus-summary-exit t)
6904 (while (not entered)
6905 ;; Then we find what group we are supposed to enter.
6906 (set-buffer gnus-group-buffer)
6907 (gnus-group-jump-to-group current-group)
6910 (if (eq gnus-keep-same-level 'best)
6911 (gnus-summary-best-group gnus-newsgroup-name)
6912 (gnus-summary-search-group backward gnus-keep-same-level))))
6913 (if (not target-group)
6914 ;; There are no further groups, so we return to the group
6917 (gnus-message 5 "Returning to the group buffer")
6919 (when (gnus-buffer-live-p current-buffer)
6920 (set-buffer current-buffer)
6921 (gnus-summary-exit))
6922 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6923 ;; We try to enter the target group.
6924 (gnus-group-jump-to-group target-group)
6925 (let ((unreads (gnus-group-group-unread)))
6926 (if (and (or (eq t unreads)
6927 (and unreads (not (zerop unreads))))
6928 (gnus-summary-read-group
6929 target-group nil no-article
6930 (and (buffer-name current-buffer) current-buffer)
6933 (setq current-group target-group
6934 target-group nil)))))))
6936 (defun gnus-summary-prev-group (&optional no-article)
6937 "Exit current newsgroup and then select previous unread newsgroup.
6938 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6940 (gnus-summary-next-group no-article nil t))
6942 ;; Walking around summary lines.
6944 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6945 "Go to the first subject satisfying any non-nil constraint.
6946 If UNREAD is non-nil, the article should be unread.
6947 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6948 If UNSEEN is non-nil, the article should be unseen.
6949 Returns the article selected or nil if there are no matching articles."
6953 ((null gnus-newsgroup-data)
6954 (gnus-message 3 "No articles in the group")
6956 ;; Pick the first article.
6957 ((not (or unread undownloaded unseen))
6958 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6959 (gnus-data-number (car gnus-newsgroup-data)))
6960 ;; Find the first unread article.
6962 (let ((data gnus-newsgroup-data))
6964 (let ((num (gnus-data-number (car data))))
6965 (or (memq num gnus-newsgroup-unfetched)
6966 (not (or (and unread
6967 (memq num gnus-newsgroup-unreads))
6969 (memq num gnus-newsgroup-undownloaded))
6971 (memq num gnus-newsgroup-unseen)))))))
6972 (setq data (cdr data)))
6976 (goto-char (gnus-data-pos (car data)))
6977 (gnus-data-number (car data)))
6978 (gnus-message 3 "No more%s articles"
6979 (let* ((r (when unread " unread"))
6980 (d (when undownloaded " undownloaded"))
6981 (s (when unseen " unseen"))
6982 (l (delq nil (list r d s))))
6983 (cond ((= 3 (length l))
6984 (concat r "," d ", or" s))
6986 (concat (car l) ", or" (cadr l)))
6993 (gnus-summary-position-point))))))
6995 (defun gnus-summary-next-subject (n &optional unread dont-display)
6996 "Go to next N'th summary line.
6997 If N is negative, go to the previous N'th subject line.
6998 If UNREAD is non-nil, only unread articles are selected.
6999 The difference between N and the actual number of steps taken is
7002 (let ((backward (< n 0))
7006 (gnus-summary-find-prev unread)
7007 (gnus-summary-find-next unread)))
7008 (unless (zerop (setq n (1- n)))
7009 (gnus-summary-show-thread)))
7011 (gnus-message 7 "No more%s articles"
7012 (if unread " unread" "")))
7013 (unless dont-display
7014 (gnus-summary-recenter)
7015 (gnus-summary-position-point))
7018 (defun gnus-summary-next-unread-subject (n)
7019 "Go to next N'th unread summary line."
7021 (gnus-summary-next-subject n t))
7023 (defun gnus-summary-prev-subject (n &optional unread)
7024 "Go to previous N'th summary line.
7025 If optional argument UNREAD is non-nil, only unread article is selected."
7027 (gnus-summary-next-subject (- n) unread))
7029 (defun gnus-summary-prev-unread-subject (n)
7030 "Go to previous N'th unread summary line."
7032 (gnus-summary-next-subject (- n) t))
7034 (defun gnus-summary-goto-subjects (articles)
7035 "Insert the subject header for ARTICLES in the current buffer."
7037 (dolist (article articles)
7038 (gnus-summary-goto-subject article t)))
7039 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7040 (gnus-summary-position-point))
7042 (defun gnus-summary-goto-subject (article &optional force silent)
7043 "Go the subject line of ARTICLE.
7044 If FORCE, also allow jumping to articles not currently shown."
7045 (interactive "nArticle number: ")
7046 (unless (numberp article)
7047 (error "Article %s is not a number" article))
7049 (data (gnus-data-find article)))
7050 ;; We read in the article if we have to.
7053 (gnus-summary-insert-subject
7055 (if (or (numberp force) (vectorp force)) force)
7057 (setq data (gnus-data-find article)))
7062 (gnus-message 3 "Can't find article %d" article))
7064 (let ((pt (gnus-data-pos data)))
7066 (gnus-summary-set-article-display-arrow pt))
7067 (gnus-summary-position-point)
7070 ;; Walking around summary lines with displaying articles.
7072 (defun gnus-summary-expand-window (&optional arg)
7073 "Make the summary buffer take up the entire Emacs frame.
7074 Given a prefix, will force an `article' buffer configuration."
7077 (gnus-configure-windows 'article 'force)
7078 (gnus-configure-windows 'summary 'force)))
7080 (defun gnus-summary-display-article (article &optional all-header)
7081 "Display ARTICLE in article buffer."
7082 (when (gnus-buffer-live-p gnus-article-buffer)
7083 (with-current-buffer gnus-article-buffer
7084 (set-buffer-multibyte t)))
7085 (gnus-set-global-variables)
7086 (when (gnus-buffer-live-p gnus-article-buffer)
7087 (with-current-buffer gnus-article-buffer
7088 (setq gnus-article-charset gnus-newsgroup-charset)
7089 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7090 (set-buffer-multibyte t)))
7094 (if gnus-summary-display-article-function
7095 (funcall gnus-summary-display-article-function article all-header)
7096 (gnus-article-prepare article all-header))
7097 (with-current-buffer gnus-article-buffer
7098 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7100 (gnus-run-hooks 'gnus-select-article-hook)
7101 (when (and gnus-current-article
7102 (not (zerop gnus-current-article)))
7103 (gnus-summary-goto-subject gnus-current-article))
7104 (gnus-summary-recenter)
7105 (when (and gnus-use-trees gnus-show-threads)
7106 (gnus-possibly-generate-tree article)
7107 (gnus-highlight-selected-tree article))
7108 ;; Successfully display article.
7109 (gnus-article-set-window-start
7110 (cdr (assq article gnus-newsgroup-bookmarks))))))
7112 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7113 "Select the current article.
7114 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7115 non-nil, the article will be re-fetched even if it already present in
7116 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7118 ;; Make sure we are in the summary buffer to work around bbdb bug.
7119 (unless (eq major-mode 'gnus-summary-mode)
7120 (set-buffer gnus-summary-buffer))
7121 (let ((article (or article (gnus-summary-article-number)))
7122 (all-headers (not (not all-headers))) ;Must be T or NIL.
7123 gnus-summary-display-article-function)
7125 (gnus-summary-article-pseudo-p article)
7126 (error "This is a pseudo-article"))
7128 (set-buffer gnus-summary-buffer)
7129 (if (or (and gnus-single-article-buffer
7130 (or (null gnus-current-article)
7131 (null gnus-article-current)
7132 (null (get-buffer gnus-article-buffer))
7133 (not (eq article (cdr gnus-article-current)))
7134 (not (equal (car gnus-article-current)
7135 gnus-newsgroup-name))))
7136 (and (not gnus-single-article-buffer)
7137 (or (null gnus-current-article)
7138 (not (eq gnus-current-article article))))
7140 ;; The requested article is different from the current article.
7142 (gnus-summary-display-article article all-headers)
7143 (gnus-article-set-window-start
7144 (cdr (assq article gnus-newsgroup-bookmarks)))
7148 (defun gnus-summary-force-verify-and-decrypt ()
7149 "Display buttons for signed/encrypted parts and verify/decrypt them."
7151 (let ((mm-verify-option 'known)
7152 (mm-decrypt-option 'known)
7153 (gnus-article-emulate-mime t)
7154 (gnus-buttonized-mime-types (append (list "multipart/signed"
7155 "multipart/encrypted")
7156 gnus-buttonized-mime-types)))
7157 (gnus-summary-select-article nil 'force)))
7159 (defun gnus-summary-set-current-mark (&optional current-mark)
7160 "Obsolete function."
7163 (defun gnus-summary-next-article (&optional unread subject backward push)
7164 "Select the next article.
7165 If UNREAD, only unread articles are selected.
7166 If SUBJECT, only articles with SUBJECT are selected.
7167 If BACKWARD, the previous article is selected instead of the next."
7170 ;; Is there such an article?
7171 ((and (gnus-summary-search-forward unread subject backward)
7172 (or (gnus-summary-display-article (gnus-summary-article-number))
7173 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7174 (gnus-summary-position-point))
7175 ;; If not, we try the first unread, if that is wanted.
7177 gnus-auto-select-same
7178 (gnus-summary-first-unread-article))
7179 (gnus-summary-position-point)
7180 (gnus-message 6 "Wrapped"))
7181 ;; Try to get next/previous article not displayed in this group.
7182 ((and gnus-auto-extend-newsgroup
7183 (not unread) (not subject))
7184 (gnus-summary-goto-article
7185 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7186 nil (count-lines (point-min) (point))))
7187 ;; Go to next/previous group.
7189 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7190 (gnus-summary-jump-to-group gnus-newsgroup-name))
7191 (let ((cmd last-command-char)
7193 (with-current-buffer gnus-group-buffer
7196 (if (eq gnus-keep-same-level 'best)
7197 (gnus-summary-best-group gnus-newsgroup-name)
7198 (gnus-summary-search-group backward gnus-keep-same-level))))
7199 ;; For some reason, the group window gets selected. We change
7201 (select-window (get-buffer-window (current-buffer)))
7202 ;; Select next unread newsgroup automagically.
7204 ((or (not gnus-auto-select-next)
7206 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7207 ((or (eq gnus-auto-select-next 'quietly)
7208 (and (eq gnus-auto-select-next 'slightly-quietly)
7210 (and (eq gnus-auto-select-next 'almost-quietly)
7211 (gnus-summary-last-article-p)))
7213 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7215 (gnus-message 7 "No more%s articles (%s)..."
7216 (if unread " unread" "")
7217 (if group (concat "selecting " group)
7219 (gnus-summary-next-group nil group backward)))
7221 (when (gnus-key-press-event-p last-input-event)
7222 (gnus-summary-walk-group-buffer
7223 gnus-newsgroup-name cmd unread backward point))))))))
7225 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7226 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7227 (?\C-p (gnus-group-prev-unread-group 1))))
7228 (cursor-in-echo-area t)
7229 keve key group ended prompt)
7231 (set-buffer gnus-group-buffer)
7234 (if (eq gnus-keep-same-level 'best)
7235 (gnus-summary-best-group gnus-newsgroup-name)
7236 (gnus-summary-search-group backward gnus-keep-same-level))))
7240 "No more%s articles%s " (if unread " unread" "")
7242 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7243 (format " (Type %s for %s [%s])"
7244 (single-key-description cmd) group
7245 (gnus-group-unread group))
7246 (format " (Type %s to exit %s)"
7247 (single-key-description cmd)
7248 gnus-newsgroup-name))))
7249 ;; Confirm auto selection.
7250 (setq key (car (setq keve (gnus-read-event-char prompt)))
7253 ((assq key keystrokes)
7254 (let ((obuf (current-buffer)))
7255 (switch-to-buffer gnus-group-buffer)
7257 (gnus-group-jump-to-group group))
7258 (eval (cadr (assq key keystrokes)))
7259 (setq group (gnus-group-group-name))
7260 (switch-to-buffer obuf))
7264 (gnus-ephemeral-group-p gnus-newsgroup-name))
7266 (gnus-summary-next-group nil group backward)))
7268 (push (cdr keve) unread-command-events))))))
7270 (defun gnus-summary-next-unread-article ()
7271 "Select unread article after current one."
7273 (gnus-summary-next-article
7274 (or (not (eq gnus-summary-goto-unread 'never))
7275 (gnus-summary-last-article-p (gnus-summary-article-number)))
7276 (and gnus-auto-select-same
7277 (gnus-summary-article-subject))))
7279 (defun gnus-summary-prev-article (&optional unread subject)
7280 "Select the article after the current one.
7281 If UNREAD is non-nil, only unread articles are selected."
7283 (gnus-summary-next-article unread subject t))
7285 (defun gnus-summary-prev-unread-article ()
7286 "Select unread article before current one."
7288 (gnus-summary-prev-article
7289 (or (not (eq gnus-summary-goto-unread 'never))
7290 (gnus-summary-first-article-p (gnus-summary-article-number)))
7291 (and gnus-auto-select-same
7292 (gnus-summary-article-subject))))
7294 (defun gnus-summary-next-page (&optional lines circular stop)
7295 "Show next page of the selected article.
7296 If at the end of the current article, select the next article.
7297 LINES says how many lines should be scrolled up.
7299 If CIRCULAR is non-nil, go to the start of the article instead of
7300 selecting the next article when reaching the end of the current
7303 If STOP is non-nil, just stop when reaching the end of the message.
7305 Also see the variable `gnus-article-skip-boring'."
7307 (setq gnus-summary-buffer (current-buffer))
7308 (gnus-set-global-variables)
7309 (let ((article (gnus-summary-article-number))
7310 (article-window (get-buffer-window gnus-article-buffer t))
7312 ;; If the buffer is empty, we have no article.
7314 (error "No article to select"))
7315 (gnus-configure-windows 'article)
7316 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7317 (if (and (eq gnus-summary-goto-unread 'never)
7318 (not (gnus-summary-last-article-p article)))
7319 (gnus-summary-next-article)
7320 (gnus-summary-next-unread-article))
7321 (if (or (null gnus-current-article)
7322 (null gnus-article-current)
7323 (/= article (cdr gnus-article-current))
7324 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7325 ;; Selected subject is different from current article's.
7326 (gnus-summary-display-article article)
7327 (when article-window
7328 (gnus-eval-in-buffer-window gnus-article-buffer
7329 (setq endp (or (gnus-article-next-page lines)
7330 (gnus-article-only-boring-p))))
7333 (gnus-message 3 "End of message"))
7335 (gnus-summary-beginning-of-article))
7337 (gnus-message 3 "End of message"))
7339 (if (and (eq gnus-summary-goto-unread 'never)
7340 (not (gnus-summary-last-article-p article)))
7341 (gnus-summary-next-article)
7342 (gnus-summary-next-unread-article))))))))
7343 (gnus-summary-recenter)
7344 (gnus-summary-position-point)))
7346 (defun gnus-summary-prev-page (&optional lines move)
7347 "Show previous page of selected article.
7348 Argument LINES specifies lines to be scrolled down.
7349 If MOVE, move to the previous unread article if point is at
7350 the beginning of the buffer."
7352 (let ((article (gnus-summary-article-number))
7353 (article-window (get-buffer-window gnus-article-buffer t))
7355 (gnus-configure-windows 'article)
7356 (if (or (null gnus-current-article)
7357 (null gnus-article-current)
7358 (/= article (cdr gnus-article-current))
7359 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7360 ;; Selected subject is different from current article's.
7361 (gnus-summary-display-article article)
7362 (gnus-summary-recenter)
7363 (when article-window
7364 (gnus-eval-in-buffer-window gnus-article-buffer
7365 (setq endp (gnus-article-prev-page lines)))
7366 (when (and move endp)
7368 (gnus-message 3 "Beginning of message"))
7370 (if (and (eq gnus-summary-goto-unread 'never)
7371 (not (gnus-summary-first-article-p article)))
7372 (gnus-summary-prev-article)
7373 (gnus-summary-prev-unread-article))))))))
7374 (gnus-summary-position-point))
7376 (defun gnus-summary-prev-page-or-article (&optional lines)
7377 "Show previous page of selected article.
7378 Argument LINES specifies lines to be scrolled down.
7379 If at the beginning of the article, go to the next article."
7381 (gnus-summary-prev-page lines t))
7383 (defun gnus-summary-scroll-up (lines)
7384 "Scroll up (or down) one line current article.
7385 Argument LINES specifies lines to be scrolled up (or down if negative)."
7387 (gnus-configure-windows 'article)
7388 (gnus-summary-show-thread)
7389 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7390 (gnus-eval-in-buffer-window gnus-article-buffer
7392 (when (gnus-article-next-page lines)
7393 (gnus-message 3 "End of message")))
7395 (gnus-article-prev-page (- lines))))))
7396 (gnus-summary-recenter)
7397 (gnus-summary-position-point))
7399 (defun gnus-summary-scroll-down (lines)
7400 "Scroll down (or up) one line current article.
7401 Argument LINES specifies lines to be scrolled down (or up if negative)."
7403 (gnus-summary-scroll-up (- lines)))
7405 (defun gnus-summary-next-same-subject ()
7406 "Select next article which has the same subject as current one."
7408 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7410 (defun gnus-summary-prev-same-subject ()
7411 "Select previous article which has the same subject as current one."
7413 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7415 (defun gnus-summary-next-unread-same-subject ()
7416 "Select next unread article which has the same subject as current one."
7418 (gnus-summary-next-article t (gnus-summary-article-subject)))
7420 (defun gnus-summary-prev-unread-same-subject ()
7421 "Select previous unread article which has the same subject as current one."
7423 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7425 (defun gnus-summary-first-unread-article ()
7426 "Select the first unread article.
7427 Return nil if there are no unread articles."
7430 (when (gnus-summary-first-subject t)
7431 (gnus-summary-show-thread)
7432 (gnus-summary-first-subject t)
7433 (gnus-summary-display-article (gnus-summary-article-number)))
7434 (gnus-summary-position-point)))
7436 (defun gnus-summary-first-unread-subject ()
7437 "Place the point on the subject line of the first unread article.
7438 Return nil if there are no unread articles."
7441 (when (gnus-summary-first-subject t)
7442 (gnus-summary-show-thread)
7443 (gnus-summary-first-subject t))
7444 (gnus-summary-position-point)))
7446 (defun gnus-summary-first-unseen-subject ()
7447 "Place the point on the subject line of the first unseen article.
7448 Return nil if there are no unseen articles."
7451 (when (gnus-summary-first-subject nil nil t)
7452 (gnus-summary-show-thread)
7453 (gnus-summary-first-subject nil nil t))
7454 (gnus-summary-position-point)))
7456 (defun gnus-summary-first-unseen-or-unread-subject ()
7457 "Place the point on the subject line of the first unseen article or,
7458 if all article have been seen, on the subject line of the first unread
7462 (unless (when (gnus-summary-first-subject nil nil t)
7463 (gnus-summary-show-thread)
7464 (gnus-summary-first-subject nil nil t))
7465 (when (gnus-summary-first-subject t)
7466 (gnus-summary-show-thread)
7467 (gnus-summary-first-subject t)))
7468 (gnus-summary-position-point)))
7470 (defun gnus-summary-first-article ()
7471 "Select the first article.
7472 Return nil if there are no articles."
7475 (when (gnus-summary-first-subject)
7476 (gnus-summary-show-thread)
7477 (gnus-summary-first-subject)
7478 (gnus-summary-display-article (gnus-summary-article-number)))
7479 (gnus-summary-position-point)))
7481 (defun gnus-summary-best-unread-article (&optional arg)
7482 "Select the unread article with the highest score.
7483 If given a prefix argument, select the next unread article that has a
7484 score higher than the default score."
7486 (let ((article (if arg
7487 (gnus-summary-better-unread-subject)
7488 (gnus-summary-best-unread-subject))))
7490 (gnus-summary-goto-article article)
7491 (error "No unread articles"))))
7493 (defun gnus-summary-best-unread-subject ()
7494 "Select the unread subject with the highest score."
7496 (let ((best -1000000)
7497 (data gnus-newsgroup-data)
7500 (and (gnus-data-unread-p (car data))
7502 (gnus-summary-article-score (gnus-data-number (car data))))
7505 article (gnus-data-number (car data))))
7506 (setq data (cdr data)))
7508 (gnus-summary-goto-subject article))
7509 (gnus-summary-position-point)
7512 (defun gnus-summary-better-unread-subject ()
7513 "Select the first unread subject that has a score over the default score."
7515 (let ((data gnus-newsgroup-data)
7517 (while (and (setq article (gnus-data-number (car data)))
7518 (or (gnus-data-read-p (car data))
7519 (not (> (gnus-summary-article-score article)
7520 gnus-summary-default-score))))
7521 (setq data (cdr data)))
7523 (gnus-summary-goto-subject article))
7524 (gnus-summary-position-point)
7527 (defun gnus-summary-last-subject ()
7528 "Go to the last displayed subject line in the group."
7529 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7531 (gnus-summary-goto-subject article))))
7533 (defun gnus-summary-goto-article (article &optional all-headers force)
7534 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7535 If ALL-HEADERS is non-nil, no header lines are hidden.
7536 If FORCE, go to the article even if it isn't displayed. If FORCE
7537 is a number, it is the line the article is to be displayed on."
7541 "Article number or Message-ID: "
7542 (mapcar (lambda (number) (list (int-to-string number)))
7543 gnus-newsgroup-limit))
7547 (if (and (stringp article)
7548 (string-match "@\\|%40" article))
7549 (gnus-summary-refer-article article)
7550 (when (stringp article)
7551 (setq article (string-to-number article)))
7552 (if (gnus-summary-goto-subject article force)
7553 (gnus-summary-display-article article all-headers)
7554 (gnus-message 4 "Couldn't go to article %s" article) nil))
7555 (gnus-summary-position-point)))
7557 (defun gnus-summary-goto-last-article ()
7558 "Go to the previously read article."
7561 (when gnus-last-article
7562 (gnus-summary-goto-article gnus-last-article nil t))
7563 (gnus-summary-position-point)))
7565 (defun gnus-summary-pop-article (number)
7566 "Pop one article off the history and go to the previous.
7567 NUMBER articles will be popped off."
7570 (setq gnus-newsgroup-history
7571 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7573 (gnus-summary-goto-article (car to) nil t)
7574 (error "Article history empty")))
7575 (gnus-summary-position-point))
7577 ;; Summary commands and functions for limiting the summary buffer.
7579 (defun gnus-summary-limit-to-articles (n)
7580 "Limit the summary buffer to the next N articles.
7581 If not given a prefix, use the process marked articles instead."
7584 (let ((articles (gnus-summary-work-articles n)))
7585 (setq gnus-newsgroup-processable nil)
7586 (gnus-summary-limit articles))
7587 (gnus-summary-position-point)))
7589 (defun gnus-summary-pop-limit (&optional total)
7590 "Restore the previous limit.
7591 If given a prefix, remove all limits."
7594 (setq gnus-newsgroup-limits
7595 (list (mapcar (lambda (h) (mail-header-number h))
7596 gnus-newsgroup-headers))))
7597 (unless gnus-newsgroup-limits
7598 (error "No limit to pop"))
7600 (gnus-summary-limit nil 'pop)
7601 (gnus-summary-position-point)))
7603 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7604 "Limit the summary buffer to articles that have subjects that match a regexp.
7605 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7607 (list (read-string (if current-prefix-arg
7608 "Exclude subject (regexp): "
7609 "Limit to subject (regexp): "))
7610 nil current-prefix-arg))
7612 (setq header "subject"))
7613 (when (not (equal "" subject))
7615 (let ((articles (gnus-summary-find-matching
7616 (or header "subject") subject 'all nil nil
7619 (error "Found no matches for \"%s\"" subject))
7620 (gnus-summary-limit articles))
7621 (gnus-summary-position-point))))
7623 (defun gnus-summary-limit-to-author (from &optional not-matching)
7624 "Limit the summary buffer to articles that have authors that match a regexp.
7625 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7627 (list (read-string (if current-prefix-arg
7628 "Exclude author (regexp): "
7629 "Limit to author (regexp): "))
7630 current-prefix-arg))
7631 (gnus-summary-limit-to-subject from "from" not-matching))
7633 (defun gnus-summary-limit-to-age (age &optional younger-p)
7634 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7635 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7636 articles that are younger than AGE days."
7638 (let ((younger current-prefix-arg)
7641 (while (not days-got)
7642 (setq days (if younger
7643 (read-string "Limit to articles younger than (in days, older when negative): ")
7645 "Limit to articles older than (in days, younger when negative): ")))
7646 (when (> (length days) 0)
7647 (setq days (read days)))
7652 (setq younger (not younger))
7653 (setq days (* days -1))))
7654 (message "Please enter a number.")
7656 (list days younger)))
7658 (let ((data gnus-newsgroup-data)
7659 (cutoff (days-to-time age))
7660 articles d date is-younger)
7661 (while (setq d (pop data))
7662 (when (and (vectorp (gnus-data-header d))
7663 (setq date (mail-header-date (gnus-data-header d))))
7664 (setq is-younger (time-less-p
7665 (time-since (condition-case ()
7672 (push (gnus-data-number d) articles))))
7673 (gnus-summary-limit (nreverse articles)))
7674 (gnus-summary-position-point)))
7676 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7677 "Limit the summary buffer to articles that match an 'extra' header."
7681 (gnus-completing-read-with-default
7682 (symbol-name (car gnus-extra-headers))
7683 (if current-prefix-arg
7684 "Exclude extra header:"
7685 "Limit extra header:")
7687 (cons (symbol-name x) x))
7692 (read-string (format "%s header %s (regexp): "
7693 (if current-prefix-arg "Exclude" "Limit to")
7695 current-prefix-arg)))
7696 (when (not (equal "" regexp))
7698 (let ((articles (gnus-summary-find-matching
7699 (cons 'extra header) regexp 'all nil nil
7702 (error "Found no matches for \"%s\"" regexp))
7703 (gnus-summary-limit articles))
7704 (gnus-summary-position-point))))
7706 (defun gnus-summary-limit-to-display-predicate ()
7707 "Limit the summary buffer to the predicated in the `display' group parameter."
7709 (unless gnus-newsgroup-display
7710 (error "There is no `display' group parameter"))
7712 (dolist (number gnus-newsgroup-articles)
7713 (when (funcall gnus-newsgroup-display)
7714 (push number articles)))
7715 (gnus-summary-limit articles))
7716 (gnus-summary-position-point))
7718 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7720 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7722 (defun gnus-summary-limit-to-unread (&optional all)
7723 "Limit the summary buffer to articles that are not marked as read.
7724 If ALL is non-nil, limit strictly to unread articles."
7727 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7728 (gnus-summary-limit-to-marks
7729 ;; Concat all the marks that say that an article is read and have
7731 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7732 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7733 gnus-low-score-mark gnus-expirable-mark
7734 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7735 gnus-duplicate-mark gnus-souped-mark)
7738 (defun gnus-summary-limit-to-replied (&optional unreplied)
7739 "Limit the summary buffer to replied articles.
7740 If UNREPLIED (the prefix), limit to unreplied articles."
7744 (gnus-set-difference gnus-newsgroup-articles
7745 gnus-newsgroup-replied))
7746 (gnus-summary-limit gnus-newsgroup-replied))
7747 (gnus-summary-position-point))
7749 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7750 (make-obsolete 'gnus-summary-delete-marked-with
7751 'gnus-summary-limit-exclude-marks)
7753 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7754 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7755 If REVERSE, limit the summary buffer to articles that are marked
7756 with MARKS. MARKS can either be a string of marks or a list of marks.
7757 Returns how many articles were removed."
7758 (interactive "sMarks: ")
7759 (gnus-summary-limit-to-marks marks t))
7761 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7762 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7763 If REVERSE (the prefix), limit the summary buffer to articles that are
7764 not marked with MARKS. MARKS can either be a string of marks or a
7766 Returns how many articles were removed."
7767 (interactive "sMarks: \nP")
7769 (let ((data gnus-newsgroup-data)
7770 (marks (if (listp marks) marks
7771 (append marks nil))) ; Transform to list.
7774 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7775 (memq (gnus-data-mark (car data)) marks))
7776 (push (gnus-data-number (car data)) articles))
7777 (setq data (cdr data)))
7778 (gnus-summary-limit articles))
7779 (gnus-summary-position-point)))
7781 (defun gnus-summary-limit-to-score (score)
7782 "Limit to articles with score at or above SCORE."
7783 (interactive "NLimit to articles with score of at least: ")
7784 (let ((data gnus-newsgroup-data)
7787 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7789 (push (gnus-data-number (car data)) articles))
7790 (setq data (cdr data)))
7792 (gnus-summary-limit articles)
7793 (gnus-summary-position-point))))
7795 (defun gnus-summary-limit-to-unseen ()
7796 "Limit to unseen articles."
7799 (gnus-summary-limit gnus-newsgroup-unseen)
7800 (gnus-summary-position-point)))
7802 (defun gnus-summary-limit-include-thread (id)
7803 "Display all the hidden articles that is in the thread with ID in it.
7804 When called interactively, ID is the Message-ID of the current
7806 (interactive (list (mail-header-id (gnus-summary-article-header))))
7807 (let ((articles (gnus-articles-in-thread
7808 (gnus-id-to-thread (gnus-root-id id)))))
7810 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7811 (gnus-summary-limit-include-matching-articles
7813 (regexp-quote (gnus-simplify-subject-re
7814 (mail-header-subject (gnus-id-to-header id)))))
7815 (gnus-summary-position-point))))
7817 (defun gnus-summary-limit-include-matching-articles (header regexp)
7818 "Display all the hidden articles that have HEADERs that match REGEXP."
7819 (interactive (list (read-string "Match on header: ")
7820 (read-string "Regexp: ")))
7821 (let ((articles (gnus-find-matching-articles header regexp)))
7823 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7824 (gnus-summary-position-point))))
7826 (defun gnus-summary-insert-dormant-articles ()
7827 "Insert all the dormant articles for this group into the current buffer."
7829 (let ((gnus-verbose (max 6 gnus-verbose)))
7830 (if (not gnus-newsgroup-dormant)
7831 (gnus-message 3 "No cached articles for this group")
7832 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7834 (defun gnus-summary-limit-include-dormant ()
7835 "Display all the hidden articles that are marked as dormant.
7836 Note that this command only works on a subset of the articles currently
7837 fetched for this group."
7839 (unless gnus-newsgroup-dormant
7840 (error "There are no dormant articles in this group"))
7842 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7843 (gnus-summary-position-point)))
7845 (defun gnus-summary-limit-exclude-dormant ()
7846 "Hide all dormant articles."
7849 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7850 (gnus-summary-position-point)))
7852 (defun gnus-summary-limit-exclude-childless-dormant ()
7853 "Hide all dormant articles that have no children."
7855 (let ((data (gnus-data-list t))
7856 articles d children)
7857 ;; Find all articles that are either not dormant or have
7859 (while (setq d (pop data))
7860 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7862 (gnus-article-children (gnus-data-number d)))
7865 (when (memq (car children) articles)
7870 (push (gnus-data-number d) articles)))
7873 (gnus-summary-limit articles)
7874 (gnus-summary-position-point))))
7876 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7877 "Mark all unread excluded articles as read.
7878 If ALL, mark even excluded ticked and dormants as read."
7880 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7881 (let ((articles (gnus-sorted-ndifference
7883 (mapcar (lambda (h) (mail-header-number h))
7884 gnus-newsgroup-headers)
7886 gnus-newsgroup-limit))
7888 (setq gnus-newsgroup-unreads
7889 (gnus-sorted-intersection gnus-newsgroup-unreads
7890 gnus-newsgroup-limit))
7892 (setq gnus-newsgroup-dormant nil
7893 gnus-newsgroup-marked nil
7894 gnus-newsgroup-reads
7896 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7897 gnus-newsgroup-reads))
7898 (while (setq article (pop articles))
7899 (unless (or (memq article gnus-newsgroup-dormant)
7900 (memq article gnus-newsgroup-marked))
7901 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7903 (defun gnus-summary-limit (articles &optional pop)
7905 ;; We pop the previous limit off the stack and use that.
7906 (setq articles (car gnus-newsgroup-limits)
7907 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7908 ;; We use the new limit, so we push the old limit on the stack.
7909 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7911 (setq gnus-newsgroup-limit articles)
7912 (let ((total (length gnus-newsgroup-data))
7913 (data (gnus-data-find-list (gnus-summary-article-number)))
7914 (gnus-summary-mark-below nil) ; Inhibit this.
7916 ;; This will do all the work of generating the new summary buffer
7917 ;; according to the new limit.
7918 (gnus-summary-prepare)
7919 ;; Hide any threads, possibly.
7920 (gnus-summary-maybe-hide-threads)
7921 ;; Try to return to the article you were at, or one in the
7924 ;; We try to find some article after the current one.
7926 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7929 (setq data (cdr data))))
7931 ;; If there is no data, that means that we were after the last
7932 ;; article. The same goes when we can't find any articles
7933 ;; after the current one.
7934 (goto-char (point-max))
7935 (gnus-summary-find-prev))
7936 (gnus-set-mode-line 'summary)
7937 ;; We return how many articles were removed from the summary
7938 ;; buffer as a result of the new limit.
7939 (- total (length gnus-newsgroup-data))))
7941 (defsubst gnus-invisible-cut-children (threads)
7944 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7949 (defsubst gnus-cut-thread (thread)
7950 "Go forwards in the thread until we find an article that we want to display."
7951 (when (or (eq gnus-fetch-old-headers 'some)
7952 (eq gnus-fetch-old-headers 'invisible)
7953 (numberp gnus-fetch-old-headers)
7954 (eq gnus-build-sparse-threads 'some)
7955 (eq gnus-build-sparse-threads 'more))
7956 ;; Deal with old-fetched headers and sparse threads.
7960 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7961 (gnus-summary-article-ancient-p
7962 (mail-header-number (car thread))))
7963 (if (or (<= (length (cdr thread)) 1)
7964 (eq gnus-fetch-old-headers 'invisible))
7965 (setq gnus-newsgroup-limit
7966 (delq (mail-header-number (car thread))
7967 gnus-newsgroup-limit)
7968 thread (cadr thread))
7969 (when (gnus-invisible-cut-children (cdr thread))
7970 (let ((th (cdr thread)))
7972 (if (memq (mail-header-number (caar th))
7973 gnus-newsgroup-limit)
7974 (setq thread (car th)
7976 (setq th (cdr th))))))))))
7979 (defun gnus-cut-threads (threads)
7980 "Cut off all uninteresting articles from the beginning of THREADS."
7981 (when (or (eq gnus-fetch-old-headers 'some)
7982 (eq gnus-fetch-old-headers 'invisible)
7983 (numberp gnus-fetch-old-headers)
7984 (eq gnus-build-sparse-threads 'some)
7985 (eq gnus-build-sparse-threads 'more))
7988 (setcar th (gnus-cut-thread (car th)))
7989 (setq th (cdr th)))))
7990 ;; Remove nixed out threads.
7993 (defun gnus-summary-initial-limit (&optional show-if-empty)
7994 "Figure out what the initial limit is supposed to be on group entry.
7995 This entails weeding out unwanted dormants, low-scored articles,
7996 fetch-old-headers verbiage, and so on."
7997 ;; Most groups have nothing to remove.
7998 (if (or gnus-inhibit-limiting
7999 (and (null gnus-newsgroup-dormant)
8000 (eq gnus-newsgroup-display 'gnus-not-ignore)
8001 (not (eq gnus-fetch-old-headers 'some))
8002 (not (numberp gnus-fetch-old-headers))
8003 (not (eq gnus-fetch-old-headers 'invisible))
8004 (null gnus-summary-expunge-below)
8005 (not (eq gnus-build-sparse-threads 'some))
8006 (not (eq gnus-build-sparse-threads 'more))
8007 (null gnus-thread-expunge-below)
8008 (not gnus-use-nocem)))
8010 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8011 (setq gnus-newsgroup-limit nil)
8014 (unless (car (symbol-value node))
8015 ;; These threads have no parents -- they are roots.
8016 (let ((nodes (cdr (symbol-value node)))
8019 (if (and gnus-thread-expunge-below
8020 (< (gnus-thread-total-score (car nodes))
8021 gnus-thread-expunge-below))
8022 (gnus-expunge-thread (pop nodes))
8023 (setq thread (pop nodes))
8024 (gnus-summary-limit-children thread))))))
8025 gnus-newsgroup-dependencies)
8026 ;; If this limitation resulted in an empty group, we might
8027 ;; pop the previous limit and use it instead.
8028 (when (and (not gnus-newsgroup-limit)
8030 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8031 gnus-newsgroup-limit))
8033 (defun gnus-summary-limit-children (thread)
8034 "Return 1 if this subthread is visible and 0 if it is not."
8035 ;; First we get the number of visible children to this thread. This
8036 ;; is done by recursing down the thread using this function, so this
8037 ;; will really go down to a leaf article first, before slowly
8038 ;; working its way up towards the root.
8040 (let* ((max-lisp-eval-depth 5000)
8043 (apply '+ (mapcar 'gnus-summary-limit-children
8046 (number (mail-header-number (car thread)))
8049 (not (memq number gnus-newsgroup-marked))
8051 ;; If this article is dormant and has absolutely no visible
8052 ;; children, then this article isn't visible.
8053 (and (memq number gnus-newsgroup-dormant)
8055 ;; If this is "fetch-old-headered" and there is no
8056 ;; visible children, then we don't want this article.
8057 (and (or (eq gnus-fetch-old-headers 'some)
8058 (numberp gnus-fetch-old-headers))
8059 (gnus-summary-article-ancient-p number)
8061 ;; If this is "fetch-old-headered" and `invisible', then
8062 ;; we don't want this article.
8063 (and (eq gnus-fetch-old-headers 'invisible)
8064 (gnus-summary-article-ancient-p number))
8065 ;; If this is a sparsely inserted article with no children,
8066 ;; we don't want it.
8067 (and (eq gnus-build-sparse-threads 'some)
8068 (gnus-summary-article-sparse-p number)
8070 ;; If we use expunging, and this article is really
8071 ;; low-scored, then we don't want this article.
8072 (when (and gnus-summary-expunge-below
8074 (or (cdr (assq number gnus-newsgroup-scored))
8075 gnus-summary-default-score))
8076 gnus-summary-expunge-below))
8077 ;; We increase the expunge-tally here, but that has
8078 ;; nothing to do with the limits, really.
8079 (incf gnus-newsgroup-expunged-tally)
8080 ;; We also mark as read here, if that's wanted.
8081 (when (and gnus-summary-mark-below
8082 (< score gnus-summary-mark-below))
8083 (setq gnus-newsgroup-unreads
8084 (delq number gnus-newsgroup-unreads))
8085 (if gnus-newsgroup-auto-expire
8086 (push number gnus-newsgroup-expirable)
8087 (push (cons number gnus-low-score-mark)
8088 gnus-newsgroup-reads)))
8090 ;; Do the `display' group parameter.
8091 (and gnus-newsgroup-display
8092 (not (funcall gnus-newsgroup-display)))
8093 ;; Check NoCeM things.
8094 (when (and gnus-use-nocem
8095 (gnus-nocem-unwanted-article-p
8096 (mail-header-id (car thread))))
8097 (setq gnus-newsgroup-unreads
8098 (delq number gnus-newsgroup-unreads))
8100 ;; Nope, invisible article.
8102 ;; Ok, this article is to be visible, so we add it to the limit
8104 (push number gnus-newsgroup-limit)
8107 (defun gnus-expunge-thread (thread)
8108 "Mark all articles in THREAD as read."
8109 (let* ((number (mail-header-number (car thread))))
8110 (incf gnus-newsgroup-expunged-tally)
8111 ;; We also mark as read here, if that's wanted.
8112 (setq gnus-newsgroup-unreads
8113 (delq number gnus-newsgroup-unreads))
8114 (if gnus-newsgroup-auto-expire
8115 (push number gnus-newsgroup-expirable)
8116 (push (cons number gnus-low-score-mark)
8117 gnus-newsgroup-reads)))
8118 ;; Go recursively through all subthreads.
8119 (mapcar 'gnus-expunge-thread (cdr thread)))
8121 ;; Summary article oriented commands
8123 (defun gnus-summary-refer-parent-article (n)
8124 "Refer parent article N times.
8125 If N is negative, go to ancestor -N instead.
8126 The difference between N and the number of articles fetched is returned."
8130 (when (not (natnump n))
8135 (setq header (gnus-summary-article-header))
8136 (if (and (eq (mail-header-number header)
8137 (cdr gnus-article-current))
8138 (equal gnus-newsgroup-name
8139 (car gnus-article-current)))
8140 ;; If we try to find the parent of the currently
8141 ;; displayed article, then we take a look at the actual
8142 ;; References header, since this is slightly more
8143 ;; reliable than the References field we got from the
8146 (set-buffer gnus-original-article-buffer)
8147 (nnheader-narrow-to-headers)
8148 (unless (setq ref (message-fetch-field "references"))
8149 (when (setq ref (message-fetch-field "in-reply-to"))
8150 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8153 ;; It's not the current article, so we take a bet on
8154 ;; the value we got from the server.
8155 (mail-header-references header)))
8157 (not (equal ref "")))
8158 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8159 (gnus-message 1 "Couldn't find parent"))
8160 (gnus-message 1 "No references in article %d"
8161 (gnus-summary-article-number))
8164 (gnus-summary-position-point)
8167 (defun gnus-summary-refer-references ()
8168 "Fetch all articles mentioned in the References header.
8169 Return the number of articles fetched."
8171 (let ((ref (mail-header-references (gnus-summary-article-header)))
8172 (current (gnus-summary-article-number))
8176 (error "No References in the current article")
8177 ;; For each Message-ID in the References header...
8178 (while (string-match "<[^>]*>" ref)
8180 ;; ... fetch that article.
8181 (gnus-summary-refer-article
8182 (prog1 (match-string 0 ref)
8183 (setq ref (substring ref (match-end 0))))))
8184 (gnus-summary-goto-subject current)
8185 (gnus-summary-position-point)
8188 (defun gnus-summary-refer-thread (&optional limit)
8189 "Fetch all articles in the current thread.
8190 If LIMIT (the numerical prefix), fetch that many old headers instead
8191 of what's specified by the `gnus-refer-thread-limit' variable."
8193 (let ((id (mail-header-id (gnus-summary-article-header)))
8194 (limit (if limit (prefix-numeric-value limit)
8195 gnus-refer-thread-limit)))
8196 (unless (eq gnus-fetch-old-headers 'invisible)
8197 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8198 ;; Retrieve the headers and read them in.
8199 (if (eq (if (numberp limit)
8200 (gnus-retrieve-headers
8202 (+ (mail-header-number
8203 (gnus-summary-article-header))
8205 gnus-newsgroup-end))
8206 gnus-newsgroup-name (* limit 2))
8207 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8209 (gnus-retrieve-headers (list gnus-newsgroup-end)
8210 gnus-newsgroup-name limit))
8212 (gnus-build-all-threads)
8213 (error "Can't fetch thread from back ends that don't support NOV"))
8214 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8215 (gnus-summary-limit-include-thread id)))
8217 (defun gnus-summary-refer-article (message-id)
8218 "Fetch an article specified by MESSAGE-ID."
8219 (interactive "sMessage-ID: ")
8220 (when (and (stringp message-id)
8221 (not (zerop (length message-id))))
8222 (setq message-id (gnus-replace-in-string message-id " " ""))
8223 ;; Construct the correct Message-ID if necessary.
8224 ;; Suggested by tale@pawl.rpi.edu.
8225 (unless (string-match "^<" message-id)
8226 (setq message-id (concat "<" message-id)))
8227 (unless (string-match ">$" message-id)
8228 (setq message-id (concat message-id ">")))
8229 ;; People often post MIDs from URLs, so unhex it:
8230 (unless (string-match "@" message-id)
8231 (setq message-id (gnus-url-unhex-string message-id)))
8232 (let* ((header (gnus-id-to-header message-id))
8234 (gnus-summary-article-sparse-p
8235 (mail-header-number header))
8236 (memq (mail-header-number header)
8237 gnus-newsgroup-limit)))
8240 ;; If the article is present in the buffer we just go to it.
8242 (or (not (gnus-summary-article-sparse-p
8243 (mail-header-number header)))
8246 (gnus-summary-goto-article
8247 (mail-header-number header) nil t)
8249 (gnus-summary-update-article (mail-header-number header)))))
8251 ;; We fetch the article.
8253 (dolist (gnus-override-method (gnus-refer-article-methods))
8254 (when (and (gnus-check-server gnus-override-method)
8255 ;; Fetch the header,
8256 (setq number (gnus-summary-insert-subject message-id)))
8257 ;; and display the article.
8258 (gnus-summary-select-article nil nil nil number)
8260 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8262 (defun gnus-refer-article-methods ()
8263 "Return a list of referable methods."
8265 ;; No method, so we default to current and native.
8266 ((null gnus-refer-article-method)
8267 (list gnus-current-select-method gnus-select-method))
8269 ((eq 'current gnus-refer-article-method)
8270 (list gnus-current-select-method))
8271 ;; List of select methods.
8272 ((not (and (symbolp (car gnus-refer-article-method))
8273 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8275 (dolist (method gnus-refer-article-method)
8276 (push (if (eq 'current method)
8277 gnus-current-select-method
8281 ;; One single select method.
8283 (list gnus-refer-article-method))))
8285 (defun gnus-summary-edit-parameters ()
8286 "Edit the group parameters of the current group."
8288 (gnus-group-edit-group gnus-newsgroup-name 'params))
8290 (defun gnus-summary-customize-parameters ()
8291 "Customize the group parameters of the current group."
8293 (gnus-group-customize gnus-newsgroup-name))
8295 (defun gnus-summary-enter-digest-group (&optional force)
8296 "Enter an nndoc group based on the current article.
8297 If FORCE, force a digest interpretation. If not, try
8298 to guess what the document format is."
8300 (let ((conf gnus-current-window-configuration))
8301 (save-window-excursion
8303 (let (gnus-article-prepare-hook
8304 gnus-display-mime-function
8306 (gnus-summary-select-article))))
8307 (setq gnus-current-window-configuration conf)
8308 (let* ((name (format "%s-%d"
8309 (gnus-group-prefixed-name
8310 gnus-newsgroup-name (list 'nndoc ""))
8311 (with-current-buffer gnus-summary-buffer
8312 gnus-current-article)))
8313 (ogroup gnus-newsgroup-name)
8314 (params (append (gnus-info-params (gnus-get-info ogroup))
8315 (list (cons 'to-group ogroup))
8316 (list (cons 'parent-group ogroup))
8317 (list (cons 'save-article-group ogroup))))
8318 (case-fold-search t)
8319 (buf (current-buffer))
8322 (set-buffer gnus-original-article-buffer)
8323 ;; Have the digest group inherit the main mail address of
8324 ;; the parent article.
8325 (when (setq to-address (or (gnus-fetch-field "reply-to")
8326 (gnus-fetch-field "from")))
8327 (setq params (append
8328 (list (cons 'to-address
8329 (funcall gnus-decode-encoded-word-function
8331 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8332 (insert-buffer-substring gnus-original-article-buffer)
8333 ;; Remove lines that may lead nndoc to misinterpret the
8336 (goto-char (point-min))
8337 (or (search-forward "\n\n" nil t) (point)))
8338 (goto-char (point-min))
8339 (delete-matching-lines "^Path:\\|^From ")
8342 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8343 (gnus-newsgroup-ephemeral-ignored-charsets
8344 gnus-newsgroup-ignored-charsets))
8345 (gnus-group-read-ephemeral-group
8346 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8348 ,(if force 'mbox 'guess)))
8350 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8352 ;; Make all postings to this group go to the parent group.
8353 (nconc (gnus-info-params (gnus-get-info name))
8355 ;; Couldn't select this doc group.
8356 (switch-to-buffer buf)
8357 (gnus-set-global-variables)
8358 (gnus-configure-windows 'summary)
8359 (gnus-message 3 "Article couldn't be entered?"))
8360 (kill-buffer dig)))))
8362 (defun gnus-summary-read-document (n)
8363 "Open a new group based on the current article(s).
8364 This will allow you to read digests and other similar
8365 documents as newsgroups.
8366 Obeys the standard process/prefix convention."
8368 (let* ((articles (gnus-summary-work-articles n))
8369 (ogroup gnus-newsgroup-name)
8370 (params (append (gnus-info-params (gnus-get-info ogroup))
8371 (list (cons 'to-group ogroup))))
8372 article group egroup groups vgroup)
8373 (while (setq article (pop articles))
8374 (setq group (format "%s-%d" gnus-newsgroup-name article))
8375 (gnus-summary-remove-process-mark article)
8376 (when (gnus-summary-display-article article)
8379 (insert-buffer-substring gnus-original-article-buffer)
8380 ;; Remove some headers that may lead nndoc to make
8382 (message-narrow-to-head)
8383 (goto-char (point-min))
8384 (delete-matching-lines "^Path:\\|^From ")
8387 (gnus-group-read-ephemeral-group
8388 group `(nndoc ,group (nndoc-address ,(current-buffer))
8389 (nndoc-article-type guess))
8392 ;; Make all postings to this group go to the parent group.
8393 (nconc (gnus-info-params (gnus-get-info egroup))
8395 (push egroup groups))
8396 ;; Couldn't select this doc group.
8397 (gnus-error 3 "Article couldn't be entered"))))))
8398 ;; Now we have selected all the documents.
8401 (error "None of the articles could be interpreted as documents"))
8402 ((gnus-group-read-ephemeral-group
8403 (setq vgroup (format
8404 "nnvirtual:%s-%s" gnus-newsgroup-name
8405 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8406 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8408 (cons (current-buffer) 'summary)))
8410 (error "Couldn't select virtual nndoc group")))))
8412 (defun gnus-summary-isearch-article (&optional regexp-p)
8413 "Do incremental search forward on the current article.
8414 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8416 (let* ((gnus-inhibit-treatment t)
8417 (old (gnus-summary-select-article)))
8418 (gnus-configure-windows 'article)
8419 (gnus-eval-in-buffer-window gnus-article-buffer
8423 (gnus-article-show-all-headers))
8424 (goto-char (point-min))
8425 (isearch-forward regexp-p)))))
8427 (defun gnus-summary-search-article-forward (regexp &optional backward)
8428 "Search for an article containing REGEXP forward.
8429 If BACKWARD, search backward instead."
8432 (format "Search article %s (regexp%s): "
8433 (if current-prefix-arg "backward" "forward")
8434 (if gnus-last-search-regexp
8435 (concat ", default " gnus-last-search-regexp)
8437 current-prefix-arg))
8438 (if (string-equal regexp "")
8439 (setq regexp (or gnus-last-search-regexp ""))
8440 (setq gnus-last-search-regexp regexp)
8441 (setq gnus-article-before-search gnus-current-article))
8442 ;; Intentionally set gnus-last-article.
8443 (setq gnus-last-article gnus-article-before-search)
8444 (let ((gnus-last-article gnus-last-article))
8445 (if (gnus-summary-search-article regexp backward)
8446 (gnus-summary-show-thread)
8447 (error "Search failed: \"%s\"" regexp))))
8449 (defun gnus-summary-search-article-backward (regexp)
8450 "Search for an article containing REGEXP backward."
8453 (format "Search article backward (regexp%s): "
8454 (if gnus-last-search-regexp
8455 (concat ", default " gnus-last-search-regexp)
8457 (gnus-summary-search-article-forward regexp 'backward))
8460 (defmacro gnus-summary-search-article-position-point (regexp backward)
8461 "Dehighlight the last matched text and goto the beginning position."
8462 (` (if (and gnus-summary-search-article-matched-data
8463 (let ((text (caddr gnus-summary-search-article-matched-data))
8464 (inhibit-read-only t)
8467 (goto-char (car gnus-summary-search-article-matched-data))
8468 (cadr gnus-summary-search-article-matched-data))
8470 (string-match (, regexp) text)))
8471 (if (, backward) (beginning-of-line) (end-of-line))
8472 (goto-char (if (, backward) (point-max) (point-min))))))
8474 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8475 "Place point where X-Face image is displayed."
8476 (if (featurep 'xemacs)
8477 (` (let ((end (if (search-forward "\n\n" nil t)
8478 (goto-char (1- (point)))
8481 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8482 (unless (and (re-search-forward "^From:" end t)
8483 (setq extent (extent-at (point)))
8484 (extent-begin-glyph extent))
8485 (goto-char (, opoint)))))
8486 (` (let ((end (if (search-forward "\n\n" nil t)
8487 (goto-char (1- (point)))
8489 (start (or (search-backward "\n\n" nil t) (point-min))))
8491 (or (text-property-any start end 'x-face-image t);; x-face-e21
8492 (text-property-any start end 'x-face-mule-bitmap-image t)
8495 (defmacro gnus-summary-search-article-highlight-matched-text
8496 (backward treated x-face)
8497 "Highlight matched text in the function `gnus-summary-search-article'."
8498 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8499 (end (set-marker (make-marker) (match-end 0)))
8500 (inhibit-read-only t)
8504 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8506 (lambda (item) (setq items (delq item items)))
8507 '(gnus-treat-buttonize
8508 gnus-treat-fill-article
8509 gnus-treat-fill-long-lines
8510 gnus-treat-emphasize
8511 gnus-treat-highlight-headers
8512 gnus-treat-highlight-citation
8513 gnus-treat-highlight-signature
8514 gnus-treat-overstrike
8515 gnus-treat-display-x-face
8516 gnus-treat-buttonize-head
8517 gnus-treat-decode-article-as-default-mime-charset))
8518 (static-if (featurep 'xemacs)
8520 (cons '(x-face-mule-delete-x-face-field
8523 (gnus-treat-display-x-face
8524 (when (, x-face) gnus-treat-display-x-face)))
8525 (gnus-article-prepare-mime-display)))
8526 (goto-char (if (, backward) start end))
8528 (gnus-summary-search-article-highlight-goto-x-face (point)))
8529 (setq gnus-summary-search-article-matched-data
8530 (list start end (buffer-substring start end)))
8531 (unless (eq start end);; matched text has been deleted. :-<
8532 (put-text-property start end 'face
8533 (or (find-face 'isearch)
8534 'secondary-selection))))))
8537 (defun gnus-summary-search-article (regexp &optional backward)
8538 "Search for an article containing REGEXP.
8539 Optional argument BACKWARD means do search for backward.
8540 `gnus-select-article-hook' is not called during the search."
8541 ;; We have to require this here to make sure that the following
8542 ;; dynamic binding isn't shadowed by autoloading.
8543 (require 'gnus-async)
8545 (let ((gnus-select-article-hook nil) ;Disable hook.
8546 (gnus-article-prepare-hook nil)
8547 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8548 (gnus-use-article-prefetch nil)
8549 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8550 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8552 (gnus-keep-backlog nil)
8553 (gnus-break-pages nil)
8554 (gnus-summary-display-arrow nil)
8555 (gnus-updated-mode-lines nil)
8556 (gnus-auto-center-summary nil)
8557 (sum (current-buffer))
8560 (gnus-save-hidden-threads
8561 (static-if (featurep 'xemacs)
8562 (let ((gnus-inhibit-treatment t))
8563 (setq treated (eq 'old (gnus-summary-select-article)))
8565 (not (and (gnus-buffer-live-p gnus-article-buffer)
8566 (window-live-p (get-buffer-window
8567 gnus-article-buffer t)))))
8568 (gnus-summary-select-article nil t)
8569 (setq treated nil)))
8570 (let ((gnus-inhibit-treatment t)
8571 (x-face-mule-delete-x-face-field 'never))
8572 (setq treated (eq 'old (gnus-summary-select-article)))
8575 (and (gnus-buffer-live-p gnus-article-buffer)
8576 (window-live-p (get-buffer-window
8577 gnus-article-buffer t))
8578 (or (not (string-match "^\\^X-Face:" regexp))
8579 (with-current-buffer gnus-article-buffer
8580 gnus-summary-search-article-matched-data)))))
8581 (gnus-summary-select-article nil t)
8582 (setq treated nil))))
8583 (set-buffer gnus-article-buffer)
8587 (gnus-article-show-all-headers)
8588 (gnus-summary-search-article-position-point regexp backward))
8589 (goto-char (if backward (point-max) (point-min))))
8591 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8593 (re-search-backward regexp nil t)
8594 (re-search-forward regexp nil t))
8595 ;; We found the regexp.
8597 (gnus-summary-search-article-highlight-matched-text
8598 backward treated (string-match "^\\^X-Face:" regexp))
8601 (/ (- 2 (window-height
8602 (get-buffer-window gnus-article-buffer t)))
8605 (get-buffer-window (current-buffer))
8608 (setq point (point)))
8609 ;; We didn't find it, so we go to the next article.
8612 (while (eq found 'not)
8613 (if (not (if backward (gnus-summary-find-prev)
8614 (gnus-summary-find-next)))
8615 ;; No more articles.
8617 ;; Select the next article and adjust point.
8618 (unless (gnus-summary-article-sparse-p
8619 (gnus-summary-article-number))
8621 (let ((gnus-inhibit-treatment t))
8622 (gnus-summary-select-article))
8624 (set-buffer gnus-article-buffer)
8626 (goto-char (if backward (point-max) (point-min))))))))
8627 (gnus-message 7 ""))
8628 ;; Return whether we found the regexp.
8629 (when (eq found 'found)
8631 (gnus-summary-show-thread)
8632 (gnus-summary-goto-subject gnus-current-article)
8633 (gnus-summary-position-point)
8636 (defun gnus-find-matching-articles (header regexp)
8637 "Return a list of all articles that match REGEXP on HEADER.
8638 This search includes all articles in the current group that Gnus has
8639 fetched headers for, whether they are displayed or not."
8640 (let ((articles nil)
8641 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8642 (case-fold-search t))
8643 (dolist (header gnus-newsgroup-headers)
8644 (when (string-match regexp (funcall func header))
8645 (push (mail-header-number header) articles)))
8646 (nreverse articles)))
8648 (defun gnus-summary-find-matching (header regexp &optional backward unread
8649 not-case-fold not-matching)
8650 "Return a list of all articles that match REGEXP on HEADER.
8651 The search stars on the current article and goes forwards unless
8652 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8653 If UNREAD is non-nil, only unread articles will
8654 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8655 in the comparisons. If NOT-MATCHING, return a list of all articles that
8656 not match REGEXP on HEADER."
8657 (let ((case-fold-search (not not-case-fold))
8660 (if (eq (car header) 'extra)
8663 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8665 (error "%s is an invalid header" header))
8666 (unless (fboundp (intern (concat "mail-header-" header)))
8667 (error "%s is not a valid header" header))
8668 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8669 (dolist (d (if (eq backward 'all)
8671 (gnus-data-find-list
8672 (gnus-summary-article-number)
8673 (gnus-data-list backward))))
8674 (when (and (or (not unread) ; We want all articles...
8675 (gnus-data-unread-p d)) ; Or just unreads.
8676 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8680 (funcall func (gnus-data-header d))))
8681 (string-match regexp
8682 (funcall func (gnus-data-header d)))))
8683 (push (gnus-data-number d) articles))) ; Success!
8684 (nreverse articles)))
8686 (defun gnus-summary-execute-command (header regexp command &optional backward)
8687 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8688 If HEADER is an empty string (or nil), the match is done on the entire
8689 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8691 (list (let ((completion-ignore-case t))
8694 (mapcar (lambda (header) (list (format "%s" header)))
8696 '("Number" "Subject" "From" "Lines" "Date"
8697 "Message-ID" "Xref" "References" "Body")
8698 gnus-extra-headers))
8699 nil 'require-match))
8700 (read-string "Regexp: ")
8701 (read-key-sequence "Command: ")
8702 current-prefix-arg))
8703 (when (equal header "Body")
8705 ;; Hidden thread subtrees must be searched as well.
8706 (gnus-summary-show-all-threads)
8707 ;; We don't want to change current point nor window configuration.
8709 (save-window-excursion
8711 gnus-treat-strip-trailing-blank-lines
8712 gnus-treat-strip-leading-blank-lines
8713 gnus-treat-strip-multiple-blank-lines
8714 gnus-treat-hide-boring-headers
8715 gnus-treat-fold-newsgroups
8716 gnus-article-prepare-hook)
8717 (gnus-message 6 "Executing %s..." (key-description command))
8718 ;; We'd like to execute COMMAND interactively so as to give arguments.
8719 (gnus-execute header regexp
8720 `(call-interactively ',(key-binding command))
8722 (gnus-message 6 "Executing %s...done" (key-description command))))))
8724 (defun gnus-summary-beginning-of-article ()
8725 "Scroll the article back to the beginning."
8727 (gnus-summary-select-article)
8728 (gnus-configure-windows 'article)
8729 (gnus-eval-in-buffer-window gnus-article-buffer
8731 (goto-char (point-min))
8732 (when gnus-break-pages
8733 (gnus-narrow-to-page))))
8735 (defun gnus-summary-end-of-article ()
8736 "Scroll to the end of the article."
8738 (gnus-summary-select-article)
8739 (gnus-configure-windows 'article)
8740 (gnus-eval-in-buffer-window gnus-article-buffer
8742 (goto-char (point-max))
8744 (when gnus-break-pages
8745 (when (re-search-backward page-delimiter nil t)
8746 (narrow-to-region (match-end 0) (point-max)))
8747 (gnus-narrow-to-page))))
8749 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8750 "Truncate to LEN and quote all \"(\"'s in STRING."
8751 (gnus-replace-in-string (if (and len (> (length string) len))
8752 (substring string 0 len)
8756 (defun gnus-summary-print-article (&optional filename n)
8757 "Generate and print a PostScript image of the process-marked (mail) articles.
8759 If used interactively, print the current article if none are
8760 process-marked. With prefix arg, prompt the user for the name of the
8763 When used from Lisp, accept two optional args FILENAME and N. N means
8764 to print the next N articles. If N is negative, print the N previous
8765 articles. If N is nil and articles have been marked with the process
8766 mark, print these instead.
8768 If the optional first argument FILENAME is nil, send the image to the
8769 printer. If FILENAME is a string, save the PostScript image in a file with
8770 that name. If FILENAME is a number, prompt the user for the name of the file
8772 (interactive (list (ps-print-preprint current-prefix-arg)))
8773 (dolist (article (gnus-summary-work-articles n))
8774 (gnus-summary-select-article nil nil 'pseudo article)
8775 (gnus-eval-in-buffer-window gnus-article-buffer
8776 (gnus-print-buffer))
8777 (gnus-summary-remove-process-mark article))
8778 (ps-despool filename))
8780 (defun gnus-print-buffer ()
8781 (let ((buffer (generate-new-buffer " *print*")))
8784 (copy-to-buffer buffer (point-min) (point-max))
8786 (gnus-remove-text-with-property 'gnus-decoration)
8787 (when (gnus-visual-p 'article-highlight 'highlight)
8788 ;; Copy-to-buffer doesn't copy overlay. So redo
8790 (let ((gnus-article-buffer buffer))
8791 (gnus-article-highlight-citation t)
8792 (gnus-article-highlight-signature)
8793 (gnus-article-emphasize)
8794 (gnus-article-delete-invisible-text)))
8795 (let ((ps-left-header
8798 (gnus-summary-print-truncate-and-quote
8799 (mail-header-subject gnus-current-headers)
8802 (gnus-summary-print-truncate-and-quote
8803 (mail-header-from gnus-current-headers)
8807 "/pagenumberstring load"
8809 (mail-header-date gnus-current-headers) ")"))))
8810 (gnus-run-hooks 'gnus-ps-print-hook)
8813 (ps-spool-buffer-with-faces)
8814 (ps-spool-buffer)))))
8815 (kill-buffer buffer))))
8817 (defun gnus-summary-show-article (&optional arg)
8818 "Force redisplaying of the current article.
8819 If ARG (the prefix) is a number, show the article with the charset
8820 defined in `gnus-summary-show-article-charset-alist', or the charset
8822 If ARG (the prefix) is non-nil and not a number, show the raw article
8823 without any article massaging functions being run. Normally, the key
8824 strokes are `C-u g'."
8828 (gnus-summary-show-article t)
8829 (let* ((gnus-newsgroup-charset
8830 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8831 (mm-read-coding-system
8832 "View as charset: " ;; actually it is coding system.
8834 (set-buffer gnus-article-buffer)
8835 (mm-detect-coding-region (point) (point-max))))))
8836 (default-mime-charset gnus-newsgroup-charset)
8837 (gnus-newsgroup-ignored-charsets 'gnus-all))
8838 (gnus-summary-select-article nil 'force)
8839 (let ((deps gnus-newsgroup-dependencies)
8842 (set-buffer gnus-original-article-buffer)
8844 (message-narrow-to-head)
8845 (setq head (buffer-string))
8846 (goto-char (point-min))
8847 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8848 (goto-char (point-max))
8850 (setq lines (1- (count-lines (point) (point-max))))))
8852 (insert (format "211 %d Article retrieved.\n"
8853 (cdr gnus-article-current)))
8855 (if lines (insert (format "Lines: %d\n" lines)))
8857 (let ((nntp-server-buffer (current-buffer)))
8858 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8859 (gnus-data-set-header
8860 (gnus-data-find (cdr gnus-article-current))
8862 (gnus-summary-update-article-line
8863 (cdr gnus-article-current) header)
8864 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8865 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8867 ;; Select the article the normal way.
8868 (gnus-summary-select-article nil 'force))
8870 ;; We have to require this here to make sure that the following
8871 ;; dynamic binding isn't shadowed by autoloading.
8872 (require 'gnus-async)
8874 ;; Bind the article treatment functions to nil.
8875 (let ((gnus-have-all-headers t)
8876 gnus-article-prepare-hook
8877 gnus-article-decode-hook
8880 (gnus-inhibit-treatment t))
8881 (gnus-summary-select-article nil 'force))))
8882 (gnus-summary-goto-subject gnus-current-article)
8883 (gnus-summary-position-point))
8885 (defun gnus-summary-show-raw-article ()
8886 "Show the raw article without any article massaging functions being run."
8888 (gnus-summary-show-article t))
8890 (defun gnus-summary-verbose-headers (&optional arg)
8891 "Toggle permanent full header display.
8892 If ARG is a positive number, turn header display on.
8893 If ARG is a negative number, turn header display off."
8895 (setq gnus-show-all-headers
8896 (cond ((or (not (numberp arg))
8898 (not gnus-show-all-headers))
8901 (gnus-summary-show-article))
8903 (defun gnus-summary-toggle-header (&optional arg)
8904 "Show the headers if they are hidden, or hide them if they are shown.
8905 If ARG is a positive number, show the entire header.
8906 If ARG is a negative number, hide the unwanted header lines."
8908 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8909 (get-buffer-window gnus-article-buffer t))))
8910 (with-current-buffer gnus-article-buffer
8912 (article-narrow-to-head)
8913 (let* ((buffer-read-only nil)
8914 (inhibit-point-motion-hooks t)
8915 (hidden (if (numberp arg)
8917 (gnus-article-hidden-text-p 'headers)))
8919 (delete-region (point-min) (point-max))
8920 (with-current-buffer gnus-original-article-buffer
8921 (goto-char (setq s (point-min)))
8922 (setq e (if (search-forward "\n\n" nil t)
8925 (insert-buffer-substring gnus-original-article-buffer s e)
8926 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8927 ;; article-decode-encoded-words by default.
8928 (article-decode-encoded-words)
8929 (run-hooks 'gnus-article-decode-hook)
8931 (let ((gnus-treat-hide-headers nil)
8932 (gnus-treat-hide-boring-headers nil))
8933 (gnus-delete-wash-type 'headers)
8934 (gnus-treat-article 'head))
8935 (gnus-treat-article 'head))
8938 (set-window-start window (goto-char (point-min))))
8939 (if gnus-break-pages
8940 (gnus-narrow-to-page)
8941 (when (gnus-visual-p 'page-marker)
8942 (let ((buffer-read-only nil))
8943 (gnus-remove-text-with-property 'gnus-prev)
8944 (gnus-remove-text-with-property 'gnus-next))))
8945 (gnus-set-mode-line 'article)))))
8947 (defun gnus-summary-show-all-headers ()
8948 "Make all header lines visible."
8950 (gnus-summary-toggle-header 1))
8952 (defun gnus-summary-toggle-mime (&optional arg)
8953 "Toggle MIME processing.
8954 If ARG is a positive number, turn MIME processing on."
8956 (setq gnus-show-mime
8958 (not gnus-show-mime)
8959 (> (prefix-numeric-value arg) 0)))
8960 (gnus-summary-select-article t 'force))
8962 (defun gnus-summary-caesar-message (&optional arg)
8963 "Caesar rotate the current article by 13.
8964 The numerical prefix specifies how many places to rotate each letter
8967 (gnus-summary-select-article)
8968 (let ((mail-header-separator ""))
8969 (gnus-eval-in-buffer-window gnus-article-buffer
8972 (let ((start (window-start))
8974 (message-caesar-buffer-body arg)
8975 (set-window-start (get-buffer-window (current-buffer)) start))))))
8977 (autoload 'unmorse-region "morse"
8978 "Convert morse coded text in region to ordinary ASCII text."
8981 (defun gnus-summary-morse-message (&optional arg)
8982 "Morse decode the current article."
8984 (gnus-summary-select-article)
8985 (let ((mail-header-separator ""))
8986 (gnus-eval-in-buffer-window gnus-article-buffer
8990 (let ((pos (window-start))
8992 (goto-char (point-min))
8993 (when (message-goto-body)
8994 (gnus-narrow-to-body))
8995 (goto-char (point-min))
8996 (while (re-search-forward "·" (point-max) t)
8997 (replace-match "."))
8998 (unmorse-region (point-min) (point-max))
9000 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9002 (defun gnus-summary-stop-page-breaking ()
9003 "Stop page breaking in the current article."
9005 (gnus-summary-select-article)
9006 (gnus-eval-in-buffer-window gnus-article-buffer
9008 (when (gnus-visual-p 'page-marker)
9009 (let ((buffer-read-only nil))
9010 (gnus-remove-text-with-property 'gnus-prev)
9011 (gnus-remove-text-with-property 'gnus-next))
9012 (setq gnus-page-broken nil))))
9014 (defun gnus-summary-move-article (&optional n to-newsgroup
9015 select-method action)
9016 "Move the current article to a different newsgroup.
9017 If N is a positive number, move the N next articles.
9018 If N is a negative number, move the N previous articles.
9019 If N is nil and any articles have been marked with the process mark,
9020 move those articles instead.
9021 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9022 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9023 re-spool using this method.
9025 When called interactively with TO-NEWSGROUP being nil, the value of
9026 the variable `gnus-move-split-methods' is used for finding a default
9027 for the target newsgroup.
9029 For this function to work, both the current newsgroup and the
9030 newsgroup that you want to move to have to support the `request-move'
9031 and `request-accept' functions.
9033 ACTION can be either `move' (the default), `crosspost' or `copy'."
9036 (setq action 'move))
9037 ;; Check whether the source group supports the required functions.
9038 (cond ((and (eq action 'move)
9039 (not (gnus-check-backend-function
9040 'request-move-article gnus-newsgroup-name)))
9041 (error "The current group does not support article moving"))
9042 ((and (eq action 'crosspost)
9043 (not (gnus-check-backend-function
9044 'request-replace-article gnus-newsgroup-name)))
9045 (error "The current group does not support article editing")))
9046 (let ((articles (gnus-summary-work-articles n))
9047 (prefix (if (gnus-check-backend-function
9048 'request-move-article gnus-newsgroup-name)
9049 (funcall gnus-move-group-prefix-function
9050 gnus-newsgroup-name)
9052 (names '((move "Move" "Moving")
9053 (copy "Copy" "Copying")
9054 (crosspost "Crosspost" "Crossposting")))
9055 (copy-buf (save-excursion
9056 (nnheader-set-temp-buffer " *copy article*")))
9057 art-group to-method new-xref article to-groups)
9058 (unless (assq action names)
9059 (error "Unknown action %s" action))
9060 ;; Read the newsgroup name.
9061 (when (and (not to-newsgroup)
9062 (not select-method))
9063 (if (and gnus-move-split-methods
9065 (and (memq gnus-current-article articles)
9066 (gnus-buffer-live-p gnus-original-article-buffer))))
9067 ;; When `gnus-move-split-methods' is non-nil, we have to
9068 ;; select an article to give `gnus-read-move-group-name' an
9069 ;; opportunity to suggest an appropriate default. However,
9070 ;; we needn't render or mark the article.
9071 (let ((gnus-display-mime-function nil)
9072 (gnus-article-prepare-hook nil)
9073 (gnus-mark-article-hook nil))
9074 (gnus-summary-select-article nil nil nil (car articles))))
9076 (gnus-read-move-group-name
9077 (cadr (assq action names))
9078 (symbol-value (intern (format "gnus-current-%s-group" action)))
9080 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9081 (setq to-method (or select-method
9082 (gnus-server-to-method
9083 (gnus-group-method to-newsgroup))))
9084 ;; Check the method we are to move this article to...
9085 (unless (gnus-check-backend-function
9086 'request-accept-article (car to-method))
9087 (error "%s does not support article copying" (car to-method)))
9088 (unless (gnus-check-server to-method)
9089 (error "Can't open server %s" (car to-method)))
9090 (gnus-message 6 "%s to %s: %s..."
9091 (caddr (assq action names))
9092 (or (car select-method) to-newsgroup) articles)
9094 (setq article (pop articles))
9098 ;; Move the article.
9100 ;; Remove this article from future suppression.
9101 (gnus-dup-unsuppress-article article)
9102 (gnus-request-move-article
9103 article ; Article to move
9104 gnus-newsgroup-name ; From newsgroup
9105 (nth 1 (gnus-find-method-for-group
9106 gnus-newsgroup-name)) ; Server
9107 (list 'gnus-request-accept-article
9108 to-newsgroup (list 'quote select-method)
9109 (not articles) t) ; Accept form
9110 (not articles))) ; Only save nov last time
9111 ;; Copy the article.
9114 (set-buffer copy-buf)
9115 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9116 (gnus-request-accept-article
9117 to-newsgroup select-method (not articles) t))))
9118 ;; Crosspost the article.
9119 ((eq action 'crosspost)
9120 (let ((xref (message-tokenize-header
9121 (mail-header-xref (gnus-summary-article-header article))
9123 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9124 ":" (number-to-string article)))
9126 (setq xref (list (system-name))))
9129 (mapconcat 'identity
9130 (delete "Xref:" (delete new-xref xref))
9134 (set-buffer copy-buf)
9135 ;; First put the article in the destination group.
9136 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9137 (when (consp (setq art-group
9138 (gnus-request-accept-article
9139 to-newsgroup select-method (not articles))))
9140 (setq new-xref (concat new-xref " " (car art-group)
9142 (number-to-string (cdr art-group))))
9143 ;; Now we have the new Xrefs header, so we insert
9144 ;; it and replace the new article.
9145 (nnheader-replace-header "Xref" new-xref)
9146 (gnus-request-replace-article
9147 (cdr art-group) to-newsgroup (current-buffer))
9151 (gnus-message 1 "Couldn't %s article %s: %s"
9152 (cadr (assq action names)) article
9153 (nnheader-get-report (car to-method))))
9154 ((eq art-group 'junk)
9155 (when (eq action 'move)
9156 (gnus-summary-mark-article article gnus-canceled-mark)
9157 (gnus-message 4 "Deleted article %s" article)
9158 ;; run the delete hook
9159 (run-hook-with-args 'gnus-summary-article-delete-hook
9162 (assoc article (gnus-data-list nil)))
9163 gnus-newsgroup-name nil
9166 (let* ((pto-group (gnus-group-prefixed-name
9167 (car art-group) to-method))
9168 (info (gnus-get-info pto-group))
9169 (to-group (gnus-info-group info))
9171 ;; Update the group that has been moved to.
9173 (memq action '(move copy)))
9174 (unless (member to-group to-groups)
9175 (push to-group to-groups))
9177 (unless (memq article gnus-newsgroup-unreads)
9178 (push 'read to-marks)
9180 info (gnus-add-to-range (gnus-info-read info)
9181 (list (cdr art-group)))))
9183 ;; See whether the article is to be put in the cache.
9184 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9185 gnus-article-mark-lists
9186 (delete '(expirable . expire)
9187 (copy-sequence gnus-article-mark-lists))))
9188 (to-article (cdr art-group)))
9190 ;; Enter the article into the cache in the new group,
9191 ;; if that is required.
9192 (when gnus-use-cache
9193 (gnus-cache-possibly-enter-article
9195 (let ((header (copy-sequence
9196 (gnus-summary-article-header article))))
9197 (mail-header-set-number header to-article)
9199 (memq article gnus-newsgroup-marked)
9200 (memq article gnus-newsgroup-dormant)
9201 (memq article gnus-newsgroup-unreads)))
9203 (when gnus-preserve-marks
9204 ;; Copy any marks over to the new group.
9205 (when (and (equal to-group gnus-newsgroup-name)
9206 (not (memq article gnus-newsgroup-unreads)))
9207 ;; Mark this article as read in this group.
9208 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9209 (setcdr (gnus-active to-group) to-article)
9210 (setcdr gnus-newsgroup-active to-article))
9213 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9214 (when (memq article (symbol-value
9215 (intern (format "gnus-newsgroup-%s"
9217 (push (cdar marks) to-marks)
9218 ;; If the other group is the same as this group,
9219 ;; then we have to add the mark to the list.
9220 (when (equal to-group gnus-newsgroup-name)
9221 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9224 (intern (format "gnus-newsgroup-%s"
9226 ;; Copy the marks to other group.
9227 (gnus-add-marked-articles
9228 to-group (cdar marks) (list to-article) info)))
9229 (setq marks (cdr marks)))
9231 (gnus-request-set-mark
9232 to-group (list (list (list to-article) 'add to-marks))))
9235 (concat "(gnus-group-set-info '"
9236 (gnus-prin1-to-string (gnus-get-info to-group))
9239 ;; Update the Xref header in this article to point to
9240 ;; the new crossposted article we have just created.
9241 (when (eq action 'crosspost)
9243 (set-buffer copy-buf)
9244 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9245 (nnheader-replace-header "Xref" new-xref)
9246 (gnus-request-replace-article
9247 article gnus-newsgroup-name (current-buffer))))
9249 ;; run the move/copy/crosspost/respool hook
9250 (run-hook-with-args 'gnus-summary-article-move-hook
9253 (assoc article (gnus-data-list nil)))
9258 ;;;!!!Why is this necessary?
9259 (set-buffer gnus-summary-buffer)
9261 (gnus-summary-goto-subject article)
9262 (when (eq action 'move)
9263 (gnus-summary-mark-article article gnus-canceled-mark))))
9264 (gnus-summary-remove-process-mark article))
9265 ;; Re-activate all groups that have been moved to.
9267 (set-buffer gnus-group-buffer)
9268 (let ((gnus-group-marked to-groups))
9269 (gnus-group-get-new-news-this-group nil t)))
9271 (gnus-kill-buffer copy-buf)
9272 (gnus-summary-position-point)
9273 (gnus-set-mode-line 'summary)))
9275 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9276 "Move the current article to a different newsgroup.
9277 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9278 When called interactively, if TO-NEWSGROUP is nil, use the value of
9279 the variable `gnus-move-split-methods' for finding a default target
9281 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9282 re-spool using this method."
9284 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9286 (defun gnus-summary-crosspost-article (&optional n)
9287 "Crosspost the current article to some other group."
9289 (gnus-summary-move-article n nil nil 'crosspost))
9291 (defcustom gnus-summary-respool-default-method nil
9292 "Default method type for respooling an article.
9293 If nil, use to the current newsgroup method."
9295 :group 'gnus-summary-mail)
9297 (defcustom gnus-summary-display-while-building nil
9298 "If non-nil, show and update the summary buffer as it's being built.
9299 If the value is t, update the buffer after every line is inserted. If
9300 the value is an integer (N), update the display every N lines."
9302 :type '(choice (const :tag "off" nil)
9304 (const :tag "frequently" t)))
9306 (defun gnus-summary-respool-article (&optional n method)
9307 "Respool the current article.
9308 The article will be squeezed through the mail spooling process again,
9309 which means that it will be put in some mail newsgroup or other
9310 depending on `nnmail-split-methods'.
9311 If N is a positive number, respool the N next articles.
9312 If N is a negative number, respool the N previous articles.
9313 If N is nil and any articles have been marked with the process mark,
9314 respool those articles instead.
9316 Respooling can be done both from mail groups and \"real\" newsgroups.
9317 In the former case, the articles in question will be moved from the
9318 current group into whatever groups they are destined to. In the
9319 latter case, they will be copied into the relevant groups."
9321 (list current-prefix-arg
9322 (let* ((methods (gnus-methods-using 'respool))
9324 (symbol-name (or gnus-summary-respool-default-method
9325 (car (gnus-find-method-for-group
9326 gnus-newsgroup-name)))))
9328 (gnus-completing-read-with-default
9329 methname "What backend do you want to use when respooling?"
9330 methods nil t nil 'gnus-mail-method-history))
9333 ((zerop (length (setq ms (gnus-servers-using-backend
9335 (list (intern method) ""))
9339 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9340 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9343 (error "No method given for respooling"))
9344 (if (assoc (symbol-name
9345 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9346 (gnus-methods-using 'respool))
9347 (gnus-summary-move-article n nil method)
9348 (gnus-summary-copy-article n nil method)))
9350 (defun gnus-summary-import-article (file &optional edit)
9351 "Import an arbitrary file into a mail newsgroup."
9352 (interactive "fImport file: \nP")
9353 (let ((group gnus-newsgroup-name)
9354 (now (current-time))
9355 atts lines group-art)
9356 (unless (gnus-check-backend-function 'request-accept-article group)
9357 (error "%s does not support article importing" group))
9358 (or (file-readable-p file)
9359 (not (file-regular-p file))
9360 (error "Can't read %s" file))
9362 (set-buffer (gnus-get-buffer-create " *import file*"))
9364 (nnheader-insert-file-contents file)
9365 (goto-char (point-min))
9366 (if (nnheader-article-p)
9368 (goto-char (point-min))
9369 (search-forward "\n\n" nil t)
9370 (narrow-to-region (point-min) (1- (point)))
9371 (goto-char (point-min))
9372 (unless (re-search-forward "^date:" nil t)
9373 (goto-char (point-max))
9374 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9375 ;; This doesn't look like an article, so we fudge some headers.
9376 (setq atts (file-attributes file)
9377 lines (count-lines (point-min) (point-max)))
9378 (insert "From: " (read-string "From: ") "\n"
9379 "Subject: " (read-string "Subject: ") "\n"
9380 "Date: " (message-make-date (nth 5 atts)) "\n"
9381 "Message-ID: " (message-make-message-id) "\n"
9382 "Lines: " (int-to-string lines) "\n"
9383 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9384 (setq group-art (gnus-request-accept-article group nil t))
9385 (kill-buffer (current-buffer)))
9386 (setq gnus-newsgroup-active (gnus-activate-group group))
9388 (gnus-summary-goto-article (cdr group-art) nil t)
9390 (gnus-summary-edit-article))))
9392 (defun gnus-summary-create-article ()
9393 "Create an article in a mail newsgroup."
9395 (let ((group gnus-newsgroup-name)
9396 (now (current-time))
9398 (unless (gnus-check-backend-function 'request-accept-article group)
9399 (error "%s does not support article importing" group))
9401 (set-buffer (gnus-get-buffer-create " *import file*"))
9403 (goto-char (point-min))
9404 ;; This doesn't look like an article, so we fudge some headers.
9405 (insert "From: " (read-string "From: ") "\n"
9406 "Subject: " (read-string "Subject: ") "\n"
9407 "Date: " (message-make-date now) "\n"
9408 "Message-ID: " (message-make-message-id) "\n")
9409 (setq group-art (gnus-request-accept-article group nil t))
9410 (kill-buffer (current-buffer)))
9411 (setq gnus-newsgroup-active (gnus-activate-group group))
9413 (gnus-summary-goto-article (cdr group-art) nil t)
9414 (gnus-summary-edit-article)))
9416 (defun gnus-summary-article-posted-p ()
9417 "Say whether the current (mail) article is available from news as well.
9418 This will be the case if the article has both been mailed and posted."
9420 (let ((id (mail-header-references (gnus-summary-article-header)))
9421 (gnus-override-method (car (gnus-refer-article-methods))))
9422 (if (gnus-request-head id "")
9423 (gnus-message 2 "The current message was found on %s"
9424 gnus-override-method)
9425 (gnus-message 2 "The current message couldn't be found on %s"
9426 gnus-override-method)
9429 (defun gnus-summary-expire-articles (&optional now)
9430 "Expire all articles that are marked as expirable in the current group."
9432 (when (and (not gnus-group-is-exiting-without-update-p)
9433 (gnus-check-backend-function
9434 'request-expire-articles gnus-newsgroup-name))
9435 ;; This backend supports expiry.
9436 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9437 (expirable (if total
9439 ;; We need to update the info for
9440 ;; this group for `gnus-list-of-read-articles'
9441 ;; to give us the right answer.
9442 (gnus-run-hooks 'gnus-exit-group-hook)
9443 (gnus-summary-update-info)
9444 (gnus-list-of-read-articles gnus-newsgroup-name))
9445 (setq gnus-newsgroup-expirable
9446 (sort gnus-newsgroup-expirable '<))))
9447 (expiry-wait (if now 'immediate
9448 (gnus-group-find-parameter
9449 gnus-newsgroup-name 'expiry-wait)))
9450 (nnmail-expiry-target
9451 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9452 nnmail-expiry-target))
9455 ;; There are expirable articles in this group, so we run them
9456 ;; through the expiry process.
9457 (gnus-message 6 "Expiring articles...")
9458 (unless (gnus-check-group gnus-newsgroup-name)
9459 (error "Can't open server for %s" gnus-newsgroup-name))
9460 ;; The list of articles that weren't expired is returned.
9463 (let ((nnmail-expiry-wait-function nil)
9464 (nnmail-expiry-wait expiry-wait))
9465 (setq es (gnus-request-expire-articles
9466 expirable gnus-newsgroup-name)))
9467 (setq es (gnus-request-expire-articles
9468 expirable gnus-newsgroup-name)))
9470 (setq gnus-newsgroup-expirable es))
9471 ;; We go through the old list of expirable, and mark all
9472 ;; really expired articles as nonexistent.
9473 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9474 (let ((gnus-use-cache nil))
9475 (dolist (article expirable)
9476 (when (and (not (memq article es))
9477 (gnus-data-find article))
9478 (gnus-summary-mark-article article gnus-canceled-mark)
9479 (run-hook-with-args 'gnus-summary-article-expire-hook
9482 (assoc article (gnus-data-list nil)))
9486 (gnus-message 6 "Expiring articles...done")))))
9488 (defun gnus-summary-expire-articles-now ()
9489 "Expunge all expirable articles in the current group.
9490 This means that *all* articles that are marked as expirable will be
9491 deleted forever, right now."
9493 (or gnus-expert-user
9495 "Are you really, really, really sure you want to delete all these messages? ")
9497 (gnus-summary-expire-articles t))
9499 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9500 (defun gnus-summary-delete-article (&optional n)
9501 "Delete the N next (mail) articles.
9502 This command actually deletes articles. This is not a marking
9503 command. The article will disappear forever from your life, never to
9506 If N is negative, delete backwards.
9507 If N is nil and articles have been marked with the process mark,
9508 delete these instead.
9510 If `gnus-novice-user' is non-nil you will be asked for
9511 confirmation before the articles are deleted."
9513 (unless (gnus-check-backend-function 'request-expire-articles
9514 gnus-newsgroup-name)
9515 (error "The current newsgroup does not support article deletion"))
9516 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9517 (error "Couldn't open server"))
9518 ;; Compute the list of articles to delete.
9519 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9520 (nnmail-expiry-target 'delete)
9522 (if (and gnus-novice-user
9523 (not (gnus-yes-or-no-p
9524 (format "Do you really want to delete %s forever? "
9525 (if (> (length articles) 1)
9526 (format "these %s articles" (length articles))
9529 ;; Delete the articles.
9530 (setq not-deleted (gnus-request-expire-articles
9531 articles gnus-newsgroup-name 'force))
9533 (gnus-summary-remove-process-mark (car articles))
9534 ;; The backend might not have been able to delete the article
9536 (unless (memq (car articles) not-deleted)
9537 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9538 (let* ((article (car articles))
9539 (ghead (gnus-data-header
9540 (assoc article (gnus-data-list nil)))))
9541 (run-hook-with-args 'gnus-summary-article-delete-hook
9542 'delete ghead gnus-newsgroup-name nil
9544 (setq articles (cdr articles)))
9546 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9547 (gnus-summary-position-point)
9548 (gnus-set-mode-line 'summary)
9551 (defun gnus-summary-edit-article (&optional force)
9552 "Edit the current article.
9553 This will have permanent effect only in mail groups.
9554 If FORCE is non-nil, allow editing of articles even in read-only
9558 (set-buffer gnus-summary-buffer)
9559 (let ((mail-parse-charset gnus-newsgroup-charset)
9560 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9561 (gnus-set-global-variables)
9562 (when (and (not force)
9563 (gnus-group-read-only-p))
9564 (error "The current newsgroup does not support article editing"))
9565 (gnus-summary-show-article t)
9566 (gnus-article-edit-article
9568 `(lambda (no-highlight)
9569 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9570 (message-options message-options)
9571 (message-options-set-recipient)
9572 (mail-parse-ignored-charsets
9573 ',gnus-newsgroup-ignored-charsets))
9574 (gnus-summary-edit-article-done
9575 ,(or (mail-header-references gnus-current-headers) "")
9576 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9578 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9580 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9582 "Make edits to the current article permanent."
9585 ;; The buffer restriction contains the entire article if it exists.
9586 (when (article-goto-body)
9587 (let ((lines (count-lines (point) (point-max)))
9588 (length (- (point-max) (point)))
9589 (case-fold-search t)
9590 (body (copy-marker (point))))
9591 (goto-char (point-min))
9592 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9593 (delete-region (match-beginning 1) (match-end 1))
9594 (insert (number-to-string length)))
9595 (goto-char (point-min))
9596 (when (re-search-forward
9597 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9598 (delete-region (match-beginning 1) (match-end 1))
9599 (insert (number-to-string length)))
9600 (goto-char (point-min))
9601 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9602 (delete-region (match-beginning 1) (match-end 1))
9603 (insert (number-to-string lines))))))
9604 ;; Replace the article.
9605 (let ((buf (current-buffer)))
9607 (insert-buffer-substring buf)
9609 (if (and (not read-only)
9610 (not (gnus-request-replace-article
9611 (cdr gnus-article-current) (car gnus-article-current)
9612 (current-buffer) t)))
9613 (error "Couldn't replace article")
9614 ;; Update the summary buffer.
9616 (equal (message-tokenize-header references " ")
9617 (message-tokenize-header
9618 (or (message-fetch-field "references") "") " ")))
9619 ;; We only have to update this line.
9622 (message-narrow-to-head)
9623 (let ((head (buffer-string))
9626 (insert (format "211 %d Article retrieved.\n"
9627 (cdr gnus-article-current)))
9630 (let ((nntp-server-buffer (current-buffer)))
9631 (setq header (car (gnus-get-newsgroup-headers
9634 (set-buffer gnus-summary-buffer)
9635 (gnus-data-set-header
9636 (gnus-data-find (cdr gnus-article-current))
9638 (gnus-summary-update-article-line
9639 (cdr gnus-article-current) header)
9640 (if (gnus-summary-goto-subject
9641 (cdr gnus-article-current) nil t)
9642 (gnus-summary-update-secondary-mark
9643 (cdr gnus-article-current))))))))
9645 (set-buffer (or buffer gnus-summary-buffer))
9646 (gnus-summary-update-article (cdr gnus-article-current))
9647 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9648 (gnus-summary-update-secondary-mark
9649 (cdr gnus-article-current))))
9650 ;; Prettify the article buffer again.
9651 (unless no-highlight
9653 (set-buffer gnus-article-buffer)
9654 ;;;!!! Fix this -- article should be rehighlighted.
9655 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9656 (set-buffer gnus-original-article-buffer)
9657 (gnus-request-article
9658 (cdr gnus-article-current)
9659 (car gnus-article-current) (current-buffer))))
9660 ;; Prettify the summary buffer line.
9661 (when (gnus-visual-p 'summary-highlight 'highlight)
9662 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9664 (defun gnus-summary-edit-wash (key)
9665 "Perform editing command KEY in the article buffer."
9669 (message "%s" (concat (this-command-keys) "- "))
9672 (gnus-summary-edit-article)
9673 (execute-kbd-macro (concat (this-command-keys) key))
9674 (gnus-article-edit-done))
9678 (defun gnus-summary-respool-query (&optional silent trace)
9679 "Query where the respool algorithm would put this article."
9681 (let (gnus-mark-article-hook)
9682 (gnus-summary-select-article)
9684 (set-buffer gnus-original-article-buffer)
9685 (let ((groups (nnmail-article-group 'identity trace)))
9688 (message "This message would go to %s"
9689 (mapconcat 'car groups ", "))
9690 (message "This message would go to no groups"))
9693 (defun gnus-summary-respool-trace ()
9694 "Trace where the respool algorithm would put this article.
9695 Display a buffer showing all fancy splitting patterns which matched."
9697 (gnus-summary-respool-query nil t))
9699 ;; Summary marking commands.
9701 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9702 "Mark articles which has the same subject as read, and then select the next.
9703 If UNMARK is positive, remove any kind of mark.
9704 If UNMARK is negative, tick articles."
9707 (setq unmark (prefix-numeric-value unmark)))
9709 (gnus-summary-mark-same-subject
9710 (gnus-summary-article-subject) unmark)))
9711 ;; Select next unread article. If auto-select-same mode, should
9712 ;; select the first unread article.
9713 (gnus-summary-next-article t (and gnus-auto-select-same
9714 (gnus-summary-article-subject)))
9715 (gnus-message 7 "%d article%s marked as %s"
9716 count (if (= count 1) " is" "s are")
9717 (if unmark "unread" "read"))))
9719 (defun gnus-summary-kill-same-subject (&optional unmark)
9720 "Mark articles which has the same subject as read.
9721 If UNMARK is positive, remove any kind of mark.
9722 If UNMARK is negative, tick articles."
9725 (setq unmark (prefix-numeric-value unmark)))
9727 (gnus-summary-mark-same-subject
9728 (gnus-summary-article-subject) unmark)))
9729 ;; If marked as read, go to next unread subject.
9731 ;; Go to next unread subject.
9732 (gnus-summary-next-subject 1 t))
9733 (gnus-message 7 "%d articles are marked as %s"
9734 count (if unmark "unread" "read"))))
9736 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9737 "Mark articles with same SUBJECT as read, and return marked number.
9738 If optional argument UNMARK is positive, remove any kinds of marks.
9739 If optional argument UNMARK is negative, mark articles as unread instead."
9743 ((null unmark) ; Mark as read.
9746 (gnus-summary-mark-article-as-read gnus-killed-mark)
9747 (gnus-summary-show-thread) t)
9748 (gnus-summary-find-subject subject))
9749 (setq count (1+ count))))
9750 ((> unmark 0) ; Tick.
9753 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9754 (gnus-summary-show-thread) t)
9755 (gnus-summary-find-subject subject))
9756 (setq count (1+ count))))
9757 (t ; Mark as unread.
9760 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9761 (gnus-summary-show-thread) t)
9762 (gnus-summary-find-subject subject))
9763 (setq count (1+ count)))))
9764 (gnus-set-mode-line 'summary)
9765 ;; Return the number of marked articles.
9768 (defun gnus-summary-mark-as-processable (n &optional unmark)
9769 "Set the process mark on the next N articles.
9770 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9771 the process mark instead. The difference between N and the actual
9772 number of articles marked is returned."
9774 (if (and (null n) (gnus-region-active-p))
9775 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9776 (setq n (prefix-numeric-value n))
9777 (let ((backward (< n 0))
9782 (gnus-summary-remove-process-mark
9783 (gnus-summary-article-number))
9784 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9785 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9788 (gnus-message 7 "No more articles"))
9789 (gnus-summary-recenter)
9790 (gnus-summary-position-point)
9793 (defun gnus-summary-unmark-as-processable (n)
9794 "Remove the process mark from the next N articles.
9795 If N is negative, unmark backward instead. The difference between N and
9796 the actual number of articles unmarked is returned."
9798 (gnus-summary-mark-as-processable n t))
9800 (defun gnus-summary-unmark-all-processable ()
9801 "Remove the process mark from all articles."
9804 (while gnus-newsgroup-processable
9805 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9806 (gnus-summary-position-point))
9808 (defun gnus-summary-add-mark (article type)
9809 "Mark ARTICLE with a mark of TYPE."
9810 (let ((vtype (car (assq type gnus-article-mark-lists)))
9813 (error "No such mark type: %s" type)
9814 (setq var (intern (format "gnus-newsgroup-%s" type)))
9815 (set var (cons article (symbol-value var)))
9816 (if (memq type '(processable cached replied forwarded recent saved))
9817 (gnus-summary-update-secondary-mark article)
9818 ;;; !!! This is bogus. We should find out what primary
9819 ;;; !!! mark we want to set.
9820 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9822 (defun gnus-summary-mark-as-expirable (n)
9823 "Mark N articles forward as expirable.
9824 If N is negative, mark backward instead. The difference between N and
9825 the actual number of articles marked is returned."
9827 (gnus-summary-mark-forward n gnus-expirable-mark))
9829 (defun gnus-summary-mark-as-spam (n)
9830 "Mark N articles forward as spam.
9831 If N is negative, mark backward instead. The difference between N and
9832 the actual number of articles marked is returned."
9834 (gnus-summary-mark-forward n gnus-spam-mark))
9836 (defun gnus-summary-mark-article-as-replied (article)
9837 "Mark ARTICLE as replied to and update the summary line.
9838 ARTICLE can also be a list of articles."
9839 (interactive (list (gnus-summary-article-number)))
9840 (let ((articles (if (listp article) article (list article))))
9841 (dolist (article articles)
9842 (unless (numberp article)
9843 (error "%s is not a number" article))
9844 (push article gnus-newsgroup-replied)
9845 (let ((buffer-read-only nil))
9846 (when (gnus-summary-goto-subject article nil t)
9847 (gnus-summary-update-secondary-mark article))))))
9849 (defun gnus-summary-mark-article-as-forwarded (article)
9850 "Mark ARTICLE as forwarded and update the summary line.
9851 ARTICLE can also be a list of articles."
9852 (let ((articles (if (listp article) article (list article))))
9853 (dolist (article articles)
9854 (push article gnus-newsgroup-forwarded)
9855 (let ((buffer-read-only nil))
9856 (when (gnus-summary-goto-subject article nil t)
9857 (gnus-summary-update-secondary-mark article))))))
9859 (defun gnus-summary-set-bookmark (article)
9860 "Set a bookmark in current article."
9861 (interactive (list (gnus-summary-article-number)))
9862 (when (or (not (get-buffer gnus-article-buffer))
9863 (not gnus-current-article)
9864 (not gnus-article-current)
9865 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9866 (error "No current article selected"))
9867 ;; Remove old bookmark, if one exists.
9868 (gnus-pull article gnus-newsgroup-bookmarks)
9869 ;; Set the new bookmark, which is on the form
9870 ;; (article-number . line-number-in-body).
9873 (with-current-buffer gnus-article-buffer
9880 gnus-newsgroup-bookmarks)
9881 (gnus-message 6 "A bookmark has been added to the current article."))
9883 (defun gnus-summary-remove-bookmark (article)
9884 "Remove the bookmark from the current article."
9885 (interactive (list (gnus-summary-article-number)))
9886 ;; Remove old bookmark, if one exists.
9887 (if (not (assq article gnus-newsgroup-bookmarks))
9888 (gnus-message 6 "No bookmark in current article.")
9889 (gnus-pull article gnus-newsgroup-bookmarks)
9890 (gnus-message 6 "Removed bookmark.")))
9892 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9893 (defun gnus-summary-mark-as-dormant (n)
9894 "Mark N articles forward as dormant.
9895 If N is negative, mark backward instead. The difference between N and
9896 the actual number of articles marked is returned."
9898 (gnus-summary-mark-forward n gnus-dormant-mark))
9900 (defun gnus-summary-set-process-mark (article)
9901 "Set the process mark on ARTICLE and update the summary line."
9902 (setq gnus-newsgroup-processable
9904 (delq article gnus-newsgroup-processable)))
9905 (when (gnus-summary-goto-subject article)
9906 (gnus-summary-show-thread)
9907 (gnus-summary-goto-subject article)
9908 (gnus-summary-update-secondary-mark article)))
9910 (defun gnus-summary-remove-process-mark (article)
9911 "Remove the process mark from ARTICLE and update the summary line."
9912 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9913 (when (gnus-summary-goto-subject article)
9914 (gnus-summary-show-thread)
9915 (gnus-summary-goto-subject article)
9916 (gnus-summary-update-secondary-mark article)))
9918 (defun gnus-summary-set-saved-mark (article)
9919 "Set the process mark on ARTICLE and update the summary line."
9920 (push article gnus-newsgroup-saved)
9921 (when (gnus-summary-goto-subject article)
9922 (gnus-summary-update-secondary-mark article)))
9924 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9925 "Mark N articles as read forwards.
9926 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9927 The difference between N and the actual number of articles marked is
9929 If NO-EXPIRE, auto-expiry will be inhibited."
9931 (gnus-summary-show-thread)
9932 (let ((backward (< n 0))
9933 (gnus-summary-goto-unread
9934 (and gnus-summary-goto-unread
9935 (not (eq gnus-summary-goto-unread 'never))
9936 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9937 gnus-ticked-mark gnus-dormant-mark)))))
9939 (mark (or mark gnus-del-mark)))
9941 (gnus-summary-mark-article nil mark no-expire)
9942 (zerop (gnus-summary-next-subject
9944 (and gnus-summary-goto-unread
9945 (not (eq gnus-summary-goto-unread 'never)))
9949 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9950 (gnus-summary-recenter)
9951 (gnus-summary-position-point)
9952 (gnus-set-mode-line 'summary)
9955 (defun gnus-summary-mark-article-as-read (mark)
9956 "Mark the current article quickly as read with MARK."
9957 (let ((article (gnus-summary-article-number)))
9958 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9959 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9960 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9961 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9962 (push (cons article mark) gnus-newsgroup-reads)
9963 ;; Possibly remove from cache, if that is used.
9964 (when gnus-use-cache
9965 (gnus-cache-enter-remove-article article))
9966 ;; Allow the backend to change the mark.
9967 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9968 ;; Check for auto-expiry.
9969 (when (and gnus-newsgroup-auto-expire
9970 (memq mark gnus-auto-expirable-marks))
9971 (setq mark gnus-expirable-mark)
9972 ;; Let the backend know about the mark change.
9973 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9974 (push article gnus-newsgroup-expirable))
9975 ;; Set the mark in the buffer.
9976 (gnus-summary-update-mark mark 'unread)
9979 (defun gnus-summary-mark-article-as-unread (mark)
9980 "Mark the current article quickly as unread with MARK."
9981 (let* ((article (gnus-summary-article-number))
9982 (old-mark (gnus-summary-article-mark article)))
9983 ;; Allow the backend to change the mark.
9984 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9985 (if (eq mark old-mark)
9989 (gnus-error 1 "Can't mark negative article numbers")
9991 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9992 (setq gnus-newsgroup-spam-marked
9993 (delq article gnus-newsgroup-spam-marked))
9994 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9995 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9996 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9997 (cond ((= mark gnus-ticked-mark)
9998 (setq gnus-newsgroup-marked
9999 (gnus-add-to-sorted-list gnus-newsgroup-marked
10001 ((= mark gnus-spam-mark)
10002 (setq gnus-newsgroup-spam-marked
10003 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10005 ((= mark gnus-dormant-mark)
10006 (setq gnus-newsgroup-dormant
10007 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10010 (setq gnus-newsgroup-unreads
10011 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10013 (gnus-pull article gnus-newsgroup-reads)
10015 ;; See whether the article is to be put in the cache.
10016 (and gnus-use-cache
10017 (vectorp (gnus-summary-article-header article))
10019 (gnus-cache-possibly-enter-article
10020 gnus-newsgroup-name article
10021 (gnus-summary-article-header article)
10022 (= mark gnus-ticked-mark)
10023 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10026 (gnus-summary-update-mark mark 'unread)
10029 (defun gnus-summary-mark-article (&optional article mark no-expire)
10030 "Mark ARTICLE with MARK. MARK can be any character.
10031 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10032 `??' (dormant) and `?E' (expirable).
10033 If MARK is nil, then the default character `?r' is used.
10034 If ARTICLE is nil, then the article on the current line will be
10036 If NO-EXPIRE, auto-expiry will be inhibited."
10037 ;; The mark might be a string.
10038 (when (stringp mark)
10039 (setq mark (aref mark 0)))
10040 ;; If no mark is given, then we check auto-expiring.
10042 (setq mark gnus-del-mark))
10043 (when (and (not no-expire)
10044 gnus-newsgroup-auto-expire
10045 (memq mark gnus-auto-expirable-marks))
10046 (setq mark gnus-expirable-mark))
10047 (let ((article (or article (gnus-summary-article-number)))
10048 (old-mark (gnus-summary-article-mark article)))
10049 ;; Allow the backend to change the mark.
10050 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10051 (if (eq mark old-mark)
10054 (error "No article on current line"))
10055 (if (not (if (or (= mark gnus-unread-mark)
10056 (= mark gnus-ticked-mark)
10057 (= mark gnus-spam-mark)
10058 (= mark gnus-dormant-mark))
10059 (gnus-mark-article-as-unread article mark)
10060 (gnus-mark-article-as-read article mark)))
10062 ;; See whether the article is to be put in the cache.
10063 (and gnus-use-cache
10064 (not (= mark gnus-canceled-mark))
10065 (vectorp (gnus-summary-article-header article))
10067 (gnus-cache-possibly-enter-article
10068 gnus-newsgroup-name article
10069 (gnus-summary-article-header article)
10070 (= mark gnus-ticked-mark)
10071 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10073 (when (gnus-summary-goto-subject article nil t)
10074 (let ((buffer-read-only nil))
10075 (gnus-summary-show-thread)
10077 (gnus-summary-update-mark mark 'unread)
10080 (defun gnus-summary-update-secondary-mark (article)
10081 "Update the secondary (read, process, cache) mark."
10082 (gnus-summary-update-mark
10083 (cond ((memq article gnus-newsgroup-processable)
10085 ((memq article gnus-newsgroup-cached)
10087 ((memq article gnus-newsgroup-replied)
10089 ((memq article gnus-newsgroup-forwarded)
10090 gnus-forwarded-mark)
10091 ((memq article gnus-newsgroup-saved)
10093 ((memq article gnus-newsgroup-recent)
10095 ((memq article gnus-newsgroup-unseen)
10099 (when (gnus-visual-p 'summary-highlight 'highlight)
10100 (gnus-run-hooks 'gnus-summary-update-hook))
10103 (defun gnus-summary-update-download-mark (article)
10104 "Update the download mark."
10105 (gnus-summary-update-mark
10106 (cond ((memq article gnus-newsgroup-undownloaded)
10107 gnus-undownloaded-mark)
10108 (gnus-newsgroup-agentized
10109 gnus-downloaded-mark)
10113 (gnus-summary-update-line t)
10116 (defun gnus-summary-update-mark (mark type)
10117 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10118 (buffer-read-only nil))
10119 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10121 (when (looking-at "\r")
10123 (when (<= (+ forward (point)) (point-max))
10124 ;; Go to the right position on the line.
10125 (goto-char (+ forward (point)))
10126 ;; Replace the old mark with the new mark.
10127 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10128 ;; Optionally update the marks by some user rule.
10129 (when (eq type 'unread)
10130 (gnus-data-set-mark
10131 (gnus-data-find (gnus-summary-article-number)) mark)
10132 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10134 (defun gnus-mark-article-as-read (article &optional mark)
10135 "Enter ARTICLE in the pertinent lists and remove it from others."
10136 ;; Make the article expirable.
10137 (let ((mark (or mark gnus-del-mark)))
10138 (setq gnus-newsgroup-expirable
10139 (if (= mark gnus-expirable-mark)
10140 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10141 (delq article gnus-newsgroup-expirable)))
10142 ;; Remove from unread and marked lists.
10143 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10144 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10145 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10146 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10147 (push (cons article mark) gnus-newsgroup-reads)
10148 ;; Possibly remove from cache, if that is used.
10149 (when gnus-use-cache
10150 (gnus-cache-enter-remove-article article))
10153 (defun gnus-mark-article-as-unread (article &optional mark)
10154 "Enter ARTICLE in the pertinent lists and remove it from others."
10155 (let ((mark (or mark gnus-ticked-mark)))
10158 (gnus-error 1 "Can't mark negative article numbers")
10160 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10161 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10162 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10163 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10164 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10166 ;; Unsuppress duplicates?
10167 (when gnus-suppress-duplicates
10168 (gnus-dup-unsuppress-article article))
10170 (cond ((= mark gnus-ticked-mark)
10171 (setq gnus-newsgroup-marked
10172 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10173 ((= mark gnus-spam-mark)
10174 (setq gnus-newsgroup-spam-marked
10175 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10177 ((= mark gnus-dormant-mark)
10178 (setq gnus-newsgroup-dormant
10179 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10181 (setq gnus-newsgroup-unreads
10182 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10183 (gnus-pull article gnus-newsgroup-reads)
10186 (defalias 'gnus-summary-mark-as-unread-forward
10187 'gnus-summary-tick-article-forward)
10188 (make-obsolete 'gnus-summary-mark-as-unread-forward
10189 'gnus-summary-tick-article-forward)
10190 (defun gnus-summary-tick-article-forward (n)
10191 "Tick N articles forwards.
10192 If N is negative, tick backwards instead.
10193 The difference between N and the number of articles ticked is returned."
10195 (gnus-summary-mark-forward n gnus-ticked-mark))
10197 (defalias 'gnus-summary-mark-as-unread-backward
10198 'gnus-summary-tick-article-backward)
10199 (make-obsolete 'gnus-summary-mark-as-unread-backward
10200 'gnus-summary-tick-article-backward)
10201 (defun gnus-summary-tick-article-backward (n)
10202 "Tick N articles backwards.
10203 The difference between N and the number of articles ticked is returned."
10205 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10207 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10208 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10209 (defun gnus-summary-tick-article (&optional article clear-mark)
10210 "Mark current article as unread.
10211 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10212 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10214 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10215 gnus-ticked-mark)))
10217 (defun gnus-summary-mark-as-read-forward (n)
10218 "Mark N articles as read forwards.
10219 If N is negative, mark backwards instead.
10220 The difference between N and the actual number of articles marked is
10223 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10225 (defun gnus-summary-mark-as-read-backward (n)
10226 "Mark the N articles as read backwards.
10227 The difference between N and the actual number of articles marked is
10230 (gnus-summary-mark-forward
10231 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10233 (defun gnus-summary-mark-as-read (&optional article mark)
10234 "Mark current article as read.
10235 ARTICLE specifies the article to be marked as read.
10236 MARK specifies a string to be inserted at the beginning of the line."
10237 (gnus-summary-mark-article article mark))
10239 (defun gnus-summary-clear-mark-forward (n)
10240 "Clear marks from N articles forward.
10241 If N is negative, clear backward instead.
10242 The difference between N and the number of marks cleared is returned."
10244 (gnus-summary-mark-forward n gnus-unread-mark))
10246 (defun gnus-summary-clear-mark-backward (n)
10247 "Clear marks from N articles backward.
10248 The difference between N and the number of marks cleared is returned."
10250 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10252 (defun gnus-summary-mark-unread-as-read ()
10253 "Intended to be used by `gnus-summary-mark-article-hook'."
10254 (when (memq gnus-current-article gnus-newsgroup-unreads)
10255 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10257 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10258 "Intended to be used by `gnus-summary-mark-article-hook'."
10259 (let ((mark (gnus-summary-article-mark)))
10260 (when (or (gnus-unread-mark-p mark)
10261 (gnus-read-mark-p mark))
10262 (gnus-summary-mark-article gnus-current-article
10263 (or new-mark gnus-read-mark)))))
10265 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10266 "Intended to be used by `gnus-summary-mark-article-hook'."
10267 (let ((mark (gnus-summary-article-mark)))
10268 (when (or (gnus-unread-mark-p mark)
10269 (gnus-read-mark-p mark))
10270 (gnus-summary-mark-article (gnus-summary-article-number)
10271 (or new-mark gnus-read-mark)))))
10273 (defun gnus-summary-mark-unread-as-ticked ()
10274 "Intended to be used by `gnus-summary-mark-article-hook'."
10275 (when (memq gnus-current-article gnus-newsgroup-unreads)
10276 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10278 (defun gnus-summary-mark-region-as-read (point mark all)
10279 "Mark all unread articles between point and mark as read.
10280 If given a prefix, mark all articles between point and mark as read,
10281 even ticked and dormant ones."
10282 (interactive "r\nP")
10286 (beginning-of-line)
10291 (memq (setq article (gnus-summary-article-number))
10292 gnus-newsgroup-unreads))
10293 (gnus-summary-mark-article article gnus-del-mark))
10295 (gnus-summary-find-next))))))
10297 (defun gnus-summary-mark-below (score mark)
10298 "Mark articles with score less than SCORE with MARK."
10299 (interactive "P\ncMark: ")
10300 (setq score (if score
10301 (prefix-numeric-value score)
10302 (or gnus-summary-default-score 0)))
10304 (set-buffer gnus-summary-buffer)
10305 (goto-char (point-min))
10308 (and (< (gnus-summary-article-score) score)
10309 (gnus-summary-mark-article nil mark))
10310 (gnus-summary-find-next)))))
10312 (defun gnus-summary-kill-below (&optional score)
10313 "Mark articles with score below SCORE as read."
10315 (gnus-summary-mark-below score gnus-killed-mark))
10317 (defun gnus-summary-clear-above (&optional score)
10318 "Clear all marks from articles with score above SCORE."
10320 (gnus-summary-mark-above score gnus-unread-mark))
10322 (defun gnus-summary-tick-above (&optional score)
10323 "Tick all articles with score above SCORE."
10325 (gnus-summary-mark-above score gnus-ticked-mark))
10327 (defun gnus-summary-mark-above (score mark)
10328 "Mark articles with score over SCORE with MARK."
10329 (interactive "P\ncMark: ")
10330 (setq score (if score
10331 (prefix-numeric-value score)
10332 (or gnus-summary-default-score 0)))
10334 (set-buffer gnus-summary-buffer)
10335 (goto-char (point-min))
10337 (when (> (gnus-summary-article-score) score)
10338 (gnus-summary-mark-article nil mark))
10340 (gnus-summary-find-next)))))
10342 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10343 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10344 (defun gnus-summary-limit-include-expunged (&optional no-error)
10345 "Display all the hidden articles that were expunged for low scores."
10347 (let ((buffer-read-only nil))
10348 (let ((scored gnus-newsgroup-scored)
10351 (unless (gnus-summary-article-header (caar scored))
10352 (and (setq h (gnus-number-to-header (caar scored)))
10353 (< (cdar scored) gnus-summary-expunge-below)
10355 (setq scored (cdr scored)))
10357 (when (not no-error)
10358 (error "No expunged articles hidden"))
10359 (goto-char (point-min))
10360 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10361 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10362 (mapcar (lambda (x) (push (mail-header-number x)
10363 gnus-newsgroup-limit))
10365 (gnus-summary-prepare-unthreaded (nreverse headers))
10366 (goto-char (point-min))
10367 (gnus-summary-position-point)
10370 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10371 "Mark all unread articles in this newsgroup as read.
10372 If prefix argument ALL is non-nil, ticked and dormant articles will
10373 also be marked as read.
10374 If QUIETLY is non-nil, no questions will be asked.
10376 If TO-HERE is non-nil, it should be a point in the buffer. All
10377 articles before (after, if REVERSE is set) this point will be marked
10380 Note that this function will only catch up the unread article
10381 in the current summary buffer limitation.
10383 The number of articles marked as read is returned."
10388 (not gnus-interactive-catchup) ;Without confirmation?
10392 "Mark absolutely all articles as read? "
10393 "Mark all unread articles as read? ")))
10395 (not gnus-newsgroup-adaptive)
10396 (not gnus-newsgroup-auto-expire)
10397 (not gnus-suppress-duplicates)
10398 (or (not gnus-use-cache)
10399 (eq gnus-use-cache 'passive)))
10402 (setq gnus-newsgroup-marked nil
10403 gnus-newsgroup-spam-marked nil
10404 gnus-newsgroup-dormant nil))
10405 (setq gnus-newsgroup-unreads
10406 (gnus-sorted-nunion
10407 (gnus-intersection gnus-newsgroup-unreads
10408 gnus-newsgroup-downloadable)
10409 gnus-newsgroup-unfetched)))
10410 ;; We actually mark all articles as canceled, which we
10411 ;; have to do when using auto-expiry or adaptive scoring.
10412 (gnus-summary-show-all-threads)
10413 (if (and to-here reverse)
10415 (goto-char to-here)
10416 (gnus-summary-mark-current-read-and-unread-as-read
10418 (while (gnus-summary-find-next (not all))
10419 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10420 (when (gnus-summary-first-subject (not all))
10422 (if to-here (< (point) to-here) t)
10423 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10424 (gnus-summary-find-next (not all))))))
10425 (gnus-set-mode-line 'summary))
10427 (gnus-summary-position-point)))
10429 (defun gnus-summary-catchup-to-here (&optional all)
10430 "Mark all unticked articles before the current one as read.
10431 If ALL is non-nil, also mark ticked and dormant articles as read."
10434 (gnus-save-hidden-threads
10435 (let ((beg (point)))
10436 ;; We check that there are unread articles.
10437 (when (or all (gnus-summary-find-prev))
10438 (gnus-summary-catchup all t beg)))))
10439 (gnus-summary-position-point))
10441 (defun gnus-summary-catchup-from-here (&optional all)
10442 "Mark all unticked articles after (and including) the current one as read.
10443 If ALL is non-nil, also mark ticked and dormant articles as read."
10446 (gnus-save-hidden-threads
10447 (let ((beg (point)))
10448 ;; We check that there are unread articles.
10449 (when (or all (gnus-summary-find-next))
10450 (gnus-summary-catchup all t beg nil t)))))
10451 (gnus-summary-position-point))
10453 (defun gnus-summary-catchup-all (&optional quietly)
10454 "Mark all articles in this newsgroup as read.
10455 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10456 instead, which marks only unread articles as read."
10458 (gnus-summary-catchup t quietly))
10460 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10461 "Mark all unread articles in this group as read, then exit.
10462 If prefix argument ALL is non-nil, all articles are marked as read.
10463 If QUIETLY is non-nil, no questions will be asked."
10465 (when (gnus-summary-catchup all quietly nil 'fast)
10466 ;; Select next newsgroup or exit.
10467 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10468 (eq gnus-auto-select-next 'quietly))
10469 (gnus-summary-next-group nil)
10470 (gnus-summary-exit))))
10472 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10473 "Mark all articles in this newsgroup as read, and then exit.
10474 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10475 instead, which marks only unread articles as read."
10477 (gnus-summary-catchup-and-exit t quietly))
10479 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10480 "Mark all articles in this group as read and select the next group.
10481 If given a prefix, mark all articles, unread as well as ticked, as
10485 (gnus-summary-catchup all))
10486 (gnus-summary-next-group))
10492 (defmacro gnus-with-article (article &rest forms)
10493 "Select ARTICLE and perform FORMS in the original article buffer.
10494 Then replace the article with the result."
10496 ;; We don't want the article to be marked as read.
10497 (let (gnus-mark-article-hook)
10498 (gnus-summary-select-article t t nil ,article))
10499 (set-buffer gnus-original-article-buffer)
10501 (if (not (gnus-check-backend-function
10502 'request-replace-article (car gnus-article-current)))
10503 (gnus-message 5 "Read-only group; not replacing")
10504 (unless (gnus-request-replace-article
10505 ,article (car gnus-article-current)
10506 (current-buffer) t)
10507 (error "Couldn't replace article")))
10508 ;; The cache and backlog have to be flushed somewhat.
10509 (when gnus-keep-backlog
10510 (gnus-backlog-remove-article
10511 (car gnus-article-current) (cdr gnus-article-current)))
10512 (when gnus-use-cache
10513 (gnus-cache-update-article
10514 (car gnus-article-current) (cdr gnus-article-current)))))
10516 (put 'gnus-with-article 'lisp-indent-function 1)
10517 (put 'gnus-with-article 'edebug-form-spec '(form body))
10519 ;; Thread-based commands.
10521 (defun gnus-summary-articles-in-thread (&optional article)
10522 "Return a list of all articles in the current thread.
10523 If ARTICLE is non-nil, return all articles in the thread that starts
10524 with that article."
10525 (let* ((article (or article (gnus-summary-article-number)))
10526 (data (gnus-data-find-list article))
10527 (top-level (gnus-data-level (car data)))
10529 (cond ((null gnus-thread-operation-ignore-subject)
10530 (gnus-simplify-subject-re
10531 (mail-header-subject (gnus-data-header (car data)))))
10532 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10533 (gnus-simplify-subject-fuzzy
10534 (mail-header-subject (gnus-data-header (car data)))))
10536 (end-point (save-excursion
10537 (if (gnus-summary-go-to-next-thread)
10538 (point) (point-max))))
10541 (< (gnus-data-pos (car data)) end-point))
10542 (when (or (not top-subject)
10543 (string= top-subject
10544 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10545 (gnus-simplify-subject-fuzzy
10546 (mail-header-subject
10547 (gnus-data-header (car data))))
10548 (gnus-simplify-subject-re
10549 (mail-header-subject
10550 (gnus-data-header (car data)))))))
10551 (push (gnus-data-number (car data)) articles))
10552 (unless (and (setq data (cdr data))
10553 (> (gnus-data-level (car data)) top-level))
10555 ;; Return the list of articles.
10556 (nreverse articles)))
10558 (defun gnus-summary-rethread-current ()
10559 "Rethread the thread the current article is part of."
10561 (let* ((gnus-show-threads t)
10562 (article (gnus-summary-article-number))
10563 (id (mail-header-id (gnus-summary-article-header)))
10564 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10566 (error "No article on the current line"))
10567 (gnus-rebuild-thread id)
10568 (gnus-summary-goto-subject article)))
10570 (defun gnus-summary-reparent-thread ()
10571 "Make the current article child of the marked (or previous) article.
10573 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10574 is non-nil or the Subject: of both articles are the same."
10576 (unless (not (gnus-group-read-only-p))
10577 (error "The current newsgroup does not support article editing"))
10578 (unless (<= (length gnus-newsgroup-processable) 1)
10579 (error "No more than one article may be marked"))
10580 (save-window-excursion
10581 (let ((gnus-article-buffer " *reparent*")
10582 (current-article (gnus-summary-article-number))
10583 ;; First grab the marked article, otherwise one line up.
10584 (parent-article (if (not (null gnus-newsgroup-processable))
10585 (car gnus-newsgroup-processable)
10587 (if (eq (forward-line -1) 0)
10588 (gnus-summary-article-number)
10589 (error "Beginning of summary buffer"))))))
10590 (unless (not (eq current-article parent-article))
10591 (error "An article may not be self-referential"))
10592 (let ((message-id (mail-header-id
10593 (gnus-summary-article-header parent-article))))
10594 (unless (and message-id (not (equal message-id "")))
10595 (error "No message-id in desired parent"))
10596 (gnus-with-article current-article
10598 (goto-char (point-min))
10599 (message-narrow-to-head)
10600 (if (re-search-forward "^References: " nil t)
10602 (re-search-forward "^[^ \t]" nil t)
10605 (insert " " message-id))
10606 (insert "References: " message-id "\n"))))
10607 (set-buffer gnus-summary-buffer)
10608 (gnus-summary-unmark-all-processable)
10609 (gnus-summary-update-article current-article)
10610 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10611 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10612 (gnus-summary-rethread-current)
10613 (gnus-message 3 "Article %d is now the child of article %d"
10614 current-article parent-article)))))
10616 (defun gnus-summary-toggle-threads (&optional arg)
10617 "Toggle showing conversation threads.
10618 If ARG is positive number, turn showing conversation threads on."
10620 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10621 (setq gnus-show-threads
10622 (if (null arg) (not gnus-show-threads)
10623 (> (prefix-numeric-value arg) 0)))
10624 (gnus-summary-prepare)
10625 (gnus-summary-goto-subject current)
10626 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10627 (gnus-summary-position-point)))
10629 (defun gnus-summary-show-all-threads ()
10630 "Show all threads."
10633 (let ((buffer-read-only nil))
10634 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10635 (gnus-summary-position-point))
10637 (defun gnus-summary-show-thread ()
10638 "Show thread subtrees.
10639 Returns nil if no thread was there to be shown."
10641 (let ((buffer-read-only nil)
10643 (end (point-at-eol))
10644 ;; Leave point at bol
10645 (beg (progn (beginning-of-line) (point))))
10647 ;; Any hidden lines here?
10648 (search-forward "\r" end t)
10649 (subst-char-in-region beg end ?\^M ?\n t)
10651 (gnus-summary-position-point))))
10653 (defun gnus-summary-maybe-hide-threads ()
10654 "If requested, hide the threads that should be hidden."
10655 (when (and gnus-show-threads
10656 gnus-thread-hide-subtree)
10657 (gnus-summary-hide-all-threads
10658 (if (or (consp gnus-thread-hide-subtree)
10659 (functionp gnus-thread-hide-subtree))
10660 (gnus-make-predicate gnus-thread-hide-subtree)
10663 ;;; Hiding predicates.
10665 (defun gnus-article-unread-p (header)
10666 (memq (mail-header-number header) gnus-newsgroup-unreads))
10668 (defun gnus-article-unseen-p (header)
10669 (memq (mail-header-number header) gnus-newsgroup-unseen))
10671 (defun gnus-map-articles (predicate articles)
10672 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10673 (apply 'gnus-or (mapcar predicate
10674 (mapcar 'gnus-summary-article-header articles))))
10676 (defun gnus-summary-hide-all-threads (&optional predicate)
10677 "Hide all thread subtrees.
10678 If PREDICATE is supplied, threads that satisfy this predicate
10679 will not be hidden."
10682 (goto-char (point-min))
10685 (when (or (not predicate)
10687 predicate (gnus-summary-article-children)))
10688 (gnus-summary-hide-thread))
10689 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10690 (gnus-summary-position-point))
10692 (defun gnus-summary-hide-thread ()
10693 "Hide thread subtrees.
10694 If PREDICATE is supplied, threads that satisfy this predicate
10695 will not be hidden.
10696 Returns nil if no threads were there to be hidden."
10698 (let ((buffer-read-only nil)
10700 (article (gnus-summary-article-number)))
10702 ;; Go forward until either the buffer ends or the subthread
10704 (when (and (not (eobp))
10705 (or (zerop (gnus-summary-next-thread 1 t))
10706 (goto-char (point-max))))
10708 (if (and (> (point) start)
10709 (search-backward "\n" start t))
10711 (subst-char-in-region start (point) ?\n ?\^M)
10712 (gnus-summary-goto-subject article))
10716 (defun gnus-summary-go-to-next-thread (&optional previous)
10717 "Go to the same level (or less) next thread.
10718 If PREVIOUS is non-nil, go to previous thread instead.
10719 Return the article number moved to, or nil if moving was impossible."
10720 (let ((level (gnus-summary-thread-level))
10721 (way (if previous -1 1))
10724 (while (and (not (eobp))
10725 (< level (gnus-summary-thread-level)))
10726 (forward-line way))
10733 (gnus-summary-article-number)
10734 (goto-char beg)))))
10736 (defun gnus-summary-next-thread (n &optional silent)
10737 "Go to the same level next N'th thread.
10738 If N is negative, search backward instead.
10739 Returns the difference between N and the number of skips actually
10742 If SILENT, don't output messages."
10744 (let ((backward (< n 0))
10746 (while (and (> n 0)
10747 (gnus-summary-go-to-next-thread backward))
10750 (gnus-summary-position-point))
10751 (when (and (not silent) (/= 0 n))
10752 (gnus-message 7 "No more threads"))
10755 (defun gnus-summary-prev-thread (n)
10756 "Go to the same level previous N'th thread.
10757 Returns the difference between N and the number of skips actually
10760 (gnus-summary-next-thread (- n)))
10762 (defun gnus-summary-go-down-thread ()
10763 "Go down one level in the current thread."
10764 (let ((children (gnus-summary-article-children)))
10766 (gnus-summary-goto-subject (car children)))))
10768 (defun gnus-summary-go-up-thread ()
10769 "Go up one level in the current thread."
10770 (let ((parent (gnus-summary-article-parent)))
10772 (gnus-summary-goto-subject parent))))
10774 (defun gnus-summary-down-thread (n)
10775 "Go down thread N steps.
10776 If N is negative, go up instead.
10777 Returns the difference between N and how many steps down that were
10782 (while (and (> n 0)
10783 (if up (gnus-summary-go-up-thread)
10784 (gnus-summary-go-down-thread)))
10786 (gnus-summary-position-point)
10788 (gnus-message 7 "Can't go further"))
10791 (defun gnus-summary-up-thread (n)
10792 "Go up thread N steps.
10793 If N is negative, go down instead.
10794 Returns the difference between N and how many steps down that were
10797 (gnus-summary-down-thread (- n)))
10799 (defun gnus-summary-top-thread ()
10800 "Go to the top of the thread."
10802 (while (gnus-summary-go-up-thread))
10803 (gnus-summary-article-number))
10805 (defun gnus-summary-kill-thread (&optional unmark)
10806 "Mark articles under current thread as read.
10807 If the prefix argument is positive, remove any kinds of marks.
10808 If the prefix argument is negative, tick articles instead."
10811 (setq unmark (prefix-numeric-value unmark)))
10812 (let ((articles (gnus-summary-articles-in-thread)))
10814 ;; Expand the thread.
10815 (gnus-summary-show-thread)
10816 ;; Mark all the articles.
10818 (gnus-summary-goto-subject (car articles))
10819 (cond ((null unmark)
10820 (gnus-summary-mark-article-as-read gnus-killed-mark))
10822 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10824 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10825 (setq articles (cdr articles))))
10826 ;; Hide killed subtrees.
10828 gnus-thread-hide-killed
10829 (gnus-summary-hide-thread))
10830 ;; If marked as read, go to next unread subject.
10831 (when (null unmark)
10832 ;; Go to next unread subject.
10833 (gnus-summary-next-subject 1 t)))
10834 (gnus-set-mode-line 'summary))
10836 ;; Summary sorting commands
10838 (defun gnus-summary-sort-by-number (&optional reverse)
10839 "Sort the summary buffer by article number.
10840 Argument REVERSE means reverse order."
10842 (gnus-summary-sort 'number reverse))
10844 (defun gnus-summary-sort-by-random (&optional reverse)
10845 "Randomize the order in the summary buffer.
10846 Argument REVERSE means to randomize in reverse order."
10848 (gnus-summary-sort 'random reverse))
10850 (defun gnus-summary-sort-by-author (&optional reverse)
10851 "Sort the summary buffer by author name alphabetically.
10852 If `case-fold-search' is non-nil, case of letters is ignored.
10853 Argument REVERSE means reverse order."
10855 (gnus-summary-sort 'author reverse))
10857 (defun gnus-summary-sort-by-subject (&optional reverse)
10858 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10859 If `case-fold-search' is non-nil, case of letters is ignored.
10860 Argument REVERSE means reverse order."
10862 (gnus-summary-sort 'subject reverse))
10864 (defun gnus-summary-sort-by-date (&optional reverse)
10865 "Sort the summary buffer by date.
10866 Argument REVERSE means reverse order."
10868 (gnus-summary-sort 'date reverse))
10870 (defun gnus-summary-sort-by-score (&optional reverse)
10871 "Sort the summary buffer by score.
10872 Argument REVERSE means reverse order."
10874 (gnus-summary-sort 'score reverse))
10876 (defun gnus-summary-sort-by-lines (&optional reverse)
10877 "Sort the summary buffer by the number of lines.
10878 Argument REVERSE means reverse order."
10880 (gnus-summary-sort 'lines reverse))
10882 (defun gnus-summary-sort-by-chars (&optional reverse)
10883 "Sort the summary buffer by article length.
10884 Argument REVERSE means reverse order."
10886 (gnus-summary-sort 'chars reverse))
10888 (defun gnus-summary-sort-by-original (&optional reverse)
10889 "Sort the summary buffer using the default sorting method.
10890 Argument REVERSE means reverse order."
10892 (let* ((buffer-read-only)
10893 (gnus-summary-prepare-hook nil))
10894 ;; We do the sorting by regenerating the threads.
10895 (gnus-summary-prepare)
10896 ;; Hide subthreads if needed.
10897 (gnus-summary-maybe-hide-threads)))
10899 (defun gnus-summary-sort (predicate reverse)
10900 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10901 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10902 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10903 (gnus-thread-sort-functions
10908 (gnus-sort-gathered-threads-function
10909 gnus-thread-sort-functions)
10910 (gnus-article-sort-functions
10914 (,article t2 t1))))
10916 (gnus-summary-prepare-hook nil))
10917 ;; We do the sorting by regenerating the threads.
10918 (gnus-summary-prepare)
10919 ;; Hide subthreads if needed.
10920 (gnus-summary-maybe-hide-threads)))
10922 ;; Summary saving commands.
10924 (defun gnus-summary-save-article (&optional n not-saved)
10925 "Save the current article using the default saver function.
10926 If N is a positive number, save the N next articles.
10927 If N is a negative number, save the N previous articles.
10928 If N is nil and any articles have been marked with the process mark,
10929 save those articles instead.
10930 The variable `gnus-default-article-saver' specifies the saver function."
10932 (let* ((articles (gnus-summary-work-articles n))
10933 (save-buffer (save-excursion
10934 (nnheader-set-temp-buffer " *Gnus Save*")))
10935 (num (length articles))
10937 (dolist (article articles)
10938 (setq header (gnus-summary-article-header article))
10939 (if (not (vectorp header))
10940 ;; This is a pseudo-article.
10941 (if (assq 'name header)
10942 (gnus-copy-file (cdr (assq 'name header)))
10943 (gnus-message 1 "Article %d is unsaveable" article))
10944 ;; This is a real article.
10945 (save-window-excursion
10946 (let ((gnus-display-mime-function nil)
10947 (gnus-article-prepare-hook nil))
10948 (gnus-summary-select-article t nil nil article)))
10950 (set-buffer save-buffer)
10952 (insert-buffer-substring gnus-original-article-buffer))
10953 (setq file (gnus-article-save save-buffer file num))
10954 (gnus-summary-remove-process-mark article)
10956 (gnus-summary-set-saved-mark article))))
10957 (gnus-kill-buffer save-buffer)
10958 (gnus-summary-position-point)
10959 (gnus-set-mode-line 'summary)
10962 (defun gnus-summary-pipe-output (&optional arg headers)
10963 "Pipe the current article to a subprocess.
10964 If N is a positive number, pipe the N next articles.
10965 If N is a negative number, pipe the N previous articles.
10966 If N is nil and any articles have been marked with the process mark,
10967 pipe those articles instead.
10968 If HEADERS (the symbolic prefix), include the headers, too."
10969 (interactive (gnus-interactive "P\ny"))
10970 (require 'gnus-art)
10971 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10972 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10973 (gnus-summary-save-article arg t))
10974 (let ((buffer (get-buffer "*Shell Command Output*")))
10976 (not (zerop (buffer-size buffer))))
10977 (gnus-configure-windows 'pipe))))
10979 (defun gnus-summary-save-article-mail (&optional arg)
10980 "Append the current article to an mail file.
10981 If N is a positive number, save the N next articles.
10982 If N is a negative number, save the N previous articles.
10983 If N is nil and any articles have been marked with the process mark,
10984 save those articles instead."
10986 (require 'gnus-art)
10987 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10988 (gnus-summary-save-article arg)))
10990 (defun gnus-summary-save-article-rmail (&optional arg)
10991 "Append the current article to an rmail file.
10992 If N is a positive number, save the N next articles.
10993 If N is a negative number, save the N previous articles.
10994 If N is nil and any articles have been marked with the process mark,
10995 save those articles instead."
10997 (require 'gnus-art)
10998 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10999 (gnus-summary-save-article arg)))
11001 (defun gnus-summary-save-article-file (&optional arg)
11002 "Append the current article to a file.
11003 If N is a positive number, save the N next articles.
11004 If N is a negative number, save the N previous articles.
11005 If N is nil and any articles have been marked with the process mark,
11006 save those articles instead."
11008 (require 'gnus-art)
11009 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11010 (gnus-summary-save-article arg)))
11012 (defun gnus-summary-write-article-file (&optional arg)
11013 "Write the current article to a file, deleting the previous file.
11014 If N is a positive number, save the N next articles.
11015 If N is a negative number, save the N previous articles.
11016 If N is nil and any articles have been marked with the process mark,
11017 save those articles instead."
11019 (require 'gnus-art)
11020 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11021 (gnus-summary-save-article arg)))
11023 (defun gnus-summary-save-article-body-file (&optional arg)
11024 "Append the current article body to a file.
11025 If N is a positive number, save the N next articles.
11026 If N is a negative number, save the N previous articles.
11027 If N is nil and any articles have been marked with the process mark,
11028 save those articles instead."
11030 (require 'gnus-art)
11031 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11032 (gnus-summary-save-article arg)))
11034 (defun gnus-summary-muttprint (&optional arg)
11035 "Print the current article using Muttprint.
11036 If N is a positive number, save the N next articles.
11037 If N is a negative number, save the N previous articles.
11038 If N is nil and any articles have been marked with the process mark,
11039 save those articles instead."
11041 (require 'gnus-art)
11042 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11043 (gnus-summary-save-article arg t)))
11045 (defun gnus-summary-pipe-message (program)
11046 "Pipe the current article through PROGRAM."
11047 (interactive "sProgram: ")
11048 (gnus-summary-select-article)
11049 (let ((mail-header-separator ""))
11050 (gnus-eval-in-buffer-window gnus-article-buffer
11053 (let ((start (window-start))
11055 (message-pipe-buffer-body program)
11056 (set-window-start (get-buffer-window (current-buffer)) start))))))
11058 (defun gnus-get-split-value (methods)
11059 "Return a value based on the split METHODS."
11060 (let (split-name method result match)
11063 (set-buffer gnus-original-article-buffer)
11065 (nnheader-narrow-to-headers)
11066 (while (and methods (not split-name))
11067 (goto-char (point-min))
11068 (setq method (pop methods))
11069 (setq match (car method))
11072 ;; Regular expression.
11074 (re-search-forward match nil t)))
11079 (setq result (funcall match gnus-newsgroup-name))))
11084 (setq result (eval match)))))
11085 (setq split-name (cdr method))
11086 (cond ((stringp result)
11087 (push (expand-file-name
11088 result gnus-article-save-directory)
11091 (setq split-name (append result split-name)))))))))
11092 (nreverse split-name)))
11094 (defun gnus-valid-move-group-p (group)
11095 (and (boundp group)
11096 (symbol-name group)
11097 (symbol-value group)
11098 (gnus-get-function (gnus-find-method-for-group
11099 (symbol-name group)) 'request-accept-article t)))
11101 (defun gnus-read-move-group-name (prompt default articles prefix)
11102 "Read a group name."
11103 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11104 (minibuffer-confirm-incomplete nil) ; XEmacs
11106 (format "%s %s to:"
11108 (if (> (length articles) 1)
11109 (format "these %d articles" (length articles))
11114 (gnus-completing-read-with-default
11117 'gnus-valid-move-group-p
11119 'gnus-group-history))
11120 ((= 1 (length split-name))
11121 (gnus-completing-read-with-default
11122 (car split-name) prom
11124 'gnus-valid-move-group-p
11126 'gnus-group-history))
11128 (gnus-completing-read-with-default
11130 (mapcar 'list (nreverse split-name))
11132 'gnus-group-history))))
11133 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11135 (if (or (string= to-newsgroup "")
11136 (string= to-newsgroup prefix))
11137 (setq to-newsgroup default))
11138 (unless to-newsgroup
11139 (error "No group name entered"))
11140 (or (gnus-active to-newsgroup)
11141 (gnus-activate-group to-newsgroup nil nil to-method)
11142 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11144 (or (and (gnus-request-create-group to-newsgroup to-method)
11145 (gnus-activate-group
11146 to-newsgroup nil nil to-method)
11147 (gnus-subscribe-group to-newsgroup))
11148 (error "Couldn't create group %s" to-newsgroup)))
11149 (error "No such group: %s" to-newsgroup)))
11152 (defun gnus-summary-save-parts (type dir n &optional reverse)
11153 "Save parts matching TYPE to DIR.
11154 If REVERSE, save parts that do not match TYPE."
11156 (list (read-string "Save parts of type: "
11157 (or (car gnus-summary-save-parts-type-history)
11158 gnus-summary-save-parts-default-mime)
11159 'gnus-summary-save-parts-type-history)
11160 (setq gnus-summary-save-parts-last-directory
11161 (read-file-name "Save to directory: "
11162 gnus-summary-save-parts-last-directory
11164 current-prefix-arg))
11165 (gnus-summary-iterate n
11166 (let ((gnus-display-mime-function nil)
11167 (gnus-inhibit-treatment t))
11168 (gnus-summary-select-article))
11170 (set-buffer gnus-article-buffer)
11171 (let ((handles (or gnus-article-mime-handles
11172 (mm-dissect-buffer nil gnus-article-loose-mime)
11173 (and gnus-article-emulate-mime
11174 (mm-uu-dissect)))))
11176 (gnus-summary-save-parts-1 type dir handles reverse)
11177 (unless gnus-article-mime-handles ;; Don't destroy this case.
11178 (mm-destroy-parts handles)))))))
11180 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11181 (if (stringp (car handle))
11182 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11185 (not (string-match type (mm-handle-media-type handle)))
11186 (string-match type (mm-handle-media-type handle)))
11187 (let ((file (expand-file-name
11189 mm-file-name-rewrite-functions
11190 (file-name-nondirectory
11192 (mail-content-type-get
11193 (mm-handle-disposition handle) 'filename)
11194 (mail-content-type-get
11195 (mm-handle-type handle) 'name)
11196 (concat gnus-newsgroup-name
11197 "." (number-to-string
11198 (cdr gnus-article-current))))))
11200 (unless (file-exists-p file)
11201 (mm-save-part-to-file handle file))))))
11203 ;; Summary extract commands
11205 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11206 (let ((buffer-read-only nil)
11207 (article (gnus-summary-article-number))
11209 (unless (gnus-summary-goto-subject article)
11210 (error "No such article: %d" article))
11211 (gnus-summary-position-point)
11212 ;; If all commands are to be bunched up on one line, we collect
11214 (unless gnus-view-pseudos-separately
11215 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11218 (setq action (cdr (assq 'action (car ps))))
11219 (setq files (list (cdr (assq 'name (car ps)))))
11220 (while (and ps (cdr ps)
11221 (string= (or action "1")
11222 (or (cdr (assq 'action (cadr ps))) "2")))
11223 (push (cdr (assq 'name (cadr ps))) files)
11224 (setcdr ps (cddr ps)))
11226 (when (not (string-match "%s" action))
11229 (when (assq 'execute (car ps))
11230 (setcdr (assq 'execute (car ps))
11231 (funcall (if (string-match "%s" action)
11238 (shell-quote-argument f)))
11240 (setq ps (cdr ps)))))
11241 (if (and gnus-view-pseudos (not not-view))
11243 (when (assq 'execute (car pslist))
11244 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11245 (eq gnus-view-pseudos 'not-confirm)))
11246 (setq pslist (cdr pslist)))
11249 (setq after-article (or (cdr (assq 'article (car pslist)))
11250 (gnus-summary-article-number)))
11251 (gnus-summary-goto-subject after-article)
11254 (insert " " (file-name-nondirectory
11255 (cdr (assq 'name (car pslist))))
11256 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11258 (forward-line -1) ; back to `b'
11259 (gnus-add-text-properties
11260 b (1- e) (list 'gnus-number gnus-reffed-article-number
11261 gnus-mouse-face-prop gnus-mouse-face))
11263 after-article gnus-reffed-article-number
11264 gnus-unread-mark b (car pslist) 0 (- e b))
11265 (setq gnus-newsgroup-unreads
11266 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11267 gnus-reffed-article-number))
11268 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11269 (setq pslist (cdr pslist)))))))
11271 (defun gnus-pseudos< (p1 p2)
11272 (let ((c1 (cdr (assq 'action p1)))
11273 (c2 (cdr (assq 'action p2))))
11274 (and c1 c2 (string< c1 c2))))
11276 (defun gnus-request-pseudo-article (props)
11277 (cond ((assq 'execute props)
11278 (gnus-execute-command (cdr (assq 'execute props)))))
11279 (let ((gnus-current-article (gnus-summary-article-number)))
11280 (gnus-run-hooks 'gnus-mark-article-hook)))
11282 (defun gnus-execute-command (command &optional automatic)
11284 (gnus-article-setup-buffer)
11285 (set-buffer gnus-article-buffer)
11286 (setq buffer-read-only nil)
11287 (let ((command (if automatic command
11288 (read-string "Command: " (cons command 0)))))
11290 (insert "$ " command "\n\n")
11291 (if gnus-view-pseudo-asynchronously
11292 (start-process "gnus-execute" (current-buffer) shell-file-name
11293 shell-command-switch command)
11294 (call-process shell-file-name nil t nil
11295 shell-command-switch command)))))
11297 ;; Summary kill commands.
11299 (defun gnus-summary-edit-global-kill (article)
11300 "Edit the \"global\" kill file."
11301 (interactive (list (gnus-summary-article-number)))
11302 (gnus-group-edit-global-kill article))
11304 (defun gnus-summary-edit-local-kill ()
11305 "Edit a local kill file applied to the current newsgroup."
11307 (setq gnus-current-headers (gnus-summary-article-header))
11308 (gnus-group-edit-local-kill
11309 (gnus-summary-article-number) gnus-newsgroup-name))
11311 ;;; Header reading.
11313 (defun gnus-read-header (id &optional header)
11314 "Read the headers of article ID and enter them into the Gnus system."
11315 (let ((group gnus-newsgroup-name)
11316 (gnus-override-method
11318 gnus-override-method
11319 (and (gnus-news-group-p gnus-newsgroup-name)
11320 (car (gnus-refer-article-methods)))))
11322 ;; First we check to see whether the header in question is already
11325 ;; This is a Message-ID.
11326 (setq header (or header (gnus-id-to-header id)))
11327 ;; This is an article number.
11328 (setq header (or header (gnus-summary-article-header id))))
11330 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11331 ;; We have found the header.
11333 ;; We have to really fetch the header to this article.
11335 (set-buffer nntp-server-buffer)
11336 (when (setq where (gnus-request-head id group))
11337 (nnheader-fold-continuation-lines)
11338 (goto-char (point-max))
11340 (goto-char (point-min))
11344 ((cdr where) (cdr where))
11345 (header (mail-header-number header))
11346 (t gnus-reffed-article-number))
11348 (insert " Article retrieved.\n"))
11349 (if (or (not where)
11350 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11351 () ; Malformed head.
11352 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11353 (when (and (stringp id)
11354 (not (string= (gnus-group-real-name group)
11356 ;; If we fetched by Message-ID and the article came
11357 ;; from a different group, we fudge some bogus article
11358 ;; numbers for this article.
11359 (mail-header-set-number header gnus-reffed-article-number))
11361 (set-buffer gnus-summary-buffer)
11362 (decf gnus-reffed-article-number)
11363 (gnus-remove-header (mail-header-number header))
11364 (push header gnus-newsgroup-headers)
11365 (setq gnus-current-headers header)
11366 (push (mail-header-number header) gnus-newsgroup-limit)))
11369 (defun gnus-remove-header (number)
11370 "Remove header NUMBER from `gnus-newsgroup-headers'."
11371 (if (and gnus-newsgroup-headers
11372 (= number (mail-header-number (car gnus-newsgroup-headers))))
11373 (pop gnus-newsgroup-headers)
11374 (let ((headers gnus-newsgroup-headers))
11375 (while (and (cdr headers)
11376 (not (= number (mail-header-number (cadr headers)))))
11378 (when (cdr headers)
11379 (setcdr headers (cddr headers))))))
11382 ;;; summary highlights
11385 (defun gnus-highlight-selected-summary ()
11386 "Highlight selected article in summary buffer."
11387 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11388 (when gnus-summary-selected-face
11390 (let* ((beg (point-at-bol))
11391 (end (point-at-eol))
11392 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11393 (from (if (get-text-property beg gnus-mouse-face-prop)
11395 (or (next-single-property-change
11396 beg gnus-mouse-face-prop nil end)
11401 (or (next-single-property-change
11402 from gnus-mouse-face-prop nil end)
11404 ;; If no mouse-face prop on line we will have to = from = end,
11405 ;; so we highlight the entire line instead.
11406 (when (= (+ to 2) from)
11409 (if gnus-newsgroup-selected-overlay
11410 ;; Move old overlay.
11412 gnus-newsgroup-selected-overlay from to (current-buffer))
11413 ;; Create new overlay.
11415 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11416 'face gnus-summary-selected-face))))))
11418 (defvar gnus-summary-highlight-line-cached nil)
11419 (defvar gnus-summary-highlight-line-trigger nil)
11421 (defun gnus-summary-highlight-line-0 ()
11422 (if (and (eq gnus-summary-highlight-line-trigger
11423 gnus-summary-highlight)
11424 gnus-summary-highlight-line-cached)
11425 gnus-summary-highlight-line-cached
11426 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11427 gnus-summary-highlight-line-cached
11428 (let* ((cond (list 'cond))
11430 (list gnus-summary-highlight))
11432 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11436 (gnus-byte-compile (list 'lambda nil cond))))))
11438 (defun gnus-summary-highlight-line ()
11439 "Highlight current line according to `gnus-summary-highlight'."
11440 (let* ((beg (point-at-bol))
11441 (article (or (gnus-summary-article-number) gnus-current-article))
11442 (score (or (cdr (assq article
11443 gnus-newsgroup-scored))
11444 gnus-summary-default-score 0))
11445 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11446 (inhibit-read-only t)
11447 (default gnus-summary-default-score)
11448 (default-high gnus-summary-default-high-score)
11449 (default-low gnus-summary-default-low-score)
11450 (uncached (and gnus-summary-use-undownloaded-faces
11451 (memq article gnus-newsgroup-undownloaded)
11452 (not (memq article gnus-newsgroup-cached)))))
11453 (let ((face (funcall (gnus-summary-highlight-line-0))))
11454 (unless (eq face (get-text-property beg 'face))
11455 (gnus-put-text-property-excluding-characters-with-faces
11456 beg (point-at-eol) 'face
11457 (setq face (if (boundp face) (symbol-value face) face)))
11458 (when gnus-summary-highlight-line-function
11459 (funcall gnus-summary-highlight-line-function article face))))))
11461 (defun gnus-update-read-articles (group unread &optional compute)
11462 "Update the list of read articles in GROUP.
11463 UNREAD is a sorted list."
11464 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11465 (info (gnus-get-info group))
11468 (if (or (not info) (not active))
11469 ;; There is no info on this group if it was, in fact,
11470 ;; killed. Gnus stores no information on killed groups, so
11471 ;; there's nothing to be done.
11472 ;; One could store the information somewhere temporarily,
11473 ;; perhaps... Hmmm...
11475 ;; Remove any negative articles numbers.
11476 (while (and unread (< (car unread) 0))
11477 (setq unread (cdr unread)))
11478 ;; Remove any expired article numbers
11479 (while (and unread (< (car unread) (car active)))
11480 (setq unread (cdr unread)))
11481 ;; Compute the ranges of read articles by looking at the list of
11482 ;; unread articles.
11484 (when (/= (car unread) prev)
11485 (push (if (= prev (1- (car unread))) prev
11486 (cons prev (1- (car unread))))
11488 (setq prev (1+ (car unread)))
11489 (setq unread (cdr unread)))
11490 (when (<= prev (cdr active))
11491 (push (cons prev (cdr active)) read))
11492 (setq read (if (> (length read) 1) (nreverse read) read))
11497 ;; Propagate the read marks to the backend.
11498 (when (gnus-check-backend-function 'request-set-mark group)
11499 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11500 (add (gnus-remove-from-range read (gnus-info-read info))))
11502 (unless (gnus-check-group group)
11503 (error "Can't open server for %s" group))
11504 (gnus-request-set-mark
11505 group (delq nil (list (if add (list add 'add '(read)))
11506 (if del (list del 'del '(read))))))
11508 `(gnus-request-set-mark
11511 (if del (list del 'add '(read)))
11512 (if add (list add 'del '(read))))))))))
11513 (set-buffer gnus-group-buffer)
11514 (gnus-undo-register
11516 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11517 (gnus-info-set-read ',info ',(gnus-info-read info))
11518 (gnus-get-unread-articles-in-group ',info
11519 (gnus-active ,group))
11520 (gnus-group-update-group ,group t)
11522 ;; Enter this list into the group info.
11523 (gnus-info-set-read info read)
11524 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11525 (gnus-get-unread-articles-in-group info (gnus-active group))
11528 (defun gnus-offer-save-summaries ()
11529 "Offer to save all active summary buffers."
11531 ;; Go through all buffers and find all summaries.
11532 (dolist (buffer (buffer-list))
11533 (when (and (setq buffer (buffer-name buffer))
11534 (string-match "Summary" buffer)
11535 (with-current-buffer buffer
11536 ;; We check that this is, indeed, a summary buffer.
11537 (and (eq major-mode 'gnus-summary-mode)
11538 ;; Also make sure this isn't bogus.
11539 gnus-newsgroup-prepared
11540 ;; Also make sure that this isn't a
11541 ;; dead summary buffer.
11542 (not gnus-dead-summary-mode))))
11543 (push buffer buffers)))
11544 ;; Go through all these summary buffers and offer to save them.
11548 "Update summary buffer %s? "
11550 (switch-to-buffer buf)
11551 (gnus-summary-exit))
11555 ;;; @ for mime-partial
11558 (defun gnus-request-partial-message ()
11560 (let ((number (gnus-summary-article-number))
11561 (group gnus-newsgroup-name)
11562 (mother gnus-article-buffer))
11563 (set-buffer (get-buffer-create " *Partial Article*"))
11565 (setq mime-preview-buffer mother)
11566 (gnus-request-article-this-buffer number group)
11567 (mime-parse-buffer)
11570 (autoload 'mime-combine-message/partial-pieces-automatically
11572 "Internal method to combine message/partial messages automatically.")
11574 (mime-add-condition
11575 'action '((type . message)(subtype . partial)
11576 (major-mode . gnus-original-article-mode)
11577 (method . mime-combine-message/partial-pieces-automatically)
11578 (summary-buffer-exp . gnus-summary-buffer)
11579 (request-partial-message-method . gnus-request-partial-message)
11583 ;;; @ for message/rfc822
11586 (defun gnus-mime-extract-message/rfc822 (entity situation)
11587 "Burst a forwarded article."
11589 (set-buffer gnus-summary-buffer)
11590 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11591 gnus-newsgroup-name 'gnus-group-history))
11592 (gnus-group-marked (list group))
11595 (mime-insert-entity-content entity)
11596 (setq article (gnus-request-accept-article group)))
11597 (when (and (consp article)
11598 (numberp (setq article (cdr article))))
11599 (setq info (gnus-get-info group))
11600 (gnus-info-set-read info
11601 (gnus-remove-from-range (gnus-info-read info)
11603 (when (string-equal group gnus-newsgroup-name)
11605 (let (gnus-show-threads)
11606 (gnus-summary-goto-subject article t))
11607 (gnus-summary-clear-mark-forward 1))
11608 (set-buffer gnus-group-buffer)
11609 (gnus-group-get-new-news-this-group nil t)))))
11611 (mime-add-condition
11612 'action '((type . message)(subtype . rfc822)
11613 (major-mode . gnus-original-article-mode)
11614 (method . gnus-mime-extract-message/rfc822)
11618 (mime-add-condition
11619 'action '((type . message)(subtype . news)
11620 (major-mode . gnus-original-article-mode)
11621 (method . gnus-mime-extract-message/rfc822)
11625 (defun gnus-mime-extract-multipart (entity situation)
11626 (let ((children (mime-entity-children entity))
11627 mime-acting-situation-to-override
11630 (mime-play-entity (car children)
11631 (cons (assq 'mode situation)
11632 mime-acting-situation-to-override))
11633 (setq children (cdr children)))
11634 (if (setq f (cdr (assq 'after-method
11635 mime-acting-situation-to-override)))
11639 (mime-add-condition
11640 'action '((type . multipart)
11641 (method . gnus-mime-extract-multipart)
11650 (defun gnus-summary-inherit-default-charset ()
11651 "Import `default-mime-charset' from summary buffer.
11652 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11654 (if (buffer-live-p gnus-summary-buffer)
11655 (let (d-m-c d-m-c-u)
11656 (with-current-buffer gnus-summary-buffer
11657 (setq d-m-c (if (local-variable-p 'default-mime-charset
11658 gnus-summary-buffer)
11659 default-mime-charset
11662 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11663 gnus-summary-buffer)
11664 (symbol-value 'default-mime-charset-unlimited)
11667 (kill-local-variable 'default-mime-charset)
11668 (set (make-local-variable 'default-mime-charset) d-m-c))
11670 (kill-local-variable 'default-mime-charset-unlimited)
11671 (set (make-local-variable 'default-mime-charset-unlimited)
11674 (defun gnus-summary-setup-default-charset ()
11675 "Setup newsgroup default charset."
11676 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11678 (setq gnus-newsgroup-charset nil)
11679 (set (make-local-variable 'default-mime-charset) nil)
11680 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11681 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11682 (let ((ignored-charsets
11683 (or gnus-newsgroup-ephemeral-ignored-charsets
11685 (and gnus-newsgroup-name
11686 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11687 gnus-newsgroup-ignored-charsets)))
11689 (setq gnus-newsgroup-charset
11690 (or gnus-newsgroup-ephemeral-charset
11691 (when (and gnus-newsgroup-name
11692 (setq charset (gnus-parameter-charset
11693 gnus-newsgroup-name)))
11694 (make-local-variable 'default-mime-charset)
11695 (setq default-mime-charset charset))
11696 gnus-default-charset))
11697 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11698 ignored-charsets))))
11704 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11705 "Display the current article buffer fully MIME-buttonized.
11706 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11707 treated as multipart/mixed."
11709 (require 'gnus-art)
11710 (let ((gnus-unbuttonized-mime-types nil)
11711 (gnus-mime-display-multipart-as-mixed show-all-parts))
11712 (gnus-summary-show-article)))
11714 (defun gnus-summary-repair-multipart (article)
11715 "Add a Content-Type header to a multipart article without one."
11716 (interactive (list (gnus-summary-article-number)))
11717 (gnus-with-article article
11718 (message-narrow-to-head)
11719 (message-remove-header "Mime-Version")
11720 (goto-char (point-max))
11721 (insert "Mime-Version: 1.0\n")
11723 (when (search-forward "\n--" nil t)
11724 (let ((separator (buffer-substring (point) (point-at-eol))))
11725 (message-narrow-to-head)
11726 (message-remove-header "Content-Type")
11727 (goto-char (point-max))
11728 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11731 (let (gnus-mark-article-hook)
11732 (gnus-summary-select-article t t nil article)))
11734 (defun gnus-summary-toggle-display-buttonized ()
11735 "Toggle the buttonizing of the article buffer."
11737 (require 'gnus-art)
11738 (if (setq gnus-inhibit-mime-unbuttonizing
11739 (not gnus-inhibit-mime-unbuttonizing))
11740 (let ((gnus-unbuttonized-mime-types nil))
11741 (gnus-summary-show-article))
11742 (gnus-summary-show-article)))
11745 ;;; Intelli-mouse commmands
11748 (defun gnus-wheel-summary-scroll (event)
11750 (let ((amount (if (memq 'shift (event-modifiers event))
11751 (car gnus-wheel-scroll-amount)
11752 (cdr gnus-wheel-scroll-amount)))
11753 (direction (- (* (static-if (featurep 'xemacs)
11754 (event-button event)
11755 (cond ((eq 'mouse-4 (event-basic-type event))
11757 ((eq 'mouse-5 (event-basic-type event))
11761 (gnus-summary-scroll-up (* amount direction))
11762 (when (gnus-eval-in-buffer-window gnus-article-buffer
11765 (and (if (< 0 direction)
11766 (gnus-article-next-page 0)
11767 (gnus-article-prev-page 0)
11769 (if (setq edge (get-text-property
11770 (point-min) 'gnus-wheel-edge))
11771 (setq edge (* edge direction))
11774 (let ((buffer-read-only nil)
11775 (inhibit-read-only t))
11776 (put-text-property (point-min) (point-max)
11777 'gnus-wheel-edge direction)
11779 (or (> edge gnus-wheel-edge-resistance)
11780 (let ((buffer-read-only nil)
11781 (inhibit-read-only t))
11782 (put-text-property (point-min) (point-max)
11784 (* (1+ edge) direction))
11786 (eq last-command 'gnus-wheel-summary-scroll))))
11787 (gnus-summary-next-article nil nil (minusp direction)))))
11789 (defun gnus-wheel-install ()
11790 "Enable mouse wheel support on summary window."
11791 (when gnus-use-wheel
11793 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11795 (define-key gnus-summary-mode-map key
11796 'gnus-wheel-summary-scroll)))))
11798 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11801 ;;; Traditional PGP commmands
11804 (defun gnus-summary-decrypt-article (&optional force)
11805 "Decrypt the current article in traditional PGP way.
11806 This will have permanent effect only in mail groups.
11807 If FORCE is non-nil, allow editing of articles even in read-only
11810 (gnus-summary-select-article t)
11811 (gnus-eval-in-buffer-window gnus-article-buffer
11815 (goto-char (point-min))
11816 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11817 (error "Not a traditional PGP message!"))
11818 (let ((armor-start (match-beginning 0)))
11819 (if (and (pgg-decrypt-region armor-start (point-max))
11820 (or force (not (gnus-group-read-only-p))))
11821 (let ((inhibit-read-only t)
11823 (delete-region armor-start
11825 (re-search-forward "^-+END PGP" nil t)
11826 (beginning-of-line 2)
11828 (insert-buffer-substring pgg-output-buffer))))))))
11830 (defun gnus-summary-verify-article ()
11831 "Verify the current article in traditional PGP way."
11834 (set-buffer gnus-original-article-buffer)
11835 (goto-char (point-min))
11836 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11837 (error "Not a traditional PGP message!"))
11838 (re-search-forward "^-+END PGP" nil t)
11839 (beginning-of-line 2)
11840 (call-interactively (function pgg-verify-region))))
11843 ;;; Generic summary marking commands
11846 (defvar gnus-summary-marking-alist
11847 '((read gnus-del-mark "d")
11848 (unread gnus-unread-mark "u")
11849 (ticked gnus-ticked-mark "!")
11850 (dormant gnus-dormant-mark "?")
11851 (expirable gnus-expirable-mark "e"))
11852 "An alist of names/marks/keystrokes.")
11854 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11855 (defvar gnus-summary-mark-map)
11857 (defun gnus-summary-make-all-marking-commands ()
11858 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11859 (dolist (elem gnus-summary-marking-alist)
11860 (apply 'gnus-summary-make-marking-command elem)))
11862 (defun gnus-summary-make-marking-command (name mark keystroke)
11863 (let ((map (make-sparse-keymap)))
11864 (define-key gnus-summary-generic-mark-map keystroke map)
11865 (dolist (lway `((next "next" next nil "n")
11866 (next-unread "next unread" next t "N")
11867 (prev "previous" prev nil "p")
11868 (prev-unread "previous unread" prev t "P")
11869 (nomove "" nil nil ,keystroke)))
11870 (let ((func (gnus-summary-make-marking-command-1
11871 mark (car lway) lway name)))
11872 (setq func (eval func))
11873 (define-key map (nth 4 lway) func)))))
11875 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11877 (format "gnus-summary-put-mark-as-%s%s"
11878 name (if (eq way 'nomove)
11880 (concat "-" (symbol-name way)))))
11883 "Mark the current article as %s%s.
11884 If N, the prefix, then repeat N times.
11885 If N is negative, move in reverse order.
11886 The difference between N and the actual number of articles marked is
11888 name (car (cdr lway)))
11890 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11892 (defun gnus-summary-generic-mark (n mark move unread)
11893 "Mark N articles with MARK."
11894 (unless (eq major-mode 'gnus-summary-mode)
11895 (error "This command can only be used in the summary buffer"))
11896 (gnus-summary-show-thread)
11899 ((eq move 'next) 1)
11900 ((eq move 'prev) -1)
11902 (if (zerop nummove)
11906 nummove (* -1 nummove))))
11907 (while (and (> n 0)
11908 (gnus-summary-mark-article nil mark)
11909 (zerop (gnus-summary-next-subject nummove unread t)))
11912 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11913 (gnus-summary-recenter)
11914 (gnus-summary-position-point)
11915 (gnus-set-mode-line 'summary)
11918 (defun gnus-summary-insert-articles (articles)
11919 (when (setq articles
11920 (gnus-sorted-difference articles
11921 (mapcar (lambda (h)
11922 (mail-header-number h))
11923 gnus-newsgroup-headers)))
11924 (setq gnus-newsgroup-headers
11926 gnus-newsgroup-headers
11927 (gnus-fetch-headers articles)
11928 'gnus-article-sort-by-number))
11929 ;; Suppress duplicates?
11930 (when gnus-suppress-duplicates
11931 (gnus-dup-suppress-articles))
11933 ;; We might want to build some more threads first.
11934 (when (and gnus-fetch-old-headers
11935 (eq gnus-headers-retrieved-by 'nov))
11936 (if (eq gnus-fetch-old-headers 'invisible)
11937 (gnus-build-all-threads)
11938 (gnus-build-old-threads)))
11939 ;; Let the Gnus agent mark articles as read.
11941 (gnus-agent-get-undownloaded-list))
11942 ;; Remove list identifiers from subject
11943 (when gnus-list-identifiers
11944 (gnus-summary-remove-list-identifiers))
11945 ;; First and last article in this newsgroup.
11946 (when gnus-newsgroup-headers
11947 (setq gnus-newsgroup-begin
11948 (mail-header-number (car gnus-newsgroup-headers))
11950 (mail-header-number
11951 (gnus-last-element gnus-newsgroup-headers))))
11952 (when gnus-use-scoring
11953 (gnus-possibly-score-headers))))
11955 (defun gnus-summary-insert-old-articles (&optional all)
11956 "Insert all old articles in this group.
11957 If ALL is non-nil, already read articles become readable.
11958 If ALL is a number, fetch this number of articles."
11961 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11964 ;; Some nntp servers lie about their active range. When
11965 ;; this happens, the active range can be in the millions.
11966 ;; Use a compressed range to avoid creating a huge list.
11967 (gnus-range-difference (list gnus-newsgroup-active) old))
11968 (setq len (gnus-range-length older))
11973 (let ((older-range (nreverse older)))
11977 (let* ((r (pop older-range))
11978 (min (if (numberp r) r (car r)))
11979 (max (if (numberp r) r (cdr r))))
11980 (while (and (<= min max)
11985 (setq older (gnus-uncompress-range older))))
11987 (setq older (gnus-uncompress-range older)))
11989 (when (and (numberp gnus-large-newsgroup)
11990 (> len gnus-large-newsgroup))
11991 (let* ((cursor-in-echo-area nil)
11992 (initial (gnus-parameter-large-newsgroup-initial
11993 gnus-newsgroup-name))
11997 "How many articles from %s (%s %d): "
11999 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12000 (if initial "max" "default")
12003 (cons (number-to-string initial)
12005 (unless (string-match "^[ \t]*$" input)
12006 (setq all (string-to-number input))
12008 (let ((older-range (nreverse older)))
12012 (let* ((r (pop older-range))
12013 (min (if (numberp r) r (car r)))
12014 (max (if (numberp r) r (cdr r))))
12015 (while (and (<= min max)
12019 max (1- max))))))))))
12020 (setq older (gnus-uncompress-range older))))
12022 (message "No old news.")
12023 (gnus-summary-insert-articles older)
12024 (gnus-summary-limit (gnus-sorted-nunion old older))))
12025 (gnus-summary-position-point)))
12027 (defun gnus-summary-insert-new-articles ()
12028 "Insert all new articles in this group."
12031 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12032 (old-active gnus-newsgroup-active)
12033 (nnmail-fetched-sources (list t))
12035 (setq gnus-newsgroup-active
12036 (gnus-activate-group gnus-newsgroup-name 'scan))
12037 (setq i (cdr gnus-newsgroup-active))
12038 (while (> i (cdr old-active))
12042 (message "No gnus is bad news")
12043 (gnus-summary-insert-articles new)
12044 (setq gnus-newsgroup-unreads
12045 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12046 (gnus-summary-limit (gnus-sorted-nunion old new))))
12047 (gnus-summary-position-point)))
12049 (gnus-summary-make-all-marking-commands)
12051 (gnus-ems-redefine)
12053 (provide 'gnus-sum)
12055 (run-hooks 'gnus-sum-load-hook)
12057 ;; Local Variables:
12058 ;; coding: iso-8859-1
12061 ;;; gnus-sum.el ends here