1 ;;; gnus-sum.el --- summary mode commands for gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
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., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
33 (defvar tool-bar-map))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
57 (autoload 'mm-uu-dissect "mm-uu")
58 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
59 "Deuglify broken Outlook (Express) articles and redisplay."
61 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
62 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
63 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-fetch-old-headers nil
73 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
74 If an unread article in the group refers to an older, already read (or
75 just marked as read) article, the old article will not normally be
76 displayed in the Summary buffer. If this variable is t, Gnus
77 will attempt to grab the headers to the old articles, and thereby
78 build complete threads. If it has the value `some', only enough
79 headers to connect otherwise loose threads will be displayed. This
80 variable can also be a number. In that case, no more than that number
81 of old headers will be fetched. If it has the value `invisible', all
82 old headers will be fetched, but none will be displayed.
84 The server has to support NOV for any of this to work."
86 :type '(choice (const :tag "off" nil)
91 (sexp :menu-tag "other" t)))
93 (defcustom gnus-refer-thread-limit 200
94 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
95 If t, fetch all the available old headers."
98 (sexp :menu-tag "other" t)))
100 (defcustom gnus-summary-make-false-root 'adopt
101 "*nil means that Gnus won't gather loose threads.
102 If the root of a thread has expired or been read in a previous
103 session, the information necessary to build a complete thread has been
104 lost. Instead of having many small sub-threads from this original thread
105 scattered all over the summary buffer, Gnus can gather them.
107 If non-nil, Gnus will try to gather all loose sub-threads from an
108 original thread into one large thread.
110 If this variable is non-nil, it should be one of `none', `adopt',
113 If this variable is `none', Gnus will not make a false root, but just
114 present the sub-threads after another.
115 If this variable is `dummy', Gnus will create a dummy root that will
116 have all the sub-threads as children.
117 If this variable is `adopt', Gnus will make one of the \"children\"
118 the parent and mark all the step-children as such.
119 If this variable is `empty', the \"children\" are printed with empty
120 subject fields. (Or rather, they will be printed with a string
121 given by the `gnus-summary-same-subject' variable.)"
123 :type '(choice (const :tag "off" nil)
129 (defcustom gnus-summary-make-false-root-always nil
130 "Always make a false dummy root."
135 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
136 "*A regexp to match subjects to be excluded from loose thread gathering.
137 As loose thread gathering is done on subjects only, that means that
138 there can be many false gatherings performed. By rooting out certain
139 common subjects, gathering might become saner."
143 (defcustom gnus-summary-gather-subject-limit nil
144 "*Maximum length of subject comparisons when gathering loose threads.
145 Use nil to compare full subjects. Setting this variable to a low
146 number will help gather threads that have been corrupted by
147 newsreaders chopping off subject lines, but it might also mean that
148 unrelated articles that have subject that happen to begin with the
149 same few characters will be incorrectly gathered.
151 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
154 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "on" t)))
158 (defcustom gnus-simplify-subject-functions nil
159 "List of functions taking a string argument that simplify subjects.
160 The functions are applied recursively.
162 Useful functions to put in this list include:
163 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
164 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
166 :type '(repeat function))
168 (defcustom gnus-simplify-ignored-prefixes nil
169 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
171 :type '(choice (const :tag "off" nil)
174 (defcustom gnus-build-sparse-threads nil
175 "*If non-nil, fill in the gaps in threads.
176 If `some', only fill in the gaps that are needed to tie loose threads
177 together. If `more', fill in all leaf nodes that Gnus can find. If
178 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
180 :type '(choice (const :tag "off" nil)
183 (sexp :menu-tag "all" t)))
185 (defcustom gnus-summary-thread-gathering-function
186 'gnus-gather-threads-by-subject
187 "*Function used for gathering loose threads.
188 There are two pre-defined functions: `gnus-gather-threads-by-subject',
189 which only takes Subjects into consideration; and
190 `gnus-gather-threads-by-references', which compared the References
191 headers of the articles to find matches."
193 :type '(radio (function-item gnus-gather-threads-by-subject)
194 (function-item gnus-gather-threads-by-references)
195 (function :tag "other")))
197 (defcustom gnus-summary-same-subject ""
198 "*String indicating that the current article has the same subject as the previous.
199 This variable will only be used if the value of
200 `gnus-summary-make-false-root' is `empty'."
201 :group 'gnus-summary-format
204 (defcustom gnus-summary-goto-unread t
205 "*If t, many commands will go to the next unread article.
206 This applies to marking commands as well as other commands that
207 \"naturally\" select the next article, like, for instance, `SPC' at
208 the end of an article.
210 If nil, the marking commands do NOT go to the next unread article
211 \(they go to the next article instead). If `never', commands that
212 usually go to the next unread article, will go to the next article,
213 whether it is read or not."
214 :group 'gnus-summary-marks
215 :link '(custom-manual "(gnus)Setting Marks")
216 :type '(choice (const :tag "off" nil)
218 (sexp :menu-tag "on" t)))
220 (defcustom gnus-summary-default-score 0
221 "*Default article score level.
222 All scores generated by the score files will be added to this score.
223 If this variable is nil, scoring will be disabled."
224 :group 'gnus-score-default
225 :type '(choice (const :tag "disable")
228 (defcustom gnus-summary-default-high-score 0
229 "*Default threshold for a high scored article.
230 An article will be highlighted as high scored if its score is greater
233 :group 'gnus-score-default
236 (defcustom gnus-summary-default-low-score 0
237 "*Default threshold for a low scored article.
238 An article will be highlighted as low scored if its score is smaller
241 :group 'gnus-score-default
244 (defcustom gnus-summary-zcore-fuzz 0
245 "*Fuzziness factor for the zcore in the summary buffer.
246 Articles with scores closer than this to `gnus-summary-default-score'
248 :group 'gnus-summary-format
251 (defcustom gnus-simplify-subject-fuzzy-regexp nil
252 "*Strings to be removed when doing fuzzy matches.
253 This can either be a regular expression or list of regular expressions
254 that will be removed from subject strings if fuzzy subject
255 simplification is selected."
257 :type '(repeat regexp))
259 (defcustom gnus-show-threads t
260 "*If non-nil, display threads in summary mode."
264 (defcustom gnus-thread-hide-subtree nil
265 "*If non-nil, hide all threads initially.
266 This can be a predicate specifier which says which threads to hide.
267 If threads are hidden, you have to run the command
268 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
269 to expose hidden threads."
271 :type '(radio (sexp :format "Non-nil\n"
272 :match (lambda (widget value)
273 (not (or (consp value) (functionp value))))
276 (sexp :tag "Predicate specifier")))
278 (defcustom gnus-thread-hide-killed t
279 "*If non-nil, hide killed threads automatically."
283 (defcustom gnus-thread-ignore-subject t
284 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
285 If nil, articles that have different subjects from their parents will
286 start separate threads."
290 (defcustom gnus-thread-operation-ignore-subject t
291 "*If non-nil, subjects will be ignored when doing thread commands.
292 This affects commands like `gnus-summary-kill-thread' and
293 `gnus-summary-lower-thread'.
295 If this variable is nil, articles in the same thread with different
296 subjects will not be included in the operation in question. If this
297 variable is `fuzzy', only articles that have subjects that are fuzzily
298 equal will be included."
300 :type '(choice (const :tag "off" nil)
304 (defcustom gnus-thread-indent-level 4
305 "*Number that says how much each sub-thread should be indented."
309 (defcustom gnus-auto-extend-newsgroup t
310 "*If non-nil, extend newsgroup forward and backward when requested."
311 :group 'gnus-summary-choose
314 (defcustom gnus-auto-select-first t
315 "*If non-nil, select the article under point.
316 Which article this is is controlled by the `gnus-auto-select-subject'
319 If you want to prevent automatic selection of articles in some
320 newsgroups, set the variable to nil in `gnus-select-group-hook'."
321 :group 'gnus-group-select
322 :type '(choice (const :tag "none" nil)
323 (sexp :menu-tag "first" t)))
325 (defcustom gnus-auto-select-subject 'unread
326 "*Says what subject to place under point when entering a group.
328 This variable can either be the symbols `first' (place point on the
329 first subject), `unread' (place point on the subject line of the first
330 unread article), `best' (place point on the subject line of the
331 higest-scored article), `unseen' (place point on the subject line of
332 the first unseen article), `unseen-or-unread' (place point on the subject
333 line of the first unseen article or, if all article have been seen, on the
334 subject line of the first unread article), or a function to be called to
335 place point on some subject line."
337 :group 'gnus-group-select
338 :type '(choice (const best)
342 (const unseen-or-unread)))
344 (defcustom gnus-dont-select-after-jump-to-other-group nil
345 "If non-nil, don't select the first unread article after entering the
346 other group by the command `gnus-summary-jump-to-other-group'. If nil,
347 it is depend on the value of `gnus-auto-select-first' whether to select
349 :group 'gnus-group-select
352 (defcustom gnus-auto-select-next t
353 "*If non-nil, offer to go to the next group from the end of the previous.
354 If the value is t and the next newsgroup is empty, Gnus will exit
355 summary mode and go back to group mode. If the value is neither nil
356 nor t, Gnus will select the following unread newsgroup. In
357 particular, if the value is the symbol `quietly', the next unread
358 newsgroup will be selected without any confirmation, and if it is
359 `almost-quietly', the next group will be selected without any
360 confirmation if you are located on the last article in the group.
361 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
362 will go to the next group without confirmation."
363 :group 'gnus-summary-maneuvering
364 :type '(choice (const :tag "off" nil)
366 (const almost-quietly)
367 (const slightly-quietly)
368 (sexp :menu-tag "on" t)))
370 (defcustom gnus-auto-select-same nil
371 "*If non-nil, select the next article with the same subject.
372 If there are no more articles with the same subject, go to
373 the first unread article."
374 :group 'gnus-summary-maneuvering
377 (defcustom gnus-auto-goto-ignores 'unfetched
378 "*Says how to handle unfetched articles when maneuvering.
380 This variable can either be the symbols nil (maneuver to any
381 article), `undownloaded' (maneuvering while unplugged ignores articles
382 that have not been fetched), `always-undownloaded' (maneuvering always
383 ignores articles that have not been fetched), `unfetched' (maneuvering
384 ignores articles whose headers have not been fetched).
386 NOTE: The list of unfetched articles will always be nil when plugged
387 and, when unplugged, a subset of the undownloaded article list."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "None" nil)
391 (const :tag "Undownloaded when unplugged" undownloaded)
392 (const :tag "Undownloaded" always-undownloaded)
393 (const :tag "Unfetched" unfetched)))
395 (defcustom gnus-summary-check-current nil
396 "*If non-nil, consider the current article when moving.
397 The \"unread\" movement commands will stay on the same line if the
398 current article is unread."
399 :group 'gnus-summary-maneuvering
402 (defcustom gnus-auto-center-summary 2
403 "*If non-nil, always center the current summary buffer.
404 In particular, if `vertical' do only vertical recentering. If non-nil
405 and non-`vertical', do both horizontal and vertical recentering."
406 :group 'gnus-summary-maneuvering
407 :type '(choice (const :tag "none" nil)
409 (integer :tag "height")
410 (sexp :menu-tag "both" t)))
412 (defvar gnus-auto-center-group t
413 "*If non-nil, always center the group buffer.")
415 (defcustom gnus-show-all-headers nil
416 "*If non-nil, don't hide any headers."
417 :group 'gnus-article-hiding
418 :group 'gnus-article-headers
421 (defcustom gnus-summary-ignore-duplicates nil
422 "*If non-nil, ignore articles with identical Message-ID headers."
426 (defcustom gnus-single-article-buffer t
427 "*If non-nil, display all articles in the same buffer.
428 If nil, each group will get its own article buffer."
429 :group 'gnus-article-various
432 (defcustom gnus-break-pages t
433 "*If non-nil, do page breaking on articles.
434 The page delimiter is specified by the `gnus-page-delimiter'
436 :group 'gnus-article-various
439 (defcustom gnus-show-mime t
440 "*If non-nil, do mime processing of articles.
441 The articles will simply be fed to the function given by
442 `gnus-article-display-method-for-mime'."
443 :group 'gnus-article-mime
446 (defcustom gnus-move-split-methods nil
447 "*Variable used to suggest where articles are to be moved to.
448 It uses the same syntax as the `gnus-split-methods' variable.
449 However, whereas `gnus-split-methods' specifies file names as targets,
450 this variable specifies group names."
451 :group 'gnus-summary-mail
452 :type '(repeat (choice (list :value (fun) function)
453 (cons :value ("" "") regexp (repeat string))
456 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
457 "Function used to compute default prefix for article move/copy/etc prompts.
458 The function should take one argument, a group name, and return a
459 string with the suggested prefix."
460 :group 'gnus-summary-mail
463 ;; FIXME: Although the custom type is `character' for the following variables,
464 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
466 (defcustom gnus-unread-mark ?\ ;;;Whitespace
467 "*Mark used for unread articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-ticked-mark ?!
472 "*Mark used for ticked articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-dormant-mark ??
477 "*Mark used for dormant articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-del-mark ?r
482 "*Mark used for del'd articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-read-mark ?R
487 "*Mark used for read articles."
488 :group 'gnus-summary-marks
491 (defcustom gnus-expirable-mark ?E
492 "*Mark used for expirable articles."
493 :group 'gnus-summary-marks
496 (defcustom gnus-killed-mark ?K
497 "*Mark used for killed articles."
498 :group 'gnus-summary-marks
501 (defcustom gnus-spam-mark ?$
502 "*Mark used for spam articles."
504 :group 'gnus-summary-marks
507 (defcustom gnus-souped-mark ?F
508 "*Mark used for souped articles."
509 :group 'gnus-summary-marks
512 (defcustom gnus-kill-file-mark ?X
513 "*Mark used for articles killed by kill files."
514 :group 'gnus-summary-marks
517 (defcustom gnus-low-score-mark ?Y
518 "*Mark used for articles with a low score."
519 :group 'gnus-summary-marks
522 (defcustom gnus-catchup-mark ?C
523 "*Mark used for articles that are caught up."
524 :group 'gnus-summary-marks
527 (defcustom gnus-replied-mark ?A
528 "*Mark used for articles that have been replied to."
529 :group 'gnus-summary-marks
532 (defcustom gnus-forwarded-mark ?F
533 "*Mark used for articles that have been forwarded."
535 :group 'gnus-summary-marks
538 (defcustom gnus-recent-mark ?N
539 "*Mark used for articles that are recent."
541 :group 'gnus-summary-marks
544 (defcustom gnus-cached-mark ?*
545 "*Mark used for articles that are in the cache."
546 :group 'gnus-summary-marks
549 (defcustom gnus-saved-mark ?S
550 "*Mark used for articles that have been saved."
551 :group 'gnus-summary-marks
554 (defcustom gnus-unseen-mark ?.
555 "*Mark used for articles that haven't been seen."
557 :group 'gnus-summary-marks
560 (defcustom gnus-no-mark ?\ ;;;Whitespace
561 "*Mark used for articles that have no other secondary mark."
563 :group 'gnus-summary-marks
566 (defcustom gnus-ancient-mark ?O
567 "*Mark used for ancient articles."
568 :group 'gnus-summary-marks
571 (defcustom gnus-sparse-mark ?Q
572 "*Mark used for sparsely reffed articles."
573 :group 'gnus-summary-marks
576 (defcustom gnus-canceled-mark ?G
577 "*Mark used for canceled articles."
578 :group 'gnus-summary-marks
581 (defcustom gnus-duplicate-mark ?M
582 "*Mark used for duplicate articles."
583 :group 'gnus-summary-marks
586 (defcustom gnus-undownloaded-mark ?-
587 "*Mark used for articles that weren't downloaded."
589 :group 'gnus-summary-marks
592 (defcustom gnus-downloaded-mark ?+
593 "*Mark used for articles that were downloaded."
594 :group 'gnus-summary-marks
597 (defcustom gnus-downloadable-mark ?%
598 "*Mark used for articles that are to be downloaded."
599 :group 'gnus-summary-marks
602 (defcustom gnus-unsendable-mark ?=
603 "*Mark used for articles that won't be sent."
604 :group 'gnus-summary-marks
607 (defcustom gnus-score-over-mark ?+
608 "*Score mark used for articles with high scores."
609 :group 'gnus-summary-marks
612 (defcustom gnus-score-below-mark ?-
613 "*Score mark used for articles with low scores."
614 :group 'gnus-summary-marks
617 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
618 "*There is no thread under the article."
619 :group 'gnus-summary-marks
622 (defcustom gnus-not-empty-thread-mark ?=
623 "*There is a thread under the article."
624 :group 'gnus-summary-marks
627 (defcustom gnus-view-pseudo-asynchronously nil
628 "*If non-nil, Gnus will view pseudo-articles asynchronously."
629 :group 'gnus-extract-view
632 (defcustom gnus-auto-expirable-marks
633 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
634 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
635 gnus-souped-mark gnus-duplicate-mark)
636 "*The list of marks converted into expiration if a group is auto-expirable."
639 :type '(repeat character))
641 (defcustom gnus-inhibit-user-auto-expire t
642 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
647 (defcustom gnus-view-pseudos nil
648 "*If `automatic', pseudo-articles will be viewed automatically.
649 If `not-confirm', pseudos will be viewed automatically, and the user
650 will not be asked to confirm the command."
651 :group 'gnus-extract-view
652 :type '(choice (const :tag "off" nil)
654 (const not-confirm)))
656 (defcustom gnus-view-pseudos-separately t
657 "*If non-nil, one pseudo-article will be created for each file to be viewed.
658 If nil, all files that use the same viewing command will be given as a
659 list of parameters to that command."
660 :group 'gnus-extract-view
663 (defcustom gnus-insert-pseudo-articles t
664 "*If non-nil, insert pseudo-articles when decoding articles."
665 :group 'gnus-extract-view
668 (defcustom gnus-summary-dummy-line-format
670 "*The format specification for the dummy roots in the summary buffer.
671 It works along the same lines as a normal formatting string,
672 with some simple extensions.
676 General format specifiers can also be used.
677 See `(gnus)Formatting Variables'."
678 :link '(custom-manual "(gnus)Formatting Variables")
679 :group 'gnus-threading
682 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
683 "*The format specification for the summary mode line.
684 It works along the same lines as a normal formatting string,
685 with some simple extensions:
688 %p Unprefixed group name
689 %A Current article number
690 %z Current article score
692 %U Number of unread articles in the group
693 %e Number of unselected articles in the group
694 %Z A string with unread/unselected article counts
695 %g Shortish group name
696 %S Subject of the current article
698 %s Current score file name
699 %d Number of dormant articles
700 %r Number of articles that have been marked as read in this session
701 %E Number of articles expunged by the score files"
702 :group 'gnus-summary-format
705 (defcustom gnus-list-identifiers nil
706 "Regexp that matches list identifiers to be removed from subject.
707 This can also be a list of regexps."
709 :group 'gnus-summary-format
710 :group 'gnus-article-hiding
711 :type '(choice (const :tag "none" nil)
713 (repeat :value (".*") regexp)))
715 (defcustom gnus-summary-mark-below 0
716 "*Mark all articles with a score below this variable as read.
717 This variable is local to each summary buffer and usually set by the
719 :group 'gnus-score-default
722 (defun gnus-widget-reversible-match (widget value)
723 "Ignoring WIDGET, convert VALUE to internal form.
724 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
728 (eq (length value) 2)
729 (eq (nth 0 value) 'not)
730 (symbolp (nth 1 value)))))
732 (defun gnus-widget-reversible-to-internal (widget value)
733 "Ignoring WIDGET, convert VALUE to internal form.
734 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
735 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
739 (list (nth 1 value) t)))
741 (defun gnus-widget-reversible-to-external (widget value)
742 "Ignoring WIDGET, convert VALUE to external form.
743 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
744 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
747 (list 'not (nth 0 value))
750 (define-widget 'gnus-widget-reversible 'group
751 "A `group' that convert values."
752 :match 'gnus-widget-reversible-match
753 :value-to-internal 'gnus-widget-reversible-to-internal
754 :value-to-external 'gnus-widget-reversible-to-external)
756 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
757 "*List of functions used for sorting articles in the summary buffer.
759 Each function takes two articles and returns non-nil if the first
760 article should be sorted before the other. If you use more than one
761 function, the primary sort function should be the last. You should
762 probably always include `gnus-article-sort-by-number' in the list of
763 sorting functions -- preferably first. Also note that sorting by date
764 is often much slower than sorting by number, and the sorting order is
765 very similar. (Sorting by date means sorting by the time the message
766 was sent, sorting by number means sorting by arrival time.)
768 Each item can also be a list `(not F)' where F is a function;
769 this reverses the sort order.
771 Ready-made functions include `gnus-article-sort-by-number',
772 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
773 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
774 and `gnus-article-sort-by-score'.
776 When threading is turned on, the variable `gnus-thread-sort-functions'
777 controls how articles are sorted."
778 :group 'gnus-summary-sort
779 :type '(repeat (gnus-widget-reversible
780 (choice (function-item gnus-article-sort-by-number)
781 (function-item gnus-article-sort-by-author)
782 (function-item gnus-article-sort-by-subject)
783 (function-item gnus-article-sort-by-date)
784 (function-item gnus-article-sort-by-score)
785 (function-item gnus-article-sort-by-random)
786 (function :tag "other"))
787 (boolean :tag "Reverse order"))))
790 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
791 "*List of functions used for sorting threads in the summary buffer.
792 By default, threads are sorted by article number.
794 Each function takes two threads and returns non-nil if the first
795 thread should be sorted before the other. If you use more than one
796 function, the primary sort function should be the last. You should
797 probably always include `gnus-thread-sort-by-number' in the list of
798 sorting functions -- preferably first. Also note that sorting by date
799 is often much slower than sorting by number, and the sorting order is
800 very similar. (Sorting by date means sorting by the time the message
801 was sent, sorting by number means sorting by arrival time.)
803 Each list item can also be a list `(not F)' where F is a
804 function; this specifies reversed sort order.
806 Ready-made functions include `gnus-thread-sort-by-number',
807 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
808 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
809 `gnus-thread-sort-by-most-recent-number',
810 `gnus-thread-sort-by-most-recent-date',
811 `gnus-thread-sort-by-random', and
812 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
814 When threading is turned off, the variable
815 `gnus-article-sort-functions' controls how articles are sorted."
816 :group 'gnus-summary-sort
818 (gnus-widget-reversible
819 (choice (function-item gnus-thread-sort-by-number)
820 (function-item gnus-thread-sort-by-author)
821 (function-item gnus-thread-sort-by-subject)
822 (function-item gnus-thread-sort-by-date)
823 (function-item gnus-thread-sort-by-score)
824 (function-item gnus-thread-sort-by-most-recent-number)
825 (function-item gnus-thread-sort-by-most-recent-date)
826 (function-item gnus-thread-sort-by-random)
827 (function-item gnus-thread-sort-by-total-score)
828 (function :tag "other"))
829 (boolean :tag "Reverse order"))))
831 (defcustom gnus-thread-score-function '+
832 "*Function used for calculating the total score of a thread.
834 The function is called with the scores of the article and each
835 subthread and should then return the score of the thread.
837 Some functions you can use are `+', `max', or `min'."
838 :group 'gnus-summary-sort
841 (defcustom gnus-summary-expunge-below nil
842 "All articles that have a score less than this variable will be expunged.
843 This variable is local to the summary buffers."
844 :group 'gnus-score-default
845 :type '(choice (const :tag "off" nil)
848 (defcustom gnus-thread-expunge-below nil
849 "All threads that have a total score less than this variable will be expunged.
850 See `gnus-thread-score-function' for en explanation of what a
853 This variable is local to the summary buffers."
854 :group 'gnus-threading
855 :group 'gnus-score-default
856 :type '(choice (const :tag "off" nil)
859 (defcustom gnus-summary-mode-hook nil
860 "*A hook for Gnus summary mode.
861 This hook is run before any variables are set in the summary buffer."
862 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
863 :group 'gnus-summary-various
866 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
867 (when (featurep 'xemacs)
868 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
869 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
870 (add-hook 'gnus-summary-mode-hook
871 'gnus-xmas-switch-horizontal-scrollbar-off))
873 (defcustom gnus-summary-menu-hook nil
874 "*Hook run after the creation of the summary mode menu."
875 :group 'gnus-summary-visual
878 (defcustom gnus-summary-exit-hook nil
879 "*A hook called on exit from the summary buffer.
880 It will be called with point in the group buffer."
881 :group 'gnus-summary-exit
884 (defcustom gnus-summary-prepare-hook nil
885 "*A hook called after the summary buffer has been generated.
886 If you want to modify the summary buffer, you can use this hook."
887 :group 'gnus-summary-various
890 (defcustom gnus-summary-prepared-hook nil
891 "*A hook called as the last thing after the summary buffer has been generated."
892 :group 'gnus-summary-various
895 (defcustom gnus-summary-generate-hook nil
896 "*A hook run just before generating the summary buffer.
897 This hook is commonly used to customize threading variables and the
899 :group 'gnus-summary-various
902 (defcustom gnus-select-group-hook nil
903 "*A hook called when a newsgroup is selected.
905 If you'd like to simplify subjects like the
906 `gnus-summary-next-same-subject' command does, you can use the
909 (add-hook gnus-select-group-hook
911 (mapcar (lambda (header)
912 (mail-header-set-subject
914 (gnus-simplify-subject
915 (mail-header-subject header) 're-only)))
916 gnus-newsgroup-headers)))"
917 :group 'gnus-group-select
920 (defcustom gnus-select-article-hook nil
921 "*A hook called when an article is selected."
922 :group 'gnus-summary-choose
923 :options '(gnus-agent-fetch-selected-article)
926 (defcustom gnus-visual-mark-article-hook
927 (list 'gnus-highlight-selected-summary)
928 "*Hook run after selecting an article in the summary buffer.
929 It is meant to be used for highlighting the article in some way. It
930 is not run if `gnus-visual' is nil."
931 :group 'gnus-summary-visual
934 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
935 "*A hook called before parsing the headers."
939 (defcustom gnus-exit-group-hook nil
940 "*A hook called when exiting summary mode.
941 This hook is not called from the non-updating exit commands like `Q'."
945 (defcustom gnus-summary-update-hook
946 (list 'gnus-summary-highlight-line)
947 "*A hook called when a summary line is changed.
948 The hook will not be called if `gnus-visual' is nil.
950 The default function `gnus-summary-highlight-line' will
951 highlight the line according to the `gnus-summary-highlight'
953 :group 'gnus-summary-visual
956 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
957 "*A hook called when an article is selected for the first time.
958 The hook is intended to mark an article as read (or unread)
959 automatically when it is selected."
960 :group 'gnus-summary-choose
963 (defcustom gnus-group-no-more-groups-hook nil
964 "*A hook run when returning to group mode having no more (unread) groups."
965 :group 'gnus-group-select
968 (defcustom gnus-ps-print-hook nil
969 "*A hook run before ps-printing something from Gnus."
973 (defcustom gnus-summary-article-move-hook nil
974 "*A hook called after an article is moved, copied, respooled, or crossposted."
979 (defcustom gnus-summary-article-delete-hook nil
980 "*A hook called after an article is deleted."
985 (defcustom gnus-summary-article-expire-hook nil
986 "*A hook called after an article is expired."
991 (defcustom gnus-summary-display-arrow
992 (and (fboundp 'display-graphic-p)
994 "*If non-nil, display an arrow highlighting the current article."
999 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1000 "Face used for highlighting the current article in the summary buffer."
1001 :group 'gnus-summary-visual
1004 (defvar gnus-tmp-downloaded nil)
1006 (defcustom gnus-summary-highlight
1007 '(((eq mark gnus-canceled-mark)
1008 . gnus-summary-cancelled)
1009 ((and uncached (> score default-high))
1010 . gnus-summary-high-undownloaded)
1011 ((and uncached (< score default-low))
1012 . gnus-summary-low-undownloaded)
1014 . gnus-summary-normal-undownloaded)
1015 ((and (> score default-high)
1016 (or (eq mark gnus-dormant-mark)
1017 (eq mark gnus-ticked-mark)))
1018 . gnus-summary-high-ticked)
1019 ((and (< score default-low)
1020 (or (eq mark gnus-dormant-mark)
1021 (eq mark gnus-ticked-mark)))
1022 . gnus-summary-low-ticked)
1023 ((or (eq mark gnus-dormant-mark)
1024 (eq mark gnus-ticked-mark))
1025 . gnus-summary-normal-ticked)
1026 ((and (> score default-high) (eq mark gnus-ancient-mark))
1027 . gnus-summary-high-ancient)
1028 ((and (< score default-low) (eq mark gnus-ancient-mark))
1029 . gnus-summary-low-ancient)
1030 ((eq mark gnus-ancient-mark)
1031 . gnus-summary-normal-ancient)
1032 ((and (> score default-high) (eq mark gnus-unread-mark))
1033 . gnus-summary-high-unread)
1034 ((and (< score default-low) (eq mark gnus-unread-mark))
1035 . gnus-summary-low-unread)
1036 ((eq mark gnus-unread-mark)
1037 . gnus-summary-normal-unread)
1038 ((> score default-high)
1039 . gnus-summary-high-read)
1040 ((< score default-low)
1041 . gnus-summary-low-read)
1043 . gnus-summary-normal-read))
1044 "*Controls the highlighting of summary buffer lines.
1046 A list of (FORM . FACE) pairs. When deciding how a a particular
1047 summary line should be displayed, each form is evaluated. The content
1048 of the face field after the first true form is used. You can change
1049 how those summary lines are displayed, by editing the face field.
1051 You can use the following variables in the FORM field.
1053 score: The article's score
1054 default: The default article score.
1055 default-high: The default score for high scored articles.
1056 default-low: The default score for low scored articles.
1057 below: The score below which articles are automatically marked as read.
1058 mark: The article's mark.
1059 uncached: Non-nil if the article is uncached."
1060 :group 'gnus-summary-visual
1061 :type '(repeat (cons (sexp :tag "Form" nil)
1064 (defcustom gnus-alter-header-function nil
1065 "Function called to allow alteration of article header structures.
1066 The function is called with one parameter, the article header vector,
1067 which it may alter in any way."
1068 :type '(choice (const :tag "None" nil)
1070 :group 'gnus-summary)
1072 (defvar gnus-decode-encoded-word-function
1073 (mime-find-field-decoder 'From 'nov)
1074 "Variable that says which function should be used to decode a string with encoded words.")
1076 (defcustom gnus-extra-headers '(To Newsgroups)
1077 "*Extra headers to parse."
1079 :group 'gnus-summary
1080 :type '(repeat symbol))
1082 (defcustom gnus-ignored-from-addresses
1083 (and user-mail-address (regexp-quote user-mail-address))
1084 "*Regexp of From headers that may be suppressed in favor of To headers."
1086 :group 'gnus-summary
1089 (defcustom gnus-summary-to-prefix "-> "
1090 "*String prefixed to the To field in the summary line when
1091 using `gnus-ignored-from-addresses'."
1093 :group 'gnus-summary
1096 (defcustom gnus-summary-newsgroup-prefix "=> "
1097 "*String prefixed to the Newsgroup field in the summary
1098 line when using `gnus-ignored-from-addresses'."
1100 :group 'gnus-summary
1103 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1104 "List of charsets that should be ignored.
1105 When these charsets are used in the \"charset\" parameter, the
1106 default charset will be used instead."
1108 :type '(repeat symbol)
1109 :group 'gnus-charset)
1111 (gnus-define-group-parameter
1115 "Return the ignored charsets of GROUP."
1116 :variable gnus-group-ignored-charsets-alist
1118 '(("alt\\.chinese\\.text" iso-8859-1))
1120 "Alist of regexps (to match group names) and charsets that should be ignored.
1121 When these charsets are used in the \"charset\" parameter, the
1122 default charset will be used instead."
1123 :variable-group gnus-charset
1124 :variable-type '(repeat (cons (regexp :tag "Group")
1126 :parameter-type '(choice :tag "Ignored charsets"
1129 :parameter-document "\
1130 List of charsets that should be ignored.
1132 When these charsets are used in the \"charset\" parameter, the
1133 default charset will be used instead.")
1135 (defcustom gnus-group-highlight-words-alist nil
1136 "Alist of group regexps and highlight regexps.
1137 This variable uses the same syntax as `gnus-emphasis-alist'."
1139 :type '(repeat (cons (regexp :tag "Group")
1140 (repeat (list (regexp :tag "Highlight regexp")
1141 (number :tag "Group for entire word" 0)
1142 (number :tag "Group for displayed part" 0)
1144 gnus-emphasis-highlight-words)))))
1145 :group 'gnus-summary-visual)
1147 (defcustom gnus-use-wheel nil
1148 "Use Intelli-mouse on summary movement"
1150 :group 'gnus-summary-maneuvering)
1152 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1153 "Amount to scroll messages by spinning the mouse wheel.
1154 This is actually a cons cell, where the first item is the amount to scroll
1155 on a normal wheel event, and the second is the amount to scroll when the
1156 wheel is moved with the shift key depressed."
1157 :type '(cons (integer :tag "Shift") integer)
1158 :group 'gnus-summary-maneuvering)
1160 (defcustom gnus-wheel-edge-resistance 2
1161 "How hard it should be to change the current article
1162 by moving the mouse over the edge of the article window."
1164 :group 'gnus-summary-maneuvering)
1166 (defcustom gnus-summary-show-article-charset-alist
1168 "Alist of number and charset.
1169 The article will be shown with the charset corresponding to the
1171 For example: ((1 . cn-gb-2312) (2 . big5))."
1173 :type '(repeat (cons (number :tag "Argument" 1)
1174 (symbol :tag "Charset")))
1175 :group 'gnus-charset)
1177 (defcustom gnus-preserve-marks t
1178 "Whether marks are preserved when moving, copying and respooling messages."
1181 :group 'gnus-summary-marks)
1183 (defcustom gnus-alter-articles-to-read-function nil
1184 "Function to be called to alter the list of articles to be selected."
1185 :type '(choice (const nil) function)
1186 :group 'gnus-summary)
1188 (defcustom gnus-orphan-score nil
1189 "*All orphans get this score added. Set in the score file."
1190 :group 'gnus-score-default
1191 :type '(choice (const nil)
1194 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1195 "*A regexp to match MIME parts when saving multiple parts of a
1196 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1197 This regexp will be used by default when prompting the user for which
1198 type of files to save."
1199 :group 'gnus-summary
1202 (defcustom gnus-read-all-available-headers nil
1203 "Whether Gnus should parse all headers made available to it.
1204 This is mostly relevant for slow back ends where the user may
1205 wish to widen the summary buffer to include all headers
1206 that were fetched. Say, for nnultimate groups."
1208 :group 'gnus-summary
1209 :type '(choice boolean regexp))
1211 (defcustom gnus-summary-muttprint-program "muttprint"
1212 "Command (and optional arguments) used to run Muttprint."
1214 :group 'gnus-summary
1217 (defcustom gnus-article-loose-mime t
1218 "If non-nil, don't require MIME-Version header.
1219 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1220 supply the MIME-Version header or deliberately strip it from the mail.
1221 If non-nil (the default), Gnus will treat some articles as MIME
1222 even if the MIME-Version header is missing."
1225 :group 'gnus-article-mime)
1227 (defcustom gnus-article-emulate-mime t
1228 "If non-nil, use MIME emulation for uuencode and the like.
1229 This means that Gnus will search message bodies for text that look
1230 like uuencoded bits, yEncoded bits, and so on, and present that using
1231 the normal Gnus MIME machinery."
1234 :group 'gnus-article-mime)
1236 ;;; Internal variables
1238 (defvar gnus-summary-display-cache nil)
1239 (defvar gnus-article-mime-handles nil)
1240 (defvar gnus-article-decoded-p nil)
1241 (defvar gnus-article-charset nil)
1242 (defvar gnus-article-ignored-charsets nil)
1243 (defvar gnus-scores-exclude-files nil)
1244 (defvar gnus-page-broken nil)
1246 (defvar gnus-original-article nil)
1247 (defvar gnus-article-internal-prepare-hook nil)
1248 (defvar gnus-newsgroup-process-stack nil)
1250 (defvar gnus-thread-indent-array nil)
1251 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1252 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1253 "Function called to sort the articles within a thread after it has been gathered together.")
1255 (defvar gnus-summary-save-parts-type-history nil)
1256 (defvar gnus-summary-save-parts-last-directory nil)
1258 ;; Avoid highlighting in kill files.
1259 (defvar gnus-summary-inhibit-highlight nil)
1260 (defvar gnus-newsgroup-selected-overlay nil)
1261 (defvar gnus-inhibit-limiting nil)
1262 (defvar gnus-newsgroup-adaptive-score-file nil)
1263 (defvar gnus-current-score-file nil)
1264 (defvar gnus-current-move-group nil)
1265 (defvar gnus-current-copy-group nil)
1266 (defvar gnus-current-crosspost-group nil)
1267 (defvar gnus-newsgroup-display nil)
1269 (defvar gnus-newsgroup-dependencies nil)
1270 (defvar gnus-newsgroup-adaptive nil)
1271 (defvar gnus-summary-display-article-function nil)
1272 (defvar gnus-summary-highlight-line-function nil
1273 "Function called after highlighting a summary line.")
1275 (defvar gnus-summary-line-format-alist
1276 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1277 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1278 (?s gnus-tmp-subject-or-nil ?s)
1279 (?n gnus-tmp-name ?s)
1280 (?A (std11-address-string
1281 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1282 (?a (or (std11-full-name-string
1283 (car (mime-entity-read-field gnus-tmp-header 'From)))
1285 (?F gnus-tmp-from ?s)
1286 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1287 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1288 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1289 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1290 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1291 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1292 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1293 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1294 (?L gnus-tmp-lines ?s)
1295 (?O gnus-tmp-downloaded ?c)
1296 (?I gnus-tmp-indentation ?s)
1297 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1298 (?R gnus-tmp-replied ?c)
1299 (?\[ gnus-tmp-opening-bracket ?c)
1300 (?\] gnus-tmp-closing-bracket ?c)
1301 (?\> (make-string gnus-tmp-level ? ) ?s)
1302 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1303 (?i gnus-tmp-score ?d)
1304 (?z gnus-tmp-score-char ?c)
1305 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1306 (?U gnus-tmp-unread ?c)
1307 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1309 (?t (gnus-summary-number-of-articles-in-thread
1310 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1312 (?e (gnus-summary-number-of-articles-in-thread
1313 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1315 (?u gnus-tmp-user-defined ?s)
1316 (?P (gnus-pick-line-number) ?d)
1317 (?B gnus-tmp-thread-tree-header-string ?s)
1318 (user-date (gnus-user-date
1319 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1320 "An alist of format specifications that can appear in summary lines.
1321 These are paired with what variables they correspond with, along with
1322 the type of the variable (string, integer, character, etc).")
1324 (defvar gnus-summary-dummy-line-format-alist
1325 `((?S gnus-tmp-subject ?s)
1326 (?N gnus-tmp-number ?d)
1327 (?u gnus-tmp-user-defined ?s)))
1329 (defvar gnus-summary-mode-line-format-alist
1330 `((?G gnus-tmp-group-name ?s)
1331 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1332 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1333 (?A gnus-tmp-article-number ?d)
1334 (?Z gnus-tmp-unread-and-unselected ?s)
1335 (?V gnus-version ?s)
1336 (?U gnus-tmp-unread-and-unticked ?d)
1337 (?S gnus-tmp-subject ?s)
1338 (?e gnus-tmp-unselected ?d)
1339 (?u gnus-tmp-user-defined ?s)
1340 (?d (length gnus-newsgroup-dormant) ?d)
1341 (?t (length gnus-newsgroup-marked) ?d)
1342 (?h (length gnus-newsgroup-spam-marked) ?d)
1343 (?r (length gnus-newsgroup-reads) ?d)
1344 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1345 (?E gnus-newsgroup-expunged-tally ?d)
1346 (?s (gnus-current-score-file-nondirectory) ?s)))
1348 (defvar gnus-last-search-regexp nil
1349 "Default regexp for article search command.")
1351 (defvar gnus-summary-search-article-matched-data nil
1352 "Last matched data of article search command. It is the local variable
1353 in `gnus-article-buffer' which consists of the list of start position,
1354 end position and text.")
1356 (defvar gnus-last-shell-command nil
1357 "Default shell command on article.")
1359 (defvar gnus-newsgroup-agentized nil
1360 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1361 (defvar gnus-newsgroup-begin nil)
1362 (defvar gnus-newsgroup-end nil)
1363 (defvar gnus-newsgroup-last-rmail nil)
1364 (defvar gnus-newsgroup-last-mail nil)
1365 (defvar gnus-newsgroup-last-folder nil)
1366 (defvar gnus-newsgroup-last-file nil)
1367 (defvar gnus-newsgroup-auto-expire nil)
1368 (defvar gnus-newsgroup-active nil)
1370 (defvar gnus-newsgroup-data nil)
1371 (defvar gnus-newsgroup-data-reverse nil)
1372 (defvar gnus-newsgroup-limit nil)
1373 (defvar gnus-newsgroup-limits nil)
1374 (defvar gnus-summary-use-undownloaded-faces nil)
1376 (defvar gnus-newsgroup-unreads nil
1377 "Sorted list of unread articles in the current newsgroup.")
1379 (defvar gnus-newsgroup-unselected nil
1380 "Sorted list of unselected unread articles in the current newsgroup.")
1382 (defvar gnus-newsgroup-reads nil
1383 "Alist of read articles and article marks in the current newsgroup.")
1385 (defvar gnus-newsgroup-expunged-tally nil)
1387 (defvar gnus-newsgroup-marked nil
1388 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1390 (defvar gnus-newsgroup-spam-marked nil
1391 "List of ranges of articles that have been marked as spam.")
1393 (defvar gnus-newsgroup-killed nil
1394 "List of ranges of articles that have been through the scoring process.")
1396 (defvar gnus-newsgroup-cached nil
1397 "Sorted list of articles that come from the article cache.")
1399 (defvar gnus-newsgroup-saved nil
1400 "List of articles that have been saved.")
1402 (defvar gnus-newsgroup-kill-headers nil)
1404 (defvar gnus-newsgroup-replied nil
1405 "List of articles that have been replied to in the current newsgroup.")
1407 (defvar gnus-newsgroup-forwarded nil
1408 "List of articles that have been forwarded in the current newsgroup.")
1410 (defvar gnus-newsgroup-recent nil
1411 "List of articles that have are recent in the current newsgroup.")
1413 (defvar gnus-newsgroup-expirable nil
1414 "Sorted list of articles in the current newsgroup that can be expired.")
1416 (defvar gnus-newsgroup-processable nil
1417 "List of articles in the current newsgroup that can be processed.")
1419 (defvar gnus-newsgroup-downloadable nil
1420 "Sorted list of articles in the current newsgroup that can be processed.")
1422 (defvar gnus-newsgroup-unfetched nil
1423 "Sorted list of articles in the current newsgroup whose headers have
1424 not been fetched into the agent.
1426 This list will always be a subset of gnus-newsgroup-undownloaded.")
1428 (defvar gnus-newsgroup-undownloaded nil
1429 "List of articles in the current newsgroup that haven't been downloaded.")
1431 (defvar gnus-newsgroup-unsendable nil
1432 "List of articles in the current newsgroup that won't be sent.")
1434 (defvar gnus-newsgroup-bookmarks nil
1435 "List of articles in the current newsgroup that have bookmarks.")
1437 (defvar gnus-newsgroup-dormant nil
1438 "Sorted list of dormant articles in the current newsgroup.")
1440 (defvar gnus-newsgroup-unseen nil
1441 "List of unseen articles in the current newsgroup.")
1443 (defvar gnus-newsgroup-seen nil
1444 "Range of seen articles in the current newsgroup.")
1446 (defvar gnus-newsgroup-articles nil
1447 "List of articles in the current newsgroup.")
1449 (defvar gnus-newsgroup-scored nil
1450 "List of scored articles in the current newsgroup.")
1452 (defvar gnus-newsgroup-incorporated nil
1453 "List of incorporated articles in the current newsgroup.")
1455 (defvar gnus-newsgroup-headers nil
1456 "List of article headers in the current newsgroup.")
1458 (defvar gnus-newsgroup-threads nil)
1460 (defvar gnus-newsgroup-prepared nil
1461 "Whether the current group has been prepared properly.")
1463 (defvar gnus-newsgroup-ancient nil
1464 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1466 (defvar gnus-newsgroup-sparse nil)
1468 (defvar gnus-current-article nil)
1469 (defvar gnus-article-current nil)
1470 (defvar gnus-current-headers nil)
1471 (defvar gnus-have-all-headers nil)
1472 (defvar gnus-last-article nil)
1473 (defvar gnus-newsgroup-history nil)
1474 (defvar gnus-newsgroup-charset nil)
1475 (defvar gnus-newsgroup-ephemeral-charset nil)
1476 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1478 (defvar gnus-article-before-search nil)
1480 (defvar gnus-summary-local-variables
1481 '(gnus-newsgroup-name
1482 gnus-newsgroup-begin gnus-newsgroup-end
1483 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1484 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1485 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1486 gnus-newsgroup-unselected gnus-newsgroup-marked
1487 gnus-newsgroup-spam-marked
1488 gnus-newsgroup-reads gnus-newsgroup-saved
1489 gnus-newsgroup-replied gnus-newsgroup-forwarded
1490 gnus-newsgroup-recent
1491 gnus-newsgroup-expirable
1492 gnus-newsgroup-processable gnus-newsgroup-killed
1493 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1494 gnus-newsgroup-unfetched
1495 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1496 gnus-newsgroup-seen gnus-newsgroup-articles
1497 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1498 gnus-newsgroup-headers gnus-newsgroup-threads
1499 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1500 gnus-current-article gnus-current-headers gnus-have-all-headers
1501 gnus-last-article gnus-article-internal-prepare-hook
1502 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1503 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1504 gnus-thread-expunge-below
1505 gnus-score-alist gnus-current-score-file
1506 (gnus-summary-expunge-below . global)
1507 (gnus-summary-mark-below . global)
1508 (gnus-orphan-score . global)
1509 gnus-newsgroup-active gnus-scores-exclude-files
1510 gnus-newsgroup-history gnus-newsgroup-ancient
1511 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1512 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1513 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1514 (gnus-newsgroup-expunged-tally . 0)
1515 gnus-cache-removable-articles gnus-newsgroup-cached
1516 gnus-newsgroup-data gnus-newsgroup-data-reverse
1517 gnus-newsgroup-limit gnus-newsgroup-limits
1518 gnus-newsgroup-charset gnus-newsgroup-display
1519 gnus-summary-use-undownloaded-faces
1520 gnus-newsgroup-incorporated)
1521 "Variables that are buffer-local to the summary buffers.")
1523 (defvar gnus-newsgroup-variables nil
1524 "A list of variables that have separate values in different newsgroups.
1525 A list of newsgroup (summary buffer) local variables, or cons of
1526 variables and their default expressions to be evalled (when the default
1527 values are not nil), that should be made global while the summary buffer
1530 Note: The default expressions will be evaluated (using function `eval')
1531 before assignment to the local variable rather than just assigned to it.
1532 If the default expression is the symbol `global', that symbol will not
1533 be evaluated but the global value of the local variable will be used
1536 These variables can be used to set variables in the group parameters
1537 while still allowing them to affect operations done in other buffers.
1540 \(setq gnus-newsgroup-variables
1541 '(message-use-followup-to
1542 (gnus-visible-headers .
1543 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1546 ;; Byte-compiler warning.
1548 ;; Bind features so that require will believe that gnus-sum has
1549 ;; already been loaded (avoids infinite recursion)
1550 (let ((features (cons 'gnus-sum features)))
1551 ;; Several of the declarations in gnus-sum are needed to load the
1552 ;; following files. Right now, these definitions have been
1553 ;; compiled but not defined (evaluated). We could either do a
1554 ;; eval-and-compile about all of the declarations or evaluate the
1556 (if (boundp 'gnus-newsgroup-variables)
1558 (load "gnus-sum.el" t t t))
1560 (require 'gnus-art)))
1562 ;; Subject simplification.
1564 (defun gnus-simplify-whitespace (str)
1565 "Remove excessive whitespace from STR."
1567 (while (string-match "[ \t][ \t]+" str)
1568 (setq str (concat (substring str 0 (match-beginning 0))
1570 (substring str (match-end 0)))))
1572 (when (string-match "^[ \t]+" str)
1573 (setq str (substring str (match-end 0))))
1575 (when (string-match "[ \t]+$" str)
1576 (setq str (substring str 0 (match-beginning 0))))
1579 (defun gnus-simplify-all-whitespace (str)
1580 "Remove all whitespace from STR."
1581 (while (string-match "[ \t\n]+" str)
1582 (setq str (replace-match "" nil nil str)))
1585 (defsubst gnus-simplify-subject-re (subject)
1586 "Remove \"Re:\" from subject lines."
1587 (if (string-match message-subject-re-regexp subject)
1588 (substring subject (match-end 0))
1591 (defun gnus-simplify-subject (subject &optional re-only)
1592 "Remove `Re:' and words in parentheses.
1593 If RE-ONLY is non-nil, strip leading `Re:'s only."
1594 (let ((case-fold-search t)) ;Ignore case.
1595 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1596 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1597 (setq subject (substring subject (match-end 0))))
1598 ;; Remove uninteresting prefixes.
1599 (when (and (not re-only)
1600 gnus-simplify-ignored-prefixes
1601 (string-match gnus-simplify-ignored-prefixes subject))
1602 (setq subject (substring subject (match-end 0))))
1603 ;; Remove words in parentheses from end.
1605 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1606 (setq subject (substring subject 0 (match-beginning 0)))))
1607 ;; Return subject string.
1610 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1612 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1613 (goto-char (point-min))
1614 (while (re-search-forward regexp nil t)
1615 (replace-match (or newtext ""))))
1617 (defun gnus-simplify-buffer-fuzzy ()
1618 "Simplify string in the buffer fuzzily.
1619 The string in the accessible portion of the current buffer is simplified.
1620 It is assumed to be a single-line subject.
1621 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1622 matter is removed. Additional things can be deleted by setting
1623 `gnus-simplify-subject-fuzzy-regexp'."
1624 (let ((case-fold-search t)
1626 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1628 (while (not (eq modified-tick (buffer-modified-tick)))
1629 (setq modified-tick (buffer-modified-tick))
1631 ((listp gnus-simplify-subject-fuzzy-regexp)
1632 (mapcar 'gnus-simplify-buffer-fuzzy-step
1633 gnus-simplify-subject-fuzzy-regexp))
1634 (gnus-simplify-subject-fuzzy-regexp
1635 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1636 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1637 (gnus-simplify-buffer-fuzzy-step
1638 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1639 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1641 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1642 (gnus-simplify-buffer-fuzzy-step " +" " ")
1643 (gnus-simplify-buffer-fuzzy-step " $")
1644 (gnus-simplify-buffer-fuzzy-step "^ +")))
1646 (defun gnus-simplify-subject-fuzzy (subject)
1647 "Simplify a subject string fuzzily.
1648 See `gnus-simplify-buffer-fuzzy' for details."
1650 (gnus-set-work-buffer)
1651 (let ((case-fold-search t))
1652 ;; Remove uninteresting prefixes.
1653 (when (and gnus-simplify-ignored-prefixes
1654 (string-match gnus-simplify-ignored-prefixes subject))
1655 (setq subject (substring subject (match-end 0))))
1657 (inline (gnus-simplify-buffer-fuzzy))
1660 (defsubst gnus-simplify-subject-fully (subject)
1661 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1663 (gnus-simplify-subject-functions
1664 (gnus-map-function gnus-simplify-subject-functions subject))
1665 ((null gnus-summary-gather-subject-limit)
1666 (gnus-simplify-subject-re subject))
1667 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1668 (gnus-simplify-subject-fuzzy subject))
1669 ((numberp gnus-summary-gather-subject-limit)
1670 (gnus-limit-string (gnus-simplify-subject-re subject)
1671 gnus-summary-gather-subject-limit))
1675 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1676 "Check whether two subjects are equal.
1677 If optional argument SIMPLE-FIRST is t, first argument is already
1680 ((null simple-first)
1681 (equal (gnus-simplify-subject-fully s1)
1682 (gnus-simplify-subject-fully s2)))
1685 (gnus-simplify-subject-fully s2)))))
1687 (defun gnus-summary-bubble-group ()
1688 "Increase the score of the current group.
1689 This is a handy function to add to `gnus-summary-exit-hook' to
1690 increase the score of each group you read."
1691 (gnus-group-add-score gnus-newsgroup-name))
1695 ;;; Gnus summary mode
1698 (put 'gnus-summary-mode 'mode-class 'special)
1700 (defvar gnus-article-commands-menu)
1702 ;; Non-orthogonal keys
1704 (gnus-define-keys gnus-summary-mode-map
1705 " " gnus-summary-next-page
1706 "\177" gnus-summary-prev-page
1707 [delete] gnus-summary-prev-page
1708 [backspace] gnus-summary-prev-page
1709 "\r" gnus-summary-scroll-up
1710 "\M-\r" gnus-summary-scroll-down
1711 "n" gnus-summary-next-unread-article
1712 "p" gnus-summary-prev-unread-article
1713 "N" gnus-summary-next-article
1714 "P" gnus-summary-prev-article
1715 "\M-\C-n" gnus-summary-next-same-subject
1716 "\M-\C-p" gnus-summary-prev-same-subject
1717 "\M-n" gnus-summary-next-unread-subject
1718 "\M-p" gnus-summary-prev-unread-subject
1719 "." gnus-summary-first-unread-article
1720 "," gnus-summary-best-unread-article
1721 "\M-s" gnus-summary-search-article-forward
1722 "\M-r" gnus-summary-search-article-backward
1723 "<" gnus-summary-beginning-of-article
1724 ">" gnus-summary-end-of-article
1725 "j" gnus-summary-goto-article
1726 "^" gnus-summary-refer-parent-article
1727 "\M-^" gnus-summary-refer-article
1728 "u" gnus-summary-tick-article-forward
1729 "!" gnus-summary-tick-article-forward
1730 "U" gnus-summary-tick-article-backward
1731 "d" gnus-summary-mark-as-read-forward
1732 "D" gnus-summary-mark-as-read-backward
1733 "E" gnus-summary-mark-as-expirable
1734 "\M-u" gnus-summary-clear-mark-forward
1735 "\M-U" gnus-summary-clear-mark-backward
1736 "k" gnus-summary-kill-same-subject-and-select
1737 "\C-k" gnus-summary-kill-same-subject
1738 "\M-\C-k" gnus-summary-kill-thread
1739 "\M-\C-l" gnus-summary-lower-thread
1740 "e" gnus-summary-edit-article
1741 "#" gnus-summary-mark-as-processable
1742 "\M-#" gnus-summary-unmark-as-processable
1743 "\M-\C-t" gnus-summary-toggle-threads
1744 "\M-\C-s" gnus-summary-show-thread
1745 "\M-\C-h" gnus-summary-hide-thread
1746 "\M-\C-f" gnus-summary-next-thread
1747 "\M-\C-b" gnus-summary-prev-thread
1748 [(meta down)] gnus-summary-next-thread
1749 [(meta up)] gnus-summary-prev-thread
1750 "\M-\C-u" gnus-summary-up-thread
1751 "\M-\C-d" gnus-summary-down-thread
1752 "&" gnus-summary-execute-command
1753 "c" gnus-summary-catchup-and-exit
1754 "\C-w" gnus-summary-mark-region-as-read
1755 "\C-t" gnus-summary-toggle-truncation
1756 "?" gnus-summary-mark-as-dormant
1757 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1758 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1759 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1760 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1761 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1762 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1763 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1764 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1765 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1766 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1767 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1768 "=" gnus-summary-expand-window
1769 "\C-x\C-s" gnus-summary-reselect-current-group
1770 "\M-g" gnus-summary-rescan-group
1771 "w" gnus-summary-stop-page-breaking
1772 "\C-c\C-r" gnus-summary-caesar-message
1773 "\M-t" gnus-summary-toggle-mime
1774 "f" gnus-summary-followup
1775 "F" gnus-summary-followup-with-original
1776 "C" gnus-summary-cancel-article
1777 "r" gnus-summary-reply
1778 "R" gnus-summary-reply-with-original
1779 "\C-c\C-f" gnus-summary-mail-forward
1780 "o" gnus-summary-save-article
1781 "\C-o" gnus-summary-save-article-mail
1782 "|" gnus-summary-pipe-output
1783 "\M-k" gnus-summary-edit-local-kill
1784 "\M-K" gnus-summary-edit-global-kill
1786 "\C-c\C-d" gnus-summary-describe-group
1787 "q" gnus-summary-exit
1788 "Q" gnus-summary-exit-no-update
1789 "\C-c\C-i" gnus-info-find-node
1790 gnus-mouse-2 gnus-mouse-pick-article
1791 [follow-link] mouse-face
1792 "m" gnus-summary-mail-other-window
1793 "a" gnus-summary-post-news
1794 "i" gnus-summary-news-other-window
1795 "x" gnus-summary-limit-to-unread
1796 "s" gnus-summary-isearch-article
1797 "t" gnus-summary-toggle-header
1798 "g" gnus-summary-show-article
1799 "l" gnus-summary-goto-last-article
1800 "v" gnus-summary-preview-mime-message
1801 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1802 "\C-d" gnus-summary-enter-digest-group
1803 "\M-\C-d" gnus-summary-read-document
1804 "\M-\C-e" gnus-summary-edit-parameters
1805 "\M-\C-a" gnus-summary-customize-parameters
1807 "\C-c\C-n" gnus-namazu-search
1808 "*" gnus-cache-enter-article
1809 "\M-*" gnus-cache-remove-article
1810 "\M-&" gnus-summary-universal-argument
1811 "\C-l" gnus-recenter
1812 "I" gnus-summary-increase-score
1813 "L" gnus-summary-lower-score
1814 "\M-i" gnus-symbolic-argument
1815 "h" gnus-summary-select-article-buffer
1817 "V" gnus-summary-score-map
1818 "X" gnus-uu-extract-map
1819 "S" gnus-summary-send-map)
1821 ;; Sort of orthogonal keymap
1822 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1823 "t" gnus-summary-tick-article-forward
1824 "!" gnus-summary-tick-article-forward
1825 "d" gnus-summary-mark-as-read-forward
1826 "r" gnus-summary-mark-as-read-forward
1827 "c" gnus-summary-clear-mark-forward
1828 " " gnus-summary-clear-mark-forward
1829 "e" gnus-summary-mark-as-expirable
1830 "x" gnus-summary-mark-as-expirable
1831 "?" gnus-summary-mark-as-dormant
1832 "b" gnus-summary-set-bookmark
1833 "B" gnus-summary-remove-bookmark
1834 "#" gnus-summary-mark-as-processable
1835 "\M-#" gnus-summary-unmark-as-processable
1836 "S" gnus-summary-limit-include-expunged
1837 "C" gnus-summary-catchup
1838 "H" gnus-summary-catchup-to-here
1839 "h" gnus-summary-catchup-from-here
1840 "\C-c" gnus-summary-catchup-all
1841 "k" gnus-summary-kill-same-subject-and-select
1842 "K" gnus-summary-kill-same-subject
1843 "P" gnus-uu-mark-map)
1845 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1846 "c" gnus-summary-clear-above
1847 "u" gnus-summary-tick-above
1848 "m" gnus-summary-mark-above
1849 "k" gnus-summary-kill-below)
1851 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1852 "/" gnus-summary-limit-to-subject
1853 "n" gnus-summary-limit-to-articles
1854 "w" gnus-summary-pop-limit
1855 "s" gnus-summary-limit-to-subject
1856 "a" gnus-summary-limit-to-author
1857 "u" gnus-summary-limit-to-unread
1858 "m" gnus-summary-limit-to-marks
1859 "M" gnus-summary-limit-exclude-marks
1860 "v" gnus-summary-limit-to-score
1861 "*" gnus-summary-limit-include-cached
1862 "D" gnus-summary-limit-include-dormant
1863 "T" gnus-summary-limit-include-thread
1864 "d" gnus-summary-limit-exclude-dormant
1865 "t" gnus-summary-limit-to-age
1866 "." gnus-summary-limit-to-unseen
1867 "x" gnus-summary-limit-to-extra
1868 "p" gnus-summary-limit-to-display-predicate
1869 "E" gnus-summary-limit-include-expunged
1870 "c" gnus-summary-limit-exclude-childless-dormant
1871 "C" gnus-summary-limit-mark-excluded-as-read
1872 "o" gnus-summary-insert-old-articles
1873 "N" gnus-summary-insert-new-articles
1874 "r" gnus-summary-limit-to-replied
1875 "R" gnus-summary-limit-to-recipient)
1877 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1878 "n" gnus-summary-next-unread-article
1879 "p" gnus-summary-prev-unread-article
1880 "N" gnus-summary-next-article
1881 "P" gnus-summary-prev-article
1882 "\C-n" gnus-summary-next-same-subject
1883 "\C-p" gnus-summary-prev-same-subject
1884 "\M-n" gnus-summary-next-unread-subject
1885 "\M-p" gnus-summary-prev-unread-subject
1886 "f" gnus-summary-first-unread-article
1887 "b" gnus-summary-best-unread-article
1888 "j" gnus-summary-goto-article
1889 "g" gnus-summary-goto-subject
1890 "l" gnus-summary-goto-last-article
1891 "o" gnus-summary-pop-article)
1893 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1894 "k" gnus-summary-kill-thread
1895 "l" gnus-summary-lower-thread
1896 "i" gnus-summary-raise-thread
1897 "T" gnus-summary-toggle-threads
1898 "t" gnus-summary-rethread-current
1899 "^" gnus-summary-reparent-thread
1900 "s" gnus-summary-show-thread
1901 "S" gnus-summary-show-all-threads
1902 "h" gnus-summary-hide-thread
1903 "H" gnus-summary-hide-all-threads
1904 "n" gnus-summary-next-thread
1905 "p" gnus-summary-prev-thread
1906 "u" gnus-summary-up-thread
1907 "o" gnus-summary-top-thread
1908 "d" gnus-summary-down-thread
1909 "#" gnus-uu-mark-thread
1910 "\M-#" gnus-uu-unmark-thread)
1912 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1913 "g" gnus-summary-prepare
1914 "c" gnus-summary-insert-cached-articles
1915 "d" gnus-summary-insert-dormant-articles)
1917 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1918 "c" gnus-summary-catchup-and-exit
1919 "C" gnus-summary-catchup-all-and-exit
1920 "E" gnus-summary-exit-no-update
1921 "J" gnus-summary-jump-to-other-group
1922 "Q" gnus-summary-exit
1923 "Z" gnus-summary-exit
1924 "n" gnus-summary-catchup-and-goto-next-group
1925 "R" gnus-summary-reselect-current-group
1926 "G" gnus-summary-rescan-group
1927 "N" gnus-summary-next-group
1928 "s" gnus-summary-save-newsrc
1929 "P" gnus-summary-prev-group)
1931 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1932 " " gnus-summary-next-page
1933 "n" gnus-summary-next-page
1934 "\177" gnus-summary-prev-page
1935 [delete] gnus-summary-prev-page
1936 "p" gnus-summary-prev-page
1937 "\r" gnus-summary-scroll-up
1938 "\M-\r" gnus-summary-scroll-down
1939 "<" gnus-summary-beginning-of-article
1940 ">" gnus-summary-end-of-article
1941 "b" gnus-summary-beginning-of-article
1942 "e" gnus-summary-end-of-article
1943 "^" gnus-summary-refer-parent-article
1944 "r" gnus-summary-refer-parent-article
1945 "D" gnus-summary-enter-digest-group
1946 "R" gnus-summary-refer-references
1947 "T" gnus-summary-refer-thread
1948 "g" gnus-summary-show-article
1949 "s" gnus-summary-isearch-article
1950 "P" gnus-summary-print-article
1951 "M" gnus-mailing-list-insinuate
1952 "t" gnus-article-babel)
1954 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1955 "b" gnus-article-add-buttons
1956 "B" gnus-article-add-buttons-to-head
1957 "o" gnus-article-treat-overstrike
1958 "e" gnus-article-emphasize
1959 "w" gnus-article-fill-cited-article
1960 "Q" gnus-article-fill-long-lines
1961 "C" gnus-article-capitalize-sentences
1962 "c" gnus-article-remove-cr
1963 "Z" gnus-article-decode-HZ
1964 "A" gnus-article-treat-ansi-sequences
1965 "h" gnus-article-wash-html
1966 "u" gnus-article-unsplit-urls
1967 "f" gnus-article-display-x-face
1968 "l" gnus-summary-stop-page-breaking
1969 "r" gnus-summary-caesar-message
1970 "m" gnus-summary-morse-message
1971 "t" gnus-summary-toggle-header
1972 "g" gnus-treat-smiley
1973 "v" gnus-summary-verbose-headers
1974 "m" gnus-summary-toggle-mime
1975 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1976 "p" gnus-article-verify-x-pgp-sig
1977 "d" gnus-article-treat-dumbquotes
1978 "i" gnus-summary-idna-message)
1980 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1981 ;; mnemonic: deuglif*Y*
1982 "u" gnus-article-outlook-unwrap-lines
1983 "a" gnus-article-outlook-repair-attribution
1984 "c" gnus-article-outlook-rearrange-citation
1985 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1987 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1988 "a" gnus-article-hide
1989 "h" gnus-article-hide-headers
1990 "b" gnus-article-hide-boring-headers
1991 "s" gnus-article-hide-signature
1992 "c" gnus-article-hide-citation
1993 "C" gnus-article-hide-citation-in-followups
1994 "l" gnus-article-hide-list-identifiers
1995 "B" gnus-article-strip-banner
1996 "P" gnus-article-hide-pem
1997 "\C-c" gnus-article-hide-citation-maybe)
1999 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2000 "a" gnus-article-highlight
2001 "h" gnus-article-highlight-headers
2002 "c" gnus-article-highlight-citation
2003 "s" gnus-article-highlight-signature)
2005 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2006 "f" gnus-article-treat-fold-headers
2007 "u" gnus-article-treat-unfold-headers
2008 "n" gnus-article-treat-fold-newsgroups)
2010 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2011 "x" gnus-article-display-x-face
2012 "d" gnus-article-display-face
2013 "s" gnus-treat-smiley
2014 "D" gnus-article-remove-images
2015 "f" gnus-treat-from-picon
2016 "m" gnus-treat-mail-picon
2017 "n" gnus-treat-newsgroups-picon)
2019 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2020 "z" gnus-article-date-ut
2021 "u" gnus-article-date-ut
2022 "l" gnus-article-date-local
2023 "p" gnus-article-date-english
2024 "e" gnus-article-date-lapsed
2025 "o" gnus-article-date-original
2026 "i" gnus-article-date-iso8601
2027 "s" gnus-article-date-user)
2029 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2030 "t" gnus-article-remove-trailing-blank-lines
2031 "l" gnus-article-strip-leading-blank-lines
2032 "m" gnus-article-strip-multiple-blank-lines
2033 "a" gnus-article-strip-blank-lines
2034 "A" gnus-article-strip-all-blank-lines
2035 "s" gnus-article-strip-leading-space
2036 "e" gnus-article-strip-trailing-space
2037 "w" gnus-article-remove-leading-whitespace)
2039 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2041 "f" gnus-summary-fetch-faq
2042 "d" gnus-summary-describe-group
2043 "h" gnus-summary-describe-briefly
2044 "i" gnus-info-find-node
2045 "c" gnus-group-fetch-charter
2046 "C" gnus-group-fetch-control)
2048 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2049 "e" gnus-summary-expire-articles
2050 "\M-\C-e" gnus-summary-expire-articles-now
2051 "\177" gnus-summary-delete-article
2052 [delete] gnus-summary-delete-article
2053 [backspace] gnus-summary-delete-article
2054 "m" gnus-summary-move-article
2055 "r" gnus-summary-respool-article
2056 "w" gnus-summary-edit-article
2057 "c" gnus-summary-copy-article
2058 "B" gnus-summary-crosspost-article
2059 "q" gnus-summary-respool-query
2060 "t" gnus-summary-respool-trace
2061 "i" gnus-summary-import-article
2062 "I" gnus-summary-create-article
2063 "p" gnus-summary-article-posted-p)
2065 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2066 "o" gnus-summary-save-article
2067 "m" gnus-summary-save-article-mail
2068 "F" gnus-summary-write-article-file
2069 "r" gnus-summary-save-article-rmail
2070 "f" gnus-summary-save-article-file
2071 "b" gnus-summary-save-article-body-file
2072 "h" gnus-summary-save-article-folder
2073 "v" gnus-summary-save-article-vm
2074 "p" gnus-summary-pipe-output
2075 "P" gnus-summary-muttprint
2076 "s" gnus-soup-add-article)
2078 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2079 "b" gnus-summary-display-buttonized
2080 "m" gnus-summary-repair-multipart
2081 "v" gnus-article-view-part
2082 "o" gnus-article-save-part
2083 "c" gnus-article-copy-part
2084 "C" gnus-article-view-part-as-charset
2085 "e" gnus-article-view-part-externally
2086 "E" gnus-article-encrypt-body
2087 "i" gnus-article-inline-part
2088 "|" gnus-article-pipe-part)
2090 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2091 "p" gnus-summary-mark-as-processable
2092 "u" gnus-summary-unmark-as-processable
2093 "U" gnus-summary-unmark-all-processable
2094 "v" gnus-uu-mark-over
2095 "s" gnus-uu-mark-series
2096 "r" gnus-uu-mark-region
2097 "g" gnus-uu-unmark-region
2098 "R" gnus-uu-mark-by-regexp
2099 "G" gnus-uu-unmark-by-regexp
2100 "t" gnus-uu-mark-thread
2101 "T" gnus-uu-unmark-thread
2102 "a" gnus-uu-mark-all
2103 "b" gnus-uu-mark-buffer
2104 "S" gnus-uu-mark-sparse
2105 "k" gnus-summary-kill-process-mark
2106 "y" gnus-summary-yank-process-mark
2107 "w" gnus-summary-save-process-mark
2108 "i" gnus-uu-invert-processable)
2110 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2111 ;;"x" gnus-uu-extract-any
2112 "m" gnus-summary-save-parts
2113 "u" gnus-uu-decode-uu
2114 "U" gnus-uu-decode-uu-and-save
2115 "s" gnus-uu-decode-unshar
2116 "S" gnus-uu-decode-unshar-and-save
2117 "o" gnus-uu-decode-save
2118 "O" gnus-uu-decode-save
2119 "b" gnus-uu-decode-binhex
2120 "B" gnus-uu-decode-binhex
2121 "p" gnus-uu-decode-postscript
2122 "P" gnus-uu-decode-postscript-and-save)
2125 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2126 "u" gnus-uu-decode-uu-view
2127 "U" gnus-uu-decode-uu-and-save-view
2128 "s" gnus-uu-decode-unshar-view
2129 "S" gnus-uu-decode-unshar-and-save-view
2130 "o" gnus-uu-decode-save-view
2131 "O" gnus-uu-decode-save-view
2132 "b" gnus-uu-decode-binhex-view
2133 "B" gnus-uu-decode-binhex-view
2134 "p" gnus-uu-decode-postscript-view
2135 "P" gnus-uu-decode-postscript-and-save-view)
2137 (defvar gnus-article-post-menu nil)
2139 (defconst gnus-summary-menu-maxlen 20)
2141 (defun gnus-summary-menu-split (menu)
2142 ;; If we have lots of elements, divide them into groups of 20
2143 ;; and make a pane (or submenu) for each one.
2144 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2145 (let ((menu menu) sublists next
2148 ;; Pull off the next gnus-summary-menu-maxlen elements
2149 ;; and make them the next element of sublist.
2150 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2152 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2154 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2155 (aref (car (last menu)) 0)) menu)
2159 (nreverse sublists))
2160 ;; Few elements--put them all in one pane.
2163 (defun gnus-summary-make-menu-bar ()
2164 (gnus-turn-off-edit-menu 'summary)
2166 (unless (boundp 'gnus-summary-misc-menu)
2169 gnus-summary-kill-menu gnus-summary-mode-map ""
2174 ["Customize" gnus-score-customize t])
2175 (gnus-make-score-map 'increase)
2176 (gnus-make-score-map 'lower)
2178 ["Kill below" gnus-summary-kill-below t]
2179 ["Mark above" gnus-summary-mark-above t]
2180 ["Tick above" gnus-summary-tick-above t]
2181 ["Clear above" gnus-summary-clear-above t])
2182 ["Current score" gnus-summary-current-score t]
2183 ["Set score" gnus-summary-set-score t]
2184 ["Switch current score file..." gnus-score-change-score-file t]
2185 ["Set mark below..." gnus-score-set-mark-below t]
2186 ["Set expunge below..." gnus-score-set-expunge-below t]
2187 ["Edit current score file" gnus-score-edit-current-scores t]
2188 ["Edit score file" gnus-score-edit-file t]
2189 ["Trace score" gnus-score-find-trace t]
2190 ["Find words" gnus-score-find-favourite-words t]
2191 ["Rescore buffer" gnus-summary-rescore t]
2192 ["Increase score..." gnus-summary-increase-score t]
2193 ["Lower score..." gnus-summary-lower-score t]))))
2195 ;; Define both the Article menu in the summary buffer and the
2196 ;; equivalent Commands menu in the article buffer here for
2200 ["All" gnus-article-hide t]
2201 ["Headers" gnus-article-hide-headers t]
2202 ["Signature" gnus-article-hide-signature t]
2203 ["Citation" gnus-article-hide-citation t]
2204 ["List identifiers" gnus-article-hide-list-identifiers t]
2205 ["Banner" gnus-article-strip-banner t]
2206 ["Boring headers" gnus-article-hide-boring-headers t])
2208 ["All" gnus-article-highlight t]
2209 ["Headers" gnus-article-highlight-headers t]
2210 ["Signature" gnus-article-highlight-signature t]
2211 ["Citation" gnus-article-highlight-citation t])
2213 ["Local" gnus-article-date-local t]
2214 ["ISO8601" gnus-article-date-iso8601 t]
2215 ["UT" gnus-article-date-ut t]
2216 ["Original" gnus-article-date-original t]
2217 ["Lapsed" gnus-article-date-lapsed t]
2218 ["User-defined" gnus-article-date-user t])
2220 ["Remove images" gnus-article-remove-images t]
2221 ["Toggle smiley" gnus-treat-smiley t]
2222 ["Show X-Face" gnus-article-display-x-face t]
2223 ["Show picons in From" gnus-treat-from-picon t]
2224 ["Show picons in mail headers" gnus-treat-mail-picon t]
2225 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2226 ("View as different encoding"
2227 ,@(gnus-summary-menu-split
2230 ;; Since easymenu under Emacs doesn't allow
2231 ;; lambda forms for menu commands, we should
2232 ;; provide intern'ed function symbols.
2233 (let ((command (intern (format "\
2234 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2238 (let ((gnus-summary-show-article-charset-alist
2240 (gnus-summary-show-article 1))))
2241 `[,(symbol-name cs) ,command t]))
2242 (sort (if (fboundp 'coding-system-list)
2243 (coding-system-list)
2244 ;;(mapcar 'car mm-mime-mule-charset-alist)
2249 ["Leading" gnus-article-strip-leading-blank-lines t]
2250 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2251 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2252 ["All of the above" gnus-article-strip-blank-lines t]
2253 ["All" gnus-article-strip-all-blank-lines t]
2254 ["Leading space" gnus-article-strip-leading-space t]
2255 ["Trailing space" gnus-article-strip-trailing-space t]
2256 ["Leading space in headers"
2257 gnus-article-remove-leading-whitespace t])
2258 ["Overstrike" gnus-article-treat-overstrike t]
2259 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2260 ["Emphasis" gnus-article-emphasize t]
2261 ["Word wrap" gnus-article-fill-cited-article t]
2262 ["Fill long lines" gnus-article-fill-long-lines t]
2263 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2264 ["Remove CR" gnus-article-remove-cr t]
2265 ["Rot 13" gnus-summary-caesar-message
2266 ,@(if (featurep 'xemacs) '(t)
2267 '(:help "\"Caesar rotate\" article by 13"))]
2268 ["De-IDNA" gnus-summary-idna-message t]
2269 ["Morse decode" gnus-summary-morse-message t]
2270 ["Unix pipe..." gnus-summary-pipe-message t]
2271 ["Add buttons" gnus-article-add-buttons t]
2272 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2273 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2274 ["Toggle MIME" gnus-summary-toggle-mime t]
2275 ["Verbose header" gnus-summary-verbose-headers t]
2276 ["Toggle header" gnus-summary-toggle-header t]
2277 ["Unfold headers" gnus-article-treat-unfold-headers t]
2278 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2279 ["Html" gnus-article-wash-html t]
2280 ["Unsplit URLs" gnus-article-unsplit-urls t]
2281 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2282 ["Decode HZ" gnus-article-decode-HZ t]
2283 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2284 ("(Outlook) Deuglify"
2285 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2286 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2287 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2288 ["Full (Outlook) deuglify"
2289 gnus-article-outlook-deuglify-article t])
2292 ["Save in default format..." gnus-summary-save-article
2293 ,@(if (featurep 'xemacs) '(t)
2294 '(:help "Save article using default method"))]
2295 ["Save in file..." gnus-summary-save-article-file
2296 ,@(if (featurep 'xemacs) '(t)
2297 '(:help "Save article in file"))]
2298 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2299 ["Save in MH folder..." gnus-summary-save-article-folder t]
2300 ["Save in VM folder..." gnus-summary-save-article-vm t]
2301 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2302 ["Save body in file..." gnus-summary-save-article-body-file t]
2303 ["Pipe through a filter..." gnus-summary-pipe-output t]
2304 ["Add to SOUP packet" gnus-soup-add-article t]
2305 ["Print with Muttprint..." gnus-summary-muttprint t]
2306 ["Print" gnus-summary-print-article
2307 ,@(if (featurep 'xemacs) '(t)
2308 '(:help "Generate and print a PostScript image"))])
2309 ("Copy, move,... (Backend)"
2310 ,@(if (featurep 'xemacs) nil
2311 '(:help "Copying, moving, expiring articles..."))
2312 ["Respool article..." gnus-summary-respool-article t]
2313 ["Move article..." gnus-summary-move-article
2314 (gnus-check-backend-function
2315 'request-move-article gnus-newsgroup-name)]
2316 ["Copy article..." gnus-summary-copy-article t]
2317 ["Crosspost article..." gnus-summary-crosspost-article
2318 (gnus-check-backend-function
2319 'request-replace-article gnus-newsgroup-name)]
2320 ["Import file..." gnus-summary-import-article
2321 (gnus-check-backend-function
2322 'request-accept-article gnus-newsgroup-name)]
2323 ["Create article..." gnus-summary-create-article
2324 (gnus-check-backend-function
2325 'request-accept-article gnus-newsgroup-name)]
2326 ["Check if posted" gnus-summary-article-posted-p t]
2327 ["Edit article" gnus-summary-edit-article
2328 (not (gnus-group-read-only-p))]
2329 ["Delete article" gnus-summary-delete-article
2330 (gnus-check-backend-function
2331 'request-expire-articles gnus-newsgroup-name)]
2332 ["Query respool" gnus-summary-respool-query t]
2333 ["Trace respool" gnus-summary-respool-trace t]
2334 ["Delete expirable articles" gnus-summary-expire-articles-now
2335 (gnus-check-backend-function
2336 'request-expire-articles gnus-newsgroup-name)])
2338 ["Uudecode" gnus-uu-decode-uu
2339 ,@(if (featurep 'xemacs) '(t)
2340 '(:help "Decode uuencoded article(s)"))]
2341 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2342 ["Unshar" gnus-uu-decode-unshar t]
2343 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2344 ["Save" gnus-uu-decode-save t]
2345 ["Binhex" gnus-uu-decode-binhex t]
2346 ["Postscript" gnus-uu-decode-postscript t])
2348 ["Enter article" gnus-cache-enter-article t]
2349 ["Remove article" gnus-cache-remove-article t])
2350 ["Translate" gnus-article-babel t]
2351 ["Select article buffer" gnus-summary-select-article-buffer t]
2352 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2353 ["Isearch article..." gnus-summary-isearch-article t]
2354 ["Beginning of the article" gnus-summary-beginning-of-article t]
2355 ["End of the article" gnus-summary-end-of-article t]
2356 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2357 ["Fetch referenced articles" gnus-summary-refer-references t]
2358 ["Fetch current thread" gnus-summary-refer-thread t]
2359 ["Fetch article with id..." gnus-summary-refer-article t]
2360 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2361 ["Redisplay" gnus-summary-show-article t]
2362 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2364 gnus-summary-article-menu gnus-summary-mode-map ""
2365 (cons "Article" innards))
2367 (if (not (keymapp gnus-summary-article-menu))
2369 gnus-article-commands-menu gnus-article-mode-map ""
2370 (cons "Commands" innards))
2371 ;; in Emacs, don't share menu.
2372 (setq gnus-article-commands-menu
2373 (copy-keymap gnus-summary-article-menu))
2374 (define-key gnus-article-mode-map [menu-bar commands]
2375 (cons "Commands" gnus-article-commands-menu))))
2378 gnus-summary-thread-menu gnus-summary-mode-map ""
2380 ["Find all messages in thread" gnus-summary-refer-thread t]
2381 ["Toggle threading" gnus-summary-toggle-threads t]
2382 ["Hide threads" gnus-summary-hide-all-threads t]
2383 ["Show threads" gnus-summary-show-all-threads t]
2384 ["Hide thread" gnus-summary-hide-thread t]
2385 ["Show thread" gnus-summary-show-thread t]
2386 ["Go to next thread" gnus-summary-next-thread t]
2387 ["Go to previous thread" gnus-summary-prev-thread t]
2388 ["Go down thread" gnus-summary-down-thread t]
2389 ["Go up thread" gnus-summary-up-thread t]
2390 ["Top of thread" gnus-summary-top-thread t]
2391 ["Mark thread as read" gnus-summary-kill-thread t]
2392 ["Lower thread score" gnus-summary-lower-thread t]
2393 ["Raise thread score" gnus-summary-raise-thread t]
2394 ["Rethread current" gnus-summary-rethread-current t]))
2397 gnus-summary-post-menu gnus-summary-mode-map ""
2399 ["Send a message (mail or news)" gnus-summary-post-news
2400 ,@(if (featurep 'xemacs) '(t)
2401 '(:help "Compose a new message (mail or news)"))]
2402 ["Followup" gnus-summary-followup
2403 ,@(if (featurep 'xemacs) '(t)
2404 '(:help "Post followup to this article"))]
2405 ["Followup and yank" gnus-summary-followup-with-original
2406 ,@(if (featurep 'xemacs) '(t)
2407 '(:help "Post followup to this article, quoting its contents"))]
2408 ["Supersede article" gnus-summary-supersede-article t]
2409 ["Cancel article" gnus-summary-cancel-article
2410 ,@(if (featurep 'xemacs) '(t)
2411 '(:help "Cancel an article you posted"))]
2412 ["Reply" gnus-summary-reply t]
2413 ["Reply and yank" gnus-summary-reply-with-original t]
2414 ["Wide reply" gnus-summary-wide-reply t]
2415 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2416 ,@(if (featurep 'xemacs) '(t)
2417 '(:help "Mail a reply, quoting this article"))]
2418 ["Very wide reply" gnus-summary-very-wide-reply t]
2419 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2420 ,@(if (featurep 'xemacs) '(t)
2421 '(:help "Mail a very wide reply, quoting this article"))]
2422 ["Mail forward" gnus-summary-mail-forward t]
2423 ["Post forward" gnus-summary-post-forward t]
2424 ["Digest and mail" gnus-summary-digest-mail-forward t]
2425 ["Digest and post" gnus-summary-digest-post-forward t]
2426 ["Resend message" gnus-summary-resend-message t]
2427 ["Resend message edit" gnus-summary-resend-message-edit t]
2428 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2429 ["Send a mail" gnus-summary-mail-other-window t]
2430 ["Create a local message" gnus-summary-news-other-window t]
2431 ["Uuencode and post" gnus-uu-post-news
2432 ,@(if (featurep 'xemacs) '(t)
2433 '(:help "Post a uuencoded article"))]
2434 ["Followup via news" gnus-summary-followup-to-mail t]
2435 ["Followup via news and yank"
2436 gnus-summary-followup-to-mail-with-original t]
2438 ;;["Send" gnus-summary-send-draft t]
2439 ;;["Send bounced" gnus-resend-bounced-mail t])
2443 ((not (keymapp gnus-summary-post-menu))
2444 (setq gnus-article-post-menu gnus-summary-post-menu))
2445 ((not gnus-article-post-menu)
2446 ;; Don't share post menu.
2447 (setq gnus-article-post-menu
2448 (copy-keymap gnus-summary-post-menu))))
2449 (define-key gnus-article-mode-map [menu-bar post]
2450 (cons "Post" gnus-article-post-menu))
2453 gnus-summary-misc-menu gnus-summary-mode-map ""
2456 ["Mark as read" gnus-summary-mark-as-read-forward t]
2457 ["Mark same subject and select"
2458 gnus-summary-kill-same-subject-and-select t]
2459 ["Mark same subject" gnus-summary-kill-same-subject t]
2460 ["Catchup" gnus-summary-catchup
2461 ,@(if (featurep 'xemacs) '(t)
2462 '(:help "Mark unread articles in this group as read"))]
2463 ["Catchup all" gnus-summary-catchup-all t]
2464 ["Catchup to here" gnus-summary-catchup-to-here t]
2465 ["Catchup from here" gnus-summary-catchup-from-here t]
2466 ["Catchup region" gnus-summary-mark-region-as-read
2467 (gnus-mark-active-p)]
2468 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2470 ["Tick" gnus-summary-tick-article-forward t]
2471 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2472 ["Remove marks" gnus-summary-clear-mark-forward t]
2473 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2474 ["Set bookmark" gnus-summary-set-bookmark t]
2475 ["Remove bookmark" gnus-summary-remove-bookmark t])
2477 ["Marks..." gnus-summary-limit-to-marks t]
2478 ["Subject..." gnus-summary-limit-to-subject t]
2479 ["Author..." gnus-summary-limit-to-author t]
2480 ["Recipient..." gnus-summary-limit-to-recipient t]
2481 ["Age..." gnus-summary-limit-to-age t]
2482 ["Extra..." gnus-summary-limit-to-extra t]
2483 ["Score..." gnus-summary-limit-to-score t]
2484 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2485 ["Unread" gnus-summary-limit-to-unread t]
2486 ["Unseen" gnus-summary-limit-to-unseen t]
2487 ["Replied" gnus-summary-limit-to-replied t]
2488 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2489 ["Next articles" gnus-summary-limit-to-articles t]
2490 ["Pop limit" gnus-summary-pop-limit t]
2491 ["Show dormant" gnus-summary-limit-include-dormant t]
2492 ["Hide childless dormant"
2493 gnus-summary-limit-exclude-childless-dormant t]
2494 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2495 ["Hide marked" gnus-summary-limit-exclude-marks t]
2496 ["Show expunged" gnus-summary-limit-include-expunged t])
2498 ["Set mark" gnus-summary-mark-as-processable t]
2499 ["Remove mark" gnus-summary-unmark-as-processable t]
2500 ["Remove all marks" gnus-summary-unmark-all-processable t]
2501 ["Invert marks" gnus-uu-invert-processable t]
2502 ["Mark above" gnus-uu-mark-over t]
2503 ["Mark series" gnus-uu-mark-series t]
2504 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2505 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2506 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2507 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2508 ["Mark all" gnus-uu-mark-all t]
2509 ["Mark buffer" gnus-uu-mark-buffer t]
2510 ["Mark sparse" gnus-uu-mark-sparse t]
2511 ["Mark thread" gnus-uu-mark-thread t]
2512 ["Unmark thread" gnus-uu-unmark-thread t]
2513 ("Process Mark Sets"
2514 ["Kill" gnus-summary-kill-process-mark t]
2515 ["Yank" gnus-summary-yank-process-mark
2516 gnus-newsgroup-process-stack]
2517 ["Save" gnus-summary-save-process-mark t]
2518 ["Run command on marked..." gnus-summary-universal-argument t]))
2520 ["Page forward" gnus-summary-next-page
2521 ,@(if (featurep 'xemacs) '(t)
2522 '(:help "Show next page of article"))]
2523 ["Page backward" gnus-summary-prev-page
2524 ,@(if (featurep 'xemacs) '(t)
2525 '(:help "Show previous page of article"))]
2526 ["Line forward" gnus-summary-scroll-up t])
2528 ["Next unread article" gnus-summary-next-unread-article t]
2529 ["Previous unread article" gnus-summary-prev-unread-article t]
2530 ["Next article" gnus-summary-next-article t]
2531 ["Previous article" gnus-summary-prev-article t]
2532 ["Next unread subject" gnus-summary-next-unread-subject t]
2533 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2534 ["Next article same subject" gnus-summary-next-same-subject t]
2535 ["Previous article same subject" gnus-summary-prev-same-subject t]
2536 ["First unread article" gnus-summary-first-unread-article t]
2537 ["Best unread article" gnus-summary-best-unread-article t]
2538 ["Go to subject number..." gnus-summary-goto-subject t]
2539 ["Go to article number..." gnus-summary-goto-article t]
2540 ["Go to the last article" gnus-summary-goto-last-article t]
2541 ["Pop article off history" gnus-summary-pop-article t])
2543 ["Sort by number" gnus-summary-sort-by-number t]
2544 ["Sort by author" gnus-summary-sort-by-author t]
2545 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2546 ["Sort by subject" gnus-summary-sort-by-subject t]
2547 ["Sort by date" gnus-summary-sort-by-date t]
2548 ["Sort by score" gnus-summary-sort-by-score t]
2549 ["Sort by lines" gnus-summary-sort-by-lines t]
2550 ["Sort by characters" gnus-summary-sort-by-chars t]
2551 ["Randomize" gnus-summary-sort-by-random t]
2552 ["Original sort" gnus-summary-sort-by-original t])
2554 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2555 ["Describe group" gnus-summary-describe-group t]
2556 ["Fetch charter" gnus-group-fetch-charter
2557 ,@(if (featurep 'xemacs) nil
2558 '(:help "Display the charter of the current group"))]
2559 ["Fetch control message" gnus-group-fetch-control
2560 ,@(if (featurep 'xemacs) nil
2561 '(:help "Display the archived control message for the current group"))]
2562 ["Read manual" gnus-info-find-node t])
2564 ["Pick and read" gnus-pick-mode t]
2565 ["Binary" gnus-binary-mode t])
2567 ["Regenerate" gnus-summary-prepare t]
2568 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2569 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2570 ["Toggle threading" gnus-summary-toggle-threads t])
2571 ["See old articles" gnus-summary-insert-old-articles t]
2572 ["See new articles" gnus-summary-insert-new-articles t]
2573 ["Filter articles..." gnus-summary-execute-command t]
2574 ["Run command on articles..." gnus-summary-universal-argument t]
2575 ["Search articles forward..." gnus-summary-search-article-forward t]
2576 ["Search articles backward..." gnus-summary-search-article-backward t]
2577 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2578 ["Expand window" gnus-summary-expand-window t]
2579 ["Expire expirable articles" gnus-summary-expire-articles
2580 (gnus-check-backend-function
2581 'request-expire-articles gnus-newsgroup-name)]
2582 ["Edit local kill file" gnus-summary-edit-local-kill t]
2583 ["Edit main kill file" gnus-summary-edit-global-kill t]
2584 ["Edit group parameters" gnus-summary-edit-parameters t]
2585 ["Customize group parameters" gnus-summary-customize-parameters t]
2586 ["Send a bug report" gnus-bug t]
2588 ["Catchup and exit" gnus-summary-catchup-and-exit
2589 ,@(if (featurep 'xemacs) '(t)
2590 '(:help "Mark unread articles in this group as read, then exit"))]
2591 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2592 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2593 ["Exit group" gnus-summary-exit
2594 ,@(if (featurep 'xemacs) '(t)
2595 '(:help "Exit current group, return to group selection mode"))]
2596 ["Exit group without updating" gnus-summary-exit-no-update t]
2597 ["Exit and goto next group" gnus-summary-next-group t]
2598 ["Exit and goto prev group" gnus-summary-prev-group t]
2599 ["Reselect group" gnus-summary-reselect-current-group t]
2600 ["Rescan group" gnus-summary-rescan-group t]
2601 ["Update dribble" gnus-summary-save-newsrc t])))
2603 (gnus-run-hooks 'gnus-summary-menu-hook)))
2605 (defvar gnus-summary-tool-bar-map nil)
2607 ;; Emacs 21 tool bar. Should be no-op otherwise.
2608 (defun gnus-summary-make-tool-bar ()
2609 (if (and (fboundp 'tool-bar-add-item-from-menu)
2610 (default-value 'tool-bar-mode)
2611 (not gnus-summary-tool-bar-map))
2612 (setq gnus-summary-tool-bar-map
2613 (let ((tool-bar-map (make-sparse-keymap))
2614 (load-path (mm-image-load-path)))
2615 (tool-bar-add-item-from-menu
2616 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2617 (tool-bar-add-item-from-menu
2618 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2619 (tool-bar-add-item-from-menu
2620 'gnus-summary-post-news "post" gnus-summary-mode-map)
2621 (tool-bar-add-item-from-menu
2622 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2623 (tool-bar-add-item-from-menu
2624 'gnus-summary-followup "followup" gnus-summary-mode-map)
2625 (tool-bar-add-item-from-menu
2626 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2627 (tool-bar-add-item-from-menu
2628 'gnus-summary-reply "reply" gnus-summary-mode-map)
2629 (tool-bar-add-item-from-menu
2630 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2631 (tool-bar-add-item-from-menu
2632 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2633 (tool-bar-add-item-from-menu
2634 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2635 (tool-bar-add-item-from-menu
2636 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2637 (tool-bar-add-item-from-menu
2638 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2639 (tool-bar-add-item-from-menu
2640 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2641 (tool-bar-add-item-from-menu
2642 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2643 (tool-bar-add-item-from-menu
2644 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2645 (tool-bar-add-item-from-menu
2646 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2648 (if gnus-summary-tool-bar-map
2649 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2651 (defun gnus-score-set-default (var value)
2652 "A version of set that updates the GNU Emacs menu-bar."
2654 ;; It is the message that forces the active status to be updated.
2657 (defun gnus-make-score-map (type)
2658 "Make a summary score map of type TYPE."
2661 (let ((headers '(("author" "from" string)
2662 ("subject" "subject" string)
2663 ("article body" "body" string)
2664 ("article head" "head" string)
2665 ("xref" "xref" string)
2666 ("extra header" "extra" string)
2667 ("lines" "lines" number)
2668 ("followups to author" "followup" string)))
2669 (types '((number ("less than" <)
2672 (string ("substring" s)
2676 (perms '(("temporary" (current-time-string))
2684 (if (eq type 'lower)
2689 (setq header (car headers))
2695 (let ((ts (cdr (assoc (nth 2 header) types)))
2711 'gnus-summary-score-entry
2713 (if (or (string= (nth 1 header)
2715 (string= (nth 1 header)
2718 (list 'gnus-summary-header
2720 (list 'quote (nth 1 (car ts)))
2721 (list 'gnus-score-delta-default
2728 (list (nreverse outp))))
2731 (list (nreverse outt))))
2733 (setq headers (cdr headers)))
2734 (list (nreverse outh))))))))
2738 (defun gnus-summary-mode (&optional group)
2739 "Major mode for reading articles.
2741 All normal editing commands are switched off.
2742 \\<gnus-summary-mode-map>
2743 Each line in this buffer represents one article. To read an
2744 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2745 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2748 You can also post articles and send mail from this buffer. To
2749 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2750 of an article, type `\\[gnus-summary-reply]'.
2752 There are approx. one gazillion commands you can execute in this
2753 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2755 The following commands are available:
2757 \\{gnus-summary-mode-map}"
2759 (kill-all-local-variables)
2760 (when (gnus-visual-p 'summary-menu 'menu)
2761 (gnus-summary-make-menu-bar)
2762 (gnus-summary-make-tool-bar))
2763 (gnus-summary-make-local-variables)
2764 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2765 (gnus-summary-make-local-variables))
2766 (gnus-make-thread-indent-array)
2767 (gnus-simplify-mode-line)
2768 (setq major-mode 'gnus-summary-mode)
2769 (setq mode-name "Summary")
2770 (make-local-variable 'minor-mode-alist)
2771 (use-local-map gnus-summary-mode-map)
2772 (buffer-disable-undo)
2773 (setq buffer-read-only t ;Disable modification
2774 show-trailing-whitespace nil)
2775 (setq truncate-lines t)
2776 (setq selective-display t)
2777 (setq selective-display-ellipses t) ;Display `...'
2778 (gnus-summary-set-display-table)
2779 (gnus-set-default-directory)
2780 (setq gnus-newsgroup-name group)
2781 (unless (gnus-news-group-p group)
2782 (setq gnus-newsgroup-incorporated
2783 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2784 (make-local-variable 'gnus-summary-line-format)
2785 (make-local-variable 'gnus-summary-line-format-spec)
2786 (make-local-variable 'gnus-summary-dummy-line-format)
2787 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2788 (make-local-variable 'gnus-summary-mark-positions)
2789 (gnus-make-local-hook 'pre-command-hook)
2790 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2791 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2792 (turn-on-gnus-mailing-list-mode)
2793 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2794 (gnus-update-summary-mark-positions))
2796 (defun gnus-summary-make-local-variables ()
2797 "Make all the local summary buffer variables."
2799 (dolist (local gnus-summary-local-variables)
2802 (if (eq (cdr local) 'global)
2803 ;; Copy the global value of the variable.
2804 (setq global (symbol-value (car local)))
2805 ;; Use the value from the list.
2806 (setq global (eval (cdr local))))
2807 (set (make-local-variable (car local)) global))
2808 ;; Simple nil-valued local variable.
2809 (set (make-local-variable local) nil)))))
2811 (defun gnus-summary-clear-local-variables ()
2812 (let ((locals gnus-summary-local-variables))
2814 (if (consp (car locals))
2815 (and (symbolp (caar locals))
2816 (set (caar locals) nil))
2817 (and (symbolp (car locals))
2818 (set (car locals) nil)))
2819 (setq locals (cdr locals)))))
2821 ;; Summary data functions.
2823 (defmacro gnus-data-number (data)
2826 (defmacro gnus-data-set-number (data number)
2827 `(setcar ,data ,number))
2829 (defmacro gnus-data-mark (data)
2832 (defmacro gnus-data-set-mark (data mark)
2833 `(setcar (nthcdr 1 ,data) ,mark))
2835 (defmacro gnus-data-pos (data)
2838 (defmacro gnus-data-set-pos (data pos)
2839 `(setcar (nthcdr 2 ,data) ,pos))
2841 (defmacro gnus-data-header (data)
2844 (defmacro gnus-data-set-header (data header)
2845 `(setcar (nthcdr 3 ,data) ,header))
2847 (defmacro gnus-data-level (data)
2850 (defmacro gnus-data-unread-p (data)
2851 `(= (nth 1 ,data) gnus-unread-mark))
2853 (defmacro gnus-data-read-p (data)
2854 `(/= (nth 1 ,data) gnus-unread-mark))
2856 (defmacro gnus-data-pseudo-p (data)
2857 `(consp (nth 3 ,data)))
2859 (defmacro gnus-data-find (number)
2860 `(assq ,number gnus-newsgroup-data))
2862 (defmacro gnus-data-find-list (number &optional data)
2863 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2864 (memq (assq ,number bdata)
2867 (defmacro gnus-data-make (number mark pos header level)
2868 `(list ,number ,mark ,pos ,header ,level))
2870 (defun gnus-data-enter (after-article number mark pos header level offset)
2871 (let ((data (gnus-data-find-list after-article)))
2873 (error "No such article: %d" after-article))
2874 (setcdr data (cons (gnus-data-make number mark pos header level)
2876 (setq gnus-newsgroup-data-reverse nil)
2877 (gnus-data-update-list (cddr data) offset)))
2879 (defun gnus-data-enter-list (after-article list &optional offset)
2881 (let ((data (and after-article (gnus-data-find-list after-article)))
2885 (let ((odata gnus-newsgroup-data))
2886 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2888 (gnus-data-update-list odata offset)))
2889 ;; Find the last element in the list to be spliced into the main
2891 (setq list (last list))
2894 (setcdr list gnus-newsgroup-data)
2895 (setq gnus-newsgroup-data ilist)
2897 (gnus-data-update-list (cdr list) offset)))
2898 (setcdr list (cdr data))
2901 (gnus-data-update-list (cdr list) offset))))
2902 (setq gnus-newsgroup-data-reverse nil))))
2904 (defun gnus-data-remove (article &optional offset)
2905 (let ((data gnus-newsgroup-data))
2906 (if (= (gnus-data-number (car data)) article)
2908 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2909 gnus-newsgroup-data-reverse nil)
2911 (gnus-data-update-list gnus-newsgroup-data offset)))
2913 (when (= (gnus-data-number (cadr data)) article)
2914 (setcdr data (cddr data))
2916 (gnus-data-update-list (cdr data) offset))
2918 gnus-newsgroup-data-reverse nil))
2919 (setq data (cdr data))))))
2921 (defmacro gnus-data-list (backward)
2923 (or gnus-newsgroup-data-reverse
2924 (setq gnus-newsgroup-data-reverse
2925 (reverse gnus-newsgroup-data)))
2926 gnus-newsgroup-data))
2928 (defun gnus-data-update-list (data offset)
2929 "Add OFFSET to the POS of all data entries in DATA."
2930 (setq gnus-newsgroup-data-reverse nil)
2932 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2933 (setq data (cdr data))))
2935 (defun gnus-summary-article-pseudo-p (article)
2936 "Say whether this article is a pseudo article or not."
2937 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2939 (defmacro gnus-summary-article-sparse-p (article)
2940 "Say whether this article is a sparse article or not."
2941 `(memq ,article gnus-newsgroup-sparse))
2943 (defmacro gnus-summary-article-ancient-p (article)
2944 "Say whether this article is a sparse article or not."
2945 `(memq ,article gnus-newsgroup-ancient))
2947 (defun gnus-article-parent-p (number)
2948 "Say whether this article is a parent or not."
2949 (let ((data (gnus-data-find-list number)))
2950 (and (cdr data) ; There has to be an article after...
2951 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2952 (gnus-data-level (nth 1 data))))))
2954 (defun gnus-article-children (number)
2955 "Return a list of all children to NUMBER."
2956 (let* ((data (gnus-data-find-list number))
2957 (level (gnus-data-level (car data)))
2959 (setq data (cdr data))
2961 (= (gnus-data-level (car data)) (1+ level)))
2962 (push (gnus-data-number (car data)) children)
2963 (setq data (cdr data)))
2966 (defmacro gnus-summary-skip-intangible ()
2967 "If the current article is intangible, then jump to a different article."
2968 '(let ((to (get-text-property (point) 'gnus-intangible)))
2969 (and to (gnus-summary-goto-subject to))))
2971 (defmacro gnus-summary-article-intangible-p ()
2972 "Say whether this article is intangible or not."
2973 '(get-text-property (point) 'gnus-intangible))
2975 (defun gnus-article-read-p (article)
2976 "Say whether ARTICLE is read or not."
2977 (not (or (memq article gnus-newsgroup-marked)
2978 (memq article gnus-newsgroup-spam-marked)
2979 (memq article gnus-newsgroup-unreads)
2980 (memq article gnus-newsgroup-unselected)
2981 (memq article gnus-newsgroup-dormant))))
2983 ;; Some summary mode macros.
2985 (defmacro gnus-summary-article-number ()
2986 "The article number of the article on the current line.
2987 If there isn't an article number here, then we return the current
2990 (gnus-summary-skip-intangible)
2991 (or (get-text-property (point) 'gnus-number)
2992 (gnus-summary-last-subject))))
2994 (defmacro gnus-summary-article-header (&optional number)
2995 "Return the header of article NUMBER."
2996 `(gnus-data-header (gnus-data-find
2997 ,(or number '(gnus-summary-article-number)))))
2999 (defmacro gnus-summary-thread-level (&optional number)
3000 "Return the level of thread that starts with article NUMBER."
3001 `(if (and (eq gnus-summary-make-false-root 'dummy)
3002 (get-text-property (point) 'gnus-intangible))
3004 (gnus-data-level (gnus-data-find
3005 ,(or number '(gnus-summary-article-number))))))
3007 (defmacro gnus-summary-article-mark (&optional number)
3008 "Return the mark of article NUMBER."
3009 `(gnus-data-mark (gnus-data-find
3010 ,(or number '(gnus-summary-article-number)))))
3012 (defmacro gnus-summary-article-pos (&optional number)
3013 "Return the position of the line of article NUMBER."
3014 `(gnus-data-pos (gnus-data-find
3015 ,(or number '(gnus-summary-article-number)))))
3017 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3018 (defmacro gnus-summary-article-subject (&optional number)
3019 "Return current subject string or nil if nothing."
3022 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3023 '(gnus-data-header (assq (gnus-summary-article-number)
3024 gnus-newsgroup-data)))))
3027 (mail-header-subject headers))))
3029 (defmacro gnus-summary-article-score (&optional number)
3030 "Return current article score."
3031 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3032 gnus-newsgroup-scored))
3033 gnus-summary-default-score 0))
3035 (defun gnus-summary-article-children (&optional number)
3036 "Return a list of article numbers that are children of article NUMBER."
3037 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3038 (level (gnus-data-level (car data)))
3040 (while (and (setq data (cdr data))
3041 (> (setq l (gnus-data-level (car data))) level))
3042 (and (= (1+ level) l)
3043 (push (gnus-data-number (car data))
3045 (nreverse children)))
3047 (defun gnus-summary-article-parent (&optional number)
3048 "Return the article number of the parent of article NUMBER."
3049 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3050 (gnus-data-list t)))
3051 (level (gnus-data-level (car data))))
3053 () ; This is a root.
3054 ;; We search until we find an article with a level less than
3055 ;; this one. That function has to be the parent.
3056 (while (and (setq data (cdr data))
3057 (not (< (gnus-data-level (car data)) level))))
3058 (and data (gnus-data-number (car data))))))
3060 (defun gnus-unread-mark-p (mark)
3061 "Say whether MARK is the unread mark."
3062 (= mark gnus-unread-mark))
3064 (defun gnus-read-mark-p (mark)
3065 "Say whether MARK is one of the marks that mark as read.
3066 This is all marks except unread, ticked, dormant, and expirable."
3067 (not (or (= mark gnus-unread-mark)
3068 (= mark gnus-ticked-mark)
3069 (= mark gnus-spam-mark)
3070 (= mark gnus-dormant-mark)
3071 (= mark gnus-expirable-mark))))
3073 (defmacro gnus-article-mark (number)
3074 "Return the MARK of article NUMBER.
3075 This macro should only be used when computing the mark the \"first\"
3076 time; i.e., when generating the summary lines. After that,
3077 `gnus-summary-article-mark' should be used to examine the
3080 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3081 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3082 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3083 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3084 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3085 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3086 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3087 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3088 gnus-ancient-mark))))
3090 ;; Saving hidden threads.
3092 (defmacro gnus-save-hidden-threads (&rest forms)
3093 "Save hidden threads, eval FORMS, and restore the hidden threads."
3094 (let ((config (make-symbol "config")))
3095 `(let ((,config (gnus-hidden-threads-configuration)))
3099 (gnus-restore-hidden-threads-configuration ,config)))))
3100 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3101 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3103 (defun gnus-data-compute-positions ()
3104 "Compute the positions of all articles."
3105 (setq gnus-newsgroup-data-reverse nil)
3106 (let ((data gnus-newsgroup-data))
3108 (gnus-save-hidden-threads
3109 (gnus-summary-show-all-threads)
3110 (goto-char (point-min))
3112 (while (get-text-property (point) 'gnus-intangible)
3114 (gnus-data-set-pos (car data) (+ (point) 3))
3115 (setq data (cdr data))
3116 (forward-line 1))))))
3118 (defun gnus-hidden-threads-configuration ()
3119 "Return the current hidden threads configuration."
3122 (goto-char (point-min))
3123 (while (search-forward "\r" nil t)
3124 (push (1- (point)) config))
3127 (defun gnus-restore-hidden-threads-configuration (config)
3128 "Restore hidden threads configuration from CONFIG."
3130 (let (point buffer-read-only)
3131 (while (setq point (pop config))
3132 (when (and (< point (point-max))
3134 (eq (char-after) ?\n))
3135 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3137 ;; Various summary mode internalish functions.
3139 (defun gnus-mouse-pick-article (e)
3142 (gnus-summary-next-page nil t))
3144 (defun gnus-summary-set-display-table ()
3145 "Change the display table.
3146 Odd characters have a tendency to mess
3147 up nicely formatted displays - we make all possible glyphs
3148 display only a single character."
3150 ;; We start from the standard display table, if any.
3151 (let ((table (or (copy-sequence standard-display-table)
3152 (make-display-table)))
3154 ;; Nix out all the control chars...
3155 (while (>= (setq i (1- i)) 0)
3156 (aset table i [??]))
3157 ;; ... but not newline and cr, of course. (cr is necessary for the
3158 ;; selective display).
3159 (aset table ?\n nil)
3160 (aset table ?\r nil)
3161 ;; We keep TAB as well.
3162 (aset table ?\t nil)
3163 ;; We nix out any glyphs over 126 that are not set already.
3165 (while (>= (setq i (1- i)) 127)
3166 ;; Only modify if the entry is nil.
3167 (unless (aref table i)
3168 (aset table i [??]))))
3169 (setq buffer-display-table table)))
3171 (defun gnus-summary-set-article-display-arrow (pos)
3172 "Update the overlay arrow to point to line at position POS."
3173 (when (and gnus-summary-display-arrow
3174 (boundp 'overlay-arrow-position)
3175 (boundp 'overlay-arrow-string))
3179 (unless overlay-arrow-position
3180 (setq overlay-arrow-position (make-marker)))
3181 (setq overlay-arrow-string "=>"
3182 overlay-arrow-position (set-marker overlay-arrow-position
3184 (current-buffer))))))
3186 (defun gnus-summary-setup-buffer (group)
3187 "Initialize summary buffer."
3188 (let ((buffer (gnus-summary-buffer-name group))
3189 (dead-name (concat "*Dead Summary "
3190 (gnus-group-decoded-name group) "*")))
3191 ;; If a dead summary buffer exists, we kill it.
3192 (when (gnus-buffer-live-p dead-name)
3193 (gnus-kill-buffer dead-name))
3194 (if (get-buffer buffer)
3197 (setq gnus-summary-buffer (current-buffer))
3198 (not gnus-newsgroup-prepared))
3199 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3200 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3201 (gnus-summary-mode group)
3203 (gnus-carpal-setup-buffer 'summary))
3204 (unless gnus-single-article-buffer
3205 (make-local-variable 'gnus-article-buffer)
3206 (make-local-variable 'gnus-article-current)
3207 (make-local-variable 'gnus-original-article-buffer))
3208 (setq gnus-newsgroup-name group)
3209 ;; Set any local variables in the group parameters.
3210 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3213 (defun gnus-set-global-variables ()
3214 "Set the global equivalents of the buffer-local variables.
3215 They are set to the latest values they had. These reflect the summary
3216 buffer that was in action when the last article was fetched."
3217 (when (eq major-mode 'gnus-summary-mode)
3218 (setq gnus-summary-buffer (current-buffer))
3219 (let ((name gnus-newsgroup-name)
3220 (marked gnus-newsgroup-marked)
3221 (spam gnus-newsgroup-spam-marked)
3222 (unread gnus-newsgroup-unreads)
3223 (headers gnus-current-headers)
3224 (data gnus-newsgroup-data)
3225 (summary gnus-summary-buffer)
3226 (article-buffer gnus-article-buffer)
3227 (original gnus-original-article-buffer)
3228 (gac gnus-article-current)
3229 (reffed gnus-reffed-article-number)
3230 (score-file gnus-current-score-file)
3231 (default-charset gnus-newsgroup-charset)
3233 (let ((locals gnus-newsgroup-variables))
3235 (if (consp (car locals))
3236 (push (eval (caar locals)) vlist)
3237 (push (eval (car locals)) vlist))
3238 (setq locals (cdr locals)))
3239 (setq vlist (nreverse vlist)))
3240 (with-current-buffer gnus-group-buffer
3241 (setq gnus-newsgroup-name name
3242 gnus-newsgroup-marked marked
3243 gnus-newsgroup-spam-marked spam
3244 gnus-newsgroup-unreads unread
3245 gnus-current-headers headers
3246 gnus-newsgroup-data data
3247 gnus-article-current gac
3248 gnus-summary-buffer summary
3249 gnus-article-buffer article-buffer
3250 gnus-original-article-buffer original
3251 gnus-reffed-article-number reffed
3252 gnus-current-score-file score-file
3253 gnus-newsgroup-charset default-charset)
3254 (let ((locals gnus-newsgroup-variables))
3256 (if (consp (car locals))
3257 (set (caar locals) (pop vlist))
3258 (set (car locals) (pop vlist)))
3259 (setq locals (cdr locals))))
3260 ;; The article buffer also has local variables.
3261 (when (gnus-buffer-live-p gnus-article-buffer)
3262 (set-buffer gnus-article-buffer)
3263 (setq gnus-summary-buffer summary))))))
3265 (defun gnus-summary-article-unread-p (article)
3266 "Say whether ARTICLE is unread or not."
3267 (memq article gnus-newsgroup-unreads))
3269 (defun gnus-summary-first-article-p (&optional article)
3270 "Return whether ARTICLE is the first article in the buffer."
3271 (if (not (setq article (or article (gnus-summary-article-number))))
3273 (eq article (caar gnus-newsgroup-data))))
3275 (defun gnus-summary-last-article-p (&optional article)
3276 "Return whether ARTICLE is the last article in the buffer."
3277 (if (not (setq article (or article (gnus-summary-article-number))))
3278 ;; All non-existent numbers are the last article. :-)
3280 (not (cdr (gnus-data-find-list article)))))
3282 (defun gnus-make-thread-indent-array ()
3284 (unless (and gnus-thread-indent-array
3285 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3286 (setq gnus-thread-indent-array (make-vector 201 "")
3287 gnus-thread-indent-array-level gnus-thread-indent-level)
3289 (aset gnus-thread-indent-array n
3290 (make-string (* n gnus-thread-indent-level) ? ))
3293 (defun gnus-update-summary-mark-positions ()
3294 "Compute where the summary marks are to go."
3296 (when (gnus-buffer-exists-p gnus-summary-buffer)
3297 (set-buffer gnus-summary-buffer))
3298 (let ((spec gnus-summary-line-format-spec)
3301 (gnus-set-work-buffer)
3302 (let ((gnus-tmp-unread ?Z)
3303 (gnus-replied-mark ?Z)
3304 (gnus-score-below-mark ?Z)
3305 (gnus-score-over-mark ?Z)
3306 (gnus-undownloaded-mark ?Z)
3307 (gnus-summary-line-format-spec spec)
3308 (gnus-newsgroup-downloadable '(0))
3310 (make-full-mail-header
3311 0 "" "nobody" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil))
3312 case-fold-search ignores)
3313 ;; Here, all marks are bound to Z.
3314 (gnus-summary-insert-line header
3315 0 nil t gnus-tmp-unread t nil "" nil 1)
3316 (goto-char (point-min))
3317 ;; Memorize the positions of the same characters as dummy marks.
3318 (while (re-search-forward "[A-D]" nil t)
3319 (push (point) ignores))
3321 ;; We use A-D as dummy marks in order to know column positions
3322 ;; where marks should be inserted.
3323 (setq gnus-tmp-unread ?A
3324 gnus-replied-mark ?B
3325 gnus-score-below-mark ?C
3326 gnus-score-over-mark ?C
3327 gnus-undownloaded-mark ?D)
3328 (gnus-summary-insert-line header
3329 0 nil t gnus-tmp-unread t nil "" nil 1)
3330 ;; Ignore characters which aren't dummy marks.
3332 (delete-region (goto-char (1- p)) p)
3334 (goto-char (point-min))
3335 (setq pos (list (cons 'unread
3336 (and (search-forward "A" nil t)
3337 (- (point) (point-min) 1)))))
3338 (goto-char (point-min))
3339 (push (cons 'replied (and (search-forward "B" nil t)
3340 (- (point) (point-min) 1)))
3342 (goto-char (point-min))
3343 (push (cons 'score (and (search-forward "C" nil t)
3344 (- (point) (point-min) 1)))
3346 (goto-char (point-min))
3347 (push (cons 'download (and (search-forward "D" nil t)
3348 (- (point) (point-min) 1)))
3350 (setq gnus-summary-mark-positions pos))))
3352 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3353 "Insert a dummy root in the summary buffer."
3355 (gnus-add-text-properties
3356 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3357 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3359 (defun gnus-summary-extract-address-component (from)
3360 (or (car (funcall gnus-extract-address-components from))
3363 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3364 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3365 default-mime-charset)))
3366 ;; Is it really necessary to do this next part for each summary line?
3367 ;; Luckily, doesn't seem to slow things down much.
3369 (and gnus-ignored-from-addresses
3370 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3371 (let ((extra-headers (mail-header-extra header))
3375 ((setq to (cdr (assq 'To extra-headers)))
3376 (concat gnus-summary-to-prefix
3378 (gnus-summary-extract-address-component
3379 (funcall gnus-decode-encoded-word-function to)))))
3380 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3381 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3382 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3384 (defun gnus-summary-insert-line (gnus-tmp-header
3385 gnus-tmp-level gnus-tmp-current
3386 undownloaded gnus-tmp-unread gnus-tmp-replied
3387 gnus-tmp-expirable gnus-tmp-subject-or-nil
3388 &optional gnus-tmp-dummy gnus-tmp-score
3390 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3391 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3392 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3393 (gnus-tmp-score-char
3394 (if (or (null gnus-summary-default-score)
3395 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3396 gnus-summary-zcore-fuzz))
3398 (if (< gnus-tmp-score gnus-summary-default-score)
3399 gnus-score-below-mark gnus-score-over-mark)))
3400 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3402 (cond (gnus-tmp-process gnus-process-mark)
3403 ((memq gnus-tmp-current gnus-newsgroup-cached)
3405 (gnus-tmp-replied gnus-replied-mark)
3406 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3407 gnus-forwarded-mark)
3408 ((memq gnus-tmp-current gnus-newsgroup-saved)
3410 ((memq gnus-tmp-number gnus-newsgroup-recent)
3412 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3415 (gnus-tmp-downloaded
3417 gnus-undownloaded-mark)
3418 (gnus-newsgroup-agentized
3419 gnus-downloaded-mark)
3422 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3425 ((string-match "<[^>]+> *$" gnus-tmp-from)
3426 (let ((beg (match-beginning 0)))
3427 (or (and (string-match "^\".+\"" gnus-tmp-from)
3428 (substring gnus-tmp-from 1 (1- (match-end 0))))
3429 (substring gnus-tmp-from 0 beg))))
3430 ((string-match "(.+)" gnus-tmp-from)
3431 (substring gnus-tmp-from
3432 (1+ (match-beginning 0)) (1- (match-end 0))))
3434 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3435 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3436 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3437 (buffer-read-only nil))
3438 (when (string= gnus-tmp-name "")
3439 (setq gnus-tmp-name gnus-tmp-from))
3440 (unless (numberp gnus-tmp-lines)
3441 (setq gnus-tmp-lines -1))
3442 (if (= gnus-tmp-lines -1)
3443 (setq gnus-tmp-lines "?")
3444 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3445 (gnus-put-text-property-excluding-characters-with-faces
3447 (progn (eval gnus-summary-line-format-spec) (point))
3448 'gnus-number gnus-tmp-number)
3449 (when (gnus-visual-p 'summary-highlight 'highlight)
3451 (gnus-run-hooks 'gnus-summary-update-hook)
3454 (defun gnus-summary-update-line (&optional dont-update)
3455 "Update summary line after change."
3456 (when (and gnus-summary-default-score
3457 (not gnus-summary-inhibit-highlight))
3458 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3459 (article (gnus-summary-article-number))
3460 (score (gnus-summary-article-score article)))
3462 (if (and gnus-summary-mark-below
3463 (< (gnus-summary-article-score)
3464 gnus-summary-mark-below))
3465 ;; This article has a low score, so we mark it as read.
3466 (when (memq article gnus-newsgroup-unreads)
3467 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3468 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3469 ;; This article was previously marked as read on account
3470 ;; of a low score, but now it has risen, so we mark it as
3472 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3473 (gnus-summary-update-mark
3474 (if (or (null gnus-summary-default-score)
3475 (<= (abs (- score gnus-summary-default-score))
3476 gnus-summary-zcore-fuzz))
3478 (if (< score gnus-summary-default-score)
3479 gnus-score-below-mark gnus-score-over-mark))
3481 ;; Do visual highlighting.
3482 (when (gnus-visual-p 'summary-highlight 'highlight)
3483 (gnus-run-hooks 'gnus-summary-update-hook)))))
3485 (defvar gnus-tmp-new-adopts nil)
3487 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3488 "Return the number of articles in THREAD.
3489 This may be 0 in some cases -- if none of the articles in
3490 the thread are to be displayed."
3492 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3494 ((not (listp thread))
3496 ((and (consp thread) (cdr thread))
3499 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3502 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3505 (when (and level (zerop level) gnus-tmp-new-adopts)
3508 'gnus-summary-number-of-articles-in-thread
3509 gnus-tmp-new-adopts))))
3511 (if (> number 1) gnus-not-empty-thread-mark
3512 gnus-empty-thread-mark)
3515 (defsubst gnus-summary-line-message-size (head)
3516 "Return pretty-printed version of message size.
3517 This function is intended to be used in
3518 `gnus-summary-line-format-alist'."
3519 (let ((c (or (mail-header-chars head) -1)))
3520 (cond ((< c 0) "n/a") ; chars not available
3521 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3522 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3523 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3524 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3527 (defun gnus-summary-set-local-parameters (group)
3528 "Go through the local params of GROUP and set all variable specs in that list."
3529 (let ((vars '(quit-config))) ; Ignore quit-config.
3530 (dolist (elem (gnus-group-find-parameter group))
3531 (and (consp elem) ; Has to be a cons.
3532 (consp (cdr elem)) ; The cdr has to be a list.
3533 (symbolp (car elem)) ; Has to be a symbol in there.
3534 (not (memq (car elem) vars))
3535 (ignore-errors ; So we set it.
3536 (push (car elem) vars)
3537 (make-local-variable (car elem))
3538 (set (car elem) (eval (nth 1 elem))))))))
3540 (defun gnus-summary-read-group (group &optional show-all no-article
3541 kill-buffer no-display backward
3543 "Start reading news in newsgroup GROUP.
3544 If SHOW-ALL is non-nil, already read articles are also listed.
3545 If NO-ARTICLE is non-nil, no article is selected initially.
3546 If NO-DISPLAY, don't generate a summary buffer."
3550 (let ((gnus-auto-select-next nil))
3551 (or (gnus-summary-read-group-1
3552 group show-all no-article
3553 kill-buffer no-display
3556 select-articles nil)))))
3557 (eq gnus-auto-select-next 'quietly))
3558 (set-buffer gnus-group-buffer)
3559 ;; The entry function called above goes to the next
3560 ;; group automatically, so we go two groups back
3561 ;; if we are searching for the previous group.
3563 (gnus-group-prev-unread-group 2))
3564 (if (not (equal group (gnus-group-group-name)))
3565 (setq group (gnus-group-group-name))
3569 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3570 "Directly jump to the other GROUP from summary buffer.
3571 If SHOW-ALL is non-nil, already read articles are also listed."
3573 (if (eq gnus-summary-buffer (current-buffer))
3574 (list (completing-read
3575 "Group: " gnus-active-hashtb nil t
3576 (when (and gnus-newsgroup-name
3577 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3578 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3579 'gnus-group-history)
3581 (error "%s must be invoked from a gnus summary buffer." this-command)))
3582 (unless (or (zerop (length group))
3583 (and gnus-newsgroup-name
3584 (string-equal gnus-newsgroup-name group)))
3586 (gnus-summary-read-group group show-all
3587 gnus-dont-select-after-jump-to-other-group)))
3589 (defun gnus-summary-read-group-1 (group show-all no-article
3590 kill-buffer no-display
3591 &optional select-articles)
3592 ;; Killed foreign groups can't be entered.
3593 ;; (when (and (not (gnus-group-native-p group))
3594 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3595 ;; (error "Dead non-native groups can't be entered"))
3596 (gnus-message 5 "Retrieving newsgroup: %s..."
3597 (gnus-group-decoded-name group))
3598 (let* ((new-group (gnus-summary-setup-buffer group))
3599 (quit-config (gnus-group-quit-config group))
3600 (did-select (and new-group (gnus-select-newsgroup
3601 group show-all select-articles))))
3603 ;; This summary buffer exists already, so we just select it.
3605 (gnus-set-global-variables)
3607 (gnus-kill-or-deaden-summary kill-buffer))
3608 (gnus-configure-windows 'summary 'force)
3609 (gnus-set-mode-line 'summary)
3610 (gnus-summary-position-point)
3613 ;; We couldn't select this group.
3615 (when (and (eq major-mode 'gnus-summary-mode)
3616 (not (equal (current-buffer) kill-buffer)))
3617 (kill-buffer (current-buffer))
3618 (if (not quit-config)
3620 ;; Update the info -- marks might need to be removed,
3622 (gnus-summary-update-info)
3623 (set-buffer gnus-group-buffer)
3624 (gnus-group-jump-to-group group)
3625 (gnus-group-next-unread-group 1))
3626 (gnus-handle-ephemeral-exit quit-config)))
3627 (let ((grpinfo (gnus-get-info group)))
3628 (if (null (gnus-info-read grpinfo))
3629 (gnus-message 3 "Group %s contains no messages"
3630 (gnus-group-decoded-name group))
3631 (gnus-message 3 "Can't select group")))
3633 ;; The user did a `C-g' while prompting for number of articles,
3634 ;; so we exit this group.
3635 ((eq did-select 'quit)
3636 (and (eq major-mode 'gnus-summary-mode)
3637 (not (equal (current-buffer) kill-buffer))
3638 (kill-buffer (current-buffer)))
3640 (gnus-kill-or-deaden-summary kill-buffer))
3641 (if (not quit-config)
3643 (set-buffer gnus-group-buffer)
3644 (gnus-group-jump-to-group group)
3645 (gnus-group-next-unread-group 1)
3646 (gnus-configure-windows 'group 'force))
3647 (gnus-handle-ephemeral-exit quit-config))
3648 ;; Finally signal the quit.
3650 ;; The group was successfully selected.
3652 (gnus-set-global-variables)
3653 ;; Save the active value in effect when the group was entered.
3654 (setq gnus-newsgroup-active
3656 (gnus-active gnus-newsgroup-name)))
3657 ;; You can change the summary buffer in some way with this hook.
3658 (gnus-run-hooks 'gnus-select-group-hook)
3659 (when (memq 'summary (gnus-update-format-specifications
3660 nil 'summary 'summary-mode 'summary-dummy))
3661 ;; The format specification for the summary line was updated,
3662 ;; so we need to update the mark positions as well.
3663 (gnus-update-summary-mark-positions))
3664 ;; Do score processing.
3665 (when gnus-use-scoring
3666 (gnus-possibly-score-headers))
3667 ;; Check whether to fill in the gaps in the threads.
3668 (when gnus-build-sparse-threads
3669 (gnus-build-sparse-threads))
3670 ;; Find the initial limit.
3672 (let ((gnus-newsgroup-dormant nil))
3673 (gnus-summary-initial-limit show-all))
3674 (gnus-summary-initial-limit show-all))
3675 ;; Generate the summary buffer.
3677 (gnus-summary-prepare))
3678 (when gnus-use-trees
3679 (gnus-tree-open group)
3680 (setq gnus-summary-highlight-line-function
3681 'gnus-tree-highlight-article))
3682 ;; If the summary buffer is empty, but there are some low-scored
3683 ;; articles or some excluded dormants, we include these in the
3685 (when (and (zerop (buffer-size))
3687 (cond (gnus-newsgroup-dormant
3688 (gnus-summary-limit-include-dormant))
3689 ((and gnus-newsgroup-scored show-all)
3690 (gnus-summary-limit-include-expunged t))))
3691 ;; Function `gnus-apply-kill-file' must be called in this hook.
3692 (gnus-run-hooks 'gnus-apply-kill-hook)
3693 (if (and (zerop (buffer-size))
3696 ;; This newsgroup is empty.
3697 (gnus-summary-catchup-and-exit nil t)
3698 (gnus-message 6 "No unread news")
3700 (gnus-kill-or-deaden-summary kill-buffer))
3701 ;; Return nil from this function.
3703 ;; Hide conversation thread subtrees. We cannot do this in
3704 ;; gnus-summary-prepare-hook since kill processing may not
3705 ;; work with hidden articles.
3706 (gnus-summary-maybe-hide-threads)
3708 (gnus-kill-or-deaden-summary kill-buffer))
3709 (gnus-summary-auto-select-subject)
3710 ;; Show first unread article if requested.
3711 (if (and (not no-article)
3713 gnus-newsgroup-unreads
3714 gnus-auto-select-first)
3716 (gnus-configure-windows 'summary)
3717 (let ((art (gnus-summary-article-number)))
3718 (unless (and (not gnus-plugged)
3719 (or (memq art gnus-newsgroup-undownloaded)
3720 (memq art gnus-newsgroup-downloadable)))
3721 (gnus-summary-goto-article art))))
3722 ;; Don't select any articles.
3723 (gnus-summary-position-point)
3724 (gnus-configure-windows 'summary 'force)
3725 (gnus-set-mode-line 'summary))
3726 (when (and gnus-auto-center-group
3727 (get-buffer-window gnus-group-buffer t))
3728 ;; Gotta use windows, because recenter does weird stuff if
3729 ;; the current buffer ain't the displayed window.
3730 (let ((owin (selected-window)))
3731 (select-window (get-buffer-window gnus-group-buffer t))
3732 (when (gnus-group-goto-group group)
3734 (select-window owin)))
3735 ;; Mark this buffer as "prepared".
3736 (setq gnus-newsgroup-prepared t)
3737 (gnus-run-hooks 'gnus-summary-prepared-hook)
3738 (unless (gnus-ephemeral-group-p group)
3739 (gnus-group-update-group group))
3742 (defun gnus-summary-auto-select-subject ()
3743 "Select the subject line on initial group entry."
3744 (goto-char (point-min))
3746 ((eq gnus-auto-select-subject 'best)
3747 (gnus-summary-best-unread-subject))
3748 ((eq gnus-auto-select-subject 'unread)
3749 (gnus-summary-first-unread-subject))
3750 ((eq gnus-auto-select-subject 'unseen)
3751 (gnus-summary-first-unseen-subject))
3752 ((eq gnus-auto-select-subject 'unseen-or-unread)
3753 (gnus-summary-first-unseen-or-unread-subject))
3754 ((eq gnus-auto-select-subject 'first)
3757 ((functionp gnus-auto-select-subject)
3758 (funcall gnus-auto-select-subject))))
3760 (defun gnus-summary-prepare ()
3761 "Generate the summary buffer."
3763 (let ((buffer-read-only nil))
3765 (setq gnus-newsgroup-data nil
3766 gnus-newsgroup-data-reverse nil)
3767 (gnus-run-hooks 'gnus-summary-generate-hook)
3768 ;; Generate the buffer, either with threads or without.
3769 (when gnus-newsgroup-headers
3770 (gnus-summary-prepare-threads
3771 (if gnus-show-threads
3772 (gnus-sort-gathered-threads
3773 (funcall gnus-summary-thread-gathering-function
3775 (gnus-cut-threads (gnus-make-threads)))))
3776 ;; Unthreaded display.
3777 (gnus-sort-articles gnus-newsgroup-headers))))
3778 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3779 ;; Call hooks for modifying summary buffer.
3780 (goto-char (point-min))
3781 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3783 (defsubst gnus-general-simplify-subject (subject)
3784 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3787 ;; Truncate the subject.
3788 (gnus-simplify-subject-functions
3789 (gnus-map-function gnus-simplify-subject-functions subject))
3790 ((numberp gnus-summary-gather-subject-limit)
3791 (setq subject (gnus-simplify-subject-re subject))
3792 (if (> (length subject) gnus-summary-gather-subject-limit)
3793 (substring subject 0 gnus-summary-gather-subject-limit)
3795 ;; Fuzzily simplify it.
3796 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3797 (gnus-simplify-subject-fuzzy subject))
3798 ;; Just remove the leading "Re:".
3800 (gnus-simplify-subject-re subject))))
3802 (if (and gnus-summary-gather-exclude-subject
3803 (string-match gnus-summary-gather-exclude-subject subject))
3804 nil ; This article shouldn't be gathered
3807 (defun gnus-summary-simplify-subject-query ()
3808 "Query where the respool algorithm would put this article."
3810 (gnus-summary-select-article)
3812 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3814 (defun gnus-gather-threads-by-subject (threads)
3815 "Gather threads by looking at Subject headers."
3816 (if (not gnus-summary-make-false-root)
3818 (let ((hashtb (gnus-make-hashtable 1024))
3821 subject hthread whole-subject)
3823 (setq subject (gnus-general-simplify-subject
3824 (setq whole-subject (mail-header-subject
3827 (if (setq hthread (gnus-gethash subject hashtb))
3829 ;; We enter a dummy root into the thread, if we
3830 ;; haven't done that already.
3831 (unless (stringp (caar hthread))
3832 (setcar hthread (list whole-subject (car hthread))))
3833 ;; We add this new gathered thread to this gathered
3835 (setcdr (car hthread)
3836 (nconc (cdar hthread) (list (car threads))))
3837 ;; Remove it from the list of threads.
3838 (setcdr prev (cdr threads))
3839 (setq threads prev))
3840 ;; Enter this thread into the hash table.
3841 (gnus-sethash subject
3842 (if gnus-summary-make-false-root-always
3844 ;; If you want a dummy root above all
3846 (setcar threads (list whole-subject
3852 (setq threads (cdr threads)))
3855 (defun gnus-gather-threads-by-references (threads)
3856 "Gather threads by looking at References headers."
3857 (let ((idhashtb (gnus-make-hashtable 1024))
3858 (thhashtb (gnus-make-hashtable 1024))
3861 ids references id gthread gid entered ref)
3863 (when (setq references (mail-header-references (caar threads)))
3864 (setq id (mail-header-id (caar threads))
3865 ids (inline (gnus-split-references references))
3867 (while (setq ref (pop ids))
3868 (setq ids (delete ref ids))
3869 (if (not (setq gid (gnus-gethash ref idhashtb)))
3871 (gnus-sethash ref id idhashtb)
3872 (gnus-sethash id threads thhashtb))
3873 (setq gthread (gnus-gethash gid thhashtb))
3875 ;; We enter a dummy root into the thread, if we
3876 ;; haven't done that already.
3877 (unless (stringp (caar gthread))
3878 (setcar gthread (list (mail-header-subject (caar gthread))
3880 ;; We add this new gathered thread to this gathered
3882 (setcdr (car gthread)
3883 (nconc (cdar gthread) (list (car threads)))))
3884 ;; Add it into the thread hash table.
3885 (gnus-sethash id gthread thhashtb)
3887 ;; Remove it from the list of threads.
3888 (setcdr prev (cdr threads))
3889 (setq threads prev))))
3891 (setq threads (cdr threads)))
3894 (defun gnus-sort-gathered-threads (threads)
3895 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3896 (let ((result threads))
3898 (when (stringp (caar threads))
3899 (setcdr (car threads)
3900 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3901 (setq threads (cdr threads)))
3904 (defun gnus-thread-loop-p (root thread)
3905 "Say whether ROOT is in THREAD."
3906 (let ((stack (list thread))
3909 (while (setq thread (pop stack))
3910 (setq th (cdr thread))
3912 (not (eq (caar th) root)))
3915 ;; We have found a loop.
3917 (setcdr thread (delq (car th) (cdr thread)))
3918 (if (boundp (setq ref-dep (intern "none"
3919 gnus-newsgroup-dependencies)))
3920 (setcdr (symbol-value ref-dep)
3921 (nconc (cdr (symbol-value ref-dep))
3923 (set ref-dep (list nil (car th))))
3926 ;; Push all the subthreads onto the stack.
3927 (push (cdr thread) stack)))
3930 (defun gnus-make-threads ()
3931 "Go through the dependency hashtb and find the roots. Return all threads."
3933 (while (catch 'infloop
3936 ;; Deal with self-referencing References loops.
3937 (when (and (car (symbol-value refs))
3944 (car (symbol-value refs)) thread))
3945 (cdr (symbol-value refs)))))))
3948 (unless (car (symbol-value refs))
3949 ;; These threads do not refer back to any other articles,
3950 ;; so they're roots.
3951 (setq threads (append (cdr (symbol-value refs)) threads))))
3952 gnus-newsgroup-dependencies)))
3955 ;; Build the thread tree.
3956 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3957 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3959 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3960 if it was already present.
3962 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3963 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3964 Message-IDs will be renamed to a unique Message-ID before being
3967 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3968 (let* ((id (mail-header-id header))
3969 (id-dep (and id (intern id dependencies)))
3970 parent-id ref ref-dep ref-header replaced)
3971 ;; Enter this `header' in the `dependencies' table.
3975 ;; The first two cases do the normal part: enter a new `header'
3976 ;; in the `dependencies' table.
3977 ((not (boundp id-dep))
3978 (set id-dep (list header)))
3979 ((null (car (symbol-value id-dep)))
3980 (setcar (symbol-value id-dep) header))
3982 ;; From here the `header' was already present in the
3983 ;; `dependencies' table.
3985 ;; Overrides an existing entry;
3986 ;; just set the header part of the entry.
3987 (setcar (symbol-value id-dep) header)
3990 ;; Renames the existing `header' to a unique Message-ID.
3991 ((not gnus-summary-ignore-duplicates)
3992 ;; An article with this Message-ID has already been seen.
3993 ;; We rename the Message-ID.
3994 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3996 (mail-header-set-id header id))
3998 ;; The last case ignores an existing entry, except it adds any
3999 ;; additional Xrefs (in case the two articles came from different
4001 ;; Also sets `header' to `nil' meaning that the `dependencies'
4002 ;; table was *not* modified.
4004 (mail-header-set-xref
4005 (car (symbol-value id-dep))
4006 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4008 (or (mail-header-xref header) "")))
4011 (when (and header (not replaced))
4012 ;; First check that we are not creating a References loop.
4013 (setq parent-id (gnus-parent-id (mail-header-references header)))
4014 (setq ref parent-id)
4016 (setq ref-dep (intern-soft ref dependencies))
4018 (setq ref-header (car (symbol-value ref-dep))))
4019 (if (string= id ref)
4020 ;; Yuk! This is a reference loop. Make the article be a
4023 (mail-header-set-references (car (symbol-value id-dep)) "none")
4025 (setq parent-id nil))
4026 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4027 (setq ref-dep (intern (or parent-id "none") dependencies))
4028 (if (boundp ref-dep)
4029 (setcdr (symbol-value ref-dep)
4030 (nconc (cdr (symbol-value ref-dep))
4031 (list (symbol-value id-dep))))
4032 (set ref-dep (list nil (symbol-value id-dep)))))
4035 (defun gnus-extract-message-id-from-in-reply-to (string)
4036 (if (string-match "<[^>]+>" string)
4037 (substring string (match-beginning 0) (match-end 0))
4040 (defun gnus-build-sparse-threads ()
4041 (let ((headers gnus-newsgroup-headers)
4042 (mail-parse-charset gnus-newsgroup-charset)
4043 (gnus-summary-ignore-duplicates t)
4044 header references generation relations
4045 subject child end new-child date)
4046 ;; First we create an alist of generations/relations, where
4047 ;; generations is how much we trust the relation, and the relation
4049 (gnus-message 7 "Making sparse threads...")
4051 (nnheader-set-temp-buffer " *gnus sparse threads*")
4052 (while (setq header (pop headers))
4053 (when (and (setq references (mail-header-references header))
4054 (not (string= references "")))
4056 (setq child (mail-header-id header)
4057 subject (mail-header-subject header)
4058 date (mail-header-date header)
4060 (while (search-backward ">" nil t)
4061 (setq end (1+ (point)))
4062 (when (search-backward "<" nil t)
4063 (setq new-child (buffer-substring (point) end))
4064 (push (list (incf generation)
4065 child (setq child new-child)
4069 (push (list (1+ generation) child nil subject) relations))
4071 (kill-buffer (current-buffer)))
4072 ;; Sort over trustworthiness.
4075 (when (gnus-dependencies-add-header
4076 (make-full-mail-header-from-decoded-header
4077 gnus-reffed-article-number
4078 (nth 3 relation) "" (or (nth 4 relation) "")
4080 (or (nth 2 relation) "") 0 0 "")
4081 gnus-newsgroup-dependencies nil)
4082 (push gnus-reffed-article-number gnus-newsgroup-limit)
4083 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4084 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4085 gnus-newsgroup-reads)
4086 (decf gnus-reffed-article-number)))
4087 (sort relations 'car-less-than-car))
4088 (gnus-message 7 "Making sparse threads...done")))
4090 (defun gnus-build-old-threads ()
4091 ;; Look at all the articles that refer back to old articles, and
4092 ;; fetch the headers for the articles that aren't there. This will
4093 ;; build complete threads - if the roots haven't been expired by the
4095 (let ((mail-parse-charset gnus-newsgroup-charset)
4099 (when (not (car (symbol-value refs)))
4100 (setq heads (cdr (symbol-value refs)))
4102 (if (memq (mail-header-number (caar heads))
4103 gnus-newsgroup-dormant)
4104 (setq heads (cdr heads))
4105 (setq id (symbol-name refs))
4106 (while (and (setq id (gnus-build-get-header id))
4107 (not (car (gnus-id-to-thread id)))))
4108 (setq heads nil)))))
4109 gnus-newsgroup-dependencies)))
4111 (defsubst gnus-remove-odd-characters (string)
4112 "Translate STRING into something that doesn't contain weird characters."
4113 (mm-subst-char-in-string
4115 (mm-subst-char-in-string ?\n ?\- string t) t))
4117 ;; This function has to be called with point after the article number
4118 ;; on the beginning of the line.
4119 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4120 (let ((eol (point-at-eol))
4121 (buffer (current-buffer))
4122 header references in-reply-to)
4124 ;; overview: [num subject from date id refs chars lines misc]
4127 (narrow-to-region (point) eol)
4132 (make-full-mail-header
4134 (nnheader-nov-field) ; subject
4135 (nnheader-nov-field) ; from
4136 (nnheader-nov-field) ; date
4137 (nnheader-nov-read-message-id number) ; id
4138 (setq references (nnheader-nov-field)) ; refs
4139 (nnheader-nov-read-integer) ; chars
4140 (nnheader-nov-read-integer) ; lines
4142 (if (looking-at "Xref: ")
4143 (goto-char (match-end 0)))
4144 (nnheader-nov-field)) ; Xref
4145 (nnheader-nov-parse-extra)))) ; extra
4149 (when (and (string= references "")
4150 (setq in-reply-to (mail-header-extra header))
4151 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4152 (mail-header-set-references
4153 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4155 (when gnus-alter-header-function
4156 (funcall gnus-alter-header-function header))
4157 (gnus-dependencies-add-header header dependencies force-new)))
4159 (defun gnus-build-get-header (id)
4160 "Look through the buffer of NOV lines and find the header to ID.
4161 Enter this line into the dependencies hash table, and return
4162 the id of the parent article (if any)."
4163 (let ((deps gnus-newsgroup-dependencies)
4167 (set-buffer nntp-server-buffer)
4168 (let ((case-fold-search nil))
4169 (goto-char (point-min))
4170 (while (and (not found)
4171 (search-forward id nil t))
4173 (setq found (looking-at
4174 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4175 (regexp-quote id))))
4176 (or found (beginning-of-line 2)))
4180 (setq header (gnus-nov-parse-line
4181 (read (current-buffer)) deps))
4182 (gnus-parent-id (mail-header-references header))))))
4184 (let ((number (mail-header-number header)))
4185 (push number gnus-newsgroup-limit)
4186 (push header gnus-newsgroup-headers)
4187 (if (memq number gnus-newsgroup-unselected)
4189 (setq gnus-newsgroup-unreads
4190 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4192 (setq gnus-newsgroup-unselected
4193 (delq number gnus-newsgroup-unselected)))
4194 (push number gnus-newsgroup-ancient)))))))
4196 (defun gnus-build-all-threads ()
4197 "Read all the headers."
4198 (let ((gnus-summary-ignore-duplicates t)
4199 (mail-parse-charset gnus-newsgroup-charset)
4200 (dependencies gnus-newsgroup-dependencies)
4203 (set-buffer nntp-server-buffer)
4204 (let ((case-fold-search nil))
4205 (goto-char (point-min))
4208 (setq article (read (current-buffer))
4209 header (gnus-nov-parse-line article dependencies)))
4211 (with-current-buffer gnus-summary-buffer
4212 (push header gnus-newsgroup-headers)
4213 (if (memq (setq article (mail-header-number header))
4214 gnus-newsgroup-unselected)
4216 (setq gnus-newsgroup-unreads
4217 (gnus-add-to-sorted-list
4218 gnus-newsgroup-unreads article))
4219 (setq gnus-newsgroup-unselected
4220 (delq article gnus-newsgroup-unselected)))
4221 (push article gnus-newsgroup-ancient)))
4222 (forward-line 1)))))))
4224 (defun gnus-summary-update-article-line (article header)
4225 "Update the line for ARTICLE using HEADER."
4226 (let* ((id (mail-header-id header))
4227 (thread (gnus-id-to-thread id)))
4229 (error "Article in no thread"))
4230 ;; Update the thread.
4231 (setcar thread header)
4232 (gnus-summary-goto-subject article)
4233 (let* ((datal (gnus-data-find-list article))
4235 (buffer-read-only nil)
4236 (level (gnus-summary-thread-level)))
4238 (let ((inserted (- (point)
4240 (gnus-summary-insert-line
4242 (memq article gnus-newsgroup-undownloaded)
4243 (gnus-article-mark article)
4244 (memq article gnus-newsgroup-replied)
4245 (memq article gnus-newsgroup-expirable)
4246 ;; Only insert the Subject string when it's different
4247 ;; from the previous Subject string.
4252 (mail-header-subject
4255 (gnus-data-find-list
4257 (gnus-data-list t)))))
4258 ;; Error on the side of excessive subjects.
4260 (mail-header-subject header)))
4262 (mail-header-subject header))
4263 nil (cdr (assq article gnus-newsgroup-scored))
4264 (memq article gnus-newsgroup-processable))
4267 (gnus-data-update-list
4269 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4271 (defun gnus-summary-update-article (article &optional iheader)
4272 "Update ARTICLE in the summary buffer."
4273 (set-buffer gnus-summary-buffer)
4274 (let* ((header (gnus-summary-article-header article))
4275 (id (mail-header-id header))
4276 (data (gnus-data-find article))
4277 (thread (gnus-id-to-thread id))
4278 (references (mail-header-references header))
4282 (when (and references
4283 (not (equal "" references)))
4286 (buffer-read-only nil)
4292 (delq thread parent)))
4293 (if (gnus-summary-insert-subject id header)
4294 ;; Set the (possibly) new article number in the data structure.
4295 (gnus-data-set-number data (gnus-id-to-article id))
4299 (defun gnus-rebuild-thread (id &optional line)
4300 "Rebuild the thread containing ID.
4301 If LINE, insert the rebuilt thread starting on line LINE."
4302 (let ((buffer-read-only nil)
4303 old-pos current thread data)
4304 (if (not gnus-show-threads)
4305 (setq thread (list (car (gnus-id-to-thread id))))
4306 ;; Get the thread this article is part of.
4307 (setq thread (gnus-remove-thread id)))
4308 (setq old-pos (point-at-bol))
4309 (setq current (save-excursion
4310 (and (re-search-backward "[\r\n]" nil t)
4311 (gnus-summary-article-number))))
4312 ;; If this is a gathered thread, we have to go some re-gathering.
4313 (when (stringp (car thread))
4314 (let ((subject (car thread))
4316 (setq thread (cdr thread))
4318 (unless (memq (setq thr (gnus-id-to-thread
4320 (mail-header-id (caar thread)))))
4323 (setq thread (cdr thread)))
4324 ;; We now have all (unique) roots.
4325 (if (= (length roots) 1)
4326 ;; All the loose roots are now one solid root.
4327 (setq thread (car roots))
4328 (setq thread (cons subject (gnus-sort-threads roots))))))
4330 ;; We then insert this thread into the summary buffer.
4332 (goto-char (point-min))
4333 (forward-line (1- line)))
4334 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4335 (if gnus-show-threads
4336 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4337 (gnus-summary-prepare-unthreaded thread))
4338 (setq data (nreverse gnus-newsgroup-data))
4339 (setq threads gnus-newsgroup-threads))
4340 ;; We splice the new data into the data structure.
4341 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4342 ;;!!! then we want to insert at the beginning of the buffer.
4343 ;;!!! That happens to be true with Gnus now, but that may
4344 ;;!!! change in the future. Perhaps.
4345 (gnus-data-enter-list
4346 (if line nil current) data (- (point) old-pos))
4347 (setq gnus-newsgroup-threads
4348 (nconc threads gnus-newsgroup-threads))
4349 (gnus-data-compute-positions))))
4351 (defun gnus-number-to-header (number)
4352 "Return the header for article NUMBER."
4353 (let ((headers gnus-newsgroup-headers))
4355 (not (= number (mail-header-number (car headers)))))
4360 (defun gnus-parent-headers (in-headers &optional generation)
4361 "Return the headers of the GENERATIONeth parent of HEADERS."
4363 (setq generation 1))
4365 (headers in-headers)
4368 (not (zerop generation))
4369 (setq references (mail-header-references headers)))
4370 (setq headers (if (and references
4371 (setq parent (gnus-parent-id references)))
4372 (car (gnus-id-to-thread parent))
4375 (and (not (eq headers in-headers))
4378 (defun gnus-id-to-thread (id)
4379 "Return the (sub-)thread where ID appears."
4380 (gnus-gethash id gnus-newsgroup-dependencies))
4382 (defun gnus-id-to-article (id)
4383 "Return the article number of ID."
4384 (let ((thread (gnus-id-to-thread id)))
4387 (mail-header-number (car thread)))))
4389 (defun gnus-id-to-header (id)
4390 "Return the article headers of ID."
4391 (car (gnus-id-to-thread id)))
4393 (defun gnus-article-displayed-root-p (article)
4394 "Say whether ARTICLE is a root(ish) article."
4395 (let ((level (gnus-summary-thread-level article))
4396 (refs (mail-header-references (gnus-summary-article-header article)))
4402 ((null (gnus-parent-id refs)) t)
4404 (null (setq particle (gnus-id-to-article
4405 (gnus-parent-id refs))))
4406 (null (gnus-summary-thread-level particle)))))))
4408 (defun gnus-root-id (id)
4409 "Return the id of the root of the thread where ID appears."
4411 (while (and id (setq prev (car (gnus-id-to-thread id))))
4413 id (gnus-parent-id (mail-header-references prev))))
4416 (defun gnus-articles-in-thread (thread)
4417 "Return the list of articles in THREAD."
4418 (cons (mail-header-number (car thread))
4419 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4421 (defun gnus-remove-thread (id &optional dont-remove)
4422 "Remove the thread that has ID in it."
4423 (let (headers thread last-id)
4424 ;; First go up in this thread until we find the root.
4425 (setq last-id (gnus-root-id id)
4426 headers (message-flatten-list (gnus-id-to-thread last-id)))
4427 ;; We have now found the real root of this thread. It might have
4428 ;; been gathered into some loose thread, so we have to search
4429 ;; through the threads to find the thread we wanted.
4430 (let ((threads gnus-newsgroup-threads)
4433 (setq sub (car threads))
4434 (if (stringp (car sub))
4435 ;; This is a gathered thread, so we look at the roots
4436 ;; below it to find whether this article is in this
4439 (setq sub (cdr sub))
4441 (when (member (caar sub) headers)
4442 (setq thread (car threads)
4445 (setq sub (cdr sub))))
4446 ;; It's an ordinary thread, so we check it.
4447 (when (eq (car sub) (car headers))
4450 (setq threads (cdr threads)))
4451 ;; If this article is in no thread, then it's a root.
4454 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4455 (setq thread (gnus-id-to-thread last-id)))
4458 thread ; We return this thread.
4460 (if (stringp (car thread))
4462 ;; If we use dummy roots, then we have to remove the
4463 ;; dummy root as well.
4464 (when (eq gnus-summary-make-false-root 'dummy)
4465 ;; We go to the dummy root by going to
4466 ;; the first sub-"thread", and then one line up.
4467 (gnus-summary-goto-article
4468 (mail-header-number (caadr thread)))
4471 (gnus-data-compute-positions))
4472 (setq thread (cdr thread))
4474 (gnus-remove-thread-1 (car thread))
4475 (setq thread (cdr thread))))
4476 (gnus-remove-thread-1 thread))))))))
4478 (defun gnus-remove-thread-1 (thread)
4479 "Remove the thread THREAD recursively."
4480 (let ((number (mail-header-number (pop thread)))
4482 (setq thread (reverse thread))
4484 (gnus-remove-thread-1 (pop thread)))
4485 (when (setq d (gnus-data-find number))
4486 (goto-char (gnus-data-pos d))
4487 (gnus-summary-show-thread)
4493 (gnus-delete-line)))))))
4495 (defun gnus-sort-threads-1 (threads func)
4496 (sort (mapcar (lambda (thread)
4499 (gnus-sort-threads-1 (cdr thread) func))))
4502 (defun gnus-sort-threads (threads)
4504 (if (not gnus-thread-sort-functions)
4506 (gnus-message 8 "Sorting threads...")
4507 (let ((max-lisp-eval-depth 5000))
4508 (prog1 (gnus-sort-threads-1
4510 (gnus-make-sort-function gnus-thread-sort-functions))
4511 (gnus-message 8 "Sorting threads...done")))))
4513 (defun gnus-sort-articles (articles)
4515 (when gnus-article-sort-functions
4516 (gnus-message 7 "Sorting articles...")
4518 (setq gnus-newsgroup-headers
4519 (sort articles (gnus-make-sort-function
4520 gnus-article-sort-functions)))
4521 (gnus-message 7 "Sorting articles...done"))))
4523 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4524 (defmacro gnus-thread-header (thread)
4525 "Return header of first article in THREAD.
4526 Note that THREAD must never, ever be anything else than a variable -
4527 using some other form will lead to serious barfage."
4528 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4529 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4530 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4533 (defsubst gnus-article-sort-by-number (h1 h2)
4534 "Sort articles by article number."
4535 (< (mail-header-number h1)
4536 (mail-header-number h2)))
4538 (defun gnus-thread-sort-by-number (h1 h2)
4539 "Sort threads by root article number."
4540 (gnus-article-sort-by-number
4541 (gnus-thread-header h1) (gnus-thread-header h2)))
4543 (defsubst gnus-article-sort-by-random (h1 h2)
4544 "Sort articles by article number."
4547 (defun gnus-thread-sort-by-random (h1 h2)
4548 "Sort threads by root article number."
4549 (gnus-article-sort-by-random
4550 (gnus-thread-header h1) (gnus-thread-header h2)))
4552 (defsubst gnus-article-sort-by-lines (h1 h2)
4553 "Sort articles by article Lines header."
4554 (< (mail-header-lines h1)
4555 (mail-header-lines h2)))
4557 (defun gnus-thread-sort-by-lines (h1 h2)
4558 "Sort threads by root article Lines header."
4559 (gnus-article-sort-by-lines
4560 (gnus-thread-header h1) (gnus-thread-header h2)))
4562 (defsubst gnus-article-sort-by-chars (h1 h2)
4563 "Sort articles by octet length."
4564 (< (mail-header-chars h1)
4565 (mail-header-chars h2)))
4567 (defun gnus-thread-sort-by-chars (h1 h2)
4568 "Sort threads by root article octet length."
4569 (gnus-article-sort-by-chars
4570 (gnus-thread-header h1) (gnus-thread-header h2)))
4572 (defsubst gnus-article-sort-by-author (h1 h2)
4573 "Sort articles by root author."
4575 (let ((addr (car (mime-entity-read-field h1 'From))))
4576 (or (std11-full-name-string addr)
4577 (std11-address-string addr)
4579 (let ((addr (car (mime-entity-read-field h2 'From))))
4580 (or (std11-full-name-string addr)
4581 (std11-address-string addr)
4585 (defun gnus-thread-sort-by-author (h1 h2)
4586 "Sort threads by root author."
4587 (gnus-article-sort-by-author
4588 (gnus-thread-header h1) (gnus-thread-header h2)))
4590 (defsubst gnus-article-sort-by-recipient (h1 h2)
4591 "Sort articles by recipient."
4593 (let ((extract (funcall
4594 gnus-extract-address-components
4595 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4596 (or (car extract) (cadr extract)))
4597 (let ((extract (funcall
4598 gnus-extract-address-components
4599 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4600 (or (car extract) (cadr extract)))))
4602 (defsubst gnus-article-sort-by-subject (h1 h2)
4603 "Sort articles by root subject."
4605 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4606 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4608 (defun gnus-thread-sort-by-subject (h1 h2)
4609 "Sort threads by root subject."
4610 (gnus-article-sort-by-subject
4611 (gnus-thread-header h1) (gnus-thread-header h2)))
4613 (defsubst gnus-article-sort-by-date (h1 h2)
4614 "Sort articles by root article date."
4616 (gnus-date-get-time (mail-header-date h1))
4617 (gnus-date-get-time (mail-header-date h2))))
4619 (defun gnus-thread-sort-by-date (h1 h2)
4620 "Sort threads by root article date."
4621 (gnus-article-sort-by-date
4622 (gnus-thread-header h1) (gnus-thread-header h2)))
4624 (defsubst gnus-article-sort-by-score (h1 h2)
4625 "Sort articles by root article score.
4626 Unscored articles will be counted as having a score of zero."
4627 (> (or (cdr (assq (mail-header-number h1)
4628 gnus-newsgroup-scored))
4629 gnus-summary-default-score 0)
4630 (or (cdr (assq (mail-header-number h2)
4631 gnus-newsgroup-scored))
4632 gnus-summary-default-score 0)))
4634 (defun gnus-thread-sort-by-score (h1 h2)
4635 "Sort threads by root article score."
4636 (gnus-article-sort-by-score
4637 (gnus-thread-header h1) (gnus-thread-header h2)))
4639 (defun gnus-thread-sort-by-total-score (h1 h2)
4640 "Sort threads by the sum of all scores in the thread.
4641 Unscored articles will be counted as having a score of zero."
4642 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4644 (defun gnus-thread-total-score (thread)
4645 ;; This function find the total score of THREAD.
4650 (if (stringp (car thread))
4651 (apply gnus-thread-score-function 0
4652 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4653 (gnus-thread-total-score-1 thread)))
4655 (gnus-thread-total-score-1 (list thread)))))
4657 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4658 "Sort threads such that the thread with the most recently arrived article comes first."
4659 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4661 (defun gnus-thread-highest-number (thread)
4662 "Return the highest article number in THREAD."
4663 (apply 'max (mapcar (lambda (header)
4664 (mail-header-number header))
4665 (message-flatten-list thread))))
4667 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4668 "Sort threads such that the thread with the most recently dated article comes first."
4669 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4671 (defun gnus-thread-latest-date (thread)
4672 "Return the highest article date in THREAD."
4673 (let ((previous-time 0))
4679 (time-to-seconds (mail-header-parse-date
4680 (mail-header-date header)))
4681 (error previous-time))))
4683 (message-flatten-list thread)
4685 (< (mail-header-number h1)
4686 (mail-header-number h2))))))))
4688 (defun gnus-thread-total-score-1 (root)
4689 ;; This function find the total score of the thread below ROOT.
4690 (setq root (car root))
4691 (apply gnus-thread-score-function
4693 (mapcar 'gnus-thread-total-score
4694 (cdr (gnus-id-to-thread (mail-header-id root))))
4695 (when (> (mail-header-number root) 0)
4696 (list (or (cdr (assq (mail-header-number root)
4697 gnus-newsgroup-scored))
4698 gnus-summary-default-score 0))))
4699 (list gnus-summary-default-score)
4702 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4703 (defvar gnus-tmp-prev-subject nil)
4704 (defvar gnus-tmp-false-parent nil)
4705 (defvar gnus-tmp-root-expunged nil)
4706 (defvar gnus-tmp-dummy-line nil)
4708 (eval-when-compile (defvar gnus-tmp-header))
4709 (defun gnus-extra-header (type &optional header)
4710 "Return the extra header of TYPE."
4711 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4714 (defvar gnus-tmp-thread-tree-header-string "")
4716 (defcustom gnus-sum-thread-tree-root "> "
4717 "With %B spec, used for the root of a thread.
4718 If nil, use subject instead."
4720 :type '(radio (const :format "%v " nil) string)
4721 :group 'gnus-thread)
4722 (defcustom gnus-sum-thread-tree-false-root "> "
4723 "With %B spec, used for a false root of a thread.
4724 If nil, use subject instead."
4726 :type '(radio (const :format "%v " nil) string)
4727 :group 'gnus-thread)
4728 (defcustom gnus-sum-thread-tree-single-indent ""
4729 "With %B spec, used for a thread with just one message.
4730 If nil, use subject instead."
4732 :type '(radio (const :format "%v " nil) string)
4733 :group 'gnus-thread)
4734 (defcustom gnus-sum-thread-tree-vertical "| "
4735 "With %B spec, used for drawing a vertical line."
4738 :group 'gnus-thread)
4739 (defcustom gnus-sum-thread-tree-indent " "
4740 "With %B spec, used for indenting."
4743 :group 'gnus-thread)
4744 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4745 "With %B spec, used for a leaf with brothers."
4748 :group 'gnus-thread)
4749 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4750 "With %B spec, used for a leaf without brothers."
4753 :group 'gnus-thread)
4755 (defun gnus-summary-prepare-threads (threads)
4756 "Prepare summary buffer from THREADS and indentation LEVEL.
4757 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4758 or a straight list of headers."
4759 (gnus-message 7 "Generating summary...")
4761 (setq gnus-newsgroup-threads threads)
4764 (let ((gnus-tmp-level 0)
4765 (default-score (or gnus-summary-default-score 0))
4766 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4767 (building-line-count gnus-summary-display-while-building)
4768 (building-count (integerp gnus-summary-display-while-building))
4769 thread number subject stack state gnus-tmp-gathered beg-match
4770 new-roots gnus-tmp-new-adopts thread-end simp-subject
4771 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4772 gnus-tmp-replied gnus-tmp-subject-or-nil
4773 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4774 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4775 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4778 (setq gnus-tmp-prev-subject nil
4779 gnus-tmp-thread-tree-header-string "")
4781 (if (vectorp (car threads))
4782 ;; If this is a straight (sic) list of headers, then a
4783 ;; threaded summary display isn't required, so we just create
4784 ;; an unthreaded one.
4785 (gnus-summary-prepare-unthreaded threads)
4787 ;; Do the threaded display.
4789 (if gnus-summary-display-while-building
4790 (switch-to-buffer (buffer-name)))
4791 (while (or threads stack gnus-tmp-new-adopts new-roots)
4793 (if (and (= gnus-tmp-level 0)
4796 (not gnus-tmp-false-parent)
4797 (or gnus-tmp-new-adopts new-roots))
4798 (if gnus-tmp-new-adopts
4799 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4800 thread (list (car gnus-tmp-new-adopts))
4801 gnus-tmp-header (caar thread)
4802 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4804 (setq thread (list (car new-roots))
4805 gnus-tmp-header (caar thread)
4806 new-roots (cdr new-roots))))
4809 ;; If there are some threads, we do them before the
4810 ;; threads on the stack.
4811 (setq thread threads
4812 gnus-tmp-header (caar thread))
4813 ;; There were no current threads, so we pop something off
4815 (setq state (car stack)
4816 gnus-tmp-level (car state)
4817 tree-stack (cadr state)
4818 thread (caddr state)
4820 gnus-tmp-header (caar thread))))
4822 (setq gnus-tmp-false-parent nil)
4823 (setq gnus-tmp-root-expunged nil)
4824 (setq thread-end nil)
4826 (if (stringp gnus-tmp-header)
4827 ;; The header is a dummy root.
4829 ((eq gnus-summary-make-false-root 'adopt)
4830 ;; We let the first article adopt the rest.
4831 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4833 (setq gnus-tmp-gathered
4835 (lambda (h) (mail-header-number (car h)))
4838 (setq thread (cons (list (caar thread)
4841 (setq gnus-tmp-level -1
4842 gnus-tmp-false-parent t))
4843 ((eq gnus-summary-make-false-root 'empty)
4844 ;; We print adopted articles with empty subject fields.
4845 (setq gnus-tmp-gathered
4847 (lambda (h) (mail-header-number (car h)))
4850 (setq gnus-tmp-level -1))
4851 ((eq gnus-summary-make-false-root 'dummy)
4852 ;; We remember that we probably want to output a dummy
4854 (setq gnus-tmp-dummy-line gnus-tmp-header)
4855 (setq gnus-tmp-prev-subject gnus-tmp-header))
4857 ;; We do not make a root for the gathered
4858 ;; sub-threads at all.
4859 (setq gnus-tmp-level -1)))
4861 (setq number (mail-header-number gnus-tmp-header)
4862 subject (mail-header-subject gnus-tmp-header)
4863 simp-subject (gnus-simplify-subject-fully subject))
4866 ;; If the thread has changed subject, we might want to make
4867 ;; this subthread into a root.
4868 ((and (null gnus-thread-ignore-subject)
4869 (not (zerop gnus-tmp-level))
4870 gnus-tmp-prev-subject
4871 (not (string= gnus-tmp-prev-subject simp-subject)))
4872 (setq new-roots (nconc new-roots (list (car thread)))
4874 gnus-tmp-header nil))
4875 ;; If the article lies outside the current limit,
4876 ;; then we do not display it.
4877 ((not (memq number gnus-newsgroup-limit))
4878 (setq gnus-tmp-gathered
4880 (lambda (h) (mail-header-number (car h)))
4883 (setq gnus-tmp-new-adopts (if (cdar thread)
4884 (append gnus-tmp-new-adopts
4886 gnus-tmp-new-adopts)
4888 gnus-tmp-header nil)
4889 (when (zerop gnus-tmp-level)
4890 (setq gnus-tmp-root-expunged t)))
4891 ;; Perhaps this article is to be marked as read?
4892 ((and gnus-summary-mark-below
4893 (< (or (cdr (assq number gnus-newsgroup-scored))
4895 gnus-summary-mark-below)
4896 ;; Don't touch sparse articles.
4897 (not (gnus-summary-article-sparse-p number))
4898 (not (gnus-summary-article-ancient-p number)))
4899 (setq gnus-newsgroup-unreads
4900 (delq number gnus-newsgroup-unreads))
4901 (if gnus-newsgroup-auto-expire
4902 (setq gnus-newsgroup-expirable
4903 (gnus-add-to-sorted-list
4904 gnus-newsgroup-expirable number))
4905 (push (cons number gnus-low-score-mark)
4906 gnus-newsgroup-reads))))
4908 (when gnus-tmp-header
4909 ;; We may have an old dummy line to output before this
4911 (when (and gnus-tmp-dummy-line
4914 (mail-header-subject gnus-tmp-header)))
4915 (gnus-summary-insert-dummy-line
4916 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4917 (setq gnus-tmp-dummy-line nil))
4919 ;; Compute the mark.
4920 (setq gnus-tmp-unread (gnus-article-mark number))
4922 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4923 gnus-tmp-header gnus-tmp-level)
4924 gnus-newsgroup-data)
4926 ;; Actually insert the line.
4928 gnus-tmp-subject-or-nil
4930 ((and gnus-thread-ignore-subject
4931 gnus-tmp-prev-subject
4932 (not (string= gnus-tmp-prev-subject simp-subject)))
4934 ((zerop gnus-tmp-level)
4935 (if (and (eq gnus-summary-make-false-root 'empty)
4936 (memq number gnus-tmp-gathered)
4937 gnus-tmp-prev-subject
4938 (string= gnus-tmp-prev-subject simp-subject))
4939 gnus-summary-same-subject
4941 (t gnus-summary-same-subject)))
4942 (if (and (eq gnus-summary-make-false-root 'adopt)
4943 (= gnus-tmp-level 1)
4944 (memq number gnus-tmp-gathered))
4945 (setq gnus-tmp-opening-bracket ?\<
4946 gnus-tmp-closing-bracket ?\>)
4947 (setq gnus-tmp-opening-bracket ?\[
4948 gnus-tmp-closing-bracket ?\]))
4950 gnus-tmp-indentation
4951 (aref gnus-thread-indent-array gnus-tmp-level)
4952 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4953 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4954 gnus-summary-default-score 0)
4956 (if (or (null gnus-summary-default-score)
4957 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4958 gnus-summary-zcore-fuzz))
4960 (if (< gnus-tmp-score gnus-summary-default-score)
4961 gnus-score-below-mark gnus-score-over-mark))
4963 (cond ((memq number gnus-newsgroup-processable)
4965 ((memq number gnus-newsgroup-cached)
4967 ((memq number gnus-newsgroup-replied)
4969 ((memq number gnus-newsgroup-forwarded)
4970 gnus-forwarded-mark)
4971 ((memq number gnus-newsgroup-saved)
4973 ((memq number gnus-newsgroup-recent)
4975 ((memq number gnus-newsgroup-unseen)
4979 (cond ((memq number gnus-newsgroup-undownloaded)
4980 gnus-undownloaded-mark)
4981 (gnus-newsgroup-agentized
4982 gnus-downloaded-mark)
4985 gnus-tmp-from (mail-header-from gnus-tmp-header)
4988 ((string-match "<[^>]+> *$" gnus-tmp-from)
4989 (setq beg-match (match-beginning 0))
4990 (or (and (string-match "^\".+\"" gnus-tmp-from)
4991 (substring gnus-tmp-from 1 (1- (match-end 0))))
4992 (substring gnus-tmp-from 0 beg-match)))
4993 ((string-match "(.+)" gnus-tmp-from)
4994 (substring gnus-tmp-from
4995 (1+ (match-beginning 0)) (1- (match-end 0))))
4999 gnus-tmp-thread-tree-header-string
5001 ((not gnus-show-threads) "")
5002 ((zerop gnus-tmp-level)
5003 (cond ((cdar thread)
5004 (or gnus-sum-thread-tree-root subject))
5005 (gnus-tmp-new-adopts
5006 (or gnus-sum-thread-tree-false-root subject))
5008 (or gnus-sum-thread-tree-single-indent subject))))
5010 (concat (apply 'concat
5011 (mapcar (lambda (item)
5013 gnus-sum-thread-tree-vertical
5014 gnus-sum-thread-tree-indent))
5015 (cdr (reverse tree-stack))))
5017 gnus-sum-thread-tree-leaf-with-other
5018 gnus-sum-thread-tree-single-leaf)))))
5019 (when (string= gnus-tmp-name "")
5020 (setq gnus-tmp-name gnus-tmp-from))
5021 (unless (numberp gnus-tmp-lines)
5022 (setq gnus-tmp-lines -1))
5023 (if (= gnus-tmp-lines -1)
5024 (setq gnus-tmp-lines "?")
5025 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5026 (gnus-put-text-property
5028 (progn (eval gnus-summary-line-format-spec) (point))
5029 'gnus-number number)
5032 (gnus-run-hooks 'gnus-summary-update-hook)
5035 (setq gnus-tmp-prev-subject simp-subject)))
5037 (when (nth 1 thread)
5038 (push (list (max 0 gnus-tmp-level)
5039 (copy-sequence tree-stack)
5042 (push (if (nth 1 thread) 1 0) tree-stack)
5043 (incf gnus-tmp-level)
5044 (setq threads (if thread-end nil (cdar thread)))
5045 (if gnus-summary-display-while-building
5048 ;; use a set frequency
5049 (setq building-line-count (1- building-line-count))
5050 (when (= building-line-count 0)
5052 (setq building-line-count
5053 gnus-summary-display-while-building)))
5057 (setq gnus-tmp-level 0)))))
5058 (gnus-message 7 "Generating summary...done"))
5060 (defun gnus-summary-prepare-unthreaded (headers)
5061 "Generate an unthreaded summary buffer based on HEADERS."
5062 (let (header number mark)
5067 ;; We may have to root out some bad articles...
5068 (when (memq (setq number (mail-header-number
5069 (setq header (pop headers))))
5070 gnus-newsgroup-limit)
5071 ;; Mark article as read when it has a low score.
5072 (when (and gnus-summary-mark-below
5073 (< (or (cdr (assq number gnus-newsgroup-scored))
5074 gnus-summary-default-score 0)
5075 gnus-summary-mark-below)
5076 (not (gnus-summary-article-ancient-p number)))
5077 (setq gnus-newsgroup-unreads
5078 (delq number gnus-newsgroup-unreads))
5079 (if gnus-newsgroup-auto-expire
5080 (push number gnus-newsgroup-expirable)
5081 (push (cons number gnus-low-score-mark)
5082 gnus-newsgroup-reads)))
5084 (setq mark (gnus-article-mark number))
5085 (push (gnus-data-make number mark (1+ (point)) header 0)
5086 gnus-newsgroup-data)
5087 (gnus-summary-insert-line
5089 (memq number gnus-newsgroup-undownloaded)
5090 mark (memq number gnus-newsgroup-replied)
5091 (memq number gnus-newsgroup-expirable)
5092 (mail-header-subject header) nil
5093 (cdr (assq number gnus-newsgroup-scored))
5094 (memq number gnus-newsgroup-processable))))))
5096 (defun gnus-summary-remove-list-identifiers ()
5097 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5098 (let ((regexp (if (consp gnus-list-identifiers)
5099 (mapconcat 'identity gnus-list-identifiers " *\\|")
5100 gnus-list-identifiers))
5103 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5104 (dolist (header gnus-newsgroup-headers)
5105 (setq subject (mail-header-subject header)
5107 (while (string-match regexp subject)
5109 (concat (substring subject 0 (match-beginning 1))
5110 (substring subject (match-end 0)))
5113 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5115 (concat (substring subject 0 (match-beginning 1))
5116 (substring subject (match-end 1)))))
5117 (mail-header-set-subject header subject))))))
5119 (defun gnus-fetch-headers (articles)
5120 "Fetch headers of ARTICLES."
5121 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5122 (gnus-message 5 "Fetching headers for %s..." name)
5125 (setq gnus-headers-retrieved-by
5126 (gnus-retrieve-headers
5127 articles gnus-newsgroup-name
5128 ;; We might want to fetch old headers, but
5129 ;; not if there is only 1 article.
5131 (not (eq gnus-fetch-old-headers 'some))
5132 (not (numberp gnus-fetch-old-headers)))
5133 (> (length articles) 1))
5134 gnus-fetch-old-headers))))
5135 (gnus-get-newsgroup-headers-xover
5136 articles nil nil gnus-newsgroup-name t)
5137 (gnus-get-newsgroup-headers))
5138 (gnus-message 5 "Fetching headers for %s...done" name))))
5140 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5141 "Select newsgroup GROUP.
5142 If READ-ALL is non-nil, all articles in the group are selected.
5143 If SELECT-ARTICLES, only select those articles from GROUP."
5144 (let* ((entry (gnus-group-entry group))
5145 ;;!!! Dirty hack; should be removed.
5146 (gnus-summary-ignore-duplicates
5147 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5149 gnus-summary-ignore-duplicates))
5150 (info (nth 2 entry))
5151 articles fetched-articles cached)
5153 (unless (gnus-check-server
5154 (set (make-local-variable 'gnus-current-select-method)
5155 (gnus-find-method-for-group group)))
5156 (error "Couldn't open server"))
5158 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5159 (gnus-activate-group group) ; Or we can activate it...
5160 (progn ; Or we bug out.
5161 (when (equal major-mode 'gnus-summary-mode)
5162 (gnus-kill-buffer (current-buffer)))
5163 (error "Couldn't activate group %s: %s"
5164 group (gnus-status-message group))))
5166 (unless (gnus-request-group group t)
5167 (when (equal major-mode 'gnus-summary-mode)
5168 (gnus-kill-buffer (current-buffer)))
5169 (error "Couldn't request group %s: %s"
5170 group (gnus-status-message group)))
5173 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5175 (setq gnus-summary-use-undownloaded-faces
5176 (gnus-agent-find-parameter
5178 'agent-enable-undownloaded-faces)))
5180 (setq gnus-newsgroup-name group
5181 gnus-newsgroup-unselected nil
5182 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5184 (let ((display (gnus-group-find-parameter group 'display)))
5185 (setq gnus-newsgroup-display
5187 ((not (zerop (or (car-safe read-all) 0)))
5188 ;; The user entered the group with C-u SPC/RET, let's show
5194 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5196 ;; The following is probably the "correct" solution, but
5197 ;; it makes Gnus fetch all headers and then limit the
5198 ;; articles (which is slow), so instead we hack the
5199 ;; select-articles parameter instead. -- Simon Josefsson
5202 ;; (gnus-byte-compile
5203 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5205 (setq select-articles
5206 (gnus-uncompress-range
5207 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5211 (cdr (gnus-active group)))))
5216 (gnus-summary-setup-default-charset)
5218 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5219 (when (gnus-virtual-group-p group)
5220 (setq cached gnus-newsgroup-cached))
5222 (setq gnus-newsgroup-unreads
5223 (gnus-sorted-ndifference
5224 (gnus-sorted-ndifference gnus-newsgroup-unreads
5225 gnus-newsgroup-marked)
5226 gnus-newsgroup-dormant))
5228 (setq gnus-newsgroup-processable nil)
5230 (gnus-update-read-articles group gnus-newsgroup-unreads)
5232 ;; Adjust and set lists of article marks.
5234 (gnus-adjust-marked-articles info))
5235 (if (setq articles select-articles)
5236 (setq gnus-newsgroup-unselected
5237 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5238 (setq articles (gnus-articles-to-read group read-all)))
5242 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5244 ((eq articles 0) nil)
5246 ;; Init the dependencies hash table.
5247 (setq gnus-newsgroup-dependencies
5248 (gnus-make-hashtable (length articles)))
5249 (gnus-set-global-variables)
5250 ;; Retrieve the headers and read them in.
5252 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5254 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5256 (setq gnus-newsgroup-cached cached))
5258 ;; Suppress duplicates?
5259 (when gnus-suppress-duplicates
5260 (gnus-dup-suppress-articles))
5262 ;; Set the initial limit.
5263 (setq gnus-newsgroup-limit (copy-sequence articles))
5264 ;; Remove canceled articles from the list of unread articles.
5265 (setq fetched-articles
5266 (mapcar (lambda (headers) (mail-header-number headers))
5267 gnus-newsgroup-headers))
5268 (setq gnus-newsgroup-articles fetched-articles)
5269 (setq gnus-newsgroup-unreads
5270 (gnus-sorted-nintersection
5271 gnus-newsgroup-unreads fetched-articles))
5272 (gnus-compute-unseen-list)
5274 ;; Removed marked articles that do not exist.
5275 (gnus-update-missing-marks
5276 (gnus-sorted-difference articles fetched-articles))
5277 ;; We might want to build some more threads first.
5278 (when (and gnus-fetch-old-headers
5279 (eq gnus-headers-retrieved-by 'nov))
5280 (if (eq gnus-fetch-old-headers 'invisible)
5281 (gnus-build-all-threads)
5282 (gnus-build-old-threads)))
5283 ;; Let the Gnus agent mark articles as read.
5285 (gnus-agent-get-undownloaded-list))
5286 ;; Remove list identifiers from subject
5287 (when gnus-list-identifiers
5288 (gnus-summary-remove-list-identifiers))
5289 ;; Check whether auto-expire is to be done in this group.
5290 (setq gnus-newsgroup-auto-expire
5291 (gnus-group-auto-expirable-p group))
5292 ;; Set up the article buffer now, if necessary.
5293 (unless gnus-single-article-buffer
5294 (gnus-article-setup-buffer))
5295 ;; First and last article in this newsgroup.
5296 (when gnus-newsgroup-headers
5297 (setq gnus-newsgroup-begin
5298 (mail-header-number (car gnus-newsgroup-headers))
5301 (gnus-last-element gnus-newsgroup-headers))))
5302 ;; GROUP is successfully selected.
5303 (or gnus-newsgroup-headers t)))))
5305 (defun gnus-compute-unseen-list ()
5306 ;; The `seen' marks are treated specially.
5307 (if (not gnus-newsgroup-seen)
5308 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5309 (setq gnus-newsgroup-unseen
5310 (gnus-inverse-list-range-intersection
5311 gnus-newsgroup-articles gnus-newsgroup-seen))))
5313 (defun gnus-summary-display-make-predicate (display)
5314 (require 'gnus-agent)
5315 (when (= (length display) 1)
5316 (setq display (car display)))
5317 (unless gnus-summary-display-cache
5318 (dolist (elem (append '((unread . unread)
5321 gnus-article-mark-lists))
5322 (push (cons (cdr elem)
5324 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5325 gnus-summary-display-cache)))
5326 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5327 (gnus-category-predicate-cache gnus-summary-display-cache))
5328 (gnus-get-predicate display)))
5330 ;; Uses the dynamically bound `number' variable.
5333 (defun gnus-article-marked-p (type &optional article)
5334 (let ((article (or article number)))
5337 (memq article gnus-newsgroup-marked))
5339 (memq article gnus-newsgroup-spam-marked))
5341 (memq article gnus-newsgroup-unsendable))
5342 ((eq type 'undownload)
5343 (memq article gnus-newsgroup-undownloaded))
5344 ((eq type 'download)
5345 (memq article gnus-newsgroup-downloadable))
5347 (memq article gnus-newsgroup-unreads))
5349 (memq article gnus-newsgroup-reads))
5351 (memq article gnus-newsgroup-dormant) )
5353 (memq article gnus-newsgroup-expirable))
5355 (memq article gnus-newsgroup-replied))
5357 (memq article gnus-newsgroup-killed))
5358 ((eq type 'bookmark)
5359 (assq article gnus-newsgroup-bookmarks))
5361 (assq article gnus-newsgroup-scored))
5363 (memq article gnus-newsgroup-saved))
5365 (memq article gnus-newsgroup-cached))
5367 (memq article gnus-newsgroup-forwarded))
5369 (not (memq article gnus-newsgroup-unseen)))
5371 (memq article gnus-newsgroup-recent))
5374 (defun gnus-articles-to-read (group &optional read-all)
5375 "Find out what articles the user wants to read."
5377 ;; Select all articles if `read-all' is non-nil, or if there
5378 ;; are no unread articles.
5380 (and (zerop (length gnus-newsgroup-marked))
5381 (zerop (length gnus-newsgroup-unreads)))
5382 ;; Fetch all if the predicate is non-nil.
5383 gnus-newsgroup-display)
5384 ;; We want to select the headers for all the articles in
5385 ;; the group, so we select either all the active
5386 ;; articles in the group, or (if that's nil), the
5387 ;; articles in the cache.
5389 (gnus-uncompress-range (gnus-active group))
5390 (gnus-cache-articles-in-group group))
5391 ;; Select only the "normal" subset of articles.
5393 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5394 gnus-newsgroup-unreads)))
5395 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5396 (scored (length scored-list))
5397 (number (length articles))
5398 (marked (+ (length gnus-newsgroup-marked)
5399 (length gnus-newsgroup-dormant)))
5404 ((numberp gnus-newsgroup-display)
5405 gnus-newsgroup-display)
5409 ((and (or (<= scored marked) (= scored number))
5410 (numberp gnus-large-newsgroup)
5411 (> number gnus-large-newsgroup))
5412 (let* ((cursor-in-echo-area nil)
5413 (initial (gnus-parameter-large-newsgroup-initial
5414 gnus-newsgroup-name))
5418 "How many articles from %s (%s %d): "
5420 (gnus-group-decoded-name gnus-newsgroup-name)
5422 (if initial "max" "default")
5425 (cons (number-to-string initial)
5427 (if (string-match "^[ \t]*$" input) number input)))
5428 ((and (> scored marked) (< scored number)
5429 (> (- scored number) 20))
5432 (format "%s %s (%d scored, %d total): "
5433 "How many articles from"
5434 (gnus-group-decoded-name group)
5436 (if (string-match "^[ \t]*$" input)
5440 (message "Quit getting the articles to read")
5442 (setq select (if (stringp select) (string-to-number select) select))
5443 (if (or (null select) (zerop select))
5445 (if (and (not (zerop scored)) (<= (abs select) scored))
5447 (setq articles (sort scored-list '<))
5448 (setq number (length articles)))
5449 (setq articles (copy-sequence articles)))
5451 (when (< (abs select) number)
5453 ;; Select the N oldest articles.
5454 (setcdr (nthcdr (1- (abs select)) articles) nil)
5455 ;; Select the N most recent articles.
5456 (setq articles (nthcdr (- number select) articles))))
5457 (setq gnus-newsgroup-unselected
5458 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5459 (when gnus-alter-articles-to-read-function
5462 (funcall gnus-alter-articles-to-read-function
5463 gnus-newsgroup-name articles)
5467 (defun gnus-killed-articles (killed articles)
5470 (when (inline (gnus-member-of-range (car articles) killed))
5471 (push (car articles) out))
5472 (setq articles (cdr articles)))
5475 (defun gnus-uncompress-marks (marks)
5476 "Uncompress the mark ranges in MARKS."
5477 (let ((uncompressed '(score bookmark))
5480 (if (memq (caar marks) uncompressed)
5481 (push (car marks) out)
5482 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5483 (setq marks (cdr marks)))
5486 (defun gnus-article-mark-to-type (mark)
5487 "Return the type of MARK."
5488 (or (cadr (assq mark gnus-article-special-mark-lists))
5491 (defun gnus-article-unpropagatable-p (mark)
5492 "Return whether MARK should be propagated to back end."
5493 (memq mark gnus-article-unpropagated-mark-lists))
5495 (defun gnus-adjust-marked-articles (info)
5496 "Set all article lists and remove all marks that are no longer valid."
5497 (let* ((marked-lists (gnus-info-marks info))
5498 (active (gnus-active (gnus-info-group info)))
5501 (types gnus-article-mark-lists)
5502 marks var articles article mark mark-type
5505 (dolist (marks marked-lists)
5506 (setq mark (car marks)
5507 mark-type (gnus-article-mark-to-type mark)
5508 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5510 ;; We set the variable according to the type of the marks list,
5511 ;; and then adjust the marks to a subset of the active articles.
5513 ;; Adjust "simple" lists - compressed yet unsorted
5514 ((eq mark-type 'list)
5515 ;; Simultaneously uncompress and clip to active range
5516 ;; See gnus-uncompress-range for a description of possible marks
5518 (if (not (cadr marks))
5520 (setq articles (if (numberp (cddr marks))
5526 (while (setq article (pop articles))
5527 (cond ((consp article)
5528 (setq bgn (max (car article) min)
5529 end (min (cdr article) max))
5531 (setq l (setcdr l (cons bgn nil))
5533 ((and (<= min article)
5535 (setq l (setcdr l (cons article nil))))))
5536 (set var (cdr lh)))))
5538 ((eq mark-type 'tuple)
5539 (set var (setq articles (cdr marks)))
5540 (when (not (listp (cdr (symbol-value var))))
5541 (set var (list (symbol-value var))))
5542 (when (not (listp (cdr articles)))
5543 (setq articles (list articles)))
5545 (when (or (not (consp (setq article (pop articles))))
5546 (< (car article) min)
5547 (> (car article) max))
5548 (set var (delq article (symbol-value var))))))
5549 ;; Adjust ranges (sloppily).
5550 ((eq mark-type 'range)
5553 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5554 ;; It should be (seen (NUM1 . NUM2)).
5555 (when (numberp (cddr marks))
5556 (setcdr marks (list (cdr marks))))
5557 (setq articles (cdr marks))
5558 (while (and articles
5559 (or (and (consp (car articles))
5560 (> min (cdar articles)))
5561 (and (numberp (car articles))
5562 (> min (car articles)))))
5564 (set var articles))))))))
5566 (defun gnus-update-missing-marks (missing)
5567 "Go through the list of MISSING articles and remove them from the mark lists."
5570 ;; Go through all types.
5571 (dolist (elem gnus-article-mark-lists)
5572 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5573 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5574 (when (symbol-value var)
5575 ;; This list has articles. So we delete all missing
5576 ;; articles from it.
5579 (set var (delq (pop m) (symbol-value var))))))))))
5581 (defun gnus-update-marks ()
5582 "Enter the various lists of marked articles into the newsgroup info list."
5583 (let ((types gnus-article-mark-lists)
5584 (info (gnus-get-info gnus-newsgroup-name))
5585 type list newmarked symbol delta-marks)
5587 ;; Add all marks lists to the list of marks lists.
5588 (while (setq type (pop types))
5589 (setq list (symbol-value
5591 (intern (format "gnus-newsgroup-%s" (car type))))))
5594 ;; Get rid of the entries of the articles that have the
5596 (when (and (eq (cdr type) 'score)
5600 (prev (cons nil list))
5603 (if (or (not (consp (car arts)))
5604 (= (cdar arts) gnus-summary-default-score))
5605 (setcdr prev (cdr arts))
5607 (setq arts (cdr arts)))
5608 (setq list (cdr all)))))
5610 (when (eq (cdr type) 'seen)
5611 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5613 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5614 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5616 (when (and (gnus-check-backend-function
5617 'request-set-mark gnus-newsgroup-name)
5618 (not (gnus-article-unpropagatable-p (cdr type))))
5619 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5620 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5621 (add (gnus-remove-from-range
5622 (gnus-copy-sequence list) old)))
5624 (push (list add 'add (list (cdr type))) delta-marks))
5626 (push (list del 'del (list (cdr type))) delta-marks))))
5629 (push (cons (cdr type) list) newmarked)))
5632 (unless (gnus-check-group gnus-newsgroup-name)
5633 (error "Can't open server for %s" gnus-newsgroup-name))
5634 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5636 ;; Enter these new marks into the info of the group.
5638 (setcar (nthcdr 3 info) newmarked)
5639 ;; Add the marks lists to the end of the info.
5641 (setcdr (nthcdr 2 info) (list newmarked))))
5643 ;; Cut off the end of the info if there's nothing else there.
5647 (when (nthcdr (decf i) info)
5648 (setcdr (nthcdr i info) nil)))))))
5650 (defun gnus-set-mode-line (where)
5651 "Set the mode line of the article or summary buffers.
5652 If WHERE is `summary', the summary mode line format will be used."
5653 ;; Is this mode line one we keep updated?
5654 (when (and (memq where gnus-updated-mode-lines)
5656 (intern (format "gnus-%s-mode-line-format-spec" where))))
5659 ;; We evaluate this in the summary buffer since these
5660 ;; variables are buffer-local to that buffer.
5661 (set-buffer gnus-summary-buffer)
5662 ;; We bind all these variables that are used in the `eval' form
5664 (let* ((mformat (symbol-value
5666 (format "gnus-%s-mode-line-format-spec" where))))
5667 (gnus-tmp-group-name (gnus-group-decoded-name
5668 gnus-newsgroup-name))
5669 (gnus-tmp-article-number (or gnus-current-article 0))
5670 (gnus-tmp-unread gnus-newsgroup-unreads)
5671 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5672 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5673 (gnus-tmp-unread-and-unselected
5674 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5675 (zerop gnus-tmp-unselected))
5677 ((zerop gnus-tmp-unselected)
5678 (format "{%d more}" gnus-tmp-unread-and-unticked))
5679 (t (format "{%d(+%d) more}"
5680 gnus-tmp-unread-and-unticked
5681 gnus-tmp-unselected))))
5683 (if (and gnus-current-headers
5684 (vectorp gnus-current-headers))
5685 (gnus-mode-string-quote
5686 (mail-header-subject gnus-current-headers))
5688 bufname-length max-len
5689 gnus-tmp-header);; passed as argument to any user-format-funcs
5690 (setq mode-string (eval mformat))
5691 (setq bufname-length (if (string-match "%b" mode-string)
5694 (if (eq where 'summary)
5696 (get-buffer gnus-article-buffer))))
5699 (setq max-len (max 4 (if gnus-mode-non-string-length
5701 gnus-mode-non-string-length
5703 (length mode-string))))
5704 ;; We might have to chop a bit of the string off...
5705 (when (> (length mode-string) max-len)
5707 (concat (gnus-truncate-string mode-string (- max-len 3))
5709 ;; Pad the mode string a bit.
5710 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5711 ;; Update the mode line.
5712 (setq mode-line-buffer-identification
5713 (gnus-mode-line-buffer-identification (list mode-string)))
5714 (set-buffer-modified-p t))))
5716 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5717 "Go through the HEADERS list and add all Xrefs to a hash table.
5718 The resulting hash table is returned, or nil if no Xrefs were found."
5719 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5720 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5721 (xref-hashtb (gnus-make-hashtable))
5722 start group entry number xrefs header)
5724 (setq header (pop headers))
5725 (when (and (setq xrefs (mail-header-xref header))
5726 (not (memq (setq number (mail-header-number header))
5729 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5730 (setq start (match-end 0))
5731 (setq group (if prefix
5732 (concat prefix (substring xrefs (match-beginning 1)
5734 (substring xrefs (match-beginning 1) (match-end 1))))
5736 (string-to-number (substring xrefs (match-beginning 2)
5738 (if (setq entry (gnus-gethash group xref-hashtb))
5739 (setcdr entry (cons number (cdr entry)))
5740 (gnus-sethash group (cons number nil) xref-hashtb)))))
5741 (and start xref-hashtb)))
5743 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5744 "Look through all the headers and mark the Xrefs as read."
5745 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5746 name info xref-hashtb idlist method nth4)
5748 (set-buffer gnus-group-buffer)
5749 (when (setq xref-hashtb
5750 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5753 (unless (string= from-newsgroup (setq name (symbol-name group)))
5754 (setq idlist (symbol-value group))
5755 ;; Dead groups are not updated.
5757 (setq info (gnus-get-info name))
5758 (when (stringp (setq nth4 (gnus-info-method info)))
5759 (setq nth4 (gnus-server-to-method nth4))))
5760 ;; Only do the xrefs if the group has the same
5761 ;; select method as the group we have just read.
5762 (or (gnus-methods-equal-p
5763 nth4 (gnus-find-method-for-group from-newsgroup))
5765 (equal nth4 (setq method (gnus-find-method-for-group
5767 (and (equal (car nth4) (car method))
5768 (equal (nth 1 nth4) (nth 1 method))))
5769 gnus-use-cross-reference
5770 (or (not (eq gnus-use-cross-reference t))
5772 ;; Only do cross-references on subscribed
5773 ;; groups, if that is what is wanted.
5774 (<= (gnus-info-level info) gnus-level-subscribed))
5775 (gnus-group-make-articles-read name idlist))))
5778 (defun gnus-compute-read-articles (group articles)
5779 (let* ((entry (gnus-group-entry group))
5780 (info (nth 2 entry))
5781 (active (gnus-active group))
5784 ;; First peel off all invalid article numbers.
5786 (let ((ids articles)
5788 (while (setq id (pop ids))
5789 (when (and first (> id (cdr active)))
5790 ;; We'll end up in this situation in one particular
5791 ;; obscure situation. If you re-scan a group and get
5792 ;; a new article that is cross-posted to a different
5793 ;; group that has not been re-scanned, you might get
5794 ;; crossposted article that has a higher number than
5795 ;; Gnus believes possible. So we re-activate this
5796 ;; group as well. This might mean doing the
5797 ;; crossposting thingy will *increase* the number
5798 ;; of articles in some groups. Tsk, tsk.
5799 (setq active (or (gnus-activate-group group) active)))
5800 (when (or (> id (cdr active))
5801 (< id (car active)))
5802 (setq articles (delq id articles))))))
5803 ;; If the read list is nil, we init it.
5805 (null (gnus-info-read info))
5807 (setq ninfo (cons 1 (1- (car active))))
5808 (setq ninfo (gnus-info-read info)))
5809 ;; Then we add the read articles to the range.
5811 ninfo (setq articles (sort articles '<))))))
5813 (defun gnus-group-make-articles-read (group articles)
5814 "Update the info of GROUP to say that ARTICLES are read."
5816 (entry (gnus-group-entry group))
5817 (info (nth 2 entry))
5818 (active (gnus-active group))
5821 (setq range (gnus-compute-read-articles group articles))
5822 (with-current-buffer gnus-group-buffer
5825 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5826 (gnus-info-set-read ',info ',(gnus-info-read info))
5827 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5828 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5829 (gnus-group-update-group ,group t))))
5830 ;; Add the read articles to the range.
5831 (gnus-info-set-read info range)
5832 (gnus-request-set-mark group (list (list range 'add '(read))))
5833 ;; Then we have to re-compute how many unread
5834 ;; articles there are in this group.
5838 (setq num (- (1+ (cdr active)) (car active))))
5839 ((not (listp (cdr range)))
5840 (setq num (- (cdr active) (- (1+ (cdr range))
5844 (if (numberp (car range))
5846 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5847 (setq range (cdr range)))
5848 (setq num (- (cdr active) num))))
5849 ;; Update the number of unread articles.
5851 ;; Update the group buffer.
5852 (unless (gnus-ephemeral-group-p group)
5853 (gnus-group-update-group group t))))))
5855 (defvar gnus-newsgroup-none-id 0)
5857 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5858 (let ((cur nntp-server-buffer)
5861 (with-current-buffer gnus-summary-buffer
5862 gnus-newsgroup-dependencies)))
5863 headers id end ref number
5864 (mail-parse-charset gnus-newsgroup-charset)
5865 (mail-parse-ignored-charsets
5866 (save-excursion (condition-case nil
5867 (set-buffer gnus-summary-buffer)
5869 gnus-newsgroup-ignored-charsets)))
5871 (set-buffer nntp-server-buffer)
5872 ;; Translate all TAB characters into SPACE characters.
5873 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5874 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5875 (ietf-drums-unfold-fws)
5876 (gnus-run-hooks 'gnus-parse-headers-hook)
5877 (let ((case-fold-search t)
5878 in-reply-to header p lines chars ctype)
5879 (goto-char (point-min))
5880 ;; Search to the beginning of the next header. Error messages
5881 ;; do not begin with 2 or 3.
5882 (while (re-search-forward "^[23][0-9]+ " nil t)
5885 ;; This implementation of this function, with nine
5886 ;; search-forwards instead of the one re-search-forward and
5887 ;; a case (which basically was the old function) is actually
5888 ;; about twice as fast, even though it looks messier. You
5889 ;; can't have everything, I guess. Speed and elegance
5890 ;; doesn't always go hand in hand.
5893 (make-full-mail-header
5896 (setq number (read cur))
5899 (narrow-to-region (point)
5900 (or (and (search-forward "\n.\n" nil t)
5906 (if (search-forward "\nsubject:" nil t)
5907 (nnheader-header-value)
5912 (if (search-forward "\nfrom:" nil t)
5913 (nnheader-header-value)
5918 (if (search-forward "\ndate:" nil t)
5919 (nnheader-header-value) ""))
5923 (setq id (if (re-search-forward
5924 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5925 ;; We do it this way to make sure the Message-ID
5926 ;; is (somewhat) syntactically valid.
5927 (buffer-substring (match-beginning 1)
5929 ;; If there was no message-id, we just fake one
5930 ;; to make subsequent routines simpler.
5931 (nnheader-generate-fake-message-id number))))
5935 (if (search-forward "\nreferences:" nil t)
5939 (nnheader-header-value)
5944 (search-backward ">" end t)
5947 (search-backward "<" end t)
5949 ;; Get the references from the in-reply-to header if there
5950 ;; were no references and the in-reply-to header looks
5952 (if (and (search-forward "\nin-reply-to:" nil t)
5953 (setq in-reply-to (nnheader-header-value))
5954 (string-match "<[^>]+>" in-reply-to))
5956 (setq ref (substring in-reply-to (match-beginning 0)
5958 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5959 (setq ref2 (substring in-reply-to (match-beginning 0)
5961 (when (> (length ref2) (length ref))
5968 (if (search-forward "\nchars: " nil t)
5969 (if (numberp (setq chars (ignore-errors (read cur))))
5975 (if (search-forward "\nlines: " nil t)
5976 (if (numberp (setq lines (ignore-errors (read cur))))
5982 (and (search-forward "\nxref:" nil t)
5983 (nnheader-header-value)))
5985 (when gnus-extra-headers
5986 (let ((extra gnus-extra-headers)
5990 (when (search-forward
5991 (concat "\n" (symbol-name (car extra)) ":") nil t)
5992 (push (cons (car extra) (nnheader-header-value)) out))
5996 (if (and (search-forward "\ncontent-type: " nil t)
5997 (setq ctype (nnheader-header-value)))
5998 (mime-entity-set-content-type-internal
5999 header (mime-parse-Content-Type ctype)))
6000 (when (equal id ref)
6003 (when gnus-alter-header-function
6004 (funcall gnus-alter-header-function header)
6005 (setq id (mail-header-id header)
6006 ref (gnus-parent-id (mail-header-references header))))
6009 (gnus-dependencies-add-header
6010 header dependencies force-new))
6011 (push header headers))
6012 (goto-char (point-max))
6014 (nreverse headers)))))
6016 ;; Goes through the xover lines and returns a list of vectors
6017 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6018 force-new dependencies
6019 group also-fetch-heads)
6020 "Parse the news overview data in the server buffer.
6021 Return a list of headers that match SEQUENCE (see
6022 `nntp-retrieve-headers')."
6023 ;; Get the Xref when the users reads the articles since most/some
6024 ;; NNTP servers do not include Xrefs when using XOVER.
6025 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6026 (let ((mail-parse-charset gnus-newsgroup-charset)
6027 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6028 (cur nntp-server-buffer)
6029 (dependencies (or dependencies gnus-newsgroup-dependencies))
6031 ((eq gnus-read-all-available-headers t)
6033 ((stringp gnus-read-all-available-headers)
6034 (string-match gnus-read-all-available-headers group))
6037 number headers header)
6039 (set-buffer nntp-server-buffer)
6040 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6041 ;; Allow the user to mangle the headers before parsing them.
6042 (gnus-run-hooks 'gnus-parse-headers-hook)
6043 (goto-char (point-min))
6044 (gnus-parse-without-error
6045 (while (and (or sequence allp)
6047 (setq number (read cur))
6049 (while (and sequence
6050 (< (car sequence) number))
6051 (setq sequence (cdr sequence))))
6054 (eq number (car sequence))))
6056 (setq sequence (cdr sequence))
6057 (setq header (inline
6058 (gnus-nov-parse-line
6059 number dependencies force-new)))))
6060 (push header headers))
6062 ;; A common bug in inn is that if you have posted an article and
6063 ;; then retrieves the active file, it will answer correctly --
6064 ;; the new article is included. However, a NOV entry for the
6065 ;; article may not have been generated yet, so this may fail.
6066 ;; We work around this problem by retrieving the last few
6067 ;; headers using HEAD.
6068 (if (or (not also-fetch-heads)
6070 ;; We (probably) got all the headers.
6072 (let ((gnus-nov-is-evil t))
6075 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6076 (gnus-get-newsgroup-headers))))))))
6078 (defun gnus-article-get-xrefs ()
6079 "Fill in the Xref value in `gnus-current-headers', if necessary.
6080 This is meant to be called in `gnus-article-internal-prepare-hook'."
6081 (let ((headers (with-current-buffer gnus-summary-buffer
6082 gnus-current-headers)))
6083 (or (not gnus-use-cross-reference)
6085 (and (mail-header-xref headers)
6086 (not (string= (mail-header-xref headers) "")))
6087 (let ((case-fold-search t)
6090 (nnheader-narrow-to-headers)
6091 (goto-char (point-min))
6092 (when (or (and (not (eobp))
6093 (eq (downcase (char-after)) ?x)
6094 (looking-at "Xref:"))
6095 (search-forward "\nXref:" nil t))
6096 (goto-char (1+ (match-end 0)))
6097 (setq xref (buffer-substring (point) (point-at-eol)))
6098 (mail-header-set-xref headers xref)))))))
6100 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6101 "Find article ID and insert the summary line for that article.
6102 OLD-HEADER can either be a header or a line number to insert
6103 the subject line on."
6104 (let* ((line (and (numberp old-header) old-header))
6105 (old-header (and (vectorp old-header) old-header))
6106 (header (cond ((and old-header use-old-header)
6109 (gnus-number-to-header id))
6110 (gnus-number-to-header id))
6112 (gnus-read-header id))))
6113 (number (and (numberp id) id))
6116 ;; Rebuild the thread that this article is part of and go to the
6117 ;; article we have fetched.
6118 (when (and (not gnus-show-threads)
6121 (setq d (gnus-data-find (mail-header-number old-header))))
6122 (goto-char (gnus-data-pos d))
6128 (gnus-delete-line))))))
6129 ;; Remove list identifiers from subject.
6130 (when gnus-list-identifiers
6131 (let ((gnus-newsgroup-headers (list header)))
6132 (gnus-summary-remove-list-identifiers)))
6134 (mail-header-set-number header (mail-header-number old-header)))
6135 (setq gnus-newsgroup-sparse
6136 (delq (setq number (mail-header-number header))
6137 gnus-newsgroup-sparse))
6138 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6139 (push number gnus-newsgroup-limit)
6140 (gnus-rebuild-thread (mail-header-id header) line)
6141 (gnus-summary-goto-subject number nil t))
6142 (when (and (numberp number)
6144 ;; We have to update the boundaries even if we can't fetch the
6145 ;; article if ID is a number -- so that the next `P' or `N'
6146 ;; command will fetch the previous (or next) article even
6147 ;; if the one we tried to fetch this time has been canceled.
6148 (when (> number gnus-newsgroup-end)
6149 (setq gnus-newsgroup-end number))
6150 (when (< number gnus-newsgroup-begin)
6151 (setq gnus-newsgroup-begin number))
6152 (setq gnus-newsgroup-unselected
6153 (delq number gnus-newsgroup-unselected)))
6154 ;; Report back a success?
6155 (and header (mail-header-number header))))
6157 ;;; Process/prefix in the summary buffer
6159 (defun gnus-summary-work-articles (n)
6160 "Return a list of articles to be worked upon.
6161 The prefix argument, the list of process marked articles, and the
6162 current article will be taken into consideration."
6164 (set-buffer gnus-summary-buffer)
6167 ;; A numerical prefix has been given.
6168 (setq n (prefix-numeric-value n))
6169 (let ((backward (< n 0))
6170 (n (abs (prefix-numeric-value n)))
6175 (push (setq article (gnus-summary-article-number))
6178 (gnus-summary-find-prev nil article)
6179 (gnus-summary-find-next nil article)))
6181 (nreverse articles)))
6182 ((and (gnus-region-active-p) (mark))
6183 (message "region active")
6184 ;; Work on the region between point and mark.
6185 (let ((max (max (point) (mark)))
6188 (goto-char (min (point) (mark)))
6191 (push (setq article (gnus-summary-article-number)) articles)
6192 (gnus-summary-find-next nil article)
6194 (nreverse articles))))
6195 (gnus-newsgroup-processable
6196 ;; There are process-marked articles present.
6197 ;; Save current state.
6198 (gnus-summary-save-process-mark)
6200 (reverse gnus-newsgroup-processable))
6202 ;; Just return the current article.
6203 (list (gnus-summary-article-number))))))
6205 (defmacro gnus-summary-iterate (arg &rest forms)
6206 "Iterate over the process/prefixed articles and do FORMS.
6207 ARG is the interactive prefix given to the command. FORMS will be
6208 executed with point over the summary line of the articles."
6209 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6210 `(let ((,articles (gnus-summary-work-articles ,arg)))
6212 (gnus-summary-goto-subject (car ,articles))
6216 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6217 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6219 (defun gnus-summary-save-process-mark ()
6220 "Push the current set of process marked articles on the stack."
6222 (push (copy-sequence gnus-newsgroup-processable)
6223 gnus-newsgroup-process-stack))
6225 (defun gnus-summary-kill-process-mark ()
6226 "Push the current set of process marked articles on the stack and unmark."
6228 (gnus-summary-save-process-mark)
6229 (gnus-summary-unmark-all-processable))
6231 (defun gnus-summary-yank-process-mark ()
6232 "Pop the last process mark state off the stack and restore it."
6234 (unless gnus-newsgroup-process-stack
6235 (error "Empty mark stack"))
6236 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6238 (defun gnus-summary-process-mark-set (set)
6239 "Make SET into the current process marked articles."
6240 (gnus-summary-unmark-all-processable)
6241 (mapc 'gnus-summary-set-process-mark set))
6243 ;;; Searching and stuff
6245 (defun gnus-summary-search-group (&optional backward use-level)
6246 "Search for next unread newsgroup.
6247 If optional argument BACKWARD is non-nil, search backward instead."
6249 (set-buffer gnus-group-buffer)
6250 (when (gnus-group-search-forward
6251 backward nil (if use-level (gnus-group-group-level) nil))
6252 (gnus-group-group-name))))
6254 (defun gnus-summary-best-group (&optional exclude-group)
6255 "Find the name of the best unread group.
6256 If EXCLUDE-GROUP, do not go to this group."
6257 (with-current-buffer gnus-group-buffer
6259 (gnus-group-best-unread-group exclude-group))))
6261 (defun gnus-summary-find-next (&optional unread article backward)
6263 (gnus-summary-find-prev unread article)
6264 (let* ((dummy (gnus-summary-article-intangible-p))
6265 (article (or article (gnus-summary-article-number)))
6266 (data (gnus-data-find-list article))
6268 (when (and (not dummy)
6269 (or (not gnus-summary-check-current)
6271 (not (gnus-data-unread-p (car data)))))
6272 (setq data (cdr data)))
6277 (unless (memq (gnus-data-number (car data))
6279 ((eq gnus-auto-goto-ignores
6280 'always-undownloaded)
6281 gnus-newsgroup-undownloaded)
6284 ((eq gnus-auto-goto-ignores
6286 gnus-newsgroup-unfetched)
6287 ((eq gnus-auto-goto-ignores
6289 gnus-newsgroup-undownloaded)))
6290 (when (gnus-data-unread-p (car data))
6291 (setq result (car data)
6293 (setq data (cdr data)))
6296 (goto-char (gnus-data-pos result))
6297 (gnus-data-number result)))))
6299 (defun gnus-summary-find-prev (&optional unread article)
6300 (let* ((eobp (eobp))
6301 (article (or article (gnus-summary-article-number)))
6302 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6304 (when (and (not eobp)
6305 (or (not gnus-summary-check-current)
6307 (not (gnus-data-unread-p (car data)))))
6308 (setq data (cdr data)))
6313 (unless (memq (gnus-data-number (car data))
6315 ((eq gnus-auto-goto-ignores
6316 'always-undownloaded)
6317 gnus-newsgroup-undownloaded)
6320 ((eq gnus-auto-goto-ignores
6322 gnus-newsgroup-unfetched)
6323 ((eq gnus-auto-goto-ignores
6325 gnus-newsgroup-undownloaded)))
6326 (when (gnus-data-unread-p (car data))
6327 (setq result (car data)
6329 (setq data (cdr data)))
6332 (goto-char (gnus-data-pos result))
6333 (gnus-data-number result))))
6335 (defun gnus-summary-find-subject (subject &optional unread backward article)
6336 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6337 (article (or article (gnus-summary-article-number)))
6338 (articles (gnus-data-list backward))
6339 (arts (gnus-data-find-list article articles))
6341 (when (or (not gnus-summary-check-current)
6343 (not (gnus-data-unread-p (car arts))))
6344 (setq arts (cdr arts)))
6346 (and (or (not unread)
6347 (gnus-data-unread-p (car arts)))
6348 (vectorp (gnus-data-header (car arts)))
6350 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6351 (setq result (car arts)
6353 (setq arts (cdr arts)))
6355 (goto-char (gnus-data-pos result))
6356 (gnus-data-number result))))
6358 (defun gnus-summary-search-forward (&optional unread subject backward)
6359 "Search forward for an article.
6360 If UNREAD, look for unread articles. If SUBJECT, look for
6361 articles with that subject. If BACKWARD, search backward instead."
6362 (cond (subject (gnus-summary-find-subject subject unread backward))
6363 (backward (gnus-summary-find-prev unread))
6364 (t (gnus-summary-find-next unread))))
6366 (defun gnus-recenter (&optional n)
6367 "Center point in window and redisplay frame.
6368 Also do horizontal recentering."
6370 (when (and gnus-auto-center-summary
6371 (not (eq gnus-auto-center-summary 'vertical)))
6372 (gnus-horizontal-recenter))
6375 (defun gnus-summary-recenter ()
6376 "Center point in the summary window.
6377 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6378 displayed, no centering will be performed."
6379 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6380 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6382 ;; The user has to want it.
6383 (when gnus-auto-center-summary
6384 (let* ((top (cond ((< (window-height) 4) 0)
6385 ((< (window-height) 7) 1)
6386 (t (if (numberp gnus-auto-center-summary)
6387 gnus-auto-center-summary
6388 (/ (1- (window-height)) 2)))))
6389 (height (1- (window-height)))
6390 (bottom (save-excursion (goto-char (point-max))
6391 (forward-line (- height))
6393 (window (get-buffer-window (current-buffer))))
6394 (when (get-buffer-window gnus-article-buffer)
6395 ;; Only do recentering when the article buffer is displayed,
6396 ;; Set the window start to either `bottom', which is the biggest
6397 ;; possible valid number, or the second line from the top,
6398 ;; whichever is the least.
6399 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6400 (if (> bottom top-pos)
6401 ;; Keep the second line from the top visible
6402 (set-window-start window top-pos t)
6403 ;; Try to keep the bottom line visible; if it's partially
6404 ;; obscured, either scroll one more line to make it fully
6405 ;; visible, or revert to using TOP-POS.
6407 (goto-char (point-max))
6409 (let ((last-line-start (point)))
6411 (set-window-start window (point) t)
6412 (when (not (pos-visible-in-window-p last-line-start window))
6414 (set-window-start window (min (point) top-pos) t)))))))
6415 ;; Do horizontal recentering while we're at it.
6416 (when (and (get-buffer-window (current-buffer) t)
6417 (not (eq gnus-auto-center-summary 'vertical)))
6418 (let ((selected (selected-window)))
6419 (select-window (get-buffer-window (current-buffer) t))
6420 (gnus-summary-position-point)
6421 (gnus-horizontal-recenter)
6422 (select-window selected))))))
6424 (defun gnus-summary-jump-to-group (newsgroup)
6425 "Move point to NEWSGROUP in group mode buffer."
6426 ;; Keep update point of group mode buffer if visible.
6427 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6428 (save-window-excursion
6429 ;; Take care of tree window mode.
6430 (when (get-buffer-window gnus-group-buffer)
6431 (pop-to-buffer gnus-group-buffer))
6432 (gnus-group-jump-to-group newsgroup))
6434 ;; Take care of tree window mode.
6435 (if (get-buffer-window gnus-group-buffer)
6436 (pop-to-buffer gnus-group-buffer)
6437 (set-buffer gnus-group-buffer))
6438 (gnus-group-jump-to-group newsgroup))))
6440 ;; This function returns a list of article numbers based on the
6441 ;; difference between the ranges of read articles in this group and
6442 ;; the range of active articles.
6443 (defun gnus-list-of-unread-articles (group)
6444 (let* ((read (gnus-info-read (gnus-get-info group)))
6445 (active (or (gnus-active group) (gnus-activate-group group)))
6446 (last (or (cdr active)
6447 (error "Group %s couldn't be activated " group)))
6449 ;; If none are read, then all are unread.
6451 (setq first (car active))
6452 ;; If the range of read articles is a single range, then the
6453 ;; first unread article is the article after the last read
6454 ;; article. Sounds logical, doesn't it?
6455 (if (and (not (listp (cdr read)))
6456 (or (< (car read) (car active))
6457 (progn (setq read (list read))
6459 (setq first (max (car active) (1+ (cdr read))))
6460 ;; `read' is a list of ranges.
6461 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6464 (setq first (car active)))
6467 (while (< first nlast)
6468 (setq unread (cons first unread)
6470 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6471 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6472 (setq read (cdr read)))))
6473 ;; And add the last unread articles.
6474 (while (<= first last)
6475 (setq unread (cons first unread)
6477 ;; Return the list of unread articles.
6478 (delq 0 (nreverse unread))))
6480 (defun gnus-list-of-read-articles (group)
6481 "Return a list of unread, unticked and non-dormant articles."
6482 (let* ((info (gnus-get-info group))
6483 (marked (gnus-info-marks info))
6484 (active (gnus-active group)))
6486 (gnus-list-range-difference
6487 (gnus-list-range-difference
6488 (gnus-sorted-complement
6489 (gnus-uncompress-range active)
6490 (gnus-list-of-unread-articles group))
6491 (cdr (assq 'dormant marked)))
6492 (cdr (assq 'tick marked))))))
6494 ;; This function returns a sequence of article numbers based on the
6495 ;; difference between the ranges of read articles in this group and
6496 ;; the range of active articles.
6497 (defun gnus-sequence-of-unread-articles (group)
6498 (let* ((read (gnus-info-read (gnus-get-info group)))
6499 (active (or (gnus-active group) (gnus-activate-group group)))
6502 ;; If none are read, then all are unread.
6504 (setq first (car active))
6505 ;; If the range of read articles is a single range, then the
6506 ;; first unread article is the article after the last read
6507 ;; article. Sounds logical, doesn't it?
6508 (if (and (not (listp (cdr read)))
6509 (or (< (car read) (car active))
6510 (progn (setq read (list read))
6512 (setq first (max (car active) (1+ (cdr read))))
6513 ;; `read' is a list of ranges.
6514 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6517 (setq first (car active)))
6520 (push (cons first nlast) unread))
6521 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6522 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6523 (setq read (cdr read)))))
6524 ;; And add the last unread articles.
6525 (cond ((< first last)
6526 (push (cons first last) unread))
6528 (push first unread)))
6529 ;; Return the sequence of unread articles.
6530 (delq 0 (nreverse unread))))
6532 ;; Various summary commands
6534 (defun gnus-summary-select-article-buffer ()
6535 "Reconfigure windows to show article buffer."
6537 (if (not (gnus-buffer-live-p gnus-article-buffer))
6538 (error "There is no article buffer for this summary buffer")
6539 (gnus-configure-windows 'article)
6540 (select-window (get-buffer-window gnus-article-buffer))))
6542 (defun gnus-summary-universal-argument (arg)
6543 "Perform any operation on all articles that are process/prefixed."
6545 (let ((articles (gnus-summary-work-articles arg))
6552 (substitute-command-keys
6553 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6555 (gnus-error 1 "Undefined key")
6558 (gnus-summary-goto-subject (setq article (pop articles)))
6559 (let (gnus-newsgroup-processable)
6560 (command-execute func))
6561 (gnus-summary-remove-process-mark article)))))
6562 (gnus-summary-position-point))
6564 (defun gnus-summary-toggle-truncation (&optional arg)
6565 "Toggle truncation of summary lines.
6566 With ARG, turn line truncation on if ARG is positive."
6568 (setq truncate-lines
6569 (if (null arg) (not truncate-lines)
6570 (> (prefix-numeric-value arg) 0)))
6573 (defun gnus-summary-find-for-reselect ()
6574 "Return the number of an article to stay on across a reselect.
6575 The current article is considered, then following articles, then previous
6576 articles. An article is sought which is not cancelled and isn't a temporary
6577 insertion from another group. If there's no such then return a dummy 0."
6579 (dolist (rev '(nil t))
6580 (unless found ; don't demand the reverse list if we don't need it
6581 (let ((data (gnus-data-find-list
6582 (gnus-summary-article-number) (gnus-data-list rev))))
6583 (while (and data (not found))
6584 (if (and (< 0 (gnus-data-number (car data)))
6585 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6586 (setq found (gnus-data-number (car data))))
6587 (setq data (cdr data))))))
6590 (defun gnus-summary-reselect-current-group (&optional all rescan)
6591 "Exit and then reselect the current newsgroup.
6592 The prefix argument ALL means to select all articles."
6594 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6595 (error "Ephemeral groups can't be reselected"))
6596 (let ((current-subject (gnus-summary-find-for-reselect))
6597 (group gnus-newsgroup-name))
6598 (setq gnus-newsgroup-begin nil)
6599 (gnus-summary-exit nil 'leave-hidden)
6600 ;; We have to adjust the point of group mode buffer because
6601 ;; point was moved to the next unread newsgroup by exiting.
6602 (gnus-summary-jump-to-group group)
6605 (save-window-excursion
6606 ;; Don't show group contents.
6607 (set-window-start (selected-window) (point-max))
6608 (gnus-group-get-new-news-this-group 1))))
6609 (gnus-group-read-group all t)
6610 (gnus-summary-goto-subject current-subject nil t)))
6612 (defun gnus-summary-rescan-group (&optional all)
6613 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6615 (gnus-summary-reselect-current-group all t))
6617 (defun gnus-summary-update-info (&optional non-destructive)
6619 (let ((group gnus-newsgroup-name))
6621 (when gnus-newsgroup-kill-headers
6622 (setq gnus-newsgroup-killed
6623 (gnus-compress-sequence
6625 (gnus-list-range-intersection
6626 gnus-newsgroup-unselected gnus-newsgroup-killed)
6627 gnus-newsgroup-unreads)
6629 (unless (listp (cdr gnus-newsgroup-killed))
6630 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6631 (let ((headers gnus-newsgroup-headers))
6632 ;; Set the new ranges of read articles.
6633 (with-current-buffer gnus-group-buffer
6634 (gnus-undo-force-boundary))
6635 (gnus-update-read-articles
6636 group (gnus-sorted-union
6637 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6638 ;; Set the current article marks.
6639 (let ((gnus-newsgroup-scored
6640 (if (and (not gnus-save-score)
6641 (not non-destructive))
6643 gnus-newsgroup-scored)))
6645 (gnus-update-marks)))
6646 ;; Do the cross-ref thing.
6647 (when gnus-use-cross-reference
6648 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6649 ;; Do not switch windows but change the buffer to work.
6650 (set-buffer gnus-group-buffer)
6651 (unless (gnus-ephemeral-group-p group)
6652 (gnus-group-update-group group)))))))
6654 (defun gnus-summary-save-newsrc (&optional force)
6655 "Save the current number of read/marked articles in the dribble buffer.
6656 The dribble buffer will then be saved.
6657 If FORCE (the prefix), also save the .newsrc file(s)."
6659 (gnus-summary-update-info t)
6661 (gnus-save-newsrc-file)
6662 (gnus-dribble-save)))
6664 (defun gnus-summary-exit (&optional temporary leave-hidden)
6665 "Exit reading current newsgroup, and then return to group selection mode.
6666 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6668 (gnus-set-global-variables)
6669 (gnus-kill-save-kill-buffer)
6670 (gnus-async-halt-prefetch)
6671 (let* ((group gnus-newsgroup-name)
6672 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6673 (gnus-group-is-exiting-p t)
6676 (buf (current-buffer)))
6678 ;; Do adaptive scoring, and possibly save score files.
6679 (when gnus-newsgroup-adaptive
6680 (gnus-score-adaptive))
6681 (when gnus-use-scoring
6683 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6684 ;; If we have several article buffers, we kill them at exit.
6685 (unless gnus-single-article-buffer
6686 (gnus-kill-buffer gnus-original-article-buffer)
6687 (setq gnus-article-current nil))
6688 (when gnus-use-cache
6689 (gnus-cache-possibly-remove-articles)
6690 (gnus-cache-save-buffers))
6691 (gnus-async-prefetch-remove-group group)
6692 (when gnus-suppress-duplicates
6693 (gnus-dup-enter-articles))
6694 (when gnus-use-trees
6695 (gnus-tree-close group))
6696 (when gnus-use-cache
6697 (gnus-cache-write-active))
6698 ;; Remove entries for this group.
6699 (nnmail-purge-split-history (gnus-group-real-name group))
6700 ;; Make all changes in this group permanent.
6702 (gnus-run-hooks 'gnus-exit-group-hook)
6703 (gnus-summary-update-info))
6704 (gnus-close-group group)
6705 ;; Make sure where we were, and go to next newsgroup.
6706 (set-buffer gnus-group-buffer)
6708 (gnus-group-jump-to-group group))
6709 (gnus-run-hooks 'gnus-summary-exit-hook)
6710 (unless (or quit-config
6711 ;; If this group has disappeared from the summary
6712 ;; buffer, don't skip forwards.
6713 (not (string= group (gnus-group-group-name))))
6714 (gnus-group-next-unread-group 1))
6715 (setq group-point (point))
6718 ;; If we have several article buffers, we kill them at exit.
6719 (unless gnus-single-article-buffer
6720 (gnus-kill-buffer gnus-article-buffer)
6721 (gnus-kill-buffer gnus-original-article-buffer)
6722 (setq gnus-article-current nil))
6724 (if (not gnus-kill-summary-on-exit)
6726 (gnus-deaden-summary)
6728 ;; We set all buffer-local variables to nil. It is unclear why
6729 ;; this is needed, but if we don't, buffer-local variables are
6730 ;; not garbage-collected, it seems. This would the lead to en
6731 ;; ever-growing Emacs.
6732 (gnus-summary-clear-local-variables)
6733 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6734 (gnus-summary-clear-local-variables))
6735 (when (get-buffer gnus-article-buffer)
6736 (bury-buffer gnus-article-buffer))
6737 ;; Return to group mode buffer.
6738 (when (eq mode 'gnus-summary-mode)
6739 (gnus-kill-buffer buf)))
6740 (setq gnus-current-select-method gnus-select-method)
6741 (set-buffer gnus-group-buffer)
6743 (gnus-handle-ephemeral-exit quit-config)
6744 (goto-char group-point)
6745 ;; If gnus-group-buffer is already displayed, make sure we also move
6746 ;; the cursor in the window that displays it.
6747 (let ((win (get-buffer-window (current-buffer) 0)))
6748 (if win (set-window-point win (point))))
6749 (unless leave-hidden
6750 (gnus-configure-windows 'group 'force))
6751 (unless (pos-visible-in-window-p)
6752 (forward-line (/ (static-if (featurep 'xemacs)
6753 (window-displayed-height)
6754 (1- (window-height)))
6756 (set-window-start (selected-window) (point))
6757 (goto-char group-point)))
6758 ;; Clear the current group name.
6760 (setq gnus-newsgroup-name nil)))))
6762 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6763 (defun gnus-summary-exit-no-update (&optional no-questions)
6764 "Quit reading current newsgroup without updating read article info."
6766 (let* ((group gnus-newsgroup-name)
6767 (gnus-group-is-exiting-p t)
6768 (gnus-group-is-exiting-without-update-p t)
6769 (quit-config (gnus-group-quit-config group)))
6770 (when (or no-questions
6772 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6773 (gnus-async-halt-prefetch)
6774 (run-hooks 'gnus-summary-prepare-exit-hook)
6775 ;; If we have several article buffers, we kill them at exit.
6776 (unless gnus-single-article-buffer
6777 (gnus-kill-buffer gnus-article-buffer)
6778 (gnus-kill-buffer gnus-original-article-buffer)
6779 (setq gnus-article-current nil))
6780 (if (not gnus-kill-summary-on-exit)
6781 (gnus-deaden-summary)
6782 (gnus-close-group group)
6783 (gnus-summary-clear-local-variables)
6784 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6785 (gnus-summary-clear-local-variables))
6786 (gnus-kill-buffer gnus-summary-buffer))
6787 (unless gnus-single-article-buffer
6788 (setq gnus-article-current nil))
6789 (when gnus-use-trees
6790 (gnus-tree-close group))
6791 (gnus-async-prefetch-remove-group group)
6792 (when (get-buffer gnus-article-buffer)
6793 (bury-buffer gnus-article-buffer))
6794 ;; Return to the group buffer.
6795 (gnus-configure-windows 'group 'force)
6796 ;; Clear the current group name.
6797 (setq gnus-newsgroup-name nil)
6798 (unless (gnus-ephemeral-group-p group)
6799 (gnus-group-update-group group))
6800 (when (equal (gnus-group-group-name) group)
6801 (gnus-group-next-unread-group 1))
6803 (gnus-handle-ephemeral-exit quit-config)))))
6805 (defun gnus-handle-ephemeral-exit (quit-config)
6806 "Handle movement when leaving an ephemeral group.
6807 The state which existed when entering the ephemeral is reset."
6808 (if (not (buffer-name (car quit-config)))
6809 (gnus-configure-windows 'group 'force)
6810 (set-buffer (car quit-config))
6811 (cond ((eq major-mode 'gnus-summary-mode)
6812 (gnus-set-global-variables))
6813 ((eq major-mode 'gnus-article-mode)
6815 ;; The `gnus-summary-buffer' variable may point
6816 ;; to the old summary buffer when using a single
6818 (unless (gnus-buffer-live-p gnus-summary-buffer)
6819 (set-buffer gnus-group-buffer))
6820 (set-buffer gnus-summary-buffer)
6821 (gnus-set-global-variables))))
6822 (if (or (eq (cdr quit-config) 'article)
6823 (eq (cdr quit-config) 'pick))
6825 ;; The current article may be from the ephemeral group
6826 ;; thus it is best that we reload this article
6828 ;; If we're exiting from a large digest, this can be
6829 ;; extremely slow. So, it's better not to reload it. -- jh.
6830 ;;(gnus-summary-show-article)
6831 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6832 (gnus-configure-windows 'pick 'force)
6833 (gnus-configure-windows (cdr quit-config) 'force)))
6834 (gnus-configure-windows (cdr quit-config) 'force))
6835 (when (eq major-mode 'gnus-summary-mode)
6836 (gnus-summary-next-subject 1 nil t)
6837 (gnus-summary-recenter)
6838 (gnus-summary-position-point))))
6840 (defun gnus-summary-preview-mime-message ()
6841 "MIME decode and play this message."
6843 (let ((gnus-break-pages nil)
6845 (gnus-summary-select-article gnus-show-all-headers t))
6846 (let ((w (get-buffer-window gnus-article-buffer)))
6848 (select-window (get-buffer-window gnus-article-buffer)))))
6852 (defvar gnus-dead-summary-mode-map nil)
6854 (unless gnus-dead-summary-mode-map
6855 (setq gnus-dead-summary-mode-map (make-keymap))
6856 (suppress-keymap gnus-dead-summary-mode-map)
6857 (substitute-key-definition
6858 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6859 (dolist (key '("\C-d" "\r" "\177" [delete]))
6860 (define-key gnus-dead-summary-mode-map
6861 key 'gnus-summary-wake-up-the-dead))
6862 (dolist (key '("q" "Q"))
6863 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6865 (defvar gnus-dead-summary-mode nil
6866 "Minor mode for Gnus summary buffers.")
6868 (defun gnus-dead-summary-mode (&optional arg)
6869 "Minor mode for Gnus summary buffers."
6871 (when (eq major-mode 'gnus-summary-mode)
6872 (make-local-variable 'gnus-dead-summary-mode)
6873 (setq gnus-dead-summary-mode
6874 (if (null arg) (not gnus-dead-summary-mode)
6875 (> (prefix-numeric-value arg) 0)))
6876 (when gnus-dead-summary-mode
6878 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6880 (defun gnus-deaden-summary ()
6881 "Make the current summary buffer into a dead summary buffer."
6882 ;; Kill any previous dead summary buffer.
6883 (when (and gnus-dead-summary
6884 (buffer-name gnus-dead-summary))
6885 (with-current-buffer gnus-dead-summary
6886 (when gnus-dead-summary-mode
6887 (kill-buffer (current-buffer)))))
6888 ;; Make this the current dead summary.
6889 (setq gnus-dead-summary (current-buffer))
6890 (gnus-dead-summary-mode 1)
6891 (let ((name (buffer-name)))
6892 (when (string-match "Summary" name)
6894 (concat (substring name 0 (match-beginning 0)) "Dead "
6895 (substring name (match-beginning 0)))
6899 (defun gnus-kill-or-deaden-summary (buffer)
6900 "Kill or deaden the summary BUFFER."
6902 (when (and (buffer-name buffer)
6903 (not gnus-single-article-buffer))
6904 (with-current-buffer buffer
6905 (gnus-kill-buffer gnus-article-buffer)
6906 (gnus-kill-buffer gnus-original-article-buffer)))
6909 (gnus-kill-summary-on-exit
6910 (when (and gnus-use-trees
6911 (gnus-buffer-exists-p buffer))
6914 (gnus-tree-close gnus-newsgroup-name)))
6915 (gnus-kill-buffer buffer))
6916 ;; Deaden the buffer.
6917 ((gnus-buffer-exists-p buffer)
6920 (gnus-deaden-summary))))))
6922 (defun gnus-summary-wake-up-the-dead (&rest args)
6923 "Wake up the dead summary buffer."
6925 (gnus-dead-summary-mode -1)
6926 (let ((name (buffer-name)))
6927 (when (string-match "Dead " name)
6929 (concat (substring name 0 (match-beginning 0))
6930 (substring name (match-end 0)))
6932 (gnus-message 3 "This dead summary is now alive again"))
6934 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6935 (defun gnus-summary-fetch-faq (&optional faq-dir)
6936 "Fetch the FAQ for the current group.
6937 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6941 (when current-prefix-arg
6943 "FAQ dir: " (and (listp gnus-group-faq-directory)
6945 gnus-group-faq-directory))))))
6946 (let (gnus-faq-buffer)
6947 (when (setq gnus-faq-buffer
6948 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6949 (gnus-configure-windows 'summary-faq))))
6951 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6952 (defun gnus-summary-describe-group (&optional force)
6953 "Describe the current newsgroup."
6955 (gnus-group-describe-group force gnus-newsgroup-name))
6957 (defun gnus-summary-describe-briefly ()
6958 "Describe summary mode commands briefly."
6960 (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")))
6962 ;; Walking around group mode buffer from summary mode.
6964 (defun gnus-summary-next-group (&optional no-article target-group backward)
6965 "Exit current newsgroup and then select next unread newsgroup.
6966 If prefix argument NO-ARTICLE is non-nil, no article is selected
6967 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6968 previous group instead."
6970 ;; Stop pre-fetching.
6971 (gnus-async-halt-prefetch)
6972 (let ((current-group gnus-newsgroup-name)
6973 (current-buffer (current-buffer))
6975 ;; First we semi-exit this group to update Xrefs and all variables.
6976 ;; We can't do a real exit, because the window conf must remain
6977 ;; the same in case the user is prompted for info, and we don't
6978 ;; want the window conf to change before that...
6979 (gnus-summary-exit t)
6980 (while (not entered)
6981 ;; Then we find what group we are supposed to enter.
6982 (set-buffer gnus-group-buffer)
6983 (gnus-group-jump-to-group current-group)
6986 (if (eq gnus-keep-same-level 'best)
6987 (gnus-summary-best-group gnus-newsgroup-name)
6988 (gnus-summary-search-group backward gnus-keep-same-level))))
6989 (if (not target-group)
6990 ;; There are no further groups, so we return to the group
6993 (gnus-message 5 "Returning to the group buffer")
6995 (when (gnus-buffer-live-p current-buffer)
6996 (set-buffer current-buffer)
6997 (gnus-summary-exit))
6998 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6999 ;; We try to enter the target group.
7000 (gnus-group-jump-to-group target-group)
7001 (let ((unreads (gnus-group-group-unread)))
7002 (if (and (or (eq t unreads)
7003 (and unreads (not (zerop unreads))))
7004 (gnus-summary-read-group
7005 target-group nil no-article
7006 (and (buffer-name current-buffer) current-buffer)
7009 (setq current-group target-group
7010 target-group nil)))))))
7012 (defun gnus-summary-prev-group (&optional no-article)
7013 "Exit current newsgroup and then select previous unread newsgroup.
7014 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7016 (gnus-summary-next-group no-article nil t))
7018 ;; Walking around summary lines.
7020 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7021 "Go to the first subject satisfying any non-nil constraint.
7022 If UNREAD is non-nil, the article should be unread.
7023 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7024 If UNSEEN is non-nil, the article should be unseen.
7025 Returns the article selected or nil if there are no matching articles."
7029 ((null gnus-newsgroup-data)
7030 (gnus-message 3 "No articles in the group")
7032 ;; Pick the first article.
7033 ((not (or unread undownloaded unseen))
7034 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7035 (gnus-data-number (car gnus-newsgroup-data)))
7036 ;; Find the first unread article.
7038 (let ((data gnus-newsgroup-data))
7040 (let ((num (gnus-data-number (car data))))
7041 (or (memq num gnus-newsgroup-unfetched)
7042 (not (or (and unread
7043 (memq num gnus-newsgroup-unreads))
7045 (memq num gnus-newsgroup-undownloaded))
7047 (memq num gnus-newsgroup-unseen)))))))
7048 (setq data (cdr data)))
7052 (goto-char (gnus-data-pos (car data)))
7053 (gnus-data-number (car data)))
7054 (gnus-message 3 "No more%s articles"
7055 (let* ((r (when unread " unread"))
7056 (d (when undownloaded " undownloaded"))
7057 (s (when unseen " unseen"))
7058 (l (delq nil (list r d s))))
7059 (cond ((= 3 (length l))
7060 (concat r "," d ", or" s))
7062 (concat (car l) ", or" (cadr l)))
7069 (gnus-summary-position-point))))))
7071 (defun gnus-summary-next-subject (n &optional unread dont-display)
7072 "Go to next N'th summary line.
7073 If N is negative, go to the previous N'th subject line.
7074 If UNREAD is non-nil, only unread articles are selected.
7075 The difference between N and the actual number of steps taken is
7078 (let ((backward (< n 0))
7082 (gnus-summary-find-prev unread)
7083 (gnus-summary-find-next unread)))
7084 (unless (zerop (setq n (1- n)))
7085 (gnus-summary-show-thread)))
7087 (gnus-message 7 "No more%s articles"
7088 (if unread " unread" "")))
7089 (unless dont-display
7090 (gnus-summary-recenter)
7091 (gnus-summary-position-point))
7094 (defun gnus-summary-next-unread-subject (n)
7095 "Go to next N'th unread summary line."
7097 (gnus-summary-next-subject n t))
7099 (defun gnus-summary-prev-subject (n &optional unread)
7100 "Go to previous N'th summary line.
7101 If optional argument UNREAD is non-nil, only unread article is selected."
7103 (gnus-summary-next-subject (- n) unread))
7105 (defun gnus-summary-prev-unread-subject (n)
7106 "Go to previous N'th unread summary line."
7108 (gnus-summary-next-subject (- n) t))
7110 (defun gnus-summary-goto-subjects (articles)
7111 "Insert the subject header for ARTICLES in the current buffer."
7113 (dolist (article articles)
7114 (gnus-summary-goto-subject article t)))
7115 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7116 (gnus-summary-position-point))
7118 (defun gnus-summary-goto-subject (article &optional force silent)
7119 "Go the subject line of ARTICLE.
7120 If FORCE, also allow jumping to articles not currently shown."
7121 (interactive "nArticle number: ")
7122 (unless (numberp article)
7123 (error "Article %s is not a number" article))
7125 (data (gnus-data-find article)))
7126 ;; We read in the article if we have to.
7129 (gnus-summary-insert-subject
7131 (if (or (numberp force) (vectorp force)) force)
7133 (setq data (gnus-data-find article)))
7138 (gnus-message 3 "Can't find article %d" article))
7140 (let ((pt (gnus-data-pos data)))
7142 (gnus-summary-set-article-display-arrow pt))
7143 (gnus-summary-position-point)
7146 ;; Walking around summary lines with displaying articles.
7148 (defun gnus-summary-expand-window (&optional arg)
7149 "Make the summary buffer take up the entire Emacs frame.
7150 Given a prefix, will force an `article' buffer configuration."
7153 (gnus-configure-windows 'article 'force)
7154 (gnus-configure-windows 'summary 'force)))
7156 (defun gnus-summary-display-article (article &optional all-header)
7157 "Display ARTICLE in article buffer."
7158 (when (gnus-buffer-live-p gnus-article-buffer)
7159 (with-current-buffer gnus-article-buffer
7160 (set-buffer-multibyte t)))
7161 (gnus-set-global-variables)
7162 (when (gnus-buffer-live-p gnus-article-buffer)
7163 (with-current-buffer gnus-article-buffer
7164 (setq gnus-article-charset gnus-newsgroup-charset)
7165 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7166 (set-buffer-multibyte t)))
7170 (if gnus-summary-display-article-function
7171 (funcall gnus-summary-display-article-function article all-header)
7172 (gnus-article-prepare article all-header))
7173 (with-current-buffer gnus-article-buffer
7174 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7176 (gnus-run-hooks 'gnus-select-article-hook)
7177 (when (and gnus-current-article
7178 (not (zerop gnus-current-article)))
7179 (gnus-summary-goto-subject gnus-current-article))
7180 (gnus-summary-recenter)
7181 (when (and gnus-use-trees gnus-show-threads)
7182 (gnus-possibly-generate-tree article)
7183 (gnus-highlight-selected-tree article))
7184 ;; Successfully display article.
7185 (gnus-article-set-window-start
7186 (cdr (assq article gnus-newsgroup-bookmarks))))))
7188 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7189 "Select the current article.
7190 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7191 non-nil, the article will be re-fetched even if it already present in
7192 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7194 ;; Make sure we are in the summary buffer to work around bbdb bug.
7195 (unless (eq major-mode 'gnus-summary-mode)
7196 (set-buffer gnus-summary-buffer))
7197 (let ((article (or article (gnus-summary-article-number)))
7198 (all-headers (not (not all-headers))) ;Must be T or NIL.
7199 gnus-summary-display-article-function)
7201 (gnus-summary-article-pseudo-p article)
7202 (error "This is a pseudo-article"))
7204 (set-buffer gnus-summary-buffer)
7205 (if (or (and gnus-single-article-buffer
7206 (or (null gnus-current-article)
7207 (null gnus-article-current)
7208 (null (get-buffer gnus-article-buffer))
7209 (not (eq article (cdr gnus-article-current)))
7210 (not (equal (car gnus-article-current)
7211 gnus-newsgroup-name))))
7212 (and (not gnus-single-article-buffer)
7213 (or (null gnus-current-article)
7214 (not (eq gnus-current-article article))))
7216 ;; The requested article is different from the current article.
7218 (gnus-summary-display-article article all-headers)
7219 (gnus-article-set-window-start
7220 (cdr (assq article gnus-newsgroup-bookmarks)))
7224 (defun gnus-summary-force-verify-and-decrypt ()
7225 "Display buttons for signed/encrypted parts and verify/decrypt them."
7227 (let ((mm-verify-option 'known)
7228 (mm-decrypt-option 'known)
7229 (gnus-article-emulate-mime t)
7230 (gnus-buttonized-mime-types (append (list "multipart/signed"
7231 "multipart/encrypted")
7232 gnus-buttonized-mime-types)))
7233 (gnus-summary-select-article nil 'force)))
7235 (defun gnus-summary-set-current-mark (&optional current-mark)
7236 "Obsolete function."
7239 (defun gnus-summary-next-article (&optional unread subject backward push)
7240 "Select the next article.
7241 If UNREAD, only unread articles are selected.
7242 If SUBJECT, only articles with SUBJECT are selected.
7243 If BACKWARD, the previous article is selected instead of the next."
7246 ;; Is there such an article?
7247 ((and (gnus-summary-search-forward unread subject backward)
7248 (or (gnus-summary-display-article (gnus-summary-article-number))
7249 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7250 (gnus-summary-position-point))
7251 ;; If not, we try the first unread, if that is wanted.
7253 gnus-auto-select-same
7254 (gnus-summary-first-unread-article))
7255 (gnus-summary-position-point)
7256 (gnus-message 6 "Wrapped"))
7257 ;; Try to get next/previous article not displayed in this group.
7258 ((and gnus-auto-extend-newsgroup
7259 (not unread) (not subject))
7260 (gnus-summary-goto-article
7261 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7262 nil (count-lines (point-min) (point))))
7263 ;; Go to next/previous group.
7265 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7266 (gnus-summary-jump-to-group gnus-newsgroup-name))
7267 (let ((cmd last-command-char)
7269 (with-current-buffer gnus-group-buffer
7272 (if (eq gnus-keep-same-level 'best)
7273 (gnus-summary-best-group gnus-newsgroup-name)
7274 (gnus-summary-search-group backward gnus-keep-same-level))))
7275 ;; For some reason, the group window gets selected. We change
7277 (select-window (get-buffer-window (current-buffer)))
7278 ;; Select next unread newsgroup automagically.
7280 ((or (not gnus-auto-select-next)
7282 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7283 ((or (eq gnus-auto-select-next 'quietly)
7284 (and (eq gnus-auto-select-next 'slightly-quietly)
7286 (and (eq gnus-auto-select-next 'almost-quietly)
7287 (gnus-summary-last-article-p)))
7289 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7291 (gnus-message 7 "No more%s articles (%s)..."
7292 (if unread " unread" "")
7293 (if group (concat "selecting " group)
7295 (gnus-summary-next-group nil group backward)))
7297 (when (gnus-key-press-event-p last-input-event)
7298 (gnus-summary-walk-group-buffer
7299 gnus-newsgroup-name cmd unread backward point))))))))
7301 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7302 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7303 (?\C-p (gnus-group-prev-unread-group 1))))
7304 (cursor-in-echo-area t)
7305 keve key group ended prompt)
7307 (set-buffer gnus-group-buffer)
7310 (if (eq gnus-keep-same-level 'best)
7311 (gnus-summary-best-group gnus-newsgroup-name)
7312 (gnus-summary-search-group backward gnus-keep-same-level))))
7316 "No more%s articles%s " (if unread " unread" "")
7318 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7319 (format " (Type %s for %s [%s])"
7320 (single-key-description cmd)
7321 (gnus-group-decoded-name group)
7322 (gnus-group-unread group))
7323 (format " (Type %s to exit %s)"
7324 (single-key-description cmd)
7325 (gnus-group-decoded-name gnus-newsgroup-name)))))
7326 ;; Confirm auto selection.
7327 (setq key (car (setq keve (gnus-read-event-char prompt)))
7330 ((assq key keystrokes)
7331 (let ((obuf (current-buffer)))
7332 (switch-to-buffer gnus-group-buffer)
7334 (gnus-group-jump-to-group group))
7335 (eval (cadr (assq key keystrokes)))
7336 (setq group (gnus-group-group-name))
7337 (switch-to-buffer obuf))
7341 (gnus-ephemeral-group-p gnus-newsgroup-name))
7343 (gnus-summary-next-group nil group backward)))
7345 (push (cdr keve) unread-command-events))))))
7347 (defun gnus-summary-next-unread-article ()
7348 "Select unread article after current one."
7350 (gnus-summary-next-article
7351 (or (not (eq gnus-summary-goto-unread 'never))
7352 (gnus-summary-last-article-p (gnus-summary-article-number)))
7353 (and gnus-auto-select-same
7354 (gnus-summary-article-subject))))
7356 (defun gnus-summary-prev-article (&optional unread subject)
7357 "Select the article after the current one.
7358 If UNREAD is non-nil, only unread articles are selected."
7360 (gnus-summary-next-article unread subject t))
7362 (defun gnus-summary-prev-unread-article ()
7363 "Select unread article before current one."
7365 (gnus-summary-prev-article
7366 (or (not (eq gnus-summary-goto-unread 'never))
7367 (gnus-summary-first-article-p (gnus-summary-article-number)))
7368 (and gnus-auto-select-same
7369 (gnus-summary-article-subject))))
7371 (defun gnus-summary-next-page (&optional lines circular stop)
7372 "Show next page of the selected article.
7373 If at the end of the current article, select the next article.
7374 LINES says how many lines should be scrolled up.
7376 If CIRCULAR is non-nil, go to the start of the article instead of
7377 selecting the next article when reaching the end of the current
7380 If STOP is non-nil, just stop when reaching the end of the message.
7382 Also see the variable `gnus-article-skip-boring'."
7384 (setq gnus-summary-buffer (current-buffer))
7385 (gnus-set-global-variables)
7386 (let ((article (gnus-summary-article-number))
7387 (article-window (get-buffer-window gnus-article-buffer t))
7389 ;; If the buffer is empty, we have no article.
7391 (error "No article to select"))
7392 (gnus-configure-windows 'article)
7393 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7394 (if (and (eq gnus-summary-goto-unread 'never)
7395 (not (gnus-summary-last-article-p article)))
7396 (gnus-summary-next-article)
7397 (gnus-summary-next-unread-article))
7398 (if (or (null gnus-current-article)
7399 (null gnus-article-current)
7400 (/= article (cdr gnus-article-current))
7401 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7402 ;; Selected subject is different from current article's.
7403 (gnus-summary-display-article article)
7404 (when article-window
7405 (gnus-eval-in-buffer-window gnus-article-buffer
7406 (setq endp (or (gnus-article-next-page lines)
7407 (gnus-article-only-boring-p))))
7410 (gnus-message 3 "End of message"))
7412 (gnus-summary-beginning-of-article))
7414 (gnus-message 3 "End of message"))
7416 (if (and (eq gnus-summary-goto-unread 'never)
7417 (not (gnus-summary-last-article-p article)))
7418 (gnus-summary-next-article)
7419 (gnus-summary-next-unread-article))))))))
7420 (gnus-summary-recenter)
7421 (gnus-summary-position-point)))
7423 (defun gnus-summary-prev-page (&optional lines move)
7424 "Show previous page of selected article.
7425 Argument LINES specifies lines to be scrolled down.
7426 If MOVE, move to the previous unread article if point is at
7427 the beginning of the buffer."
7429 (let ((article (gnus-summary-article-number))
7430 (article-window (get-buffer-window gnus-article-buffer t))
7432 (gnus-configure-windows 'article)
7433 (if (or (null gnus-current-article)
7434 (null gnus-article-current)
7435 (/= article (cdr gnus-article-current))
7436 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7437 ;; Selected subject is different from current article's.
7438 (gnus-summary-display-article article)
7439 (gnus-summary-recenter)
7440 (when article-window
7441 (gnus-eval-in-buffer-window gnus-article-buffer
7442 (setq endp (gnus-article-prev-page lines)))
7443 (when (and move endp)
7445 (gnus-message 3 "Beginning of message"))
7447 (if (and (eq gnus-summary-goto-unread 'never)
7448 (not (gnus-summary-first-article-p article)))
7449 (gnus-summary-prev-article)
7450 (gnus-summary-prev-unread-article))))))))
7451 (gnus-summary-position-point))
7453 (defun gnus-summary-prev-page-or-article (&optional lines)
7454 "Show previous page of selected article.
7455 Argument LINES specifies lines to be scrolled down.
7456 If at the beginning of the article, go to the next article."
7458 (gnus-summary-prev-page lines t))
7460 (defun gnus-summary-scroll-up (lines)
7461 "Scroll up (or down) one line current article.
7462 Argument LINES specifies lines to be scrolled up (or down if negative)."
7464 (gnus-configure-windows 'article)
7465 (gnus-summary-show-thread)
7466 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7467 (gnus-eval-in-buffer-window gnus-article-buffer
7469 (when (gnus-article-next-page lines)
7470 (gnus-message 3 "End of message")))
7472 (gnus-article-prev-page (- lines))))))
7473 (gnus-summary-recenter)
7474 (gnus-summary-position-point))
7476 (defun gnus-summary-scroll-down (lines)
7477 "Scroll down (or up) one line current article.
7478 Argument LINES specifies lines to be scrolled down (or up if negative)."
7480 (gnus-summary-scroll-up (- lines)))
7482 (defun gnus-summary-next-same-subject ()
7483 "Select next article which has the same subject as current one."
7485 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7487 (defun gnus-summary-prev-same-subject ()
7488 "Select previous article which has the same subject as current one."
7490 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7492 (defun gnus-summary-next-unread-same-subject ()
7493 "Select next unread article which has the same subject as current one."
7495 (gnus-summary-next-article t (gnus-summary-article-subject)))
7497 (defun gnus-summary-prev-unread-same-subject ()
7498 "Select previous unread article which has the same subject as current one."
7500 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7502 (defun gnus-summary-first-unread-article ()
7503 "Select the first unread article.
7504 Return nil if there are no unread articles."
7507 (when (gnus-summary-first-subject t)
7508 (gnus-summary-show-thread)
7509 (gnus-summary-first-subject t)
7510 (gnus-summary-display-article (gnus-summary-article-number)))
7511 (gnus-summary-position-point)))
7513 (defun gnus-summary-first-unread-subject ()
7514 "Place the point on the subject line of the first unread article.
7515 Return nil if there are no unread articles."
7518 (when (gnus-summary-first-subject t)
7519 (gnus-summary-show-thread)
7520 (gnus-summary-first-subject t))
7521 (gnus-summary-position-point)))
7523 (defun gnus-summary-first-unseen-subject ()
7524 "Place the point on the subject line of the first unseen article.
7525 Return nil if there are no unseen articles."
7528 (when (gnus-summary-first-subject nil nil t)
7529 (gnus-summary-show-thread)
7530 (gnus-summary-first-subject nil nil t))
7531 (gnus-summary-position-point)))
7533 (defun gnus-summary-first-unseen-or-unread-subject ()
7534 "Place the point on the subject line of the first unseen article or,
7535 if all article have been seen, on the subject line of the first unread
7539 (unless (when (gnus-summary-first-subject nil nil t)
7540 (gnus-summary-show-thread)
7541 (gnus-summary-first-subject nil nil t))
7542 (when (gnus-summary-first-subject t)
7543 (gnus-summary-show-thread)
7544 (gnus-summary-first-subject t)))
7545 (gnus-summary-position-point)))
7547 (defun gnus-summary-first-article ()
7548 "Select the first article.
7549 Return nil if there are no articles."
7552 (when (gnus-summary-first-subject)
7553 (gnus-summary-show-thread)
7554 (gnus-summary-first-subject)
7555 (gnus-summary-display-article (gnus-summary-article-number)))
7556 (gnus-summary-position-point)))
7558 (defun gnus-summary-best-unread-article (&optional arg)
7559 "Select the unread article with the highest score.
7560 If given a prefix argument, select the next unread article that has a
7561 score higher than the default score."
7563 (let ((article (if arg
7564 (gnus-summary-better-unread-subject)
7565 (gnus-summary-best-unread-subject))))
7567 (gnus-summary-goto-article article)
7568 (error "No unread articles"))))
7570 (defun gnus-summary-best-unread-subject ()
7571 "Select the unread subject with the highest score."
7573 (let ((best -1000000)
7574 (data gnus-newsgroup-data)
7577 (and (gnus-data-unread-p (car data))
7579 (gnus-summary-article-score (gnus-data-number (car data))))
7582 article (gnus-data-number (car data))))
7583 (setq data (cdr data)))
7585 (gnus-summary-goto-subject article))
7586 (gnus-summary-position-point)
7589 (defun gnus-summary-better-unread-subject ()
7590 "Select the first unread subject that has a score over the default score."
7592 (let ((data gnus-newsgroup-data)
7594 (while (and (setq article (gnus-data-number (car data)))
7595 (or (gnus-data-read-p (car data))
7596 (not (> (gnus-summary-article-score article)
7597 gnus-summary-default-score))))
7598 (setq data (cdr data)))
7600 (gnus-summary-goto-subject article))
7601 (gnus-summary-position-point)
7604 (defun gnus-summary-last-subject ()
7605 "Go to the last displayed subject line in the group."
7606 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7608 (gnus-summary-goto-subject article))))
7610 (defun gnus-summary-goto-article (article &optional all-headers force)
7611 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7612 If ALL-HEADERS is non-nil, no header lines are hidden.
7613 If FORCE, go to the article even if it isn't displayed. If FORCE
7614 is a number, it is the line the article is to be displayed on."
7618 "Article number or Message-ID: "
7619 (mapcar (lambda (number) (list (int-to-string number)))
7620 gnus-newsgroup-limit))
7624 (if (and (stringp article)
7625 (string-match "@\\|%40" article))
7626 (gnus-summary-refer-article article)
7627 (when (stringp article)
7628 (setq article (string-to-number article)))
7629 (if (gnus-summary-goto-subject article force)
7630 (gnus-summary-display-article article all-headers)
7631 (gnus-message 4 "Couldn't go to article %s" article) nil))
7632 (gnus-summary-position-point)))
7634 (defun gnus-summary-goto-last-article ()
7635 "Go to the previously read article."
7638 (when gnus-last-article
7639 (gnus-summary-goto-article gnus-last-article nil t))
7640 (gnus-summary-position-point)))
7642 (defun gnus-summary-pop-article (number)
7643 "Pop one article off the history and go to the previous.
7644 NUMBER articles will be popped off."
7647 (setq gnus-newsgroup-history
7648 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7650 (gnus-summary-goto-article (car to) nil t)
7651 (error "Article history empty")))
7652 (gnus-summary-position-point))
7654 ;; Summary commands and functions for limiting the summary buffer.
7656 (defun gnus-summary-limit-to-articles (n)
7657 "Limit the summary buffer to the next N articles.
7658 If not given a prefix, use the process marked articles instead."
7661 (let ((articles (gnus-summary-work-articles n)))
7662 (setq gnus-newsgroup-processable nil)
7663 (gnus-summary-limit articles))
7664 (gnus-summary-position-point)))
7666 (defun gnus-summary-pop-limit (&optional total)
7667 "Restore the previous limit.
7668 If given a prefix, remove all limits."
7671 (setq gnus-newsgroup-limits
7672 (list (mapcar (lambda (h) (mail-header-number h))
7673 gnus-newsgroup-headers))))
7674 (unless gnus-newsgroup-limits
7675 (error "No limit to pop"))
7677 (gnus-summary-limit nil 'pop)
7678 (gnus-summary-position-point)))
7680 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7681 "Limit the summary buffer to articles that have subjects that match a regexp.
7682 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7684 (list (read-string (if current-prefix-arg
7685 "Exclude subject (regexp): "
7686 "Limit to subject (regexp): "))
7687 nil current-prefix-arg))
7689 (setq header "subject"))
7690 (when (not (equal "" subject))
7692 (let ((articles (gnus-summary-find-matching
7693 (or header "subject") subject 'all nil nil
7696 (error "Found no matches for \"%s\"" subject))
7697 (gnus-summary-limit articles))
7698 (gnus-summary-position-point))))
7700 (defun gnus-summary-limit-to-author (from &optional not-matching)
7701 "Limit the summary buffer to articles that have authors that match a regexp.
7702 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7704 (list (read-string (if current-prefix-arg
7705 "Exclude author (regexp): "
7706 "Limit to author (regexp): "))
7707 current-prefix-arg))
7708 (gnus-summary-limit-to-subject from "from" not-matching))
7710 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
7711 "Limit the summary buffer to articles with the given RECIPIENT.
7713 If NOT-MATCHING, exclude RECIPIENT.
7715 To and Cc headers are checked. You need to include them in
7716 `nnmail-extra-headers'."
7717 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
7719 (list (read-string (format "%s recipient (regexp): "
7720 (if current-prefix-arg "Exclude" "Limit to")))
7721 current-prefix-arg))
7722 (when (not (equal "" recipient))
7724 (if (memq 'To nnmail-extra-headers)
7725 (gnus-summary-find-matching
7726 (cons 'extra 'To) recipient 'all nil nil
7729 1 "`To' isn't present in `nnmail-extra-headers'")
7733 (if (memq 'Cc nnmail-extra-headers)
7734 (gnus-summary-find-matching
7735 (cons 'extra 'Cc) recipient 'all nil nil
7738 1 "`Cc' isn't present in `nnmail-extra-headers'")
7743 ;; We need the numbers that are in both lists:
7745 (and (memq a to) a))
7749 (error "Found no matches for \"%s\"" recipient))
7750 (gnus-summary-limit articles))
7751 (gnus-summary-position-point))))
7753 (defun gnus-summary-limit-to-age (age &optional younger-p)
7754 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7755 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7756 articles that are younger than AGE days."
7758 (let ((younger current-prefix-arg)
7761 (while (not days-got)
7762 (setq days (if younger
7763 (read-string "Limit to articles younger than (in days, older when negative): ")
7765 "Limit to articles older than (in days, younger when negative): ")))
7766 (when (> (length days) 0)
7767 (setq days (read days)))
7772 (setq younger (not younger))
7773 (setq days (* days -1))))
7774 (message "Please enter a number.")
7776 (list days younger)))
7778 (let ((data gnus-newsgroup-data)
7779 (cutoff (days-to-time age))
7780 articles d date is-younger)
7781 (while (setq d (pop data))
7782 (when (and (vectorp (gnus-data-header d))
7783 (setq date (mail-header-date (gnus-data-header d))))
7784 (setq is-younger (time-less-p
7785 (time-since (condition-case ()
7792 (push (gnus-data-number d) articles))))
7793 (gnus-summary-limit (nreverse articles)))
7794 (gnus-summary-position-point)))
7796 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7797 "Limit the summary buffer to articles that match an 'extra' header."
7801 (gnus-completing-read-with-default
7802 (symbol-name (car gnus-extra-headers))
7803 (if current-prefix-arg
7804 "Exclude extra header:"
7805 "Limit extra header:")
7807 (cons (symbol-name x) x))
7812 (read-string (format "%s header %s (regexp): "
7813 (if current-prefix-arg "Exclude" "Limit to")
7815 current-prefix-arg)))
7816 (when (not (equal "" regexp))
7818 (let ((articles (gnus-summary-find-matching
7819 (cons 'extra header) regexp 'all nil nil
7822 (error "Found no matches for \"%s\"" regexp))
7823 (gnus-summary-limit articles))
7824 (gnus-summary-position-point))))
7826 (defun gnus-summary-limit-to-display-predicate ()
7827 "Limit the summary buffer to the predicated in the `display' group parameter."
7829 (unless gnus-newsgroup-display
7830 (error "There is no `display' group parameter"))
7832 (dolist (number gnus-newsgroup-articles)
7833 (when (funcall gnus-newsgroup-display)
7834 (push number articles)))
7835 (gnus-summary-limit articles))
7836 (gnus-summary-position-point))
7838 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7840 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7842 (defun gnus-summary-limit-to-unread (&optional all)
7843 "Limit the summary buffer to articles that are not marked as read.
7844 If ALL is non-nil, limit strictly to unread articles."
7847 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7848 (gnus-summary-limit-to-marks
7849 ;; Concat all the marks that say that an article is read and have
7851 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7852 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7853 gnus-low-score-mark gnus-expirable-mark
7854 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7855 gnus-duplicate-mark gnus-souped-mark)
7858 (defun gnus-summary-limit-to-replied (&optional unreplied)
7859 "Limit the summary buffer to replied articles.
7860 If UNREPLIED (the prefix), limit to unreplied articles."
7864 (gnus-set-difference gnus-newsgroup-articles
7865 gnus-newsgroup-replied))
7866 (gnus-summary-limit gnus-newsgroup-replied))
7867 (gnus-summary-position-point))
7869 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7870 (make-obsolete 'gnus-summary-delete-marked-with
7871 'gnus-summary-limit-exclude-marks)
7873 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7874 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7875 If REVERSE, limit the summary buffer to articles that are marked
7876 with MARKS. MARKS can either be a string of marks or a list of marks.
7877 Returns how many articles were removed."
7878 (interactive "sMarks: ")
7879 (gnus-summary-limit-to-marks marks t))
7881 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7882 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7883 If REVERSE (the prefix), limit the summary buffer to articles that are
7884 not marked with MARKS. MARKS can either be a string of marks or a
7886 Returns how many articles were removed."
7887 (interactive "sMarks: \nP")
7889 (let ((data gnus-newsgroup-data)
7890 (marks (if (listp marks) marks
7891 (append marks nil))) ; Transform to list.
7894 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7895 (memq (gnus-data-mark (car data)) marks))
7896 (push (gnus-data-number (car data)) articles))
7897 (setq data (cdr data)))
7898 (gnus-summary-limit articles))
7899 (gnus-summary-position-point)))
7901 (defun gnus-summary-limit-to-score (score)
7902 "Limit to articles with score at or above SCORE."
7903 (interactive "NLimit to articles with score of at least: ")
7904 (let ((data gnus-newsgroup-data)
7907 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7909 (push (gnus-data-number (car data)) articles))
7910 (setq data (cdr data)))
7912 (gnus-summary-limit articles)
7913 (gnus-summary-position-point))))
7915 (defun gnus-summary-limit-to-unseen ()
7916 "Limit to unseen articles."
7919 (gnus-summary-limit gnus-newsgroup-unseen)
7920 (gnus-summary-position-point)))
7922 (defun gnus-summary-limit-include-thread (id)
7923 "Display all the hidden articles that is in the thread with ID in it.
7924 When called interactively, ID is the Message-ID of the current
7926 (interactive (list (mail-header-id (gnus-summary-article-header))))
7927 (let ((articles (gnus-articles-in-thread
7928 (gnus-id-to-thread (gnus-root-id id)))))
7930 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7931 (gnus-summary-limit-include-matching-articles
7933 (regexp-quote (gnus-simplify-subject-re
7934 (mail-header-subject (gnus-id-to-header id)))))
7935 (gnus-summary-position-point))))
7937 (defun gnus-summary-limit-include-matching-articles (header regexp)
7938 "Display all the hidden articles that have HEADERs that match REGEXP."
7939 (interactive (list (read-string "Match on header: ")
7940 (read-string "Regexp: ")))
7941 (let ((articles (gnus-find-matching-articles header regexp)))
7943 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7944 (gnus-summary-position-point))))
7946 (defun gnus-summary-insert-dormant-articles ()
7947 "Insert all the dormant articles for this group into the current buffer."
7949 (let ((gnus-verbose (max 6 gnus-verbose)))
7950 (if (not gnus-newsgroup-dormant)
7951 (gnus-message 3 "No cached articles for this group")
7952 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7954 (defun gnus-summary-limit-include-dormant ()
7955 "Display all the hidden articles that are marked as dormant.
7956 Note that this command only works on a subset of the articles currently
7957 fetched for this group."
7959 (unless gnus-newsgroup-dormant
7960 (error "There are no dormant articles in this group"))
7962 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7963 (gnus-summary-position-point)))
7965 (defun gnus-summary-limit-exclude-dormant ()
7966 "Hide all dormant articles."
7969 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7970 (gnus-summary-position-point)))
7972 (defun gnus-summary-limit-exclude-childless-dormant ()
7973 "Hide all dormant articles that have no children."
7975 (let ((data (gnus-data-list t))
7976 articles d children)
7977 ;; Find all articles that are either not dormant or have
7979 (while (setq d (pop data))
7980 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7982 (gnus-article-children (gnus-data-number d)))
7985 (when (memq (car children) articles)
7990 (push (gnus-data-number d) articles)))
7993 (gnus-summary-limit articles)
7994 (gnus-summary-position-point))))
7996 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7997 "Mark all unread excluded articles as read.
7998 If ALL, mark even excluded ticked and dormants as read."
8000 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8001 (let ((articles (gnus-sorted-ndifference
8003 (mapcar (lambda (h) (mail-header-number h))
8004 gnus-newsgroup-headers)
8006 gnus-newsgroup-limit))
8008 (setq gnus-newsgroup-unreads
8009 (gnus-sorted-intersection gnus-newsgroup-unreads
8010 gnus-newsgroup-limit))
8012 (setq gnus-newsgroup-dormant nil
8013 gnus-newsgroup-marked nil
8014 gnus-newsgroup-reads
8016 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8017 gnus-newsgroup-reads))
8018 (while (setq article (pop articles))
8019 (unless (or (memq article gnus-newsgroup-dormant)
8020 (memq article gnus-newsgroup-marked))
8021 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8023 (defun gnus-summary-limit (articles &optional pop)
8025 ;; We pop the previous limit off the stack and use that.
8026 (setq articles (car gnus-newsgroup-limits)
8027 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8028 ;; We use the new limit, so we push the old limit on the stack.
8029 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8031 (setq gnus-newsgroup-limit articles)
8032 (let ((total (length gnus-newsgroup-data))
8033 (data (gnus-data-find-list (gnus-summary-article-number)))
8034 (gnus-summary-mark-below nil) ; Inhibit this.
8036 ;; This will do all the work of generating the new summary buffer
8037 ;; according to the new limit.
8038 (gnus-summary-prepare)
8039 ;; Hide any threads, possibly.
8040 (gnus-summary-maybe-hide-threads)
8041 ;; Try to return to the article you were at, or one in the
8044 ;; We try to find some article after the current one.
8046 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8049 (setq data (cdr data))))
8051 ;; If there is no data, that means that we were after the last
8052 ;; article. The same goes when we can't find any articles
8053 ;; after the current one.
8054 (goto-char (point-max))
8055 (gnus-summary-find-prev))
8056 (gnus-set-mode-line 'summary)
8057 ;; We return how many articles were removed from the summary
8058 ;; buffer as a result of the new limit.
8059 (- total (length gnus-newsgroup-data))))
8061 (defsubst gnus-invisible-cut-children (threads)
8064 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8069 (defsubst gnus-cut-thread (thread)
8070 "Go forwards in the thread until we find an article that we want to display."
8071 (when (or (eq gnus-fetch-old-headers 'some)
8072 (eq gnus-fetch-old-headers 'invisible)
8073 (numberp gnus-fetch-old-headers)
8074 (eq gnus-build-sparse-threads 'some)
8075 (eq gnus-build-sparse-threads 'more))
8076 ;; Deal with old-fetched headers and sparse threads.
8080 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8081 (gnus-summary-article-ancient-p
8082 (mail-header-number (car thread))))
8083 (if (or (<= (length (cdr thread)) 1)
8084 (eq gnus-fetch-old-headers 'invisible))
8085 (setq gnus-newsgroup-limit
8086 (delq (mail-header-number (car thread))
8087 gnus-newsgroup-limit)
8088 thread (cadr thread))
8089 (when (gnus-invisible-cut-children (cdr thread))
8090 (let ((th (cdr thread)))
8092 (if (memq (mail-header-number (caar th))
8093 gnus-newsgroup-limit)
8094 (setq thread (car th)
8096 (setq th (cdr th))))))))))
8099 (defun gnus-cut-threads (threads)
8100 "Cut off all uninteresting articles from the beginning of THREADS."
8101 (when (or (eq gnus-fetch-old-headers 'some)
8102 (eq gnus-fetch-old-headers 'invisible)
8103 (numberp gnus-fetch-old-headers)
8104 (eq gnus-build-sparse-threads 'some)
8105 (eq gnus-build-sparse-threads 'more))
8108 (setcar th (gnus-cut-thread (car th)))
8109 (setq th (cdr th)))))
8110 ;; Remove nixed out threads.
8113 (defun gnus-summary-initial-limit (&optional show-if-empty)
8114 "Figure out what the initial limit is supposed to be on group entry.
8115 This entails weeding out unwanted dormants, low-scored articles,
8116 fetch-old-headers verbiage, and so on."
8117 ;; Most groups have nothing to remove.
8118 (if (or gnus-inhibit-limiting
8119 (and (null gnus-newsgroup-dormant)
8120 (eq gnus-newsgroup-display 'gnus-not-ignore)
8121 (not (eq gnus-fetch-old-headers 'some))
8122 (not (numberp gnus-fetch-old-headers))
8123 (not (eq gnus-fetch-old-headers 'invisible))
8124 (null gnus-summary-expunge-below)
8125 (not (eq gnus-build-sparse-threads 'some))
8126 (not (eq gnus-build-sparse-threads 'more))
8127 (null gnus-thread-expunge-below)
8128 (not gnus-use-nocem)))
8130 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8131 (setq gnus-newsgroup-limit nil)
8134 (unless (car (symbol-value node))
8135 ;; These threads have no parents -- they are roots.
8136 (let ((nodes (cdr (symbol-value node)))
8139 (if (and gnus-thread-expunge-below
8140 (< (gnus-thread-total-score (car nodes))
8141 gnus-thread-expunge-below))
8142 (gnus-expunge-thread (pop nodes))
8143 (setq thread (pop nodes))
8144 (gnus-summary-limit-children thread))))))
8145 gnus-newsgroup-dependencies)
8146 ;; If this limitation resulted in an empty group, we might
8147 ;; pop the previous limit and use it instead.
8148 (when (and (not gnus-newsgroup-limit)
8150 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8151 gnus-newsgroup-limit))
8153 (defun gnus-summary-limit-children (thread)
8154 "Return 1 if this subthread is visible and 0 if it is not."
8155 ;; First we get the number of visible children to this thread. This
8156 ;; is done by recursing down the thread using this function, so this
8157 ;; will really go down to a leaf article first, before slowly
8158 ;; working its way up towards the root.
8160 (let* ((max-lisp-eval-depth 5000)
8163 (apply '+ (mapcar 'gnus-summary-limit-children
8166 (number (mail-header-number (car thread)))
8169 (not (memq number gnus-newsgroup-marked))
8171 ;; If this article is dormant and has absolutely no visible
8172 ;; children, then this article isn't visible.
8173 (and (memq number gnus-newsgroup-dormant)
8175 ;; If this is "fetch-old-headered" and there is no
8176 ;; visible children, then we don't want this article.
8177 (and (or (eq gnus-fetch-old-headers 'some)
8178 (numberp gnus-fetch-old-headers))
8179 (gnus-summary-article-ancient-p number)
8181 ;; If this is "fetch-old-headered" and `invisible', then
8182 ;; we don't want this article.
8183 (and (eq gnus-fetch-old-headers 'invisible)
8184 (gnus-summary-article-ancient-p number))
8185 ;; If this is a sparsely inserted article with no children,
8186 ;; we don't want it.
8187 (and (eq gnus-build-sparse-threads 'some)
8188 (gnus-summary-article-sparse-p number)
8190 ;; If we use expunging, and this article is really
8191 ;; low-scored, then we don't want this article.
8192 (when (and gnus-summary-expunge-below
8194 (or (cdr (assq number gnus-newsgroup-scored))
8195 gnus-summary-default-score))
8196 gnus-summary-expunge-below))
8197 ;; We increase the expunge-tally here, but that has
8198 ;; nothing to do with the limits, really.
8199 (incf gnus-newsgroup-expunged-tally)
8200 ;; We also mark as read here, if that's wanted.
8201 (when (and gnus-summary-mark-below
8202 (< score gnus-summary-mark-below))
8203 (setq gnus-newsgroup-unreads
8204 (delq number gnus-newsgroup-unreads))
8205 (if gnus-newsgroup-auto-expire
8206 (push number gnus-newsgroup-expirable)
8207 (push (cons number gnus-low-score-mark)
8208 gnus-newsgroup-reads)))
8210 ;; Do the `display' group parameter.
8211 (and gnus-newsgroup-display
8212 (not (funcall gnus-newsgroup-display)))
8213 ;; Check NoCeM things.
8214 (when (and gnus-use-nocem
8215 (gnus-nocem-unwanted-article-p
8216 (mail-header-id (car thread))))
8217 (setq gnus-newsgroup-unreads
8218 (delq number gnus-newsgroup-unreads))
8220 ;; Nope, invisible article.
8222 ;; Ok, this article is to be visible, so we add it to the limit
8224 (push number gnus-newsgroup-limit)
8227 (defun gnus-expunge-thread (thread)
8228 "Mark all articles in THREAD as read."
8229 (let* ((number (mail-header-number (car thread))))
8230 (incf gnus-newsgroup-expunged-tally)
8231 ;; We also mark as read here, if that's wanted.
8232 (setq gnus-newsgroup-unreads
8233 (delq number gnus-newsgroup-unreads))
8234 (if gnus-newsgroup-auto-expire
8235 (push number gnus-newsgroup-expirable)
8236 (push (cons number gnus-low-score-mark)
8237 gnus-newsgroup-reads)))
8238 ;; Go recursively through all subthreads.
8239 (mapcar 'gnus-expunge-thread (cdr thread)))
8241 ;; Summary article oriented commands
8243 (defun gnus-summary-refer-parent-article (n)
8244 "Refer parent article N times.
8245 If N is negative, go to ancestor -N instead.
8246 The difference between N and the number of articles fetched is returned."
8250 (when (not (natnump n))
8255 (setq header (gnus-summary-article-header))
8256 (if (and (eq (mail-header-number header)
8257 (cdr gnus-article-current))
8258 (equal gnus-newsgroup-name
8259 (car gnus-article-current)))
8260 ;; If we try to find the parent of the currently
8261 ;; displayed article, then we take a look at the actual
8262 ;; References header, since this is slightly more
8263 ;; reliable than the References field we got from the
8266 (set-buffer gnus-original-article-buffer)
8267 (nnheader-narrow-to-headers)
8268 (unless (setq ref (message-fetch-field "references"))
8269 (when (setq ref (message-fetch-field "in-reply-to"))
8270 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8273 ;; It's not the current article, so we take a bet on
8274 ;; the value we got from the server.
8275 (mail-header-references header)))
8277 (not (equal ref "")))
8278 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8279 (gnus-message 1 "Couldn't find parent"))
8280 (gnus-message 1 "No references in article %d"
8281 (gnus-summary-article-number))
8284 (gnus-summary-position-point)
8287 (defun gnus-summary-refer-references ()
8288 "Fetch all articles mentioned in the References header.
8289 Return the number of articles fetched."
8291 (let ((ref (mail-header-references (gnus-summary-article-header)))
8292 (current (gnus-summary-article-number))
8296 (error "No References in the current article")
8297 ;; For each Message-ID in the References header...
8298 (while (string-match "<[^>]*>" ref)
8300 ;; ... fetch that article.
8301 (gnus-summary-refer-article
8302 (prog1 (match-string 0 ref)
8303 (setq ref (substring ref (match-end 0))))))
8304 (gnus-summary-goto-subject current)
8305 (gnus-summary-position-point)
8308 (defun gnus-summary-refer-thread (&optional limit)
8309 "Fetch all articles in the current thread.
8310 If LIMIT (the numerical prefix), fetch that many old headers instead
8311 of what's specified by the `gnus-refer-thread-limit' variable."
8313 (let ((id (mail-header-id (gnus-summary-article-header)))
8314 (limit (if limit (prefix-numeric-value limit)
8315 gnus-refer-thread-limit)))
8316 (unless (eq gnus-fetch-old-headers 'invisible)
8317 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8318 ;; Retrieve the headers and read them in.
8319 (if (eq (if (numberp limit)
8320 (gnus-retrieve-headers
8322 (+ (mail-header-number
8323 (gnus-summary-article-header))
8325 gnus-newsgroup-end))
8326 gnus-newsgroup-name (* limit 2))
8327 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8329 (gnus-retrieve-headers (list gnus-newsgroup-end)
8330 gnus-newsgroup-name limit))
8332 (gnus-build-all-threads)
8333 (error "Can't fetch thread from back ends that don't support NOV"))
8334 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8335 (gnus-summary-limit-include-thread id)))
8337 (defun gnus-summary-refer-article (message-id)
8338 "Fetch an article specified by MESSAGE-ID."
8339 (interactive "sMessage-ID: ")
8340 (when (and (stringp message-id)
8341 (not (zerop (length message-id))))
8342 (setq message-id (gnus-replace-in-string message-id " " ""))
8343 ;; Construct the correct Message-ID if necessary.
8344 ;; Suggested by tale@pawl.rpi.edu.
8345 (unless (string-match "^<" message-id)
8346 (setq message-id (concat "<" message-id)))
8347 (unless (string-match ">$" message-id)
8348 (setq message-id (concat message-id ">")))
8349 ;; People often post MIDs from URLs, so unhex it:
8350 (unless (string-match "@" message-id)
8351 (setq message-id (gnus-url-unhex-string message-id)))
8352 (let* ((header (gnus-id-to-header message-id))
8354 (gnus-summary-article-sparse-p
8355 (mail-header-number header))
8356 (memq (mail-header-number header)
8357 gnus-newsgroup-limit)))
8360 ;; If the article is present in the buffer we just go to it.
8362 (or (not (gnus-summary-article-sparse-p
8363 (mail-header-number header)))
8366 (gnus-summary-goto-article
8367 (mail-header-number header) nil t)
8369 (gnus-summary-update-article (mail-header-number header)))))
8371 ;; We fetch the article.
8373 (dolist (gnus-override-method (gnus-refer-article-methods))
8374 (when (and (gnus-check-server gnus-override-method)
8375 ;; Fetch the header,
8376 (setq number (gnus-summary-insert-subject message-id)))
8377 ;; and display the article.
8378 (gnus-summary-select-article nil nil nil number)
8380 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8382 (defun gnus-refer-article-methods ()
8383 "Return a list of referable methods."
8385 ;; No method, so we default to current and native.
8386 ((null gnus-refer-article-method)
8387 (list gnus-current-select-method gnus-select-method))
8389 ((eq 'current gnus-refer-article-method)
8390 (list gnus-current-select-method))
8391 ;; List of select methods.
8392 ((not (and (symbolp (car gnus-refer-article-method))
8393 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8395 (dolist (method gnus-refer-article-method)
8396 (push (if (eq 'current method)
8397 gnus-current-select-method
8401 ;; One single select method.
8403 (list gnus-refer-article-method))))
8405 (defun gnus-summary-edit-parameters ()
8406 "Edit the group parameters of the current group."
8408 (gnus-group-edit-group gnus-newsgroup-name 'params))
8410 (defun gnus-summary-customize-parameters ()
8411 "Customize the group parameters of the current group."
8413 (gnus-group-customize gnus-newsgroup-name))
8415 (defun gnus-summary-enter-digest-group (&optional force)
8416 "Enter an nndoc group based on the current article.
8417 If FORCE, force a digest interpretation. If not, try
8418 to guess what the document format is."
8420 (let ((conf gnus-current-window-configuration))
8421 (save-window-excursion
8423 (let (gnus-article-prepare-hook
8424 gnus-display-mime-function
8426 (gnus-summary-select-article))))
8427 (setq gnus-current-window-configuration conf)
8428 (let* ((name (format "%s-%d"
8429 (gnus-group-prefixed-name
8430 gnus-newsgroup-name (list 'nndoc ""))
8431 (with-current-buffer gnus-summary-buffer
8432 gnus-current-article)))
8433 (ogroup gnus-newsgroup-name)
8434 (params (append (gnus-info-params (gnus-get-info ogroup))
8435 (list (cons 'to-group ogroup))
8436 (list (cons 'parent-group ogroup))
8437 (list (cons 'save-article-group ogroup))))
8438 (case-fold-search t)
8439 (buf (current-buffer))
8442 (set-buffer gnus-original-article-buffer)
8443 ;; Have the digest group inherit the main mail address of
8444 ;; the parent article.
8445 (when (setq to-address (or (gnus-fetch-field "reply-to")
8446 (gnus-fetch-field "from")))
8447 (setq params (append
8448 (list (cons 'to-address
8449 (funcall gnus-decode-encoded-word-function
8451 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8452 (insert-buffer-substring gnus-original-article-buffer)
8453 ;; Remove lines that may lead nndoc to misinterpret the
8456 (goto-char (point-min))
8457 (or (search-forward "\n\n" nil t) (point)))
8458 (goto-char (point-min))
8459 (delete-matching-lines "^Path:\\|^From ")
8462 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8463 (gnus-newsgroup-ephemeral-ignored-charsets
8464 gnus-newsgroup-ignored-charsets))
8465 (gnus-group-read-ephemeral-group
8466 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8468 ,(if force 'mbox 'guess)))
8470 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8472 ;; Make all postings to this group go to the parent group.
8473 (nconc (gnus-info-params (gnus-get-info name))
8475 ;; Couldn't select this doc group.
8476 (switch-to-buffer buf)
8477 (gnus-set-global-variables)
8478 (gnus-configure-windows 'summary)
8479 (gnus-message 3 "Article couldn't be entered?"))
8480 (kill-buffer dig)))))
8482 (defun gnus-summary-read-document (n)
8483 "Open a new group based on the current article(s).
8484 This will allow you to read digests and other similar
8485 documents as newsgroups.
8486 Obeys the standard process/prefix convention."
8488 (let* ((ogroup gnus-newsgroup-name)
8489 (params (append (gnus-info-params (gnus-get-info ogroup))
8490 (list (cons 'to-group ogroup))))
8491 group egroup groups vgroup)
8492 (dolist (article (gnus-summary-work-articles n))
8493 (setq group (format "%s-%d" gnus-newsgroup-name article))
8494 (gnus-summary-remove-process-mark article)
8495 (when (gnus-summary-display-article article)
8498 (insert-buffer-substring gnus-original-article-buffer)
8499 ;; Remove some headers that may lead nndoc to make
8501 (message-narrow-to-head)
8502 (goto-char (point-min))
8503 (delete-matching-lines "^Path:\\|^From ")
8506 (gnus-group-read-ephemeral-group
8507 group `(nndoc ,group (nndoc-address ,(current-buffer))
8508 (nndoc-article-type guess))
8511 ;; Make all postings to this group go to the parent group.
8512 (nconc (gnus-info-params (gnus-get-info egroup))
8514 (push egroup groups))
8515 ;; Couldn't select this doc group.
8516 (gnus-error 3 "Article couldn't be entered"))))))
8517 ;; Now we have selected all the documents.
8520 (error "None of the articles could be interpreted as documents"))
8521 ((gnus-group-read-ephemeral-group
8522 (setq vgroup (format
8523 "nnvirtual:%s-%s" gnus-newsgroup-name
8524 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8525 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8527 (cons (current-buffer) 'summary)))
8529 (error "Couldn't select virtual nndoc group")))))
8531 (defun gnus-summary-isearch-article (&optional regexp-p)
8532 "Do incremental search forward on the current article.
8533 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8535 (let* ((gnus-inhibit-treatment t)
8536 (old (gnus-summary-select-article)))
8537 (gnus-configure-windows 'article)
8538 (gnus-eval-in-buffer-window gnus-article-buffer
8542 (gnus-article-show-all-headers))
8543 (goto-char (point-min))
8544 (isearch-forward regexp-p)))))
8546 (defun gnus-summary-search-article-forward (regexp &optional backward)
8547 "Search for an article containing REGEXP forward.
8548 If BACKWARD, search backward instead."
8551 (format "Search article %s (regexp%s): "
8552 (if current-prefix-arg "backward" "forward")
8553 (if gnus-last-search-regexp
8554 (concat ", default " gnus-last-search-regexp)
8556 current-prefix-arg))
8557 (if (string-equal regexp "")
8558 (setq regexp (or gnus-last-search-regexp ""))
8559 (setq gnus-last-search-regexp regexp)
8560 (setq gnus-article-before-search gnus-current-article))
8561 ;; Intentionally set gnus-last-article.
8562 (setq gnus-last-article gnus-article-before-search)
8563 (let ((gnus-last-article gnus-last-article))
8564 (if (gnus-summary-search-article regexp backward)
8565 (gnus-summary-show-thread)
8566 (signal 'search-failed (list regexp)))))
8568 (defun gnus-summary-search-article-backward (regexp)
8569 "Search for an article containing REGEXP backward."
8572 (format "Search article backward (regexp%s): "
8573 (if gnus-last-search-regexp
8574 (concat ", default " gnus-last-search-regexp)
8576 (gnus-summary-search-article-forward regexp 'backward))
8579 (defmacro gnus-summary-search-article-position-point (regexp backward)
8580 "Dehighlight the last matched text and goto the beginning position."
8581 (` (if (and gnus-summary-search-article-matched-data
8582 (let ((text (caddr gnus-summary-search-article-matched-data))
8583 (inhibit-read-only t)
8586 (goto-char (car gnus-summary-search-article-matched-data))
8587 (cadr gnus-summary-search-article-matched-data))
8589 (string-match (, regexp) text)))
8590 (if (, backward) (beginning-of-line) (end-of-line))
8591 (goto-char (if (, backward) (point-max) (point-min))))))
8593 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8594 "Place point where X-Face image is displayed."
8595 (if (featurep 'xemacs)
8596 (` (let ((end (if (search-forward "\n\n" nil t)
8597 (goto-char (1- (point)))
8600 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8601 (unless (and (re-search-forward "^From:" end t)
8602 (setq extent (extent-at (point)))
8603 (extent-begin-glyph extent))
8604 (goto-char (, opoint)))))
8605 (` (let ((end (if (search-forward "\n\n" nil t)
8606 (goto-char (1- (point)))
8608 (start (or (search-backward "\n\n" nil t) (point-min))))
8610 (or (text-property-any start end 'x-face-image t);; x-face-e21
8613 (defmacro gnus-summary-search-article-highlight-matched-text
8614 (backward treated x-face)
8615 "Highlight matched text in the function `gnus-summary-search-article'."
8616 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8617 (end (set-marker (make-marker) (match-end 0)))
8618 (inhibit-read-only t)
8622 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8624 (lambda (item) (setq items (delq item items)))
8625 '(gnus-treat-buttonize
8626 gnus-treat-fill-article
8627 gnus-treat-fill-long-lines
8628 gnus-treat-emphasize
8629 gnus-treat-highlight-headers
8630 gnus-treat-highlight-citation
8631 gnus-treat-highlight-signature
8632 gnus-treat-overstrike
8633 gnus-treat-display-x-face
8634 gnus-treat-buttonize-head
8635 gnus-treat-decode-article-as-default-mime-charset))
8637 (gnus-treat-display-x-face
8638 (when (, x-face) gnus-treat-display-x-face)))
8639 (gnus-article-prepare-mime-display)))
8640 (goto-char (if (, backward) start end))
8642 (gnus-summary-search-article-highlight-goto-x-face (point)))
8643 (setq gnus-summary-search-article-matched-data
8644 (list start end (buffer-substring start end)))
8645 (unless (eq start end);; matched text has been deleted. :-<
8646 (put-text-property start end 'face
8647 (or (find-face 'isearch)
8648 'secondary-selection))))))
8651 (defun gnus-summary-search-article (regexp &optional backward)
8652 "Search for an article containing REGEXP.
8653 Optional argument BACKWARD means do search for backward.
8654 `gnus-select-article-hook' is not called during the search."
8655 ;; We have to require this here to make sure that the following
8656 ;; dynamic binding isn't shadowed by autoloading.
8657 (require 'gnus-async)
8659 (let ((gnus-select-article-hook nil) ;Disable hook.
8660 (gnus-article-prepare-hook nil)
8661 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8662 (gnus-use-article-prefetch nil)
8663 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8664 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8666 (gnus-keep-backlog nil)
8667 (gnus-break-pages nil)
8668 (gnus-summary-display-arrow nil)
8669 (gnus-updated-mode-lines nil)
8670 (gnus-auto-center-summary nil)
8671 (sum (current-buffer))
8674 (gnus-save-hidden-threads
8675 (static-if (featurep 'xemacs)
8676 (let ((gnus-inhibit-treatment t))
8677 (setq treated (eq 'old (gnus-summary-select-article)))
8679 (not (and (gnus-buffer-live-p gnus-article-buffer)
8680 (window-live-p (get-buffer-window
8681 gnus-article-buffer t)))))
8682 (gnus-summary-select-article nil t)
8683 (setq treated nil)))
8684 (let ((gnus-inhibit-treatment t))
8685 (setq treated (eq 'old (gnus-summary-select-article)))
8688 (and (gnus-buffer-live-p gnus-article-buffer)
8689 (window-live-p (get-buffer-window
8690 gnus-article-buffer t))
8691 (or (not (string-match "^\\^X-Face:" regexp))
8692 (with-current-buffer gnus-article-buffer
8693 gnus-summary-search-article-matched-data)))))
8694 (gnus-summary-select-article nil t)
8695 (setq treated nil))))
8696 (set-buffer gnus-article-buffer)
8700 (gnus-article-show-all-headers)
8701 (gnus-summary-search-article-position-point regexp backward))
8702 (goto-char (if backward (point-max) (point-min))))
8704 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8706 (re-search-backward regexp nil t)
8707 (re-search-forward regexp nil t))
8708 ;; We found the regexp.
8710 (gnus-summary-search-article-highlight-matched-text
8711 backward treated (string-match "^\\^X-Face:" regexp))
8714 (/ (- 2 (window-height
8715 (get-buffer-window gnus-article-buffer t)))
8718 (get-buffer-window (current-buffer))
8721 (setq point (point)))
8722 ;; We didn't find it, so we go to the next article.
8725 (while (eq found 'not)
8726 (if (not (if backward (gnus-summary-find-prev)
8727 (gnus-summary-find-next)))
8728 ;; No more articles.
8730 ;; Select the next article and adjust point.
8731 (unless (gnus-summary-article-sparse-p
8732 (gnus-summary-article-number))
8734 (let ((gnus-inhibit-treatment t))
8735 (gnus-summary-select-article))
8737 (set-buffer gnus-article-buffer)
8739 (goto-char (if backward (point-max) (point-min))))))))
8740 (gnus-message 7 ""))
8741 ;; Return whether we found the regexp.
8742 (when (eq found 'found)
8744 (gnus-summary-show-thread)
8745 (gnus-summary-goto-subject gnus-current-article)
8746 (gnus-summary-position-point)
8749 (defun gnus-find-matching-articles (header regexp)
8750 "Return a list of all articles that match REGEXP on HEADER.
8751 This search includes all articles in the current group that Gnus has
8752 fetched headers for, whether they are displayed or not."
8753 (let ((articles nil)
8754 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8755 (case-fold-search t))
8756 (dolist (header gnus-newsgroup-headers)
8757 (when (string-match regexp (funcall func header))
8758 (push (mail-header-number header) articles)))
8759 (nreverse articles)))
8761 (defun gnus-summary-find-matching (header regexp &optional backward unread
8762 not-case-fold not-matching)
8763 "Return a list of all articles that match REGEXP on HEADER.
8764 The search stars on the current article and goes forwards unless
8765 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8766 If UNREAD is non-nil, only unread articles will
8767 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8768 in the comparisons. If NOT-MATCHING, return a list of all articles that
8769 not match REGEXP on HEADER."
8770 (let ((case-fold-search (not not-case-fold))
8773 (if (eq (car header) 'extra)
8776 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8778 (error "%s is an invalid header" header))
8779 (unless (fboundp (intern (concat "mail-header-" header)))
8780 (error "%s is not a valid header" header))
8781 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8782 (dolist (d (if (eq backward 'all)
8784 (gnus-data-find-list
8785 (gnus-summary-article-number)
8786 (gnus-data-list backward))))
8787 (when (and (or (not unread) ; We want all articles...
8788 (gnus-data-unread-p d)) ; Or just unreads.
8789 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8793 (funcall func (gnus-data-header d))))
8794 (string-match regexp
8795 (funcall func (gnus-data-header d)))))
8796 (push (gnus-data-number d) articles))) ; Success!
8797 (nreverse articles)))
8799 (defun gnus-summary-execute-command (header regexp command &optional backward)
8800 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8801 If HEADER is an empty string (or nil), the match is done on the entire
8802 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8804 (list (let ((completion-ignore-case t))
8807 (mapcar (lambda (header) (list (format "%s" header)))
8809 '("Number" "Subject" "From" "Lines" "Date"
8810 "Message-ID" "Xref" "References" "Body")
8811 gnus-extra-headers))
8812 nil 'require-match))
8813 (read-string "Regexp: ")
8814 (read-key-sequence "Command: ")
8815 current-prefix-arg))
8816 (when (equal header "Body")
8818 ;; Hidden thread subtrees must be searched as well.
8819 (gnus-summary-show-all-threads)
8820 ;; We don't want to change current point nor window configuration.
8822 (save-window-excursion
8824 gnus-treat-strip-trailing-blank-lines
8825 gnus-treat-strip-leading-blank-lines
8826 gnus-treat-strip-multiple-blank-lines
8827 gnus-treat-hide-boring-headers
8828 gnus-treat-fold-newsgroups
8829 gnus-article-prepare-hook)
8830 (gnus-message 6 "Executing %s..." (key-description command))
8831 ;; We'd like to execute COMMAND interactively so as to give arguments.
8832 (gnus-execute header regexp
8833 `(call-interactively ',(key-binding command))
8835 (gnus-message 6 "Executing %s...done" (key-description command))))))
8837 (defun gnus-summary-beginning-of-article ()
8838 "Scroll the article back to the beginning."
8840 (gnus-summary-select-article)
8841 (gnus-configure-windows 'article)
8842 (gnus-eval-in-buffer-window gnus-article-buffer
8844 (goto-char (point-min))
8845 (when gnus-break-pages
8846 (gnus-narrow-to-page))))
8848 (defun gnus-summary-end-of-article ()
8849 "Scroll to the end of the article."
8851 (gnus-summary-select-article)
8852 (gnus-configure-windows 'article)
8853 (gnus-eval-in-buffer-window gnus-article-buffer
8855 (goto-char (point-max))
8857 (when gnus-break-pages
8858 (when (re-search-backward page-delimiter nil t)
8859 (narrow-to-region (match-end 0) (point-max)))
8860 (gnus-narrow-to-page))))
8862 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8863 "Truncate to LEN and quote all \"(\"'s in STRING."
8864 (gnus-replace-in-string (if (and len (> (length string) len))
8865 (substring string 0 len)
8869 (defun gnus-summary-print-article (&optional filename n)
8870 "Generate and print a PostScript image of the process-marked (mail) articles.
8872 If used interactively, print the current article if none are
8873 process-marked. With prefix arg, prompt the user for the name of the
8876 When used from Lisp, accept two optional args FILENAME and N. N means
8877 to print the next N articles. If N is negative, print the N previous
8878 articles. If N is nil and articles have been marked with the process
8879 mark, print these instead.
8881 If the optional first argument FILENAME is nil, send the image to the
8882 printer. If FILENAME is a string, save the PostScript image in a file with
8883 that name. If FILENAME is a number, prompt the user for the name of the file
8885 (interactive (list (ps-print-preprint current-prefix-arg)))
8886 (dolist (article (gnus-summary-work-articles n))
8887 (gnus-summary-select-article nil nil 'pseudo article)
8888 (gnus-eval-in-buffer-window gnus-article-buffer
8889 (gnus-print-buffer))
8890 (gnus-summary-remove-process-mark article))
8891 (ps-despool filename))
8893 (defun gnus-print-buffer ()
8894 (let ((buffer (generate-new-buffer " *print*")))
8897 (copy-to-buffer buffer (point-min) (point-max))
8899 (gnus-remove-text-with-property 'gnus-decoration)
8900 (when (gnus-visual-p 'article-highlight 'highlight)
8901 ;; Copy-to-buffer doesn't copy overlay. So redo
8903 (let ((gnus-article-buffer buffer))
8904 (gnus-article-highlight-citation t)
8905 (gnus-article-highlight-signature)
8906 (gnus-article-emphasize)
8907 (gnus-article-delete-invisible-text)))
8908 (let ((ps-left-header
8911 (gnus-summary-print-truncate-and-quote
8912 (mail-header-subject gnus-current-headers)
8915 (gnus-summary-print-truncate-and-quote
8916 (mail-header-from gnus-current-headers)
8920 "/pagenumberstring load"
8922 (mail-header-date gnus-current-headers) ")"))))
8923 (gnus-run-hooks 'gnus-ps-print-hook)
8926 (ps-spool-buffer-with-faces)
8927 (ps-spool-buffer)))))
8928 (kill-buffer buffer))))
8930 (defun gnus-summary-show-article (&optional arg)
8931 "Force redisplaying of the current article.
8932 If ARG (the prefix) is a number, show the article with the charset
8933 defined in `gnus-summary-show-article-charset-alist', or the charset
8935 If ARG (the prefix) is non-nil and not a number, show the raw article
8936 without any article massaging functions being run. Normally, the key
8937 strokes are `C-u g'."
8941 (gnus-summary-show-article t)
8942 (let* ((gnus-newsgroup-charset
8943 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8944 (mm-read-coding-system
8945 "View as charset: " ;; actually it is coding system.
8946 (with-current-buffer gnus-article-buffer
8947 (mm-detect-coding-region (point) (point-max))))))
8948 (default-mime-charset gnus-newsgroup-charset)
8949 (gnus-newsgroup-ignored-charsets 'gnus-all))
8950 (gnus-summary-select-article nil 'force)
8951 (let ((deps gnus-newsgroup-dependencies)
8954 (set-buffer gnus-original-article-buffer)
8956 (message-narrow-to-head)
8957 (setq head (buffer-string))
8958 (goto-char (point-min))
8959 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8960 (goto-char (point-max))
8962 (setq lines (1- (count-lines (point) (point-max))))))
8964 (insert (format "211 %d Article retrieved.\n"
8965 (cdr gnus-article-current)))
8967 (if lines (insert (format "Lines: %d\n" lines)))
8969 (let ((nntp-server-buffer (current-buffer)))
8970 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8971 (gnus-data-set-header
8972 (gnus-data-find (cdr gnus-article-current))
8974 (gnus-summary-update-article-line
8975 (cdr gnus-article-current) header)
8976 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8977 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8979 ;; Select the article the normal way.
8980 (gnus-summary-select-article nil 'force))
8982 ;; We have to require this here to make sure that the following
8983 ;; dynamic binding isn't shadowed by autoloading.
8984 (require 'gnus-async)
8986 ;; Bind the article treatment functions to nil.
8987 (let ((gnus-have-all-headers t)
8988 gnus-article-prepare-hook
8989 gnus-article-decode-hook
8992 (gnus-inhibit-treatment t))
8993 (gnus-summary-select-article nil 'force))))
8994 (gnus-summary-goto-subject gnus-current-article)
8995 (gnus-summary-position-point))
8997 (defun gnus-summary-show-raw-article ()
8998 "Show the raw article without any article massaging functions being run."
9000 (gnus-summary-show-article t))
9002 (defun gnus-summary-verbose-headers (&optional arg)
9003 "Toggle permanent full header display.
9004 If ARG is a positive number, turn header display on.
9005 If ARG is a negative number, turn header display off."
9007 (setq gnus-show-all-headers
9008 (cond ((or (not (numberp arg))
9010 (not gnus-show-all-headers))
9013 (gnus-summary-show-article))
9015 (defun gnus-summary-toggle-header (&optional arg)
9016 "Show the headers if they are hidden, or hide them if they are shown.
9017 If ARG is a positive number, show the entire header.
9018 If ARG is a negative number, hide the unwanted header lines."
9020 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9021 (get-buffer-window gnus-article-buffer t))))
9022 (with-current-buffer gnus-article-buffer
9024 (article-narrow-to-head)
9025 (let* ((buffer-read-only nil)
9026 (inhibit-point-motion-hooks t)
9027 (hidden (if (numberp arg)
9029 (or (not (looking-at "[^ \t\n]+:"))
9030 (gnus-article-hidden-text-p 'headers))))
9032 (delete-region (point-min) (point-max))
9033 (with-current-buffer gnus-original-article-buffer
9034 (goto-char (setq s (point-min)))
9035 (setq e (if (search-forward "\n\n" nil t)
9038 (insert-buffer-substring gnus-original-article-buffer s e)
9039 ;; In T-gnus, gnus-article-decode-hook doesn't contain
9040 ;; article-decode-encoded-words by default.
9041 (article-decode-encoded-words)
9042 (run-hooks 'gnus-article-decode-hook)
9044 (let ((gnus-treat-hide-headers nil)
9045 (gnus-treat-hide-boring-headers nil))
9046 (gnus-delete-wash-type 'headers)
9047 (gnus-treat-article 'head))
9048 (gnus-treat-article 'head))
9051 (set-window-start window (goto-char (point-min))))
9052 (if gnus-break-pages
9053 (gnus-narrow-to-page)
9054 (when (gnus-visual-p 'page-marker)
9055 (let ((buffer-read-only nil))
9056 (gnus-remove-text-with-property 'gnus-prev)
9057 (gnus-remove-text-with-property 'gnus-next))))
9058 (gnus-set-mode-line 'article)))))
9060 (defun gnus-summary-show-all-headers ()
9061 "Make all header lines visible."
9063 (gnus-summary-toggle-header 1))
9065 (defun gnus-summary-toggle-mime (&optional arg)
9066 "Toggle MIME processing.
9067 If ARG is a positive number, turn MIME processing on."
9069 (setq gnus-show-mime
9071 (not gnus-show-mime)
9072 (> (prefix-numeric-value arg) 0)))
9073 (gnus-summary-select-article t 'force))
9075 (defun gnus-summary-caesar-message (&optional arg)
9076 "Caesar rotate the current article by 13.
9077 The numerical prefix specifies how many places to rotate each letter
9080 (gnus-summary-select-article)
9081 (let ((mail-header-separator ""))
9082 (gnus-eval-in-buffer-window gnus-article-buffer
9085 (let ((start (window-start))
9087 (message-caesar-buffer-body arg)
9088 (set-window-start (get-buffer-window (current-buffer)) start)))))
9089 ;; Create buttons and stuff...
9090 (gnus-treat-article nil))
9092 (defun gnus-summary-idna-message (&optional arg)
9093 "Decode IDNA encoded domain names in the current articles.
9094 IDNA encoded domain names looks like `xn--bar'. If a string
9095 remain unencoded after running this function, it is likely an
9096 invalid IDNA string (`xn--bar' is invalid).
9098 You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9099 installed for this command to work."
9101 (if (not (and (condition-case nil (require 'idna)
9103 (mm-coding-system-p 'utf-8)
9104 (executable-find (symbol-value 'idna-program))))
9106 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9107 (gnus-summary-select-article)
9108 (let ((mail-header-separator ""))
9109 (gnus-eval-in-buffer-window gnus-article-buffer
9112 (let ((start (window-start))
9114 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9115 (replace-match (idna-to-unicode (match-string 1))))
9116 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9118 (autoload 'unmorse-region "morse"
9119 "Convert morse coded text in region to ordinary ASCII text."
9122 (defun gnus-summary-morse-message (&optional arg)
9123 "Morse decode the current article."
9125 (gnus-summary-select-article)
9126 (let ((mail-header-separator ""))
9127 (gnus-eval-in-buffer-window gnus-article-buffer
9131 (let ((pos (window-start))
9133 (goto-char (point-min))
9134 (when (message-goto-body)
9135 (gnus-narrow-to-body))
9136 (goto-char (point-min))
9137 (while (search-forward "·" (point-max) t)
9138 (replace-match "."))
9139 (unmorse-region (point-min) (point-max))
9141 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9143 (defun gnus-summary-stop-page-breaking ()
9144 "Stop page breaking in the current article."
9146 (gnus-summary-select-article)
9147 (gnus-eval-in-buffer-window gnus-article-buffer
9149 (when (gnus-visual-p 'page-marker)
9150 (let ((buffer-read-only nil))
9151 (gnus-remove-text-with-property 'gnus-prev)
9152 (gnus-remove-text-with-property 'gnus-next))
9153 (setq gnus-page-broken nil))))
9155 (defun gnus-summary-move-article (&optional n to-newsgroup
9156 select-method action)
9157 "Move the current article to a different newsgroup.
9158 If N is a positive number, move the N next articles.
9159 If N is a negative number, move the N previous articles.
9160 If N is nil and any articles have been marked with the process mark,
9161 move those articles instead.
9162 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9163 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9164 re-spool using this method.
9166 When called interactively with TO-NEWSGROUP being nil, the value of
9167 the variable `gnus-move-split-methods' is used for finding a default
9168 for the target newsgroup.
9170 For this function to work, both the current newsgroup and the
9171 newsgroup that you want to move to have to support the `request-move'
9172 and `request-accept' functions.
9174 ACTION can be either `move' (the default), `crosspost' or `copy'."
9177 (setq action 'move))
9178 ;; Check whether the source group supports the required functions.
9179 (cond ((and (eq action 'move)
9180 (not (gnus-check-backend-function
9181 'request-move-article gnus-newsgroup-name)))
9182 (error "The current group does not support article moving"))
9183 ((and (eq action 'crosspost)
9184 (not (gnus-check-backend-function
9185 'request-replace-article gnus-newsgroup-name)))
9186 (error "The current group does not support article editing")))
9187 (let ((articles (gnus-summary-work-articles n))
9188 (prefix (if (gnus-check-backend-function
9189 'request-move-article gnus-newsgroup-name)
9190 (funcall gnus-move-group-prefix-function
9191 gnus-newsgroup-name)
9193 (names '((move "Move" "Moving")
9194 (copy "Copy" "Copying")
9195 (crosspost "Crosspost" "Crossposting")))
9196 (copy-buf (save-excursion
9197 (nnheader-set-temp-buffer " *copy article*")))
9198 art-group to-method new-xref article to-groups articles-to-update-marks)
9199 (unless (assq action names)
9200 (error "Unknown action %s" action))
9201 ;; Read the newsgroup name.
9202 (when (and (not to-newsgroup)
9203 (not select-method))
9204 (if (and gnus-move-split-methods
9206 (and (memq gnus-current-article articles)
9207 (gnus-buffer-live-p gnus-original-article-buffer))))
9208 ;; When `gnus-move-split-methods' is non-nil, we have to
9209 ;; select an article to give `gnus-read-move-group-name' an
9210 ;; opportunity to suggest an appropriate default. However,
9211 ;; we needn't render or mark the article.
9212 (let ((gnus-display-mime-function nil)
9213 (gnus-article-prepare-hook nil)
9214 (gnus-mark-article-hook nil))
9215 (gnus-summary-select-article nil nil nil (car articles))))
9217 (gnus-read-move-group-name
9218 (cadr (assq action names))
9219 (symbol-value (intern (format "gnus-current-%s-group" action)))
9221 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9222 (setq to-method (or select-method
9223 (gnus-server-to-method
9224 (gnus-group-method to-newsgroup))))
9225 ;; Check the method we are to move this article to...
9226 (unless (gnus-check-backend-function
9227 'request-accept-article (car to-method))
9228 (error "%s does not support article copying" (car to-method)))
9229 (unless (gnus-check-server to-method)
9230 (error "Can't open server %s" (car to-method)))
9231 (gnus-message 6 "%s to %s: %s..."
9232 (caddr (assq action names))
9233 (or (car select-method) to-newsgroup) articles)
9235 (setq article (pop articles))
9239 ;; Move the article.
9241 ;; Remove this article from future suppression.
9242 (gnus-dup-unsuppress-article article)
9243 (let* ((from-method (gnus-find-method-for-group
9244 gnus-newsgroup-name))
9245 (to-method (gnus-find-method-for-group
9247 (move-is-internal (gnus-method-equal from-method to-method)))
9248 (gnus-request-move-article
9249 article ; Article to move
9250 gnus-newsgroup-name ; From newsgroup
9251 (nth 1 (gnus-find-method-for-group
9252 gnus-newsgroup-name)) ; Server
9253 (list 'gnus-request-accept-article
9254 to-newsgroup (list 'quote select-method)
9255 (not articles) t) ; Accept form
9256 (not articles) ; Only save nov last time
9257 move-is-internal))) ; is this move internal?
9258 ;; Copy the article.
9261 (set-buffer copy-buf)
9262 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9264 (nnheader-narrow-to-headers)
9265 (dolist (hdr gnus-copy-article-ignored-headers)
9266 (message-remove-header hdr t)))
9267 (gnus-request-accept-article
9268 to-newsgroup select-method (not articles) t))))
9269 ;; Crosspost the article.
9270 ((eq action 'crosspost)
9271 (let ((xref (message-tokenize-header
9272 (mail-header-xref (gnus-summary-article-header article))
9274 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9275 ":" (number-to-string article)))
9277 (setq xref (list (system-name))))
9280 (mapconcat 'identity
9281 (delete "Xref:" (delete new-xref xref))
9285 (set-buffer copy-buf)
9286 ;; First put the article in the destination group.
9287 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9288 (when (consp (setq art-group
9289 (gnus-request-accept-article
9290 to-newsgroup select-method (not articles))))
9291 (setq new-xref (concat new-xref " " (car art-group)
9293 (number-to-string (cdr art-group))))
9294 ;; Now we have the new Xrefs header, so we insert
9295 ;; it and replace the new article.
9296 (nnheader-replace-header "Xref" new-xref)
9297 (gnus-request-replace-article
9298 (cdr art-group) to-newsgroup (current-buffer))
9302 (gnus-message 1 "Couldn't %s article %s: %s"
9303 (cadr (assq action names)) article
9304 (nnheader-get-report (car to-method))))
9305 ((eq art-group 'junk)
9306 (when (eq action 'move)
9307 (gnus-summary-mark-article article gnus-canceled-mark)
9308 (gnus-message 4 "Deleted article %s" article)
9309 ;; run the delete hook
9310 (run-hook-with-args 'gnus-summary-article-delete-hook
9313 (assoc article (gnus-data-list nil)))
9314 gnus-newsgroup-name nil
9317 (let* ((pto-group (gnus-group-prefixed-name
9318 (car art-group) to-method))
9319 (info (gnus-get-info pto-group))
9320 (to-group (gnus-info-group info))
9322 ;; Update the group that has been moved to.
9324 (memq action '(move copy)))
9325 (unless (member to-group to-groups)
9326 (push to-group to-groups))
9328 (unless (memq article gnus-newsgroup-unreads)
9329 (push 'read to-marks)
9331 info (gnus-add-to-range (gnus-info-read info)
9332 (list (cdr art-group)))))
9334 ;; See whether the article is to be put in the cache.
9335 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9336 gnus-article-mark-lists
9337 (delete '(expirable . expire)
9338 (copy-sequence gnus-article-mark-lists))))
9339 (to-article (cdr art-group)))
9341 ;; Enter the article into the cache in the new group,
9342 ;; if that is required.
9343 (when gnus-use-cache
9344 (gnus-cache-possibly-enter-article
9346 (let ((header (copy-sequence
9347 (gnus-summary-article-header article))))
9348 (mail-header-set-number header to-article)
9350 (memq article gnus-newsgroup-marked)
9351 (memq article gnus-newsgroup-dormant)
9352 (memq article gnus-newsgroup-unreads)))
9354 (when gnus-preserve-marks
9355 ;; Copy any marks over to the new group.
9356 (when (and (equal to-group gnus-newsgroup-name)
9357 (not (memq article gnus-newsgroup-unreads)))
9358 ;; Mark this article as read in this group.
9359 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9360 (setcdr (gnus-active to-group) to-article)
9361 (setcdr gnus-newsgroup-active to-article))
9364 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9365 (when (memq article (symbol-value
9366 (intern (format "gnus-newsgroup-%s"
9368 (push (cdar marks) to-marks)
9369 ;; If the other group is the same as this group,
9370 ;; then we have to add the mark to the list.
9371 (when (equal to-group gnus-newsgroup-name)
9372 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9375 (intern (format "gnus-newsgroup-%s"
9377 ;; Copy the marks to other group.
9378 (gnus-add-marked-articles
9379 to-group (cdar marks) (list to-article) info)))
9380 (setq marks (cdr marks)))
9382 (gnus-request-set-mark
9383 to-group (list (list (list to-article) 'add to-marks))))
9386 (concat "(gnus-group-set-info '"
9387 (gnus-prin1-to-string (gnus-get-info to-group))
9390 ;; Update the Xref header in this article to point to
9391 ;; the new crossposted article we have just created.
9392 (when (eq action 'crosspost)
9394 (set-buffer copy-buf)
9395 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9396 (nnheader-replace-header "Xref" new-xref)
9397 (gnus-request-replace-article
9398 article gnus-newsgroup-name (current-buffer))))
9400 ;; run the move/copy/crosspost/respool hook
9401 (run-hook-with-args 'gnus-summary-article-move-hook
9404 (assoc article (gnus-data-list nil)))
9409 ;;;!!!Why is this necessary?
9410 (set-buffer gnus-summary-buffer)
9412 (gnus-summary-goto-subject article)
9413 (when (eq action 'move)
9414 (gnus-summary-mark-article article gnus-canceled-mark))))
9415 (push article articles-to-update-marks))
9417 (apply 'gnus-summary-remove-process-mark articles-to-update-marks)
9418 ;; Re-activate all groups that have been moved to.
9420 (set-buffer gnus-group-buffer)
9421 (let ((gnus-group-marked to-groups))
9422 (gnus-group-get-new-news-this-group nil t)))
9424 (gnus-kill-buffer copy-buf)
9425 (gnus-summary-position-point)
9426 (gnus-set-mode-line 'summary)))
9428 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9429 "Copy the current article to some other group.
9430 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9431 When called interactively, if TO-NEWSGROUP is nil, use the value of
9432 the variable `gnus-move-split-methods' for finding a default target
9434 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9435 re-spool using this method."
9437 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9439 (defun gnus-summary-crosspost-article (&optional n)
9440 "Crosspost the current article to some other group."
9442 (gnus-summary-move-article n nil nil 'crosspost))
9444 (defcustom gnus-summary-respool-default-method nil
9445 "Default method type for respooling an article.
9446 If nil, use to the current newsgroup method."
9448 :group 'gnus-summary-mail)
9450 (defcustom gnus-summary-display-while-building nil
9451 "If non-nil, show and update the summary buffer as it's being built.
9452 If the value is t, update the buffer after every line is inserted. If
9453 the value is an integer (N), update the display every N lines."
9456 :type '(choice (const :tag "off" nil)
9458 (const :tag "frequently" t)))
9460 (defun gnus-summary-respool-article (&optional n method)
9461 "Respool the current article.
9462 The article will be squeezed through the mail spooling process again,
9463 which means that it will be put in some mail newsgroup or other
9464 depending on `nnmail-split-methods'.
9465 If N is a positive number, respool the N next articles.
9466 If N is a negative number, respool the N previous articles.
9467 If N is nil and any articles have been marked with the process mark,
9468 respool those articles instead.
9470 Respooling can be done both from mail groups and \"real\" newsgroups.
9471 In the former case, the articles in question will be moved from the
9472 current group into whatever groups they are destined to. In the
9473 latter case, they will be copied into the relevant groups."
9475 (list current-prefix-arg
9476 (let* ((methods (gnus-methods-using 'respool))
9478 (symbol-name (or gnus-summary-respool-default-method
9479 (car (gnus-find-method-for-group
9480 gnus-newsgroup-name)))))
9482 (gnus-completing-read-with-default
9483 methname "What backend do you want to use when respooling?"
9484 methods nil t nil 'gnus-mail-method-history))
9487 ((zerop (length (setq ms (gnus-servers-using-backend
9489 (list (intern method) ""))
9493 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9494 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9497 (error "No method given for respooling"))
9498 (if (assoc (symbol-name
9499 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9500 (gnus-methods-using 'respool))
9501 (gnus-summary-move-article n nil method)
9502 (gnus-summary-copy-article n nil method)))
9504 (defun gnus-summary-import-article (file &optional edit)
9505 "Import an arbitrary file into a mail newsgroup."
9506 (interactive "fImport file: \nP")
9507 (let ((group gnus-newsgroup-name)
9508 (now (current-time))
9509 atts lines group-art)
9510 (unless (gnus-check-backend-function 'request-accept-article group)
9511 (error "%s does not support article importing" group))
9512 (or (file-readable-p file)
9513 (not (file-regular-p file))
9514 (error "Can't read %s" file))
9516 (set-buffer (gnus-get-buffer-create " *import file*"))
9518 (nnheader-insert-file-contents file)
9519 (goto-char (point-min))
9520 (if (nnheader-article-p)
9522 (goto-char (point-min))
9523 (search-forward "\n\n" nil t)
9524 (narrow-to-region (point-min) (1- (point)))
9525 (goto-char (point-min))
9526 (unless (re-search-forward "^date:" nil t)
9527 (goto-char (point-max))
9528 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9529 ;; This doesn't look like an article, so we fudge some headers.
9530 (setq atts (file-attributes file)
9531 lines (count-lines (point-min) (point-max)))
9532 (insert "From: " (read-string "From: ") "\n"
9533 "Subject: " (read-string "Subject: ") "\n"
9534 "Date: " (message-make-date (nth 5 atts)) "\n"
9535 "Message-ID: " (message-make-message-id) "\n"
9536 "Lines: " (int-to-string lines) "\n"
9537 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9538 (setq group-art (gnus-request-accept-article group nil t))
9539 (kill-buffer (current-buffer)))
9540 (setq gnus-newsgroup-active (gnus-activate-group group))
9542 (gnus-summary-goto-article (cdr group-art) nil t)
9544 (gnus-summary-edit-article))))
9546 (defun gnus-summary-create-article ()
9547 "Create an article in a mail newsgroup."
9549 (let ((group gnus-newsgroup-name)
9550 (now (current-time))
9552 (unless (gnus-check-backend-function 'request-accept-article group)
9553 (error "%s does not support article importing" group))
9555 (set-buffer (gnus-get-buffer-create " *import file*"))
9557 (goto-char (point-min))
9558 ;; This doesn't look like an article, so we fudge some headers.
9559 (insert "From: " (read-string "From: ") "\n"
9560 "Subject: " (read-string "Subject: ") "\n"
9561 "Date: " (message-make-date now) "\n"
9562 "Message-ID: " (message-make-message-id) "\n")
9563 (setq group-art (gnus-request-accept-article group nil t))
9564 (kill-buffer (current-buffer)))
9565 (setq gnus-newsgroup-active (gnus-activate-group group))
9567 (gnus-summary-goto-article (cdr group-art) nil t)
9568 (gnus-summary-edit-article)))
9570 (defun gnus-summary-article-posted-p ()
9571 "Say whether the current (mail) article is available from news as well.
9572 This will be the case if the article has both been mailed and posted."
9574 (let ((id (mail-header-references (gnus-summary-article-header)))
9575 (gnus-override-method (car (gnus-refer-article-methods))))
9576 (if (gnus-request-head id "")
9577 (gnus-message 2 "The current message was found on %s"
9578 gnus-override-method)
9579 (gnus-message 2 "The current message couldn't be found on %s"
9580 gnus-override-method)
9583 (defun gnus-summary-expire-articles (&optional now)
9584 "Expire all articles that are marked as expirable in the current group."
9586 (when (and (not gnus-group-is-exiting-without-update-p)
9587 (gnus-check-backend-function
9588 'request-expire-articles gnus-newsgroup-name))
9589 ;; This backend supports expiry.
9590 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9591 (expirable (if total
9593 ;; We need to update the info for
9594 ;; this group for `gnus-list-of-read-articles'
9595 ;; to give us the right answer.
9596 (gnus-run-hooks 'gnus-exit-group-hook)
9597 (gnus-summary-update-info)
9598 (gnus-list-of-read-articles gnus-newsgroup-name))
9599 (setq gnus-newsgroup-expirable
9600 (sort gnus-newsgroup-expirable '<))))
9601 (expiry-wait (if now 'immediate
9602 (gnus-group-find-parameter
9603 gnus-newsgroup-name 'expiry-wait)))
9604 (nnmail-expiry-target
9605 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9606 nnmail-expiry-target))
9609 ;; There are expirable articles in this group, so we run them
9610 ;; through the expiry process.
9611 (gnus-message 6 "Expiring articles...")
9612 (unless (gnus-check-group gnus-newsgroup-name)
9613 (error "Can't open server for %s" gnus-newsgroup-name))
9614 ;; The list of articles that weren't expired is returned.
9617 (let ((nnmail-expiry-wait-function nil)
9618 (nnmail-expiry-wait expiry-wait))
9619 (setq es (gnus-request-expire-articles
9620 expirable gnus-newsgroup-name)))
9621 (setq es (gnus-request-expire-articles
9622 expirable gnus-newsgroup-name)))
9624 (setq gnus-newsgroup-expirable es))
9625 ;; We go through the old list of expirable, and mark all
9626 ;; really expired articles as nonexistent.
9627 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9628 (let ((gnus-use-cache nil))
9629 (dolist (article expirable)
9630 (when (and (not (memq article es))
9631 (gnus-data-find article))
9632 (gnus-summary-mark-article article gnus-canceled-mark)
9633 (run-hook-with-args 'gnus-summary-article-expire-hook
9636 (assoc article (gnus-data-list nil)))
9640 (gnus-message 6 "Expiring articles...done")))))
9642 (defun gnus-summary-expire-articles-now ()
9643 "Expunge all expirable articles in the current group.
9644 This means that *all* articles that are marked as expirable will be
9645 deleted forever, right now."
9647 (or gnus-expert-user
9649 "Are you really, really, really sure you want to delete all these messages? ")
9651 (gnus-summary-expire-articles t))
9653 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9654 (defun gnus-summary-delete-article (&optional n)
9655 "Delete the N next (mail) articles.
9656 This command actually deletes articles. This is not a marking
9657 command. The article will disappear forever from your life, never to
9660 If N is negative, delete backwards.
9661 If N is nil and articles have been marked with the process mark,
9662 delete these instead.
9664 If `gnus-novice-user' is non-nil you will be asked for
9665 confirmation before the articles are deleted."
9667 (unless (gnus-check-backend-function 'request-expire-articles
9668 gnus-newsgroup-name)
9669 (error "The current newsgroup does not support article deletion"))
9670 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9671 (error "Couldn't open server"))
9672 ;; Compute the list of articles to delete.
9673 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9674 (nnmail-expiry-target 'delete)
9676 (if (and gnus-novice-user
9677 (not (gnus-yes-or-no-p
9678 (format "Do you really want to delete %s forever? "
9679 (if (> (length articles) 1)
9680 (format "these %s articles" (length articles))
9683 ;; Delete the articles.
9684 (setq not-deleted (gnus-request-expire-articles
9685 articles gnus-newsgroup-name 'force))
9687 (gnus-summary-remove-process-mark (car articles))
9688 ;; The backend might not have been able to delete the article
9690 (unless (memq (car articles) not-deleted)
9691 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9692 (let* ((article (car articles))
9693 (ghead (gnus-data-header
9694 (assoc article (gnus-data-list nil)))))
9695 (run-hook-with-args 'gnus-summary-article-delete-hook
9696 'delete ghead gnus-newsgroup-name nil
9698 (setq articles (cdr articles)))
9700 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9701 (gnus-summary-position-point)
9702 (gnus-set-mode-line 'summary)
9705 (defun gnus-summary-edit-article (&optional force)
9706 "Edit the current article.
9707 This will have permanent effect only in mail groups.
9708 If FORCE is non-nil, allow editing of articles even in read-only
9712 (set-buffer gnus-summary-buffer)
9713 (let ((mail-parse-charset gnus-newsgroup-charset)
9714 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9715 (gnus-set-global-variables)
9716 (when (and (not force)
9717 (gnus-group-read-only-p))
9718 (error "The current newsgroup does not support article editing"))
9719 (gnus-summary-show-article t)
9720 (gnus-article-edit-article
9722 `(lambda (no-highlight)
9723 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9724 (message-options message-options)
9725 (message-options-set-recipient)
9726 (mail-parse-ignored-charsets
9727 ',gnus-newsgroup-ignored-charsets))
9728 (gnus-summary-edit-article-done
9729 ,(or (mail-header-references gnus-current-headers) "")
9730 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9732 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9734 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9736 "Make edits to the current article permanent."
9739 ;; The buffer restriction contains the entire article if it exists.
9740 (when (article-goto-body)
9741 (let ((lines (count-lines (point) (point-max)))
9742 (length (- (point-max) (point)))
9743 (case-fold-search t)
9744 (body (copy-marker (point))))
9745 (goto-char (point-min))
9746 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9747 (delete-region (match-beginning 1) (match-end 1))
9748 (insert (number-to-string length)))
9749 (goto-char (point-min))
9750 (when (re-search-forward
9751 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9752 (delete-region (match-beginning 1) (match-end 1))
9753 (insert (number-to-string length)))
9754 (goto-char (point-min))
9755 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9756 (delete-region (match-beginning 1) (match-end 1))
9757 (insert (number-to-string lines))))))
9758 ;; Replace the article.
9759 (let ((buf (current-buffer)))
9761 (insert-buffer-substring buf)
9763 (if (and (not read-only)
9764 (not (gnus-request-replace-article
9765 (cdr gnus-article-current) (car gnus-article-current)
9766 (current-buffer) t)))
9767 (error "Couldn't replace article")
9768 ;; Update the summary buffer.
9770 (equal (message-tokenize-header references " ")
9771 (message-tokenize-header
9772 (or (message-fetch-field "references") "") " ")))
9773 ;; We only have to update this line.
9776 (message-narrow-to-head)
9777 (let ((head (buffer-string))
9780 (insert (format "211 %d Article retrieved.\n"
9781 (cdr gnus-article-current)))
9784 (let ((nntp-server-buffer (current-buffer)))
9785 (setq header (car (gnus-get-newsgroup-headers
9788 (set-buffer gnus-summary-buffer)
9789 (gnus-data-set-header
9790 (gnus-data-find (cdr gnus-article-current))
9792 (gnus-summary-update-article-line
9793 (cdr gnus-article-current) header)
9794 (if (gnus-summary-goto-subject
9795 (cdr gnus-article-current) nil t)
9796 (gnus-summary-update-secondary-mark
9797 (cdr gnus-article-current))))))))
9799 (set-buffer (or buffer gnus-summary-buffer))
9800 (gnus-summary-update-article (cdr gnus-article-current))
9801 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9802 (gnus-summary-update-secondary-mark
9803 (cdr gnus-article-current))))
9804 ;; Prettify the article buffer again.
9805 (unless no-highlight
9807 (set-buffer gnus-article-buffer)
9808 ;;;!!! Fix this -- article should be rehighlighted.
9809 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9810 (set-buffer gnus-original-article-buffer)
9811 (gnus-request-article
9812 (cdr gnus-article-current)
9813 (car gnus-article-current) (current-buffer))))
9814 ;; Prettify the summary buffer line.
9815 (when (gnus-visual-p 'summary-highlight 'highlight)
9816 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9818 (defun gnus-summary-edit-wash (key)
9819 "Perform editing command KEY in the article buffer."
9823 (message "%s" (concat (this-command-keys) "- "))
9826 (gnus-summary-edit-article)
9827 (execute-kbd-macro (concat (this-command-keys) key))
9828 (gnus-article-edit-done))
9832 (defun gnus-summary-respool-query (&optional silent trace)
9833 "Query where the respool algorithm would put this article."
9835 (let (gnus-mark-article-hook)
9836 (gnus-summary-select-article)
9838 (set-buffer gnus-original-article-buffer)
9839 (let ((groups (nnmail-article-group 'identity trace)))
9842 (message "This message would go to %s"
9843 (mapconcat 'car groups ", "))
9844 (message "This message would go to no groups"))
9847 (defun gnus-summary-respool-trace ()
9848 "Trace where the respool algorithm would put this article.
9849 Display a buffer showing all fancy splitting patterns which matched."
9851 (gnus-summary-respool-query nil t))
9853 ;; Summary marking commands.
9855 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9856 "Mark articles which has the same subject as read, and then select the next.
9857 If UNMARK is positive, remove any kind of mark.
9858 If UNMARK is negative, tick articles."
9861 (setq unmark (prefix-numeric-value unmark)))
9863 (gnus-summary-mark-same-subject
9864 (gnus-summary-article-subject) unmark)))
9865 ;; Select next unread article. If auto-select-same mode, should
9866 ;; select the first unread article.
9867 (gnus-summary-next-article t (and gnus-auto-select-same
9868 (gnus-summary-article-subject)))
9869 (gnus-message 7 "%d article%s marked as %s"
9870 count (if (= count 1) " is" "s are")
9871 (if unmark "unread" "read"))))
9873 (defun gnus-summary-kill-same-subject (&optional unmark)
9874 "Mark articles which has the same subject as read.
9875 If UNMARK is positive, remove any kind of mark.
9876 If UNMARK is negative, tick articles."
9879 (setq unmark (prefix-numeric-value unmark)))
9881 (gnus-summary-mark-same-subject
9882 (gnus-summary-article-subject) unmark)))
9883 ;; If marked as read, go to next unread subject.
9885 ;; Go to next unread subject.
9886 (gnus-summary-next-subject 1 t))
9887 (gnus-message 7 "%d articles are marked as %s"
9888 count (if unmark "unread" "read"))))
9890 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9891 "Mark articles with same SUBJECT as read, and return marked number.
9892 If optional argument UNMARK is positive, remove any kinds of marks.
9893 If optional argument UNMARK is negative, mark articles as unread instead."
9897 ((null unmark) ; Mark as read.
9900 (gnus-summary-mark-article-as-read gnus-killed-mark)
9901 (gnus-summary-show-thread) t)
9902 (gnus-summary-find-subject subject))
9903 (setq count (1+ count))))
9904 ((> unmark 0) ; Tick.
9907 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9908 (gnus-summary-show-thread) t)
9909 (gnus-summary-find-subject subject))
9910 (setq count (1+ count))))
9911 (t ; Mark as unread.
9914 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9915 (gnus-summary-show-thread) t)
9916 (gnus-summary-find-subject subject))
9917 (setq count (1+ count)))))
9918 (gnus-set-mode-line 'summary)
9919 ;; Return the number of marked articles.
9922 (defun gnus-summary-mark-as-processable (n &optional unmark)
9923 "Set the process mark on the next N articles.
9924 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9925 the process mark instead. The difference between N and the actual
9926 number of articles marked is returned."
9928 (if (and (null n) (gnus-region-active-p))
9929 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9930 (setq n (prefix-numeric-value n))
9931 (let ((backward (< n 0))
9936 (gnus-summary-remove-process-mark
9937 (gnus-summary-article-number))
9938 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9939 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9942 (gnus-message 7 "No more articles"))
9943 (gnus-summary-recenter)
9944 (gnus-summary-position-point)
9947 (defun gnus-summary-unmark-as-processable (n)
9948 "Remove the process mark from the next N articles.
9949 If N is negative, unmark backward instead. The difference between N and
9950 the actual number of articles unmarked is returned."
9952 (gnus-summary-mark-as-processable n t))
9954 (defun gnus-summary-unmark-all-processable ()
9955 "Remove the process mark from all articles."
9958 (while gnus-newsgroup-processable
9959 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9960 (gnus-summary-position-point))
9962 (defun gnus-summary-add-mark (article type)
9963 "Mark ARTICLE with a mark of TYPE."
9964 (let ((vtype (car (assq type gnus-article-mark-lists)))
9967 (error "No such mark type: %s" type)
9968 (setq var (intern (format "gnus-newsgroup-%s" type)))
9969 (set var (cons article (symbol-value var)))
9970 (if (memq type '(processable cached replied forwarded recent saved))
9971 (gnus-summary-update-secondary-mark article)
9972 ;;; !!! This is bogus. We should find out what primary
9973 ;;; !!! mark we want to set.
9974 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9976 (defun gnus-summary-mark-as-expirable (n)
9977 "Mark N articles forward as expirable.
9978 If N is negative, mark backward instead. The difference between N and
9979 the actual number of articles marked is returned."
9981 (gnus-summary-mark-forward n gnus-expirable-mark))
9983 (defun gnus-summary-mark-as-spam (n)
9984 "Mark N articles forward as spam.
9985 If N is negative, mark backward instead. The difference between N and
9986 the actual number of articles marked is returned."
9988 (gnus-summary-mark-forward n gnus-spam-mark))
9990 (defun gnus-summary-mark-article-as-replied (article)
9991 "Mark ARTICLE as replied to and update the summary line.
9992 ARTICLE can also be a list of articles."
9993 (interactive (list (gnus-summary-article-number)))
9994 (let ((articles (if (listp article) article (list article))))
9995 (dolist (article articles)
9996 (unless (numberp article)
9997 (error "%s is not a number" article))
9998 (push article gnus-newsgroup-replied)
9999 (let ((buffer-read-only nil))
10000 (when (gnus-summary-goto-subject article nil t)
10001 (gnus-summary-update-secondary-mark article))))))
10003 (defun gnus-summary-mark-article-as-forwarded (article)
10004 "Mark ARTICLE as forwarded and update the summary line.
10005 ARTICLE can also be a list of articles."
10006 (let ((articles (if (listp article) article (list article))))
10007 (dolist (article articles)
10008 (push article gnus-newsgroup-forwarded)
10009 (let ((buffer-read-only nil))
10010 (when (gnus-summary-goto-subject article nil t)
10011 (gnus-summary-update-secondary-mark article))))))
10013 (defun gnus-summary-set-bookmark (article)
10014 "Set a bookmark in current article."
10015 (interactive (list (gnus-summary-article-number)))
10016 (when (or (not (get-buffer gnus-article-buffer))
10017 (not gnus-current-article)
10018 (not gnus-article-current)
10019 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10020 (error "No current article selected"))
10021 ;; Remove old bookmark, if one exists.
10022 (gnus-pull article gnus-newsgroup-bookmarks)
10023 ;; Set the new bookmark, which is on the form
10024 ;; (article-number . line-number-in-body).
10027 (with-current-buffer gnus-article-buffer
10031 (article-goto-body)
10034 gnus-newsgroup-bookmarks)
10035 (gnus-message 6 "A bookmark has been added to the current article."))
10037 (defun gnus-summary-remove-bookmark (article)
10038 "Remove the bookmark from the current article."
10039 (interactive (list (gnus-summary-article-number)))
10040 ;; Remove old bookmark, if one exists.
10041 (if (not (assq article gnus-newsgroup-bookmarks))
10042 (gnus-message 6 "No bookmark in current article.")
10043 (gnus-pull article gnus-newsgroup-bookmarks)
10044 (gnus-message 6 "Removed bookmark.")))
10046 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10047 (defun gnus-summary-mark-as-dormant (n)
10048 "Mark N articles forward as dormant.
10049 If N is negative, mark backward instead. The difference between N and
10050 the actual number of articles marked is returned."
10052 (gnus-summary-mark-forward n gnus-dormant-mark))
10054 (defun gnus-summary-set-process-mark (article)
10055 "Set the process mark on ARTICLE and update the summary line."
10056 (setq gnus-newsgroup-processable
10058 (delq article gnus-newsgroup-processable)))
10059 (when (gnus-summary-goto-subject article)
10060 (gnus-summary-show-thread)
10061 (gnus-summary-goto-subject article)
10062 (gnus-summary-update-secondary-mark article)))
10064 (defun gnus-summary-remove-process-mark (&rest articles)
10065 "Remove the process mark from ARTICLES and update the summary line."
10066 (dolist (article articles)
10067 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10068 (when (gnus-summary-goto-subject article)
10069 (gnus-summary-show-thread)
10070 (gnus-summary-goto-subject article)
10071 (gnus-summary-update-secondary-mark article))))
10073 (defun gnus-summary-set-saved-mark (article)
10074 "Set the process mark on ARTICLE and update the summary line."
10075 (push article gnus-newsgroup-saved)
10076 (when (gnus-summary-goto-subject article)
10077 (gnus-summary-update-secondary-mark article)))
10079 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10080 "Mark N articles as read forwards.
10081 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10082 The difference between N and the actual number of articles marked is
10084 If NO-EXPIRE, auto-expiry will be inhibited."
10086 (gnus-summary-show-thread)
10087 (let ((backward (< n 0))
10088 (gnus-summary-goto-unread
10089 (and gnus-summary-goto-unread
10090 (not (eq gnus-summary-goto-unread 'never))
10091 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10092 gnus-ticked-mark gnus-dormant-mark)))))
10094 (mark (or mark gnus-del-mark)))
10095 (while (and (> n 0)
10096 (gnus-summary-mark-article nil mark no-expire)
10097 (zerop (gnus-summary-next-subject
10099 (and gnus-summary-goto-unread
10100 (not (eq gnus-summary-goto-unread 'never)))
10104 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10105 (gnus-summary-recenter)
10106 (gnus-summary-position-point)
10107 (gnus-set-mode-line 'summary)
10110 (defun gnus-summary-mark-article-as-read (mark)
10111 "Mark the current article quickly as read with MARK."
10112 (let ((article (gnus-summary-article-number)))
10113 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10114 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10115 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10116 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10117 (push (cons article mark) gnus-newsgroup-reads)
10118 ;; Possibly remove from cache, if that is used.
10119 (when gnus-use-cache
10120 (gnus-cache-enter-remove-article article))
10121 ;; Allow the backend to change the mark.
10122 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10123 ;; Check for auto-expiry.
10124 (when (and gnus-newsgroup-auto-expire
10125 (memq mark gnus-auto-expirable-marks))
10126 (setq mark gnus-expirable-mark)
10127 ;; Let the backend know about the mark change.
10128 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10129 (push article gnus-newsgroup-expirable))
10130 ;; Set the mark in the buffer.
10131 (gnus-summary-update-mark mark 'unread)
10134 (defun gnus-summary-mark-article-as-unread (mark)
10135 "Mark the current article quickly as unread with MARK."
10136 (let* ((article (gnus-summary-article-number))
10137 (old-mark (gnus-summary-article-mark article)))
10138 ;; Allow the backend to change the mark.
10139 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10140 (if (eq mark old-mark)
10144 (gnus-error 1 "Can't mark negative article numbers")
10146 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10147 (setq gnus-newsgroup-spam-marked
10148 (delq article gnus-newsgroup-spam-marked))
10149 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10150 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10151 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10152 (cond ((= mark gnus-ticked-mark)
10153 (setq gnus-newsgroup-marked
10154 (gnus-add-to-sorted-list gnus-newsgroup-marked
10156 ((= mark gnus-spam-mark)
10157 (setq gnus-newsgroup-spam-marked
10158 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10160 ((= mark gnus-dormant-mark)
10161 (setq gnus-newsgroup-dormant
10162 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10165 (setq gnus-newsgroup-unreads
10166 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10168 (gnus-pull article gnus-newsgroup-reads)
10170 ;; See whether the article is to be put in the cache.
10171 (and gnus-use-cache
10172 (vectorp (gnus-summary-article-header article))
10174 (gnus-cache-possibly-enter-article
10175 gnus-newsgroup-name article
10176 (gnus-summary-article-header article)
10177 (= mark gnus-ticked-mark)
10178 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10181 (gnus-summary-update-mark mark 'unread)
10184 (defun gnus-summary-mark-article (&optional article mark no-expire)
10185 "Mark ARTICLE with MARK. MARK can be any character.
10186 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10187 `??' (dormant) and `?E' (expirable).
10188 If MARK is nil, then the default character `?r' is used.
10189 If ARTICLE is nil, then the article on the current line will be
10191 If NO-EXPIRE, auto-expiry will be inhibited."
10192 ;; The mark might be a string.
10193 (when (stringp mark)
10194 (setq mark (aref mark 0)))
10195 ;; If no mark is given, then we check auto-expiring.
10197 (setq mark gnus-del-mark))
10198 (when (and (not no-expire)
10199 gnus-newsgroup-auto-expire
10200 (memq mark gnus-auto-expirable-marks))
10201 (setq mark gnus-expirable-mark))
10202 (let ((article (or article (gnus-summary-article-number)))
10203 (old-mark (gnus-summary-article-mark article)))
10204 ;; Allow the backend to change the mark.
10205 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10206 (if (eq mark old-mark)
10209 (error "No article on current line"))
10210 (if (not (if (or (= mark gnus-unread-mark)
10211 (= mark gnus-ticked-mark)
10212 (= mark gnus-spam-mark)
10213 (= mark gnus-dormant-mark))
10214 (gnus-mark-article-as-unread article mark)
10215 (gnus-mark-article-as-read article mark)))
10217 ;; See whether the article is to be put in the cache.
10218 (and gnus-use-cache
10219 (not (= mark gnus-canceled-mark))
10220 (vectorp (gnus-summary-article-header article))
10222 (gnus-cache-possibly-enter-article
10223 gnus-newsgroup-name article
10224 (gnus-summary-article-header article)
10225 (= mark gnus-ticked-mark)
10226 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10228 (when (gnus-summary-goto-subject article nil t)
10229 (let ((buffer-read-only nil))
10230 (gnus-summary-show-thread)
10232 (gnus-summary-update-mark mark 'unread)
10235 (defun gnus-summary-update-secondary-mark (article)
10236 "Update the secondary (read, process, cache) mark."
10237 (gnus-summary-update-mark
10238 (cond ((memq article gnus-newsgroup-processable)
10240 ((memq article gnus-newsgroup-cached)
10242 ((memq article gnus-newsgroup-replied)
10244 ((memq article gnus-newsgroup-forwarded)
10245 gnus-forwarded-mark)
10246 ((memq article gnus-newsgroup-saved)
10248 ((memq article gnus-newsgroup-recent)
10250 ((memq article gnus-newsgroup-unseen)
10254 (when (gnus-visual-p 'summary-highlight 'highlight)
10255 (gnus-run-hooks 'gnus-summary-update-hook))
10258 (defun gnus-summary-update-download-mark (article)
10259 "Update the download mark."
10260 (gnus-summary-update-mark
10261 (cond ((memq article gnus-newsgroup-undownloaded)
10262 gnus-undownloaded-mark)
10263 (gnus-newsgroup-agentized
10264 gnus-downloaded-mark)
10268 (gnus-summary-update-line t)
10271 (defun gnus-summary-update-mark (mark type)
10272 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10273 (buffer-read-only nil))
10274 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10276 (when (looking-at "\r")
10278 (when (<= (+ forward (point)) (point-max))
10279 ;; Go to the right position on the line.
10280 (goto-char (+ forward (point)))
10281 ;; Replace the old mark with the new mark.
10282 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10283 ;; Optionally update the marks by some user rule.
10284 (when (eq type 'unread)
10285 (gnus-data-set-mark
10286 (gnus-data-find (gnus-summary-article-number)) mark)
10287 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10289 (defun gnus-mark-article-as-read (article &optional mark)
10290 "Enter ARTICLE in the pertinent lists and remove it from others."
10291 ;; Make the article expirable.
10292 (let ((mark (or mark gnus-del-mark)))
10293 (setq gnus-newsgroup-expirable
10294 (if (= mark gnus-expirable-mark)
10295 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10296 (delq article gnus-newsgroup-expirable)))
10297 ;; Remove from unread and marked lists.
10298 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10299 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10300 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10301 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10302 (push (cons article mark) gnus-newsgroup-reads)
10303 ;; Possibly remove from cache, if that is used.
10304 (when gnus-use-cache
10305 (gnus-cache-enter-remove-article article))
10308 (defun gnus-mark-article-as-unread (article &optional mark)
10309 "Enter ARTICLE in the pertinent lists and remove it from others."
10310 (let ((mark (or mark gnus-ticked-mark)))
10313 (gnus-error 1 "Can't mark negative article numbers")
10315 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10316 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10317 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10318 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10319 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10321 ;; Unsuppress duplicates?
10322 (when gnus-suppress-duplicates
10323 (gnus-dup-unsuppress-article article))
10325 (cond ((= mark gnus-ticked-mark)
10326 (setq gnus-newsgroup-marked
10327 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10328 ((= mark gnus-spam-mark)
10329 (setq gnus-newsgroup-spam-marked
10330 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10332 ((= mark gnus-dormant-mark)
10333 (setq gnus-newsgroup-dormant
10334 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10336 (setq gnus-newsgroup-unreads
10337 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10338 (gnus-pull article gnus-newsgroup-reads)
10341 (defalias 'gnus-summary-mark-as-unread-forward
10342 'gnus-summary-tick-article-forward)
10343 (make-obsolete 'gnus-summary-mark-as-unread-forward
10344 'gnus-summary-tick-article-forward)
10345 (defun gnus-summary-tick-article-forward (n)
10346 "Tick N articles forwards.
10347 If N is negative, tick backwards instead.
10348 The difference between N and the number of articles ticked is returned."
10350 (gnus-summary-mark-forward n gnus-ticked-mark))
10352 (defalias 'gnus-summary-mark-as-unread-backward
10353 'gnus-summary-tick-article-backward)
10354 (make-obsolete 'gnus-summary-mark-as-unread-backward
10355 'gnus-summary-tick-article-backward)
10356 (defun gnus-summary-tick-article-backward (n)
10357 "Tick N articles backwards.
10358 The difference between N and the number of articles ticked is returned."
10360 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10362 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10363 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10364 (defun gnus-summary-tick-article (&optional article clear-mark)
10365 "Mark current article as unread.
10366 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10367 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10369 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10370 gnus-ticked-mark)))
10372 (defun gnus-summary-mark-as-read-forward (n)
10373 "Mark N articles as read forwards.
10374 If N is negative, mark backwards instead.
10375 The difference between N and the actual number of articles marked is
10378 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10380 (defun gnus-summary-mark-as-read-backward (n)
10381 "Mark the N articles as read backwards.
10382 The difference between N and the actual number of articles marked is
10385 (gnus-summary-mark-forward
10386 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10388 (defun gnus-summary-mark-as-read (&optional article mark)
10389 "Mark current article as read.
10390 ARTICLE specifies the article to be marked as read.
10391 MARK specifies a string to be inserted at the beginning of the line."
10392 (gnus-summary-mark-article article mark))
10394 (defun gnus-summary-clear-mark-forward (n)
10395 "Clear marks from N articles forward.
10396 If N is negative, clear backward instead.
10397 The difference between N and the number of marks cleared is returned."
10399 (gnus-summary-mark-forward n gnus-unread-mark))
10401 (defun gnus-summary-clear-mark-backward (n)
10402 "Clear marks from N articles backward.
10403 The difference between N and the number of marks cleared is returned."
10405 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10407 (defun gnus-summary-mark-unread-as-read ()
10408 "Intended to be used by `gnus-summary-mark-article-hook'."
10409 (when (memq gnus-current-article gnus-newsgroup-unreads)
10410 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10412 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10413 "Intended to be used by `gnus-summary-mark-article-hook'."
10414 (let ((mark (gnus-summary-article-mark)))
10415 (when (or (gnus-unread-mark-p mark)
10416 (gnus-read-mark-p mark))
10417 (gnus-summary-mark-article gnus-current-article
10418 (or new-mark gnus-read-mark)))))
10420 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10421 "Intended to be used by `gnus-summary-mark-article-hook'."
10422 (let ((mark (gnus-summary-article-mark)))
10423 (when (or (gnus-unread-mark-p mark)
10424 (gnus-read-mark-p mark))
10425 (gnus-summary-mark-article (gnus-summary-article-number)
10426 (or new-mark gnus-read-mark)))))
10428 (defun gnus-summary-mark-unread-as-ticked ()
10429 "Intended to be used by `gnus-summary-mark-article-hook'."
10430 (when (memq gnus-current-article gnus-newsgroup-unreads)
10431 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10433 (defun gnus-summary-mark-region-as-read (point mark all)
10434 "Mark all unread articles between point and mark as read.
10435 If given a prefix, mark all articles between point and mark as read,
10436 even ticked and dormant ones."
10437 (interactive "r\nP")
10441 (beginning-of-line)
10446 (memq (setq article (gnus-summary-article-number))
10447 gnus-newsgroup-unreads))
10448 (gnus-summary-mark-article article gnus-del-mark))
10450 (gnus-summary-find-next))))))
10452 (defun gnus-summary-mark-below (score mark)
10453 "Mark articles with score less than SCORE with MARK."
10454 (interactive "P\ncMark: ")
10455 (setq score (if score
10456 (prefix-numeric-value score)
10457 (or gnus-summary-default-score 0)))
10459 (set-buffer gnus-summary-buffer)
10460 (goto-char (point-min))
10463 (and (< (gnus-summary-article-score) score)
10464 (gnus-summary-mark-article nil mark))
10465 (gnus-summary-find-next)))))
10467 (defun gnus-summary-kill-below (&optional score)
10468 "Mark articles with score below SCORE as read."
10470 (gnus-summary-mark-below score gnus-killed-mark))
10472 (defun gnus-summary-clear-above (&optional score)
10473 "Clear all marks from articles with score above SCORE."
10475 (gnus-summary-mark-above score gnus-unread-mark))
10477 (defun gnus-summary-tick-above (&optional score)
10478 "Tick all articles with score above SCORE."
10480 (gnus-summary-mark-above score gnus-ticked-mark))
10482 (defun gnus-summary-mark-above (score mark)
10483 "Mark articles with score over SCORE with MARK."
10484 (interactive "P\ncMark: ")
10485 (setq score (if score
10486 (prefix-numeric-value score)
10487 (or gnus-summary-default-score 0)))
10489 (set-buffer gnus-summary-buffer)
10490 (goto-char (point-min))
10492 (when (> (gnus-summary-article-score) score)
10493 (gnus-summary-mark-article nil mark))
10495 (gnus-summary-find-next)))))
10497 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10498 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10499 (defun gnus-summary-limit-include-expunged (&optional no-error)
10500 "Display all the hidden articles that were expunged for low scores."
10502 (let ((buffer-read-only nil))
10503 (let ((scored gnus-newsgroup-scored)
10506 (unless (gnus-summary-article-header (caar scored))
10507 (and (setq h (gnus-number-to-header (caar scored)))
10508 (< (cdar scored) gnus-summary-expunge-below)
10510 (setq scored (cdr scored)))
10512 (when (not no-error)
10513 (error "No expunged articles hidden"))
10514 (goto-char (point-min))
10515 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10516 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10517 (mapcar (lambda (x) (push (mail-header-number x)
10518 gnus-newsgroup-limit))
10520 (gnus-summary-prepare-unthreaded (nreverse headers))
10521 (goto-char (point-min))
10522 (gnus-summary-position-point)
10525 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10526 "Mark all unread articles in this newsgroup as read.
10527 If prefix argument ALL is non-nil, ticked and dormant articles will
10528 also be marked as read.
10529 If QUIETLY is non-nil, no questions will be asked.
10531 If TO-HERE is non-nil, it should be a point in the buffer. All
10532 articles before (after, if REVERSE is set) this point will be marked
10535 Note that this function will only catch up the unread article
10536 in the current summary buffer limitation.
10538 The number of articles marked as read is returned."
10543 (not gnus-interactive-catchup) ;Without confirmation?
10547 "Mark absolutely all articles as read? "
10548 "Mark all unread articles as read? ")))
10550 (not gnus-newsgroup-adaptive)
10551 (not gnus-newsgroup-auto-expire)
10552 (not gnus-suppress-duplicates)
10553 (or (not gnus-use-cache)
10554 (eq gnus-use-cache 'passive)))
10557 (setq gnus-newsgroup-marked nil
10558 gnus-newsgroup-spam-marked nil
10559 gnus-newsgroup-dormant nil))
10560 (setq gnus-newsgroup-unreads
10561 (gnus-sorted-nunion
10562 (gnus-intersection gnus-newsgroup-unreads
10563 gnus-newsgroup-downloadable)
10564 gnus-newsgroup-unfetched)))
10565 ;; We actually mark all articles as canceled, which we
10566 ;; have to do when using auto-expiry or adaptive scoring.
10567 (gnus-summary-show-all-threads)
10568 (if (and to-here reverse)
10570 (goto-char to-here)
10571 (gnus-summary-mark-current-read-and-unread-as-read
10573 (while (gnus-summary-find-next (not all))
10574 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10575 (when (gnus-summary-first-subject (not all))
10577 (if to-here (< (point) to-here) t)
10578 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10579 (gnus-summary-find-next (not all))))))
10580 (gnus-set-mode-line 'summary))
10582 (gnus-summary-position-point)))
10584 (defun gnus-summary-catchup-to-here (&optional all)
10585 "Mark all unticked articles before the current one as read.
10586 If ALL is non-nil, also mark ticked and dormant articles as read."
10589 (gnus-save-hidden-threads
10590 (let ((beg (point)))
10591 ;; We check that there are unread articles.
10592 (when (or all (gnus-summary-find-prev))
10593 (gnus-summary-catchup all t beg)))))
10594 (gnus-summary-position-point))
10596 (defun gnus-summary-catchup-from-here (&optional all)
10597 "Mark all unticked articles after (and including) the current one as read.
10598 If ALL is non-nil, also mark ticked and dormant articles as read."
10601 (gnus-save-hidden-threads
10602 (let ((beg (point)))
10603 ;; We check that there are unread articles.
10604 (when (or all (gnus-summary-find-next))
10605 (gnus-summary-catchup all t beg nil t)))))
10606 (gnus-summary-position-point))
10608 (defun gnus-summary-catchup-all (&optional quietly)
10609 "Mark all articles in this newsgroup as read.
10610 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10611 instead, which marks only unread articles as read."
10613 (gnus-summary-catchup t quietly))
10615 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10616 "Mark all unread articles in this group as read, then exit.
10617 If prefix argument ALL is non-nil, all articles are marked as read.
10618 If QUIETLY is non-nil, no questions will be asked."
10620 (when (gnus-summary-catchup all quietly nil 'fast)
10621 ;; Select next newsgroup or exit.
10622 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10623 (eq gnus-auto-select-next 'quietly))
10624 (gnus-summary-next-group nil)
10625 (gnus-summary-exit))))
10627 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10628 "Mark all articles in this newsgroup as read, and then exit.
10629 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10630 instead, which marks only unread articles as read."
10632 (gnus-summary-catchup-and-exit t quietly))
10634 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10635 "Mark all articles in this group as read and select the next group.
10636 If given a prefix, mark all articles, unread as well as ticked, as
10640 (gnus-summary-catchup all))
10641 (gnus-summary-next-group))
10647 (defmacro gnus-with-article (article &rest forms)
10648 "Select ARTICLE and perform FORMS in the original article buffer.
10649 Then replace the article with the result."
10651 ;; We don't want the article to be marked as read.
10652 (let (gnus-mark-article-hook)
10653 (gnus-summary-select-article t t nil ,article))
10654 (set-buffer gnus-original-article-buffer)
10656 (if (not (gnus-check-backend-function
10657 'request-replace-article (car gnus-article-current)))
10658 (gnus-message 5 "Read-only group; not replacing")
10659 (unless (gnus-request-replace-article
10660 ,article (car gnus-article-current)
10661 (current-buffer) t)
10662 (error "Couldn't replace article")))
10663 ;; The cache and backlog have to be flushed somewhat.
10664 (when gnus-keep-backlog
10665 (gnus-backlog-remove-article
10666 (car gnus-article-current) (cdr gnus-article-current)))
10667 (when gnus-use-cache
10668 (gnus-cache-update-article
10669 (car gnus-article-current) (cdr gnus-article-current)))))
10671 (put 'gnus-with-article 'lisp-indent-function 1)
10672 (put 'gnus-with-article 'edebug-form-spec '(form body))
10674 ;; Thread-based commands.
10676 (defun gnus-summary-articles-in-thread (&optional article)
10677 "Return a list of all articles in the current thread.
10678 If ARTICLE is non-nil, return all articles in the thread that starts
10679 with that article."
10680 (let* ((article (or article (gnus-summary-article-number)))
10681 (data (gnus-data-find-list article))
10682 (top-level (gnus-data-level (car data)))
10684 (cond ((null gnus-thread-operation-ignore-subject)
10685 (gnus-simplify-subject-re
10686 (mail-header-subject (gnus-data-header (car data)))))
10687 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10688 (gnus-simplify-subject-fuzzy
10689 (mail-header-subject (gnus-data-header (car data)))))
10691 (end-point (save-excursion
10692 (if (gnus-summary-go-to-next-thread)
10693 (point) (point-max))))
10696 (< (gnus-data-pos (car data)) end-point))
10697 (when (or (not top-subject)
10698 (string= top-subject
10699 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10700 (gnus-simplify-subject-fuzzy
10701 (mail-header-subject
10702 (gnus-data-header (car data))))
10703 (gnus-simplify-subject-re
10704 (mail-header-subject
10705 (gnus-data-header (car data)))))))
10706 (push (gnus-data-number (car data)) articles))
10707 (unless (and (setq data (cdr data))
10708 (> (gnus-data-level (car data)) top-level))
10710 ;; Return the list of articles.
10711 (nreverse articles)))
10713 (defun gnus-summary-rethread-current ()
10714 "Rethread the thread the current article is part of."
10716 (let* ((gnus-show-threads t)
10717 (article (gnus-summary-article-number))
10718 (id (mail-header-id (gnus-summary-article-header)))
10719 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10721 (error "No article on the current line"))
10722 (gnus-rebuild-thread id)
10723 (gnus-summary-goto-subject article)))
10725 (defun gnus-summary-reparent-thread ()
10726 "Make the current article child of the marked (or previous) article.
10728 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10729 is non-nil or the Subject: of both articles are the same."
10731 (unless (not (gnus-group-read-only-p))
10732 (error "The current newsgroup does not support article editing"))
10733 (unless (<= (length gnus-newsgroup-processable) 1)
10734 (error "No more than one article may be marked"))
10735 (save-window-excursion
10736 (let ((gnus-article-buffer " *reparent*")
10737 (current-article (gnus-summary-article-number))
10738 ;; First grab the marked article, otherwise one line up.
10739 (parent-article (if (not (null gnus-newsgroup-processable))
10740 (car gnus-newsgroup-processable)
10742 (if (eq (forward-line -1) 0)
10743 (gnus-summary-article-number)
10744 (error "Beginning of summary buffer"))))))
10745 (unless (not (eq current-article parent-article))
10746 (error "An article may not be self-referential"))
10747 (let ((message-id (mail-header-id
10748 (gnus-summary-article-header parent-article))))
10749 (unless (and message-id (not (equal message-id "")))
10750 (error "No message-id in desired parent"))
10751 (gnus-with-article current-article
10753 (goto-char (point-min))
10754 (message-narrow-to-head)
10755 (if (re-search-forward "^References: " nil t)
10757 (re-search-forward "^[^ \t]" nil t)
10760 (insert " " message-id))
10761 (insert "References: " message-id "\n"))))
10762 (set-buffer gnus-summary-buffer)
10763 (gnus-summary-unmark-all-processable)
10764 (gnus-summary-update-article current-article)
10765 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10766 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10767 (gnus-summary-rethread-current)
10768 (gnus-message 3 "Article %d is now the child of article %d"
10769 current-article parent-article)))))
10771 (defun gnus-summary-toggle-threads (&optional arg)
10772 "Toggle showing conversation threads.
10773 If ARG is positive number, turn showing conversation threads on."
10775 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10776 (setq gnus-show-threads
10777 (if (null arg) (not gnus-show-threads)
10778 (> (prefix-numeric-value arg) 0)))
10779 (gnus-summary-prepare)
10780 (gnus-summary-goto-subject current)
10781 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10782 (gnus-summary-position-point)))
10784 (defun gnus-summary-show-all-threads ()
10785 "Show all threads."
10788 (let ((buffer-read-only nil))
10789 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10790 (gnus-summary-position-point))
10792 (defun gnus-summary-show-thread ()
10793 "Show thread subtrees.
10794 Returns nil if no thread was there to be shown."
10796 (let ((buffer-read-only nil)
10798 (end (point-at-eol))
10799 ;; Leave point at bol
10800 (beg (progn (beginning-of-line) (point))))
10802 ;; Any hidden lines here?
10803 (search-forward "\r" end t)
10804 (subst-char-in-region beg end ?\^M ?\n t)
10806 (gnus-summary-position-point))))
10808 (defun gnus-summary-maybe-hide-threads ()
10809 "If requested, hide the threads that should be hidden."
10810 (when (and gnus-show-threads
10811 gnus-thread-hide-subtree)
10812 (gnus-summary-hide-all-threads
10813 (if (or (consp gnus-thread-hide-subtree)
10814 (functionp gnus-thread-hide-subtree))
10815 (gnus-make-predicate gnus-thread-hide-subtree)
10818 ;;; Hiding predicates.
10820 (defun gnus-article-unread-p (header)
10821 (memq (mail-header-number header) gnus-newsgroup-unreads))
10823 (defun gnus-article-unseen-p (header)
10824 (memq (mail-header-number header) gnus-newsgroup-unseen))
10826 (defun gnus-map-articles (predicate articles)
10827 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10828 (apply 'gnus-or (mapcar predicate
10829 (mapcar 'gnus-summary-article-header articles))))
10831 (defun gnus-summary-hide-all-threads (&optional predicate)
10832 "Hide all thread subtrees.
10833 If PREDICATE is supplied, threads that satisfy this predicate
10834 will not be hidden."
10837 (goto-char (point-min))
10840 (when (or (not predicate)
10842 predicate (gnus-summary-article-children)))
10843 (gnus-summary-hide-thread))
10844 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10845 (gnus-summary-position-point))
10847 (defun gnus-summary-hide-thread ()
10848 "Hide thread subtrees.
10849 If PREDICATE is supplied, threads that satisfy this predicate
10850 will not be hidden.
10851 Returns nil if no threads were there to be hidden."
10853 (let ((buffer-read-only nil)
10855 (article (gnus-summary-article-number)))
10857 ;; Go forward until either the buffer ends or the subthread
10859 (when (and (not (eobp))
10860 (or (zerop (gnus-summary-next-thread 1 t))
10861 (goto-char (point-max))))
10863 (if (and (> (point) start)
10864 (search-backward "\n" start t))
10866 (subst-char-in-region start (point) ?\n ?\^M)
10867 (gnus-summary-goto-subject article))
10871 (defun gnus-summary-go-to-next-thread (&optional previous)
10872 "Go to the same level (or less) next thread.
10873 If PREVIOUS is non-nil, go to previous thread instead.
10874 Return the article number moved to, or nil if moving was impossible."
10875 (let ((level (gnus-summary-thread-level))
10876 (way (if previous -1 1))
10879 (while (and (not (eobp))
10880 (< level (gnus-summary-thread-level)))
10881 (forward-line way))
10888 (gnus-summary-article-number)
10889 (goto-char beg)))))
10891 (defun gnus-summary-next-thread (n &optional silent)
10892 "Go to the same level next N'th thread.
10893 If N is negative, search backward instead.
10894 Returns the difference between N and the number of skips actually
10897 If SILENT, don't output messages."
10899 (let ((backward (< n 0))
10901 (while (and (> n 0)
10902 (gnus-summary-go-to-next-thread backward))
10905 (gnus-summary-position-point))
10906 (when (and (not silent) (/= 0 n))
10907 (gnus-message 7 "No more threads"))
10910 (defun gnus-summary-prev-thread (n)
10911 "Go to the same level previous N'th thread.
10912 Returns the difference between N and the number of skips actually
10915 (gnus-summary-next-thread (- n)))
10917 (defun gnus-summary-go-down-thread ()
10918 "Go down one level in the current thread."
10919 (let ((children (gnus-summary-article-children)))
10921 (gnus-summary-goto-subject (car children)))))
10923 (defun gnus-summary-go-up-thread ()
10924 "Go up one level in the current thread."
10925 (let ((parent (gnus-summary-article-parent)))
10927 (gnus-summary-goto-subject parent))))
10929 (defun gnus-summary-down-thread (n)
10930 "Go down thread N steps.
10931 If N is negative, go up instead.
10932 Returns the difference between N and how many steps down that were
10937 (while (and (> n 0)
10938 (if up (gnus-summary-go-up-thread)
10939 (gnus-summary-go-down-thread)))
10941 (gnus-summary-position-point)
10943 (gnus-message 7 "Can't go further"))
10946 (defun gnus-summary-up-thread (n)
10947 "Go up thread N steps.
10948 If N is negative, go down instead.
10949 Returns the difference between N and how many steps down that were
10952 (gnus-summary-down-thread (- n)))
10954 (defun gnus-summary-top-thread ()
10955 "Go to the top of the thread."
10957 (while (gnus-summary-go-up-thread))
10958 (gnus-summary-article-number))
10960 (defun gnus-summary-kill-thread (&optional unmark)
10961 "Mark articles under current thread as read.
10962 If the prefix argument is positive, remove any kinds of marks.
10963 If the prefix argument is negative, tick articles instead."
10966 (setq unmark (prefix-numeric-value unmark)))
10967 (let ((articles (gnus-summary-articles-in-thread)))
10969 ;; Expand the thread.
10970 (gnus-summary-show-thread)
10971 ;; Mark all the articles.
10973 (gnus-summary-goto-subject (car articles))
10974 (cond ((null unmark)
10975 (gnus-summary-mark-article-as-read gnus-killed-mark))
10977 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10979 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10980 (setq articles (cdr articles))))
10981 ;; Hide killed subtrees.
10983 gnus-thread-hide-killed
10984 (gnus-summary-hide-thread))
10985 ;; If marked as read, go to next unread subject.
10986 (when (null unmark)
10987 ;; Go to next unread subject.
10988 (gnus-summary-next-subject 1 t)))
10989 (gnus-set-mode-line 'summary))
10991 ;; Summary sorting commands
10993 (defun gnus-summary-sort-by-number (&optional reverse)
10994 "Sort the summary buffer by article number.
10995 Argument REVERSE means reverse order."
10997 (gnus-summary-sort 'number reverse))
10999 (defun gnus-summary-sort-by-random (&optional reverse)
11000 "Randomize the order in the summary buffer.
11001 Argument REVERSE means to randomize in reverse order."
11003 (gnus-summary-sort 'random reverse))
11005 (defun gnus-summary-sort-by-author (&optional reverse)
11006 "Sort the summary buffer by author name alphabetically.
11007 If `case-fold-search' is non-nil, case of letters is ignored.
11008 Argument REVERSE means reverse order."
11010 (gnus-summary-sort 'author reverse))
11012 (defun gnus-summary-sort-by-recipient (&optional reverse)
11013 "Sort the summary buffer by recipient name alphabetically.
11014 If `case-fold-search' is non-nil, case of letters is ignored.
11015 Argument REVERSE means reverse order."
11017 (gnus-summary-sort 'recipient reverse))
11019 (defun gnus-summary-sort-by-subject (&optional reverse)
11020 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11021 If `case-fold-search' is non-nil, case of letters is ignored.
11022 Argument REVERSE means reverse order."
11024 (gnus-summary-sort 'subject reverse))
11026 (defun gnus-summary-sort-by-date (&optional reverse)
11027 "Sort the summary buffer by date.
11028 Argument REVERSE means reverse order."
11030 (gnus-summary-sort 'date reverse))
11032 (defun gnus-summary-sort-by-score (&optional reverse)
11033 "Sort the summary buffer by score.
11034 Argument REVERSE means reverse order."
11036 (gnus-summary-sort 'score reverse))
11038 (defun gnus-summary-sort-by-lines (&optional reverse)
11039 "Sort the summary buffer by the number of lines.
11040 Argument REVERSE means reverse order."
11042 (gnus-summary-sort 'lines reverse))
11044 (defun gnus-summary-sort-by-chars (&optional reverse)
11045 "Sort the summary buffer by article length.
11046 Argument REVERSE means reverse order."
11048 (gnus-summary-sort 'chars reverse))
11050 (defun gnus-summary-sort-by-original (&optional reverse)
11051 "Sort the summary buffer using the default sorting method.
11052 Argument REVERSE means reverse order."
11054 (let* ((buffer-read-only)
11055 (gnus-summary-prepare-hook nil))
11056 ;; We do the sorting by regenerating the threads.
11057 (gnus-summary-prepare)
11058 ;; Hide subthreads if needed.
11059 (gnus-summary-maybe-hide-threads)))
11061 (defun gnus-summary-sort (predicate reverse)
11062 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11063 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11064 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11065 (gnus-thread-sort-functions
11070 (gnus-sort-gathered-threads-function
11071 gnus-thread-sort-functions)
11072 (gnus-article-sort-functions
11076 (,article t2 t1))))
11078 (gnus-summary-prepare-hook nil))
11079 ;; We do the sorting by regenerating the threads.
11080 (gnus-summary-prepare)
11081 ;; Hide subthreads if needed.
11082 (gnus-summary-maybe-hide-threads)))
11084 ;; Summary saving commands.
11086 (defun gnus-summary-save-article (&optional n not-saved)
11087 "Save the current article using the default saver function.
11088 If N is a positive number, save the N next articles.
11089 If N is a negative number, save the N previous articles.
11090 If N is nil and any articles have been marked with the process mark,
11091 save those articles instead.
11092 The variable `gnus-default-article-saver' specifies the saver function."
11094 (let* ((articles (gnus-summary-work-articles n))
11095 (save-buffer (save-excursion
11096 (nnheader-set-temp-buffer " *Gnus Save*")))
11097 (num (length articles))
11099 (dolist (article articles)
11100 (setq header (gnus-summary-article-header article))
11101 (if (not (vectorp header))
11102 ;; This is a pseudo-article.
11103 (if (assq 'name header)
11104 (gnus-copy-file (cdr (assq 'name header)))
11105 (gnus-message 1 "Article %d is unsaveable" article))
11106 ;; This is a real article.
11107 (save-window-excursion
11108 (let ((gnus-display-mime-function nil)
11109 (gnus-article-prepare-hook nil))
11110 (gnus-summary-select-article t nil nil article)))
11112 (set-buffer save-buffer)
11114 (insert-buffer-substring gnus-original-article-buffer))
11115 (setq file (gnus-article-save save-buffer file num))
11116 (gnus-summary-remove-process-mark article)
11118 (gnus-summary-set-saved-mark article))))
11119 (gnus-kill-buffer save-buffer)
11120 (gnus-summary-position-point)
11121 (gnus-set-mode-line 'summary)
11124 (defun gnus-summary-pipe-output (&optional arg headers)
11125 "Pipe the current article to a subprocess.
11126 If N is a positive number, pipe the N next articles.
11127 If N is a negative number, pipe the N previous articles.
11128 If N is nil and any articles have been marked with the process mark,
11129 pipe those articles instead.
11130 If HEADERS (the symbolic prefix), include the headers, too."
11131 (interactive (gnus-interactive "P\ny"))
11132 (require 'gnus-art)
11133 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11134 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11135 (gnus-summary-save-article arg t))
11136 (let ((buffer (get-buffer "*Shell Command Output*")))
11138 (not (zerop (buffer-size buffer))))
11139 (gnus-configure-windows 'pipe))))
11141 (defun gnus-summary-save-article-mail (&optional arg)
11142 "Append the current article to an mail file.
11143 If N is a positive number, save the N next articles.
11144 If N is a negative number, save the N previous articles.
11145 If N is nil and any articles have been marked with the process mark,
11146 save those articles instead."
11148 (require 'gnus-art)
11149 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11150 (gnus-summary-save-article arg)))
11152 (defun gnus-summary-save-article-rmail (&optional arg)
11153 "Append the current article to an rmail file.
11154 If N is a positive number, save the N next articles.
11155 If N is a negative number, save the N previous articles.
11156 If N is nil and any articles have been marked with the process mark,
11157 save those articles instead."
11159 (require 'gnus-art)
11160 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11161 (gnus-summary-save-article arg)))
11163 (defun gnus-summary-save-article-file (&optional arg)
11164 "Append the current article to a file.
11165 If N is a positive number, save the N next articles.
11166 If N is a negative number, save the N previous articles.
11167 If N is nil and any articles have been marked with the process mark,
11168 save those articles instead."
11170 (require 'gnus-art)
11171 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11172 (gnus-summary-save-article arg)))
11174 (defun gnus-summary-write-article-file (&optional arg)
11175 "Write the current article to a file, deleting the previous file.
11176 If N is a positive number, save the N next articles.
11177 If N is a negative number, save the N previous articles.
11178 If N is nil and any articles have been marked with the process mark,
11179 save those articles instead."
11181 (require 'gnus-art)
11182 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11183 (gnus-summary-save-article arg)))
11185 (defun gnus-summary-save-article-body-file (&optional arg)
11186 "Append the current article body to a file.
11187 If N is a positive number, save the N next articles.
11188 If N is a negative number, save the N previous articles.
11189 If N is nil and any articles have been marked with the process mark,
11190 save those articles instead."
11192 (require 'gnus-art)
11193 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11194 (gnus-summary-save-article arg)))
11196 (defun gnus-summary-muttprint (&optional arg)
11197 "Print the current article using Muttprint.
11198 If N is a positive number, save the N next articles.
11199 If N is a negative number, save the N previous articles.
11200 If N is nil and any articles have been marked with the process mark,
11201 save those articles instead."
11203 (require 'gnus-art)
11204 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11205 (gnus-summary-save-article arg t)))
11207 (defun gnus-summary-pipe-message (program)
11208 "Pipe the current article through PROGRAM."
11209 (interactive "sProgram: ")
11210 (gnus-summary-select-article)
11211 (let ((mail-header-separator ""))
11212 (gnus-eval-in-buffer-window gnus-article-buffer
11215 (let ((start (window-start))
11217 (message-pipe-buffer-body program)
11218 (set-window-start (get-buffer-window (current-buffer)) start))))))
11220 (defun gnus-get-split-value (methods)
11221 "Return a value based on the split METHODS."
11222 (let (split-name method result match)
11225 (set-buffer gnus-original-article-buffer)
11227 (nnheader-narrow-to-headers)
11228 (while (and methods (not split-name))
11229 (goto-char (point-min))
11230 (setq method (pop methods))
11231 (setq match (car method))
11234 ;; Regular expression.
11236 (re-search-forward match nil t)))
11241 (setq result (funcall match gnus-newsgroup-name))))
11246 (setq result (eval match)))))
11247 (setq split-name (cdr method))
11248 (cond ((stringp result)
11249 (push (expand-file-name
11250 result gnus-article-save-directory)
11253 (setq split-name (append result split-name)))))))))
11254 (nreverse split-name)))
11256 (defun gnus-valid-move-group-p (group)
11257 (and (boundp group)
11258 (symbol-name group)
11259 (symbol-value group)
11260 (gnus-get-function (gnus-find-method-for-group
11261 (symbol-name group)) 'request-accept-article t)))
11263 (defun gnus-read-move-group-name (prompt default articles prefix)
11264 "Read a group name."
11265 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11266 (minibuffer-confirm-incomplete nil) ; XEmacs
11268 (format "%s %s to:"
11270 (if (> (length articles) 1)
11271 (format "these %d articles" (length articles))
11276 (gnus-completing-read-with-default
11279 'gnus-valid-move-group-p
11281 'gnus-group-history))
11282 ((= 1 (length split-name))
11283 (gnus-completing-read-with-default
11284 (car split-name) prom
11286 'gnus-valid-move-group-p
11288 'gnus-group-history))
11290 (gnus-completing-read-with-default
11292 (mapcar 'list (nreverse split-name))
11294 'gnus-group-history))))
11295 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11297 (if (or (string= to-newsgroup "")
11298 (string= to-newsgroup prefix))
11299 (setq to-newsgroup default))
11300 (unless to-newsgroup
11301 (error "No group name entered"))
11302 (or (gnus-active to-newsgroup)
11303 (gnus-activate-group to-newsgroup nil nil to-method)
11304 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11306 (or (and (gnus-request-create-group to-newsgroup to-method)
11307 (gnus-activate-group
11308 to-newsgroup nil nil to-method)
11309 (gnus-subscribe-group to-newsgroup))
11310 (error "Couldn't create group %s" to-newsgroup)))
11311 (error "No such group: %s" to-newsgroup)))
11314 (defun gnus-summary-save-parts (type dir n &optional reverse)
11315 "Save parts matching TYPE to DIR.
11316 If REVERSE, save parts that do not match TYPE."
11318 (list (read-string "Save parts of type: "
11319 (or (car gnus-summary-save-parts-type-history)
11320 gnus-summary-save-parts-default-mime)
11321 'gnus-summary-save-parts-type-history)
11322 (setq gnus-summary-save-parts-last-directory
11323 (read-file-name "Save to directory: "
11324 gnus-summary-save-parts-last-directory
11326 current-prefix-arg))
11327 (gnus-summary-iterate n
11328 (let ((gnus-display-mime-function nil)
11329 (gnus-inhibit-treatment t))
11330 (gnus-summary-select-article))
11332 (set-buffer gnus-article-buffer)
11333 (let ((handles (or gnus-article-mime-handles
11334 (mm-dissect-buffer nil gnus-article-loose-mime)
11335 (and gnus-article-emulate-mime
11336 (mm-uu-dissect)))))
11338 (gnus-summary-save-parts-1 type dir handles reverse)
11339 (unless gnus-article-mime-handles ;; Don't destroy this case.
11340 (mm-destroy-parts handles)))))))
11342 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11343 (if (stringp (car handle))
11344 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11347 (not (string-match type (mm-handle-media-type handle)))
11348 (string-match type (mm-handle-media-type handle)))
11349 (let ((file (expand-file-name
11351 mm-file-name-rewrite-functions
11352 (file-name-nondirectory
11354 (mail-content-type-get
11355 (mm-handle-disposition handle) 'filename)
11356 (mail-content-type-get
11357 (mm-handle-type handle) 'name)
11358 (concat gnus-newsgroup-name
11359 "." (number-to-string
11360 (cdr gnus-article-current))))))
11362 (unless (file-exists-p file)
11363 (mm-save-part-to-file handle file))))))
11365 ;; Summary extract commands
11367 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11368 (let ((buffer-read-only nil)
11369 (article (gnus-summary-article-number))
11371 (unless (gnus-summary-goto-subject article)
11372 (error "No such article: %d" article))
11373 (gnus-summary-position-point)
11374 ;; If all commands are to be bunched up on one line, we collect
11376 (unless gnus-view-pseudos-separately
11377 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11380 (setq action (cdr (assq 'action (car ps))))
11381 (setq files (list (cdr (assq 'name (car ps)))))
11382 (while (and ps (cdr ps)
11383 (string= (or action "1")
11384 (or (cdr (assq 'action (cadr ps))) "2")))
11385 (push (cdr (assq 'name (cadr ps))) files)
11386 (setcdr ps (cddr ps)))
11388 (when (not (string-match "%s" action))
11391 (when (assq 'execute (car ps))
11392 (setcdr (assq 'execute (car ps))
11393 (funcall (if (string-match "%s" action)
11400 (shell-quote-argument f)))
11402 (setq ps (cdr ps)))))
11403 (if (and gnus-view-pseudos (not not-view))
11405 (when (assq 'execute (car pslist))
11406 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11407 (eq gnus-view-pseudos 'not-confirm)))
11408 (setq pslist (cdr pslist)))
11411 (setq after-article (or (cdr (assq 'article (car pslist)))
11412 (gnus-summary-article-number)))
11413 (gnus-summary-goto-subject after-article)
11416 (insert " " (file-name-nondirectory
11417 (cdr (assq 'name (car pslist))))
11418 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11420 (forward-line -1) ; back to `b'
11421 (gnus-add-text-properties
11422 b (1- e) (list 'gnus-number gnus-reffed-article-number
11423 gnus-mouse-face-prop gnus-mouse-face))
11425 after-article gnus-reffed-article-number
11426 gnus-unread-mark b (car pslist) 0 (- e b))
11427 (setq gnus-newsgroup-unreads
11428 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11429 gnus-reffed-article-number))
11430 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11431 (setq pslist (cdr pslist)))))))
11433 (defun gnus-pseudos< (p1 p2)
11434 (let ((c1 (cdr (assq 'action p1)))
11435 (c2 (cdr (assq 'action p2))))
11436 (and c1 c2 (string< c1 c2))))
11438 (defun gnus-request-pseudo-article (props)
11439 (cond ((assq 'execute props)
11440 (gnus-execute-command (cdr (assq 'execute props)))))
11441 (let ((gnus-current-article (gnus-summary-article-number)))
11442 (gnus-run-hooks 'gnus-mark-article-hook)))
11444 (defun gnus-execute-command (command &optional automatic)
11446 (gnus-article-setup-buffer)
11447 (set-buffer gnus-article-buffer)
11448 (setq buffer-read-only nil)
11449 (let ((command (if automatic command
11450 (read-string "Command: " (cons command 0)))))
11452 (insert "$ " command "\n\n")
11453 (if gnus-view-pseudo-asynchronously
11454 (start-process "gnus-execute" (current-buffer) shell-file-name
11455 shell-command-switch command)
11456 (call-process shell-file-name nil t nil
11457 shell-command-switch command)))))
11459 ;; Summary kill commands.
11461 (defun gnus-summary-edit-global-kill (article)
11462 "Edit the \"global\" kill file."
11463 (interactive (list (gnus-summary-article-number)))
11464 (gnus-group-edit-global-kill article))
11466 (defun gnus-summary-edit-local-kill ()
11467 "Edit a local kill file applied to the current newsgroup."
11469 (setq gnus-current-headers (gnus-summary-article-header))
11470 (gnus-group-edit-local-kill
11471 (gnus-summary-article-number) gnus-newsgroup-name))
11473 ;;; Header reading.
11475 (defun gnus-read-header (id &optional header)
11476 "Read the headers of article ID and enter them into the Gnus system."
11477 (let ((group gnus-newsgroup-name)
11478 (gnus-override-method
11480 gnus-override-method
11481 (and (gnus-news-group-p gnus-newsgroup-name)
11482 (car (gnus-refer-article-methods)))))
11484 ;; First we check to see whether the header in question is already
11487 ;; This is a Message-ID.
11488 (setq header (or header (gnus-id-to-header id)))
11489 ;; This is an article number.
11490 (setq header (or header (gnus-summary-article-header id))))
11492 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11493 ;; We have found the header.
11495 ;; We have to really fetch the header to this article.
11497 (set-buffer nntp-server-buffer)
11498 (when (setq where (gnus-request-head id group))
11499 (nnheader-fold-continuation-lines)
11500 (goto-char (point-max))
11502 (goto-char (point-min))
11506 ((cdr where) (cdr where))
11507 (header (mail-header-number header))
11508 (t gnus-reffed-article-number))
11510 (insert " Article retrieved.\n"))
11511 (if (or (not where)
11512 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11513 () ; Malformed head.
11514 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11515 (when (and (stringp id)
11516 (not (string= (gnus-group-real-name group)
11518 ;; If we fetched by Message-ID and the article came
11519 ;; from a different group, we fudge some bogus article
11520 ;; numbers for this article.
11521 (mail-header-set-number header gnus-reffed-article-number))
11523 (set-buffer gnus-summary-buffer)
11524 (decf gnus-reffed-article-number)
11525 (gnus-remove-header (mail-header-number header))
11526 (push header gnus-newsgroup-headers)
11527 (setq gnus-current-headers header)
11528 (push (mail-header-number header) gnus-newsgroup-limit)))
11531 (defun gnus-remove-header (number)
11532 "Remove header NUMBER from `gnus-newsgroup-headers'."
11533 (if (and gnus-newsgroup-headers
11534 (= number (mail-header-number (car gnus-newsgroup-headers))))
11535 (pop gnus-newsgroup-headers)
11536 (let ((headers gnus-newsgroup-headers))
11537 (while (and (cdr headers)
11538 (not (= number (mail-header-number (cadr headers)))))
11540 (when (cdr headers)
11541 (setcdr headers (cddr headers))))))
11544 ;;; summary highlights
11547 (defun gnus-highlight-selected-summary ()
11548 "Highlight selected article in summary buffer."
11549 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11550 (when gnus-summary-selected-face
11552 (let* ((beg (point-at-bol))
11553 (end (point-at-eol))
11554 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11555 (from (if (get-text-property beg gnus-mouse-face-prop)
11557 (or (next-single-property-change
11558 beg gnus-mouse-face-prop nil end)
11563 (or (next-single-property-change
11564 from gnus-mouse-face-prop nil end)
11566 ;; If no mouse-face prop on line we will have to = from = end,
11567 ;; so we highlight the entire line instead.
11568 (when (= (+ to 2) from)
11571 (if gnus-newsgroup-selected-overlay
11572 ;; Move old overlay.
11574 gnus-newsgroup-selected-overlay from to (current-buffer))
11575 ;; Create new overlay.
11577 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11578 'face gnus-summary-selected-face))))))
11580 (defvar gnus-summary-highlight-line-cached nil)
11581 (defvar gnus-summary-highlight-line-trigger nil)
11583 (defun gnus-summary-highlight-line-0 ()
11584 (if (and (eq gnus-summary-highlight-line-trigger
11585 gnus-summary-highlight)
11586 gnus-summary-highlight-line-cached)
11587 gnus-summary-highlight-line-cached
11588 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11589 gnus-summary-highlight-line-cached
11590 (let* ((cond (list 'cond))
11592 (list gnus-summary-highlight))
11594 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11598 (gnus-byte-compile (list 'lambda nil cond))))))
11600 (defun gnus-summary-highlight-line ()
11601 "Highlight current line according to `gnus-summary-highlight'."
11602 (let* ((beg (point-at-bol))
11603 (article (or (gnus-summary-article-number) gnus-current-article))
11604 (score (or (cdr (assq article
11605 gnus-newsgroup-scored))
11606 gnus-summary-default-score 0))
11607 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11608 (inhibit-read-only t)
11609 (default gnus-summary-default-score)
11610 (default-high gnus-summary-default-high-score)
11611 (default-low gnus-summary-default-low-score)
11612 (uncached (and gnus-summary-use-undownloaded-faces
11613 (memq article gnus-newsgroup-undownloaded)
11614 (not (memq article gnus-newsgroup-cached)))))
11615 (let ((face (funcall (gnus-summary-highlight-line-0))))
11616 (unless (eq face (get-text-property beg 'face))
11617 (gnus-put-text-property-excluding-characters-with-faces
11618 beg (point-at-eol) 'face
11619 (setq face (if (boundp face) (symbol-value face) face)))
11620 (when gnus-summary-highlight-line-function
11621 (funcall gnus-summary-highlight-line-function article face))))))
11623 (defun gnus-update-read-articles (group unread &optional compute)
11624 "Update the list of read articles in GROUP.
11625 UNREAD is a sorted list."
11626 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11627 (info (gnus-get-info group))
11630 (if (or (not info) (not active))
11631 ;; There is no info on this group if it was, in fact,
11632 ;; killed. Gnus stores no information on killed groups, so
11633 ;; there's nothing to be done.
11634 ;; One could store the information somewhere temporarily,
11635 ;; perhaps... Hmmm...
11637 ;; Remove any negative articles numbers.
11638 (while (and unread (< (car unread) 0))
11639 (setq unread (cdr unread)))
11640 ;; Remove any expired article numbers
11641 (while (and unread (< (car unread) (car active)))
11642 (setq unread (cdr unread)))
11643 ;; Compute the ranges of read articles by looking at the list of
11644 ;; unread articles.
11646 (when (/= (car unread) prev)
11647 (push (if (= prev (1- (car unread))) prev
11648 (cons prev (1- (car unread))))
11650 (setq prev (1+ (car unread)))
11651 (setq unread (cdr unread)))
11652 (when (<= prev (cdr active))
11653 (push (cons prev (cdr active)) read))
11654 (setq read (if (> (length read) 1) (nreverse read) read))
11659 ;; Propagate the read marks to the backend.
11660 (when (gnus-check-backend-function 'request-set-mark group)
11661 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11662 (add (gnus-remove-from-range read (gnus-info-read info))))
11664 (unless (gnus-check-group group)
11665 (error "Can't open server for %s" group))
11666 (gnus-request-set-mark
11667 group (delq nil (list (if add (list add 'add '(read)))
11668 (if del (list del 'del '(read))))))
11670 `(gnus-request-set-mark
11673 (if del (list del 'add '(read)))
11674 (if add (list add 'del '(read))))))))))
11675 (set-buffer gnus-group-buffer)
11676 (gnus-undo-register
11678 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11679 (gnus-info-set-read ',info ',(gnus-info-read info))
11680 (gnus-get-unread-articles-in-group ',info
11681 (gnus-active ,group))
11682 (gnus-group-update-group ,group t)
11684 ;; Enter this list into the group info.
11685 (gnus-info-set-read info read)
11686 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11687 (gnus-get-unread-articles-in-group info (gnus-active group))
11690 (defun gnus-offer-save-summaries ()
11691 "Offer to save all active summary buffers."
11693 ;; Go through all buffers and find all summaries.
11694 (dolist (buffer (buffer-list))
11695 (when (and (setq buffer (buffer-name buffer))
11696 (string-match "Summary" buffer)
11697 (with-current-buffer buffer
11698 ;; We check that this is, indeed, a summary buffer.
11699 (and (eq major-mode 'gnus-summary-mode)
11700 ;; Also make sure this isn't bogus.
11701 gnus-newsgroup-prepared
11702 ;; Also make sure that this isn't a
11703 ;; dead summary buffer.
11704 (not gnus-dead-summary-mode))))
11705 (push buffer buffers)))
11706 ;; Go through all these summary buffers and offer to save them.
11710 "Update summary buffer %s? "
11712 (switch-to-buffer buf)
11713 (gnus-summary-exit))
11717 ;;; @ for mime-partial
11720 (defun gnus-request-partial-message ()
11722 (let ((number (gnus-summary-article-number))
11723 (group gnus-newsgroup-name)
11724 (mother gnus-article-buffer))
11725 (set-buffer (get-buffer-create " *Partial Article*"))
11727 (setq mime-preview-buffer mother)
11728 (gnus-request-article-this-buffer number group)
11729 (mime-parse-buffer)
11732 (autoload 'mime-combine-message/partial-pieces-automatically
11734 "Internal method to combine message/partial messages automatically.")
11736 (mime-add-condition
11737 'action '((type . message)(subtype . partial)
11738 (major-mode . gnus-original-article-mode)
11739 (method . mime-combine-message/partial-pieces-automatically)
11740 (summary-buffer-exp . gnus-summary-buffer)
11741 (request-partial-message-method . gnus-request-partial-message)
11745 ;;; @ for message/rfc822
11748 (defun gnus-mime-extract-message/rfc822 (entity situation)
11749 "Burst a forwarded article."
11751 (set-buffer gnus-summary-buffer)
11752 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11753 gnus-newsgroup-name 'gnus-group-history))
11754 (gnus-group-marked (list group))
11757 (mime-insert-entity-content entity)
11758 (setq article (gnus-request-accept-article group)))
11759 (when (and (consp article)
11760 (numberp (setq article (cdr article))))
11761 (setq info (gnus-get-info group))
11762 (gnus-info-set-read info
11763 (gnus-remove-from-range (gnus-info-read info)
11765 (when (string-equal group gnus-newsgroup-name)
11767 (let (gnus-show-threads)
11768 (gnus-summary-goto-subject article t))
11769 (gnus-summary-clear-mark-forward 1))
11770 (set-buffer gnus-group-buffer)
11771 (gnus-group-get-new-news-this-group nil t)))))
11773 (mime-add-condition
11774 'action '((type . message)(subtype . rfc822)
11775 (major-mode . gnus-original-article-mode)
11776 (method . gnus-mime-extract-message/rfc822)
11780 (mime-add-condition
11781 'action '((type . message)(subtype . news)
11782 (major-mode . gnus-original-article-mode)
11783 (method . gnus-mime-extract-message/rfc822)
11787 (defun gnus-mime-extract-multipart (entity situation)
11788 (let ((children (mime-entity-children entity))
11789 mime-acting-situation-to-override
11792 (mime-play-entity (car children)
11793 (cons (assq 'mode situation)
11794 mime-acting-situation-to-override))
11795 (setq children (cdr children)))
11796 (if (setq f (cdr (assq 'after-method
11797 mime-acting-situation-to-override)))
11801 (mime-add-condition
11802 'action '((type . multipart)
11803 (method . gnus-mime-extract-multipart)
11812 (defun gnus-summary-inherit-default-charset ()
11813 "Import `default-mime-charset' from summary buffer.
11814 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11816 (if (buffer-live-p gnus-summary-buffer)
11817 (let (d-m-c d-m-c-u)
11818 (with-current-buffer gnus-summary-buffer
11819 (setq d-m-c (if (local-variable-p 'default-mime-charset
11820 gnus-summary-buffer)
11821 default-mime-charset
11824 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11825 gnus-summary-buffer)
11826 (symbol-value 'default-mime-charset-unlimited)
11829 (kill-local-variable 'default-mime-charset)
11830 (set (make-local-variable 'default-mime-charset) d-m-c))
11832 (kill-local-variable 'default-mime-charset-unlimited)
11833 (set (make-local-variable 'default-mime-charset-unlimited)
11836 (defun gnus-summary-setup-default-charset ()
11837 "Setup newsgroup default charset."
11838 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11840 (setq gnus-newsgroup-charset nil)
11841 (set (make-local-variable 'default-mime-charset) nil)
11842 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11843 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11844 (let ((ignored-charsets
11845 (or gnus-newsgroup-ephemeral-ignored-charsets
11847 (and gnus-newsgroup-name
11848 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11849 gnus-newsgroup-ignored-charsets)))
11851 (setq gnus-newsgroup-charset
11852 (or gnus-newsgroup-ephemeral-charset
11853 (when (and gnus-newsgroup-name
11854 (setq charset (gnus-parameter-charset
11855 gnus-newsgroup-name)))
11856 (make-local-variable 'default-mime-charset)
11857 (setq default-mime-charset charset))
11858 gnus-default-charset))
11859 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11860 ignored-charsets))))
11866 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11867 "Display the current article buffer fully MIME-buttonized.
11868 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11869 treated as multipart/mixed."
11871 (require 'gnus-art)
11872 (let ((gnus-unbuttonized-mime-types nil)
11873 (gnus-mime-display-multipart-as-mixed show-all-parts))
11874 (gnus-summary-show-article)))
11876 (defun gnus-summary-repair-multipart (article)
11877 "Add a Content-Type header to a multipart article without one."
11878 (interactive (list (gnus-summary-article-number)))
11879 (gnus-with-article article
11880 (message-narrow-to-head)
11881 (message-remove-header "Mime-Version")
11882 (goto-char (point-max))
11883 (insert "Mime-Version: 1.0\n")
11885 (when (search-forward "\n--" nil t)
11886 (let ((separator (buffer-substring (point) (point-at-eol))))
11887 (message-narrow-to-head)
11888 (message-remove-header "Content-Type")
11889 (goto-char (point-max))
11890 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11893 (let (gnus-mark-article-hook)
11894 (gnus-summary-select-article t t nil article)))
11896 (defun gnus-summary-toggle-display-buttonized ()
11897 "Toggle the buttonizing of the article buffer."
11899 (require 'gnus-art)
11900 (if (setq gnus-inhibit-mime-unbuttonizing
11901 (not gnus-inhibit-mime-unbuttonizing))
11902 (let ((gnus-unbuttonized-mime-types nil))
11903 (gnus-summary-show-article))
11904 (gnus-summary-show-article)))
11907 ;;; Intelli-mouse commmands
11910 (defun gnus-wheel-summary-scroll (event)
11912 (let ((amount (if (memq 'shift (event-modifiers event))
11913 (car gnus-wheel-scroll-amount)
11914 (cdr gnus-wheel-scroll-amount)))
11915 (direction (- (* (static-if (featurep 'xemacs)
11916 (event-button event)
11917 (cond ((eq 'mouse-4 (event-basic-type event))
11919 ((eq 'mouse-5 (event-basic-type event))
11923 (gnus-summary-scroll-up (* amount direction))
11924 (when (gnus-eval-in-buffer-window gnus-article-buffer
11927 (and (if (< 0 direction)
11928 (gnus-article-next-page 0)
11929 (gnus-article-prev-page 0)
11931 (if (setq edge (get-text-property
11932 (point-min) 'gnus-wheel-edge))
11933 (setq edge (* edge direction))
11936 (let ((buffer-read-only nil)
11937 (inhibit-read-only t))
11938 (put-text-property (point-min) (point-max)
11939 'gnus-wheel-edge direction)
11941 (or (> edge gnus-wheel-edge-resistance)
11942 (let ((buffer-read-only nil)
11943 (inhibit-read-only t))
11944 (put-text-property (point-min) (point-max)
11946 (* (1+ edge) direction))
11948 (eq last-command 'gnus-wheel-summary-scroll))))
11949 (gnus-summary-next-article nil nil (minusp direction)))))
11951 (defun gnus-wheel-install ()
11952 "Enable mouse wheel support on summary window."
11953 (when gnus-use-wheel
11955 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11957 (define-key gnus-summary-mode-map key
11958 'gnus-wheel-summary-scroll)))))
11960 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11963 ;;; Traditional PGP commmands
11966 (defun gnus-summary-decrypt-article (&optional force)
11967 "Decrypt the current article in traditional PGP way.
11968 This will have permanent effect only in mail groups.
11969 If FORCE is non-nil, allow editing of articles even in read-only
11972 (gnus-summary-select-article t)
11973 (gnus-eval-in-buffer-window gnus-article-buffer
11977 (goto-char (point-min))
11978 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11979 (error "Not a traditional PGP message!"))
11980 (let ((armor-start (match-beginning 0)))
11981 (if (and (pgg-decrypt-region armor-start (point-max))
11982 (or force (not (gnus-group-read-only-p))))
11983 (let ((inhibit-read-only t)
11985 (delete-region armor-start
11987 (re-search-forward "^-+END PGP" nil t)
11988 (beginning-of-line 2)
11990 (insert-buffer-substring pgg-output-buffer))))))))
11992 (defun gnus-summary-verify-article ()
11993 "Verify the current article in traditional PGP way."
11996 (set-buffer gnus-original-article-buffer)
11997 (goto-char (point-min))
11998 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11999 (error "Not a traditional PGP message!"))
12000 (re-search-forward "^-+END PGP" nil t)
12001 (beginning-of-line 2)
12002 (call-interactively (function pgg-verify-region))))
12005 ;;; Generic summary marking commands
12008 (defvar gnus-summary-marking-alist
12009 '((read gnus-del-mark "d")
12010 (unread gnus-unread-mark "u")
12011 (ticked gnus-ticked-mark "!")
12012 (dormant gnus-dormant-mark "?")
12013 (expirable gnus-expirable-mark "e"))
12014 "An alist of names/marks/keystrokes.")
12016 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12017 (defvar gnus-summary-mark-map)
12019 (defun gnus-summary-make-all-marking-commands ()
12020 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12021 (dolist (elem gnus-summary-marking-alist)
12022 (apply 'gnus-summary-make-marking-command elem)))
12024 (defun gnus-summary-make-marking-command (name mark keystroke)
12025 (let ((map (make-sparse-keymap)))
12026 (define-key gnus-summary-generic-mark-map keystroke map)
12027 (dolist (lway `((next "next" next nil "n")
12028 (next-unread "next unread" next t "N")
12029 (prev "previous" prev nil "p")
12030 (prev-unread "previous unread" prev t "P")
12031 (nomove "" nil nil ,keystroke)))
12032 (let ((func (gnus-summary-make-marking-command-1
12033 mark (car lway) lway name)))
12034 (setq func (eval func))
12035 (define-key map (nth 4 lway) func)))))
12037 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12039 (format "gnus-summary-put-mark-as-%s%s"
12040 name (if (eq way 'nomove)
12042 (concat "-" (symbol-name way)))))
12045 "Mark the current article as %s%s.
12046 If N, the prefix, then repeat N times.
12047 If N is negative, move in reverse order.
12048 The difference between N and the actual number of articles marked is
12050 name (car (cdr lway)))
12052 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12054 (defun gnus-summary-generic-mark (n mark move unread)
12055 "Mark N articles with MARK."
12056 (unless (eq major-mode 'gnus-summary-mode)
12057 (error "This command can only be used in the summary buffer"))
12058 (gnus-summary-show-thread)
12061 ((eq move 'next) 1)
12062 ((eq move 'prev) -1)
12064 (if (zerop nummove)
12068 nummove (* -1 nummove))))
12069 (while (and (> n 0)
12070 (gnus-summary-mark-article nil mark)
12071 (zerop (gnus-summary-next-subject nummove unread t)))
12074 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12075 (gnus-summary-recenter)
12076 (gnus-summary-position-point)
12077 (gnus-set-mode-line 'summary)
12080 (defun gnus-summary-insert-articles (articles)
12081 (when (setq articles
12082 (gnus-sorted-difference articles
12083 (mapcar (lambda (h)
12084 (mail-header-number h))
12085 gnus-newsgroup-headers)))
12086 (setq gnus-newsgroup-headers
12088 gnus-newsgroup-headers
12089 (gnus-fetch-headers articles)
12090 'gnus-article-sort-by-number))
12091 ;; Suppress duplicates?
12092 (when gnus-suppress-duplicates
12093 (gnus-dup-suppress-articles))
12095 ;; We might want to build some more threads first.
12096 (when (and gnus-fetch-old-headers
12097 (eq gnus-headers-retrieved-by 'nov))
12098 (if (eq gnus-fetch-old-headers 'invisible)
12099 (gnus-build-all-threads)
12100 (gnus-build-old-threads)))
12101 ;; Let the Gnus agent mark articles as read.
12103 (gnus-agent-get-undownloaded-list))
12104 ;; Remove list identifiers from subject
12105 (when gnus-list-identifiers
12106 (gnus-summary-remove-list-identifiers))
12107 ;; First and last article in this newsgroup.
12108 (when gnus-newsgroup-headers
12109 (setq gnus-newsgroup-begin
12110 (mail-header-number (car gnus-newsgroup-headers))
12112 (mail-header-number
12113 (gnus-last-element gnus-newsgroup-headers))))
12114 (when gnus-use-scoring
12115 (gnus-possibly-score-headers))))
12117 (defun gnus-summary-insert-old-articles (&optional all)
12118 "Insert all old articles in this group.
12119 If ALL is non-nil, already read articles become readable.
12120 If ALL is a number, fetch this number of articles."
12123 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12126 ;; Some nntp servers lie about their active range. When
12127 ;; this happens, the active range can be in the millions.
12128 ;; Use a compressed range to avoid creating a huge list.
12129 (gnus-range-difference (list gnus-newsgroup-active) old))
12130 (setq len (gnus-range-length older))
12135 (let ((older-range (nreverse older)))
12139 (let* ((r (pop older-range))
12140 (min (if (numberp r) r (car r)))
12141 (max (if (numberp r) r (cdr r))))
12142 (while (and (<= min max)
12147 (setq older (gnus-uncompress-range older))))
12149 (setq older (gnus-uncompress-range older)))
12151 (when (and (numberp gnus-large-newsgroup)
12152 (> len gnus-large-newsgroup))
12153 (let* ((cursor-in-echo-area nil)
12154 (initial (gnus-parameter-large-newsgroup-initial
12155 gnus-newsgroup-name))
12159 "How many articles from %s (%s %d): "
12161 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12162 (if initial "max" "default")
12165 (cons (number-to-string initial)
12167 (unless (string-match "^[ \t]*$" input)
12168 (setq all (string-to-number input))
12170 (let ((older-range (nreverse older)))
12174 (let* ((r (pop older-range))
12175 (min (if (numberp r) r (car r)))
12176 (max (if (numberp r) r (cdr r))))
12177 (while (and (<= min max)
12181 max (1- max))))))))))
12182 (setq older (gnus-uncompress-range older))))
12184 (message "No old news.")
12185 (gnus-summary-insert-articles older)
12186 (gnus-summary-limit (gnus-sorted-nunion old older))))
12187 (gnus-summary-position-point)))
12189 (defun gnus-summary-insert-new-articles ()
12190 "Insert all new articles in this group."
12193 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12194 (old-active gnus-newsgroup-active)
12195 (nnmail-fetched-sources (list t))
12197 (setq gnus-newsgroup-active
12198 (gnus-activate-group gnus-newsgroup-name 'scan))
12199 (setq i (cdr gnus-newsgroup-active))
12200 (while (> i (cdr old-active))
12204 (message "No gnus is bad news")
12205 (gnus-summary-insert-articles new)
12206 (setq gnus-newsgroup-unreads
12207 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12208 (gnus-summary-limit (gnus-sorted-nunion old new))))
12209 (gnus-summary-position-point)))
12211 (gnus-summary-make-all-marking-commands)
12213 (gnus-ems-redefine)
12215 (provide 'gnus-sum)
12217 (run-hooks 'gnus-sum-load-hook)
12219 ;; Local Variables:
12220 ;; coding: iso-8859-1
12223 ;;; gnus-sum.el ends here